mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
+20215
-121
File diff suppressed because it is too large
Load Diff
+11
-6
@@ -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]
|
||||
]];
|
||||
}
|
||||
|
||||
|
||||
@@ -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] &&
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user