How to use properties file from Routing? graph.ch.weightings: [] is not equal to loaded [fastest|car]

There are some differences between OSM files for " Map Matching " and " Routing "

“Map Matching” doesn’t work with files of Routing

For “Map Matching”:

java -jar matching-web/target/graphhopper-map-matching-web-*.jar import *.osm.pbf

image

For “Routing”:

./graphhopper.sh -a import -i

image

image

So there are some differences in proporties file

When I use properties file form Routing for MapMathing I get the next error:

 java.lang.IllegalStateException: Configured graph.ch.weightings: [] is not equal to loaded [fastest|car]
     at com.graphhopper.storage.GraphHopperStorage.loadExisting(GraphHopperStorage.java:254)
     at com.graphhopper.GraphHopper.load(GraphHopper.java:781)
     at com.graphhopper.matching.MatchCommand.<init>(MatchCommand.java:45)
     at com.example.gpstrack.Map.onConnected(Map.java:811)

In my app I want to use routing and map matching at the same time and use the same files

It seems I need two instance of Graphhopper anyway:

    graphHopperRouting.load("*/graphhopper/country-gh");

    graphHopperMapMatching.getCHFactoryDecorator().setEnabled(false);
    graphHopperMapMatching.load(("*/graphhopper/country-gh");

But how to init the same files? If could init different proporties files, something like this:

image

But I believe default constructor of Graphhopper class won’t allow such manipulations, it expects path to the folder

Any feedback?

You need to make sure that you are using the same configuration for e.g. prepare.ch.weightings

I mean there is no problem using two different folders: one for MapMatching and another one for Routing, with their own properties file it works fine

But I want to use only one folder, because files like “edge”, “geometry”, “location_index”, “names”, “nodes” are the same, only properties differs

Many phones don’t have a lot of storage memory

You can change the properties file to your needs. This is the “configuration file”.

I understand, but how to make one universal properties file which will work for MapMatching and for Routing at the same time, what can I change to make it work for both APIs?

Or I just can dynamically copy proporties files to that folder

For e.g. when App starts it copies first properties file to *gh folder (where “edge”, “geometry”, “location_index”, “names”, “nodes” are placed) and loads one instance of GraphHopper for Routing
after that app deletes that properties file, copies another properties file to *gh folder and loads another instance of GraphHopper for MapMatching

As noted above:

When both graphs are created with the same properties you can use them for routing and map matching.

Well what does same configuration/properties mean? How to implement it, any examples?

What I did:

  1. downloaded osm.pbf file
  2. convert it with ./graphhopper.sh -a import map.osm.pbf
  3. convert it with java -jar matching-web/target/graphhopper-map-matching-web-*.jar import map.osm.pbf
  4. now I have two folders, one works for Routing and another one works for MapMatching

I also have this problem, have you solved this problem ?

no, GraphHopper’s “load” method expects path to folder, so the only way is to use the next crutch:

Dynamically copy properties files to that folder:
For e.g. when App starts it copies first properties file to *gh folder (where “edge”, “geometry”, “location_index”, “names”, “nodes” are placed) and loads one instance of GraphHopper for Routing
after that app deletes that properties file, copies another properties file to *gh folder and loads another instance of GraphHopper for MapMatching