arthurdjn / noiseplanet

A Python package for Map Matching and Mapping. Research work for Noise Planet center.
http://noise-planet.org/
Apache License 2.0
51 stars 13 forks source link

Exception raised when no matching node is found #5

Open Huzaifg opened 3 years ago

Huzaifg commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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. https://github.com/wannesm/LeuvenMapMatching/issues/15#issue-930321194

Best

arthurdjn commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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!

ZeroCSIS commented 2 months ago

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!

I found the same problem, have you solved it?

Huzaifg commented 2 months ago

Hello,

This was very long ago and I work on different things now. Sorry, I will not be able to help you on this. Good luck!

ZeroCSIS commented 2 months ago

Hello,

This was very long ago and I work on different things now. Sorry, I will not be able to help you on this. Good luck!

Thanks for your kind reply. I tried some other libs and it cloud work