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

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

Closed
CreativeSelf0 opened this issue Nov 23, 2021 · 7 comments
Closed

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

CreativeSelf0 opened this issue Nov 23, 2021 · 7 comments

Comments

@CreativeSelf0
Copy link

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
Copy link

fakerms commented Nov 25, 2021

Fixed in wannesm/LeuvenMapMatching#22

@1213314896
Copy link

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

@jks-liu
Copy link

jks-liu commented Dec 29, 2021

An workaround is set use_rtree=False in below line.

map_con = InMemMap("myosm", use_latlon=True, use_rtree=True, index_edges=True)

@1213314896
Copy link

An workaround is set use_rtree=False in below line.

map_con = InMemMap("myosm", use_latlon=True, use_rtree=True, index_edges=True)

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
Copy link

jks-liu commented Dec 31, 2021

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

@jks-liu
Copy link

jks-liu commented Jan 1, 2022

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

@CreativeSelf0
Copy link
Author

Thanks.

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

4 participants