Socket
Socket
Sign inDemoInstall

geojson-equality

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson-equality - npm Package Compare versions

Comparing version 0.1.7 to 0.2.0

36

dist/geojson-equality.js

@@ -25,4 +25,8 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o;"undefined"!=typeof window?o=window:"undefined"!=typeof global?o=global:"undefined"!=typeof self&&(o=self),o.GeojsonEquality=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){

break;
case 'GeometryCollection':
return this.compareGeometryCollection(g1, g2);
case 'Feature':
return this.compareFeature(g1, g2);
case 'FeatureCollection':
return this.compareFeatureCollection(g1, g2);
default:

@@ -131,2 +135,17 @@ if (g1.type.indexOf('Multi') === 0) {

Equality.prototype.compareGeometryCollection= function(g1,g2) {
if (
!sameLength(g1.geometries, g2.geometries) ||
!this.compareBBox(g1,g2)
) {
return false;
}
for (var i=0; i < g1.geometries.length; i++) {
if (!this.compare(g1.geometries[i], g2.geometries[i])) {
return false;
}
}
return true
};
Equality.prototype.compareFeature = function(g1,g2) {

@@ -143,2 +162,17 @@ if (

Equality.prototype.compareFeatureCollection = function(g1,g2) {
if (
!sameLength(g1.features, g2.features) ||
!this.compareBBox(g1,g2)
) {
return false;
}
for (var i=0; i < g1.features.length; i++) {
if (!this.compare(g1.features[i], g2.features[i])) {
return false;
}
}
return true
};
Equality.prototype.compareBBox = function(g1,g2) {

@@ -183,3 +217,3 @@ if (

// equivalence is determined by ==.
} else if (typeof actual != 'object' && typeof expected != 'object') {
} else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {
return opts.strict ? actual === expected : actual == expected;

@@ -186,0 +220,0 @@

2

dist/geojson-equality.min.js

@@ -1,1 +0,1 @@

!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.GeojsonEquality=e()}}(function(){return function e(t,r,o){function n(c,u){if(!r[c]){if(!t[c]){var p="function"==typeof require&&require;if(!u&&p)return p(c,!0);if(i)return i(c,!0);var s=new Error("Cannot find module '"+c+"'");throw s.code="MODULE_NOT_FOUND",s}var a=r[c]={exports:{}};t[c][0].call(a.exports,function(e){var r=t[c][1][e];return n(r?r:e)},a,a.exports,e,t,r,o)}return r[c].exports}for(var i="function"==typeof require&&require,c=0;c<o.length;c++)n(o[c]);return n}({1:[function(e,t){function r(e){return e.coordinates.map(function(t){return{type:e.type.replace("Multi",""),coordinates:t}})}function o(e,t){return e.hasOwnProperty("coordinates")?e.coordinates.length===t.coordinates.length:e.length===t.length}function n(e,t){return i(e,t,{strict:!0})}var i=e("deep-equal"),c=function(e){this.precision=e&&e.precision?e.precision:17,this.direction=e&&e.direction?e.direction:!1,this.pseudoNode=e&&e.pseudoNode?e.pseudoNode:!1,this.objectComparator=e&&e.objectComparator?e.objectComparator:n};c.prototype.compare=function(e,t){if(e.type!==t.type||!o(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates,0,!1);case"Polygon":return this.comparePolygon(e,t);case"Feature":return this.compareFeature(e,t);default:if(0===e.type.indexOf("Multi")){var n=this,i=r(e),c=r(t);return i.every(function(e){return this.some(function(t){return n.compare(e,t)})},c)}}return!1},c.prototype.compareCoord=function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r].toFixed(this.precision)!==t[r].toFixed(this.precision))return!1;return!0},c.prototype.compareLine=function(e,t,r,n){if(!o(e,t))return!1;var i=this.pseudoNode?e:this.removePseudo(e),c=this.pseudoNode?t:this.removePseudo(t);if(!n||this.compareCoord(i[0],c[0])||(c=this.fixStartIndex(c,i))){var u=this.compareCoord(i[r],c[r]);return this.direction||u?this.comparePath(i,c):this.compareCoord(i[r],c[c.length-(1+r)])?this.comparePath(i.slice().reverse(),c):!1}},c.prototype.fixStartIndex=function(e,t){for(var r,o=-1,n=0;n<e.length;n++)if(this.compareCoord(e[n],t[0])){o=n;break}return o>=0&&(r=[].concat(e.slice(o,e.length),e.slice(1,o+1))),r},c.prototype.comparePath=function(e,t){var r=this;return e.every(function(e,t){return r.compareCoord(e,this[t])},t)},c.prototype.comparePolygon=function(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){var r=e.coordinates.slice(1,e.coordinates.length),o=t.coordinates.slice(1,t.coordinates.length),n=this;return r.every(function(e){return this.some(function(t){return n.compareLine(e,t,1,!0)})},o)}return!1},c.prototype.compareFeature=function(e,t){return e.id===t.id&&this.objectComparator(e.properties,t.properties)&&this.compareBBox(e,t)?this.compare(e.geometry,t.geometry):!1},c.prototype.compareBBox=function(e,t){return!e.bbox&&!t.bbox||e.bbox&&t.bbox&&this.compareCoord(e.bbox,t.bbox)?!0:!1},c.prototype.removePseudo=function(e){return e},t.exports=c},{"deep-equal":2}],2:[function(e,t){function r(e){return null===e||void 0===e}function o(e){return e&&"object"==typeof e&&"number"==typeof e.length?"function"!=typeof e.copy||"function"!=typeof e.slice?!1:e.length>0&&"number"!=typeof e[0]?!1:!0:!1}function n(e,t,n){var s,a;if(r(e)||r(t))return!1;if(e.prototype!==t.prototype)return!1;if(u(e))return u(t)?(e=i.call(e),t=i.call(t),p(e,t,n)):!1;if(o(e)){if(!o(t))return!1;if(e.length!==t.length)return!1;for(s=0;s<e.length;s++)if(e[s]!==t[s])return!1;return!0}try{var f=c(e),l=c(t)}catch(d){return!1}if(f.length!=l.length)return!1;for(f.sort(),l.sort(),s=f.length-1;s>=0;s--)if(f[s]!=l[s])return!1;for(s=f.length-1;s>=0;s--)if(a=f[s],!p(e[a],t[a],n))return!1;return typeof e==typeof t}var i=Array.prototype.slice,c=e("./lib/keys.js"),u=e("./lib/is_arguments.js"),p=t.exports=function(e,t,r){return r||(r={}),e===t?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():"object"!=typeof e&&"object"!=typeof t?r.strict?e===t:e==t:n(e,t,r)}},{"./lib/is_arguments.js":3,"./lib/keys.js":4}],3:[function(e,t,r){function o(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function n(e){return e&&"object"==typeof e&&"number"==typeof e.length&&Object.prototype.hasOwnProperty.call(e,"callee")&&!Object.prototype.propertyIsEnumerable.call(e,"callee")||!1}var i="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();r=t.exports=i?o:n,r.supported=o,r.unsupported=n},{}],4:[function(e,t,r){function o(e){var t=[];for(var r in e)t.push(r);return t}r=t.exports="function"==typeof Object.keys?Object.keys:o,r.shim=o},{}]},{},[1])(1)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.GeojsonEquality=e()}}(function(){return function e(t,r,o){function n(c,u){if(!r[c]){if(!t[c]){var s="function"==typeof require&&require;if(!u&&s)return s(c,!0);if(i)return i(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var a=r[c]={exports:{}};t[c][0].call(a.exports,function(e){var r=t[c][1][e];return n(r?r:e)},a,a.exports,e,t,r,o)}return r[c].exports}for(var i="function"==typeof require&&require,c=0;c<o.length;c++)n(o[c]);return n}({1:[function(e,t,r){function o(e){return e.coordinates.map(function(t){return{type:e.type.replace("Multi",""),coordinates:t}})}function n(e,t){return e.hasOwnProperty("coordinates")?e.coordinates.length===t.coordinates.length:e.length===t.length}function i(e,t){return c(e,t,{strict:!0})}var c=e("deep-equal"),u=function(e){this.precision=e&&e.precision?e.precision:17,this.direction=e&&e.direction?e.direction:!1,this.pseudoNode=e&&e.pseudoNode?e.pseudoNode:!1,this.objectComparator=e&&e.objectComparator?e.objectComparator:i};u.prototype.compare=function(e,t){if(e.type!==t.type||!n(e,t))return!1;switch(e.type){case"Point":return this.compareCoord(e.coordinates,t.coordinates);case"LineString":return this.compareLine(e.coordinates,t.coordinates,0,!1);case"Polygon":return this.comparePolygon(e,t);case"GeometryCollection":return this.compareGeometryCollection(e,t);case"Feature":return this.compareFeature(e,t);case"FeatureCollection":return this.compareFeatureCollection(e,t);default:if(0===e.type.indexOf("Multi")){var r=this,i=o(e),c=o(t);return i.every(function(e){return this.some(function(t){return r.compare(e,t)})},c)}}return!1},u.prototype.compareCoord=function(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(e[r].toFixed(this.precision)!==t[r].toFixed(this.precision))return!1;return!0},u.prototype.compareLine=function(e,t,r,o){if(!n(e,t))return!1;var i=this.pseudoNode?e:this.removePseudo(e),c=this.pseudoNode?t:this.removePseudo(t);if(!o||this.compareCoord(i[0],c[0])||(c=this.fixStartIndex(c,i))){var u=this.compareCoord(i[r],c[r]);return this.direction||u?this.comparePath(i,c):this.compareCoord(i[r],c[c.length-(1+r)])?this.comparePath(i.slice().reverse(),c):!1}},u.prototype.fixStartIndex=function(e,t){for(var r,o=-1,n=0;n<e.length;n++)if(this.compareCoord(e[n],t[0])){o=n;break}return o>=0&&(r=[].concat(e.slice(o,e.length),e.slice(1,o+1))),r},u.prototype.comparePath=function(e,t){var r=this;return e.every(function(e,t){return r.compareCoord(e,this[t])},t)},u.prototype.comparePolygon=function(e,t){if(this.compareLine(e.coordinates[0],t.coordinates[0],1,!0)){var r=e.coordinates.slice(1,e.coordinates.length),o=t.coordinates.slice(1,t.coordinates.length),n=this;return r.every(function(e){return this.some(function(t){return n.compareLine(e,t,1,!0)})},o)}return!1},u.prototype.compareGeometryCollection=function(e,t){if(!n(e.geometries,t.geometries)||!this.compareBBox(e,t))return!1;for(var r=0;r<e.geometries.length;r++)if(!this.compare(e.geometries[r],t.geometries[r]))return!1;return!0},u.prototype.compareFeature=function(e,t){return e.id===t.id&&this.objectComparator(e.properties,t.properties)&&this.compareBBox(e,t)?this.compare(e.geometry,t.geometry):!1},u.prototype.compareFeatureCollection=function(e,t){if(!n(e.features,t.features)||!this.compareBBox(e,t))return!1;for(var r=0;r<e.features.length;r++)if(!this.compare(e.features[r],t.features[r]))return!1;return!0},u.prototype.compareBBox=function(e,t){return!e.bbox&&!t.bbox||e.bbox&&t.bbox&&this.compareCoord(e.bbox,t.bbox)?!0:!1},u.prototype.removePseudo=function(e){return e},t.exports=u},{"deep-equal":2}],2:[function(e,t,r){function o(e){return null===e||void 0===e}function n(e){return e&&"object"==typeof e&&"number"==typeof e.length?"function"!=typeof e.copy||"function"!=typeof e.slice?!1:e.length>0&&"number"!=typeof e[0]?!1:!0:!1}function i(e,t,r){var i,a;if(o(e)||o(t))return!1;if(e.prototype!==t.prototype)return!1;if(s(e))return s(t)?(e=c.call(e),t=c.call(t),p(e,t,r)):!1;if(n(e)){if(!n(t))return!1;if(e.length!==t.length)return!1;for(i=0;i<e.length;i++)if(e[i]!==t[i])return!1;return!0}try{var f=u(e),l=u(t)}catch(h){return!1}if(f.length!=l.length)return!1;for(f.sort(),l.sort(),i=f.length-1;i>=0;i--)if(f[i]!=l[i])return!1;for(i=f.length-1;i>=0;i--)if(a=f[i],!p(e[a],t[a],r))return!1;return typeof e==typeof t}var c=Array.prototype.slice,u=e("./lib/keys.js"),s=e("./lib/is_arguments.js"),p=t.exports=function(e,t,r){return r||(r={}),e===t?!0:e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():!e||!t||"object"!=typeof e&&"object"!=typeof t?r.strict?e===t:e==t:i(e,t,r)}},{"./lib/is_arguments.js":3,"./lib/keys.js":4}],3:[function(e,t,r){function o(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function n(e){return e&&"object"==typeof e&&"number"==typeof e.length&&Object.prototype.hasOwnProperty.call(e,"callee")&&!Object.prototype.propertyIsEnumerable.call(e,"callee")||!1}var i="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();r=t.exports=i?o:n,r.supported=o,r.unsupported=n},{}],4:[function(e,t,r){function o(e){var t=[];for(var r in e)t.push(r);return t}r=t.exports="function"==typeof Object.keys?Object.keys:o,r.shim=o},{}]},{},[1])(1)});

@@ -24,4 +24,8 @@ //index.js

break;
case 'GeometryCollection':
return this.compareGeometryCollection(g1, g2);
case 'Feature':
return this.compareFeature(g1, g2);
case 'FeatureCollection':
return this.compareFeatureCollection(g1, g2);
default:

@@ -130,2 +134,17 @@ if (g1.type.indexOf('Multi') === 0) {

Equality.prototype.compareGeometryCollection= function(g1,g2) {
if (
!sameLength(g1.geometries, g2.geometries) ||
!this.compareBBox(g1,g2)
) {
return false;
}
for (var i=0; i < g1.geometries.length; i++) {
if (!this.compare(g1.geometries[i], g2.geometries[i])) {
return false;
}
}
return true
};
Equality.prototype.compareFeature = function(g1,g2) {

@@ -142,2 +161,17 @@ if (

Equality.prototype.compareFeatureCollection = function(g1,g2) {
if (
!sameLength(g1.features, g2.features) ||
!this.compareBBox(g1,g2)
) {
return false;
}
for (var i=0; i < g1.features.length; i++) {
if (!this.compare(g1.features[i], g2.features[i])) {
return false;
}
}
return true
};
Equality.prototype.compareBBox = function(g1,g2) {

@@ -144,0 +178,0 @@ if (

{
"name": "geojson-equality",
"version": "0.1.7",
"version": "0.2.0",
"description": "Check two valid geojson geometries for equality.",

@@ -39,5 +39,5 @@ "main": "index.js",

"mocha": "~1.21.4",
"uglify-js": "~2.4.15",
"uglify-js": "^2.6.0",
"watchify": "~1.0.2"
}
}

@@ -271,2 +271,194 @@ var expect = require('chai').expect,

describe ('geojson-equality for FeatureCollection', function() {
it ('will not be equal with different number of features', function() {
var f1 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [0, 0] }
}]
};
var f2 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [0, 0] }
},{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [0, 0] }
}]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal with different features', function() {
var f1 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [0, 0] }
}]
};
var f2 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [1, 1] }
}]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal with different order of features', function() {
var f1 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [0, 0] }
},{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [1, 1] }
}]
};
var f2 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [1, 1] }
},{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [0, 0] }
}]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will be equal with equal features', function() {
var f1 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [1, 1] }
}]
};
var f2 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [1, 1] }
}]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.true;
});
it ('will be equal with equal with no features', function() {
var f1 = {
"type": "FeatureCollection",
"features": []
};
var f2 = {
"type": "FeatureCollection",
"features": []
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.true;
});
it ('will use a custom comparator if provided', function() {
var f1 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "id1",
"properties": {"foo_123": "bar"},
"geometry": { "type": "Polygon", "coordinates": [
[[40, 20], [31, 10], [30, 20], [30, 10], [10, 40]]
]}
}]
};
var f2 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "id1",
"properties": {"foo_456": "bar"},
"geometry": { "type": "Polygon", "coordinates": [
[[40, 20], [31, 10], [30, 20], [30, 10], [10, 40]]
]}
}]
};
var eq = new Equality({objectComparator: function(obj1, obj2) {
return ('foo_123' in obj1 && 'foo_456' in obj2);
}});
expect(eq.compare(f1, f2)).to.be.true;
});
it ('will not be equal if one has bbox and other not', function() {
var f1 = {"type": "FeatureCollection", "features": [], "bbox": [1, 2, 3, 4]},
f2 = {"type": "FeatureCollection", "features": "[]"},
eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal if bboxes are not equal', function() {
var f1 = {"type": "FeatureCollection", "features": [], "bbox": [1, 2, 3, 4]},
f2 = {"type": "FeatureCollection", "features": [], "bbox": [1, 2, 3, 5]},
eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('equal feature collections with bboxes', function() {
var f1 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "id1",
"properties": {"foo": "bar1"},
"geometry": { "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 10]]
]}
}],
"bbox": [10, 10, 41, 40]
};
var f2 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "id1",
"properties": {"foo": "bar1"},
"geometry": { "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 10]]
]}
}],
"bbox": [10, 10, 41, 40]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.true;
});
it ('not equal features with equal bboxes', function() {
var f1 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "id1",
"properties": {"foo": "bar1"},
"geometry": { "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 10]]
]}
}],
"bbox": [10, 10, 41, 40]
};
var f2 = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": "id1",
"properties": {"foo": "bar1"},
"geometry": { "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 1]]
]}
}],
"bbox": [10, 10, 41, 40]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
});
describe('geojson-equality for MultiPoints', function() {

@@ -366,1 +558,124 @@ var g1 = { "type": "MultiPoint", "coordinates": [

describe ('geojson-equality for GeometryCollection', function() {
it ('will not be equal with different number of geometries', function() {
var f1 = {
"type": "GeometryCollection",
"geometries": [{ "type": "Point", "coordinates": [0, 0] }]
};
var f2 = {
"type": "GeometryCollection",
"geometries": [
{ "type": "Point", "coordinates": [0, 0] },
{ "type": "Point", "coordinates": [0, 0] }
]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal with different geometries', function() {
var f1 = {
"type": "GeometryCollection",
"geometries": [{ "type": "Point", "coordinates": [0, 0] }]
};
var f2 = {
"type": "GeometryCollection",
"geometries": [{ "type": "Point", "coordinates": [1, 1] }]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal with different order of geometries', function() {
var f1 = {
"type": "GeometryCollection",
"geometries": [
{ "type": "Point", "coordinates": [0, 0] },
{ "type": "Point", "coordinates": [1, 1] }
]
};
var f2 = {
"type": "GeometryCollection",
"geometries": [
{ "type": "Point", "coordinates": [1, 1] },
{ "type": "Point", "coordinates": [0, 0] }
]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will be equal with equal geometries', function() {
var f1 = {
"type": "GeometryCollection",
"geometries": [{ "type": "Point", "coordinates": [0, 0] }]
};
var f2 = {
"type": "GeometryCollection",
"geometries": [{ "type": "Point", "coordinates": [0, 0] }]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.true;
});
it ('will be equal with equal with no geometries', function() {
var f1 = {
"type": "GeometryCollection",
"geometries": []
};
var f2 = {
"type": "GeometryCollection",
"geometries": []
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.true;
});
it ('will not be equal if one has bbox and other not', function() {
var f1 = {"type": "GeometryCollection", "geometries": [], "bbox": [1, 2, 3, 4]},
f2 = {"type": "GeometryCollection", "geometries": "[]"},
eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal if bboxes are not equal', function() {
var f1 = {"type": "GeometryCollection", "geometries": [], "bbox": [1, 2, 3, 4]},
f2 = {"type": "GeometryCollection", "geometries": [], "bbox": [1, 2, 3, 5]},
eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('equal geometry collections with bboxes', function() {
var f1 = {
"type": "GeometryCollection",
"geometries": [{ "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 10]]
]}
],
"bbox": [10, 10, 41, 40]
};
var f2 = {
"type": "GeometryCollection",
"geometries": [{ "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 10]]
]}
],
"bbox": [10, 10, 41, 40]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.true;
});
it ('not equal geometries with equal bboxes', function() {
var f1 = {
"type": "GeometryCollection",
"geometries": [{ "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 10]]
]}
],
"bbox": [10, 10, 41, 40]
};
var f2 = {
"type": "GeometryCollection",
"geometries": [{ "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 1]]
]}
],
"bbox": [10, 10, 41, 40]
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc