diff --git a/js/id/geo.js b/js/id/geo.js index 36ca5fb3a..8978828b0 100644 --- a/js/id/geo.js +++ b/js/id/geo.js @@ -135,33 +135,3 @@ iD.geo.pathLength = function(path) { } return length; }; - -iD.geo.pointInFeature = function(point, feature) { - if (feature.bounds) { - var bounds = feature.bounds; - - if (point[0] < bounds[0][0] || point[0] > bounds[1][0] || point[1] < bounds[0][1] || point[1] > bounds[1][1]) - return false; - } - - if (feature.geometry.type === 'Polygon') { - return _.every(feature.geometry.coordinates, function (ring, i) { - if (i === 0) - return iD.geo.pointInPolygon(point, ring); - - return !iD.geo.pointInPolygon(point, ring); - }); - } - else if (feature.geometry.type === 'MultiPolygon') { - return _.some(feature.geometry.coordinates, function (polygon) { - return _.every(polygon, function (ring, i) { - if (i === 0) - return iD.geo.pointInPolygon(point, ring); - - return !iD.geo.pointInPolygon(point, ring); - }); - }); - } - - return false; -}; diff --git a/test/spec/geo.js b/test/spec/geo.js index 38b2514c4..a6a86ecb2 100644 --- a/test/spec/geo.js +++ b/test/spec/geo.js @@ -223,52 +223,4 @@ describe('iD.geo', function() { expect(iD.geo.pathLength(path)).to.eql(0); }); }); - - describe('.pointInFeature', function() { - it('point should be in a polygon feature', function() { - var feature = { geometry: { type: 'Polygon', coordinates: [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]] } }; - var point = [0.5, 0.5]; - expect(iD.geo.pointInFeature(point, feature)).to.be.true; - }); - it('point should not be in a polygon feature with a hole', function() { - var feature = { geometry: { type: 'Polygon', coordinates: [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]], [[0.1, 0.1], [0.1, 0.9], [0.9, 0.9], [0.9, 0.1], [0.1, 0.1]]] } }; - var point = [0.5, 0.5]; - expect(iD.geo.pointInFeature(point, feature)).to.be.false; - }); - it('point should be in a polygon feature with a hole', function() { - var feature = { geometry: { type: 'Polygon', coordinates: [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]], [[0.1, 0.1], [0.1, 0.9], [0.9, 0.9], [0.9, 0.1], [0.1, 0.1]]] } }; - var point = [0.05, 0.05]; - expect(iD.geo.pointInFeature(point, feature)).to.be.true; - }); - it('point should be in a polygon feature with bounds', function() { - var feature = { geometry: { type: 'Polygon', coordinates: [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]] }, bounds: [[0, 0], [1, 1]] }; - var point = [0.5, 0.5]; - expect(iD.geo.pointInFeature(point, feature)).to.be.true; - }); - it('point should not be in a polygon feature with bounds', function() { - var feature = { geometry: { type: 'Polygon', coordinates: [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]] }, bounds: [[0, 0], [1, 1]] }; - var point = [0.5, 1.5]; - expect(iD.geo.pointInFeature(point, feature)).to.be.false; - }); - it('point should not be in a point feature', function() { - var feature = { geometry: { type: 'Point', coordinates: [0, 0] } }; - var point = [0.5, 0.5]; - expect(iD.geo.pointInFeature(point, feature)).to.be.false; - }); - it('point should be in a multipolygon feature', function() { - var feature = { geometry: { type: 'MultiPolygon', coordinates: [[[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]], [[[2, 2], [2, 3], [3, 3], [3, 2], [2, 2]]]] } }; - var point = [0.5, 0.5]; - expect(iD.geo.pointInFeature(point, feature)).to.be.true; - }); - it('point should be in a multipolygon feature in second polygon', function() { - var feature = { geometry: { type: 'MultiPolygon', coordinates: [[[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]], [[[2, 2], [2, 3], [3, 3], [3, 2], [2, 2]]]] } }; - var point = [2.5, 2.5]; - expect(iD.geo.pointInFeature(point, feature)).to.be.true; - }); - it('point should not be in a multipolygon feature', function() { - var feature = { geometry: { type: 'MultiPolygon', coordinates: [[[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]], [[[2, 2], [2, 3], [3, 3], [3, 2], [2, 2]]]] } }; - var point = [0.5, 1.5]; - expect(iD.geo.pointInFeature(point, feature)).to.be.false; - }); - }); });