Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LCSS matcher failing #202

Open
iaguerri opened this issue Jan 20, 2025 · 6 comments
Open

LCSS matcher failing #202

iaguerri opened this issue Jan 20, 2025 · 6 comments

Comments

@iaguerri
Copy link

Hey there!

I'm using Mappymatch for GPS coordinates. In this example, I have 93 coordinates.
While the tool is very accurate, I have encountered a problem—a single trace loops twice within a circuit. During the first lap, the loop is matched correctly.
In the photograph, the red line represents the Path result, the yellow points represent the trace, and the black line represents the OSM roads used for matching.
As shown in the second photo, points 44 and 45 are quite close to the road, so the Path should ideally follow that route. However, instead of continuing, it incorrectly takes the "exit" road.

I have tried adjusting the parameters but haven't determined the issue. Why does it divert from the road when half of the points are remaining?

Image

Image

Image

Thanks in advance 😄

@iaguerri
Copy link
Author

iaguerri commented Feb 20, 2025

Hello @nreinicke, any updates on this?
Best!

@nreinicke
Copy link
Collaborator

@iaguerri - Thanks for reaching out and apologies that I haven't had a chance to look at this! I don't know exactly why it's not catching this edge case but perhaps you would be able to share the trace that your using so I can take a look at it on my end?

@iaguerri
Copy link
Author

Hey @nreinicke here you have the Trace !

Please tell me if there are any doubts

package9_ok_sequence.csv

The NxMap is the one of Madrid

@iaguerri
Copy link
Author

The problem isn’t with this specific trip, but rather that Mappymatch struggles with trips that loop over the same trajectories, even when adjusting parameters like distance_epsilon, cutting_threshold.

@nreinicke
Copy link
Collaborator

@iaguerri - I just got a chance to look at this. I think I was able to get the trace matching appropriately by setting the cutting threshold to 20.0, here's the code I used:

from mappymatch.constructs.trace import Trace
from mappymatch.constructs.geofence import Geofence
from mappymatch.maps.nx.nx_map import NxMap, NetworkType
from mappymatch.utils.plot import plot_matches, plot_path
from mappymatch.matchers.lcss.lcss import LCSSMatcher

trace = Trace.from_csv("package9_ok_sequence.csv", lat_column="lat", lon_column="long")

geofence = Geofence.from_trace(trace, padding=2e3)

nx_map = NxMap.from_geofence(
    geofence,
    network_type=NetworkType.DRIVE,
)

matcher = LCSSMatcher(nx_map, cutting_threshold=20.0)

match_result = matcher.match_trace(trace)

plot_matches(match_result, crs=match_result.crs)

plot_path(match_result.path, crs=match_result.crs)

Which resulted in this for the matches:

Image

And this for the path:

Image

Let me know if you're still not able to reproduce.

@nreinicke
Copy link
Collaborator

Loops are definitely challenging for the algorithm and so hopefully this works for your use. Maybe in the future we can spend more time investigating these edge cases and trying to make the algorithm more robust 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants