Support polygon imagery bounds

Fixes #768
This commit is contained in:
John Firebaugh
2013-08-27 11:25:11 -07:00
parent 4e8cb0b97f
commit e30531277d
4 changed files with 20239 additions and 129 deletions
+20215 -121
View File
File diff suppressed because it is too large Load Diff
+11 -6
View File
@@ -46,15 +46,20 @@ sources.forEach(function(source) {
if (extent.min_zoom || extent.max_zoom) {
im.scaleExtent = [
+(extent.min_zoom || 0),
+(extent.max_zoom || 20)
extent.min_zoom || 0,
extent.max_zoom || 20
];
}
if (extent.bbox) {
im.extents = [[
[+extent.bbox.min_lon, +extent.bbox.min_lat],
[+extent.bbox.max_lon, +extent.bbox.max_lat]
if (extent.polygon) {
im.polygon = extent.polygon;
} else if (extent.bbox) {
im.polygon = [[
[extent.bbox.min_lon, extent.bbox.min_lat],
[extent.bbox.min_lon, extent.bbox.max_lat],
[extent.bbox.max_lon, extent.bbox.max_lat],
[extent.bbox.max_lon, extent.bbox.min_lat],
[extent.bbox.min_lon, extent.bbox.min_lat]
]];
}
+10
View File
@@ -27,6 +27,16 @@ _.extend(iD.geo.Extent.prototype, {
(this[0][1] + this[1][1]) / 2];
},
polygon: function() {
return [
[this[0][0], this[0][1]],
[this[0][0], this[1][1]],
[this[1][0], this[1][1]],
[this[1][0], this[0][1]],
[this[0][0], this[0][1]]
]
},
intersects: function(obj) {
if (!(obj instanceof iD.geo.Extent)) obj = new iD.geo.Extent(obj);
return obj[0][0] <= this[1][0] &&
+3 -2
View File
@@ -30,8 +30,9 @@ iD.BackgroundSource = function(data) {
};
source.intersects = function(extent) {
return !data.extents || data.extents.some(function(ex) {
return iD.geo.Extent(ex).intersects(extent);
extent = extent.polygon();
return !data.polygon || data.polygon.some(function(polygon) {
return iD.geo.polygonIntersectsPolygon(polygon, extent);
});
};