Skip to content

Commit

Permalink
clean(mosaic-routing): minor cleanup after self-review
Browse files Browse the repository at this point in the history
  • Loading branch information
kschrab committed Jan 31, 2024
1 parent c3819c0 commit 5a685f4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,33 @@
*/
public class CandidateRoute {

/**
* The list of connections forming this route.
*/
private final List<String> connectionIds;

/**
* The length of this route.
*/
private final double length;

/**
* The approximated driving time on this route.
*/
private final double time;

/**
* The distance in meters from the start node of the first connection in the connectionIds list, to
* the point the source query was issued.
*/
private final double offsetFromSource;

/**
* The distance in meters from the point the target query was issued, until the end node of the
* final connection in the connectionIds list.
*/
private final double offsetToTarget;

private final double offsetFromSource;

public CandidateRoute(List<String> connectionIds, double length, double time) {
this(connectionIds, length, time, 0, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public double getLength() {
public Iterable<GeoPoint> getGeometry() {
Validate.notNull(currentEdgeIterator, "Edge iterator is null");
return Iterables.transform(
currentEdgeIterator.fetchWayGeometry(FetchMode.ALL), // 3 = fetch all pillar nodes inclusive the base and adjacent tower node
currentEdgeIterator.fetchWayGeometry(FetchMode.ALL), // fetches all pillar nodes inclusive the base and adjacent tower node
ghPoint3D -> GeoPoint.latLon(ghPoint3D.getLat(), ghPoint3D.getLon(), ghPoint3D.getEle())
);
}
Expand All @@ -85,7 +85,7 @@ public String getConnectionId() {

@Override
public String getWayType() {
return getConnection().map(con -> con.getWay().getType()).orElse(null);
return WayTypeEncoder.decode(getWayTypeEncoded());
}

public int getWayTypeEncoded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private BaseGraph createGraphFromDatabase(Database db) {
final BaseGraph graph = new BaseGraph
.Builder(encoding.getEncodingManager())
.setDir(new RAMDirectory())
.set3D(false)
.set3D(true)
.withTurnCosts(encoding.getEncodingManager().needsTurnCostsSupport())
.setSegmentSize(-1)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class GraphHopperWeighting extends AbstractWeighting {
public GraphHopperWeighting(VehicleEncoding vehicleEncoding, WayTypeEncoder wayTypeEncoder, TurnCostProvider turnCostProvider, GraphhopperToDatabaseMapper graphMapper) {
super(vehicleEncoding.access(), vehicleEncoding.speed(), turnCostProvider);
this.edgePropertiesState = new GraphHopperEdgeProperties(vehicleEncoding, wayTypeEncoder, graphMapper);
this.maxSpeed = speedEnc.getMaxOrMaxStorableDecimal() / 3.6;
this.maxSpeed = speedEnc.getMaxOrMaxStorableDecimal() / 3.6; // getMaxOrMaxStorableDecimal returns the speed in km/h
}

public GraphHopperWeighting setRoutingCostFunction(RoutingCostFunction routingCostFunction) {
Expand All @@ -66,7 +66,7 @@ public double calcEdgeWeight(EdgeIteratorState edge, boolean reverse) {
synchronized (edgePropertiesState) {
edgePropertiesState.setCurrentEdgeIterator(edge, reverse);
if (routingCostFunction == null) {
return (edge.getDistance() / edgePropertiesState.getSpeed());
return edge.getDistance() / edgePropertiesState.getSpeed();
} else {
return routingCostFunction.calculateCosts(edgePropertiesState);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ private void handleWayTags(int edgeId, Way way) {
* @return List of points representing the geometry.
*/
private PointList getWayGeometry(Node from, Node to, List<Node> wayNodeList) {
PointList points = new PointList(1000, false);
PointList points = new PointList(1000, true);

boolean between = false;
boolean reverse = true;
Expand All @@ -258,7 +258,8 @@ private PointList getWayGeometry(Node from, Node to, List<Node> wayNodeList) {
if (between) {
points.add(
wayNode.getPosition().getLatitude(),
wayNode.getPosition().getLongitude()
wayNode.getPosition().getLongitude(),
wayNode.getPosition().getAltitude()
);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void calculateFastestPath_turnCosts() {
Weighting w = new FastestWeighting(enc.access(), enc.speed(), new TurnCostsProvider(enc, g.getTurnCostStorage()));

//add expensive turn at (0-1)->(1,5)
g.getTurnCostStorage().set(enc.turnCost(), 0, 1, 3, 200);
g.getTurnCostStorage().set(enc.turnCost(), 0, 1, 3, 124);

//run
Path p = new BellmanFordRouting(g, w, new PMap()).calcPath(0, 10);
Expand Down

0 comments on commit 5a685f4

Please sign in to comment.