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/probematch

v3.0.0

Published

A small module for matching probes to road networks

Downloads

15

Readme

@mapbox/probematch

Match a single GPS measurements (probe) or line of sequential GPS measurements (trace) to a road network.

probematch creates an flatbush index of a road network to allow you to quickly match probes or traces to the roads using configurable distance and bearing filters.

terms

  • probe - a single GPS measurement, represented by a Feature<Point>
  • trace - a collection of sequential GPS measurements, represented by a Feature<LineString>
  • road - a Feature<LineString> representing a road, which we may attempt to match probes and traces to
  • roads, network, road network - a FeatureCollection of roads
  • segment - a single edge of a road. For road A -> B -> C, there are two segments: A -> B and B -> C. Segments always have only 2 points.

install

npm install @mapbox/probematch

configuration

var probematch = require('@mapbox/probematch');

var roads = {
  'type': 'FeatureCollection',
  'features': [
    // Linestring features representing the road network
  ]
};

var matcher = probematch(roads, {
  compareBearing: true,
  maxBearingRange: 5,
  bidirectionalBearing: false,
  maxProbeDistance: 0.01
});

key | type | default | description --- | --- | --- | --- compareBearing | boolean | true | Should bearing of probes be used to evaluate match quality? If true, the bearing of the probe is compared to the bearing of each possible matching road segment. This ensures probes don't match cross-streets that obviously aren't the same as the probe's direction of travel maxBearingRange | number | 5 | Maximum amount in degrees that a probe's bearing may differ from a road segment's when using compareBearing bidirectionalBearing | boolean | false | Should bearing matches allow for probes to be moving in the opposite direction of a road segment's bearing? This should be true if the road network includes 2-way roads. maxProbeDistance | number | 0.01 | Maximum distance in kilometers that a probe may be from a road segment in order to consider it a possible match. Prevents matching probes to segments that are too far away from them.

usage

match

var probematch = require('@mapbox/probematch');

var roads = /* FeatureCollection of road geometries */;
var matcher = probematch(roads, {/* configuration */});

var probe = {
  type: 'Feature',
  geometry: {
    type: 'Point',
    coordinates: [0, 0]
  }
};

var probeBearing  = 57; // probe's direction of travel in degrees

var results = matcher(probe, probeBearing);

The result of matching a single proble is an array of possible matches to the road network. Results are ordered by the probe's distance from the candidate road.

Each possible match represents a road that is likely to have matched the probe.

key | type | description --- | --- | --- road | Feature<LineString> | The geometry of a road that may have been matched index | Number | The start index of the segment closest to the probe may have matched (in the road's coordinates) distance | number | Distance (in kilometers) between the probe and the road bearing | number | The bearing of the road at the location that matched

matchTrace

var probematch = require('@mapbox/probematch');

var roads = /* FeatureCollection of road geometries */;
var matcher = probematch(roads, {/* configuration */});

var results = matcher.matchTrace(line);

matchTrace returns an array of match results. The order of results is the same as the order of the coordinates in the input trace. This means that the zeroeth element in the matchTrace result is an array of possible matches for the zeroeth coordinate, and so on.