Rewind GeoJSON Polygons
This feature allows you to reorient the winding order of GeoJSON polygons. The `rewind` function takes a GeoJSON object and a boolean indicating whether to reverse the winding order to follow the right-hand rule. The code sample demonstrates how to use the package to rewind a GeoJSON polygon.
const rewind = require('@mapbox/geojson-rewind');
const geojson = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[-101.744384765625, 39.32155002466662],
[-101.5521240234375, 39.330048552942415],
[-101.40380859375, 39.330048552942415],
[-101.33239746093749, 39.364032338047984],
[-101.041259765625, 39.36827914916011],
[-100.975341796875, 39.30454987014581],
[-101.0399169921875, 39.24501680713314],
[-101.24389648437499, 39.16414104768742],
[-101.54541015625, 39.178362282029745],
[-101.744384765625, 39.32155002466662]
]
]
}
}
]
};
const rewindedGeojson = rewind(geojson, true);
console.log(JSON.stringify(rewindedGeojson, null, 2));