all these changes

This commit is contained in:
Jake Kasper
2026-04-09 13:19:47 -05:00
parent e83a51a051
commit 65315f36d1
39102 changed files with 7932979 additions and 567 deletions

2
frontend/node_modules/geojson-equality/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules

22
frontend/node_modules/geojson-equality/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014 Gagan Bansal
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

78
frontend/node_modules/geojson-equality/README.md generated vendored Normal file
View File

@@ -0,0 +1,78 @@
# geojson-equality
Check two valid geojson geometries for equality.
## installation
```
npm install geojson-equality
```
## usage
```javascript
var GeojsonEquality = require('geojson-equality');
var eq = new GeojsonEquality();
var g1 = { "type": "Polygon", "coordinates": [
[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]
]};
var g2 = { "type": "Polygon", "coordinates": [
[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]
]};
eq.compare(g1,g2); // returns true
var g3 = { "type": "Polygon", "coordinates": [
[[30o, 100], [400, 400], [200, 400], [100, 200], [300, 100]]
]};
eq.compare(g1,g3); // returns false
```
For including in browser, download file [geojson-equality.min.js](//raw.githubusercontent.com/geosquare/geojson-equality/master/dist/geojson-equality.min.js)
```html
<script type="text/javascipt" src="path/to/geojson-equality.min.js"></script>
```
This create a global variable 'GeojsonEquality'
GeojsonEquality class can be initiated with many options that are used to match the geojson.
* **precision** number as floating points precision required. Defualt is **17**
```javascript
var g1 = { "type": "Point", "coordinates": [30.2, 10] };
var g2 = { "type": "Point", "coordinates": [30.22233, 10] };
var eq = new GeojsonEqaulity({precision: 3});
eq.compare(g1,g2); // returns false
var eq = new GeojsonEqaulity({precision: 1});
eq.compare(g1,g2); // returns true
```
* **direction** true | false, direction of LineString or Polygon (orientation) is ignored if false. Default is **false**.
```javascript
var g1 = { "type": "LineString", "coordinates":
[ [30, 10], [10, 30], [40, 40] ] };
var g2 = { "type": "LineString", "coordinates":
[ [40, 40], [10, 30], [30, 10] ] };
var eq = new GeojsonEqaulity({direction: false});
eq.compare(g1,g2); // returns true
var eq = new GeojsonEqaulity({direction: true});
eq.compare(g1,g2); // returns false
```
* **objectComparator** function, custom function for use in comparing Feature properties. Default is a shallow comparison.
```javascript
// using lodash isEqual to deep comparison
var isEqual = require('lodash/lang/isEqual')
var eq = new GeojsonEqaulity({objectComparator: isEqual});
```
## developing
Once you run
```npm install```
then for running test
```npm run test```
to create build
```npm run build```
## license
This project is licensed under the terms of the MIT license.

View File

@@ -0,0 +1,295 @@
!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){
//index.js
var deepEqual = require('deep-equal');
var Equality = function(opt) {
this.precision = opt && opt.precision ? opt.precision : 17;
this.direction = opt && opt.direction ? opt.direction : false;
this.pseudoNode = opt && opt.pseudoNode ? opt.pseudoNode : false;
this.objectComparator = opt && opt.objectComparator ? opt.objectComparator : objectComparator;
};
Equality.prototype.compare = function(g1,g2) {
if (g1.type !== g2.type || !sameLength(g1,g2)) return false;
switch(g1.type) {
case 'Point':
return this.compareCoord(g1.coordinates, g2.coordinates);
break;
case 'LineString':
return this.compareLine(g1.coordinates, g2.coordinates,0,false);
break;
case 'Polygon':
return this.comparePolygon(g1,g2);
break;
case 'Feature':
return this.compareFeature(g1, g2);
default:
if (g1.type.indexOf('Multi') === 0) {
var context = this;
var g1s = explode(g1);
var g2s = explode(g2);
return g1s.every(function(g1part) {
return this.some(function(g2part) {
return context.compare(g1part,g2part);
});
},g2s);
}
}
return false;
};
function explode(g) {
return g.coordinates.map(function(part) {
return {
type: g.type.replace('Multi', ''),
coordinates: part}
});
}
//compare length of coordinates/array
function sameLength(g1,g2) {
return g1.hasOwnProperty('coordinates') ?
g1.coordinates.length === g2.coordinates.length
: g1.length === g2.length;
}
// compare the two coordinates [x,y]
Equality.prototype.compareCoord = function(c1,c2) {
if (c1.length !== c2.length) {
return false;
}
for (var i=0; i < c1.length; i++) {
if (c1[i].toFixed(this.precision) !== c2[i].toFixed(this.precision)) {
return false;
}
}
return true;
};
Equality.prototype.compareLine = function(path1,path2,ind,isPoly) {
if (!sameLength(path1,path2)) return false;
var p1 = this.pseudoNode ? path1 : this.removePseudo(path1);
var p2 = this.pseudoNode ? path2 : this.removePseudo(path2);
if (isPoly && !this.compareCoord(p1[0],p2[0])) {
// fix start index of both to same point
p2 = this.fixStartIndex(p2,p1);
if(!p2) return;
}
// for linestring ind =0 and for polygon ind =1
var sameDirection = this.compareCoord(p1[ind],p2[ind]);
if (this.direction || sameDirection
) {
return this.comparePath(p1, p2);
} else {
if (this.compareCoord(p1[ind],p2[p2.length - (1+ind)])
) {
return this.comparePath(p1.slice().reverse(), p2);
}
return false;
}
};
Equality.prototype.fixStartIndex = function(sourcePath,targetPath) {
//make sourcePath first point same as of targetPath
var correctPath,ind = -1;
for (var i=0; i< sourcePath.length; i++) {
if(this.compareCoord(sourcePath[i],targetPath[0])) {
ind = i;
break;
}
}
if (ind >= 0) {
correctPath = [].concat(
sourcePath.slice(ind,sourcePath.length),
sourcePath.slice(1,ind+1));
}
return correctPath;
};
Equality.prototype.comparePath = function (p1,p2) {
var cont = this;
return p1.every(function(c,i) {
return cont.compareCoord(c,this[i]);
},p2);
};
Equality.prototype.comparePolygon = function(g1,g2) {
if (this.compareLine(g1.coordinates[0],g2.coordinates[0],1,true)) {
var holes1 = g1.coordinates.slice(1,g1.coordinates.length);
var holes2 = g2.coordinates.slice(1,g2.coordinates.length);
var cont = this;
return holes1.every(function(h1) {
return this.some(function(h2) {
return cont.compareLine(h1,h2,1,true);
});
},holes2);
} else {
return false;
}
};
Equality.prototype.compareFeature = function(g1,g2) {
if (
g1.id !== g2.id ||
!this.objectComparator(g1.properties, g2.properties) ||
!this.compareBBox(g1,g2)
) {
return false;
}
return this.compare(g1.geometry, g2.geometry);
};
Equality.prototype.compareBBox = function(g1,g2) {
if (
(!g1.bbox && !g2.bbox) ||
(
g1.bbox && g2.bbox &&
this.compareCoord(g1.bbox, g2.bbox)
)
) {
return true;
}
return false;
};
Equality.prototype.removePseudo = function(path) {
//TODO to be implement
return path;
};
function objectComparator(obj1, obj2) {
return deepEqual(obj1, obj2, {strict: true});
}
module.exports = Equality;
},{"deep-equal":2}],2:[function(require,module,exports){
var pSlice = Array.prototype.slice;
var objectKeys = require('./lib/keys.js');
var isArguments = require('./lib/is_arguments.js');
var deepEqual = module.exports = function (actual, expected, opts) {
if (!opts) opts = {};
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;
} else if (actual instanceof Date && expected instanceof Date) {
return actual.getTime() === expected.getTime();
// 7.3. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
} else if (typeof actual != 'object' && typeof expected != 'object') {
return opts.strict ? actual === expected : actual == expected;
// 7.4. For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
// (although not necessarily the same order), equivalent values for every
// corresponding key, and an identical 'prototype' property. Note: this
// accounts for both named and indexed properties on Arrays.
} else {
return objEquiv(actual, expected, opts);
}
}
function isUndefinedOrNull(value) {
return value === null || value === undefined;
}
function isBuffer (x) {
if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;
if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
return false;
}
if (x.length > 0 && typeof x[0] !== 'number') return false;
return true;
}
function objEquiv(a, b, opts) {
var i, key;
if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
return false;
// an identical 'prototype' property.
if (a.prototype !== b.prototype) return false;
//~~~I've managed to break Object.keys through screwy arguments passing.
// Converting to array solves the problem.
if (isArguments(a)) {
if (!isArguments(b)) {
return false;
}
a = pSlice.call(a);
b = pSlice.call(b);
return deepEqual(a, b, opts);
}
if (isBuffer(a)) {
if (!isBuffer(b)) {
return false;
}
if (a.length !== b.length) return false;
for (i = 0; i < a.length; i++) {
if (a[i] !== b[i]) return false;
}
return true;
}
try {
var ka = objectKeys(a),
kb = objectKeys(b);
} catch (e) {//happens when one is a string literal and the other isn't
return false;
}
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length != kb.length)
return false;
//the same set of keys (although not necessarily the same order),
ka.sort();
kb.sort();
//~~~cheap key test
for (i = ka.length - 1; i >= 0; i--) {
if (ka[i] != kb[i])
return false;
}
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!deepEqual(a[key], b[key], opts)) return false;
}
return typeof a === typeof b;
}
},{"./lib/is_arguments.js":3,"./lib/keys.js":4}],3:[function(require,module,exports){
var supportsArgumentsClass = (function(){
return Object.prototype.toString.call(arguments)
})() == '[object Arguments]';
exports = module.exports = supportsArgumentsClass ? supported : unsupported;
exports.supported = supported;
function supported(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
};
exports.unsupported = unsupported;
function unsupported(object){
return object &&
typeof object == 'object' &&
typeof object.length == 'number' &&
Object.prototype.hasOwnProperty.call(object, 'callee') &&
!Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
false;
};
},{}],4:[function(require,module,exports){
exports = module.exports = typeof Object.keys === 'function'
? Object.keys : shim;
exports.shim = shim;
function shim (obj) {
var keys = [];
for (var key in obj) keys.push(key);
return keys;
}
},{}]},{},[1])(1)
});
//# sourceMappingURL=geojson-equality.js.map

