New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mapbox/graph-normalizer

Package Overview
Dependencies
Maintainers
85
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mapbox/graph-normalizer

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

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
46
decreased by-48.89%
Maintainers
85
Weekly downloads
 
Created
Source

Graph-normalizer

Build Status

Yay!

Takes nodes and ways in input and turn them into a graph object.

A graph is an object of this form:

{
  intersections: {
    intersectionId: { GeoJson Point with properties 'ways' and 'id' },
    ...
  },
  ways: {
    wayId: { geojson LineString with properties 'refs' and 'id' },
    ...
  }
}

This module exposes methods to create and modify graph objects.

Input

Graph objects are created from nodes and ways which are GeoJson and that must satisfy the following:

  • Nodes are GeoJson Point and have an id property.
  • Ways are GeoJson LineString or MultiLineString and have an id property as well as a refs property that is an array of node ids (a comma delineated string is acceptable as well).
  • Way coordinates have the exact same geometry as the node they represent.

Typically, graph-normalizer is used in tile-reduce scripts with input from graph-tiler which satisfies these requirements.

Usage

Installation

$ npm install private-npm-url

Methods

var graphNormalizer = require('graph-normalizer');

Create graph

graphNormalizer.createGraph(nodes, ways [, tile]);

Return a graph where only the only nodes stored are intersections, and MultiLineString ways have been split in multiple LineString ways, with !i appended to their id, where i is the index of the geometry in the MultiLineString.

If a tile ([x, y, z] array) is provided, intersections strictly outside of the tile boundaries will be discarded, and tile ids will be appended to way ids.

Split intersections

graphNormalizer.splitIntersections(graph);

Modifies graph so that every way is guaranteed to not have any intersection outside of its first and last geometry coordinates.

Ways that have been split have a !A or !B appended to their id. Ways can be split multiple times consecutively.

Merge intersections

graphNormalizer.mergeIntersections(graph);

Modifies graph so that every intersection is guaranteed to connect at least 3 ways. This method is intended to work on a graph where splitIntersections has already run.

Ways that are merged result in a way whose id is wayOne!M!wayTwo, which keeps the order of the geometry coordinates and references to nodes.

Duplicate ways

graphNormalizer.duplicateWays(graph);

If the original ways have a oneWay property that is 0 or 1 (which the output of graph-tiler satisfies), two-directional ways will be duplicated into one-ways after duplicateWays is run.

Ways that are duplicated and reversed are appended a !R to their id.

Normalize graph

graphNormalizer.normalizeGraph(nodes, ways [, tile]);

This is just a wrapper around all previous methods.

The output of this method returns a graph that satisfies the following constraints:

  • 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.

Keywords

FAQs

Package last updated on 06 Sep 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc