Skip to content

Run map matching

Can Yang edited this page Feb 7, 2020 · 10 revisions

Run map matching in C++

The programs take configuration in xml format as input

# cd to the example folder
cd example
# Run UBODT precomputation
ubodt_gen ubodt_config.xml

# Run ubodt in command line
ubodt_gen --network data/edges.shp --id id --source source --target target --output ubodt.txt --delta 4.0    

# Run map matching (Single processor)
fmm fmm_config.xml

# Run fmm or fmm_omp in command line
fmm --ubodt ubodt.txt --network data/edges.shp --gps data/trips.csv --output mr.txt --candidates 4 --radius 0.4 --error 0.5

# Run the parallelized version 
ubodt_gen_omp ubodt_config.xml
fmm_omp fmm_config.xml

Check the example folder for two sample configuration files and configuration for documentation.

If you want to write your own C++ program, you can check fmm.cpp for the detailed procedure of map matching.

Run map matching in python

After installing python extension, run fmm in python can be as simple as:

import fmm
# Load model from configuration file
model = fmm.MapMatcher("fmm_config.xml")

# Run map matching with wkt geometry as input

wkt = "LINESTRING (0.200812146892656 2.14088983050848,1.44262005649717 2.14879943502825,3.06408898305084 2.16066384180791,3.06408898305084 2.7103813559322,3.70872175141242 2.97930790960452,4.11606638418078 2.62337570621469)"

result = model.match_wkt(wkt)

# Print the result

print "Matched path geometry",result.mgeom
print "Matched points geometry",result.pgeom
print "Matched edge id",list(result.opath)
print "Matched path edges",list(result.cpath)

A demo is provided as fmm_demo.ipynb. Check the folder python for more information.