Repository: graphhopper/graphhopper (java)

Issue:
Remove the distance field from CH shortcuts
Removing `dist` from the CH shortcuts saves some memory (10% per shortcut). Right now we do not really use the distances stored in the shortcuts anyway. For example during path calculation we already calculate the distance from the original edge distances.

Pull request description:
Remove distances from CH shortcuts
No longer store distances for CH shortcuts, they were not really used anyway.
This reduces memory consumption per shortcut by four bytes (now `9*4=36 bytes` for node-based and `11*4=44 bytes` for edge-based CH). To retrieve the distance of a shortcut one can use `ShortcutUnpacker` and sum all the distances of the underlying real edges (this is the way we did it for path extraction already).

Fixes #1690.

Patch:
diff --git a/core/files/changelog.txt b/core/files/changelog.txt
index c5caacc86..c14768100 100644
--- a/core/files/changelog.txt
+++ b/core/files/changelog.txt
@@ -20,6 +20,7 @@
     removed GraphHopper.set/getTraversalMode() methods, #1705
     edge-based CH is now chosen by default if it was prepared, #1706
     it is now possible to specify finite u-turn costs for CH preparation, #1671
+    removed distances from CH shortcuts, reduces memory consumption per shortcut by 4 bytes (about 8-10%), #1719
 
 0.12
     renamed VirtualEdgeIteratorState.getOriginalEdgeKey to more precise getOriginalEdgeKey #1549
diff --git a/core/src/main/java/com/graphhopper/routing/ch/EdgeBasedNodeContractor.java b/core/src/main/java/com/graphhopper/routing/ch/EdgeBasedNodeContractor.java
index 4671d4fe5..7c0c85320 100644
--- a/core/src/main/java/com/graphhopper/routing/ch/EdgeBasedNodeContractor.java
+++ b/core/src/main/java/com/graphhopper/routing/ch/EdgeBasedNodeContractor.java
@@ -297,10 +297,8 @@ class EdgeBasedNodeContractor extends AbstractNodeContractor {
         int origFirst = edgeFrom.getParent().incEdge;
         LOGGER.trace("Adding shortcut from {} to {}, weight: {}, firstOrigEdge: {}, lastOrigEdge: {}",
                 from, adjNode, edgeTo.weight, edgeFrom.getParent().incEdge, edgeTo.incEdge);
-        // todo: so far we are not using the distance in edge based CH
-        double distance = 0.0;
         int accessFlags = PrepareEncoder.getScFwdDir();
-        int shortcutId = prepareGraph.shortcutEdgeBased(from, adjNode, accessFlags, edgeTo.weight, distance, edgeFrom.edge, edgeTo.edge, origFirst, edgeTo.incEdge);
+        int shortcutId = prepareGraph.shortcutEdgeBased(from, adjNode, accessFlags, edgeTo.weight, edgeFrom.edge, edgeTo.edge, origFirst, edgeTo.incEdge);
         final int origEdgeCount = getOrigEdgeCount(edgeFrom.edge) + getOrigEdgeCount(edgeTo.edge);
         setOrigEdgeCount(shortcutId, origEdgeCount);
         addedShortcutsCount++;
diff --git a/core/src/main/java/com/graphhopper/routing/ch/NodeBasedNodeContractor.java b/core/src/main/java/com/graphhopper/routing/ch/NodeBasedNodeContractor.java
index cbefc3d8d..d3102822f 100644
--- a/core/src/main/java/com/graphhopper/routing/ch/NodeBasedNodeContractor.java
+++ b/core/src/main/java/com/graphhopper/routing/ch/NodeBasedNodeContractor.java
@@ -176,7 +176,6 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
             if (Double.isInfinite(incomingEdgeWeight)) {
                 continue;
             }
-            final double incomingEdgeDistance = incomingEdges.getDistance();
             int incomingEdge = incomingEdges.getEdge();
             int inOrigEdgeCount = getOrigEdgeCount(incomingEdge);
             // collect outgoing nodes (goal-nodes) only once
@@ -202,7 +201,6 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
                 if (Double.isInfinite(existingDirectWeight))
                     continue;
 
-                final double existingDistSum = incomingEdgeDistance + outgoingEdges.getDistance();
                 prepareAlgo.setWeightLimit(existingDirectWeight);
                 prepareAlgo.setMaxVisitedNodes(maxVisitedNodes);
                 prepareAlgo.setEdgeFilter(ignoreNodeFilter.setAvoidNode(sch.getNode()));
@@ -217,8 +215,7 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
                     // FOUND witness path, so do not add shortcut
                     continue;
 
-                sch.foundShortcut(fromNode, toNode,
-                        existingDirectWeight, existingDistSum,
+                sch.foundShortcut(fromNode, toNode, existingDirectWeight,
                         outgoingEdges.getEdge(), getOrigEdgeCount(outgoingEdges.getEdge()),
                         incomingEdge, inOrigEdgeCount);
             }
@@ -264,7 +261,6 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
                     }
 
                     iter.setFlagsAndWeight(sc.flags, sc.weight);
-                    iter.setDistance(sc.dist);
                     iter.setSkippedEdges(sc.skippedEdge1, sc.skippedEdge2);
                     setOrigEdgeCount(iter.getEdge(), sc.originalEdges);
                     updatedInGraph = true;
@@ -273,7 +269,7 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
             }
 
             if (!updatedInGraph) {
-                int scId = prepareGraph.shortcut(sc.from, sc.to, sc.flags, sc.weight, sc.dist, sc.skippedEdge1, sc.skippedEdge2);
+                int scId = prepareGraph.shortcut(sc.from, sc.to, sc.flags, sc.weight, sc.skippedEdge1, sc.skippedEdge2);
                 setOrigEdgeCount(scId, sc.originalEdges);
 
                 tmpNewShortcuts++;
@@ -321,16 +317,14 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
         int to;
         int skippedEdge1;
         int skippedEdge2;
-        double dist;
         double weight;
         int originalEdges;
         int flags = PrepareEncoder.getScFwdDir();
 
-        public Shortcut(int from, int to, double weight, double dist) {
+        public Shortcut(int from, int to, double weight) {
             this.from = from;
             this.to = to;
             this.weight = weight;
-            this.dist = dist;
         }
 
         @Override
@@ -361,13 +355,12 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
             else
                 str = from + "->";
 
-            return str + to + ", weight:" + weight + " (" + skippedEdge1 + "," + skippedEdge2 + "), dist: " + dist;
+            return str + to + ", weight:" + weight + " (" + skippedEdge1 + "," + skippedEdge2 + ")";
         }
     }
 
     private interface ShortcutHandler {
-        void foundShortcut(int fromNode, int toNode,
-                           double existingDirectWeight, double distance,
+        void foundShortcut(int fromNode, int toNode, double existingDirectWeight,
                            int outgoingEdge, int outOrigEdgeCount,
                            int incomingEdge, int inOrigEdgeCount);
 
@@ -391,8 +384,7 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
         }
 
         @Override
-        public void foundShortcut(int fromNode, int toNode,
-                                  double existingDirectWeight, double distance,
+        public void foundShortcut(int fromNode, int toNode, double existingDirectWeight,
                                   int outgoingEdge, int outOrigEdgeCount,
                                   int incomingEdge, int inOrigEdgeCount) {
             calcShortcutsResult.shortcutsCount++;
@@ -415,8 +407,7 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
         }
 
         @Override
-        public void foundShortcut(int fromNode, int toNode,
-                                  double existingDirectWeight, double existingDistSum,
+        public void foundShortcut(int fromNode, int toNode, double existingDirectWeight,
                                   int outgoingEdge, int outOrigEdgeCount,
                                   int incomingEdge, int inOrigEdgeCount) {
             // FOUND shortcut
@@ -424,11 +415,11 @@ class NodeBasedNodeContractor extends AbstractNodeContractor {
             // and also in the graph for u->w. If existing AND identical weight => update setProperties.
             // Hint: shortcuts are always one-way due to distinct level of every node but we don't
             // know yet the levels so we need to determine the correct direction or if both directions
-            Shortcut sc = new Shortcut(fromNode, toNode, existingDirectWeight, existingDistSum);
+            Shortcut sc = new Shortcut(fromNode, toNode, existingDirectWeight);
             if (shortcuts.containsKey(sc))
                 return;
 
-            Shortcut tmpSc = new Shortcut(toNode, fromNode, existingDirectWeight, existingDistSum);
+            Shortcut tmpSc = new Shortcut(toNode, fromNode, existingDirectWeight);
             Shortcut tmpRetSc = shortcuts.get(tmpSc);
             // overwrite flags only if skipped edges are identical
             if (tmpRetSc != null && tmpRetSc.skippedEdge2 == incomingEdge && tmpRetSc.skippedEdge1 == outgoingEdge) {
diff --git a/core/src/main/java/com/graphhopper/storage/BaseGraph.java b/core/src/main/java/com/graphhopper/storage/BaseGraph.java
index 9a2fc5b89..7de9936ba 100644
--- a/core/src/main/java/com/graphhopper/storage/BaseGraph.java
+++ b/core/src/main/java/com/graphhopper/storage/BaseGraph.java
@@ -46,6 +46,11 @@ import static com.graphhopper.util.Helper.nf;
  * loadExisting, (4) usage, (5) flush, (6) close
  */
 class BaseGraph implements Graph {
+    // currently distances are stored as 4 byte integers. using a conversion factor of 1000 the minimum distance
+    // that is not considered zero is 0.0005m (=0.5mm) and the maximum distance per edge is about 2.147.483m=2147km
+    private static final double INT_DIST_FACTOR = 1000d;
+    static double MAX_DIST = Integer.MAX_VALUE / INT_DIST_FACTOR;
+
     final DataAccess edges;
     final DataAccess nodes;
     final BBox bounds;
@@ -68,7 +73,7 @@ class BaseGraph implements Graph {
     // node memory layout:
     protected int N_EDGE_REF, N_LAT, N_LON, N_ELE, N_ADDITIONAL;
     // edge memory layout not found in EdgeAccess:
-    int E_GEO, E_NAME, E_ADDITIONAL;
+    int E_DIST, E_GEO, E_NAME, E_ADDITIONAL;
     /**
      * Specifies how many entries (integers) are used per edge.
      */
@@ -224,9 +229,9 @@ class BaseGraph implements Graph {
                 nextEdgeEntryIndex(4),
                 nextEdgeEntryIndex(4),
                 nextEdgeEntryIndex(4),
-                nextEdgeEntryIndex(4),
                 nextEdgeEntryIndex(encodingManager.getBytesForFlags()));
 
+        E_DIST = nextEdgeEntryIndex(4);
         E_GEO = nextEdgeEntryIndex(4);
         E_NAME = nextEdgeEntryIndex(4);
         if (extStorage.isRequireEdgeField())
@@ -391,7 +396,7 @@ class BaseGraph implements Graph {
         }
         System.out.println("edges:");
         String formatEdges = "%12s | %12s | %12s | %12s | %12s | %12s | %12s \n";
-        System.out.format(Locale.ROOT, formatEdges, "#", "E_NODEA", "E_NODEB", "E_LINKA", "E_LINKB", "E_DIST", "E_FLAGS");
+        System.out.format(Locale.ROOT, formatEdges, "#", "E_NODEA", "E_NODEB", "E_LINKA", "E_LINKB", "E_FLAGS", "E_DIST");
         IntsRef intsRef = new IntsRef(bytesForFlags / 4);
         for (int i = 0; i < Math.min(edgeCount, printMax); ++i) {
             long edgePointer = edgeAccess.toPointer(i);
@@ -401,8 +406,8 @@ class BaseGraph implements Graph {
                     edgeAccess.getNodeB(edgePointer),
                     edgeAccess.getLinkA(edgePointer),
                     edgeAccess.getLinkB(edgePointer),
-                    edgeAccess.getDist(edgePointer),
-                    intsRef);
+                    intsRef,
+                    getDist(edgePointer));
         }
         if (edgeCount > printMax) {
             System.out.printf(Locale.ROOT, " ... %d more edges", edgeCount - printMax);
@@ -806,6 +811,34 @@ class BaseGraph implements Graph {
         return edgeAccess.isAdjacentToNode(node, edgePointer);
     }
 
+
+    private void setDist(long edgePointer, double distance) {
+        edges.setInt(edgePointer + E_DIST, distToInt(distance));
+    }
+
+    /**
+     * Translates double distance to integer in order to save it in a DataAccess object
+     */
+    private int distToInt(double distance) {
+        if (distance < 0)
+            throw new IllegalArgumentException("Distance cannot be negative: " + distance);
+        if (distance > MAX_DIST) {
+            distance = MAX_DIST;
+        }
+        int integ = (int) Math.round(distance * INT_DIST_FACTOR);
+        assert integ >= 0 : "distance out of range";
+        return integ;
+    }
+
+    /**
+     * returns distance (already translated from integer to double)
+     */
+    private double getDist(long pointer) {
+        int val = edges.getInt(pointer + E_DIST);
+        // do never return infinity even if INT MAX, see #435
+        return val / INT_DIST_FACTOR;
+    }
+
     public void setAdditionalEdgeField(long edgePointer, int value) {
         if (extStorage.isRequireEdgeField() && E_ADDITIONAL >= 0)
             edges.setInt(edgePointer + E_ADDITIONAL, value);
@@ -841,7 +874,7 @@ class BaseGraph implements Graph {
     private void setWayGeometryAtGeoRef(PointList pillarNodes, long edgePointer, boolean reverse, long geoRef) {
         int len = pillarNodes.getSize();
         int dim = nodeAccess.getDimension();
-        long geoRefPosition = (long) geoRef * 4;
+        long geoRefPosition = geoRef * 4;
         int totalLen = len * dim * 4 + 4;
         ensureGeometry(geoRefPosition, totalLen);
         byte[] wayGeometryBytes = createWayGeometryBytes(pillarNodes, reverse);
@@ -1148,13 +1181,13 @@ class BaseGraph implements Graph {
         }
 
         @Override
-        public final double getDistance() {
-            return edgeAccess.getDist(edgePointer);
+        public double getDistance() {
+            return baseGraph.getDist(edgePointer);
         }
 
         @Override
-        public final EdgeIteratorState setDistance(double dist) {
-            edgeAccess.setDist(edgePointer, dist);
+        public EdgeIteratorState setDistance(double dist) {
+            baseGraph.setDist(edgePointer, dist);
             return this;
         }
 
diff --git a/core/src/main/java/com/graphhopper/storage/CHGraph.java b/core/src/main/java/com/graphhopper/storage/CHGraph.java
index 5d492d0cb..832f01761 100644
--- a/core/src/main/java/com/graphhopper/storage/CHGraph.java
+++ b/core/src/main/java/com/graphhopper/storage/CHGraph.java
@@ -56,12 +56,12 @@ public interface CHGraph extends Graph {
      * This method creates a shortcut between a to b which is nearly identical to creating an edge
      * except that it can be excluded or included for certain traversals or algorithms.
      */
-    int shortcut(int a, int b, int accessFlags, double weight, double distance, int skippedEdge1, int skippedEdge2);
+    int shortcut(int a, int b, int accessFlags, double weight, int skippedEdge1, int skippedEdge2);
 
     /**
      * like shortcut(), but for edge-based CH
      */
-    int shortcutEdgeBased(int a, int b, int accessFlags, double weight, double distance, int skippedEdge1, int skippedEdge2, int origFirst, int origLast);
+    int shortcutEdgeBased(int a, int b, int accessFlags, double weight, int skippedEdge1, int skippedEdge2, int origFirst, int origLast);
 
     @Override
     CHEdgeIteratorState getEdgeIteratorState(int edgeId, int endNode);
diff --git a/core/src/main/java/com/graphhopper/storage/CHGraphImpl.java b/core/src/main/java/com/graphhopper/storage/CHGraphImpl.java
index e2bcb57c3..0dbdc5714 100644
--- a/core/src/main/java/com/graphhopper/storage/CHGraphImpl.java
+++ b/core/src/main/java/com/graphhopper/storage/CHGraphImpl.java
@@ -104,7 +104,7 @@ public class CHGraphImpl implements CHGraph, Storable<CHGraph> {
     }
 
     @Override
-    public int shortcut(int a, int b, int accessFlags, double weight, double distance, int skippedEdge1, int skippedEdge2) {
+    public int shortcut(int a, int b, int accessFlags, double weight, int skippedEdge1, int skippedEdge2) {
         if (!baseGraph.isFrozen())
             throw new IllegalStateException("Cannot create shortcut if graph is not yet frozen");
 
@@ -115,17 +115,16 @@ public class CHGraphImpl implements CHGraph, Storable<CHGraph> {
         // do not create CHEdgeIteratorImpl object
         long edgePointer = chEdgeAccess.toPointer(scId);
         chEdgeAccess.setAccessAndWeight(edgePointer, accessFlags & scDirMask, weight);
-        chEdgeAccess.setDist(edgePointer, distance);
         chEdgeAccess.setSkippedEdges(edgePointer, skippedEdge1, skippedEdge2);
         return scId;
     }
 
     @Override
-    public int shortcutEdgeBased(int a, int b, int accessFlags, double weight, double distance, int skippedEdge1, int skippedEdge2, int origFirst, int origLast) {
+    public int shortcutEdgeBased(int a, int b, int accessFlags, double weight, int skippedEdge1, int skippedEdge2, int origFirst, int origLast) {
         if (!chProfile.isEdgeBased()) {
             throw new IllegalStateException("Edge-based shortcuts should only be added when CHGraph is edge-based");
         }
-        int scId = shortcut(a, b, accessFlags, weight, distance, skippedEdge1, skippedEdge2);
+        int scId = shortcut(a, b, accessFlags, weight, skippedEdge1, skippedEdge2);
         chEdgeAccess.setFirstAndLastOrigEdges(chEdgeAccess.toPointer(scId), origFirst, origLast);
         return scId;
     }
@@ -327,7 +326,7 @@ public class CHGraphImpl implements CHGraph, Storable<CHGraph> {
 
     void initStorage() {
         EdgeAccess ea = baseGraph.edgeAccess;
-        chEdgeAccess.init(ea.E_NODEA, ea.E_NODEB, ea.E_LINKA, ea.E_LINKB, ea.E_DIST, ea.E_FLAGS);
+        chEdgeAccess.init(ea.E_NODEA, ea.E_NODEB, ea.E_LINKA, ea.E_LINKB, ea.E_FLAGS);
         // shortcuts
         S_SKIP_EDGE1 = ea.E_FLAGS + 4;
         S_SKIP_EDGE2 = S_SKIP_EDGE1 + 4;
@@ -421,7 +420,6 @@ public class CHGraphImpl implements CHGraph, Storable<CHGraph> {
                     chEdgeAccess.getNodeB(edgePointer),
                     chEdgeAccess.getLinkA(edgePointer),
                     chEdgeAccess.getLinkB(edgePointer),
-                    chEdgeAccess.getDist(edgePointer),
                     chEdgeAccess.getShortcutFlags(edgePointer),
                     shortcuts.getInt(edgePointer + S_SKIP_EDGE1),
                     shortcuts.getInt(edgePointer + S_SKIP_EDGE2));
@@ -465,6 +463,18 @@ public class CHGraphImpl implements CHGraph, Storable<CHGraph> {
             super(baseGraph, edgeAccess, filter);
         }
 
+        @Override
+        public double getDistance() {
+            checkShortcut(false, "getDistance");
+            return super.getDistance();
+        }
+
+        @Override
+        public EdgeIteratorState setDistance(double dist) {
+            checkShortcut(false, "setDistance");
+            return super.setDistance(dist);
+        }
+
         @Override
         public final IntsRef getFlags() {
             checkShortcut(false, "getFlags");
diff --git a/core/src/main/java/com/graphhopper/storage/EdgeAccess.java b/core/src/main/java/com/graphhopper/storage/EdgeAccess.java
index 2a5ed08f0..fae79ca64 100644
--- a/core/src/main/java/com/graphhopper/storage/EdgeAccess.java
+++ b/core/src/main/java/com/graphhopper/storage/EdgeAccess.java
@@ -26,22 +26,18 @@ import com.graphhopper.util.EdgeIteratorState;
  */
 abstract class EdgeAccess {
     private static final int NO_NODE = -1;
-    // distance of around +-1000 000 meter are ok
-    private static final double INT_DIST_FACTOR = 1000d;
-    static double MAX_DIST = Integer.MAX_VALUE / INT_DIST_FACTOR;
     final DataAccess edges;
-    int E_NODEA, E_NODEB, E_LINKA, E_LINKB, E_DIST, E_FLAGS;
+    int E_NODEA, E_NODEB, E_LINKA, E_LINKB, E_FLAGS;
 
     EdgeAccess(DataAccess edges) {
         this.edges = edges;
     }
 
-    final void init(int E_NODEA, int E_NODEB, int E_LINKA, int E_LINKB, int E_DIST, int E_FLAGS) {
+    final void init(int E_NODEA, int E_NODEB, int E_LINKA, int E_LINKB, int E_FLAGS) {
         this.E_NODEA = E_NODEA;
         this.E_NODEB = E_NODEB;
         this.E_LINKA = E_LINKA;
         this.E_LINKB = E_LINKB;
-        this.E_DIST = E_DIST;
         this.E_FLAGS = E_FLAGS;
     }
 
@@ -61,37 +57,10 @@ abstract class EdgeAccess {
         edges.setInt(edgePointer + E_NODEB, NO_NODE);
     }
 
-    static final boolean isInvalidNodeB(int node) {
+    static boolean isInvalidNodeB(int node) {
         return node == EdgeAccess.NO_NODE;
     }
 
-    final void setDist(long edgePointer, double distance) {
-        edges.setInt(edgePointer + E_DIST, distToInt(distance));
-    }
-
-    /**
-     * Translates double distance to integer in order to save it in a DataAccess object
-     */
-    private int distToInt(double distance) {
-        if (distance < 0)
-            throw new IllegalArgumentException("Distance cannot be negative: " + distance);
-        if (distance > MAX_DIST) {
-            distance = MAX_DIST;
-        }
-        int integ = (int) Math.round(distance * INT_DIST_FACTOR);
-        assert integ >= 0 : "distance out of range";
-        return integ;
-    }
-
-    /**
-     * returns distance (already translated from integer to double)
-     */
-    final double getDist(long pointer) {
-        int val = edges.getInt(pointer + E_DIST);
-        // do never return infinity even if INT MAX, see #435
-        return val / INT_DIST_FACTOR;
-    }
-
     final void readFlags(long edgePointer, IntsRef edgeFlags) {
         int size = edgeFlags.ints.length;
         for (int i = 0; i < size; i++) {
diff --git a/core/src/main/java/com/graphhopper/util/Constants.java b/core/src/main/java/com/graphhopper/util/Constants.java
index 471bab792..cfeab365b 100644
--- a/core/src/main/java/com/graphhopper/util/Constants.java
+++ b/core/src/main/java/com/graphhopper/util/Constants.java
@@ -67,8 +67,8 @@ public class Constants {
     private static final int JVM_MINOR_VERSION;
 
     public static final int VERSION_NODE = 5;
-    public static final int VERSION_EDGE = 14;
-    public static final int VERSION_SHORTCUT = 4;
+    public static final int VERSION_EDGE = 15;
+    public static final int VERSION_SHORTCUT = 5;
     public static final int VERSION_GEOMETRY = 4;
     public static final int VERSION_LOCATION_IDX = 3;
     public static final int VERSION_NAME_IDX = 3;


Test patch:
diff --git a/core/src/test/java/com/graphhopper/routing/CHQueryWithTurnCostsTest.java b/core/src/test/java/com/graphhopper/routing/CHQueryWithTurnCostsTest.java
index f04252164..2d0b7255f 100644
--- a/core/src/test/java/com/graphhopper/routing/CHQueryWithTurnCostsTest.java
+++ b/core/src/test/java/com/graphhopper/routing/CHQueryWithTurnCostsTest.java
@@ -718,9 +718,7 @@ public class CHQueryWithTurnCostsTest {
     }
 
     private void addShortcut(int from, int to, int firstOrigEdge, int lastOrigEdge, int skipped1, int skipped2, double weight) {
-        // todo: not using distance atm
-        double distance = 0;
-        chGraph.shortcutEdgeBased(from, to, PrepareEncoder.getScFwdDir(), weight, distance, skipped1, skipped2, firstOrigEdge, lastOrigEdge);
+        chGraph.shortcutEdgeBased(from, to, PrepareEncoder.getScFwdDir(), weight, skipped1, skipped2, firstOrigEdge, lastOrigEdge);
     }
 
     private void setLevelEqualToNodeIdForAllNodes() {
diff --git a/core/src/test/java/com/graphhopper/routing/DijkstraBidirectionCHTest.java b/core/src/test/java/com/graphhopper/routing/DijkstraBidirectionCHTest.java
index 73b486abb..1030499b3 100644
--- a/core/src/test/java/com/graphhopper/routing/DijkstraBidirectionCHTest.java
+++ b/core/src/test/java/com/graphhopper/routing/DijkstraBidirectionCHTest.java
@@ -90,8 +90,8 @@ public class DijkstraBidirectionCHTest extends AbstractRoutingAlgorithmTester {
 
         ghStorage.freeze();
         // simulate preparation
-        int sc2_1 = g2.shortcut(0, 5, PrepareEncoder.getScFwdDir(), 1, 2.8, iter1_1.getEdge(), iter1_2.getEdge());
-        g2.shortcut(0, 7, PrepareEncoder.getScFwdDir(), 1, 4.2, sc2_1, iter2_2.getEdge());
+        int sc2_1 = g2.shortcut(0, 5, PrepareEncoder.getScFwdDir(), 1, iter1_1.getEdge(), iter1_2.getEdge());
+        g2.shortcut(0, 7, PrepareEncoder.getScFwdDir(), 1, sc2_1, iter2_2.getEdge());
         g2.setLevel(1, 0);
         g2.setLevel(3, 1);
         g2.setLevel(4, 2);
diff --git a/core/src/test/java/com/graphhopper/routing/ch/NodeBasedNodeContractorTest.java b/core/src/test/java/com/graphhopper/routing/ch/NodeBasedNodeContractorTest.java
index ee21e05b6..784ba8c75 100644
--- a/core/src/test/java/com/graphhopper/routing/ch/NodeBasedNodeContractorTest.java
+++ b/core/src/test/java/com/graphhopper/routing/ch/NodeBasedNodeContractorTest.java
@@ -28,6 +28,7 @@ import com.graphhopper.routing.weighting.ShortestWeighting;
 import com.graphhopper.routing.weighting.Weighting;
 import com.graphhopper.storage.*;
 import com.graphhopper.storage.index.LocationIndexTree;
+import com.graphhopper.util.CHEdgeIteratorState;
 import com.graphhopper.util.EdgeIterator;
 import com.graphhopper.util.EdgeIteratorState;
 import com.graphhopper.util.PMap;
@@ -179,9 +180,9 @@ public class NodeBasedNodeContractorTest {
         graph.edge(6, 7, 1, true);
         graph.freeze();
 
-        int sc1to4 = lg.shortcut(1, 4, PrepareEncoder.getScDirMask(), 2, 2, iter1to3.getEdge(), iter3to4.getEdge());
-        int sc4to6 = lg.shortcut(4, 6, PrepareEncoder.getScFwdDir(), 2, 2, iter4to5.getEdge(), iter5to6.getEdge());
-        int sc6to4 = lg.shortcut(6, 4, PrepareEncoder.getScFwdDir(), 3, 3, iter6to8.getEdge(), iter8to4.getEdge());
+        int sc1to4 = lg.shortcut(1, 4, PrepareEncoder.getScDirMask(), 2, iter1to3.getEdge(), iter3to4.getEdge());
+        int sc4to6 = lg.shortcut(4, 6, PrepareEncoder.getScFwdDir(), 2, iter4to5.getEdge(), iter5to6.getEdge());
+        int sc6to4 = lg.shortcut(6, 4, PrepareEncoder.getScFwdDir(), 3, iter6to8.getEdge(), iter8to4.getEdge());
 
         setMaxLevelOnAllNodes();
 
@@ -483,7 +484,7 @@ public class NodeBasedNodeContractorTest {
         while (iter.next()) {
             if (iter.isShortcut()) {
                 given.add(new Shortcut(
-                        iter.getBaseNode(), iter.getAdjNode(), iter.getWeight(), iter.getDistance(),
+                        iter.getBaseNode(), iter.getAdjNode(), iter.getWeight(),
                         iter.get(SC_ACCESS), iter.getReverse(SC_ACCESS),
                         iter.getSkippedEdge1(), iter.getSkippedEdge2()));
             }
@@ -502,10 +503,17 @@ public class NodeBasedNodeContractorTest {
     private Shortcut expectedShortcut(int baseNode, int adjNode, EdgeIteratorState edge1, EdgeIteratorState edge2,
                                       boolean fwd, boolean bwd) {
         //todo: weight calculation might have to be adjusted for different encoders/weightings/reverse speed
-        double weight = weighting.calcWeight(edge1, false, EdgeIterator.NO_EDGE) +
-                weighting.calcWeight(edge2, false, EdgeIterator.NO_EDGE);
-        double distance = edge1.getDistance() + edge2.getDistance();
-        return new Shortcut(baseNode, adjNode, weight, distance, fwd, bwd, edge1.getEdge(), edge2.getEdge());
+        double weight1 = getWeight(edge1);
+        double weight2 = getWeight(edge2);
+        return new Shortcut(baseNode, adjNode, weight1 + weight2, fwd, bwd, edge1.getEdge(), edge2.getEdge());
+    }
+
+    private double getWeight(EdgeIteratorState edge) {
+        if (edge instanceof CHEdgeIteratorState) {
+            return ((CHEdgeIteratorState) edge).getWeight();
+        } else {
+            return weighting.calcWeight(edge, false, EdgeIterator.NO_EDGE);
+        }
     }
 
     private Set<Shortcut> setOf(Shortcut... shortcuts) {
@@ -531,17 +539,15 @@ public class NodeBasedNodeContractorTest {
         int baseNode;
         int adjNode;
         double weight;
-        double distance;
         boolean fwd;
         boolean bwd;
         int skipEdge1;
         int skipEdge2;
 
-        Shortcut(int baseNode, int adjNode, double weight, double distance, boolean fwd, boolean bwd, int skipEdge1, int skipEdge2) {
+        Shortcut(int baseNode, int adjNode, double weight, boolean fwd, boolean bwd, int skipEdge1, int skipEdge2) {
             this.baseNode = baseNode;
             this.adjNode = adjNode;
             this.weight = weight;
-            this.distance = distance;
             this.fwd = fwd;
             this.bwd = bwd;
             this.skipEdge1 = skipEdge1;
@@ -556,7 +562,6 @@ public class NodeBasedNodeContractorTest {
             return baseNode == shortcut.baseNode &&
                     adjNode == shortcut.adjNode &&
                     Double.compare(shortcut.weight, weight) == 0 &&
-                    Double.compare(shortcut.distance, distance) == 0 &&
                     fwd == shortcut.fwd &&
                     bwd == shortcut.bwd &&
                     skipEdge1 == shortcut.skipEdge1 &&
@@ -565,7 +570,7 @@ public class NodeBasedNodeContractorTest {
 
         @Override
         public int hashCode() {
-            return Objects.hash(baseNode, adjNode, weight, distance, fwd, bwd, skipEdge1, skipEdge2);
+            return Objects.hash(baseNode, adjNode, weight, fwd, bwd, skipEdge1, skipEdge2);
         }
 
         @Override
@@ -574,7 +579,6 @@ public class NodeBasedNodeContractorTest {
                     "baseNode=" + baseNode +
                     ", adjNode=" + adjNode +
                     ", weight=" + weight +
-                    ", distance=" + distance +
                     ", fwd=" + fwd +
                     ", bwd=" + bwd +
                     ", skipEdge1=" + skipEdge1 +
diff --git a/core/src/test/java/com/graphhopper/routing/ch/Path4CHTest.java b/core/src/test/java/com/graphhopper/routing/ch/Path4CHTest.java
index faa7b5c7d..3482316b1 100644
--- a/core/src/test/java/com/graphhopper/routing/ch/Path4CHTest.java
+++ b/core/src/test/java/com/graphhopper/routing/ch/Path4CHTest.java
@@ -58,10 +58,10 @@ public class Path4CHTest {
         // we 'contract' the graph such that only a few shortcuts are created and that the fwd/bwd searches for the
         // 0-8 query meet at node 4 (make sure we include all three cases where turn cost times might come to play:
         // fwd/bwd search and meeting point)
-        addShortcut(0, 2, 0, 1, 0, 1, 0.12, 2, 0);
-        addShortcut(2, 4, 2, 3, 2, 3, 0.12, 2, 0);
-        addShortcut(4, 6, 4, 5, 4, 5, 0.12, 2, 0);
-        addShortcut(6, 8, 6, 7, 6, 7, 0.12, 2, 0);
+        addShortcut(0, 2, 0, 1, 0, 1, 0.12, 0);
+        addShortcut(2, 4, 2, 3, 2, 3, 0.12, 0);
+        addShortcut(4, 6, 4, 5, 4, 5, 0.12, 0);
+        addShortcut(6, 8, 6, 7, 6, 7, 0.12, 0);
         setCHOrder(1, 3, 5, 7, 0, 8, 2, 6, 4);
 
         // going from 0 to 8 will create shortest path tree entries that follow the shortcuts.
@@ -105,18 +105,18 @@ public class Path4CHTest {
         addTurnCost(edge1, edge0, 1, 0);
 
         // shortcuts ->
-        addShortcut(0, 2, 0, 1, 0, 1, 0.12, 2, 5);
-        addShortcut(2, 4, 2, 3, 2, 3, 0.12, 2, 2);
-        addShortcut(4, 6, 4, 5, 4, 5, 0.12, 2, 4);
-        addShortcut(2, 6, 2, 5, 7, 8, 0.24, 4, 7);
-        addShortcut(0, 6, 0, 5, 6, 9, 0.36, 6, 12);
+        addShortcut(0, 2, 0, 1, 0, 1, 0.12, 5);
+        addShortcut(2, 4, 2, 3, 2, 3, 0.12, 2);
+        addShortcut(4, 6, 4, 5, 4, 5, 0.12, 4);
+        addShortcut(2, 6, 2, 5, 7, 8, 0.24, 7);
+        addShortcut(0, 6, 0, 5, 6, 9, 0.36, 12);
 
         // shortcuts <-
-        addShortcut(6, 4, 5, 4, 5, 4, 0.24, 2, 3);
-        addShortcut(4, 2, 3, 2, 3, 2, 0.24, 2, 4);
-        addShortcut(2, 0, 1, 0, 1, 0, 0.24, 2, 0);
-        addShortcut(6, 2, 5, 2, 11, 12, 0.48, 4, 9);
-        addShortcut(6, 0, 5, 0, 14, 13, 0.60, 6, 10);
+        addShortcut(6, 4, 5, 4, 5, 4, 0.24, 3);
+        addShortcut(4, 2, 3, 2, 3, 2, 0.24, 4);
+        addShortcut(2, 0, 1, 0, 1, 0, 0.24, 0);
+        addShortcut(6, 2, 5, 2, 11, 12, 0.48, 9);
+        addShortcut(6, 0, 5, 0, 14, 13, 0.60, 10);
 
         // strictly it would be cleaner to manually build the SPT and extract the path, but for convenience we
         // use the routing algo to build it
@@ -140,9 +140,9 @@ public class Path4CHTest {
         return GHUtility.getEdge(graph, from, to);
     }
 
-    private void addShortcut(int from, int to, int origFirst, int origLast, int skip1, int skip2, double edgeWeight, double distance, int turnCost) {
+    private void addShortcut(int from, int to, int origFirst, int origLast, int skip1, int skip2, double edgeWeight, int turnCost) {
         double weight = edgeWeight + turnCost * 1000;
-        chGraph.shortcutEdgeBased(from, to, PrepareEncoder.getScFwdDir(), weight, distance, skip1, skip2, origFirst, origLast);
+        chGraph.shortcutEdgeBased(from, to, PrepareEncoder.getScFwdDir(), weight, skip1, skip2, origFirst, origLast);
     }
 
     private void checkPath(int from, int to, double edgeWeight, int distance, int turnCostTime) {
diff --git a/core/src/test/java/com/graphhopper/routing/ch/PrepareContractionHierarchiesTest.java b/core/src/test/java/com/graphhopper/routing/ch/PrepareContractionHierarchiesTest.java
index 232696098..7f12a151e 100644
--- a/core/src/test/java/com/graphhopper/routing/ch/PrepareContractionHierarchiesTest.java
+++ b/core/src/test/java/com/graphhopper/routing/ch/PrepareContractionHierarchiesTest.java
@@ -315,23 +315,23 @@ public class PrepareContractionHierarchiesTest {
         ghStorage.freeze();
         int x = EdgeIterator.NO_EDGE;
         double weight = w.calcWeight(edgeState01, false, x) + w.calcWeight(edgeState12, false, x);
-        int sc0_2 = g.shortcut(0, 2, oneDirFlags, w.calcWeight(edgeState01, false, x) + w.calcWeight(edgeState12, false, x), 2 * dist, tmpEdgeId, edgeState12.getEdge());
+        int sc0_2 = g.shortcut(0, 2, oneDirFlags, w.calcWeight(edgeState01, false, x) + w.calcWeight(edgeState12, false, x), tmpEdgeId, edgeState12.getEdge());
 
         tmpEdgeId = sc0_2;
         weight += w.calcWeight(edgeState23, false, x);
-        int sc0_3 = g.shortcut(0, 3, oneDirFlags, weight, 3 * dist, tmpEdgeId, edgeState23.getEdge());
+        int sc0_3 = g.shortcut(0, 3, oneDirFlags, weight, tmpEdgeId, edgeState23.getEdge());
 
         tmpEdgeId = sc0_3;
         weight += w.calcWeight(edgeState34, false, x);
-        int sc0_4 = g.shortcut(0, 4, oneDirFlags, weight, 4, tmpEdgeId, edgeState34.getEdge());
+        int sc0_4 = g.shortcut(0, 4, oneDirFlags, weight, tmpEdgeId, edgeState34.getEdge());
 
         tmpEdgeId = sc0_4;
         weight += w.calcWeight(edgeState45, false, x);
-        int sc0_5 = g.shortcut(0, 5, oneDirFlags, weight, 5, tmpEdgeId, edgeState45.getEdge());
+        int sc0_5 = g.shortcut(0, 5, oneDirFlags, weight, tmpEdgeId, edgeState45.getEdge());
 
         tmpEdgeId = sc0_5;
         weight += w.calcWeight(edgeState56, false, x);
-        int sc0_6 = g.shortcut(0, 6, oneDirFlags, weight, 6, tmpEdgeId, edgeState56.getEdge());
+        int sc0_6 = g.shortcut(0, 6, oneDirFlags, weight, tmpEdgeId, edgeState56.getEdge());
 
         g.setLevel(0, 10);
         g.setLevel(6, 9);
diff --git a/core/src/test/java/com/graphhopper/routing/util/DefaultEdgeFilterTest.java b/core/src/test/java/com/graphhopper/routing/util/DefaultEdgeFilterTest.java
index 13c575771..2e891baa0 100644
--- a/core/src/test/java/com/graphhopper/routing/util/DefaultEdgeFilterTest.java
+++ b/core/src/test/java/com/graphhopper/routing/util/DefaultEdgeFilterTest.java
@@ -71,7 +71,7 @@ public class DefaultEdgeFilterTest {
 
     private void addShortcut(CHGraph chGraph, int from, int to, boolean fwd, int skip1, int skip2) {
         int accessFlags = fwd ? PrepareEncoder.getScFwdDir() : PrepareEncoder.getScBwdDir();
-        chGraph.shortcut(from, to, accessFlags, 5, 5, skip1, skip2);
+        chGraph.shortcut(from, to, accessFlags, 5, skip1, skip2);
     }
 
 }
\ No newline at end of file
diff --git a/core/src/test/java/com/graphhopper/storage/AbstractGraphStorageTester.java b/core/src/test/java/com/graphhopper/storage/AbstractGraphStorageTester.java
index fff721bd3..247700dac 100644
--- a/core/src/test/java/com/graphhopper/storage/AbstractGraphStorageTester.java
+++ b/core/src/test/java/com/graphhopper/storage/AbstractGraphStorageTester.java
@@ -119,7 +119,7 @@ public abstract class AbstractGraphStorageTester {
     public void testSetTooBigDistance_435() {
         graph = createGHStorage();
 
-        double maxDist = EdgeAccess.MAX_DIST;
+        double maxDist = BaseGraph.MAX_DIST;
         EdgeIteratorState edge1 = graph.edge(0, 1, maxDist, true);
         assertEquals(maxDist, edge1.getDistance(), 1);
 
diff --git a/core/src/test/java/com/graphhopper/storage/GraphHopperStorageCHTest.java b/core/src/test/java/com/graphhopper/storage/GraphHopperStorageCHTest.java
index 34e2f94bf..de6faa0e6 100644
--- a/core/src/test/java/com/graphhopper/storage/GraphHopperStorageCHTest.java
+++ b/core/src/test/java/com/graphhopper/storage/GraphHopperStorageCHTest.java
@@ -107,8 +107,8 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
         g.edge(10, 11, 1, true);
 
         graph.freeze();
-        g.shortcut(3, 4, PrepareEncoder.getScDirMask(), 0, 40, NO_EDGE, NO_EDGE);
-        g.shortcut(0, 4, PrepareEncoder.getScDirMask(), 0, 40, NO_EDGE, NO_EDGE);
+        g.shortcut(3, 4, PrepareEncoder.getScDirMask(), 0, NO_EDGE, NO_EDGE);
+        g.shortcut(0, 4, PrepareEncoder.getScDirMask(), 0, NO_EDGE, NO_EDGE);
         g.setLevel(0, 1);
         g.setLevel(4, 1);
 
@@ -117,7 +117,7 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
         iter = g.createEdgeExplorer().setBaseNode(2);
         assertEquals(2, GHUtility.count(iter));
 
-        int sc = g.shortcut(5, 6, PrepareEncoder.getScDirMask(), 0, 40, 1, 2);
+        int sc = g.shortcut(5, 6, PrepareEncoder.getScDirMask(), 0, 1, 2);
         CHEdgeIteratorState tmpIter = g.getEdgeIteratorState(sc, 6);
         assertEquals(1, tmpIter.getSkippedEdge1());
         assertEquals(2, tmpIter.getSkippedEdge2());
@@ -136,9 +136,9 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
         // only remove edges
         lg.edge(4, 1, 30, true);
         graph.freeze();
-        lg.shortcut(1, 2, PrepareEncoder.getScDirMask(), 0, 10, 10, 11);
-        lg.shortcut(1, 0, PrepareEncoder.getScFwdDir(), 0, 20, 12, 13);
-        lg.shortcut(3, 1, PrepareEncoder.getScFwdDir(), 0, 30, 14, 15);
+        lg.shortcut(1, 2, PrepareEncoder.getScDirMask(), 0, 10, 11);
+        lg.shortcut(1, 0, PrepareEncoder.getScFwdDir(), 0, 12, 13);
+        lg.shortcut(3, 1, PrepareEncoder.getScFwdDir(), 0, 14, 15);
         // create everytime a new independent iterator for disconnect method
         EdgeIterator iter = lg.createEdgeExplorer().setBaseNode(1);
         iter.next();
@@ -177,7 +177,7 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
 
         // only remove edges
         int flags = PrepareEncoder.getScDirMask();
-        int sc = g.shortcut(0, 1, flags, 5, 5, NO_EDGE, NO_EDGE);
+        int sc = g.shortcut(0, 1, flags, 5, NO_EDGE, NO_EDGE);
         CHEdgeIteratorState sc1 = g.getEdgeIteratorState(sc, 1);
         assertTrue(sc1.isShortcut());
         sc1.setWeight(2.001);
@@ -213,33 +213,32 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
         ghStorage.freeze();
 
         CHGraph lg = ghStorage.getCHGraph();
-        int sc1 = lg.shortcut(0, 1, PrepareEncoder.getScFwdDir(), 100.123, 0, NO_EDGE, NO_EDGE);
+        int sc1 = lg.shortcut(0, 1, PrepareEncoder.getScFwdDir(), 100.123, NO_EDGE, NO_EDGE);
 
         assertEquals(100.123, lg.getEdgeIteratorState(sc1, 1).getWeight(), 1e-3);
         assertEquals(100.123, lg.getEdgeIteratorState(sc1, 0).getWeight(), 1e-3);
         assertEquals(100.123, ((CHEdgeIteratorState) GHUtility.getEdge(lg, 0, 1)).getWeight(), 1e-3);
         assertEquals(100.123, ((CHEdgeIteratorState) GHUtility.getEdge(lg, 1, 0)).getWeight(), 1e-3);
 
-        int sc2 = lg.shortcut(1, 0, PrepareEncoder.getScDirMask(), 1.011011, 0, NO_EDGE, NO_EDGE);
+        int sc2 = lg.shortcut(1, 0, PrepareEncoder.getScDirMask(), 1.011011, NO_EDGE, NO_EDGE);
         assertEquals(1.011011, lg.getEdgeIteratorState(sc2, 0).getWeight(), 1e-3);
         assertEquals(1.011011, lg.getEdgeIteratorState(sc2, 1).getWeight(), 1e-3);
     }
 
     @Test
-    public void weightAndDistanceExact() {
+    public void weightExact() {
         graph = createGHStorage();
         CHGraph chGraph = getGraph(graph);
         graph.edge(0, 1, 1, false);
         graph.edge(1, 2, 1, false);
         graph.freeze();
 
-        // we just make up some weights and distances, they do not really have to be related to our previous edges.
+        // we just make up some weights, they do not really have to be related to our previous edges.
         // 1.004+1.006 = 2.09999999999. we make sure this does not become 2.09 instead of 2.10 (due to truncation)
         double x1 = 1.004;
         double x2 = 1.006;
-        chGraph.shortcut(0, 2, PrepareEncoder.getScFwdDir(), x1 + x2, x1 + x2, 0, 1);
+        chGraph.shortcut(0, 2, PrepareEncoder.getScFwdDir(), x1 + x2, 0, 1);
         CHEdgeIteratorState sc = chGraph.getEdgeIteratorState(2, 2);
-        assertEquals(2.01, sc.getDistance(), 1.e-6);
         assertEquals(2.01, sc.getWeight(), 1.e-6);
     }
 
@@ -255,7 +254,7 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
         EdgeIteratorState edge1 = chGraph.edge(0, 1);
         chGraph.edge(1, 2);
         graph.freeze();
-        chGraph.shortcut(0, 1, PrepareEncoder.getScDirMask(), 10, 10, NO_EDGE, NO_EDGE);
+        chGraph.shortcut(0, 1, PrepareEncoder.getScDirMask(), 10, NO_EDGE, NO_EDGE);
 
         QueryGraph qGraph = new QueryGraph(chGraph);
         QueryResult fromRes = createQR(1.004, 1.01, 0, edge1);
@@ -303,7 +302,7 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
         assertEquals(1, GHUtility.count(graph.createEdgeExplorer().setBaseNode(1)));
         assertEquals(1, GHUtility.count(chGraph.createEdgeExplorer().setBaseNode(1)));
 
-        chGraph.shortcut(2, 3, PrepareEncoder.getScDirMask(), 10, 10, NO_EDGE, NO_EDGE);
+        chGraph.shortcut(2, 3, PrepareEncoder.getScDirMask(), 10, NO_EDGE, NO_EDGE);
 
         // should be identical to access without shortcut
         assertEquals(1, GHUtility.count(graph.createEdgeExplorer().setBaseNode(1)));
@@ -349,7 +348,7 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
         graph.freeze();
 
         CHGraph lg = graph.getCHGraph();
-        lg.shortcut(1, 4, PrepareEncoder.getScFwdDir(), 3, 3, NO_EDGE, NO_EDGE);
+        lg.shortcut(1, 4, PrepareEncoder.getScFwdDir(), 3, NO_EDGE, NO_EDGE);
 
         EdgeExplorer vehicleOutExplorer = lg.createEdgeExplorer(DefaultEdgeFilter.outEdges(carEncoder));
         // iteration should result in same nodes even if reusing the iterator
@@ -365,7 +364,7 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
         graph.freeze();
 
         CHGraph lg = graph.getCHGraph();
-        lg.shortcut(1, 4, PrepareEncoder.getScDirMask(), 10, 10, NO_EDGE, NO_EDGE);
+        lg.shortcut(1, 4, PrepareEncoder.getScDirMask(), 10, NO_EDGE, NO_EDGE);
 
         AllCHEdgesIterator iter = lg.getAllEdges();
         iter.next();
@@ -385,7 +384,7 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
         graph.freeze();
 
         CHGraph lg = graph.getCHGraph();
-        lg.shortcut(1, 4, PrepareEncoder.getScDirMask(), 10, 10, edge1.getEdge(), edge2.getEdge());
+        lg.shortcut(1, 4, PrepareEncoder.getScDirMask(), 10, edge1.getEdge(), edge2.getEdge());
 
         AllCHEdgesIterator iter = lg.getAllEdges();
         iter.next();
@@ -456,7 +455,7 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
 
     private void addShortcut(CHGraph chGraph, int from, int to, boolean fwd, int firstOrigEdge, int lastOrigEdge,
                              int skipEdge1, int skipEdge2, int distance) {
-        chGraph.shortcutEdgeBased(from, to, fwd ? PrepareEncoder.getScFwdDir() : PrepareEncoder.getScBwdDir(), 0, distance, skipEdge1, skipEdge2, firstOrigEdge, lastOrigEdge);
+        chGraph.shortcutEdgeBased(from, to, fwd ? PrepareEncoder.getScFwdDir() : PrepareEncoder.getScBwdDir(), 0, skipEdge1, skipEdge2, firstOrigEdge, lastOrigEdge);
     }
 
     @Test
@@ -478,11 +477,11 @@ public class GraphHopperStorageCHTest extends GraphHopperStorageTest {
 
         CHGraph carCHGraph = graph.getCHGraph(chProfiles.get(0));
         // enable forward directions for car
-        int carSC02 = carCHGraph.shortcut(0, 2, PrepareEncoder.getScFwdDir(), 10, 20, NO_EDGE, NO_EDGE);
+        int carSC02 = carCHGraph.shortcut(0, 2, PrepareEncoder.getScFwdDir(), 10, NO_EDGE, NO_EDGE);
 
         CHGraph bikeCHGraph = graph.getCHGraph(chProfiles.get(1));
         // enable both directions for bike
-        int bikeSC02 = bikeCHGraph.shortcut(0, 2, PrepareEncoder.getScDirMask(), 10, 20, NO_EDGE, NO_EDGE);
+        int bikeSC02 = bikeCHGraph.shortcut(0, 2, PrepareEncoder.getScDirMask(), 10, NO_EDGE, NO_EDGE);
 
         // assert car CH graph
         assertTrue(carCHGraph.getEdgeIteratorState(carSC02, 2).get(tmpCarAccessEnc));
diff --git a/core/src/test/java/com/graphhopper/storage/ShortcutUnpackerTest.java b/core/src/test/java/com/graphhopper/storage/ShortcutUnpackerTest.java
index f981f99ad..83e8ffc56 100644
--- a/core/src/test/java/com/graphhopper/storage/ShortcutUnpackerTest.java
+++ b/core/src/test/java/com/graphhopper/storage/ShortcutUnpackerTest.java
@@ -296,11 +296,10 @@ public class ShortcutUnpackerTest {
     private void shortcut(int baseNode, int adjNode, int skip1, int skip2, int origFirst, int origLast) {
         // shortcut weight/distance is not important for us here
         double weight = 1;
-        double distance = 1;
         if (edgeBased) {
-            chGraph.shortcutEdgeBased(baseNode, adjNode, PrepareEncoder.getScFwdDir(), weight, distance, skip1, skip2, origFirst, origLast);
+            chGraph.shortcutEdgeBased(baseNode, adjNode, PrepareEncoder.getScFwdDir(), weight, skip1, skip2, origFirst, origLast);
         } else {
-            chGraph.shortcut(baseNode, adjNode, PrepareEncoder.getScFwdDir(), weight, distance, skip1, skip2);
+            chGraph.shortcut(baseNode, adjNode, PrepareEncoder.getScFwdDir(), weight, skip1, skip2);
         }
     }
 
diff --git a/core/src/test/java/com/graphhopper/storage/index/LocationIndexTreeCHTest.java b/core/src/test/java/com/graphhopper/storage/index/LocationIndexTreeCHTest.java
index e777fe5b8..36b840797 100644
--- a/core/src/test/java/com/graphhopper/storage/index/LocationIndexTreeCHTest.java
+++ b/core/src/test/java/com/graphhopper/storage/index/LocationIndexTreeCHTest.java
@@ -83,16 +83,16 @@ public class LocationIndexTreeCHTest extends LocationIndexTreeTest {
         // create shortcuts
         ghStorage.freeze();
         int flags = PrepareEncoder.getScDirMask();
-        int sc1 = addShortcut(lg, 0, 2, 0, 20, iter1.getEdge(), iter2.getEdge(), flags);
-        int sc2 = addShortcut(lg, 2, 4, 0, 28, iter3.getEdge(), iter4.getEdge(), flags);
-        addShortcut(lg, 0, 4, 0, 40, sc1, sc2, flags);
+        int sc1 = addShortcut(lg, 0, 2, 0, iter1.getEdge(), iter2.getEdge(), flags);
+        int sc2 = addShortcut(lg, 2, 4, 0, iter3.getEdge(), iter4.getEdge(), flags);
+        addShortcut(lg, 0, 4, 0, sc1, sc2, flags);
 
         LocationIndex index = createIndex(ghStorage, -1);
         assertEquals(2, findID(index, 0, 0.5));
     }
 
-    private int addShortcut(CHGraph lg, int from, int to, double weight, double distance, int skip1, int skip2, int direction) {
-        return lg.shortcut(from, to, direction, weight, distance, skip1, skip2);
+    private int addShortcut(CHGraph lg, int from, int to, double weight, int skip1, int skip2, int direction) {
+        return lg.shortcut(from, to, direction, weight, skip1, skip2);
     }
 
     @Test