mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-23 16:49:40 +02:00
Convert lodah-es and d3 to named imports for geo
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _extend from 'lodash-es/extend';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
geoMetersToLat,
|
geoMetersToLat,
|
||||||
geoMetersToLon
|
geoMetersToLon
|
||||||
@@ -20,7 +21,7 @@ export function geoExtent(min, max) {
|
|||||||
|
|
||||||
geoExtent.prototype = new Array(2);
|
geoExtent.prototype = new Array(2);
|
||||||
|
|
||||||
_.extend(geoExtent.prototype, {
|
_extend(geoExtent.prototype, {
|
||||||
|
|
||||||
equals: function (obj) {
|
equals: function (obj) {
|
||||||
return this[0][0] === obj[0][0] &&
|
return this[0][0] === obj[0][0] &&
|
||||||
|
|||||||
+4
-3
@@ -1,4 +1,5 @@
|
|||||||
import _ from 'lodash';
|
import _every from 'lodash-es/every';
|
||||||
|
import _some from 'lodash-es/some';
|
||||||
|
|
||||||
|
|
||||||
export function geoRoundCoords(c) {
|
export function geoRoundCoords(c) {
|
||||||
@@ -239,7 +240,7 @@ export function geoPointInPolygon(point, polygon) {
|
|||||||
|
|
||||||
|
|
||||||
export function geoPolygonContainsPolygon(outer, inner) {
|
export function geoPolygonContainsPolygon(outer, inner) {
|
||||||
return _.every(inner, function(point) {
|
return _every(inner, function(point) {
|
||||||
return geoPointInPolygon(point, outer);
|
return geoPointInPolygon(point, outer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -258,7 +259,7 @@ export function geoPolygonIntersectsPolygon(outer, inner, checkSegments) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testPoints(outer, inner) {
|
function testPoints(outer, inner) {
|
||||||
return _.some(inner, function(point) {
|
return _some(inner, function(point) {
|
||||||
return geoPointInPolygon(point, outer);
|
return geoPointInPolygon(point, outer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
import * as d3 from 'd3';
|
import {
|
||||||
|
geoMercatorRaw as d3_geoMercatorRaw,
|
||||||
|
geoTransform as d3_geoTransform
|
||||||
|
} from 'd3-geo';
|
||||||
|
|
||||||
|
import {
|
||||||
|
zoomIdentity as d3_zoomIdentity
|
||||||
|
} from 'd3-zoom';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Bypasses features of D3's default projection stream pipeline that are unnecessary:
|
Bypasses features of D3's default projection stream pipeline that are unnecessary:
|
||||||
@@ -7,7 +15,7 @@ import * as d3 from 'd3';
|
|||||||
* Resampling
|
* Resampling
|
||||||
*/
|
*/
|
||||||
export function geoRawMercator() {
|
export function geoRawMercator() {
|
||||||
var project = d3.geoMercatorRaw,
|
var project = d3_geoMercatorRaw,
|
||||||
k = 512 / Math.PI, // scale
|
k = 512 / Math.PI, // scale
|
||||||
x = 0, y = 0, // translate
|
x = 0, y = 0, // translate
|
||||||
clipExtent = [[0, 0], [0, 0]];
|
clipExtent = [[0, 0], [0, 0]];
|
||||||
@@ -48,7 +56,7 @@ export function geoRawMercator() {
|
|||||||
|
|
||||||
|
|
||||||
projection.transform = function(_) {
|
projection.transform = function(_) {
|
||||||
if (!arguments.length) return d3.zoomIdentity.translate(x, y).scale(k);
|
if (!arguments.length) return d3_zoomIdentity.translate(x, y).scale(k);
|
||||||
x = +_.x;
|
x = +_.x;
|
||||||
y = +_.y;
|
y = +_.y;
|
||||||
k = +_.k;
|
k = +_.k;
|
||||||
@@ -56,7 +64,7 @@ export function geoRawMercator() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
projection.stream = d3.geoTransform({
|
projection.stream = d3_geoTransform({
|
||||||
point: function(x, y) {
|
point: function(x, y) {
|
||||||
x = projection([x, y]);
|
x = projection([x, y]);
|
||||||
this.stream.point(x[0], x[1]);
|
this.stream.point(x[0], x[1]);
|
||||||
|
|||||||
Reference in New Issue
Block a user