1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
10 /// @file    PCLoaderXML.h
11 /// @author  Daniel Krajzewicz
12 /// @author  Jakob Erdmann
13 /// @author  Michael Behrisch
14 /// @date    Thu, 02.11.2006
15 /// @version $Id$
16 ///
17 // A reader for polygons and pois stored in XML-format
18 /****************************************************************************/
19 #ifndef PCLoaderXML_h
20 #define PCLoaderXML_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include "PCPolyContainer.h"
30 #include "PCTypeMap.h"
31 #include <utils/shapes/ShapeHandler.h>
32 #include <utils/common/UtilExceptions.h>
33 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
38 class OptionsCont;
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 /**
45  * @class PCLoaderXML
46  * @brief A reader for polygons and pois stored in XML-format
47  *
48  * Reads pois stored as XML definition. The definitions must match
49  *  the format POLYCONVERT generates.
50  */
51 class PCLoaderXML : public ShapeHandler {
52 public:
53     /** @brief Loads pois/polygons assumed to be stored as XML
54      *
55      * If the option "xml" is set within the given options container,
56      *  an instance of PCLoaderXML is built and used as a handler for the
57      *  files given in this option.
58      *
59      * @param[in] oc The options container to get further options from
60      * @param[in] toFill The poly/pois container to add loaded polys/pois to
61      * @param[in] tm The type map to use for setting values of loaded polys/pois
62      * @exception ProcessError if something fails
63      */
64     static void loadIfSet(OptionsCont& oc, PCPolyContainer& toFill,
65                           PCTypeMap& tm);
66 
67 
68     Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, double lanePosLat);
69 
70 protected:
71     /** @brief Constructor
72      * @param[in] toFill The poly/pois container to add loaded polys/pois to
73      * @param[in] tm The type map to use for setting values of loaded polys/pois
74      * @param[in] oc The options container to get further options from
75      */
76     PCLoaderXML(PCPolyContainer& toFill,
77                 PCTypeMap& tm, OptionsCont& oc);
78 
79 
80     /// @brief Destructor
81     ~PCLoaderXML();
82 
83 
84 protected:
85     /// @name inherited from GenericSAXHandler
86     //@{
87 
88     /** @brief Called on the opening of a tag;
89      *
90      * @param[in] element ID of the currently opened element
91      * @param[in] attrs Attributes within the currently opened element
92      * @exception ProcessError If something fails
93      * @see GenericSAXHandler::myStartElement
94      */
95     virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);
96     //@}
97 
98 
99 private:
100     /// @brief The type map to use
101     PCTypeMap& myTypeMap;
102 
103     /// @brief Settings to use
104     OptionsCont& myOptions;
105 
106 };
107 
108 
109 #endif
110 
111 /****************************************************************************/
112 
113