SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
NIVissimAbstractEdge.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // -------------------
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 
34 #include <map>
35 #include <cassert>
37 #include <utils/common/ToString.h>
38 #include <utils/geom/GeomHelper.h>
40 #include <netbuild/NBNetBuilder.h>
41 #include "NIVissimAbstractEdge.h"
42 
43 #ifdef CHECK_MEMORY_LEAKS
44 #include <foreign/nvwa/debug_new.h>
45 #endif // CHECK_MEMORY_LEAKS
46 
47 
49 
51  const PositionVector& geom)
52  : myID(id), myNode(-1) {
53  // convert/publicate geometry
54  for (PositionVector::const_iterator i = geom.begin(); i != geom.end(); ++i) {
55  Position p = *i;
57  WRITE_WARNING("Unable to project coordinates for edge '" + toString(id) + "'.");
58  }
60  }
61  //
62  dictionary(id, this);
63 }
64 
65 
67 
68 
69 bool
71  DictType::iterator i = myDict.find(id);
72  if (i == myDict.end()) {
73  myDict[id] = e;
74  return true;
75  }
76  return false;
77 }
78 
79 
82  DictType::iterator i = myDict.find(id);
83  if (i == myDict.end()) {
84  return 0;
85  }
86  return (*i).second;
87 }
88 
89 
90 
93  if (myGeom.length() > pos) {
94  return myGeom.positionAtOffset(pos);
95  } else if (myGeom.length() == pos) {
96  return myGeom[-1];
97  } else {
99  const SUMOReal amount = pos - myGeom.length();
100  g.extrapolate(amount * 2);
101  return g.positionAtOffset(pos + amount * 2);
102  }
103 }
104 
105 
106 void
108  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
109  NIVissimAbstractEdge* e = (*i).second;
110  e->splitAssigning();
111  }
112 }
113 
114 void
116 
117 
118 
119 
120 
121 bool
123  return myGeom.intersects(c->myGeom);
124 }
125 
126 
127 Position
130 }
131 
132 
133 std::vector<int>
135  std::vector<int> ret;
136  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
137  NIVissimAbstractEdge* e = (*i).second;
138  if (e->overlapsWith(p, offset)) {
139  ret.push_back(e->myID);
140  }
141  }
142  return ret;
143 }
144 
145 
146 bool
148  return myGeom.overlapsWith(p, offset);
149 }
150 
151 
152 bool
154  return myNode != -1;
155 }
156 
157 
158 int
160  return myID;
161 }
162 
163 void
165  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
166  delete(*i).second;
167  }
168  myDict.clear();
169 }
170 
171 
172 const PositionVector&
174  return myGeom;
175 }
176 
177 
178 void
180  myDisturbances.push_back(disturbance);
181 }
182 
183 
184 const std::vector<int>&
186  return myDisturbances;
187 }
188 
189 
190 
191 /****************************************************************************/
192 
bool overlapsWith(const AbstractPoly &p, SUMOReal offset=0.0) const
static bool dictionary(int id, NIVissimAbstractEdge *e)
static bool transformCoordinates(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
void addDisturbance(int disturbance)
bool intersects(const Position &p1, const Position &p2) const
Returns the information whether this list of points interesects the given line.
const PositionVector & getGeometry() const
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
bool crossesEdge(NIVissimAbstractEdge *c) const
NIVissimAbstractEdge(int id, const PositionVector &geom)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
A list of positions.
Position getGeomPosition(SUMOReal pos) const
Position positionAtOffset(SUMOReal pos, SUMOReal lateralOffset=0) const
Returns the position at the given length.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
SUMOReal length() const
Returns the length.
bool overlapsWith(const AbstractPoly &poly, SUMOReal offset=0) const
Returns the information whether the given polygon overlaps with this.
Position intersectionPosition2D(const Position &p1, const Position &p2, const SUMOReal withinDist=0.) const
Returns the position of the intersection.
std::vector< int > myDisturbances
std::map< int, NIVissimAbstractEdge * > DictType
#define SUMOReal
Definition: config.h:214
const std::vector< int > & getDisturbances() const
Position crossesEdgeAtPoint(NIVissimAbstractEdge *c) const
void push_back_noDoublePos(const Position &p)
insert in back a non double position
static std::vector< int > getWithin(const AbstractPoly &p, SUMOReal offset=0.0)
void extrapolate(const SUMOReal val, const bool onlyFirst=false)
extrapolate position vector