[31] | 1 | /************************************************************************************ |
---|
| 2 | * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University |
---|
| 3 | * All rights reserved. |
---|
| 4 | * Refer to LICENSE for terms and conditions of use. |
---|
| 5 | ***********************************************************************************/ |
---|
| 6 | package vnsim.map.object; |
---|
| 7 | |
---|
| 8 | import vnsim.vehicular.simulator.intersections.*; |
---|
| 9 | |
---|
| 10 | /** |
---|
| 11 | * @author Victor-Radu |
---|
| 12 | */ |
---|
| 13 | public class Cross implements Comparable<Cross>, java.io.Serializable { |
---|
| 14 | |
---|
| 15 | /** <code>serialVersionUID</code> */ |
---|
| 16 | private static final long serialVersionUID = -5883719321862303634L; |
---|
| 17 | |
---|
| 18 | protected int roadIndex; // index of the current road |
---|
| 19 | protected int pointIndex; // index of the intersection point on the current road |
---|
| 20 | protected int crossRoadIndex; // index of the crossing road |
---|
| 21 | protected int crossPointIndex; // index of the intersection point on the crossing street |
---|
| 22 | |
---|
| 23 | public int intersectionIndex = -1; //index of the "Intersection" object in |
---|
| 24 | //the global vector "allIntersections" |
---|
| 25 | |
---|
| 26 | public Intersection intersection; |
---|
| 27 | |
---|
| 28 | public Cross(int roadIndex, int pointIndex, int crossRoadIndex, int crossPointIndex) { |
---|
| 29 | this.roadIndex = roadIndex; |
---|
| 30 | this.pointIndex = pointIndex; |
---|
| 31 | this.crossRoadIndex = crossRoadIndex; |
---|
| 32 | this.crossPointIndex = crossPointIndex; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | public int getCrossPointIndex() { |
---|
| 37 | return crossPointIndex; |
---|
| 38 | } |
---|
| 39 | public void setCrossPointIndex(int crossPointIndex) { |
---|
| 40 | this.crossPointIndex = crossPointIndex; |
---|
| 41 | } |
---|
| 42 | public int getRoadIndex() { |
---|
| 43 | return roadIndex; |
---|
| 44 | } |
---|
| 45 | public void setRoadIndex(int roadIndex) { |
---|
| 46 | this.roadIndex = roadIndex; |
---|
| 47 | } |
---|
| 48 | public int getCrossRoadIndex() { |
---|
| 49 | return crossRoadIndex; |
---|
| 50 | } |
---|
| 51 | public void setCrossRoadIndex(int crossRoadIndex) { |
---|
| 52 | this.crossRoadIndex = crossRoadIndex; |
---|
| 53 | } |
---|
| 54 | public int getPointIndex() { |
---|
| 55 | return pointIndex; |
---|
| 56 | } |
---|
| 57 | public void setPointIndex(int pointIndex) { |
---|
| 58 | this.pointIndex = pointIndex; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | /** |
---|
| 62 | * @override |
---|
| 63 | * @param arg0 |
---|
| 64 | * @return |
---|
| 65 | */ |
---|
| 66 | public int compareTo(Cross arg0) { |
---|
| 67 | Cross c = arg0; |
---|
| 68 | int r = pointIndex - c.getPointIndex(); |
---|
| 69 | if (r == 0) |
---|
| 70 | /* this happens when there is more than one crossroads at the |
---|
| 71 | * same point (common) |
---|
| 72 | */ |
---|
| 73 | r = crossRoadIndex - c.getCrossRoadIndex(); |
---|
| 74 | /* cross road index could also be same at the same point when |
---|
| 75 | * the point intersects with a circle. For example, TLID 60255246 |
---|
| 76 | * (Hardley Dr.) intersects with two different points on cross |
---|
| 77 | * road TLID 60290145 (also Hardley Dr.). Another example is |
---|
| 78 | * TLID 60260224 (Academy St.) and TLID 60260225 (Brandywine Cir.). |
---|
| 79 | * There are many such examples. |
---|
| 80 | */ |
---|
| 81 | |
---|
| 82 | return r; |
---|
| 83 | } |
---|
| 84 | } |
---|