Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2001-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 : /****************************************************************************/
14 : /// @file NIImporter_OpenStreetMap.h
15 : /// @author Daniel Krajzewicz
16 : /// @author Jakob Erdmann
17 : /// @author Michael Behrisch
18 : /// @author Walter Bamberger
19 : /// @author Gregor Laemmel
20 : /// @date Mon, 14.04.2008
21 : ///
22 : // Importer for networks stored in OpenStreetMap format
23 : /****************************************************************************/
24 : #pragma once
25 : #include <config.h>
26 :
27 : #include <string>
28 : #include <map>
29 : #include <utils/xml/SUMOSAXHandler.h>
30 : #include <utils/common/UtilExceptions.h>
31 : #include <utils/common/Parameterised.h>
32 : #include <netbuild/NBPTPlatform.h>
33 :
34 :
35 : // ===========================================================================
36 : // class declarations
37 : // ===========================================================================
38 : class NBEdge;
39 : class NBEdgeCont;
40 : class NBNetBuilder;
41 : class NBNode;
42 : class NBNodeCont;
43 : class NBTrafficLightLogicCont;
44 : class NBTypeCont;
45 : class OptionsCont;
46 :
47 :
48 : // ===========================================================================
49 : // class definitions
50 : // ===========================================================================
51 : /**
52 : * @class NIImporter_OpenStreetMap
53 : * @brief Importer for networks stored in OpenStreetMap format
54 : *
55 : */
56 : class NIImporter_OpenStreetMap {
57 : public:
58 : /** @brief Loads content of the optionally given OSM file
59 : *
60 : * If the option "osm-files" is set, the file(s) stored therein is read and
61 : * the network definition stored therein is stored within the given network
62 : * builder.
63 : *
64 : * If the option "osm-files" is not set, this method simply returns.
65 : *
66 : * @param[in] oc The options to use
67 : * @param[in, out] nb The network builder to fill
68 : */
69 : static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
70 :
71 : protected:
72 :
73 : /** @enum CycleWayType
74 : * @brief details on the kind of cycleway along this road
75 : */
76 : enum WayType {
77 : WAY_NONE = 0,
78 : WAY_FORWARD = 1,
79 : WAY_BACKWARD = 2,
80 : WAY_BOTH = WAY_FORWARD | WAY_BACKWARD,
81 : WAY_UNKNOWN = 4
82 : };
83 :
84 : /** @brief An internal representation of an OSM-node
85 : */
86 : struct NIOSMNode : public Parameterised {
87 303809 : NIOSMNode(long long int _id, double _lon, double _lat)
88 303809 : :
89 303809 : id(_id), lon(_lon), lat(_lat), ele(0.),
90 303809 : tlsControlled(false),
91 303809 : pedestrianCrossing(false),
92 303809 : railwayCrossing(false),
93 303809 : railwaySignal(false),
94 303809 : railwayBufferStop(false),
95 607618 : ptStopPosition(false), ptStopLength(0), name(""),
96 303809 : permissions(SVC_IGNORING),
97 303809 : positionMeters(std::numeric_limits<double>::max()),
98 303809 : myRailDirection(WAY_UNKNOWN),
99 303809 : node(nullptr) { }
100 :
101 : /// @brief The node's id
102 : const long long int id;
103 : /// @brief The longitude the node is located at
104 : const double lon;
105 : /// @brief The latitude the node is located at
106 : const double lat;
107 : /// @brief The elevation of this node
108 : double ele;
109 : /// @brief Whether this is a tls controlled junction
110 : bool tlsControlled;
111 : /// @brief Whether this is a pedestrian crossing
112 : bool pedestrianCrossing;
113 : /// @brief Whether this is a railway crossing
114 : bool railwayCrossing;
115 : /// @brief Whether this is a railway (main) signal
116 : bool railwaySignal;
117 : /// @brief Whether this is a railway buffer stop
118 : bool railwayBufferStop;
119 : /// @brief Whether this is a public transport stop position
120 : bool ptStopPosition;
121 : /// @brief The length of the pt stop
122 : double ptStopLength;
123 : /// @brief The name of the node
124 : std::string name;
125 : /// @brief type of pt stop
126 : SVCPermissions permissions;
127 : /// @brief kilometrage/mileage
128 : std::string position;
129 : /// @brief position converted to m (using highest precision available)
130 : double positionMeters;
131 : /// @brief Information about the direction(s) of railway usage
132 : WayType myRailDirection;
133 : /// @brief the NBNode that was instantiated
134 : NBNode* node;
135 :
136 : private:
137 : /// invalidated assignment operator
138 : NIOSMNode& operator=(const NIOSMNode& s) = delete;
139 :
140 :
141 : };
142 :
143 : public:
144 : /// @brief translate osm transport designations into sumo vehicle class
145 : static SUMOVehicleClass interpretTransportType(const std::string& type, NIOSMNode* toSet = nullptr);
146 :
147 : protected:
148 :
149 :
150 : enum ParkingType {
151 : PARKING_NONE = 0,
152 : PARKING_LEFT = 1,
153 : PARKING_RIGHT = 2,
154 : PARKING_BOTH = WAY_FORWARD | WAY_BACKWARD,
155 : PARKING_UNKNOWN = 4,
156 : PARKING_FORBIDDEN = 8,
157 : PARKING_PERPENDICULAR = 16,
158 : PARKING_DIAGONAL = 32
159 : };
160 :
161 : enum ChangeType {
162 : CHANGE_YES = 0,
163 : CHANGE_NO_LEFT = 1,
164 : CHANGE_NO_RIGHT = 2,
165 : CHANGE_NO = 3
166 : };
167 :
168 : /** @brief An internal definition of a loaded edge
169 : */
170 : class Edge : public Parameterised {
171 : public:
172 43059 : explicit Edge(long long int _id) :
173 43059 : id(_id), myNoLanes(-1), myNoLanesForward(0),
174 43059 : myMaxSpeed(MAXSPEED_UNGIVEN),
175 43059 : myMaxSpeedBackward(MAXSPEED_UNGIVEN),
176 43059 : myExtraAllowed(0),
177 43059 : myExtraDisallowed(0),
178 43059 : myCyclewayType(WAY_UNKNOWN), // building of extra lane depends on bikelaneWidth of loaded typemap
179 43059 : myBuswayType(WAY_NONE), // buslanes are always built when declared
180 43059 : mySidewalkType(WAY_UNKNOWN), // building of extra lanes depends on sidewalkWidth of loaded typemap
181 43059 : myRailDirection(WAY_UNKNOWN), // store direction(s) of railway usage
182 43059 : myParkingType(PARKING_NONE), // parking areas exported optionally
183 43059 : myChangeForward(CHANGE_YES),
184 43059 : myChangeBackward(CHANGE_YES),
185 43059 : myLayer(0), // layer is non-zero only in conflict areas
186 43059 : myCurrentIsRoad(false),
187 43059 : myAmInRoundabout(false),
188 43059 : myWidth(-1)
189 43059 : { }
190 :
191 172236 : virtual ~Edge() {}
192 :
193 : /// @brief The edge's id
194 : const long long int id;
195 : /// @brief The edge's street name
196 : std::string streetName;
197 : /// @brief The edge's track name
198 : std::string ref;
199 : /// @brief number of lanes, or -1 if unknown
200 : int myNoLanes;
201 : /// @brief number of lanes in forward direction or 0 if unknown, negative if backwards lanes are meant
202 : int myNoLanesForward;
203 : /// @brief maximum speed in km/h, or MAXSPEED_UNGIVEN
204 : double myMaxSpeed;
205 : /// @brief maximum speed in km/h, or MAXSPEED_UNGIVEN
206 : double myMaxSpeedBackward;
207 : /// @brief Extra permissions added from tags instead of highway type
208 : SVCPermissions myExtraAllowed;
209 : /// @brief Extra permissions prohibited from tags instead of highway type
210 : SVCPermissions myExtraDisallowed;
211 : /// @brief The type, stored in "highway" key
212 : std::string myHighWayType;
213 : /// @brief Information whether this is an one-way road
214 : std::string myIsOneWay;
215 : /// @brief Information about the kind of cycleway along this road
216 : WayType myCyclewayType;
217 : /// @brief Information about the kind of busway along this road
218 : WayType myBuswayType;
219 : /// @brief Information about the kind of sidwalk along this road
220 : WayType mySidewalkType;
221 : /// @brief Information about the direction(s) of railway usage
222 : WayType myRailDirection;
223 : /// @brief Information about road-side parking
224 : int myParkingType;
225 : /// @brief Information about change prohibitions (forward direction
226 : int myChangeForward;
227 : /// @brief Information about change prohibitions (backward direction
228 : int myChangeBackward;
229 : /// @brief (optional) information about whether the forward lanes are designated to some SVCs
230 : std::vector<bool> myDesignatedLaneForward;
231 : /// @brief (optional) information about whether the backward lanes are designated to some SVCs
232 : std::vector<bool> myDesignatedLaneBackward;
233 : /// @brief (optional) information about additional allowed SVCs on forward lane(s)
234 : std::vector<SVCPermissions> myAllowedLaneForward;
235 : /// @brief (optional) information about additional allowed SVCs on backward lane(s)
236 : std::vector<SVCPermissions> myAllowedLaneBackward;
237 : /// @brief (optional) information about additional disallowed SVCs on forward lane(s)
238 : std::vector<SVCPermissions> myDisallowedLaneForward;
239 : /// @brief (optional) information about additional disallowed SVCs on backward lane(s)
240 : std::vector<SVCPermissions> myDisallowedLaneBackward;
241 : /// @brief Information about the relative z-ordering of ways
242 : int myLayer;
243 : /// @brief The list of nodes this edge is made of
244 : std::vector<long long int> myCurrentNodes;
245 : /// @brief Information whether this is a road
246 : bool myCurrentIsRoad;
247 : /// @brief Information whether this road is part of a roundabout
248 : bool myAmInRoundabout;
249 : /// @brief Additionally tagged information
250 : std::map<std::string, std::string> myExtraTags;
251 : /// @brief turning direction (arrows printed on the road)
252 : std::vector<int> myTurnSignsForward;
253 : std::vector<int> myTurnSignsBackward;
254 : /// @brief Information on lane width
255 : std::vector<double> myWidthLanesForward;
256 : std::vector<double> myWidthLanesBackward;
257 : double myWidth;
258 :
259 : private:
260 : /// invalidated assignment operator
261 : Edge& operator=(const Edge& s) = delete;
262 : };
263 :
264 :
265 : NIImporter_OpenStreetMap();
266 :
267 : ~NIImporter_OpenStreetMap();
268 :
269 : void load(const OptionsCont& oc, NBNetBuilder& nb);
270 :
271 : private:
272 : /** @brief Functor which compares two NIOSMNodes according
273 : * to their coordinates
274 : */
275 : class CompareNodes {
276 : public:
277 : bool operator()(const NIOSMNode* n1, const NIOSMNode* n2) const {
278 8269276 : return (n1->lat > n2->lat) || (n1->lat == n2->lat && n1->lon > n2->lon);
279 : }
280 : };
281 :
282 :
283 : /// @brief The separator within newly created compound type names
284 : static const std::string compoundTypeSeparator;
285 :
286 : class CompareEdges;
287 :
288 : /** @brief the map from OSM node ids to actual nodes
289 : * @note: NIOSMNodes may appear multiple times due to substition
290 : */
291 : std::map<long long int, NIOSMNode*> myOSMNodes;
292 :
293 : /// @brief the set of unique nodes used in NodesHandler, used when freeing memory
294 : std::set<NIOSMNode*, CompareNodes> myUniqueNodes;
295 :
296 :
297 : /** @brief the map from OSM way ids to edge objects */
298 : std::map<long long int, Edge*> myEdges;
299 :
300 : /** @brief the map from OSM way ids to platform shapes */
301 : std::map<long long int, Edge*> myPlatformShapes;
302 :
303 : /// @brief The compounds types that do not contain known types
304 : std::set<std::string> myUnusableTypes;
305 :
306 : /// @brief The compound types that have already been mapped to other known types
307 : std::map<std::string, std::string> myKnownCompoundTypes;
308 :
309 : /// @brief import lane specific access restrictions
310 : bool myImportLaneAccess;
311 :
312 : /// @brief import sidewalks
313 : bool myImportSidewalks;
314 :
315 : /// @brief import sidewalks
316 : bool myOnewayDualSidewalk;
317 :
318 : /// @brief import bike path specific permissions and directions
319 : bool myImportBikeAccess;
320 :
321 : /// @brief import crossings
322 : bool myImportCrossings;
323 :
324 : /// @brief import turning signals (turn:lanes) to guide connection building
325 : bool myImportTurnSigns;
326 :
327 : /// @brief whether edges should carry information on the use of typemap defaults
328 : bool myAnnotateDefaults;
329 :
330 : /// @brief whether additional way and node attributes shall be imported
331 : static bool myAllAttributes;
332 :
333 : /// @brief extra attributes to import
334 : static std::set<std::string> myExtraAttributes;
335 :
336 : /** @brief Builds an NBNode
337 : *
338 : * If a node with the given id is already known, nothing is done.
339 : * Otherwise, the position and other information of the node is retrieved from the
340 : * given node map, the node is built and added to the given node container.
341 : * If the node is controlled by a tls, the according tls is built and added
342 : * to the tls container.
343 : * @param[in] id The id of the node to build
344 : * @param[in] osmNodes Map of node ids to information about these
345 : * @param[in, out] nc The node container to add the built node to
346 : * @param[in, out] tlsc The traffic lights logic container to add the built tls to
347 : * @return The built/found node
348 : * @exception ProcessError If the tls could not be added to the container
349 : */
350 : NBNode* insertNodeChecking(long long int id, NBNodeCont& nc, NBTrafficLightLogicCont& tlsc);
351 :
352 :
353 : /** @brief Builds an NBEdge
354 : *
355 : * @param[in] e The definition of the edge
356 : * @param[in] index The index of the edge (in the case it is split along her nodes)
357 : * @param[in] from The origin node of the edge
358 : * @param[in] to The destination node of the edge
359 : * @param[in] passed The list of passed nodes (geometry information)
360 : * @param[in] osmNodes Container of node definitions for getting information about nodes from
361 : * @param[in, out] The NetBuilder instance
362 : * @param[in] first The first node of the way
363 : * @param[in] last The last node of the way
364 : * @return the new index if the edge is split
365 : * @exception ProcessError If the edge could not be added to the container
366 : */
367 : int insertEdge(Edge* e, int index, NBNode* from, NBNode* to,
368 : const std::vector<long long int>& passed, NBNetBuilder& nb,
369 : const NBNode* first, const NBNode* last);
370 :
371 : /// @brief reconstruct elevation from layer info
372 : void reconstructLayerElevation(double layerElevation, NBNetBuilder& nb);
373 :
374 : /// @brief collect neighboring nodes with their road distance and maximum between-speed. Search does not continue beyond knownElevation-nodes
375 : std::map<NBNode*, std::pair<double, double> >
376 : getNeighboringNodes(NBNode* node, double maxDist, const std::set<NBNode*>& knownElevation);
377 :
378 : /// @brief check whether the type is known or consists of known type compounds. return empty string otherwise
379 : std::string usableType(const std::string& type, const std::string& id, NBTypeCont& tc);
380 :
381 : /// @brief extend kilometrage data for all nodes along railway
382 : void extendRailwayDistances(Edge* e, NBTypeCont& tc);
383 :
384 : /// @brief read distance value from node and return value in m
385 : static double interpretDistance(NIOSMNode* node);
386 :
387 : protected:
388 : static const double MAXSPEED_UNGIVEN;
389 : static const long long int INVALID_ID;
390 :
391 : static void applyChangeProhibition(NBEdge* e, int changeProhibition);
392 : /// Applies lane use information from `nie` to `e`. Uses the member values
393 : /// `myLaneAllowedForward`, `myLaneDisallowedForward` and `myLaneDesignatedForward`
394 : /// or the respective backward values to determine the ultimate lane uses.
395 : /// When a value of `e->myLaneDesignatedForward/Backward` is `true`, all permissions for the corresponding
396 : /// lane will be deleted before adding permissions from `e->myLaneAllowedForward/Backward`.
397 : /// SVCs from `e->myLaneAllowedForward/Backward` will be added to the existing permissions (for each lane).
398 : /// SVCs from `e->myLaneDisallowedForward/Backward` will be subtracted from the existing permissions.
399 : /// @brief Applies lane use information from `nie` to `e`.
400 : /// @param e The NBEdge that the new information will be written to.
401 : /// @param nie Ths Edge that the information comes from.
402 : void applyLaneUse(NBEdge* e, NIImporter_OpenStreetMap::Edge* nie, const bool forward);
403 :
404 : static void mergeTurnSigns(std::vector<int>& signs, std::vector<int> signs2);
405 : void applyTurnSigns(NBEdge* e, const std::vector<int>& turnSigns);
406 :
407 : /**
408 : * @class NodesHandler
409 : * @brief A class which extracts OSM-nodes from a parsed OSM-file
410 : */
411 : class NodesHandler : public SUMOSAXHandler {
412 : public:
413 : /** @brief Constructor
414 : * @param[in, out] toFill The nodes container to fill
415 : * @param[in, out] uniqueNodes The nodes container for ensuring uniqueness
416 : * @param[in] options The options to use
417 : */
418 : NodesHandler(std::map<long long int, NIOSMNode*>& toFill, std::set<NIOSMNode*,
419 : CompareNodes>& uniqueNodes,
420 : const OptionsCont& cont);
421 :
422 :
423 : /// @brief Destructor
424 : ~NodesHandler() override;
425 :
426 : int getDuplicateNodes() const {
427 203 : return myDuplicateNodes;
428 : }
429 :
430 : void resetHierarchy() {
431 189 : myHierarchyLevel = 0;
432 : }
433 :
434 : protected:
435 : /// @name inherited from GenericSAXHandler
436 : //@{
437 :
438 : /** @brief Called on the opening of a tag;
439 : *
440 : * @param[in] element ID of the currently opened element
441 : * @param[in] attrs Attributes within the currently opened element
442 : * @exception ProcessError If something fails
443 : * @see GenericSAXHandler::myStartElement
444 : */
445 : void myStartElement(int element, const SUMOSAXAttributes& attrs) override;
446 :
447 :
448 : /** @brief Called when a closing tag occurs
449 : *
450 : * @param[in] element ID of the currently opened element
451 : * @exception ProcessError If something fails
452 : * @see GenericSAXHandler::myEndElement
453 : */
454 : void myEndElement(int element) override;
455 : //@}
456 :
457 :
458 : private:
459 : /// @brief The nodes container to fill
460 : std::map<long long int, NIOSMNode*>& myToFill;
461 :
462 : /// @brief id of the currently parsed node
463 : std::string myLastNodeID;
464 :
465 : /// @brief the currently parsed node
466 : NIOSMNode* myCurrentNode;
467 :
468 : bool myIsStation;
469 : std::string myRailwayRef;
470 :
471 : /// @brief The current hierarchy level
472 : int myHierarchyLevel;
473 :
474 : /// @brief the set of unique nodes (used for duplicate detection/substitution)
475 : std::set<NIOSMNode*, CompareNodes>& myUniqueNodes;
476 :
477 : /// @brief whether elevation data should be imported
478 : const bool myImportElevation;
479 :
480 : /// @brief custom requirements for rail signal tagging
481 : StringVector myRailSignalRules;
482 :
483 : /// @brief number of duplicate nodes
484 : int myDuplicateNodes;
485 :
486 : /// @brief the options
487 : const OptionsCont& myOptionsCont;
488 :
489 : private:
490 : /** @brief invalidated copy constructor */
491 : NodesHandler(const NodesHandler& s);
492 :
493 : /** @brief invalidated assignment operator */
494 : NodesHandler& operator=(const NodesHandler& s);
495 :
496 : };
497 :
498 :
499 : /**
500 : * @class EdgesHandler
501 : * @brief A class which extracts OSM-edges from a parsed OSM-file
502 : */
503 : class EdgesHandler : public SUMOSAXHandler {
504 : public:
505 : /** @brief Constructor
506 : *
507 : * @param[in] osmNodes The previously parsed (osm-)nodes
508 : * @param[in, out] toFill The edges container to fill with read edges
509 : */
510 : EdgesHandler(const std::map<long long int, NIOSMNode*>& osmNodes,
511 : std::map<long long int, Edge*>& toFill, std::map<long long int, Edge*>& platformShapes,
512 : const NBTypeCont& tc);
513 :
514 :
515 : /// @brief Destructor
516 : ~EdgesHandler() override;
517 :
518 :
519 : protected:
520 : /// @name inherited from GenericSAXHandler
521 : //@{
522 :
523 : /** @brief Called on the opening of a tag;
524 : *
525 : * @param[in] element ID of the currently opened element
526 : * @param[in] attrs Attributes within the currently opened element
527 : * @exception ProcessError If something fails
528 : * @see GenericSAXHandler::myStartElement
529 : */
530 : void myStartElement(int element, const SUMOSAXAttributes& attrs) override;
531 :
532 :
533 : /** @brief Called when a closing tag occurs
534 : *
535 : * @param[in] element ID of the currently opened element
536 : * @exception ProcessError If something fails
537 : * @see GenericSAXHandler::myEndElement
538 : */
539 : void myEndElement(int element) override;
540 : //@}
541 :
542 : double interpretSpeed(const std::string& key, std::string value);
543 :
544 : int interpretChangeType(const std::string& value) const;
545 :
546 : void interpretLaneUse(const std::string& value, SUMOVehicleClass svc, const bool forward) const;
547 :
548 : void addType(const std::string& singleTypeID);
549 :
550 :
551 : private:
552 : /// @brief The previously parsed nodes
553 : const std::map<long long int, NIOSMNode*>& myOSMNodes;
554 :
555 : /// @brief A map of built edges
556 : std::map<long long int, Edge*>& myEdgeMap;
557 :
558 : /// @brief A map of built edges
559 : std::map<long long int, Edge*>& myPlatformShapesMap;
560 :
561 : /// @brief The currently built edge
562 : Edge* myCurrentEdge = nullptr;
563 :
564 : /// @brief A map of non-numeric speed descriptions to their numeric values
565 : std::map<std::string, double> mySpeedMap;
566 :
567 : const NBTypeCont& myTypeCont;
568 :
569 : private:
570 : /** @brief invalidated copy constructor */
571 : EdgesHandler(const EdgesHandler& s);
572 :
573 : /** @brief invalidated assignment operator */
574 : EdgesHandler& operator=(const EdgesHandler& s);
575 :
576 : };
577 :
578 : /**
579 : * @class RelationHandler
580 : * @brief A class which extracts relevant relation information from a parsed OSM-file
581 : * - turn restrictions
582 : */
583 : class RelationHandler : public SUMOSAXHandler {
584 : public:
585 : /** @brief Constructor
586 : *
587 : * @param[in] osmNodes The previously parsed OSM-nodes
588 : * @param[in] osmEdges The previously parse OSM-edges
589 : */
590 : RelationHandler(const std::map<long long int, NIOSMNode*>& osmNodes,
591 : const std::map<long long int, Edge*>& osmEdges, NBPTStopCont* nbptStopCont,
592 : const std::map<long long int, Edge*>& platfromShapes, NBPTLineCont* nbptLineCont,
593 : const OptionsCont& oc);
594 :
595 :
596 : /// @brief Destructor
597 : ~RelationHandler() override;
598 :
599 : protected:
600 : /// @name inherited from GenericSAXHandler
601 : //@{
602 :
603 : /** @brief Called on the opening of a tag;
604 : *
605 : * @param[in] element ID of the currently opened element
606 : * @param[in] attrs Attributes within the currently opened element
607 : * @exception ProcessError If something fails
608 : * @see GenericSAXHandler::myStartElement
609 : */
610 : void myStartElement(int element, const SUMOSAXAttributes& attrs) override;
611 :
612 :
613 : /** @brief Called when a closing tag occurs
614 : *
615 : * @param[in] element ID of the currently opened element
616 : * @exception ProcessError If something fails
617 : * @see GenericSAXHandler::myEndElement
618 : */
619 : void myEndElement(int element) override;
620 : //@}
621 :
622 :
623 : private:
624 : /// @brief The previously parsed nodes
625 : const std::map<long long int, NIOSMNode*>& myOSMNodes;
626 :
627 : /// @brief The previously parsed edges
628 : const std::map<long long int, Edge*>& myOSMEdges;
629 :
630 : /// @brief The previously parsed platform shapes
631 : const std::map<long long int, Edge*>& myPlatformShapes;
632 :
633 : /// @brief The previously filled pt stop container
634 : NBPTStopCont* myNBPTStopCont;
635 :
636 : /// @brief PT Line container to be filled
637 : NBPTLineCont* myNBPTLineCont;
638 :
639 : /// @brief The currently parsed relation
640 : long long int myCurrentRelation;
641 :
642 : /// @brief whether the currently parsed relation is a restriction
643 : bool myIsRestriction;
644 :
645 : /// @brief exceptions to the restriction currenlty being parsed
646 : SVCPermissions myRestrictionException;
647 :
648 : /// @brief the origination way for the current restriction
649 : long long int myFromWay;
650 :
651 : /// @brief the destination way for the current restriction
652 : long long int myToWay;
653 :
654 : /// @brief the via node/way for the current restriction
655 : long long int myViaNode;
656 : long long int myViaWay;
657 :
658 : /// @brief the station node for the current stop_area
659 : long long int myStation;
660 :
661 : /// @brief the options cont
662 : const OptionsCont& myOptionsCont;
663 :
664 : /** @enum RestrictionType
665 : * @brief whether the only allowed or the only forbidden connection is defined
666 : */
667 : enum class RestrictionType {
668 : /// @brief The only valid connection is declared
669 : ONLY,
670 : /// @brief The only invalid connection is declared
671 : NO,
672 : /// @brief The relation tag was missing
673 : UNKNOWN
674 : };
675 : RestrictionType myRestrictionType;
676 :
677 : /// @brief reset members to their defaults for parsing a new relation
678 : void resetValues();
679 :
680 : /// @brief check whether a referenced way has a corresponding edge
681 : bool checkEdgeRef(long long int ref) const;
682 :
683 : /// @brief try to apply the parsed restriction and return whether successful
684 : bool applyRestriction() const;
685 :
686 : /// @brief try to find the way segment among candidates
687 : NBEdge* findEdgeRef(long long int wayRef, const std::vector<NBEdge*>& candidates) const;
688 :
689 : private:
690 : /** @brief invalidated copy constructor */
691 : RelationHandler(const RelationHandler& s);
692 :
693 : /** @brief invalidated assignment operator */
694 : RelationHandler& operator=(const RelationHandler& s);
695 :
696 : /// @brief bus stop references
697 : std::vector<long long int> myStops;
698 :
699 : /// @brief myStops which are actually platforms (in case there is no stop_position)
700 : std::set<long long int> myPlatformStops;
701 :
702 :
703 : struct NIIPTPlatform {
704 : long long int ref;
705 : bool isWay;
706 : };
707 :
708 : /// @brief bus stop platforms
709 : std::vector<NIIPTPlatform> myPlatforms;
710 :
711 : /// @brief ways in pt line references
712 : std::vector<long long int> myWays;
713 :
714 : /// @brief indicates whether current relation is a pt stop area
715 : bool myIsStopArea;
716 :
717 : /// @brief indicates whether current relation is a route
718 : bool myIsRoute;
719 :
720 : /// @brief indicates whether current relation is a pt route
721 : std::string myPTRouteType;
722 :
723 : /// @brief official route color
724 : RGBColor myRouteColor;
725 :
726 : /// @brief name of the relation
727 : std::string myName;
728 :
729 : /// @brief ref of the pt line
730 : std::string myRef;
731 :
732 : /// @brief service interval of the pt line in minutes
733 : int myInterval;
734 :
735 : /// @brief night service information of the pt line
736 : std::string myNightService;
737 :
738 : /** @brief the map from stop area member to stop_area id */
739 : std::map<long long int, long long int > myStopAreas;
740 :
741 : };
742 :
743 : };
|