npm.io
0.0.1 • Published 9 years ago

geojson-polygons-equal

Licence
ISC
Version
0.0.1
Deps
0
Vulns
0
Weekly
0

geojson-polygons-equal

Checks two GeoJSON Polygons or MultiPolygons for equality.

This includes detecting polygons whose coordinates are rotated left or right differently.

Usage

var polyEqual = require('geojson-polygons-equal')

var poly1 = {
  type: 'Polygon',
  coordinates: [
    [
      [0, 0],
      [0, 1],
      [1, 1],
      [1, 0],
      [0, 0]
    ]
  ]
}

var poly2 = {
  type: 'Polygon',
  coordinates: [
    [
      [1, 1],
      [1, 0],
      [0, 0],
      [0, 1],
      [1, 1]
    ]
  ]
}

console.log(polyEqual(poly1, poly2))

outputs

true

API

var polyEquals = require('geojson-polygons-equal')
polyEquals(poly1, poly2)

Compares the two GeoJSON objects poly1 and poly2, which can be either Polygon or MultiPolygon objects.

Install

With npm installed, run

$ npm install geojson-polygons-equal

License

ISC