Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@turf/clean-coords
Advanced tools
@turf/clean-coords is a module from the Turf.js library that is used to clean coordinates in GeoJSON data. It removes redundant coordinates, such as consecutive duplicate points, and ensures the data is optimized for further processing or visualization.
Remove Redundant Coordinates
This feature removes consecutive duplicate coordinates from a GeoJSON LineString. The input line has redundant points which are removed in the cleaned output.
const turf = require('@turf/turf');
const line = turf.lineString([
[0, 0], [1, 1], [1, 1], [2, 2], [3, 3], [3, 3], [4, 4]
]);
const cleaned = turf.cleanCoords(line);
console.log(cleaned);
Clean Polygon Coordinates
This feature cleans redundant coordinates from a GeoJSON Polygon. The input polygon has duplicate points which are removed in the cleaned output.
const turf = require('@turf/turf');
const polygon = turf.polygon([
[
[0, 0], [1, 1], [1, 1], [1, 0], [0, 0], [0, 0]
]
]);
const cleaned = turf.cleanCoords(polygon);
console.log(cleaned);
The simplify-geojson package is used to simplify GeoJSON data by reducing the number of points in geometries while preserving the overall shape. Unlike @turf/clean-coords, which focuses on removing redundant points, simplify-geojson reduces the complexity of the geometry.
The geojson-rewind package ensures that GeoJSON polygons have the correct winding order. While @turf/clean-coords removes redundant coordinates, geojson-rewind focuses on correcting the order of coordinates to ensure they follow the right-hand rule.
Removes redundant coordinates from any GeoJSON Geometry.
Parameters
geojson
(Geometry | Feature) Feature or Geometryoptions
Object Optional parameters (optional, default {}
)
options.mutate
boolean allows GeoJSON input to be mutated (optional, default false
)Examples
var line = turf.lineString([[0, 0], [0, 2], [0, 5], [0, 8], [0, 8], [0, 10]]);
var multiPoint = turf.multiPoint([[0, 0], [0, 0], [2, 2]]);
turf.cleanCoords(line).geometry.coordinates;
//= [[0, 0], [0, 10]]
turf.cleanCoords(multiPoint).geometry.coordinates;
//= [[0, 0], [2, 2]]
Returns (Geometry | Feature) the cleaned input Feature/Geometry
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this module individually:
$ npm install @turf/clean-coords
Or install the Turf module that includes it as a function:
$ npm install @turf/turf
FAQs
turf clean-coords module
The npm package @turf/clean-coords receives a total of 468,245 weekly downloads. As such, @turf/clean-coords popularity was classified as popular.
We found that @turf/clean-coords demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.