cyang-kth / fmm

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

cpath and mgeom unmatched #256

Closed Vera977 closed 1 year ago

Vera977 commented 1 year ago

output file

mgeom is the geometry of the cpath. My understanding is that mgeom should include the starting and ending latitude and longitude of each path in cpath. So should the number of lon-lat pairs in mgeom be supposed to be twice the number of paths in cpath? However, When I printed the outcomes of fmm, the lengths of mgeom and cpath were not matched.

Below left is the number of paths in cpath, and right is the number of lon-lat pairs in mgeom in my results. It seems that path and geometry do not correspond. So how can I extract the latitude and longitude of starting & end points of paths in cpath? Thanks!

4 5 18 34 33 42 59 73 47 59 29 65 8 11 51 78 16 116 43 54 57 82 25 59 25 37 4 20 20 41 15 28 62 119 29 81 12 14 40 71 31 41 18 20 15 23 47 82 89 171

cyang-kth commented 1 year ago

The mgeom path is not completely the geometry of cpath, since the trajectory may pass only part of the start and end edge. The lat lng pairs may be equal as it depends on the geometry of edges. You need to fetch the information yourself using the network object to get edge geometry.

image

Vera977 commented 1 year ago

@cyang-kth Thanks for your reply. I now understand the true meaning of mgeom. Another related issue is, when I looked up the edge_gdf in the network download from osm, I found the cpath id was not the id in edge_gdf. For example, a matched point's lon-lat geom in pgeom is (30.6677305956,104.063176281) and its traversed path id is 2274 in opath. So I looked up id 2274 in the geodataframe edge_gdf generated from edges.shp to get the edge geom. Then I plot the edge geometry (id 2274) and the matched point geom in a folium map. It seems that the opath id 2274 is not the edge_gdf id 2274. They are very far apart. Please see picture below. So how can I get the path geom information if the path id do not correspond to the edge id? Thanks! image

Vera977 commented 1 year ago

@cyang-kth Thanks for your reply. I now understand the true meaning of mgeom. Another related issue is, when I looked up the edge_gdf in the network download from osm, I found the cpath id was not the id in edge_gdf. For example, a matched point's lon-lat geom in pgeom is (30.6677305956,104.063176281) and its traversed path id is 2274 in opath. So I looked up id 2274 in the geodataframe edge_gdf generated from edges.shp to get the edge geom. Then I plot the edge geometry (id 2274) and the matched point geom in a folium map. It seems that the opath id 2274 is not the edge_gdf id 2274. They are very far apart. Please see picture below. So how can I get the path geom information if the path id do not correspond to the edge id? Thanks! image

I checked my code and found that I made a mistake. The opath id is exactly the edge id. Thanks, author! ^-^