mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-23 08:39:56 +02:00
Added support for localization of address fields
This commit is contained in:
@@ -223,4 +223,52 @@ 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]]] }, properties: { 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]]] }, properties: { 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;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user