View File

@@ -0,0 +1,21 @@
{
"version": 3,
"sources": [
"node_modules/browserify/node_modules/browser-pack/_prelude.js",
"/home/gaganb/projects/geosquare/geojson-equality/index.js",
"/home/gaganb/projects/geosquare/geojson-equality/node_modules/deep-equal/index.js",
"/home/gaganb/projects/geosquare/geojson-equality/node_modules/deep-equal/lib/is_arguments.js",
"/home/gaganb/projects/geosquare/geojson-equality/node_modules/deep-equal/lib/keys.js"
],
"names": [],
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACjKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AC9FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;ACpBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA",
"file": "generated.js",
"sourceRoot": "",
"sourcesContent": [
"(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})",
"//index.js\nvar deepEqual = require('deep-equal');\n\nvar Equality = function(opt) {\n this.precision = opt && opt.precision ? opt.precision : 17;\n this.direction = opt && opt.direction ? opt.direction : false;\n this.pseudoNode = opt && opt.pseudoNode ? opt.pseudoNode : false;\n this.objectComparator = opt && opt.objectComparator ? opt.objectComparator : objectComparator;\n};\n\nEquality.prototype.compare = function(g1,g2) {\n if (g1.type !== g2.type || !sameLength(g1,g2)) return false;\n\n switch(g1.type) {\n case 'Point':\n return this.compareCoord(g1.coordinates, g2.coordinates);\n break;\n case 'LineString':\n return this.compareLine(g1.coordinates, g2.coordinates,0,false);\n break;\n case 'Polygon':\n return this.comparePolygon(g1,g2);\n break;\n case 'Feature':\n return this.compareFeature(g1, g2);\n default:\n if (g1.type.indexOf('Multi') === 0) {\n var context = this;\n var g1s = explode(g1);\n var g2s = explode(g2);\n return g1s.every(function(g1part) {\n return this.some(function(g2part) {\n return context.compare(g1part,g2part);\n });\n },g2s);\n }\n }\n return false;\n};\n\nfunction explode(g) {\n return g.coordinates.map(function(part) {\n return {\n type: g.type.replace('Multi', ''),\n coordinates: part}\n });\n}\n//compare length of coordinates/array\nfunction sameLength(g1,g2) {\n return g1.hasOwnProperty('coordinates') ?\n g1.coordinates.length === g2.coordinates.length\n : g1.length === g2.length;\n}\n\n// compare the two coordinates [x,y]\nEquality.prototype.compareCoord = function(c1,c2) {\n if (c1.length !== c2.length) {\n return false;\n }\n\n for (var i=0; i < c1.length; i++) {\n if (c1[i].toFixed(this.precision) !== c2[i].toFixed(this.precision)) {\n return false;\n }\n }\n return true;\n};\n\nEquality.prototype.compareLine = function(path1,path2,ind,isPoly) {\n if (!sameLength(path1,path2)) return false;\n var p1 = this.pseudoNode ? path1 : this.removePseudo(path1);\n var p2 = this.pseudoNode ? path2 : this.removePseudo(path2);\n if (isPoly && !this.compareCoord(p1[0],p2[0])) {\n // fix start index of both to same point\n p2 = this.fixStartIndex(p2,p1);\n if(!p2) return;\n }\n // for linestring ind =0 and for polygon ind =1\n var sameDirection = this.compareCoord(p1[ind],p2[ind]);\n if (this.direction || sameDirection\n ) {\n return this.comparePath(p1, p2);\n } else {\n if (this.compareCoord(p1[ind],p2[p2.length - (1+ind)])\n ) {\n return this.comparePath(p1.slice().reverse(), p2);\n }\n return false;\n }\n};\nEquality.prototype.fixStartIndex = function(sourcePath,targetPath) {\n //make sourcePath first point same as of targetPath\n var correctPath,ind = -1;\n for (var i=0; i< sourcePath.length; i++) {\n if(this.compareCoord(sourcePath[i],targetPath[0])) {\n ind = i;\n break;\n }\n }\n if (ind >= 0) {\n correctPath = [].concat(\n sourcePath.slice(ind,sourcePath.length),\n sourcePath.slice(1,ind+1));\n }\n return correctPath;\n};\nEquality.prototype.comparePath = function (p1,p2) {\n var cont = this;\n return p1.every(function(c,i) {\n return cont.compareCoord(c,this[i]);\n },p2);\n};\n\nEquality.prototype.comparePolygon = function(g1,g2) {\n if (this.compareLine(g1.coordinates[0],g2.coordinates[0],1,true)) {\n var holes1 = g1.coordinates.slice(1,g1.coordinates.length);\n var holes2 = g2.coordinates.slice(1,g2.coordinates.length);\n var cont = this;\n return holes1.every(function(h1) {\n return this.some(function(h2) {\n return cont.compareLine(h1,h2,1,true);\n });\n },holes2);\n } else {\n return false;\n }\n};\n\nEquality.prototype.compareFeature = function(g1,g2) {\n if (\n g1.id !== g2.id ||\n !this.objectComparator(g1.properties, g2.properties) ||\n !this.compareBBox(g1,g2)\n ) {\n return false;\n }\n return this.compare(g1.geometry, g2.geometry);\n};\n\nEquality.prototype.compareBBox = function(g1,g2) {\n if (\n (!g1.bbox && !g2.bbox) || \n (\n g1.bbox && g2.bbox &&\n this.compareCoord(g1.bbox, g2.bbox)\n )\n ) {\n return true;\n }\n return false;\n};\nEquality.prototype.removePseudo = function(path) {\n //TODO to be implement\n return path;\n};\n\nfunction objectComparator(obj1, obj2) {\n return deepEqual(obj1, obj2, {strict: true});\n}\n\nmodule.exports = Equality;\n",
"var pSlice = Array.prototype.slice;\nvar objectKeys = require('./lib/keys.js');\nvar isArguments = require('./lib/is_arguments.js');\n\nvar deepEqual = module.exports = function (actual, expected, opts) {\n if (!opts) opts = {};\n // 7.1. All identical values are equivalent, as determined by ===.\n if (actual === expected) {\n return true;\n\n } else if (actual instanceof Date && expected instanceof Date) {\n return actual.getTime() === expected.getTime();\n\n // 7.3. Other pairs that do not both pass typeof value == 'object',\n // equivalence is determined by ==.\n } else if (typeof actual != 'object' && typeof expected != 'object') {\n return opts.strict ? actual === expected : actual == expected;\n\n // 7.4. For all other Object pairs, including Array objects, equivalence is\n // determined by having the same number of owned properties (as verified\n // with Object.prototype.hasOwnProperty.call), the same set of keys\n // (although not necessarily the same order), equivalent values for every\n // corresponding key, and an identical 'prototype' property. Note: this\n // accounts for both named and indexed properties on Arrays.\n } else {\n return objEquiv(actual, expected, opts);\n }\n}\n\nfunction isUndefinedOrNull(value) {\n return value === null || value === undefined;\n}\n\nfunction isBuffer (x) {\n if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;\n if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {\n return false;\n }\n if (x.length > 0 && typeof x[0] !== 'number') return false;\n return true;\n}\n\nfunction objEquiv(a, b, opts) {\n var i, key;\n if (isUndefinedOrNull(a) || isUndefinedOrNull(b))\n return false;\n // an identical 'prototype' property.\n if (a.prototype !== b.prototype) return false;\n //~~~I've managed to break Object.keys through screwy arguments passing.\n // Converting to array solves the problem.\n if (isArguments(a)) {\n if (!isArguments(b)) {\n return false;\n }\n a = pSlice.call(a);\n b = pSlice.call(b);\n return deepEqual(a, b, opts);\n }\n if (isBuffer(a)) {\n if (!isBuffer(b)) {\n return false;\n }\n if (a.length !== b.length) return false;\n for (i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n }\n try {\n var ka = objectKeys(a),\n kb = objectKeys(b);\n } catch (e) {//happens when one is a string literal and the other isn't\n return false;\n }\n // having the same number of owned properties (keys incorporates\n // hasOwnProperty)\n if (ka.length != kb.length)\n return false;\n //the same set of keys (although not necessarily the same order),\n ka.sort();\n kb.sort();\n //~~~cheap key test\n for (i = ka.length - 1; i >= 0; i--) {\n if (ka[i] != kb[i])\n return false;\n }\n //equivalent values for every corresponding key, and\n //~~~possibly expensive deep test\n for (i = ka.length - 1; i >= 0; i--) {\n key = ka[i];\n if (!deepEqual(a[key], b[key], opts)) return false;\n }\n return typeof a === typeof b;\n}\n",
"var supportsArgumentsClass = (function(){\n return Object.prototype.toString.call(arguments)\n})() == '[object Arguments]';\n\nexports = module.exports = supportsArgumentsClass ? supported : unsupported;\n\nexports.supported = supported;\nfunction supported(object) {\n return Object.prototype.toString.call(object) == '[object Arguments]';\n};\n\nexports.unsupported = unsupported;\nfunction unsupported(object){\n return object &&\n typeof object == 'object' &&\n typeof object.length == 'number' &&\n Object.prototype.hasOwnProperty.call(object, 'callee') &&\n !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||\n false;\n};\n",
"exports = module.exports = typeof Object.keys === 'function'\n ? Object.keys : shim;\n\nexports.shim = shim;\nfunction shim (obj) {\n var keys = [];\n for (var key in obj) keys.push(key);\n return keys;\n}\n"
]
}

