SUMO - Simulation of Urban MObility
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-2017 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 
45 
47  const PositionVector& geom)
48  : myID(id), myNode(-1) {
49  // convert/publicate geometry
50  for (PositionVector::const_iterator i = geom.begin(); i != geom.end(); ++i) {
51  Position p = *i;
53  WRITE_WARNING("Unable to project coordinates for edge '" + toString(id) + "'.");
54  }
56  }
57  //
58  dictionary(id, this);
59 }
60 
61 
63 
64 
65 bool
67  DictType::iterator i = myDict.find(id);
68  if (i == myDict.end()) {
69  myDict[id] = e;
70  return true;
71  }
72  return false;
73 }
74 
75 
78  DictType::iterator i = myDict.find(id);
79  if (i == myDict.end()) {
80  return 0;
81  }
82  return (*i).second;
83 }
84 
85 
86 
89  if (myGeom.length() > pos) {
90  return myGeom.positionAtOffset(pos);
91  } else if (myGeom.length() == pos) {
92  return myGeom[-1];
93  } else {
95  const double amount = pos - myGeom.length();
96  g.extrapolate(amount * 2);
97  return g.positionAtOffset(pos + amount * 2);
98  }
99 }
100 
101 
102 void
104  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
105  NIVissimAbstractEdge* e = (*i).second;
106  e->splitAssigning();
107  }
108 }
109 
110 void
112 
113 
114 
115 
116 
117 bool
119  return myGeom.intersects(c->myGeom);
120 }
121 
122 
123 Position
126 }
127 
128 
129 std::vector<int>
131  std::vector<int> ret;
132  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
133  NIVissimAbstractEdge* e = (*i).second;
134  if (e->overlapsWith(p, offset)) {
135  ret.push_back(e->myID);
136  }
137  }
138  return ret;
139 }
140 
141 
142 bool
143 NIVissimAbstractEdge::overlapsWith(const AbstractPoly& p, double offset) const {
144  return myGeom.overlapsWith(p, offset);
145 }
146 
147 
148 bool
150  return myNode != -1;
151 }
152 
153 
154 int
156  return myID;
157 }
158 
159 void
161  for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
162  delete(*i).second;
163  }
164  myDict.clear();
165 }
166 
167 
168 const PositionVector&
170  return myGeom;
171 }
172 
173 
174 void
176  myDisturbances.push_back(disturbance);
177 }
178 
179 
180 const std::vector<int>&
182  return myDisturbances;
183 }
184 
185 
186 
187 /****************************************************************************/
188 
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:200
bool overlapsWith(const AbstractPoly &p, double offset=0.0) const
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
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.
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.