Browse Source

Fix issue with ArcBackward being drawn.

Holt59 3 years ago
parent
commit
251dbbb074
1 changed files with 17 additions and 4 deletions
  1. 17
    4
      src/main/org/insa/graph/Node.java

+ 17
- 4
src/main/org/insa/graph/Node.java View File

@@ -33,10 +33,23 @@ public class Node implements Comparable<Node> {
33 33
      */
34 34
     public static Arc linkNodes(Node origin, Node destination, float length,
35 35
             RoadInformation roadInformation, ArrayList<Point> points) {
36
-        ArcForward arc = new ArcForward(origin, destination, length, roadInformation, points);
37
-        origin.addSuccessor(arc);
38
-        if (!roadInformation.isOneWay()) {
39
-            destination.addSuccessor(new ArcBackward(arc));
36
+        Arc arc = null;
37
+        if (roadInformation.isOneWay()) {
38
+            arc = new ArcForward(origin, destination, length, roadInformation, points);
39
+            origin.addSuccessor(arc);
40
+        }
41
+        else {
42
+            Arc d2o;
43
+            if (origin.getId() < destination.getId()) {
44
+                arc = new ArcForward(origin, destination, length, roadInformation, points);
45
+                d2o = new ArcBackward(arc);
46
+            }
47
+            else {
48
+                d2o = new ArcForward(destination, origin, length, roadInformation, points);
49
+                arc = new ArcBackward(d2o);
50
+            }
51
+            origin.addSuccessor(arc);
52
+            destination.addSuccessor(d2o);
40 53
         }
41 54
         return arc;
42 55
     }

Loading…
Cancel
Save