If I want to use map matching, do I have to build a new maven project? Or other type of project is also okay? I’m new to maven project.
I created a dynamic web project. And I downloaded jars from mvn-graphhopper and mvn-map-matching. I added them in build path config. I imported com.graphhopper in a java file and the main code is from github-map-matching-java-usage. No mistake. But when i run it, error happened:
Exception in thread “main” java.lang.NoClassDefFoundError: gnu/trove/list/TIntList
I don’t know what to do. And I don’t know whether I should work with a new maven project or sth else.
added trove jar. new error:
Exception in thread “main” java.lang.UnsupportedOperationException: Cannot create DataReader. Solutions: avoid import via calling load directly, provide a DataReader or use e.g. GraphHopperOSM or a different subclass
at com.graphhopper.GraphHopper.createReader(GraphHopper.java:717)
at com.graphhopper.GraphHopper.importData(GraphHopper.java:710)
at com.graphhopper.GraphHopper.process(GraphHopper.java:681)
at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:659)
at Test2.main(Test2.java:32)
@devemux86 I think I figured out what the problem was. From version 0.7.0 to 0.8.x was a medium change on the api and the structure of the project (on how the jars will be created and named)
So with the version 0.8.x one has to use the GraphHopperOSM class to import osm maps or one will receive the exception above. In the 0.7.0 version and below the GraphHopper class was sufficient. However, to use the GraphHopperOSM class one has to import additionally the following maven dependency.
com.graphhopper
graphhopper-reader-osm
0.8.2
This is necessary because from the version 0.8.x the project was split into different jars and no complete jar (as far as I can see) will be built anymore in the map-matching project. (I also pulled the project from github and built the project but the result was the same) So the maven dependency which is given in the example here is invalid at the moment and one has to use this dependency to get the java example working: