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

Exception raised when no matching node is found #5

Open
Huzaifg opened this issue Jun 28, 2021 · 6 comments
Open

Exception raised when no matching node is found #5

Huzaifg opened this issue Jun 28, 2021 · 6 comments

Comments

@Huzaifg
Copy link

Huzaifg commented Jun 28, 2021

matching.match(graph, track, method='hmm') raises an exception when no matching node is found and stops the program. Can we skip the point is there is no matching node found in order to prevent the program from ending?

@arthurdjn
Copy link
Owner

Currently I don't think it is possible. I also want to add a feature like that, but it requires to reformat the code...
However I think you can tune these parameters to have a similar behavior: https://github.com/arthurdjn/noiseplanet/blob/master/noiseplanet/matcher/model/leuven.py#L106

Hope it helps !

@Huzaifg
Copy link
Author

Huzaifg commented Jun 29, 2021

Okay! Thanks. Yes I am trying to tune them now. However I am getting a new error

--------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-100-d927c3d75145> in <module>
      1 try:
----> 2     track_coor, route_corr, edgeid, stats = matching.match(G, track, method='hmm')
      3 except Exception as  e:
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/noiseplanet/matcher/matching.py in match(graph, track, method)
     62     elif method == 'hmm':
---> 63         track_corr, route_corr, edgeid, stats = model.match_leuven(graph, track)
     64     return track_corr, route_corr, edgeid, stats
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/noiseplanet/matcher/model/leuven.py in match_leuven(graph, track)
    135     for i in range(len(track) - 1):
--> 136         if edgeid[i] != edgeid[i+1]:
    137             route.append(track_corr[i])
IndexError: list index out of range

This is due to the match function from Leuven returning empty states (checked the length of the states returned). Trying to figure out why this is happening. This is for the DistanceMatcher with the default settings . When I use the NewsonKrummMatcher I get a ValueError: math domain error at lat2 = asin(sin(lat1) * cos(d) + cos(lat1) * sin(d) * cos(bearing)) which is wierd.

If you have any insights as to why the match function returns empty states, please do let me know. There is also a similar issue raised on the leuven repo.
wannesm/LeuvenMapMatching#15 (comment)

Best

@arthurdjn
Copy link
Owner

Seems like I need to dive a little deeper in the code. I will try to figure it out this weekend, if I find any fixes I will update this thread !

@Laura0106
Copy link

Laura0106 commented Jul 6, 2021

matching.match(graph, track, method='hmm') raises an exception when no matching node is found and stops the program. Can we skip the point is there is no matching node found in order to prevent the program from ending?

Hello! I am also facing this problem, Have you figured it out? Thanks!

@Huzaifg
Copy link
Author

Huzaifg commented Jul 6, 2021

matching.match(graph, track, method='hmm') raises an exception when no matching node is found and stops the program. Can we skip the point is there is no matching node found in order to prevent the program from ending?

Hello! I am also facing this problem, Have you figured it out? Thanks!

Hello! The only way I could solve this is by playing around with the parametrers (max_dist , max_dist_init etc) defined while generating a DistanceMatcher object

@Laura0106
Copy link

Laura0106 commented Jul 7, 2021

Okay! Thanks. Yes I am trying to tune them now. However I am getting a new error

--------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-100-d927c3d75145> in <module>
      1 try:
----> 2     track_coor, route_corr, edgeid, stats = matching.match(G, track, method='hmm')
      3 except Exception as  e:
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/noiseplanet/matcher/matching.py in match(graph, track, method)
     62     elif method == 'hmm':
---> 63         track_corr, route_corr, edgeid, stats = model.match_leuven(graph, track)
     64     return track_corr, route_corr, edgeid, stats
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/noiseplanet/matcher/model/leuven.py in match_leuven(graph, track)
    135     for i in range(len(track) - 1):
--> 136         if edgeid[i] != edgeid[i+1]:
    137             route.append(track_corr[i])
IndexError: list index out of range

This is due to the match function from Leuven returning empty states (checked the length of the states returned). Trying to figure out why this is happening. This is for the DistanceMatcher with the default settings . When I use the NewsonKrummMatcher I get a ValueError: math domain error at lat2 = asin(sin(lat1) * cos(d) + cos(lat1) * sin(d) * cos(bearing)) which is wierd.

If you have any insights as to why the match function returns empty states, please do let me know. There is also a similar issue raised on the leuven repo.
wannesm/LeuvenMapMatching#15 (comment)

Best

Hello, dear Huzaifg!
The same problem happened to me. Have you progressed ? Thanks in advance!

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

3 participants