Added support for localization of address fields

This commit is contained in:
Christian Schwarz
2014-06-03 22:49:42 +02:00
parent 4f70731dfb
commit b3acd56bbb
8 changed files with 11211 additions and 39 deletions
+48
View File
@@ -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;
});
});
});