Skip to content
GuidesBlogPlaygroundDashboard

Match GPS coordinates to the road network

MapMatchResult MapMatch.Match(MapMatchMatchParamsparameters, CancellationTokencancellationToken = default)
POST/api/v1/map-match

Match GPS coordinates to the road network

ParametersExpand Collapse
MapMatchMatchParams parameters
required IReadOnlyList<Coordinate> coordinates

GPS coordinates to match, in order of travel (max 50 points)

required Double Lat

Latitude in decimal degrees (-90 to 90)

maximum90
minimum-90
required Double Lng

Longitude in decimal degrees (-180 to 180)

maximum180
minimum-180
IReadOnlyList<Double>? radiuses

Search radius per coordinate in meters. Must have the same length as coordinates or be omitted entirely. Default: 50m per point.

ReturnsExpand Collapse
class MapMatchResult:

Map matching result as a GeoJSON FeatureCollection. Each Feature is a snapped tracepoint. The top-level matchings array contains the matched sub-routes connecting consecutive tracepoints.

required IReadOnlyList<Feature> Features

Snapped tracepoint Features in input order

required GeoJsonGeometry Geometry

GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints.

required Coordinates Coordinates

Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc.

One of the following:
IReadOnlyList<Double>
IReadOnlyList<IReadOnlyList<Double>>
IReadOnlyList<IReadOnlyList<IReadOnlyList<Double>>>
IReadOnlyList<IReadOnlyList<IReadOnlyList<IReadOnlyList<Double>>>>
required Type Type

Geometry type

One of the following:
"Point"Point
"LineString"LineString
"Polygon"Polygon
"MultiPoint"MultiPoint
"MultiLineString"MultiLineString
"MultiPolygon"MultiPolygon
required Properties Properties
Double DistanceM

Distance from the original GPS point to the snapped point in meters

Long EdgeID

Road edge ID the point was snapped to

Long MatchingsIndex

Index into the matchings array indicating which matching sub-route this point belongs to

string? Name

Road name at the snapped point

IReadOnlyList<Double> Original

Original GPS coordinate as [lng, lat]

Long WaypointIndex

Index of this tracepoint in the original coordinates array

required Type Type
required IReadOnlyList<IReadOnlyDictionary<string, JsonElement>> Matchings

Matched sub-routes. Each matching connects a contiguous sequence of tracepoints that could be matched to roads.

required Type Type

Match GPS coordinates to the road network

MapMatchMatchParams parameters = new()
{
    Coordinates =
    [
        new()
        {
            Lat = 48.8566,
            Lng = 2.3522,
        },
        new()
        {
            Lat = 48.857,
            Lng = 2.353,
        },
        new()
        {
            Lat = 48.8575,
            Lng = 2.354,
        },
    ],
};

var mapMatchResult = await client.MapMatch.Match(parameters);

Console.WriteLine(mapMatchResult);
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          2.3522,
          48.8566
        ],
        "type": "Point"
      },
      "properties": {
        "distance_m": 0,
        "edge_id": 0,
        "matchings_index": 0,
        "name": "name",
        "original": [
          0,
          0
        ],
        "waypoint_index": 0
      },
      "type": "Feature"
    }
  ],
  "matchings": [
    {
      "foo": "bar"
    }
  ],
  "type": "FeatureCollection"
}
Returns Examples
{
  "features": [
    {
      "geometry": {
        "coordinates": [
          2.3522,
          48.8566
        ],
        "type": "Point"
      },
      "properties": {
        "distance_m": 0,
        "edge_id": 0,
        "matchings_index": 0,
        "name": "name",
        "original": [
          0,
          0
        ],
        "waypoint_index": 0
      },
      "type": "Feature"
    }
  ],
  "matchings": [
    {
      "foo": "bar"
    }
  ],
  "type": "FeatureCollection"
}