How to use my own map server?

Hello there,

I’m working on a project with my school, so I downloaded and installed the open source version of graphhopper.
Our goal is to make an open source hiking circuit generator with the help of graphhopper.

We have a VM dedicated to our project, so I already downloaded the Brittany map from OSM France to use it. But since this is hosted on a VM, I have the problem with the API key.

Is there any way not to use Omniscale or thunderforest ?
Maybe my own map server or an open-source with no pricing requirements ?

(I already found a link that explains how to make my own map server, I just don’t know how to implement it …)

Thanks !

If i’m understanding it right, you want to create your own server to calculate distances or routes?

You can create a java webservice (for example with spring-boot and the spring rest api) and integrate graphhopper into it.

You can use the following tutorial to create a graphhopper instance: Stable 0.9 Java development

Put it in your constructor:

GraphHopper hopper = new GraphHopperOSM().forServer();
hopper.setDataReaderFile(osmFile);
// where to store graphhopper files?
hopper.setGraphHopperLocation(graphFolder);
hopper.setEncodingManager(new EncodingManager("car"));

// now this can take minutes if it imports or a few seconds for loading
// of course this is dependent on the area you import
hopper.importOrLoad();

Put that in your REST endpoint:

GHRequest req = new GHRequest(latFrom, lonFrom, latTo, lonTo).
setWeighting("fastest").
setVehicle("car").
setLocale(Locale.US);
GHResponse rsp = hopper.route(req);

// first check for errors
if(rsp.hasErrors()) {
   // handle them!
   // rsp.getErrors()
   return;
}

// use the best path, see the GHResponse class for more possibilities.
PathWrapper path = rsp.getBest();

// points, distance in meters and time in millis of the full path
PointList pointList = path.getPoints();
double distance = path.getDistance();
long timeInMs = path.getTime();

If you have to create a new flagEncoder (a flagEncoder decides if you can use a route or which routes you can use. To understand it, use the CarflagEncoder.java as an example. Also use the osm wiki to understand the different flags and maybe what flags you need to discribe a way as acceptable(usable) or not. Also look at DataFlagEncoder.java if you want to know how to store data for later use for example.

Hopefully that will answer your questions.
Best,
Martin

@tygore587 :+1: … so, yes customizing a vehicle profile currently needs Java knowledge

You can switch to openstreetmap in the right button, to make this the default you would need to customize the JS files

@tygore587 that is not what I was looking for … But thanks anyway !

@karussell so basically, all I need to do is comment lines with omniscale and thunderforest ?
I’ll try this afternooon

You need to set up the JS part: https://github.com/graphhopper/graphhopper/blob/master/docs/core/quickstart-from-source.md#javascript to recreate the main.js

Oh sorry, so I misunderstood your question.

i’m way too dumb…

I didn’t even notice the layer on the top right corner … thanks !

Hi!

I have a similar issue here. How can set the default overlay to OpenStreetMaps instead of Omniscale? In which js file is the menu defined? Also, I’d like to get rid of other not needed options in the menu.

The link to the doc you provided only explains how to set up js development in general, but nothing about where to start, file structure etc…

Thanks for your help!