Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@mapbox/geojson-rewind
Advanced tools
@mapbox/geojson-rewind is an npm package that allows you to reorient the winding order of GeoJSON polygons to ensure they follow the right-hand rule. This is useful for ensuring compatibility with various GIS systems and tools that expect polygons to be wound in a specific direction.
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));
The `geojson-rewind` package provides similar functionality to @mapbox/geojson-rewind by reorienting the winding order of GeoJSON polygons. It is a lightweight alternative and can be used in similar scenarios where ensuring the correct winding order is necessary.
The GeoJSON specification is picky about winding order.
This helps you generate compliant Polygon and MultiPolygon geometries. Furthermore it lets you use Canvas and other drawing libraries's default behavior to color the interior rings of Polygon and MultiPolygon features.
as npm module:
npm install --save geojson-rewind
as console utility
# install
npm install -g geojson-rewind
# use
geojson-rewind foo.geojson
as browser library
copy geojson-rewind.js
rewind(geojson, clockwise)
Given a GeoJSON FeatureCollection, Feature, or Geometry, return a version with inner and outer rings of different winding orders.
If clockwise
is true
, the outer ring is clockwise, otherwise
it is counterclockwise.
FAQs
enforce winding order for geojson
The npm package @mapbox/geojson-rewind receives a total of 782,772 weekly downloads. As such, @mapbox/geojson-rewind popularity was classified as popular.
We found that @mapbox/geojson-rewind demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 14 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.