1.0.7 • Published 3 years ago

geojson-apply-right-hand-rule v1.0.7

Weekly downloads
34
License
ISC
Repository
github
Last release
3 years ago

geojson-apply-right-hand-rule

This repo addresses the problem that not all GeoJSON-Files follow the right hand rule:

A linear ring MUST follow the right-hand rule with respect to the area it bounds, i.e., exterior rings are counterclockwise, and holes are clockwise.

It also takes care that the first and last linear ring positions are equivalent - specs say:

they MUST contain identical values

You can also use the following tools to enforce the ring winding order:

  • mapbox/geojson-rewind (based on area calculation)
  • Turfjs/turf-rewind (even based on the shoelace formula)

Install

$ npm install geojson-apply-right-hand-rule
$ npm install @types/geojson --save-dev # when using typescript

Usage

import mapCoordinates from 'geojson-apply-right-hand-rule'

const clockwise = [[100, 0], [100, 1], [101, 1], [101, 0], [100, 0]]
const geometry = mapCoordinates(clockwise)
console.log(JSON.stringify(geometry))
// {"type":"Polygon","coordinates":[[..., [101, 0], ..., [100, 1], ...]]}
1.0.7

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago