SUMO - Simulation of Urban MObility
NIVissimAbstractEdge.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
19 // -------------------
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 
33 #include <map>
34 #include <cassert>
36 #include <utils/common/ToString.h>
37 #include <utils/geom/GeomHelper.h>
39 #include <netbuild/NBNetBuilder.h>
40 #include "NIVissimAbstractEdge.h"
41 
42 
44 
46  const PositionVector& geom)
47  : myID(id), myNode(-1) {
48  // convert/publicate geometry
49  for (PositionVector::const_iterator i = geom.begin(); i != geom.end(); ++i) {
50  Position p = *i;
52  WRITE_WARNING("Unable to project coordinates for edge '" + toString(id) + "'.");
53  }
55  }
56  //
57  dictionary(id, this);
58 }
59 
60 
62 
63 
64 bool
66  DictType::iterator i = myDict.find(id);
67  if (i == myDict.end()) {
68  myDict[id] = e;
69  return true;
70  }
71  return false;
72 }
73 
74 
77  DictType::iterator i = myDict.find(id);
78  if (i == myDict.end()) {
79  return 0;
80  }
81  return (*i).second;
82 }
83 
84 
85 
88  if (myGeom.length() > pos) {
89  return myGeom.positionAtOffset(pos);
90  } else if (myGeom.length() == pos) {
91  return myGeom[-1];
92  } else {
94  const double amount = pos - myGeom.length();
95  g.extrapolate(amount * 2);
96  return g.positionAtOffset(pos + amount * 2);
97  }
98 }
99 
100 
101 void
103  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
104  NIVissimAbstractEdge* e = (*i).second;
105  e->splitAssigning();
106  }
107 }
108 
109 void
111 
112 
113 
114 
115 
116 bool
118  return myGeom.intersects(c->myGeom);
119 }
120 
121 
122 Position
125 }
126 
127 
128 std::vector<int>
130  std::vector<int> ret;
131  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
132  NIVissimAbstractEdge* e = (*i).second;
133  if (e->overlapsWith(p, offset)) {
134  ret.push_back(e->myID);
135  }
136  }
137  return ret;
138 }
139 
140 
141 bool
142 NIVissimAbstractEdge::overlapsWith(const AbstractPoly& p, double offset) const {
143  return myGeom.overlapsWith(p, offset);
144 }
145 
146 
147 bool
149  return myNode != -1;
150 }
151 
152 
153 int
155  return myID;
156 }
157 
158 void
160  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
161  delete(*i).second;
162  }
163  myDict.clear();
164 }
165 
166 
167 const PositionVector&
169  return myGeom;
170 }
171 
172 
173 void
175  myDisturbances.push_back(disturbance);
176 }
177 
178 
179 const std::vector<int>&
181  return myDisturbances;
182 }
183 
184 
185 
186 /****************************************************************************/
187 
Position getGeomPosition(double pos) const
const std::vector< int > & getDisturbances() const
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
static bool dictionary(int id, NIVissimAbstractEdge *e)
void addDisturbance(int disturbance)
Position intersectionPosition2D(const Position &p1, const Position &p2, const double withinDist=0.) const
Returns the position of the intersection.
const PositionVector & getGeometry() const
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:199
bool overlapsWith(const AbstractPoly &p, double offset=0.0) const
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
NIVissimAbstractEdge(int id, const PositionVector &geom)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:45
A list of positions.
static std::vector< int > getWithin(const AbstractPoly &p, double offset=0.0)
bool overlapsWith(const AbstractPoly &poly, double offset=0) const
Returns the information whether the given polygon overlaps with this.
Position crossesEdgeAtPoint(NIVissimAbstractEdge *c) const
void extrapolate(const double val, const bool onlyFirst=false, const bool onlyLast=false)
extrapolate position vector
double length() const
Returns the length.
std::vector< int > myDisturbances
bool crossesEdge(NIVissimAbstractEdge *c) const
std::map< int, NIVissimAbstractEdge * > DictType
void push_back_noDoublePos(const Position &p)
insert in back a non double position
Position positionAtOffset(double pos, double lateralOffset=0) const
Returns the position at the given length.
bool intersects(const Position &p1, const Position &p2) const
Returns the information whether this list of points interesects the given line.