LCOV - code coverage report
Current view: top level - src/netimport - NIImporter_OpenStreetMap.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 35 35
Test Date: 2024-12-21 15:45:41 Functions: 100.0 % 4 4

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-2024 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       299458 :         NIOSMNode(long long int _id, double _lon, double _lat)
      88       299458 :             :
      89       299458 :             id(_id), lon(_lon), lat(_lat), ele(0.),
      90       299458 :             tlsControlled(false),
      91       299458 :             pedestrianCrossing(false),
      92       299458 :             railwayCrossing(false),
      93       299458 :             railwaySignal(false),
      94       299458 :             railwayBufferStop(false),
      95       598916 :             ptStopPosition(false), ptStopLength(0), name(""),
      96       299458 :             permissions(SVC_IGNORING),
      97       299458 :             positionMeters(std::numeric_limits<double>::max()),
      98       299458 :             myRailDirection(WAY_UNKNOWN),
      99       299458 :             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        42442 :         explicit Edge(long long int _id) :
     173        42442 :             id(_id), myNoLanes(-1), myNoLanesForward(0),
     174        42442 :             myMaxSpeed(MAXSPEED_UNGIVEN),
     175        42442 :             myMaxSpeedBackward(MAXSPEED_UNGIVEN),
     176        42442 :             myExtraAllowed(0),
     177        42442 :             myExtraDisallowed(0),
     178        42442 :             myCyclewayType(WAY_UNKNOWN), // building of extra lane depends on bikelaneWidth of loaded typemap
     179        42442 :             myBuswayType(WAY_NONE), // buslanes are always built when declared
     180        42442 :             mySidewalkType(WAY_UNKNOWN), // building of extra lanes depends on sidewalkWidth of loaded typemap
     181        42442 :             myRailDirection(WAY_UNKNOWN), // store direction(s) of railway usage
     182        42442 :             myParkingType(PARKING_NONE), // parking areas exported optionally
     183        42442 :             myChangeForward(CHANGE_YES),
     184        42442 :             myChangeBackward(CHANGE_YES),
     185        42442 :             myLayer(0), // layer is non-zero only in conflict areas
     186        42442 :             myCurrentIsRoad(false),
     187        42442 :             myAmInRoundabout(false),
     188        42442 :             myWidth(-1)
     189        42442 :         { }
     190              : 
     191       169768 :         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      8184096 :             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 bike path specific permissions and directions
     316              :     bool myImportBikeAccess;
     317              : 
     318              :     /// @brief import crossings
     319              :     bool myImportCrossings;
     320              : 
     321              :     /// @brief import turning signals (turn:lanes) to guide connection building
     322              :     bool myImportTurnSigns;
     323              : 
     324              :     /// @brief whether additional way and node attributes shall be imported
     325              :     static bool myAllAttributes;
     326              : 
     327              :     /// @brief extra attributes to import
     328              :     static std::set<std::string> myExtraAttributes;
     329              : 
     330              :     /** @brief Builds an NBNode
     331              :      *
     332              :      * If a node with the given id is already known, nothing is done.
     333              :      *  Otherwise, the position and other information of the node is retrieved from the
     334              :      *  given node map, the node is built and added to the given node container.
     335              :      * If the node is controlled by a tls, the according tls is built and added
     336              :      *  to the tls container.
     337              :      * @param[in] id The id of the node to build
     338              :      * @param[in] osmNodes Map of node ids to information about these
     339              :      * @param[in, out] nc The node container to add the built node to
     340              :      * @param[in, out] tlsc The traffic lights logic container to add the built tls to
     341              :      * @return The built/found node
     342              :      * @exception ProcessError If the tls could not be added to the container
     343              :      */
     344              :     NBNode* insertNodeChecking(long long int id, NBNodeCont& nc, NBTrafficLightLogicCont& tlsc);
     345              : 
     346              : 
     347              :     /** @brief Builds an NBEdge
     348              :      *
     349              :      * @param[in] e The definition of the edge
     350              :      * @param[in] index The index of the edge (in the case it is split along her nodes)
     351              :      * @param[in] from The origin node of the edge
     352              :      * @param[in] to The destination node of the edge
     353              :      * @param[in] passed The list of passed nodes (geometry information)
     354              :      * @param[in] osmNodes Container of node definitions for getting information about nodes from
     355              :      * @param[in, out] The NetBuilder instance
     356              :      * @param[in] first The first node of the way
     357              :      * @param[in] last The last node of the way
     358              :      * @return the new index if the edge is split
     359              :      * @exception ProcessError If the edge could not be added to the container
     360              :      */
     361              :     int insertEdge(Edge* e, int index, NBNode* from, NBNode* to,
     362              :                    const std::vector<long long int>& passed, NBNetBuilder& nb,
     363              :                    const NBNode* first, const NBNode* last);
     364              : 
     365              :     /// @brief reconstruct elevation from layer info
     366              :     void reconstructLayerElevation(double layerElevation, NBNetBuilder& nb);
     367              : 
     368              :     /// @brief collect neighboring nodes with their road distance and maximum between-speed. Search does not continue beyond knownElevation-nodes
     369              :     std::map<NBNode*, std::pair<double, double> >
     370              :     getNeighboringNodes(NBNode* node, double maxDist, const std::set<NBNode*>& knownElevation);
     371              : 
     372              :     /// @brief check whether the type is known or consists of known type compounds. return empty string otherwise
     373              :     std::string usableType(const std::string& type, const std::string& id, NBTypeCont& tc);
     374              : 
     375              :     /// @brief extend kilometrage data for all nodes along railway
     376              :     void extendRailwayDistances(Edge* e, NBTypeCont& tc);
     377              : 
     378              :     /// @brief read distance value from node and return value in m
     379              :     static double interpretDistance(NIOSMNode* node);
     380              : 
     381              : protected:
     382              :     static const double MAXSPEED_UNGIVEN;
     383              :     static const long long int INVALID_ID;
     384              : 
     385              :     static void applyChangeProhibition(NBEdge* e, int changeProhibition);
     386              :     /// Applies lane use information from `nie` to `e`. Uses the member values
     387              :     /// `myLaneAllowedForward`, `myLaneDisallowedForward` and `myLaneDesignatedForward`
     388              :     /// or the respective backward values to determine the ultimate lane uses.
     389              :     /// When a value of `e->myLaneDesignatedForward/Backward` is `true`, all permissions for the corresponding
     390              :     /// lane will be deleted before adding permissions from `e->myLaneAllowedForward/Backward`.
     391              :     /// SVCs from `e->myLaneAllowedForward/Backward` will be added to the existing permissions (for each lane).
     392              :     /// SVCs from `e->myLaneDisallowedForward/Backward` will be subtracted from the existing permissions.
     393              :     /// @brief Applies lane use information from `nie` to `e`.
     394              :     /// @param e The NBEdge that the new information will be written to.
     395              :     /// @param nie Ths Edge that the information comes from.
     396              :     void applyLaneUse(NBEdge* e, NIImporter_OpenStreetMap::Edge* nie, const bool forward);
     397              : 
     398              :     static void mergeTurnSigns(std::vector<int>& signs, std::vector<int> signs2);
     399              :     void applyTurnSigns(NBEdge* e, const std::vector<int>& turnSigns);
     400              : 
     401              :     /**
     402              :      * @class NodesHandler
     403              :      * @brief A class which extracts OSM-nodes from a parsed OSM-file
     404              :      */
     405              :     class NodesHandler : public SUMOSAXHandler {
     406              :     public:
     407              :         /** @brief Constructor
     408              :          * @param[in, out] toFill The nodes container to fill
     409              :          * @param[in, out] uniqueNodes The nodes container for ensuring uniqueness
     410              :          * @param[in] options The options to use
     411              :          */
     412              :         NodesHandler(std::map<long long int, NIOSMNode*>& toFill, std::set<NIOSMNode*,
     413              :                      CompareNodes>& uniqueNodes,
     414              :                      const OptionsCont& cont);
     415              : 
     416              : 
     417              :         /// @brief Destructor
     418              :         ~NodesHandler() override;
     419              : 
     420              :         int getDuplicateNodes() const {
     421          188 :             return myDuplicateNodes;
     422              :         }
     423              : 
     424              :         void resetHierarchy() {
     425          174 :             myHierarchyLevel = 0;
     426              :         }
     427              : 
     428              :     protected:
     429              :         /// @name inherited from GenericSAXHandler
     430              :         //@{
     431              : 
     432              :         /** @brief Called on the opening of a tag;
     433              :          *
     434              :          * @param[in] element ID of the currently opened element
     435              :          * @param[in] attrs Attributes within the currently opened element
     436              :          * @exception ProcessError If something fails
     437              :          * @see GenericSAXHandler::myStartElement
     438              :          */
     439              :         void myStartElement(int element, const SUMOSAXAttributes& attrs) override;
     440              : 
     441              : 
     442              :         /** @brief Called when a closing tag occurs
     443              :          *
     444              :          * @param[in] element ID of the currently opened element
     445              :          * @exception ProcessError If something fails
     446              :          * @see GenericSAXHandler::myEndElement
     447              :          */
     448              :         void myEndElement(int element) override;
     449              :         //@}
     450              : 
     451              : 
     452              :     private:
     453              :         /// @brief The nodes container to fill
     454              :         std::map<long long int, NIOSMNode*>& myToFill;
     455              : 
     456              :         /// @brief id of the currently parsed node
     457              :         std::string myLastNodeID;
     458              : 
     459              :         /// @brief the currently parsed node
     460              :         NIOSMNode* myCurrentNode;
     461              : 
     462              :         /// @brief The current hierarchy level
     463              :         int myHierarchyLevel;
     464              : 
     465              :         /// @brief the set of unique nodes (used for duplicate detection/substitution)
     466              :         std::set<NIOSMNode*, CompareNodes>& myUniqueNodes;
     467              : 
     468              :         /// @brief whether elevation data should be imported
     469              :         const bool myImportElevation;
     470              : 
     471              :         /// @brief custom requirements for rail signal tagging
     472              :         StringVector myRailSignalRules;
     473              : 
     474              :         /// @brief number of diplicate nodes
     475              :         int myDuplicateNodes;
     476              : 
     477              :         /// @brief the options
     478              :         const OptionsCont& myOptionsCont;
     479              : 
     480              :     private:
     481              :         /** @brief invalidated copy constructor */
     482              :         NodesHandler(const NodesHandler& s);
     483              : 
     484              :         /** @brief invalidated assignment operator */
     485              :         NodesHandler& operator=(const NodesHandler& s);
     486              : 
     487              :     };
     488              : 
     489              : 
     490              :     /**
     491              :      * @class EdgesHandler
     492              :      * @brief A class which extracts OSM-edges from a parsed OSM-file
     493              :      */
     494              :     class EdgesHandler : public SUMOSAXHandler {
     495              :     public:
     496              :         /** @brief Constructor
     497              :          *
     498              :          * @param[in] osmNodes The previously parsed (osm-)nodes
     499              :          * @param[in, out] toFill The edges container to fill with read edges
     500              :          */
     501              :         EdgesHandler(const std::map<long long int, NIOSMNode*>& osmNodes,
     502              :                      std::map<long long int, Edge*>& toFill, std::map<long long int, Edge*>& platformShapes);
     503              : 
     504              : 
     505              :         /// @brief Destructor
     506              :         ~EdgesHandler() override;
     507              : 
     508              : 
     509              :     protected:
     510              :         /// @name inherited from GenericSAXHandler
     511              :         //@{
     512              : 
     513              :         /** @brief Called on the opening of a tag;
     514              :          *
     515              :          * @param[in] element ID of the currently opened element
     516              :          * @param[in] attrs Attributes within the currently opened element
     517              :          * @exception ProcessError If something fails
     518              :          * @see GenericSAXHandler::myStartElement
     519              :          */
     520              :         void myStartElement(int element, const SUMOSAXAttributes& attrs) override;
     521              : 
     522              : 
     523              :         /** @brief Called when a closing tag occurs
     524              :          *
     525              :          * @param[in] element ID of the currently opened element
     526              :          * @exception ProcessError If something fails
     527              :          * @see GenericSAXHandler::myEndElement
     528              :          */
     529              :         void myEndElement(int element) override;
     530              :         //@}
     531              : 
     532              :         double interpretSpeed(const std::string& key, std::string value);
     533              : 
     534              :         int interpretChangeType(const std::string& value) const;
     535              : 
     536              :         void interpretLaneUse(const std::string& value, SUMOVehicleClass svc, const bool forward) const;
     537              : 
     538              : 
     539              :     private:
     540              :         /// @brief The previously parsed nodes
     541              :         const std::map<long long int, NIOSMNode*>& myOSMNodes;
     542              : 
     543              :         /// @brief A map of built edges
     544              :         std::map<long long int, Edge*>& myEdgeMap;
     545              : 
     546              :         /// @brief A map of built edges
     547              :         std::map<long long int, Edge*>& myPlatformShapesMap;
     548              : 
     549              :         /// @brief The currently built edge
     550              :         Edge* myCurrentEdge = nullptr;
     551              : 
     552              :         /// @brief A map of non-numeric speed descriptions to their numeric values
     553              :         std::map<std::string, double> mySpeedMap;
     554              : 
     555              :     private:
     556              :         /** @brief invalidated copy constructor */
     557              :         EdgesHandler(const EdgesHandler& s);
     558              : 
     559              :         /** @brief invalidated assignment operator */
     560              :         EdgesHandler& operator=(const EdgesHandler& s);
     561              : 
     562              :     };
     563              : 
     564              :     /**
     565              :      * @class RelationHandler
     566              :      * @brief A class which extracts relevant relation information from a parsed OSM-file
     567              :      *   - turn restrictions
     568              :      */
     569              :     class RelationHandler : public SUMOSAXHandler {
     570              :     public:
     571              :         /** @brief Constructor
     572              :          *
     573              :          * @param[in] osmNodes The previously parsed OSM-nodes
     574              :          * @param[in] osmEdges The previously parse OSM-edges
     575              :          */
     576              :         RelationHandler(const std::map<long long int, NIOSMNode*>& osmNodes,
     577              :                         const std::map<long long int, Edge*>& osmEdges, NBPTStopCont* nbptStopCont,
     578              :                         const std::map<long long int, Edge*>& platfromShapes, NBPTLineCont* nbptLineCont,
     579              :                         const OptionsCont& oc);
     580              : 
     581              : 
     582              :         /// @brief Destructor
     583              :         ~RelationHandler() override;
     584              : 
     585              :     protected:
     586              :         /// @name inherited from GenericSAXHandler
     587              :         //@{
     588              : 
     589              :         /** @brief Called on the opening of a tag;
     590              :          *
     591              :          * @param[in] element ID of the currently opened element
     592              :          * @param[in] attrs Attributes within the currently opened element
     593              :          * @exception ProcessError If something fails
     594              :          * @see GenericSAXHandler::myStartElement
     595              :          */
     596              :         void myStartElement(int element, const SUMOSAXAttributes& attrs) override;
     597              : 
     598              : 
     599              :         /** @brief Called when a closing tag occurs
     600              :          *
     601              :          * @param[in] element ID of the currently opened element
     602              :          * @exception ProcessError If something fails
     603              :          * @see GenericSAXHandler::myEndElement
     604              :          */
     605              :         void myEndElement(int element) override;
     606              :         //@}
     607              : 
     608              : 
     609              :     private:
     610              :         /// @brief The previously parsed nodes
     611              :         const std::map<long long int, NIOSMNode*>& myOSMNodes;
     612              : 
     613              :         /// @brief The previously parsed edges
     614              :         const std::map<long long int, Edge*>& myOSMEdges;
     615              : 
     616              :         /// @brief The previously parsed platform shapes
     617              :         const std::map<long long int, Edge*>& myPlatformShapes;
     618              : 
     619              :         /// @brief The previously filled pt stop container
     620              :         NBPTStopCont* myNBPTStopCont;
     621              : 
     622              :         /// @brief PT Line container to be filled
     623              :         NBPTLineCont* myNBPTLineCont;
     624              : 
     625              :         /// @brief The currently parsed relation
     626              :         long long int myCurrentRelation;
     627              : 
     628              :         /// @brief whether the currently parsed relation is a restriction
     629              :         bool myIsRestriction;
     630              : 
     631              :         /// @brief exceptions to the restriction currenlty being parsed
     632              :         SVCPermissions myRestrictionException;
     633              : 
     634              :         /// @brief the origination way for the current restriction
     635              :         long long int myFromWay;
     636              : 
     637              :         /// @brief the destination way for the current restriction
     638              :         long long int myToWay;
     639              : 
     640              :         /// @brief the via node/way for the current restriction
     641              :         long long int myViaNode;
     642              :         long long int myViaWay;
     643              : 
     644              : 
     645              :         /// @brief the options cont
     646              :         const OptionsCont& myOptionsCont;
     647              : 
     648              :         /** @enum RestrictionType
     649              :          * @brief whether the only allowed or the only forbidden connection is defined
     650              :          */
     651              :         enum class RestrictionType {
     652              :             /// @brief The only valid connection is declared
     653              :             ONLY,
     654              :             /// @brief The only invalid connection is declared
     655              :             NO,
     656              :             /// @brief The relation tag was missing
     657              :             UNKNOWN
     658              :         };
     659              :         RestrictionType myRestrictionType;
     660              : 
     661              :         /// @brief reset members to their defaults for parsing a new relation
     662              :         void resetValues();
     663              : 
     664              :         /// @brief check whether a referenced way has a corresponding edge
     665              :         bool checkEdgeRef(long long int ref) const;
     666              : 
     667              :         /// @brief try to apply the parsed restriction and return whether successful
     668              :         bool applyRestriction() const;
     669              : 
     670              :         /// @brief try to find the way segment among candidates
     671              :         NBEdge* findEdgeRef(long long int wayRef, const std::vector<NBEdge*>& candidates) const;
     672              : 
     673              :     private:
     674              :         /** @brief invalidated copy constructor */
     675              :         RelationHandler(const RelationHandler& s);
     676              : 
     677              :         /** @brief invalidated assignment operator */
     678              :         RelationHandler& operator=(const RelationHandler& s);
     679              : 
     680              :         /// @brief bus stop references
     681              :         std::vector<long long int> myStops;
     682              : 
     683              :         /// @brief myStops which are actually platforms (in case there is no stop_position)
     684              :         std::set<long long int> myPlatformStops;
     685              : 
     686              : 
     687              :         struct NIIPTPlatform {
     688              :             long long int ref;
     689              :             bool isWay;
     690              :         };
     691              : 
     692              :         /// @brief bus stop platforms
     693              :         std::vector<NIIPTPlatform> myPlatforms;
     694              : 
     695              :         /// @brief ways in pt line references
     696              :         std::vector<long long int> myWays;
     697              : 
     698              :         /// @brief indicates whether current relation is a pt stop area
     699              :         bool myIsStopArea;
     700              : 
     701              :         /// @brief indicates whether current relation is a route
     702              :         bool myIsRoute;
     703              : 
     704              :         /// @brief indicates whether current relation is a pt route
     705              :         std::string myPTRouteType;
     706              : 
     707              :         /// @brief official route color
     708              :         RGBColor myRouteColor;
     709              : 
     710              :         /// @brief name of the relation
     711              :         std::string myName;
     712              : 
     713              :         /// @brief ref of the pt line
     714              :         std::string myRef;
     715              : 
     716              :         /// @brief service interval of the pt line in minutes
     717              :         int myInterval;
     718              : 
     719              :         /// @brief night service information of the pt line
     720              :         std::string myNightService;
     721              : 
     722              :         /** @brief the map from stop area member to stop_area id */
     723              :         std::map<long long int, long long int > myStopAreas;
     724              : 
     725              :     };
     726              : 
     727              : };
        

Generated by: LCOV version 2.0-1