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

match method returns more points than input coordinates #43

Open
CarreauClement opened this issue Mar 16, 2023 · 3 comments
Open

match method returns more points than input coordinates #43

CarreauClement opened this issue Mar 16, 2023 · 3 comments

Comments

@CarreauClement
Copy link

Hello,

Here's the example code

matcher = DistanceMatcher(graph, max_dist=12000, max_lattice_width=2)
coordinates = [[40.756470508651724,  -73.97319052003208]]

matcher.match(coordinates)
nodes = matcher.path_pred_onlynodes
print(len(nodes))

When I run this code I get 2 nodes while I only had one coordinate.
The nodes are ['7737876085', '6452768049']

Can you explain this please ?

Thanks a lot

@wannesm
Copy link
Owner

wannesm commented Mar 16, 2023

The default setting is to match edges. The path_pred_onlynodes shows the nodes, in this case 2 because and edge is between two nodes. You can also try path_pred to see the edges more explicitly.

@CarreauClement
Copy link
Author

Thanks. Is there a way to match only the nearest node from each of my coordinates ?

@wannesm
Copy link
Owner

wannesm commented Mar 17, 2023

For each match you can ask for the location and where this point is on the edge (this is also used for the plot function). For the first match like in this case you could check:

edge = matcher.lattice_best[0].edge_m
if edge.ti < 0.5:
  print(f"First node is {edge.l1}")
else:
  print(f"First node is {edge.l2}")

Starting from the closest node on the first edge makes sense, so in the master branch the path_pred_onlynodes function has been updated to use this by default.

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