package vnsim.vehicular.routePlan.cityRouting; import java.util.StringTokenizer; import vnsim.map.object.Globals; import vnsim.vehicular.simulator.intersections.DirectedRoadSegment; import vnsim.vehicular.simulator.intersections.Intersection; public class RoadSegmentCongestion { private int crossRoadIndex; private int segmentIndex; private Double congestion; public RoadSegmentCongestion(int crossIdx, int segmentIdx, Double congestion) { crossRoadIndex = crossIdx; segmentIndex = segmentIdx; this.congestion = congestion; } public int getCrossRoadIndex() { return crossRoadIndex; } public int getSegmentIndex() { return segmentIndex; } public Double getCongestion() { return congestion; } public void setCongestion(Double congestion) { this.congestion = congestion; } public boolean equals(RoadSegmentCongestion rsc) { return crossRoadIndex == rsc.getCrossRoadIndex() && segmentIndex == rsc.getSegmentIndex(); } public boolean equals(DirectedRoadSegment drs) { // all intersections must be in server db Intersection it = Globals.map.allIntersections.get(crossRoadIndex); DirectedRoadSegment thissegment = it.segments.get(segmentIndex); return drs.equals(thissegment); } public RoadSegmentCongestion clone() { return new RoadSegmentCongestion(crossRoadIndex, segmentIndex, congestion); } public static RoadSegmentCongestion createRoadSegmentCongestion(String str) { StringTokenizer st = new StringTokenizer(str); int crosIdx = Integer.parseInt(st.nextToken()); int segmentIdx = Integer.parseInt(st.nextToken()); Double congestion = Double.parseDouble(st.nextToken()); return new RoadSegmentCongestion(crosIdx, segmentIdx, congestion); } public String toString() { return "" + crossRoadIndex + " " + segmentIndex + " " + congestion; } }