Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/shapes/ShapeHandler.h
169678 views
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 ShapeHandler.h
15
/// @author Jakob Erdmann
16
/// @date Feb 2015
17
///
18
// The XML-Handler for network loading
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <utils/common/RGBColor.h>
24
#include <utils/geom/Position.h>
25
#include <utils/xml/SUMOSAXHandler.h>
26
27
28
// ===========================================================================
29
// class declarations
30
// ===========================================================================
31
class ShapeContainer;
32
class Parameterised;
33
class GeoConvHelper;
34
35
36
// ===========================================================================
37
// class definitions
38
// ===========================================================================
39
/**
40
* @class ShapeHandler
41
* @brief The XML-Handler for network loading
42
*
43
* The SAX2-handler responsible for parsing networks and routes to load.
44
* This is an extension of the MSRouteHandler as routes and vehicles may also
45
* be loaded from network descriptions.
46
*/
47
class ShapeHandler : public SUMOSAXHandler {
48
public:
49
/** @brief Constructor
50
* @param[in] file Name of the parsed file
51
* @param[in, out] net The network to fill
52
* @param[in] detBuilder The detector builder to use
53
* @param[in] triggerBuilder The trigger builder to use
54
* @param[in] edgeBuilder The builder of edges to use
55
* @param[in] junctionBuilder The builder of junctions to use
56
*/
57
ShapeHandler(const std::string& file, ShapeContainer& sc, const GeoConvHelper* = nullptr);
58
59
/// @brief Destructor
60
virtual ~ShapeHandler();
61
62
/// @brief loads all of the given files
63
static bool loadFiles(const std::vector<std::string>& files, ShapeHandler& sh);
64
65
protected:
66
/// @name inherited from GenericSAXHandler
67
//@{
68
/** @brief Called on the opening of a tag;
69
*
70
* @param[in] element ID of the currently opened element
71
* @param[in] attrs Attributes within the currently opened element
72
* @exception ProcessError If something fails
73
* @see GenericSAXHandler::myStartElement
74
* @todo Refactor/describe
75
*/
76
virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);
77
78
/** @brief Called when a closing tag occurs
79
*
80
* @param[in] element ID of the currently opened element
81
* @exception ProcessError If something fails
82
* @see GenericSAXHandler::myEndElement
83
* @todo Refactor/describe
84
*/
85
virtual void myEndElement(int element);
86
//@}
87
88
/// @brief get position for a given laneID (Has to be implemented in all child)
89
virtual Position getLanePos(const std::string& poiID, const std::string& laneID, double lanePos, bool friendlyPos, double lanePosLat) = 0;
90
91
/// @brief Whether some input attributes shall be automatically added as params (Can be implemented in all child)
92
virtual bool addLanePosParams();
93
94
protected:
95
/// @brief set default values
96
void setDefaults(const std::string& prefix, const RGBColor& color, const std::string& icon, const double layer, const bool fill = false);
97
98
/// @brief adds a POI
99
void addPOI(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);
100
101
/// @brief adds a polygon
102
void addPoly(const SUMOSAXAttributes& attrs, const bool ignorePruning, const bool useProcessing);
103
104
/// @brief get last parameterised object
105
Parameterised* getLastParameterised() const;
106
107
protected:
108
/// @brief reference to shape container in which all Shares are being added
109
ShapeContainer& myShapeContainer;
110
111
/// @brief The prefix to use
112
std::string myPrefix;
113
114
/// @brief The default color to use
115
RGBColor myDefaultColor;
116
117
/// @brief The default icon to use
118
std::string myDefaultIcon;
119
120
/// @brief The default layer to use
121
double myDefaultLayer;
122
123
/// @brief Information whether polygons should be filled
124
bool myDefaultFill;
125
126
/// @brief element to receive parameters
127
Parameterised* myLastParameterised;
128
129
/// @brief geo-conversion to use during loading
130
const GeoConvHelper* myGeoConvHelper;
131
132
/// @brief invalidate copy constructor
133
ShapeHandler(const ShapeHandler& s) = delete;
134
135
/// @brief invalidate assignment operator
136
ShapeHandler& operator=(const ShapeHandler& s) = delete;
137
};
138
139