public EdgeIteratorState copyEdge(int edge, boolean reuseGeometry) {
        EdgeIteratorStateImpl edgeState = (EdgeIteratorStateImpl) getEdgeIteratorState(edge, Integer.MIN_VALUE);
        EdgeIteratorStateImpl newEdge = (EdgeIteratorStateImpl) edge(edgeState.getBaseNode(), edgeState.getAdjNode())
                .setFlags(edgeState.getFlags())
                .setDistance(edgeState.getDistance())
                .setKeyValues(edgeState.getKeyValues());
        if (reuseGeometry) {
            // We use the same geo ref for the copied edge. This saves memory because we are not duplicating
            // the geometry, and it allows to identify the copies of a given edge.
            long edgePointer = edgeState.edgePointer;
            long geoRef = store.getGeoRef(edgePointer);
            if (geoRef == 0) {
                // No geometry for this edge, but we need to be able to identify the copied edges later, so
                // we use a dedicated negative value for the geo ref.
                geoRef = minGeoRef;
                store.setGeoRef(edgePointer, geoRef);
                minGeoRef--;
            }
            store.setGeoRef(newEdge.edgePointer, geoRef);
        } else {
            newEdge.setWayGeometry(edgeState.fetchWayGeometry(FetchMode.PILLAR_ONLY));
        }
        return newEdge;
    }
@Test
    public void copyEdge() {
        BaseGraph graph = createGHStorage();
        EnumEncodedValue<RoadClass> rcEnc = encodingManager.getEnumEncodedValue(RoadClass.KEY, RoadClass.class);
        EdgeIteratorState edge1 = graph.edge(3, 5).set(rcEnc, RoadClass.LIVING_STREET);
        EdgeIteratorState edge2 = graph.edge(3, 5).set(rcEnc, RoadClass.MOTORWAY);
        EdgeIteratorState edge3 = graph.copyEdge(edge1.getEdge(), true);
        EdgeIteratorState edge4 = graph.copyEdge(edge1.getEdge(), false);
        assertEquals(RoadClass.LIVING_STREET, edge1.get(rcEnc));
        assertEquals(RoadClass.MOTORWAY, edge2.get(rcEnc));
        assertEquals(edge1.get(rcEnc), edge3.get(rcEnc));
        assertEquals(edge1.get(rcEnc), edge4.get(rcEnc));
        graph.forEdgeAndCopiesOfEdge(graph.createEdgeExplorer(), edge1, e -> e.set(rcEnc, RoadClass.FOOTWAY));
        assertEquals(RoadClass.FOOTWAY, edge1.get(rcEnc));
        assertEquals(RoadClass.FOOTWAY, edge3.get(rcEnc));
        // edge4 was not changed because it was copied with reuseGeometry=false
        assertEquals(RoadClass.LIVING_STREET, edge4.get(rcEnc));
    }