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

Network loaded in as shapefile doesn't seem to take into account "cost"s per edge #177

Closed MathiasVersichele closed 3 years ago

MathiasVersichele commented 3 years ago

I compiled a network shapefile with the same structure as the edges.shp file in the repo, so with these fields:

I took care to define segments in both directions as stated in the docs. I then read in the network as such:

from fmm import Network,NetworkGraph,STMATCH,STMATCHConfig
from fmm import GPSConfig,ResultConfig
network_car = Network("myshapefile.shp")
print("Nodes {} edges {}".format(network_car.get_node_count(),network_car.get_edge_count()))
graph_car = NetworkGraph(network_car)
model_car = STMATCH(network_car,graph_car)
...

I get the following output:

[2021-02-08 11:53:53.777] [info] [network.cpp:72] Read network from file myshapefile.shp
[2021-02-08 11:54:06.047] [info] [network.cpp:170] Number of edges 3495996 nodes 1587665
[2021-02-08 11:54:06.047] [info] [network.cpp:172] Field index: id 0 source 1 target 2

Map-matching works technically, but it seems like it's just calculating shortest paths instead of fastest paths. E.g.

image

Black is gps-line, red is map-matched result. In "Schouwen-Duiveland" it takes a route over smaller roads instead of the highway to the south (through "Zierikzee"). I checked locally with pgrouting, and with the provided shapefile it should take that highway.

I can't find any docs on how to make sure that the "cost" field is actually used... But it's very important to get correct results for me. To see whether this field was maybe "silently" used, I changed the fields name from "cost" to "ccost", and no errors are thrown and the results look the same. So pretty confident that it's not used right now... How can I make sure that it is used ?

MathiasVersichele commented 3 years ago

I'm beginning to fear custom costs aren't possible when looking at the source code. @cyang-kth could you confirm ? If this is the case, I won't be able to use this library :-(

cyang-kth commented 3 years ago

Currently there is no way to set custom cost as it calculate the shortest path from geometry.