source: proiecte/ptvs/src/vnsim/map/object/Road.java @ 31

Last change on this file since 31 was 31, checked in by (none), 14 years ago
File size: 3.4 KB
Line 
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 ***********************************************************************************/
6package vnsim.map.object;
7
8
9
10
11import java.util.ArrayList;
12
13import vnsim.vehicular.simulator.*;
14/**
15 * @author Victor-Radu
16 *
17 */
18public class Road implements Comparable<Road>, java.io.Serializable {
19       
20        /** <code>serialVersionUID</code> */
21        private static final long serialVersionUID = -5883719321862303634L;
22       
23        protected long id;
24        protected String type;                                  //Ave., St. or other
25        protected String name;
26        protected byte[] directionPrefix; 
27        protected byte[] directionSuffix;
28        public ArrayList<Point> points = new ArrayList<Point>();        // sorted vector of points that are maximum Globals.MAXSEGLEN from each other
29        public ArrayList<Cross> crosses = new ArrayList<Cross>();       // crosses wtih other roads
30       
31        protected int nextRdIdx = -1,                   // index of next segment along a road with the same name
32                                prevRdIdx = -1;                         // index of previous ...
33                                                                                        // both used just in the map building process
34
35        protected byte[] roadinfo;                              // A41, A31 or other (see TIGER files specs)
36
37        public SortedCarVector carsOnThisRoad=new SortedCarVector();
38       
39        //added for simulation
40        public int laneNo;
41
42        public Road(){
43
44        }
45       
46        public void printRoad(boolean printPoints) {
47                System.out.println("( " + id + " " + new String(directionPrefix) + " " + name + " " +
48                                new String(directionSuffix) + " " + type + " " + new String(roadinfo) + " " + points.size() + ")");
49                if (printPoints)
50                        for (int i=0; i < points.size();i++){
51                                System.out.print("\t"+(Point)points.get(i));
52                                if (i<points.size()-1){
53                                        System.out.println(((Point)points.get(i)).distanceTo((Point)points.get(i+1)));
54                                }
55                        }
56        }
57
58        public int compareTo(Road r) {
59                return (int)(id - r.id);
60        }
61
62        public ArrayList getCrosses() {
63                return crosses;
64        }
65
66        public void setCrosses(ArrayList crosses) {
67                this.crosses = crosses;
68        }
69        public byte[] getDirectionPrefix() {
70                return directionPrefix;
71        }
72        public void setDirectionPrefix(byte[] directionPrefix) {
73                this.directionPrefix = directionPrefix;
74        }
75        public byte[] getDirectionSuffix() {
76                return directionSuffix;
77        }
78        public void setDirectionSuffix(byte[] directionSuffix) {
79                this.directionSuffix = directionSuffix;
80        }
81        public long getId() {
82                return id;
83        }
84        public void setId(long id) {
85                this.id = id;
86        }
87        public String getName() {
88                return name;
89        }
90        public void setName(String name) {
91                this.name = name;
92        }
93        public int getNextRdIdx() {
94                return nextRdIdx;
95        }
96        public void setNextRdIdx(int nextRdIdx) {
97                this.nextRdIdx = nextRdIdx;
98        }
99        public ArrayList getPoints() {
100                return points;
101        }
102        public void setPoints(ArrayList points) {
103                this.points = points;
104        }
105        public int getPrevRdIdx() {
106                return prevRdIdx;
107        }
108        public void setPrevRdIdx(int prevRdIdx) {
109                this.prevRdIdx = prevRdIdx;
110        }
111        public String getType() {
112                return type;
113        }
114        public void setType(String type) {
115                this.type = type;
116        }
117       
118        public byte[] getRoadinfo() {
119                return roadinfo;
120        }
121        public void setRoadinfo(byte[] roadinfo) {
122                this.roadinfo = roadinfo;
123        }
124
125        public int oneWay; // 0=two-way ;
126                                           // 1=one-way from point 0 to last point
127                                           // 2=one-way from last point to point 0
128}
Note: See TracBrowser for help on using the repository browser.