npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@mapbox/graph-normalizer

v3.1.3

Published

Takes nodes and ways and turn them into a normalized graph of intersections and ways.

Downloads

222

Readme

Graph-normalizer

Build Status

graph-normalizer is a JavaScript module that performs operations on an array of GeoJSON LineStrings representing OpenStreetMap ways. The operations performed cover a standard set of graph normalization techniques such as merging edges between intersections and splitting edges that cross over intersections. Ids assigned to ways in the normalized graph are deterministic and reproducible.

Installation

npm install @mapbox/graph-normlizer

Test

npm test

Benchmark

npm run bench

Use

var normalizer = require('@mapbox/graph-normalizer');

var ways = require('./ways.json');

var splitWays = normalizer.splitWays(ways);
var mergedWays = normalizer.mergeWays(ways);

console.log(JSON.stringify(ways));

API

splitWays(ways)

Any ways that traverse an intersection are split in two. !<i> is appended to the way id where i is the index of the split way in the original geometry. Note that !0 is appended to the way id if there is no split.

mergeWays(ways)

Ways that share a node which is not an intersection (only 2 way owners) are merged together. The resulting id is <wayOne>,<wayTwo>.

Input format

  • An array of GeoJSON LineString Features
  • Each feature must have a refs array signifying node Ids of the coordinates that make up the way used for topology construction
  • Each feature must have an id property representing the OpenStreetMap id of the way
  • Each feature must have a highway property representing the OpenStreetMap highway tag of the way
  • Each feature must have a oneway property representing the OpenStreetMap oneway tag of the way
    • the oneway property must be normalized to 0, 1, or -1
    • 0 signifies a bidirectional way
    • 1 signifies a oneway way traveling in coordinate order
    • -1 signifies a oneway way traveling in reverse coordinate order (this will be normalized to forward order 1)
    • graph-normalizer will not work with raw OpenStreetMap oneway values such as yes, or no

Misc

  • All way geometries in the original road network have an equivalent in the normalized graph.
  • No intersection ever lies within a normalized way, only at its ends.
  • Normalized way ids keep track of the history of transformations that led to it.
  • highway, oneway, bridge, tunnel and junction tags are conserved from the original graph by default.
  • highway, bridge, tunnel and junction tags can be merged using optional arguments. When merging different tags:
    • highway tag is set as unclassified
    • tunnel tag is set to yes i.e. we keep the info that there is a tunnel in the merged way
    • bridge tag is set to yes i.e. we keep the info that there is a bridge in the merged way
    • junction tag is set we keep the info about the junction in the merged way