Commit 2a60e439 authored by Tobias Meuser's avatar Tobias Meuser
Browse files

Minor changes to Road Network

parent dc916fdd
......@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import de.tudarmstadt.maki.simonstrator.api.component.sensor.environment.data.properties.RoadProperty;
......@@ -64,6 +65,10 @@ public class RoadNetwork implements RoadNetworkEdgeListener {
_roadNetwork = pRoadNetwork;
_edgeController = pEdgeController;
for (Entry<String, RoadNetworkEdge> roadNetworkEdge : pRoadNetwork.entrySet()) {
roadNetworkEdge.getValue().registerEdgeListener(this);
}
}
/**
......
......@@ -45,7 +45,7 @@ public class RoadNetworkEdge {
private boolean _isUsableInit = false;
private boolean _isUsable = false;
private double _length = Double.NaN;
private double _length = -1;
private List<RoadNetworkLane> _lanes = new ArrayList<>();
......@@ -254,7 +254,7 @@ public class RoadNetworkEdge {
}
public double getLength() {
if (Double.isNaN(_length)) {
if (_length < 0) {
_length = _edgeController.getEdgeLength(_edgeID);
}
return _length;
......
......@@ -21,12 +21,13 @@
package de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.paths.VehiclePathTracker;
import de.tudarmstadt.maki.simonstrator.api.component.vehicular.roadnetwork.paths.VehiclePathTrackerFactory;
public class RoadNetworkRoute {
public class RoadNetworkRoute implements Iterable<RoadNetworkEdge> {
private List<RoadNetworkEdge> _route;
public RoadNetworkRoute(List<RoadNetworkEdge> pRoute) {
......@@ -141,4 +142,17 @@ public class RoadNetworkRoute {
}
return new RoadNetworkRoute(edges);
}
@Override
public Iterator<RoadNetworkEdge> iterator() {
return _route.iterator();
}
public double calculateStandardRouteCosts() {
double sum = 0;
for (RoadNetworkEdge roadNetworkEdge : _route) {
sum += roadNetworkEdge.calculateStandardEdgeCosts();
}
return sum;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment