Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RONetHandler.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2002-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
22// The handler for SUMO-Networks
23/****************************************************************************/
24#include <config.h>
25
26#include <string>
37#include "ROEdge.h"
38#include "ROLane.h"
39#include "RONode.h"
40#include "RONet.h"
41#include "RONetHandler.h"
43
44
45// ===========================================================================
46// method definitions
47// ===========================================================================
48RONetHandler::RONetHandler(RONet& net, ROAbstractEdgeBuilder& eb, const bool ignoreInternal, const double minorPenalty, double tlsPenalty, double turnaroundPenalty) :
49 SUMOSAXHandler("sumo-network"),
50 myNet(net),
51 myNetworkVersion(0, 0),
52 myEdgeBuilder(eb), myIgnoreInternal(ignoreInternal),
53 myCurrentName(), myCurrentEdge(nullptr), myCurrentStoppingPlace(nullptr),
54 myMinorPenalty(minorPenalty),
55 myTLSPenalty(tlsPenalty),
56 myTurnaroundPenalty(turnaroundPenalty)
57{}
58
59
61
62
63void
65 const SUMOSAXAttributes& attrs) {
66 switch (element) {
68 setLocation(attrs);
69 break;
70 case SUMO_TAG_NET: {
71 bool ok;
72 myNetworkVersion = StringUtils::toVersion(attrs.get<std::string>(SUMO_ATTR_VERSION, nullptr, ok, false));
73 break;
74 }
75 case SUMO_TAG_EDGE:
76 // in the first step, we do need the name to allocate the edge
77 // in the second, we need it to know to which edge we have to add
78 // the following edges to
79 parseEdge(attrs);
80 break;
81 case SUMO_TAG_LANE:
82 parseLane(attrs);
83 break;
85 parseJunction(attrs);
86 break;
88 parseConnection(attrs);
89 break;
96 parseStoppingPlace(attrs, (SumoXMLTag)element);
97 break;
98 case SUMO_TAG_ACCESS:
99 parseAccess(attrs);
100 break;
101 case SUMO_TAG_TAZ:
102 parseDistrict(attrs);
103 break;
105 parseDistrictEdge(attrs, true);
106 break;
107 case SUMO_TAG_TAZSINK:
108 parseDistrictEdge(attrs, false);
109 break;
110 case SUMO_TAG_TYPE: {
111 bool ok = true;
112 myCurrentTypeID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
113 break;
114 }
116 bool ok = true;
117 const SUMOVehicleClass svc = getVehicleClassID(attrs.get<std::string>(SUMO_ATTR_VCLASS, myCurrentTypeID.c_str(), ok));
118 const double speed = attrs.get<double>(SUMO_ATTR_SPEED, myCurrentTypeID.c_str(), ok);
119 if (ok) {
121 }
122 break;
123 }
124 case SUMO_TAG_PREFERENCE: {
125 bool ok = true;
126 const std::string routingType = attrs.get<std::string>(SUMO_ATTR_ROUTINGTYPE, nullptr, ok);
127 const double prio = attrs.get<double>(SUMO_ATTR_PRIORITY, routingType.c_str(), ok);
128 if (prio <= 0) {
129 throw InvalidArgument("In preference for routingType '" + routingType + "', priority must be positve");
130 }
131 if (attrs.hasAttribute(SUMO_ATTR_VCLASSES)) {
132 StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_VCLASSES, routingType.c_str(), ok));
133 for (std::string className : st.getVector()) {
134 myNet.addPreference(routingType, getVehicleClassID(className), prio);
135 }
136 } else if (!attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
137 // general preferenze applying to all types and vClasses
138 myNet.addPreference(routingType, "", prio);
139 }
140 if (attrs.hasAttribute(SUMO_ATTR_VTYPES)) {
141 StringTokenizer st(attrs.get<std::string>(SUMO_ATTR_VTYPES, routingType.c_str(), ok));
142 for (std::string typeName : st.getVector()) {
143 myNet.addPreference(routingType, typeName, prio);
144 }
145 }
146 break;
147 }
148 case SUMO_TAG_REROUTER: {
149 bool ok = true;
150 myRerouterID = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
151 break;
152 }
154 if (myRerouterID != "") {
155 bool ok = true;
158 }
159 break;
161 const std::string& closed_id = attrs.getStringSecure(SUMO_ATTR_ID, "");
162 ROEdge* closedEdge = myNet.getEdge(closed_id);
163 if (closedEdge == nullptr) {
164 throw ProcessError(TLF("rerouter '%': Edge '%' to close is not known.", myRerouterID, closed_id));
165 }
166 bool ok;
167 const std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, myRerouterID.c_str(), ok, "", false);
168 const std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, myRerouterID.c_str(), ok, "");
169 RouterProhibition prohibition;
170 prohibition.permissions = parseVehicleClasses(allow, disallow);
171 prohibition.begin = STEPS2TIME(myIntervalBegin);
172 prohibition.end = STEPS2TIME(attrs.getOptSUMOTimeReporting(SUMO_ATTR_UNTIL, nullptr, ok, myIntervalEnd));
173 myNet.addProhibition(closedEdge, prohibition);
174 break;
175 }
176 case SUMO_TAG_PARAM:
177 addParam(attrs);
178 break;
179 default:
180 break;
181 }
182}
183
184
185void
187 switch (element) {
189 myRerouterID = "";
190 break;
191 case SUMO_TAG_NET:
192 // build junction graph
193 for (std::set<std::string>::const_iterator it = myUnseenNodeIDs.begin(); it != myUnseenNodeIDs.end(); ++it) {
194 WRITE_ERRORF(TL("Unknown node '%'."), *it);
195 }
196 break;
197 default:
198 break;
199 }
200}
201
202
203void
205 bool ok = true;
206 const std::string key = attrs.get<std::string>(SUMO_ATTR_KEY, nullptr, ok);
207 // circumventing empty string test
208 const std::string val = attrs.hasAttribute(SUMO_ATTR_VALUE) ? attrs.getString(SUMO_ATTR_VALUE) : "";
209 // add parameter in current created element, or in myLoadedParameterised
210 if (myCurrentEdge != nullptr) {
211 myCurrentEdge->setParameter(key, val);
212 }
213}
214
215
216void
218 // get the id, report an error if not given or empty...
219 bool ok = true;
220 myCurrentName = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
221 if (!ok) {
222 throw ProcessError();
223 }
225 if (!ok) {
226 return;
227 }
228 // get the edge
229 std::string from;
230 std::string to;
231 int priority;
232 myCurrentEdge = nullptr;
234 assert(myCurrentName[0] == ':');
236 from = junctionID;
237 to = junctionID;
238 priority = -1;
239 } else {
240 from = attrs.get<std::string>(SUMO_ATTR_FROM, myCurrentName.c_str(), ok);
241 to = attrs.get<std::string>(SUMO_ATTR_TO, myCurrentName.c_str(), ok);
242 priority = attrs.get<int>(SUMO_ATTR_PRIORITY, myCurrentName.c_str(), ok);
243 if (!ok) {
244 return;
245 }
246 }
247 RONode* fromNode = myNet.getNode(from);
248 if (fromNode == nullptr) {
249 myUnseenNodeIDs.insert(from);
250 fromNode = new RONode(from);
251 myNet.addNode(fromNode);
252 }
253 RONode* toNode = myNet.getNode(to);
254 if (toNode == nullptr) {
255 myUnseenNodeIDs.insert(to);
256 toNode = new RONode(to);
257 myNet.addNode(toNode);
258 }
259 const std::string type = attrs.getOpt<std::string>(SUMO_ATTR_TYPE, myCurrentName.c_str(), ok, "");
260 const std::string routingType = attrs.getOpt<std::string>(SUMO_ATTR_ROUTINGTYPE, myCurrentName.c_str(), ok, "");
261 // build the edge
262 myCurrentEdge = myEdgeBuilder.buildEdge(myCurrentName, fromNode, toNode, priority, type, routingType);
264
266 fromNode->addOutgoing(myCurrentEdge);
267 toNode->addIncoming(myCurrentEdge);
268 const std::string bidi = attrs.getOpt<std::string>(SUMO_ATTR_BIDI, myCurrentName.c_str(), ok, "");
269 if (bidi != "") {
271 }
272 } else {
273 myCurrentEdge = nullptr;
274 }
275}
276
277
278void
280 if (myCurrentEdge == nullptr) {
281 // was an internal edge to skip or an error occurred
282 return;
283 }
284 bool ok = true;
285 // get the id, report an error if not given or empty...
286 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
287 if (!ok) {
288 return;
289 }
290 // get the speed
291 double maxSpeed = attrs.get<double>(SUMO_ATTR_SPEED, id.c_str(), ok);
292 double length = attrs.get<double>(SUMO_ATTR_LENGTH, id.c_str(), ok);
293 std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, id.c_str(), ok, "");
294 std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, id.c_str(), ok, "");
295 const PositionVector shape = attrs.get<PositionVector>(SUMO_ATTR_SHAPE, id.c_str(), ok);
296 if (!ok) {
297 return;
298 }
299 if (shape.size() < 2) {
300 WRITE_ERRORF(TL("Ignoring lane '%' with broken shape."), id);
301 return;
302 }
303 // get the length
304 // get the vehicle classes
305 SVCPermissions permissions = parseVehicleClasses(allow, disallow, myNetworkVersion);
306 if (permissions != SVCAll) {
308 }
309 // add when both values are valid
310 if (maxSpeed > 0 && length > 0 && id.length() > 0) {
311 myCurrentEdge->addLane(new ROLane(id, myCurrentEdge, length, maxSpeed, permissions, shape));
312 } else {
313 WRITE_WARNING("Ignoring lane '" + id + "' with speed " + toString(maxSpeed) + " and length " + toString(length));
314 }
315}
316
317
318void
320 bool ok = true;
321 // get the id, report an error if not given or empty...
322 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
323 const SumoXMLNodeType type = attrs.get<SumoXMLNodeType>(SUMO_ATTR_TYPE, id.c_str(), ok);
324 if (type == SumoXMLNodeType::INTERNAL) {
325 return;
326 }
327 myUnseenNodeIDs.erase(id);
328 // get the position of the node
329 const double x = attrs.get<double>(SUMO_ATTR_X, id.c_str(), ok);
330 const double y = attrs.get<double>(SUMO_ATTR_Y, id.c_str(), ok);
331 const double z = attrs.getOpt<double>(SUMO_ATTR_Z, id.c_str(), ok, 0.);
332 if (!ok) {
333 return;
334 }
335 RONode* n = myNet.getNode(id);
336 if (n == nullptr) {
337 WRITE_WARNINGF(TL("Skipping isolated junction '%'."), id);
338 } else {
339 n->setPosition(Position(x, y, z));
340 }
341}
342
343
344void
346 bool ok = true;
347 std::string fromID = attrs.get<std::string>(SUMO_ATTR_FROM, nullptr, ok);
348 std::string toID = attrs.get<std::string>(SUMO_ATTR_TO, nullptr, ok);
349 const int fromLane = attrs.get<int>(SUMO_ATTR_FROM_LANE, nullptr, ok);
350 const int toLane = attrs.get<int>(SUMO_ATTR_TO_LANE, nullptr, ok);
351 std::string dir = attrs.get<std::string>(SUMO_ATTR_DIR, nullptr, ok);
352 std::string viaID = attrs.getOpt<std::string>(SUMO_ATTR_VIA, nullptr, ok, "");
353 std::string tlID = attrs.getOpt<std::string>(SUMO_ATTR_TLID, nullptr, ok, "");
354 ROEdge* from = myNet.getEdge(fromID);
355 ROEdge* to = myNet.getEdge(toID);
356 if (from == nullptr) {
357 throw ProcessError(TLF("unknown from-edge '%' in connection", fromID));
358 }
359 if (to == nullptr) {
360 throw ProcessError(TLF("unknown to-edge '%' in connection", toID));
361 }
362 if ((int)from->getLanes().size() <= fromLane) {
363 throw ProcessError("invalid fromLane '" + toString(fromLane) + "' in connection from '" + fromID + "'.");
364 }
365 if ((int)to->getLanes().size() <= toLane) {
366 throw ProcessError("invalid toLane '" + toString(toLane) + "' in connection to '" + toID + "'.");
367 }
368 if (myIgnoreInternal || viaID == "") {
369 std::string allow = attrs.getOpt<std::string>(SUMO_ATTR_ALLOW, nullptr, ok, "");
370 std::string disallow = attrs.getOpt<std::string>(SUMO_ATTR_DISALLOW, nullptr, ok, "");
371 ROEdge* dummyVia = nullptr;
372 SVCPermissions permissions;
373 if (allow == "" && disallow == "") {
374 permissions = SVC_UNSPECIFIED;
375 } else {
377 // dummyVia is only needed to hold permissions
378 permissions = parseVehicleClasses(allow, disallow);
379 dummyVia = new ROEdge("dummyVia_" + from->getLanes()[fromLane]->getID() + "->" + to->getLanes()[toLane]->getID(),
380 from->getToJunction(), from->getToJunction(), permissions);
381 myNet.addEdge(dummyVia);
382 }
383 from->getLanes()[fromLane]->addOutgoingLane(to->getLanes()[toLane], dummyVia);
384 from->addSuccessor(to, nullptr, dir);
385 } else {
387 if (via == nullptr) {
388 throw ProcessError(TLF("unknown via-edge '%' in connection", viaID));
389 }
390 from->getLanes()[fromLane]->addOutgoingLane(to->getLanes()[toLane], via);
391 from->addSuccessor(to, via, dir);
392 via->addSuccessor(to, nullptr, dir);
393 LinkState state = SUMOXMLDefinitions::LinkStates.get(attrs.get<std::string>(SUMO_ATTR_STATE, nullptr, ok));
394 if (state == LINKSTATE_MINOR || state == LINKSTATE_EQUAL || state == LINKSTATE_STOP || state == LINKSTATE_ALLWAY_STOP) {
396 }
399 }
400 if (tlID != "") {
402 }
403 }
404 if (to->isCrossing()) {
406 }
407}
408
409
410void
412 bool ok = true;
414 // get the id, throw if not given or empty...
415 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, toString(element).c_str(), ok);
416 // get the lane
417 myCurrentStoppingPlace->lane = attrs.get<std::string>(SUMO_ATTR_LANE, toString(element).c_str(), ok);
418 if (!ok) {
419 throw ProcessError();
420 }
422 if (edge == nullptr) {
423 throw InvalidArgument("Unknown lane '" + myCurrentStoppingPlace->lane + "' for " + toString(element) + " '" + id + "'.");
424 }
425 // get the positions
426 myCurrentStoppingPlace->startPos = attrs.getOpt<double>(SUMO_ATTR_STARTPOS, id.c_str(), ok, 0.);
427 myCurrentStoppingPlace->endPos = attrs.getOpt<double>(SUMO_ATTR_ENDPOS, id.c_str(), ok, edge->getLength());
428 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, id.c_str(), ok, false);
430 throw InvalidArgument("Invalid position for " + toString(element) + " '" + id + "'.");
431 }
432 // this is a hack: the busstop attribute is meant to hold the id within the simulation context but this is not used within the router context
433 myCurrentStoppingPlace->busstop = attrs.getOpt<std::string>(SUMO_ATTR_NAME, id.c_str(), ok, "");
434 // this is a hack: the actType is not used when using this to encode a stopping place
437}
438
439
440void
442 bool ok = true;
443 const std::string lane = attrs.get<std::string>(SUMO_ATTR_LANE, "access", ok);
444 const ROEdge* edge = myNet.getEdgeForLaneID(lane);
445 if (edge == nullptr) {
446 throw InvalidArgument("Unknown lane '" + lane + "' for access.");
447 }
448 if ((edge->getPermissions() & SVC_PEDESTRIAN) == 0) {
449 WRITE_WARNINGF(TL("Ignoring invalid access from non-pedestrian edge '%'."), edge->getID());
450 return;
451 }
452 const bool random = attrs.getOpt<std::string>(SUMO_ATTR_POSITION, "access", ok) == "random";
453 double pos = random ? edge->getLength() / 2. : attrs.getOpt<double>(SUMO_ATTR_POSITION, "access", ok, 0.);
454 double length = attrs.getOpt<double>(SUMO_ATTR_LENGTH, "access", ok, -1);
455 const bool friendlyPos = attrs.getOpt<bool>(SUMO_ATTR_FRIENDLY_POS, "access", ok, false);
456 if (!ok || (SUMORouteHandler::checkStopPos(pos, pos, edge->getLength(), 0., friendlyPos) != SUMORouteHandler::StopPos::STOPPOS_VALID)) {
457 throw InvalidArgument("Invalid position " + toString(pos) + " for access on lane '" + lane + "'.");
458 }
459 if (!ok) {
460 throw ProcessError();
461 }
462 if (length < 0) {
463 const Position accPos = myNet.getLane(lane)->geometryPositionAtOffset(pos);
464 const double stopCenter = (myCurrentStoppingPlace->startPos + myCurrentStoppingPlace->endPos) / 2;
466 length = accPos.distanceTo(stopPos);
467 }
468 myCurrentStoppingPlace->accessPos.push_back(std::make_tuple(lane, pos, length));
469}
470
471
472void
474 myCurrentEdge = nullptr;
475 bool ok = true;
476 myCurrentName = attrs.get<std::string>(SUMO_ATTR_ID, nullptr, ok);
477 if (!ok) {
478 return;
479 }
480 ROEdge* const sink = myEdgeBuilder.buildEdge(myCurrentName + "-sink", nullptr, nullptr, 0, "", "");
481 ROEdge* const source = myEdgeBuilder.buildEdge(myCurrentName + "-source", nullptr, nullptr, 0, "", "");
482 myNet.addDistrict(myCurrentName, source, sink);
483 if (attrs.hasAttribute(SUMO_ATTR_EDGES)) {
484 const std::vector<std::string>& desc = attrs.get<std::vector<std::string> >(SUMO_ATTR_EDGES, myCurrentName.c_str(), ok);
485 for (const std::string& eID : desc) {
488 }
489 }
490}
491
492
493void
495 bool ok = true;
496 std::string id = attrs.get<std::string>(SUMO_ATTR_ID, myCurrentName.c_str(), ok);
497 myNet.addDistrictEdge(myCurrentName, id, isSource);
498}
499
500void
502 bool ok = true;
503 PositionVector s = attrs.get<PositionVector>(SUMO_ATTR_NET_OFFSET, nullptr, ok);
504 Boundary convBoundary = attrs.get<Boundary>(SUMO_ATTR_CONV_BOUNDARY, nullptr, ok);
505 Boundary origBoundary = attrs.get<Boundary>(SUMO_ATTR_ORIG_BOUNDARY, nullptr, ok);
506 std::string proj = attrs.get<std::string>(SUMO_ATTR_ORIG_PROJ, nullptr, ok);
507 if (ok) {
508 Position networkOffset = s[0];
509 GeoConvHelper::init(proj, networkOffset, origBoundary, convBoundary);
510 }
511}
512
513
514/****************************************************************************/
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:287
#define WRITE_ERRORF(...)
Definition MsgHandler.h:296
#define WRITE_WARNING(msg)
Definition MsgHandler.h:286
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
#define STEPS2TIME(x)
Definition SUMOTime.h:55
#define SUMOTime_MAX
Definition SUMOTime.h:34
SUMOVehicleClass getVehicleClassID(const std::string &name)
Returns the class id of the abstract class given by its name.
const SVCPermissions SVCAll
all VClasses are allowed
const SVCPermissions SVC_UNSPECIFIED
permissions not specified
SVCPermissions parseVehicleClasses(const std::string &allowedS)
Parses the given definition of allowed vehicle classes into the given containers Deprecated classes g...
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_PEDESTRIAN
pedestrian
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_CLOSING_REROUTE
reroute of type closing
@ SUMO_TAG_NET
root element of a network file
@ SUMO_TAG_REROUTER
A rerouter.
@ SUMO_TAG_TAZ
a traffic assignment zone
@ SUMO_TAG_CHARGING_STATION
A Charging Station.
@ SUMO_TAG_ACCESS
An access point for a train stop.
@ SUMO_TAG_CONTAINER_STOP
A container stop.
@ SUMO_TAG_TAZSINK
a sink within a district (connection road)
@ SUMO_TAG_BUS_STOP
A bus stop.
@ SUMO_TAG_LOCATION
@ SUMO_TAG_RESTRICTION
begin/end of the description of an edge restriction
@ SUMO_TAG_PREFERENCE
begin/end of the description of an edge preferences
@ SUMO_TAG_CONNECTION
connectioon between two lanes
@ SUMO_TAG_PARKING_AREA
A parking area.
@ SUMO_TAG_JUNCTION
begin/end of the description of a junction
@ SUMO_TAG_TRAIN_STOP
A train stop (alias for bus stop)
@ SUMO_TAG_OVERHEAD_WIRE_SEGMENT
An overhead wire segment.
@ SUMO_TAG_LANE
begin/end of the description of a single lane
@ SUMO_TAG_PARAM
parameter associated to a certain key
@ SUMO_TAG_TYPE
type (edge)
@ SUMO_TAG_TAZSOURCE
a source within a district (connection road)
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ TURN
The link is a 180 degree turn.
@ TURN_LEFTHAND
The link is a 180 degree turn (left-hand network)
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
@ LINKSTATE_ALLWAY_STOP
This is an uncontrolled, all-way stop link.
@ LINKSTATE_STOP
This is an uncontrolled, minor link, has to stop.
@ LINKSTATE_EQUAL
This is an uncontrolled, right-before-left link.
@ LINKSTATE_MINOR
This is an uncontrolled, minor link, has to brake.
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
@ SUMO_ATTR_STARTPOS
@ SUMO_ATTR_DISALLOW
@ SUMO_ATTR_CONV_BOUNDARY
@ SUMO_ATTR_ALLOW
@ SUMO_ATTR_LANE
@ SUMO_ATTR_NET_OFFSET
@ SUMO_ATTR_ORIG_BOUNDARY
@ SUMO_ATTR_SPEED
@ SUMO_ATTR_VALUE
@ SUMO_ATTR_VIA
@ SUMO_ATTR_Y
@ SUMO_ATTR_FROM_LANE
@ SUMO_ATTR_Z
@ SUMO_ATTR_ENDPOS
@ SUMO_ATTR_X
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_BIDI
@ SUMO_ATTR_PRIORITY
@ SUMO_ATTR_VTYPES
@ SUMO_ATTR_SHAPE
edge: the shape in xml-definition
@ SUMO_ATTR_VCLASSES
@ SUMO_ATTR_NAME
@ SUMO_ATTR_ORIG_PROJ
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_END
weights: time range end
@ SUMO_ATTR_TLID
link,node: the traffic light id responsible for this link
@ SUMO_ATTR_VCLASS
@ SUMO_ATTR_FRIENDLY_POS
@ SUMO_ATTR_TO_LANE
@ SUMO_ATTR_TYPE
@ SUMO_ATTR_LENGTH
@ SUMO_ATTR_VERSION
@ SUMO_ATTR_ID
@ SUMO_ATTR_UNTIL
@ SUMO_ATTR_FUNCTION
@ SUMO_ATTR_DIR
The abstract direction of a link.
@ SUMO_ATTR_KEY
@ SUMO_ATTR_POSITION
@ SUMO_ATTR_STATE
The state of a link.
@ SUMO_ATTR_ROUTINGTYPE
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
A class that stores a 2D geometrical boundary.
Definition Boundary.h:39
static bool init(OptionsCont &oc)
Initialises the processing and the final instance using the given options.
virtual void setParameter(const std::string &key, const std::string &value)
Sets a parameter.
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
double distanceTo(const Position &p2) const
returns the euclidean distance in 3 dimensions
Definition Position.h:263
A list of positions.
Interface for building instances of router-edges.
virtual ROEdge * buildEdge(const std::string &name, RONode *from, RONode *to, const int priority, const std::string &type, const std::string &routingType)=0
Builds an edge with the given name.
A basic edge for routing applications.
Definition ROEdge.h:73
void setFunction(SumoXMLEdgeFunc func)
Sets the function of the edge.
Definition ROEdge.h:118
virtual void addLane(ROLane *lane)
Adds a lane to the edge while loading.
Definition ROEdge.cpp:120
const std::vector< ROLane * > & getLanes() const
Returns this edge's lanes.
Definition ROEdge.h:553
double getLength() const
Returns the length of the edge.
Definition ROEdge.h:225
bool isCrossing() const
return whether this edge is a pedestrian crossing
Definition ROEdge.h:165
virtual void addSuccessor(ROEdge *s, ROEdge *via=nullptr, std::string dir="")
Adds information about a connected edge.
Definition ROEdge.cpp:135
void setTimePenalty(double value)
Definition ROEdge.h:146
A single lane the router may use.
Definition ROLane.h:48
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition ROLane.h:127
RONetHandler(RONet &net, ROAbstractEdgeBuilder &eb, const bool ignoreInternal, const double minorPenalty, double tlsPenalty, double turnaroundPenalty)
Constructor.
void parseAccess(const SUMOSAXAttributes &attrs)
const double myMinorPenalty
time penalty for passing a minor link
std::string myRerouterID
virtual void myEndElement(int element)
Called when a closing tag occurs.
MMVersion myNetworkVersion
the loaded network version
virtual ~RONetHandler()
Destructor.
void parseEdge(const SUMOSAXAttributes &attrs)
Parses and builds an edge.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
std::string myCurrentName
The name of the edge/node that is currently processed.
const double myTLSPenalty
void addParam(const SUMOSAXAttributes &attrs)
assign arbitrary vehicle parameters
ROEdge * myCurrentEdge
The currently built edge.
std::string myCurrentTypeID
The id of the currently processed edge type.
void parseStoppingPlace(const SUMOSAXAttributes &attrs, const SumoXMLTag element)
const bool myIgnoreInternal
whether to ignore junction internal edges
void parseConnection(const SUMOSAXAttributes &attrs)
std::map< ROEdge *, std::string > myBidiEdges
temporary storage for bidi attributes (to be resolved after loading all edges)
ROAbstractEdgeBuilder & myEdgeBuilder
The object used to build of edges of the desired type.
virtual void parseLane(const SUMOSAXAttributes &attrs)
Parses and builds a lane.
SUMOTime myIntervalBegin
SUMOVehicleParameter::Stop * myCurrentStoppingPlace
The currently built stopping place.
RONet & myNet
The net to store the information into.
const double myTurnaroundPenalty
void parseDistrict(const SUMOSAXAttributes &attrs)
void parseJunction(const SUMOSAXAttributes &attrs)
Parses a junction's position.
void parseDistrictEdge(const SUMOSAXAttributes &attrs, bool isSource)
std::set< std::string > myUnseenNodeIDs
temporary data for checking node initialisation after network parsing is finished
void setLocation(const SUMOSAXAttributes &attrs)
Parses network location description.
SUMOTime myIntervalEnd
The router's network representation.
Definition RONet.h:63
void setPermissionsFound()
Definition RONet.cpp:940
RONode * getNode(const std::string &id) const
Retrieves an node from the network.
Definition RONet.h:214
void addStoppingPlace(const std::string &id, const SumoXMLTag category, SUMOVehicleParameter::Stop *stop)
Definition RONet.cpp:327
bool addDistrictEdge(const std::string tazID, const std::string edgeID, const bool isSource)
Definition RONet.cpp:247
void addSpeedRestriction(const std::string &id, const SUMOVehicleClass svc, const double speed)
Adds a restriction for an edge type.
Definition RONet.cpp:149
void addProhibition(const ROEdge *edge, const RouterProhibition &prohibition)
Definition RONet.cpp:980
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition RONet.h:178
virtual bool addEdge(ROEdge *edge)
Definition RONet.cpp:210
ROLane * getLane(const std::string &laneID) const
Retrieves a lane rom the network given its id.
Definition RONet.cpp:882
void addNode(RONode *node)
Definition RONet.cpp:318
ROEdge * getEdgeForLaneID(const std::string &laneID) const
Retrieves an edge from the network when the lane id is given.
Definition RONet.cpp:876
void addPreference(const std::string &routingType, SUMOVehicleClass svc, double prio)
add edge type specific routing preference
Definition RONet.cpp:185
bool addDistrict(const std::string id, ROEdge *source, ROEdge *sink)
Definition RONet.cpp:224
Base class for nodes used by the router.
Definition RONode.h:46
void addOutgoing(ROEdge *edge)
Definition RONode.h:84
void addIncoming(ROEdge *edge)
Definition RONode.h:80
void setPosition(const Position &p)
Sets the position of the node.
Definition RONode.cpp:41
static StopPos checkStopPos(double &startPos, double &endPos, const double laneLength, const double minLength, const bool friendlyPos)
check start and end position of a stop
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
SUMOTime getOptSUMOTimeReporting(int attr, const char *objectid, bool &ok, SUMOTime defaultValue, bool report=true) const
Tries to read given attribute assuming it is a SUMOTime.
virtual std::string getStringSecure(int id, const std::string &def) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
SAX-handler base for SUMO-files.
Definition of vehicle stop (position and duration)
std::string lane
The lane to stop at.
double startPos
The stopping position start.
std::string actType
act Type (only used by Persons) (used by netedit)
double endPos
The stopping position end.
std::vector< std::tuple< std::string, double, double > > accessPos
lanes and positions connected to this stop (only used by duarouter where Stop is used to store stoppi...
std::string busstop
(Optional) bus stop if one is assigned to the stop
static std::string getEdgeIDFromLane(const std::string laneID)
return edge id when given the lane ID
static StringBijection< LinkState > LinkStates
link states
static std::string getJunctionIDFromInternalEdge(const std::string internalEdge)
return the junction id when given an edge of type internal, crossing or WalkingArea
T get(const std::string &str) const
get key
std::vector< std::string > getVector()
return vector of strings
static MMVersion toVersion(const std::string &sData)
parse a (network) version string
Prohibitions and their estimated end time.
SVCPermissions permissions