geojson-equality
Check two valid geojson geometries for equality.
installation
npm install geojson-equality
usage
var GeojsonEquality = ;var eq = ; 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; // returns truevar g3 = "type": "Polygon" "coordinates": 300 100 400 400 200 400 100 200 300 100; eq; // returns false
For including in browser, download file geojson-equality.min.js
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
var g1 = "type": "Point" "coordinates": 302 10 ;var g2 = "type": "Point" "coordinates": 3022233 10 ;var eq = precision: 3;eq; // returns falsevar eq = precision: 1;eq; // returns true
- direction true | false, direction of LineString or Polygon (orientation) is ignored if false. Default is false.
var g1 = "type": "LineString" "coordinates": 30 10 10 30 40 40 ; var g2 = "type": "LineString" "coordinates": 40 40 10 30 30 10 ; var eq = direction: false; eq; // returns true var eq = direction: true; eq; // returns false
- objectComparator function, custom function for use in comparing Feature properties. Default is a shallow comparison.
// using lodash isEqual to deep comparison var isEqual = var eq = 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.