Skip to content

Instantly share code, notes, and snippets.

@karussell
karussell / OffheapUrlDataAccess.java
Created Sep 18, 2021 — forked from jtheuer/OffheapUrlDataAccess.java
Graphhopper offheap storage with URL loader.
View OffheapUrlDataAccess.java
import com.google.common.base.Preconditions;
import com.graphhopper.storage.DAType;
import com.graphhopper.storage.DataAccess;
import com.graphhopper.util.NotThreadSafe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import xerial.larray.LByteArray;
import xerial.larray.japi.LArrayJ;
import java.io.ByteArrayInputStream;
View Dockerfile
#FROM openjdk:11.0-jre
FROM openjdk:16-alpine3.13
COPY web/target/graphhopper*.jar ./graphhopper.jar
ENTRYPOINT [ "java -Xmx1g -Xms1g -jar graphhopper.jar", "10" ]
View custom_profiles.md

Custom Models

Currently available for the POST /route endpoint only and up on request. If you are interested - send us a support request.

Examples can be found here. You'll also find a link to a demo server including an editor with the JSON format that will check the syntax of your custom model and mark errors in red. You can press Ctrl+Space or Alt+Enter to retrieve auto-complete suggestions. Pressing Ctrl+Enter will send a routing request for the custom model you entered.

GraphHopper provides an easy-to-use way to customize its route calculations: custom models allow you to modify the default routing behavior by specifying a set of rules in JSON language. A simple example using the profile name of your choice or communicated from our support:

View area-condition.json
{
"priority": [{
"if": "road_class == MOTORWAY && in_near_cottbus == false",
"multiply_by": 0
}],
"areas": {
"near_cottbus": {
"type": "Feature",
"properties": {},
"geometry": {
@karussell
karussell / Lettuce.java
Last active Feb 24, 2021 — forked from eransharv/RedissonSSL.java
java lettuce redis client example using SSL
View Lettuce.java
client.setOptions(ClientOptions.builder().sslOptions(SslOptions.builder()
.keystore(new File("user.p12"), "test12".toCharArray())
.truststore(new File("keystore.jks"), "keystorepassword12")
.build()).build());
View schema.json
"schemas": {
"RouteRequest": {
"type": "object",
"properties": {
"custom_model": {
"description": "custom model bla",
"type": "object",
"properties": {
"speed": {
"type": "array",
View RandomTest.java
class RandomTest {
@Test
public void randomGraph() {
long seed = 0;//System.nanoTime();
Random rand = new Random(seed);
FlagEncoder encoder = new CarFlagEncoder();
GraphHopperStorage graph = new GraphHopperStorage(new RAMDirectory(), EncodingManager.create(encoder), false).create(100);
GHUtility.buildRandomGraph(graph, rand, 1000, 3, true, true,
@karussell
karussell / MyTest.java
Last active Jan 27, 2021
IntelliJ Debugging for Janino
View MyTest.java
class MyTest {
@Test
public void testX() throws CompileException {
IScriptEvaluator se = new ScriptEvaluator();
MyInterface i = (MyInterface) se.createFastEvaluator(""
+ "System.out.println(\"Hello\");\n"
+ "String s = \"World\";\n"
+ "System.out.println(s);\n"
+ "return true;",
MyInterface.class, new String[0]);