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 12 forks source link

'Index' object has no attribute 'upsert' #11

Closed CreativeSelf0 closed 1 year ago

CreativeSelf0 commented 2 years ago

Hello there,

I'm trying to use noiseplanet to correct GPS corrd. However, when using hmm method it returns this error message.

Any ideas?

Thanks

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_23918/3256148260.py in <module>
----> 1 track_coor, route_corr, edgeid, stats = matching.match(graph, lat_long_data_old, method='hmm')

~/anaconda3/envs/data-env/lib/python3.9/site-packages/noiseplanet/matcher/matching.py in match(graph, track, method)
     61         track_corr, route_corr, edgeid, stats = model.match_nearest_edge(graph, track)
     62     elif method == 'hmm':
---> 63         track_corr, route_corr, edgeid, stats = model.match_leuven(graph, track)
     64     return track_corr, route_corr, edgeid, stats
     65 

~/anaconda3/envs/data-env/lib/python3.9/site-packages/noiseplanet/matcher/model/leuven.py in match_leuven(graph, track)
     94         lat = graph.nodes[node]['y']
     95         lon = graph.nodes[node]['x']
---> 96         map_con.add_node(node, (lat, lon))
     97     edges_id = list(graph.edges)
     98     for edge in edges_id:

~/anaconda3/envs/data-env/lib/python3.9/site-packages/leuvenmapmatching/map/inmem.py in add_node(self, node, loc)
    191             if type(node) is not int:
    192                 raise Exception(f"Rtree index only supports integer keys for vertices")
--> 193             self.rtree.upsert(node, (loc[0], loc[1], loc[0], loc[1]))
    194 
    195     def del_node(self, node):

AttributeError: 'Index' object has no attribute 'upsert'
fakerms commented 2 years ago

Fixed in https://github.com/wannesm/LeuvenMapMatching/pull/22

1213314896 commented 2 years ago

any idea? don't know how to fix it !!

jks-liu commented 2 years ago

An workaround is set use_rtree=False in below line.

https://github.com/arthurdjn/noiseplanet/blob/56f4ceb495ac31e04f70b940b3abe26410b1d06c/noiseplanet/matcher/model/leuven.py#L90

1213314896 commented 2 years ago

An workaround is set use_rtree=False in below line.

https://github.com/arthurdjn/noiseplanet/blob/56f4ceb495ac31e04f70b940b3abe26410b1d06c/noiseplanet/matcher/model/leuven.py#L90

Dear Liu, Thank u for your helping.

could I ask one more question? h do you have an error(the IndexError: index 12 is out of bounds for axis 0 with size 12)? sometimes it can be run correctly for some WGS-84(waypoint). Sometimes it will have an error!

Error code with data:

import numpy as np from noiseplanet.matcher.model.route import route_from_track, graph_from_track from noiseplanet.matcher import matching import pandas as pd

track = np.array([[22.268942156, 114.184837977], [22.26886763, 114.184626828], [22.26876443, 114.184181684], [22.268763939, 114.184155534], [22.268766766, 114.184134369], [22.268774784, 114.184118914], [22.268783376, 114.184106381], [22.268798513, 114.184089471], [22.26892887, 114.18396158], [22.269265791, 114.183630446], [22.269747789, 114.183162936], [22.270157877, 114.182682855]]) graph = matching.model.graph_from_track(track) track_coor, route_corr, edgeid, stats = matching.match(graph, track, method='hmm')

jks-liu commented 2 years ago

I had this error before. I will request a pull of my solution.

jks-liu commented 2 years ago

@1213314896 I created a new issue for it. #13

CreativeSelf0 commented 1 year ago

Thanks.