diff --git a/modules/geo/geo.js b/modules/geo/geo.js index 318283931..7a4fe121a 100644 --- a/modules/geo/geo.js +++ b/modules/geo/geo.js @@ -8,6 +8,11 @@ var EQUATORIAL_RADIUS = 6356752.314245179; var POLAR_RADIUS = 6378137.0; +// vector addition +export function geoVecEquals(a, b) { + return (a[0] === b[0]) && (a[1] === b[1]); +} + // vector addition export function geoVecAdd(a, b) { return [ a[0] + b[0], a[1] + b[1] ]; diff --git a/modules/geo/index.js b/modules/geo/index.js index 2a1c8fa31..95bba82c5 100644 --- a/modules/geo/index.js +++ b/modules/geo/index.js @@ -23,6 +23,7 @@ export { geoPolygonIntersectsPolygon } from './geo.js'; export { geoScaleToZoom } from './geo.js'; export { geoSphericalDistance } from './geo.js'; export { geoVecAdd } from './geo.js'; +export { geoVecEquals } from './geo.js'; export { geoVecFloor } from './geo.js'; export { geoVecSubtract } from './geo.js'; export { geoVecScale } from './geo.js'; diff --git a/test/spec/geo/geo.js b/test/spec/geo/geo.js index c9762e051..585e7a2e7 100644 --- a/test/spec/geo/geo.js +++ b/test/spec/geo/geo.js @@ -1,5 +1,13 @@ describe('iD.geo', function() { + describe('geoVecEquals', function() { + it('tests vectors for equality', function() { + expect(iD.geoVecEquals([1, 2], [1, 2])).to.be.true; + expect(iD.geoVecEquals([1, 2], [1, 0])).to.be.false; + expect(iD.geoVecEquals([1, 2], [2, 1])).to.be.false; + }); + }); + describe('geoVecAdd', function() { it('adds vectors', function() { expect(iD.geoVecAdd([1, 2], [3, 4])).to.eql([4, 6]);