function shps = loadKML(filename,boundary)

xDoc = xmlread(filename);

allListitems = xDoc.getElementsByTagName('coordinates');
nshps = allListitems.getLength;
shps=[];
for k = 0:(nshps-1)
    thisListitem = allListitems.item(k);
    thisElement = thisListitem.item(0);
    text = toCharArray(getTextContent(thisElement));
    res = textscan(text,'%f,%f,%f');
    
    shp = [];
    shp.X = res{1}';
    shp.Y = res{2}';
    
    [shp.X,shp.Y,shp.Zone] = ll2utm(shp.Y,shp.X);
    
    %Ignore vectors that are completely outside boundary
    if(~isempty(boundary))
        inside = isPointInPolygon([shp.X',shp.Y'],boundary);
        if(~any(inside))
            continue;
        end
    end
    
    shp.BoundingBox(1) = min(shp.X);
    shp.BoundingBox(2) = min(shp.Y);
    shp.BoundingBox(3) = max(shp.X);
    shp.BoundingBox(4) = max(shp.Y);
    shp.offsets = zeros(1,2);
    
    shps = [shps;shp];
end