View File

@@ -0,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)});

161
frontend/node_modules/geojson-equality/index.js generated vendored Normal file
View File

@@ -0,0 +1,161 @@
//index.js
var deepEqual = require('deep-equal');
var Equality = function(opt) {
this.precision = opt && opt.precision ? opt.precision : 17;
this.direction = opt && opt.direction ? opt.direction : false;
this.pseudoNode = opt && opt.pseudoNode ? opt.pseudoNode : false;
this.objectComparator = opt && opt.objectComparator ? opt.objectComparator : objectComparator;
};
Equality.prototype.compare = function(g1,g2) {
if (g1.type !== g2.type || !sameLength(g1,g2)) return false;
switch(g1.type) {
case 'Point':
return this.compareCoord(g1.coordinates, g2.coordinates);
break;
case 'LineString':
return this.compareLine(g1.coordinates, g2.coordinates,0,false);
break;
case 'Polygon':
return this.comparePolygon(g1,g2);
break;
case 'Feature':
return this.compareFeature(g1, g2);
default:
if (g1.type.indexOf('Multi') === 0) {
var context = this;
var g1s = explode(g1);
var g2s = explode(g2);
return g1s.every(function(g1part) {
return this.some(function(g2part) {
return context.compare(g1part,g2part);
});
},g2s);
}
}
return false;
};
function explode(g) {
return g.coordinates.map(function(part) {
return {
type: g.type.replace('Multi', ''),
coordinates: part}
});
}
//compare length of coordinates/array
function sameLength(g1,g2) {
return g1.hasOwnProperty('coordinates') ?
g1.coordinates.length === g2.coordinates.length
: g1.length === g2.length;
}
// compare the two coordinates [x,y]
Equality.prototype.compareCoord = function(c1,c2) {
if (c1.length !== c2.length) {
return false;
}
for (var i=0; i < c1.length; i++) {
if (c1[i].toFixed(this.precision) !== c2[i].toFixed(this.precision)) {
return false;
}
}
return true;
};
Equality.prototype.compareLine = function(path1,path2,ind,isPoly) {
if (!sameLength(path1,path2)) return false;
var p1 = this.pseudoNode ? path1 : this.removePseudo(path1);
var p2 = this.pseudoNode ? path2 : this.removePseudo(path2);
if (isPoly && !this.compareCoord(p1[0],p2[0])) {
// fix start index of both to same point
p2 = this.fixStartIndex(p2,p1);
if(!p2) return;
}
// for linestring ind =0 and for polygon ind =1
var sameDirection = this.compareCoord(p1[ind],p2[ind]);
if (this.direction || sameDirection
) {
return this.comparePath(p1, p2);
} else {
if (this.compareCoord(p1[ind],p2[p2.length - (1+ind)])
) {
return this.comparePath(p1.slice().reverse(), p2);
}
return false;
}
};
Equality.prototype.fixStartIndex = function(sourcePath,targetPath) {
//make sourcePath first point same as of targetPath
var correctPath,ind = -1;
for (var i=0; i< sourcePath.length; i++) {
if(this.compareCoord(sourcePath[i],targetPath[0])) {
ind = i;
break;
}
}
if (ind >= 0) {
correctPath = [].concat(
sourcePath.slice(ind,sourcePath.length),
sourcePath.slice(1,ind+1));
}
return correctPath;
};
Equality.prototype.comparePath = function (p1,p2) {
var cont = this;
return p1.every(function(c,i) {
return cont.compareCoord(c,this[i]);
},p2);
};
Equality.prototype.comparePolygon = function(g1,g2) {
if (this.compareLine(g1.coordinates[0],g2.coordinates[0],1,true)) {
var holes1 = g1.coordinates.slice(1,g1.coordinates.length);
var holes2 = g2.coordinates.slice(1,g2.coordinates.length);
var cont = this;
return holes1.every(function(h1) {
return this.some(function(h2) {
return cont.compareLine(h1,h2,1,true);
});
},holes2);
} else {
return false;
}
};
Equality.prototype.compareFeature = function(g1,g2) {
if (
g1.id !== g2.id ||
!this.objectComparator(g1.properties, g2.properties) ||
!this.compareBBox(g1,g2)
) {
return false;
}
return this.compare(g1.geometry, g2.geometry);
};
Equality.prototype.compareBBox = function(g1,g2) {
if (
(!g1.bbox && !g2.bbox) ||
(
g1.bbox && g2.bbox &&
this.compareCoord(g1.bbox, g2.bbox)
)
) {
return true;
}
return false;
};
Equality.prototype.removePseudo = function(path) {
//TODO to be implement
return path;
};
function objectComparator(obj1, obj2) {
return deepEqual(obj1, obj2, {strict: true});
}
module.exports = Equality;

