Speedup imagery index with which-polygon

(closes #5226)
This commit is contained in:
Bryan Housel
2018-08-16 16:26:01 -04:00
parent ef0636ad01
commit 8b3637e55d
4 changed files with 54 additions and 48 deletions
+2 -16
View File
@@ -9,13 +9,7 @@ import {
import { json as d3_json } from 'd3-request';
import { t } from '../util/locale';
import {
geoExtent,
geoPolygonIntersectsPolygon,
geoSphericalDistance
} from '../geo';
import { geoExtent, geoSphericalDistance } from '../geo';
import { utilDetect } from '../util/detect';
@@ -116,7 +110,7 @@ export function rendererBackgroundSource(data) {
var lat = Math.atan(sinh(Math.PI * (1 - 2 * y / zoomSize)));
switch (this.projection) {
case 'EPSG:4326': // todo: alternative codes of WGS 84?
case 'EPSG:4326':
return {
x: lon * 180 / Math.PI,
y: lat * 180 / Math.PI
@@ -162,14 +156,6 @@ export function rendererBackgroundSource(data) {
};
source.intersects = function(extent) {
extent = extent.polygon();
return !data.polygon || data.polygon.some(function(polygon) {
return geoPolygonIntersectsPolygon(polygon, extent, true);
});
};
source.validZoom = function(z) {
return source.zoomExtent[0] <= z &&
(source.overzoom || source.zoomExtent[1] > z);