mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
Add geoVecEquals for strict comparisons
This commit is contained in:
@@ -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] ];
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user