MATSIM
VisLinkWLanes.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * OTFLanesLinkData
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2010 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 package org.matsim.lanes;
21 
22 import org.matsim.api.core.v01.Coord;
24 
25 import java.awt.geom.Point2D;
26 import java.awt.geom.Point2D.Double;
27 import java.io.Serializable;
28 import java.util.ArrayList;
29 import java.util.HashMap;
30 import java.util.List;
31 import java.util.Map;
32 
33 
38 public final class VisLinkWLanes implements Serializable{
39 
40  private Point2D.Double linkStart = null;
41  private Point2D.Double linkEnd = null;
42  private Point2D.Double normalizedLinkVector;
43  private Point2D.Double linkOrthogonalVector;
44  private double numberOfLanes = 1.0;
45  private int maximalAlignment = 0;
46  private Map<String, VisLane> laneData = null;
47  private String id = null;
48  private double linkWidth;
49  private Point2D.Double linkStartCenterPoint = null;
50  private Point2D.Double linkEndCenterPoint = null;
51  private Map<String, VisSignal> signals = null;
52  private ArrayList<String> toLinkIds;
53  private transient List<VisLinkWLanes> toLinks = null;
54  private Coord startCoord;
55  private Coord endCoord;
56  private double euklideanDistance;
57 
58  public VisLinkWLanes(String id){
59  this.id = id;
60  }
61 
62  public String getLinkId() {
63  return this.id;
64  }
65 
66  public void setNormalizedLinkVector(Point2D.Double v) {
67  this.normalizedLinkVector = v;
68  }
69 
70  public void setLinkOrthogonalVector(Point2D.Double v){
71  this.linkOrthogonalVector = v;
72  }
73 
74  public Point2D.Double getLinkStart() {
75  return linkStart;
76  }
77 
78 
79  public Point2D.Double getLinkEnd() {
80  return linkEnd;
81  }
82 
83 
84  public Double getNormalizedLinkVector() {
85  return normalizedLinkVector;
86  }
87 
88 
89  public Double getLinkOrthogonalVector() {
90  return linkOrthogonalVector;
91  }
92 
93  public void setNumberOfLanes(double nrLanes) {
94  this.numberOfLanes = nrLanes;
95  }
96 
97  public double getNumberOfLanes() {
98  return this.numberOfLanes;
99  }
100 
101  public void setMaximalAlignment(int maxAlign) {
102  this.maximalAlignment = maxAlign;
103  }
104 
105  public int getMaximalAlignment(){
106  return this.maximalAlignment;
107  }
108 
109  public void addLaneData(VisLane laneData){
110  if (this.laneData == null){
111  this.laneData = new HashMap<String, VisLane>();
112  }
113  this.laneData .put(laneData.getId(), laneData);
114  }
115 
116  public Map<String, VisLane> getLaneData(){
117  return this.laneData;
118  }
119 
120  public void addSignal(VisSignal signal) {
121  if (this.signals == null){
122  this.signals = new HashMap<String, VisSignal>();
123  }
124  this.signals.put(signal.getId(), signal);
125  }
126 
127  public Map<String, VisSignal> getSignals(){
128  return this.signals;
129  }
130 
131  public void setLinkWidth(double linkWidth) {
132  this.linkWidth = linkWidth;
133  }
134 
135  public double getLinkWidth(){
136  return this.linkWidth;
137  }
138  public void setLinkStartEndPoint(Double linkStart, Double linkEnd) {
139  this.linkStart = linkStart;
140  this.linkEnd = linkEnd;
141  this.calcCoords();
142  }
143 
144  public void setLinkStartCenterPoint(Double linkStartCenter) {
145  this.linkStartCenterPoint = linkStartCenter;
146  }
147 
148  public void setLinkEndCenterPoint(Double linkEndCenter) {
149  this.linkEndCenterPoint = linkEndCenter;
150  }
151 
153  return this.startCoord;
154  }
155 
157  return this.endCoord;
158  }
159 
160  private void calcCoords(){
161  this.startCoord = new Coord(linkStart.x, linkStart.y);
162  this.endCoord = new Coord(linkEnd.x, linkEnd.y);
163  this.euklideanDistance = CoordUtils.calcEuclideanDistance(startCoord, endCoord);
164  }
165 
166  public double getEuklideanDistance() {
167  return euklideanDistance;
168  }
169 
170  public Point2D.Double getLinkStartCenterPoint() {
171  return this.linkStartCenterPoint;
172  }
173 
174  public Point2D.Double getLinkEndCenterPoint() {
175  return this.linkEndCenterPoint;
176  }
177 
178  public void addToLink(VisLinkWLanes link){
179  if (this.toLinks == null){
180  this.toLinks = new ArrayList<VisLinkWLanes>();
181  }
182  this.toLinks.add(link);
183  }
184 
185  public List<VisLinkWLanes> getToLinks() {
186  return this.toLinks ;
187  }
188 
189  public void addToLinkId(String toLinkId){
190  if (this.toLinkIds == null)
191  this.toLinkIds = new ArrayList<>();
192  this.toLinkIds.add(toLinkId);
193  }
194 
195  public List<String> getToLinkIds() {
196  return toLinkIds ;
197  }
198 
199 }
static double calcEuclideanDistance(Coord coord, Coord other)