Skip to content
GuidesBlogPlaygroundDashboard

Match GPS coordinates to the road network

mapMatch().match(MapMatchMatchParamsparams, RequestOptionsrequestOptions = RequestOptions.none()) : MapMatchResult
POST/api/v1/map-match

Match GPS coordinates to the road network

ParametersExpand Collapse
params: MapMatchMatchParams
mapMatchRequest: MapMatchRequest

GPS trace to snap to the road network. Provide an array of coordinate objects representing the GPS points. Maximum 50 points per request.

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.

features: List<Feature>

Snapped tracepoint Features in input order

geometry: GeoJsonGeometry

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

coordinates: Coordinates

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

One of the following:
List<Double>
List<List<Double>>
List<List<List<Double>>>
List<List<List<List<Double>>>>
type: Type

Geometry type

One of the following:
POINT("Point")
LINE_STRING("LineString")
POLYGON("Polygon")
MULTI_POINT("MultiPoint")
MULTI_LINE_STRING("MultiLineString")
MULTI_POLYGON("MultiPolygon")
properties: Properties
distanceM: Optional<Double>

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

edgeId: Optional<Long>

Road edge ID the point was snapped to

matchingsIndex: Optional<Long>

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

name: Optional<String>

Road name at the snapped point

original: Optional<List<Double>>

Original GPS coordinate as [lng, lat]

waypointIndex: Optional<Long>

Index of this tracepoint in the original coordinates array

type: Type
matchings: List<Matching>

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

type: Type

Match GPS coordinates to the road network

package com.plazafyi.example

import com.plazafyi.client.PlazaClient
import com.plazafyi.client.okhttp.PlazaOkHttpClient
import com.plazafyi.models.mapmatch.MapMatchMatchParams
import com.plazafyi.models.mapmatch.MapMatchRequest
import com.plazafyi.models.mapmatch.MapMatchResult

fun main() {
    val client: PlazaClient = PlazaOkHttpClient.fromEnv()

    val params: MapMatchRequest = MapMatchRequest.builder()
        .coordinates(listOf(
          MapMatchRequest.Coordinate.builder()
              .lat(48.8566)
              .lng(2.3522)
              .build(),
          MapMatchRequest.Coordinate.builder()
              .lat(48.857)
              .lng(2.353)
              .build(),
          MapMatchRequest.Coordinate.builder()
              .lat(48.8575)
              .lng(2.354)
              .build(),
        ))
        .build()
    val mapMatchResult: MapMatchResult = client.mapMatch().match(params)
}
{
  "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"
}