/************************************************************************************ * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University * All rights reserved. * Refer to LICENSE for terms and conditions of use. ***********************************************************************************/ package vnsim.map.object; import vnsim.vehicular.simulator.intersections.*; /** * @author Victor-Radu */ public class Cross implements Comparable, java.io.Serializable { /** serialVersionUID */ private static final long serialVersionUID = -5883719321862303634L; protected int roadIndex; // index of the current road protected int pointIndex; // index of the intersection point on the current road protected int crossRoadIndex; // index of the crossing road protected int crossPointIndex; // index of the intersection point on the crossing street public int intersectionIndex = -1; //index of the "Intersection" object in //the global vector "allIntersections" public Intersection intersection; public Cross(int roadIndex, int pointIndex, int crossRoadIndex, int crossPointIndex) { this.roadIndex = roadIndex; this.pointIndex = pointIndex; this.crossRoadIndex = crossRoadIndex; this.crossPointIndex = crossPointIndex; } public int getCrossPointIndex() { return crossPointIndex; } public void setCrossPointIndex(int crossPointIndex) { this.crossPointIndex = crossPointIndex; } public int getRoadIndex() { return roadIndex; } public void setRoadIndex(int roadIndex) { this.roadIndex = roadIndex; } public int getCrossRoadIndex() { return crossRoadIndex; } public void setCrossRoadIndex(int crossRoadIndex) { this.crossRoadIndex = crossRoadIndex; } public int getPointIndex() { return pointIndex; } public void setPointIndex(int pointIndex) { this.pointIndex = pointIndex; } /** * @override * @param arg0 * @return */ public int compareTo(Cross arg0) { Cross c = arg0; int r = pointIndex - c.getPointIndex(); if (r == 0) /* this happens when there is more than one crossroads at the * same point (common) */ r = crossRoadIndex - c.getCrossRoadIndex(); /* cross road index could also be same at the same point when * the point intersects with a circle. For example, TLID 60255246 * (Hardley Dr.) intersects with two different points on cross * road TLID 60290145 (also Hardley Dr.). Another example is * TLID 60260224 (Academy St.) and TLID 60260225 (Brandywine Cir.). * There are many such examples. */ return r; } }