Skip to content

Match

Match GPS trace to road network.

Parameters:

Name Type Description Default
coordinates

List of (lon, lat) tuples or MatchParameters object

None
timestamps

Timestamps for each coordinate

required
steps

Return route steps for each route leg

required
geometries

Geometry format: 'polyline', 'polyline6', or 'geojson'

required
overview

Overview detail: 'simplified', 'full', or 'false'

required
annotations

Annotation type string or list

required
radiuses

Search radius in meters for each coordinate

required
bearings

Bearing constraints

required
hints

Hints from previous request

required
approaches

Approach constraints

required
exclude

Road classes to avoid

required
generate_hints

Generate hints for response

required
snapping

Snapping mode

required
gaps

Gap handling: 'split' or 'ignore'

required
tidy

Clean up trace

required
waypoints

Waypoint indices to use

required

Returns:

Type Description

Match result as osrm.Object

Source code in osrm/__init__.py
def Match(self, coordinates=None, **kwargs):
    """
    Match GPS trace to road network.

    Args:
        coordinates: List of (lon, lat) tuples or MatchParameters object
        timestamps: Timestamps for each coordinate
        steps: Return route steps for each route leg
        geometries: Geometry format: 'polyline', 'polyline6', or 'geojson'
        overview: Overview detail: 'simplified', 'full', or 'false'
        annotations: Annotation type string or list
        radiuses: Search radius in meters for each coordinate
        bearings: Bearing constraints
        hints: Hints from previous request
        approaches: Approach constraints
        exclude: Road classes to avoid
        generate_hints: Generate hints for response
        snapping: Snapping mode
        gaps: Gap handling: 'split' or 'ignore'
        tidy: Clean up trace
        waypoints: Waypoint indices to use

    Returns:
        Match result as osrm.Object
    """        
    # Support traditional usage with MatchParameters object
    if isinstance(coordinates, MatchParameters):
        return self._engine.Match(coordinates).to_dict()

    # Convenience method: build parameters from kwargs
    params = MatchParameters()

    # Set coordinates
    if coordinates is not None:
        params.coordinates = coordinates

    # Set other parameters with automatic enum conversion
    for key, value in kwargs.items():
        _set_param(params, key, value)

    return self._engine.Match(params).to_dict()

Match Parameters

Bases: osrm.osrm_ext.RouteParameters

Overloaded function.

  1. __init__(self) -> None

Instantiates an instance of MatchParameters.

Examples:

>>> match_params = osrm.MatchParameters(
        coordinates = [(7.41337, 43.72956), (7.41546, 43.73077), (7.41862, 43.73216)],
        timestamps = [1424684612, 1424684616, 1424684620],
        gaps = 'split',
        tidy = True
    )
>>> match_params.IsValid()
True

Parameters:

Name Type Description Default
timestamps list of unsigned int

Timestamps for the input locations in seconds since UNIX epoch. (default [])

required
gaps list of 'split' | 'ignore'

Allows the input track splitting based on huge timestamp gaps between points. (default [])

required
tidy bool

Allows the input track modification to obtain better matching quality for noisy tracks. (default False)

required
RouteParameters RouteParameters

Keyword arguments from parent class.

required

Returns:

Name Type Description
__init__ MatchParameters

A MatchParameters object, for usage in Match.

IsValid bool

A bool value denoting validity of parameter values.

Attributes:

Name Type Description
timestamps list of unsigned int

Timestamps for the input locations in seconds since UNIX epoch.

gaps string

Allows the input track splitting based on huge timestamp gaps between points.

tidy bool

Allows the input track modification to obtain better matching quality for noisy tracks.

RouteParameters RouteParameters

Attributes from parent class.

  1. __init__(self, timestamps: collections.abc.Sequence[int] = [], gaps: osrm.osrm_ext.MatchGapsType = '', tidy: bool = False, steps: bool = False, number_of_alternatives: int = 0, annotations: collections.abc.Sequence[osrm.osrm_ext.RouteAnnotationsType] = [], geometries: osrm.osrm_ext.RouteGeometriesType = '', overview: osrm.osrm_ext.RouteOverviewType = '', continue_straight: osrm.osrm_ext.OptionalBool = <osrm.osrm_ext.OptionalBool object at 0x7f945fee0cb0>, waypoints: collections.abc.Sequence[int] = [], coordinates: collections.abc.Sequence[osrm.osrm_ext.Coordinate] = [], hints: collections.abc.Sequence[std::optional<osrm::engine::Hint>] = [], radiuses: collections.abc.Sequence[osrm.osrm_ext.OptionalDouble] = [], bearings: collections.abc.Sequence[osrm.osrm_ext.OptionalBearing] = [], approaches: collections.abc.Sequence[osrm.osrm_ext.OptionalApproach] = [], generate_hints: bool = True, exclude: collections.abc.Sequence[str] = [], snapping: osrm.osrm_ext.SnappingType = '') -> None