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

How to exclude the first/last edges from the match if they have only a small overlap with the source trajectory? #47

Open
lukasballo opened this issue May 12, 2023 · 1 comment

Comments

@lukasballo
Copy link

How can we exclude the nodes 8 and/or 6 from the result if only a small portion of the edges 8-2 and 5-6 overlaps with the source trajectory? E.g., enforcing an overlap of >90%, otherwise removing these nodes from the result?

Thanks for any ideas!

matcher = DistanceMatcher(map_con)
matcher.match(path)
nodes = matcher.path_pred_onlynodes
# result: [8, 2, 1, 5, 6]

match_plot

@wannesm
Copy link
Owner

wannesm commented May 16, 2023

This could be possible but requires changing the inner workings of the matcher (the initial search has an argument to use edges or not, but it is not exposed).

In post-processing, however, this would be easier. You can inspect the found path and see how close the match is to the vertex. Either by computing the distance or by checking the relative distance wrt the edge (0 and 1 are the two ends of the edge). For example, for the first observation O0, this is available as

if matcher.lattice_best[0].edge_m.ti < 0.1:
    print(f'Close to node: {matcher.lattice_best[0].edge_m.l1}
elif matcher.lattice_best[0].edge_m.ti > 0.9:
    print(f'Close to node: {matcher.lattice_best[0].edge_m.l2}
else:
    print('Node not close to a vertex')

The distance between the interpolated point and the end of the edge would be:

map_con.distance(matcher.lattice_best[0].edge_m.pi, matcher.lattice_best[0].edge_m.p1)

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