cyang-kth / fmm

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

Error Loading Shapefile: Missing id, source, and target Fields #276

Closed hhtjulie closed 1 month ago

hhtjulie commented 1 month ago

A clear and concise description of the bug: I referred to #246 & #138 to download my .shp files from OSMx, but the following bug still occurs:

[critical][network.cpp:97 ] Field not found: id index -1, source index -1, target index -1
terminate called after throwing an instance of 'std::runtime_error'
  what():  Field not found: id index -1, source index -1, target index -1
Aborted (core dumped)

I checked edges.shp, and it does not contain id index, source index, or target index.

(base) juju@JujudeMacBook-Pro stockholm % ogrinfo -al -so ./edges.shp                                                                                           
INFO: Open of ./edges.shp
      using driver ESRI Shapefile successful.

Layer name: edges
Metadata:
  DBF_DATE_LAST_UPDATE=2024-09-11
Geometry: Line String
Feature Count: 102088
Extent: (17.521229, 59.148238) - (18.389798, 59.817695)
Layer SRS WKT:
GEOGCRS["WGS 84",
    DATUM["World Geodetic System 1984",
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["latitude",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["longitude",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    ID["EPSG",4326]]
Data axis to CRS axis mapping: 2,1
u: Integer64 (18.0)
v: Integer64 (18.0)
key: Integer64 (18.0)
osmid: String (254.0)
oneway: Integer(Boolean) (1.0)
name: String (83.0)
highway: String (80.0)
maxspeed: String (80.0)
reversed: String (80.0)
length: Real (24.15)
lanes: String (80.0)
bridge: String (80.0)
access: String (80.0)
ref: String (80.0)
junction: String (80.0)
tunnel: String (80.0)
width: String (80.0)
service: String (80.0)
fid: Integer64 (18.0)

How can I resolve this?

cyang-kth commented 1 month ago

You need to explicitly specify the name of the ID, source and target column name of the network file.

This is a Python example

https://github.com/cyang-kth/osm_mapmatching?tab=readme-ov-file#2-run-map-matching-with-fmm

network = Network("network/edges.shp","fid","u","v")

For other forms of configuration like xml and arguments see

https://fmm-wiki.github.io/docs/documentation/configuration/#fmm-and-stmatch