Map Matcher

1. Introduction

Map matching denotes a procedure that assigns geographical objects to locations map.

Currently PySDK supports map matcher and point matcher by using MMaaS backend.

2. Implementation

Importing the libraries:

from here.platform.map_matcher import MapMatcher
from here.platform.platform import Platform

Initialize the platform:

platform = Platform()

List all available map versions

map_matcher_list = platform.map_matcher_map_versions()
map_matcher = map_matcher_list[0]
print(f"Hrn for map matcher - {map_matcher.hrn}, Version for map matcher - {map_matcher.version}")
Hrn for map matcher - hrn:here:data::olp-here:rib-2, Version for map matcher - 4898

Gets information for a specific map version

version = map_matcher.version
map_matcher = platform.get_map_matcher_map_version(version=version)
print(f"Hrn for map matcher - {map_matcher.hrn}, Version for map matcher - {map_matcher.version}")
Hrn for map matcher - hrn:here:data::olp-here:rib-2, Version for map matcher - 4898

Get matched path corresponding to the latitude and longitude.

lat_lon_1 = {"lat": 52, "lng": 13.26952}
lat_lon_2 = {"lat": 52.499, "lng": 13.26967}
lat_lon_3 = {"lat": 52.4129, "lng": 13.26967}
lat_lon_4 = {"lat": 52.4333, "lng": 13.26967}
lat_lon_list = [lat_lon_1, lat_lon_2, lat_lon_3, lat_lon_4]
matched_path_ref_list, matched_path_points_list = map_matcher.get_matched_path(
        road_access="car", interpolate=False, lat_lon_list=lat_lon_list
    )
print(f"Matched path reference list is {matched_path_ref_list}")
Matched path reference list is ['hrn:here:data::olp-here:rib-2:4898::23618358:here:cm:segment:171497010', 'hrn:here:data::olp-here:rib-2:4898::23618356:here:cm:segment:91863244']
print(f"Matched path point list is {matched_path_points_list}")
Matched path point list is [{'location': {'lat': 52.49932398104039, 'lng': 13.269906270312536}, 'offset': 0.8501558451373247, 'indexInTrace': 1, 'type': 'onRoad'}, {'location': {'lat': 52.43329894540396, 'lng': 13.269614321672163}, 'offset': 0.9019528021962357, 'indexInTrace': 3, 'type': 'onRoad'}]

Get matched point corresponding to the latitude and longitude.

lat_lon = {"lat": 52.340, "lng": 13.269528}
matched_path_ref, matched_path_points = map_matcher.get_matched_point(
        road_access="car", interpolate=False, lat_lon=lat_lon
    )
print(f"Matched path reference is {matched_path_ref}")
Matched path reference is ['hrn:here:data::olp-here:rib-2:4898::23618334:here:cm:segment:843749355']
print(f"Matched path point is {matched_path_points}")
Matched path point is [{'location': {'lat': 52.340213004805776, 'lng': 13.269294793481752}, 'offset': 0.7033118336414467, 'indexInTrace': 0, 'type': 'onRoad'}]

3. Download notebook

from IPython.display import display, FileLink
import os
url = os.path.abspath("")
notebook_name = 'map_matcher.ipynb'
notebook = FileLink(f"{url}/{notebook_name}", result_html_prefix="Click here to download: ")
display(notebook)

Click here to download: /builds/sdk/pysdk-nagini/dev_guide/notebooks/map_matcher.ipynb

results matching ""

    No results matching ""