Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netimport/NIImporter_ArcView.h
169666 views
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
/****************************************************************************/
14
/// @file NIImporter_ArcView.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @author Jakob Erdmann
18
/// @date Sept 2002
19
///
20
// Importer for networks stored in ArcView-shape format
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <string>
26
27
28
// ===========================================================================
29
// class declarations
30
// ===========================================================================
31
class OptionsCont;
32
class OGRFeature;
33
34
35
// ===========================================================================
36
// class definitions
37
// ===========================================================================
38
/**
39
* @class NIImporter_ArcView
40
* @brief Importer for networks stored in ArcView-shape format
41
*
42
* The current importer works only if SUMO was compiled with GDAL-support.
43
* If not, an error message is generated.
44
*
45
* @todo reinsert import via shapelib
46
*/
47
class NIImporter_ArcView {
48
public:
49
/** @brief Loads content of the optionally given ArcView Shape files
50
*
51
* If the option "shapefile-prefix" is set, the file stored therein is read and
52
* the network definition stored therein is stored within the given network
53
* builder.
54
*
55
* If the option "shapefile-prefix" is not set, this method simply returns.
56
*
57
* @param[in] oc The options to use
58
* @param[in] nb The network builder to fill
59
*/
60
static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
61
62
63
protected:
64
/** @brief Constructor
65
* @param[in] oc Options container to read options from
66
* @param[in] nc The node container to store nodes into
67
* @param[in] ec The edge container to store edges into
68
* @param[in] tc The type container to get edge types from
69
* @param[in] shp_name The name of the according shape file
70
* @param[in] speedInKMH Whether the speed shall be assumed to be given in km/h
71
*/
72
NIImporter_ArcView(const OptionsCont& oc,
73
NBNodeCont& nc, NBEdgeCont& ec, NBTypeCont& tc,
74
const std::string& shp_name,
75
bool speedInKMH);
76
77
/// @brief Destructor
78
~NIImporter_ArcView();
79
80
81
/** @brief Loads the shape files
82
*/
83
void load();
84
85
86
private:
87
#ifdef HAVE_GDAL
88
/** @brief Parses the maximum speed allowed on the edge currently processed
89
* @param[in] f The entry to read the speed from
90
* @param[in] edgeid The id of the edge for error output
91
*/
92
double getSpeed(OGRFeature& f, const std::string& edgeid);
93
94
/** @brief Parses the width off the edge currently processed
95
* @param[in] f The entry to read the swidth from
96
* @param[in] edgeid The id of the edge for error output
97
*/
98
double getLaneWidth(OGRFeature& f, const std::string& edgeid, int laneNumber);
99
100
/** @brief Parses a custom length for the edge currently processed
101
* @param[in] f The entry to read the length from
102
* @param[in] edgeid The id of the edge for error output
103
*/
104
double getLength(OGRFeature& f, const std::string& edgeid);
105
106
/** @brief Parses the number of lanes of the edge currently processed
107
* @param[in] f The entry to read the lane number from
108
* @param[in] edgeid The id of the edge for error output
109
* @param[in] speed The edge's speed used to help determinig the edge's lane number
110
*/
111
int getLaneNo(OGRFeature& f,
112
const std::string& edgeid, double speed);
113
114
/** @brief Parses the priority of the edge currently processed
115
* @param[in] f The entry to read the priority from
116
* @param[in] edgeid The id of the edge for error output
117
*/
118
int getPriority(OGRFeature& f, const std::string& edgeid);
119
120
121
/** @brief Checks whether the lane spread shall be changed
122
*
123
* If for the given edge an edge into the vice direction is already
124
* stored, both edges' lane spread functions are set to LaneSpreadFunction::RIGHT.
125
*
126
* @param[in] e The edge to check
127
*/
128
void checkSpread(NBEdge* e);
129
130
131
/** @brief Sets the value from the named field into "into"
132
*
133
* If the field's name was set on the command line, the value is tried to be retrieved, returning true on success.
134
* If it cannot be retrieved, false is retuned, and the field's name is inserted into "into".
135
*
136
* If no field name was given, the standard value (defaultName) is used. In this case, an empty string is returned
137
* if the field does not exist.
138
* @param[in] poFeature The feature to read from
139
* @param[in] optionName The name of the option at which an optional field name is stored
140
* @param[in] defaultName The field's default name
141
* @param[in] prune Whether the value shall be prunned
142
* @param[out] into The read value/missing field is stored here
143
*/
144
bool getStringEntry(OGRFeature* poFeature, const std::string& optionName, const char* defaultName, bool prune, std::string& into);
145
146
/// @brief return all fields support by the given feature
147
std::vector<std::string> getFieldNames(OGRFeature* poFeature) const;
148
149
/// @brief add list of parameters to edge
150
void addParams(NBEdge* edge, OGRFeature* poFeature, const std::vector<std::string>& params) const;
151
152
#endif
153
154
private:
155
/// @brief The options to use
156
const OptionsCont& myOptions;
157
158
/// @brief The name of the shape file
159
std::string mySHPName;
160
161
/// @brief A running number to assure unique edge ids
162
int myNameAddition;
163
164
/// @brief The container to add nodes to
165
NBNodeCont& myNodeCont;
166
167
/// @brief The container to add edges to
168
NBEdgeCont& myEdgeCont;
169
170
/// @brief The container to get the types from
171
NBTypeCont& myTypeCont;
172
173
/// @brief Whether the speed is given in km/h
174
bool mySpeedInKMH;
175
176
/// @brief A running number to assure unique ids (as fallback)
177
int myRunningEdgeID;
178
int myRunningNodeID;
179
180
181
private:
182
/// @brief Invalidated copy constructor.
183
NIImporter_ArcView(const NIImporter_ArcView&);
184
185
/// @brief Invalidated assignment operator.
186
NIImporter_ArcView& operator=(const NIImporter_ArcView&);
187
188
};
189
190