3.1.3 • Published 2 years ago

@mapbox/graph-normalizer v3.1.3

Weekly downloads
3
License
ISC
Repository
github
Last release
2 years ago

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
3.1.3

2 years ago

2.7.0

3 years ago

2.6.0

4 years ago

2.5.0

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

2.4.3

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

3.1.0

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

2.3.4

7 years ago

2.3.3

7 years ago

3.0.0

7 years ago

2.3.2

8 years ago

2.3.1

8 years ago

2.3.0

8 years ago

2.2.1

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.7

8 years ago

2.0.7-3

8 years ago

2.0.7-2

8 years ago

2.0.7-1

8 years ago

2.0.7-0

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.1.1

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago