NREL / mappymatch

Pure-python package for map matching
http://mappymatch.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
56 stars 19 forks source link

OSRM matcher results do not contain expected attributes #181

Open joshuacroff opened 1 month ago

joshuacroff commented 1 month ago

Hello,

I've been using the OsrmMatcher in the mappymatch library and I've noticed that the MatchResult objects returned by the match_trace method do not contain geometry or distance to road information for the matched segments.

Here's a simplified version of the code I'm using:

import pandas as pd
import geopandas as gpd
from mappymatch.constructs.trace import Trace
from mappymatch.matchers.osrm import OsrmMatcher

# read gps points from file
gdf = gpd.read_file(file_path)

# create trace object from geodataframe
trace = Trace.from_geo_dataframe(gdf, xy=False)

# create OSRM matcher
matcher = OsrmMatcher()

# match trace
match_result = matcher.match_trace(trace)

When I inspect the MatchResult object, I see that each match has aroad_id attribute, but there's no geometry or distance information available (see screenshot).

Screenshot 2024-05-17 at 11 11 13 AM

It seems like perhaps the OSRM server does not return geometry information as part of the map matching process, but it would be very helpful if the MatchResult objects could include this information. This would allow users to visualize the matched segments without having to manually retrieve the geometry from their original map data.

Is there a way to include geometry information in the MatchResult objects, or could this be considered for a future update? Is there something off about my code or a step I've missed?

Thank you for your time and consideration.

nreinicke commented 1 month ago

Thanks for reaching out!

The OsrmMatcher was introduced more of a proof of concept and we haven't been using it much in our own map matching applications. So, it hasn't received much attention beyond the initial writing of it. That being said, it's cool to hear that you're getting some traction out of it.

It does look like OSRM returns geometry from their API and we actually have a todo to get that injected into the match results.

I can put together an issue for finishing the work on that and hopefully we can release that feature in the near future. And, if you're interested in taking a stab we always welcome contributions 😄

joshuacroff commented 1 month ago

@nreinicke thank you for your work on the library! It's been very helpful for work I'm doing to conflate GPS data to networks quickly and somewhat painlessly! It's a complex issue as you know. ;). Thanks for opening an issue! I'll take a look at the code and see if I might be able to roll my sleeves up and contribute on this feature.

nreinicke commented 1 month ago

@joshuacroff that sounds great! I started the issue #182 but let me know if I can expand on anything there.