Nurlan
Nurlan

Reputation: 2960

Embed graphhopper into project

I would like to embed graphhopper into my java application (J2EE) in order to calculate route distances between many points on the map. Points are given by their longitudes and latitudes. I don't need to render the map.

Can you give step by step details how to do that?

This link describes lines of code to be added. But it doesn't tell how to import graphhopper classes into my project.

I downloaded .pbf for my region and graphhopper project itself and getting stuck how to use it.

Upvotes: 2

Views: 1475

Answers (2)

crowmagnumb
crowmagnumb

Reputation: 7117

Assuming you cloned the graphhopper project you can build the jar

mvn clean install

which will create a jar in core/target with the current snapshot version of graphhopper (or checkout one of the releases to get a specific version). Just add this jar file to your project like you would any other third party jar.

Then to "import" your pbf file into graphhopper speak you would run from the graphhopper project directory...

./graphhopper.sh import <pbf_file>

which will create a directory in the same location and name as your pbf file but with "-gh" tacked onto the end of the filename. This is the directory that you will point your code to for graphhopper to read. I'm guessing this should be explained in the link you provided above.

Upvotes: 2

Karussell
Karussell

Reputation: 17375

But it doesn't tell how to import graphhopper classes into my project.

Take a look into the quickstart. You need to include the graphhopper dependencies via maven or gradle:

<dependency>
  <groupId>com.graphhopper</groupId>
  <artifactId>graphhopper</artifactId>
  <version>0.4.1</version>
</dependency>

If you need the details about the imports for graphhopper just use an IDE to automatically import those (e.g. NetBeans, IntelliJ, Eclipse)

Upvotes: 2

Related Questions