42
frontend/node_modules/geojson-equality/package.json generated vendored Normal file
View File

@@ -0,0 +1,42 @@
{
"name": "geojson-equality",
"version": "0.1.6",
"description": "Check two valid geojson geometries for equality.",
"main": "index.js",
"scripts": {
"test": "mocha test/test.js",
"build-debug": "browserify index.js --debug --standalone GeojsonEquality | exorcist dist/geojson-equality.js.map > dist/geojson-equality.js",
"build-min": "browserify index.js --standalone GeojsonEquality | uglifyjs -c -m > dist/geojson-equality.min.js",
"build": "npm run build-debug && npm run build-min"
},
"repository": {
"type": "git",
"url": "git://github.com/geosquare/geojson-equality.git"
},
"bugs": {
"url": "https://github.com/geosquare/geojson-equality/issues"
},
"homepage": "https://github.com/geosquare/geojson-equality",
"keywords": [
"geojson",
"equality",
"equal",
"assertion"
],
"author": "Gagan Bansal <gaganbansal123@gmail.com>",
"contributors": [
"Tim Oram <mitmaro@gmail.com>"
],
"license": "MIT",
"dependencies": {
"deep-equal": "^1.0.0"
},
"devDependencies": {
"browserify": "~5.10.1",
"chai": "~1.9.1",
"exorcist": "^0.4.0",
"mocha": "~1.21.4",
"uglify-js": "~2.4.15",
"watchify": "~1.0.2"
}
}

View File

@@ -0,0 +1 @@
--check-leaks

364
frontend/node_modules/geojson-equality/test/test.js generated vendored Normal file
View File

@@ -0,0 +1,364 @@
var expect = require('chai').expect,
Equality = require('../');
describe('geojson-equality for Points', function() {
var g1 = { "type": "Point", "coordinates": [30, 10] },
g2 = { "type": "Point", "coordinates": [30, 10] },
g3 = { "type": "Point", "coordinates": [30, 11] },
g4 = { "type": "Point", "coordinates": [30, 10, 5]},
g5 = { "type": "Point", "coordinates": [30, 10, 5]},
eq = new Equality();
it('are equal', function() {
expect(eq.compare(g1,g2)).to.be.true;
});
it('are not equal', function() {
expect(eq.compare(g1,g3)).to.be.false;
});
it('are not equal with different point dimensions', function() {
expect(eq.compare(g1,g4)).to.be.false;
});
it('are equal with 3d points', function() {
expect(eq.compare(g4,g5)).to.be.true;
});
});
describe('geojson-equality for LineStrings', function() {
var g1 = { "type": "LineString", "coordinates":
[ [30, 10], [10, 30], [40, 40] ] },
g2 = { "type": "LineString", "coordinates":
[ [30, 10], [10, 30], [40, 40] ] };
it('are equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g2)).to.be.true;
});
var g3 = { "type": "LineString", "coordinates":
[ [31, 10], [10, 30], [40, 40] ] };
it('are not equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g3)).to.be.false;
});
var g4 = { "type": "LineString", "coordinates":
[ [40, 40], [10, 30], [30, 10]] };
it('reverse direction, direction is not matched, so both are equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g4)).to.be.true;
});
it('reverse direction, direction is matched, so both are not equal', function() {
var eq = new Equality({direction: true});
expect(eq.compare(g1,g4)).to.be.false;
});
});
describe('geojson-equality for Polygons', function() {
var g1 = { "type": "Polygon", "coordinates": [
[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]
]};
var g2 = { "type": "Polygon", "coordinates": [
[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]
]};
it('are equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g2)).to.be.true;
});
var g3 = { "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 10]]
]};
it('are not equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g3)).to.be.false;
});
var g4 = { "type": "Polygon", "coordinates": [
[[30,10], [10,20], [20,40], [40,40], [30,10]]
]};
it('reverse direction, direction is not matched, so both are equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g4)).to.be.true;
});
it('reverse direction, direction is matched, so both are not equal', function() {
var eq = new Equality({direction: true});
expect(eq.compare(g1,g4)).to.be.false;
});
var g5 = { "type": "Polygon", "coordinates": [
[[10,20], [20,40], [40,40], [30,10], [10,20]]
]};
it('reverse direction, diff start index, direction is not matched, so both are equal',
function() {
var eq = new Equality();
expect(eq.compare(g1,g5)).to.be.true;
});
it('reverse direction, diff start index, direction is matched, so both are not equal',
function() {
var eq = new Equality({direction: true});
expect(eq.compare(g1,g5)).to.be.false;
});
var gh1 = { "type": "Polygon", "coordinates": [
[[45, 45], [15, 40], [10, 20], [35, 10],[45, 45]],
[[20, 30], [35, 35], [30, 20], [20, 30]]
]};
var gh2 = { "type": "Polygon", "coordinates": [
[[35, 10], [45, 45], [15, 40], [10, 20], [35, 10]],
[[20, 30], [35, 35], [30, 20], [20, 30]]
]};
it('have holes too and diff start ind, direction is not matched, both are equal',
function() {
var eq = new Equality({direction: false});
expect(eq.compare(gh1,gh2)).to.be.true;
});
it('have holes too and diff start ind, direction is matched, so both are not equal',
function() {
var eq = new Equality({direction: true});
expect(eq.compare(gh1,gh2)).to.be.true;
});
var gprecision1 = { "type": "Polygon", "coordinates": [
[[30, 10], [40.12345, 40.12345], [20, 40], [10, 20], [30, 10]]
]};
var gprecision2 = { "type": "Polygon", "coordinates": [
[[30, 10], [40.123389, 40.123378], [20, 40], [10, 20], [30, 10]]
]};
it('after limiting precision, are equal', function() {
var eq = new Equality({precision: 3});
expect(eq.compare(gprecision1,gprecision2)).to.be.true;
});
it('with high precision, are not equal', function() {
var eq = new Equality({precision: 10});
expect(eq.compare(gprecision1,gprecision2)).to.be.false;
});
});
describe ('geojson-equality for Feature', function() {
it ('will not be equal with changed id', function() {
var f1 = {"type": "Feature", "id": "id1"};
var f2 = {"type": "Feature", "id": "id2"};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal with different count of properties', function() {
var f1 = {"type": "Feature", "id": "id1", "properties": {"foo": "bar"}};
var f2 = {"type": "Feature", "id": "id1", "properties": {"foo1": "bar", "foo2": "bar"}};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal with different keys in properties', function() {
var f1 = {"type": "Feature", "id": "id1", "properties": {"foo1": "bar"}};
var f2 = {"type": "Feature", "id": "id1", "properties": {"foo2": "bar"}};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal with different properties', function() {
var f1 = {"type": "Feature", "id": "id1", "properties": {"foo": "bar1"}};
var f2 = {"type": "Feature", "id": "id1", "properties": {"foo": "bar2"}};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will not be equal with different geometry', function() {
var f1 = {
"type": "Feature",
"id": "id1",
"properties": {"foo": "bar1"},
"geometry": { "type": "Polygon", "coordinates": [
[[30, 10], [41, 40], [20, 40], [10, 20], [30, 10]]
]}
};
var f2 = {
"type": "Feature",
"id": "id1",
"properties": {"foo": "bar1"},
"geometry": { "type": "Polygon", "coordinates": [
[[40, 20], [31, 10], [30, 20], [30, 10], [10, 40]]
]}
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will be equal with nested properties', function() {
var f1 = {"type": "Feature", "id": "id1", "properties": {"foo": {"bar": "baz"}},
"geometry": {"type": "Point", "coordinates": [0, 1]}
};
var f2 = {"type": "Feature", "id": "id1", "properties": {"foo": {"bar": "baz"}},
"geometry": {"type": "Point", "coordinates": [0, 1]}
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.true;
});
it ('will not be equal with different nested properties', function() {
var f1 = {"type": "Feature", "id": "id1", "properties": {"foo": {"bar": "baz"}},
"geometry": {"type": "Point", "coordinates": [0, 1]}
};
var f2 = {"type": "Feature", "id": "id1", "properties": {"foo": {"bar": "baz2"}},
"geometry": {"type": "Point", "coordinates": [0, 1]}
};
var eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('will use a custom comparator if provided', function() {
var f1 = {
"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": "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": "Feature", "id": "id1", "bbox": [1, 2, 3, 4]},
f2 = {"type": "Feature", "id": "id1"},
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": "Feature", "id": "id1", "bbox": [1, 2, 3, 4]},
f2 = {"type": "Feature", "id": "id1", "bbox": [1, 2, 3, 5]},
eq = new Equality();
expect(eq.compare(f1, f2)).to.be.false;
});
it ('equal features with bboxes', function() {
var f1 = {
"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": "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": "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": "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() {
var g1 = { "type": "MultiPoint", "coordinates": [
[0, 40], [40, 30], [20, 20], [30, 10]
]};
var g2 = { "type": "MultiPoint", "coordinates": [
[0, 40], [20, 20], [40, 30], [30, 10]
]};
it('are equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g2)).to.be.true;
});
var g3 = { "type": "MultiPoint", "coordinates": [
[10, 40], [20, 20], [40, 30], [30, 10]
]};
it('are not equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g3)).to.be.false;
});
});
describe('geojson-equality for MultiLineString', function() {
var g1 = { "type": "MultiLineString", "coordinates": [
[[30, 10], [10, 30], [40, 40]],
[[0, 10], [10, 0], [40, 40]]
]};
var g2 = { "type": "MultiLineString", "coordinates": [
[[40, 40],[10, 30], [30, 10]],
[[0, 10], [10, 0], [40, 40]]
]};
it('reverse direction, direction is not matched, so both are equal',
function() {
var eq = new Equality();
expect(eq.compare(g1,g2)).to.be.true;
}
);
it('reverse direction, direction is matched, so both are not equal',
function() {
var eq = new Equality({direction: true});
expect(eq.compare(g1,g2)).to.be.false;
}
);
var g3 = { "type": "MultiLineString", "coordinates": [
[[10, 10], [20, 20], [10, 40]],
[[40, 40], [30, 30], [40, 20], [30, 10]] ] };
it('both are not equal',
function() {
var eq = new Equality();
expect(eq.compare(g1,g3)).to.be.false;
}
);
});
describe('geojson-equality for MultiPolygon', function() {
var g1 = { "type": "MultiPolygon", "coordinates": [
[[[30, 20], [45, 40], [10, 40], [30, 20]]],
[[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]]
]};
var g2 = { "type": "MultiPolygon", "coordinates": [
[[[30, 20], [45, 40], [10, 40], [30, 20]]],
[[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]]
]};
it('both are equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g2)).to.be.true;
});
var g3 = { "type": "MultiPolygon", "coordinates": [
[[[30, 20], [45, 40], [10, 40], [30, 20]]],
[[[15, 5], [400, 10], [10, 20], [5, 10], [15, 5]]]
]};
it('both are not equal', function() {
var eq = new Equality();
expect(eq.compare(g1,g3)).to.be.false;
});
var gh1 = { "type": "MultiPolygon", "coordinates": [
[[[40, 40], [20, 45], [45, 30], [40, 40]]],
[
[[20, 35], [10, 30], [10, 10], [30, 5], [45, 20], [20, 35]],
[[30, 20], [20, 15], [20, 25], [30, 20]],
[[20, 10], [30, 10], [30, 15], [20, 10]]
]
]};
var gh2 = { "type": "MultiPolygon", "coordinates": [
[
[[20, 35], [10, 30], [10, 10], [30, 5], [45, 20], [20, 35]],
[[20, 10], [30, 10], [30, 15], [20, 10]],
[[30, 20], [20, 15], [20, 25], [30, 20]]
],
[[[40, 40], [20, 45], [45, 30], [40, 40]]]
]};
it('having holes, both are equal', function() {
var eq = new Equality();
expect(eq.compare(gh1,gh2)).to.be.true;
});
});