
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
geojson-network-parser
Advanced tools
A utility that turns a GeoJSON FeatureCollection of a road network and turns it into a routable graph
npm install geojson-network-parser
const NetworkParser = require('geojson-network-parser');
var geojson = {
type: 'FeatureCollection',
features: [
{
type: 'Feature',
properties: {
layer: 'roadway',
cost: 4
},
geometry: {
type: 'LineString',
geometry: [[-37.231312, 32.4444], [-37.23111, 32.5534] /* and so on ... */ ]
}
},
// ... and so on with more roads
]
};
// Filter the features only process the ones that represent roads
const roads = geojson.features.filter(f => (f.properties.layer === "roadway"));
// Turn the GeoJSON FeatureCollection of roads into a network that we can find shortest-path routes on
const network = new NetworkParser(roads, "cost", 2);
const parsed = network.parse({
tolerance: 0.0000075, // Ignore gaps greater than this distance. Units are in degrees latitude, so values < 0.00002 are a good starting point.
ignoreCrossings: false // If `true`, intersections will only be added where there are two nearby points in the original FeatureCollection. If `false`, intersections will be inferred where two edge segments cross each other.
});
// Snap latitude/longitude point to nearest node on the network
const A = network.getNearestNode([-37.231312, 32.4444]);
const B = network.getNearestNode([-37.23111, 32.5534]);
// Get a list of nodes that connect the shortest path between two points
const route = network.findShortestPath(A, B);
Clone this repo then run:
npm install
npm run build
This will output a bundled js file to dist/geojson-network-parser.js
.
FAQs
A utility that turns a GeoJSON FeatureCollection of a road network and turns it into a routable graph
The npm package geojson-network-parser receives a total of 2 weekly downloads. As such, geojson-network-parser popularity was classified as not popular.
We found that geojson-network-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.