Matchers

There are several matchers that can be used to determine the road that a coordinate is matched to. Matchers may have tradeoffs between speed and accuracy.

Available Matchers

For readability, the full path is listed below and not used in other parts of the documentation.

LCSS

class LCSSMatcher(road_map: mappymatch.maps.map_interface.MapInterface, distance_epsilon: float = 50.0, similarity_cutoff: float = 0.9, cutting_threshold: float = 10.0, random_cuts: int = 0, distance_threshold: float = 10000)[source]

A map matcher based on the paper:

Zhu, Lei, Jacob R. Holden, and Jeffrey D. Gonder. “Trajectory Segmentation Map-Matching Approach for Large-Scale, High-Resolution GPS Data.” Transportation Research Record: Journal of the Transportation Research Board 2645 (2017): 67-75.

Parameters
  • road_map – The road map to use for matching

  • distance_epsilon – The distance epsilon to use for matching (default: 50 meters)

  • similarity_cutoff – The similarity cutoff to use for stopping the algorithm (default: 0.9)

  • cutting_threshold – The distance threshold to use for computing cutting points (default: 10 meters)

  • random_cuts – The number of random cuts to add at each iteration (default: 0)

  • distance_threshold – The distance threshold above which no match is made (default: 10000 meters)

match_trace(trace: mappymatch.constructs.trace.Trace) mappymatch.matchers.match_result.MatchResult[source]

Take in a trace of gps points and return a list of matching link ids

Parameters

trace – The trace to match

Returns

A list of Match objects

match_trace_batch(trace_batch: List[mappymatch.constructs.trace.Trace], processes: int = 1) List[mappymatch.matchers.match_result.MatchResult][source]

Take in a batch of traces and return a batch of matching link ids

Parameters

trace_batch – The batch of traces to match

Returns

A batch of Match objects

Line Snap

class LineSnapMatcher(road_map: mappymatch.maps.map_interface.MapInterface)[source]

A crude (but fast) map matcher that just snaps points to the nearest road network link.

map

The map to match against

match_trace(trace: mappymatch.constructs.trace.Trace) mappymatch.matchers.match_result.MatchResult[source]

Take in a trace of gps points and return a list of matching link ids

Parameters

trace – The trace to match

Returns

A list of Match objects

match_trace_batch(trace_batch: List[mappymatch.constructs.trace.Trace]) List[mappymatch.matchers.match_result.MatchResult][source]

Take in a batch of traces and return a batch of matching link ids

Parameters

trace_batch – The batch of traces to match

Returns

A batch of Match objects

Valhalla

class ValhallaMatcher(valhalla_url='https://valhalla1.openstreetmap.de/trace_attributes', cost_model='auto', shape_match='map_snap', attributes={'edge.length', 'edge.speed'})[source]

pings a Valhalla server for map matching

match_trace(trace: mappymatch.constructs.trace.Trace) mappymatch.matchers.match_result.MatchResult[source]

Take in a trace of gps points and return a list of matching link ids

Parameters

trace – The trace to match

Returns

A list of Match objects

match_trace_batch(trace_batch: list[Trace]) list[MatchResult][source]

Take in a batch of traces and return a batch of matching link ids

Parameters

trace_batch – The batch of traces to match

Returns

A batch of Match objects

Osrm

class OsrmMatcher(osrm_address='http://router.project-osrm.org', osrm_profile='driving', osrm_version='v1')[source]

pings an OSRM server for map matching

match_trace(trace: mappymatch.constructs.trace.Trace) mappymatch.matchers.match_result.MatchResult[source]

Take in a trace of gps points and return a list of matching link ids

Parameters

trace – The trace to match

Returns

A list of Match objects

match_trace_batch(trace_batch: list[Trace]) list[MatchResult][source]

Take in a batch of traces and return a batch of matching link ids

Parameters

trace_batch – The batch of traces to match

Returns

A batch of Match objects

Matcher Inferface

Each Matcher class must conform to the matcher interface defined below.

class MatcherInterface[source]

Abstract base class for a Matcher

abstract match_trace(trace: mappymatch.constructs.trace.Trace) mappymatch.matchers.match_result.MatchResult[source]

Take in a trace of gps points and return a list of matching link ids

Parameters

trace – The trace to match

Returns

A list of Match objects

abstract match_trace_batch(trace_batch: List[mappymatch.constructs.trace.Trace]) List[mappymatch.matchers.match_result.MatchResult][source]

Take in a batch of traces and return a batch of matching link ids

Parameters

trace_batch – The batch of traces to match

Returns

A batch of Match objects