From f2426435c0e5d7990cb38356ec1f5e40d627f760 Mon Sep 17 00:00:00 2001 From: Karl Schrab Date: Fri, 3 Nov 2023 09:18:19 +0100 Subject: [PATCH] refactor(routing): get rid of ExtendedGraphHopper, load grap in GraphHopperRouting instead Signed-off-by: Karl Schrab --- .../lib/routing/database/DatabaseRouting.java | 3 +- .../graphhopper/ExtendedGraphHopper.java | 161 ------------------ .../graphhopper/GraphHopperRouting.java | 123 +++++++++---- .../routing/graphhopper/VehicleEncoding.java | 7 + .../graphhopper/VehicleEncodingManager.java | 3 +- .../routing/CharlottenburgRoutingTest.java | 3 +- .../graphhopper/GraphHopperRoutingTest.java | 3 +- 7 files changed, 100 insertions(+), 203 deletions(-) delete mode 100644 lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/ExtendedGraphHopper.java diff --git a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/database/DatabaseRouting.java b/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/database/DatabaseRouting.java index dae54201e..95e66de2b 100644 --- a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/database/DatabaseRouting.java +++ b/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/database/DatabaseRouting.java @@ -86,8 +86,7 @@ public void initialize(final CRouting configuration, final File baseDirectory) t } //creates an implementation of IRoutingGraph according to the configuration - this.routing = new GraphHopperRouting() - .loadGraphFromDatabase(scenarioDatabase); + this.routing = new GraphHopperRouting(scenarioDatabase); this.routeManager = new RouteManager(this.scenarioDatabase); } diff --git a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/ExtendedGraphHopper.java b/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/ExtendedGraphHopper.java deleted file mode 100644 index cfe071e61..000000000 --- a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/ExtendedGraphHopper.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2020 Fraunhofer FOKUS and others. All rights reserved. - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contact: mosaic@fokus.fraunhofer.de - */ - -package org.eclipse.mosaic.lib.routing.graphhopper; - -import org.eclipse.mosaic.lib.routing.RoutingCostFunction; -import org.eclipse.mosaic.lib.routing.graphhopper.util.GraphhopperToDatabaseMapper; -import org.eclipse.mosaic.lib.routing.graphhopper.util.TurnCostsProvider; - -import com.graphhopper.GHRequest; -import com.graphhopper.GHResponse; -import com.graphhopper.GraphHopper; -import com.graphhopper.config.Profile; -import com.graphhopper.routing.WeightingFactory; -import com.graphhopper.routing.ev.Subnetwork; -import com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks; -import com.graphhopper.routing.util.EncodingManager; -import com.graphhopper.routing.weighting.Weighting; -import com.graphhopper.storage.BaseGraph; -import com.graphhopper.storage.RAMDirectory; -import com.graphhopper.util.Helper; -import com.graphhopper.util.PMap; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.List; - -/** - * An extension of GraphHopper which is able to import map data from the MOSAIC scenario database. - * Routing functionality is implemented {@link org.eclipse.mosaic.lib.routing.graphhopper.GraphHopperRouting}. - */ -class ExtendedGraphHopper extends GraphHopper { - - static final String WEIGHTING_TURN_COSTS = "weighting.turnCosts"; - static final String WEIGHTING_COST_FUNCTION = "weighting.costFunction"; - static final String WEIGHTING_GRAPH_MAPPER = "weighting.graphMapper"; - - private final Logger logger = LoggerFactory.getLogger(getClass()); - - protected GraphLoader graphLoader; - protected GraphhopperToDatabaseMapper mapper; - protected VehicleEncodingManager encodingManager; - - private boolean fullyLoaded = false; - - ExtendedGraphHopper(VehicleEncodingManager encoding, GraphLoader graphLoader, GraphhopperToDatabaseMapper mapper) { - this.graphLoader = graphLoader; - this.mapper = mapper; - this.encodingManager = encoding; - - setProfiles(encoding.getAllProfiles()); - } - - @Override - public EncodingManager getEncodingManager() { - return encodingManager.getEncodingManager(); - } - - @Override - public GraphHopper importOrLoad() { - fullyLoaded = false; - - setBaseGraph(new BaseGraph - .Builder(getEncodingManager()) - .setDir(new RAMDirectory()) - .set3D(false) - .withTurnCosts(getEncodingManager().needsTurnCostsSupport()) - .setSegmentSize(-1) - .build() - ); - - importDB(getGraphHopperLocation()); - fullyLoaded = true; - return this; - } - - @Override - protected WeightingFactory createWeightingFactory() { - return (profile, hints, b) -> { - final VehicleEncoding vehicleEncoding = encodingManager.getVehicleEncoding(profile.getVehicle()); - - final TurnCostsProvider turnCostProvider = new TurnCostsProvider(vehicleEncoding, getBaseGraph().getTurnCostStorage()); - if (!hints.getBool(WEIGHTING_TURN_COSTS, false)) { - turnCostProvider.disableTurnCosts(); - } - final GraphhopperToDatabaseMapper graphMapper = hints.getObject(WEIGHTING_GRAPH_MAPPER, null); - final RoutingCostFunction costFunction = hints.getObject(WEIGHTING_COST_FUNCTION, RoutingCostFunction.Default); - return new GraphHopperWeighting(vehicleEncoding, encodingManager.wayType(), turnCostProvider, graphMapper) - .setRoutingCostFunction(costFunction); - }; - } - - private void importDB(String ignore) { - if (getBaseGraph() == null) { - throw new IllegalStateException("Load or init graph before import database"); - } - - if (mapper == null) { - throw new IllegalStateException("A mapper is required for importing database"); - } - - logger.info("start creating graph from database"); - - graphLoader.initialize(getBaseGraph(), encodingManager, mapper); - graphLoader.loadGraph(); - - postProcessing(false); - try { - cleanUp(); - } catch (Exception e) { - logger.warn("Could not clean up routing graph, skipping. Routing might not work as expected!", e); - } - getBaseGraph().flush(); - } - - @Override - public boolean getFullyLoaded() { - return fullyLoaded; - } - - @Override - public GHResponse route(GHRequest request) { - throw new UnsupportedOperationException("Routing Logic is implemented in GraphHopperRouting."); - } - - /* the following code has been copied and adjusted from original GraphHopper repository. - * This was necessary, since `encodingManager` in `GraphHopper` is private, cannot be set from outside, and is used directly - * in `buildSubnetworkRemovalJobs`. */ - @Override - protected void cleanUp() { - PrepareRoutingSubnetworks preparation = new PrepareRoutingSubnetworks(getBaseGraph(), buildSubnetworkRemovalJobs()); - preparation.setMinNetworkSize(200); - preparation.setThreads(1); - preparation.doWork(); - logger.info("nodes: " + Helper.nf(getBaseGraph().getNodes()) + ", edges: " + Helper.nf(getBaseGraph().getEdges())); - } - - private List buildSubnetworkRemovalJobs() { - List jobs = new ArrayList<>(); - for (Profile profile : getProfiles()) { - Weighting weighting = createWeighting(profile, new PMap()); - // here we use `getEncodingManager()` instead of `encodingManager`, making this code work - jobs.add(new PrepareRoutingSubnetworks.PrepareJob(getEncodingManager().getBooleanEncodedValue(Subnetwork.key(profile.getName())), weighting)); - } - return jobs; - } - -} diff --git a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/GraphHopperRouting.java b/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/GraphHopperRouting.java index 24740981e..87788f781 100644 --- a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/GraphHopperRouting.java +++ b/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/GraphHopperRouting.java @@ -22,26 +22,32 @@ import org.eclipse.mosaic.lib.enums.VehicleClass; import org.eclipse.mosaic.lib.geo.GeoPoint; import org.eclipse.mosaic.lib.routing.CandidateRoute; +import org.eclipse.mosaic.lib.routing.RoutingCostFunction; import org.eclipse.mosaic.lib.routing.RoutingPosition; import org.eclipse.mosaic.lib.routing.RoutingRequest; import org.eclipse.mosaic.lib.routing.graphhopper.algorithm.RoutingAlgorithmFactory; import org.eclipse.mosaic.lib.routing.graphhopper.util.DatabaseGraphLoader; import org.eclipse.mosaic.lib.routing.graphhopper.util.GraphhopperToDatabaseMapper; +import org.eclipse.mosaic.lib.routing.graphhopper.util.TurnCostsProvider; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.graphhopper.GraphHopper; import com.graphhopper.config.Profile; import com.graphhopper.routing.Path; import com.graphhopper.routing.RoutingAlgorithm; import com.graphhopper.routing.ev.BooleanEncodedValue; import com.graphhopper.routing.querygraph.QueryGraph; import com.graphhopper.routing.querygraph.VirtualEdgeIteratorState; +import com.graphhopper.routing.subnetwork.PrepareRoutingSubnetworks; import com.graphhopper.routing.util.AccessFilter; import com.graphhopper.routing.util.EdgeFilter; import com.graphhopper.routing.weighting.Weighting; +import com.graphhopper.storage.BaseGraph; import com.graphhopper.storage.Graph; import com.graphhopper.storage.NodeAccess; +import com.graphhopper.storage.RAMDirectory; +import com.graphhopper.storage.index.LocationIndex; +import com.graphhopper.storage.index.LocationIndexTree; import com.graphhopper.storage.index.Snap; import com.graphhopper.util.DistanceCalc; import com.graphhopper.util.DistancePlaneProjection; @@ -50,6 +56,7 @@ import com.graphhopper.util.Parameters; import com.graphhopper.util.PointList; import com.graphhopper.util.shapes.GHPoint; +import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,6 +70,9 @@ public class GraphHopperRouting { + + private static final Logger LOG = LoggerFactory.getLogger(GraphHopperRouting.class); + public static final Profile PROFILE_CAR = new Profile("car").setVehicle("car").setTurnCosts(true); public static final Profile PROFILE_BIKE = new Profile("bike").setVehicle("bike").setTurnCosts(false); @@ -119,30 +129,68 @@ public class GraphHopperRouting { */ private static final double MAX_DISTANCE_TO_TARGET = 500d; - private final Logger log = LoggerFactory.getLogger(getClass()); - - private GraphHopper ghApi; private final DistanceCalc distanceCalculation = new DistancePlaneProjection(); - private GraphhopperToDatabaseMapper graphMapper; - private Database db; - private VehicleEncodingManager encoding; + private final GraphhopperToDatabaseMapper graphMapper; + private final Database db; + private final VehicleEncodingManager encoding; + private final BaseGraph graph; + private final LocationIndex locationIndex; - public GraphHopperRouting loadGraphFromDatabase(Database db) { + public GraphHopperRouting(Database db) { this.db = db; - //initialize reader and mapper for database import into graphhopper - GraphLoader reader = new DatabaseGraphLoader(db); graphMapper = new GraphhopperToDatabaseMapper(); encoding = new VehicleEncodingManager(PROFILES); - ghApi = new ExtendedGraphHopper(encoding, reader, graphMapper); - ghApi.importOrLoad(); - return this; + graph = createGraphFromDatabase(db); + locationIndex = createLocationIndex(); + cleanUpGraph(); + + graph.flush(); + } + + private BaseGraph createGraphFromDatabase(Database db) { + final BaseGraph graph = new BaseGraph + .Builder(encoding.getEncodingManager()) + .setDir(new RAMDirectory()) + .set3D(false) + .withTurnCosts(encoding.getEncodingManager().needsTurnCostsSupport()) + .setSegmentSize(-1) + .build(); + + final GraphLoader reader = new DatabaseGraphLoader(db); + reader.initialize(graph, encoding, graphMapper); + reader.loadGraph(); + LOG.info("nodes: {}, edges: {}", graph.getNodes(), graph.getEdges()); + return graph; + } + + private LocationIndex createLocationIndex() { + return new LocationIndexTree(graph, graph.getDirectory()) + .setMinResolutionInMeter(300) + .setMaxRegionSearch(4) + .prepareIndex(); + } + + protected void cleanUpGraph() { + new PrepareRoutingSubnetworks(graph, buildSubnetworkRemovalJobs()) + .setMinNetworkSize(200) + .setThreads(1) + .doWork(); + } + + private List buildSubnetworkRemovalJobs() { + List jobs = new ArrayList<>(); + for (Profile profile : encoding.getAllProfiles()) { + Weighting weighting = createWeighting(profile, RoutingCostFunction.Fastest, false); + jobs.add(new PrepareRoutingSubnetworks.PrepareJob(encoding.getVehicleEncoding(profile.getVehicle()).subnetwork(), weighting)); + } + return jobs; } public List findRoutes(RoutingRequest routingRequest) { - if (ghApi == null) { + if (graph == null) { throw new IllegalStateException("Load database at first"); } @@ -154,13 +202,6 @@ public List findRoutes(RoutingRequest routingRequest) { } final VehicleEncoding vehicleEncoding = encoding.getVehicleEncoding(profile.getVehicle()); - final PMap weightingHints = new PMap() - .putObject(ExtendedGraphHopper.WEIGHTING_TURN_COSTS, routingRequest.getRoutingParameters().isConsiderTurnCosts()) - .putObject(ExtendedGraphHopper.WEIGHTING_COST_FUNCTION, routingRequest.getRoutingParameters().getRoutingCostFunction()) - .putObject(ExtendedGraphHopper.WEIGHTING_GRAPH_MAPPER, graphMapper); - - final Weighting weighting = ghApi.createWeighting(profile, weightingHints); - final RoutingPosition source = routingRequest.getSource(); final RoutingPosition target = routingRequest.getTarget(); @@ -168,11 +209,11 @@ public List findRoutes(RoutingRequest routingRequest) { final Snap snapTarget = createQueryForTarget(target, vehicleEncoding.access()); if (snapSource.getClosestEdge() == null || snapTarget.getClosestEdge() == null) { - log.warn("Could not find a route from {} to {}", routingRequest.getSource(), routingRequest.getTarget()); + LOG.warn("Could not find a route from {} to {}", routingRequest.getSource(), routingRequest.getTarget()); return Lists.newArrayList(); } - final QueryGraph queryGraph = QueryGraph.create(ghApi.getBaseGraph(), snapSource, snapTarget); + final QueryGraph queryGraph = QueryGraph.create(graph, snapSource, snapTarget); final int numberOfAlternatives = routingRequest.getRoutingParameters().getNumAlternativeRoutes(); final PMap algoHints = new PMap(); @@ -181,6 +222,11 @@ public List findRoutes(RoutingRequest routingRequest) { algoHints.putObject(Parameters.Algorithms.AltRoute.MAX_PATHS, Math.max(numberOfAlternatives, NUM_ALTERNATIVE_PATHS) + 1); } + final Weighting weighting = createWeighting(profile, + routingRequest.getRoutingParameters().getRoutingCostFunction(), + routingRequest.getRoutingParameters().isConsiderTurnCosts() + ); + final RoutingAlgorithm algo = RoutingAlgorithmFactory.DEFAULT.createAlgorithm( queryGraph, queryGraph.wrapWeighting(weighting), algoHints ); @@ -201,16 +247,26 @@ public List findRoutes(RoutingRequest routingRequest) { && checkForDuplicate(route, duplicateSet) && checkRouteOnRequiredSourceConnection(route, source)) { result.add(route); - } else if (route != null && log.isDebugEnabled()) { - log.debug("Path is invalid and will be ignored [" + StringUtils.join(route.getConnectionIds(), ",") + "]"); + } else if (route != null && LOG.isDebugEnabled()) { + LOG.debug("Path is invalid and will be ignored [" + StringUtils.join(route.getConnectionIds(), ",") + "]"); } } return result; } + private Weighting createWeighting(Profile profile, RoutingCostFunction costFunction, boolean withTurnCosts) { + final VehicleEncoding vehicleEncoding = encoding.getVehicleEncoding(profile.getVehicle()); + final TurnCostsProvider turnCostProvider = new TurnCostsProvider(vehicleEncoding, graph.getTurnCostStorage()); + if (!withTurnCosts) { + turnCostProvider.disableTurnCosts(); + } + return new GraphHopperWeighting(vehicleEncoding, encoding.wayType(), turnCostProvider, graphMapper) + .setRoutingCostFunction(ObjectUtils.defaultIfNull(costFunction, RoutingCostFunction.Default)); + } + private Snap createQueryForTarget(RoutingPosition target, BooleanEncodedValue accessEnc) { final EdgeFilter toEdgeFilter = createEdgeFilterForRoutingPosition(target, accessEnc); - Snap queryTarget = ghApi.getLocationIndex().findClosest(target.getPosition().getLatitude(), target.getPosition().getLongitude(), toEdgeFilter); + Snap queryTarget = locationIndex.findClosest(target.getPosition().getLatitude(), target.getPosition().getLongitude(), toEdgeFilter); if (target.getConnectionId() != null) { return fixQueryResultIfNoClosestEdgeFound(queryTarget, target, accessEnc); } else { @@ -220,7 +276,7 @@ private Snap createQueryForTarget(RoutingPosition target, BooleanEncodedValue ac private Snap createQueryForSource(RoutingPosition source, BooleanEncodedValue accessEnc) { final EdgeFilter fromEdgeFilter = createEdgeFilterForRoutingPosition(source, accessEnc); - Snap querySource = ghApi.getLocationIndex().findClosest(source.getPosition().getLatitude(), source.getPosition().getLongitude(), fromEdgeFilter); + Snap querySource = locationIndex.findClosest(source.getPosition().getLatitude(), source.getPosition().getLongitude(), fromEdgeFilter); if (source.getConnectionId() != null) { querySource = fixQueryResultIfSnappedPointIsTowerNode(querySource, source, fromEdgeFilter); return fixQueryResultIfNoClosestEdgeFound(querySource, source, accessEnc); @@ -244,9 +300,9 @@ private Snap fixQueryResultIfSnappedPointIsCloseToTowerNode(Snap queryResult, Ro private Snap fixQueryResultIfNoClosestEdgeFound(Snap queryResult, RoutingPosition routingPosition, BooleanEncodedValue accessEnc) { if (queryResult.getClosestEdge() == null) { - log.warn("Wrong routing request: The from-connection {} does not fit with the given position {}", routingPosition.getConnectionId(), routingPosition.getPosition()); + LOG.warn("Wrong routing request: The from-connection {} does not fit with the given position {}", routingPosition.getConnectionId(), routingPosition.getPosition()); - return ghApi.getLocationIndex().findClosest( + return locationIndex.findClosest( routingPosition.getPosition().getLatitude(), routingPosition.getPosition().getLongitude(), AccessFilter.allEdges(accessEnc) ); } @@ -261,7 +317,7 @@ private Snap fixQueryResultIfSnappedPointIsTowerNode(Snap queryResult, RoutingPo // use the node before target node (index -2) as the alternative query node to find a QueryResult _on_ the connection. Node alternativeQueryNode = DatabaseUtils.getNodeByIndex(db.getConnection(routingPosition.getConnectionId()), -2); if (alternativeQueryNode != null) { - return ghApi.getLocationIndex().findClosest( + return locationIndex.findClosest( alternativeQueryNode.getPosition().getLatitude(), alternativeQueryNode.getPosition().getLongitude(), fromEdgeFilter ); } @@ -320,7 +376,7 @@ private CandidateRoute convertPath(Graph graph, Path newPath, RoutingPosition ta EdgeIteratorState currEdge = origEdge; if (currEdge instanceof VirtualEdgeIteratorState) { - currEdge = ghApi.getBaseGraph().getEdgeIteratorStateForKey(((VirtualEdgeIteratorState) origEdge).getOriginalEdgeKey()); + currEdge = graph.getEdgeIteratorStateForKey(((VirtualEdgeIteratorState) origEdge).getOriginalEdgeKey()); } Connection con = graphMapper.toConnection(currEdge.getEdge()); @@ -346,13 +402,13 @@ private CandidateRoute convertPath(Graph graph, Path newPath, RoutingPosition ta lastConnection = con; if (Double.isInfinite(newPath.getWeight())) { - log.warn( + LOG.warn( "Something went wrong during path search: The found route has infinite weight. Maybe there's a turn restriction or unconnected " + "sub-graphs in the network. Route will be ignored."); return null; } } else { - log.debug(String.format("A connection could be resolved by internal ID %d.", origEdge.getEdge())); + LOG.debug(String.format("A connection could be resolved by internal ID %d.", origEdge.getEdge())); } } @@ -394,5 +450,4 @@ private boolean checkRouteOnRequiredSourceConnection(CandidateRoute route, Routi } return true; } - } diff --git a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/VehicleEncoding.java b/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/VehicleEncoding.java index 866ed32cf..790adecb2 100644 --- a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/VehicleEncoding.java +++ b/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/VehicleEncoding.java @@ -18,6 +18,7 @@ import com.graphhopper.config.Profile; import com.graphhopper.routing.ev.BooleanEncodedValue; import com.graphhopper.routing.ev.DecimalEncodedValue; +import com.graphhopper.routing.ev.Subnetwork; import com.graphhopper.routing.ev.TurnCost; import com.graphhopper.routing.ev.TurnRestriction; import com.graphhopper.routing.util.DefaultVehicleEncodedValuesFactory; @@ -31,6 +32,7 @@ public class VehicleEncoding { private final BooleanEncodedValue turnRestrictionEnc; private final DecimalEncodedValue turnCostEnc; private final DecimalEncodedValue priorityEnc; + private final BooleanEncodedValue subnetworkEnc; VehicleEncoding(Profile profile) { VehicleEncodedValues vehicle = new DefaultVehicleEncodedValuesFactory() @@ -40,6 +42,7 @@ public class VehicleEncoding { this.priorityEnc = vehicle.getPriorityEnc(); this.turnRestrictionEnc = TurnRestriction.create(profile.getVehicle()); this.turnCostEnc = TurnCost.create(profile.getVehicle(), 255); + this.subnetworkEnc = Subnetwork.create(profile.getVehicle()); } public BooleanEncodedValue access() { @@ -61,4 +64,8 @@ public BooleanEncodedValue turnRestriction() { public DecimalEncodedValue turnCost() { return turnCostEnc; } + + public BooleanEncodedValue subnetwork() { + return subnetworkEnc; + } } diff --git a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/VehicleEncodingManager.java b/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/VehicleEncodingManager.java index aa95bf69d..0a5acc0cb 100644 --- a/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/VehicleEncodingManager.java +++ b/lib/mosaic-routing/src/main/java/org/eclipse/mosaic/lib/routing/graphhopper/VehicleEncodingManager.java @@ -18,7 +18,6 @@ import org.eclipse.mosaic.lib.routing.graphhopper.util.WayTypeEncoder; import com.graphhopper.config.Profile; -import com.graphhopper.routing.ev.Subnetwork; import com.graphhopper.routing.util.EncodingManager; import java.util.ArrayList; @@ -54,7 +53,7 @@ public VehicleEncodingManager(List profiles) { .add(encoding.speed()) .addTurnCostEncodedValue(encoding.turnRestriction()) .addTurnCostEncodedValue(encoding.turnCost()) - .add(Subnetwork.create(profile.getName())); + .add(encoding.subnetwork()); if (encoding.priority() != null) { builder.add(encoding.priority()); } diff --git a/lib/mosaic-routing/src/test/java/org/eclipse/mosaic/lib/routing/CharlottenburgRoutingTest.java b/lib/mosaic-routing/src/test/java/org/eclipse/mosaic/lib/routing/CharlottenburgRoutingTest.java index d78d63273..af8819c6e 100644 --- a/lib/mosaic-routing/src/test/java/org/eclipse/mosaic/lib/routing/CharlottenburgRoutingTest.java +++ b/lib/mosaic-routing/src/test/java/org/eclipse/mosaic/lib/routing/CharlottenburgRoutingTest.java @@ -57,8 +57,7 @@ public void setUp() throws IOException { database = Database.loadFromFile(dbFileCopy); - routing = new GraphHopperRouting(); - routing.loadGraphFromDatabase(database); + routing = new GraphHopperRouting(database); } @Test diff --git a/lib/mosaic-routing/src/test/java/org/eclipse/mosaic/lib/routing/graphhopper/GraphHopperRoutingTest.java b/lib/mosaic-routing/src/test/java/org/eclipse/mosaic/lib/routing/graphhopper/GraphHopperRoutingTest.java index 5b4ecb067..b661ca137 100644 --- a/lib/mosaic-routing/src/test/java/org/eclipse/mosaic/lib/routing/graphhopper/GraphHopperRoutingTest.java +++ b/lib/mosaic-routing/src/test/java/org/eclipse/mosaic/lib/routing/graphhopper/GraphHopperRoutingTest.java @@ -60,8 +60,7 @@ public void setUp() throws IOException { database = Database.loadFromFile(dbFileCopy); - routing = new GraphHopperRouting(); - routing.loadGraphFromDatabase(database); + routing = new GraphHopperRouting(database); } @Test