cyang-kth / fmm

Fast map matching, an open source framework in C++
https://fmm-wiki.github.io/
Apache License 2.0
878 stars 205 forks source link

Error occurs when getting input from file - RuntimeError:stoi #192

Closed ThirasaraAriyarathna closed 3 years ago

ThirasaraAriyarathna commented 3 years ago

Traceback (most recent call last): File "porto.py", line 44, in status = model.match_gps_file(input_config, result_config, fmm_config, use_omp=True) File "/Usr/miniconda3/envs/py27/lib/python2.7/site-packages/fmm.py", line 1533, in match_gps_file return _fmm.FastMapMatch_match_gps_file(self, gps_config, result_config, config, use_omp) RuntimeError: stoi

This error occurs when I tried to get input from a file. However, using the same ubodt.txt I can match wkts. Following are the configurations of input and output files.

gps file : id column : TRIP_ID geom column : geometry timestamp column : timestamp x column : x y column : y GPS point : false

Result file : Output fields: opath pgeom offset error spdist cpath tpath mgeom ep tp length duration speed

And also I get following warning. [2021-05-26 13:33:00.232] [warning] [ubodt.cpp:242] Load factor is too large.

Road network data: Graph nodes 761535 edges 1839349

cyang-kth commented 3 years ago

From your description, the gps file is empty, you need to specify a file name. Please check the example folder for notebook files.

ThirasaraAriyarathna commented 3 years ago

I have specified an output filename yet after printing the result config, that's why it's not printing in the input config. Following is my code. This works fine with another dataset (Geolife dataset). Now I am trying to match the GPS points of the Porto taxi dataset. This doesn't work only when I'm getting the input from a file. Otherwise, if I use model.match_wkt(wkt,fmm_config) it works fine.

Thank you very much.

from fmm import Network,NetworkGraph,FastMapMatch,FastMapMatchConfig,UBODT,GPSConfig,ResultConfig,UBODTGenAlgorithm import os

network = Network("porto-network-drive/edges.shp","fid","u","v") print "Nodes {} edges {}".format(network.get_node_count(),network.get_edge_count()) graph = NetworkGraph(network)

ubodt_gen = UBODTGenAlgorithm(network,graph) status = ubodt_gen.generate_ubodt("data/ubodt.txt", 0.03, binary=False, use_omp=True) print status

ubodt = UBODT.read_ubodt_csv("porto-network-drive/ubodt.txt") model = FastMapMatch(network,graph,ubodt)

k = 32 radius = 0.4 gps_error = 0.001 fmm_config = FastMapMatchConfig(k,radius,gps_error)

input_config = GPSConfig() input_config.id = "TRIP_ID" input_config.geom = "geometry" input_config.timestamp = "timestamps" print input_config.to_string()

result_config = ResultConfig() result_config.output_config.write_tpath = True result_config.output_config.write_pgeom = True result_config.output_config.write_length = True result_config.output_config.write_duration = True result_config.output_config.write_speed = True result_config.output_config.write_opath = True result_config.output_config.write_ogeom = True result_config.output_config.write_offset = True result_config.output_config.write_error = True result_config.output_config.write_spdist = True result_config.output_config.write_ep = True result_config.output_config.write_tp = True print result_config.to_string()

input_config.file = 'Trajectories/Porto/20000001_porto.csv' result_config.file = 'Trajectories/Porto/matched_20000001_porto.csv' status = model.match_gps_file(input_config, result_config, fmm_config, use_omp=True) print status

cyang-kth commented 3 years ago

The reason you did see anything in the file field is that you assign the file field after the print function in your code.

Also make sure that your trip.csv file format match this one https://github.com/cyang-kth/fmm/blob/master/example/data/trips.csv including your header name, separater of ;, geometry format.