mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00: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 {
|
||||
geoMetersToLat,
|
||||
geoMetersToLon
|
||||
@@ -20,7 +21,7 @@ export function geoExtent(min, max) {
|
||||
|
||||
geoExtent.prototype = new Array(2);
|
||||
|
||||
_.extend(geoExtent.prototype, {
|
||||
_extend(geoExtent.prototype, {
|
||||
|
||||
equals: function (obj) {
|
||||
return this[0][0] === obj[0][0] &&
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import _ from 'lodash';
|
||||
import _every from 'lodash-es/every';
|
||||
import _some from 'lodash-es/some';
|
||||
|
||||
|
||||
export function geoRoundCoords(c) {
|
||||
@@ -239,7 +240,7 @@ export function geoPointInPolygon(point, polygon) {
|
||||
|
||||
|
||||
export function geoPolygonContainsPolygon(outer, inner) {
|
||||
return _.every(inner, function(point) {
|
||||
return _every(inner, function(point) {
|
||||
return geoPointInPolygon(point, outer);
|
||||
});
|
||||
}
|
||||
@@ -258,7 +259,7 @@ export function geoPolygonIntersectsPolygon(outer, inner, checkSegments) {
|
||||
}
|
||||
|
||||
function testPoints(outer, inner) {
|
||||
return _.some(inner, function(point) {
|
||||
return _some(inner, function(point) {
|
||||
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:
|
||||
@@ -7,7 +15,7 @@ import * as d3 from 'd3';
|
||||
* Resampling
|
||||
*/
|
||||
export function geoRawMercator() {
|
||||
var project = d3.geoMercatorRaw,
|
||||
var project = d3_geoMercatorRaw,
|
||||
k = 512 / Math.PI, // scale
|
||||
x = 0, y = 0, // translate
|
||||
clipExtent = [[0, 0], [0, 0]];
|
||||
@@ -48,7 +56,7 @@ export function geoRawMercator() {
|
||||
|
||||
|
||||
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;
|
||||
y = +_.y;
|
||||
k = +_.k;
|
||||
@@ -56,7 +64,7 @@ export function geoRawMercator() {
|
||||
};
|
||||
|
||||
|
||||
projection.stream = d3.geoTransform({
|
||||
projection.stream = d3_geoTransform({
|
||||
point: function(x, y) {
|
||||
x = projection([x, y]);
|
||||
this.stream.point(x[0], x[1]);
|
||||
|
||||
Reference in New Issue
Block a user