Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netimport/NIImporter_DlrNavteq.h
169668 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2008-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_DlrNavteq.h
15
/// @author Daniel Krajzewicz
16
/// @author Michael Behrisch
17
/// @author Jakob Erdmann
18
/// @date Mon, 14.04.2008
19
///
20
// Importer for networks stored in Elmar's format
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <string>
26
#include <map>
27
#include <utils/common/UtilExceptions.h>
28
#include <utils/importio/LineHandler.h>
29
30
31
// ===========================================================================
32
// class declarations
33
// ===========================================================================
34
class NBEdgeCont;
35
class NBNetBuilder;
36
class NBNodeCont;
37
class NBTrafficLightLogicCont;
38
class NBTypeCont;
39
class OptionsCont;
40
class PositionVector;
41
class StringTokenizer;
42
43
44
// ===========================================================================
45
// class definitions
46
// ===========================================================================
47
/**
48
* @class NIImporter_DlrNavteq
49
* @brief Importer for networks stored in Elmar's format
50
*
51
*/
52
class NIImporter_DlrNavteq {
53
public:
54
/** @brief Loads content of the optionally given dlr-navteq (aka Elmar-fomat) folder
55
*
56
* If the option "dlr-navteq-prefix" is set, the file(s) stored therein is read and
57
* the network definition stored therein is stored within the given network
58
* builder.
59
*
60
* If the option "dlr-navteq-prefix" is not set, this method simply returns.
61
*
62
* @param[in] oc The options to use
63
* @param[in] nb The network builder to fill
64
*/
65
static void loadNetwork(const OptionsCont& oc, NBNetBuilder& nb);
66
67
/// @brief scaling factor for geo coordinates (DLRNavteq format uses this to increase floating point precisions)
68
static const std::string GEO_SCALE;
69
70
/// @brief decides whether the edge length of the input format should be used
71
static bool keepLength;
72
73
/// @brief magic value for undefined stuff
74
static const std::string UNDEFINED;
75
76
protected:
77
/**
78
* @class NodesHandler
79
* @brief Importer of nodes stored in unsplit elmar format
80
*
81
* Being a LineHandler, this class retrieves each line from a LineReader
82
* and parses these information assuming they contain node definitions
83
* in DLRNavteq's unsplit format.
84
*/
85
class NodesHandler : public LineHandler {
86
public:
87
/** @brief Constructor
88
* @param[in, filled] nc The node control to insert loaded nodes into
89
* @param[in] file The name of the parsed file
90
* @param[in, geoms] geoms Storage for read edge geometries
91
*/
92
NodesHandler(NBNodeCont& nc, const std::string& file,
93
std::map<std::string, PositionVector>& geoms);
94
95
96
/// @brief Destructor
97
~NodesHandler();
98
99
100
/** @brief Parsing method
101
*
102
* Implementation of the LineHandler-interface called by a LineReader;
103
* interprets the retrieved information and stores it into "myNodeCont".
104
* Additionally, edge geometries are parsed and stored into "myGeoms".
105
*
106
* @param[in] result The read line
107
* @return Whether the parsing shall continue
108
* @exception ProcessError if something fails
109
* @see LineHandler::report
110
*/
111
bool report(const std::string& result);
112
113
114
protected:
115
// @brief The node container to store parsed nodes into
116
NBNodeCont& myNodeCont;
117
118
/// @brief A container for parsed geometries
119
std::map<std::string, PositionVector>& myGeoms;
120
121
122
private:
123
/// @brief Invalidated copy constructor.
124
NodesHandler(const NodesHandler&);
125
126
/// @brief Invalidated assignment operator.
127
NodesHandler& operator=(const NodesHandler&);
128
129
};
130
131
132
/**
133
* @class EdgesHandler
134
* @brief Importer of edges stored in unsplit elmar format
135
*
136
* Being a LineHandler, this class retrieves each line from a LineReader
137
* and parses these information assuming they contain edge definitions
138
* in DLRNavteq's unsplit format.
139
*/
140
class EdgesHandler : public LineHandler {
141
142
public:
143
/** @brief Constructor
144
* @param[in] nc The node control to retrieve nodes from
145
* @param[in, filled] ec The edge control to insert loaded edges into
146
* @param[in] tc The type control to retrieve types from
147
* @param[in] file The name of the parsed file
148
* @param[in] geoms The previously read edge geometries
149
* @param[in] streetNames The previously read street names
150
*/
151
EdgesHandler(NBNodeCont& nc, NBEdgeCont& ec, NBTypeCont& tc,
152
const std::string& file,
153
std::map<std::string, PositionVector>& geoms,
154
std::map<std::string, std::string>& streetNames);
155
156
157
/// @brief Destructor
158
~EdgesHandler();
159
160
161
/** @brief Parsing method
162
*
163
* Implementation of the LineHandler-interface called by a LineReader;
164
* interprets the retrieved information and stores it into "myEdgeCont".
165
* @param[in] result The read line
166
* @return Whether the parsing shall continue
167
* @exception ProcessError if something fails
168
* @see LineHandler::report
169
*/
170
bool report(const std::string& result);
171
172
173
protected:
174
/// @brief The node container to get the referenced nodes from
175
NBNodeCont& myNodeCont;
176
177
/// @brief The edge container to store loaded edges into
178
NBEdgeCont& myEdgeCont;
179
180
/// @brief The type container to retrieve type info from
181
NBTypeCont& myTypeCont;
182
183
/// @brief Previously read edge geometries (manipulated during use)
184
std::map<std::string, PositionVector>& myGeoms;
185
186
/// @brief Previously read streat names (non-const because operate[] is more convenient)
187
std::map<std::string, std::string>& myStreetNames;
188
189
/// @brief Whether node positions shall not be added to the edge's geometry
190
bool myTryIgnoreNodePositions;
191
192
/// @brief version number of current file
193
double myVersion;
194
195
/// @brief the version number of the edge file being parsed
196
std::vector<int> myColumns;
197
198
/// @brief the file being parsed
199
const std::string myFile;
200
201
static const int MISSING_COLUMN;
202
203
enum ColumnName {
204
LINK_ID = 0,
205
NODE_ID_FROM,
206
NODE_ID_TO,
207
BETWEEN_NODE_ID,
208
LENGTH,
209
VEHICLE_TYPE,
210
FORM_OF_WAY,
211
BRUNNEL_TYPE,
212
FUNCTIONAL_ROAD_CLASS,
213
SPEED_CATEGORY,
214
NUMBER_OF_LANES,
215
SPEED_LIMIT,
216
SPEED_RESTRICTION,
217
NAME_ID1_REGIONAL,
218
NAME_ID2_LOCAL,
219
HOUSENUMBERS_RIGHT,
220
HOUSENUMBERS_LEFT,
221
ZIP_CODE,
222
AREA_ID,
223
SUBAREA_ID,
224
THROUGH_TRAFFIC,
225
SPECIAL_RESTRICTIONS,
226
EXTENDED_NUMBER_OF_LANES,
227
ISRAMP,
228
CONNECTION
229
};
230
231
std::string getColumn(const StringTokenizer& st, ColumnName name, const std::string fallback = "");
232
233
private:
234
/// @brief build the street name for the given ids
235
std::string getStreetNameFromIDs(const std::string& regionalID, const std::string& localID) const;
236
237
238
private:
239
/// @brief Invalidated copy constructor.
240
EdgesHandler(const EdgesHandler&);
241
242
/// @brief Invalidated assignment operator.
243
EdgesHandler& operator=(const EdgesHandler&);
244
245
};
246
247
248
/**
249
* @class TrafficlightsHandler
250
* @brief Importer of traffic lights stored in DLRNavteq's (aka elmar) format
251
*
252
* Being a LineHandler, this class retrieves each line from a LineReader
253
* and parses these information assuming they contain traffic light definitions
254
* in DLRNavteq's format.
255
*/
256
class TrafficlightsHandler : public LineHandler {
257
public:
258
/** @brief Constructor
259
* @param[in] nc The node control to retrieve nodes from
260
* @param[in, filled] tlc The traffic lights container to fill
261
* @param[in] file The name of the parsed file
262
*/
263
TrafficlightsHandler(NBNodeCont& nc, NBTrafficLightLogicCont& tlc,
264
NBEdgeCont& ne, const std::string& file);
265
266
267
/// @brief Destructor
268
~TrafficlightsHandler();
269
270
271
/** @brief Parsing method
272
*
273
* Implementation of the LineHandler-interface called by a LineReader;
274
* interprets the retrieved information and alters the nodes.
275
* @param[in] result The read line
276
* @return Whether the parsing shall continue
277
* @exception ProcessError if something fails
278
* @see LineHandler::report
279
*/
280
bool report(const std::string& result);
281
282
283
protected:
284
/// @brief The node container to get the referenced nodes from
285
NBNodeCont& myNodeCont;
286
287
/// @brief The traffic lights container to add built tls to
288
NBTrafficLightLogicCont& myTLLogicCont;
289
290
/// @brief The edge container to get the referenced edges from
291
NBEdgeCont& myEdgeCont;
292
293
294
private:
295
/// @brief Invalidated copy constructor.
296
TrafficlightsHandler(const TrafficlightsHandler&);
297
298
/// @brief Invalidated assignment operator.
299
TrafficlightsHandler& operator=(const TrafficlightsHandler&);
300
301
};
302
303
304
/**
305
* @class NamesHandler
306
* @brief Importer of street names in DLRNavteq's (aka elmar) format
307
*
308
* Being a LineHandler, this class retrieves each line from a LineReader
309
* and parses these information assuming they contain name definitions
310
* in DLRNavteq's format.
311
*/
312
class NamesHandler : public LineHandler {
313
public:
314
/** @brief Constructor
315
* @param[in] file The name of the parsed file
316
* @param[filled] streetNames output container for read names
317
*/
318
NamesHandler(const std::string& file, std::map<std::string, std::string>& streetNames);
319
320
321
/// @brief Destructor
322
~NamesHandler();
323
324
325
/** @brief Parsing method
326
*
327
* Implementation of the LineHandler-interface called by a LineReader;
328
* interprets the retrieved information and stores the streetNames
329
* @param[in] result The read line
330
* @return Whether the parsing shall continue
331
* @exception ProcessError if something fails
332
* @see LineHandler::report
333
*/
334
bool report(const std::string& result);
335
336
337
protected:
338
/// @brief The container for storing read names
339
std::map<std::string, std::string>& myStreetNames;
340
341
342
private:
343
/// @brief Invalidated copy constructor.
344
NamesHandler(const NamesHandler&);
345
346
/// @brief Invalidated assignment operator.
347
NamesHandler& operator=(const NamesHandler&);
348
349
};
350
351
352
/**
353
* @class TimeRestrictionsHandler
354
* @brief Importer of street names in DLRNavteq's (aka elmar) format
355
*
356
* Being a LineHandler, this class retrieves each line from a LineReader
357
* and parses these information assuming they contain name definitions
358
* in DLRNavteq's format.
359
*/
360
class TimeRestrictionsHandler : public LineHandler {
361
public:
362
/** @brief Constructor
363
* @param[in] file The name of the parsed file
364
* @param[filled] streetNames output container for read names
365
*/
366
TimeRestrictionsHandler(NBEdgeCont& ec, NBDistrictCont& dc, time_t constructionTime);
367
368
369
/// @brief Destructor
370
~TimeRestrictionsHandler();
371
372
373
/** @brief Parsing method
374
*
375
* Implementation of the LineHandler-interface called by a LineReader;
376
* interprets the retrieved information and stores the streetNames
377
* @param[in] result The read line
378
* @return Whether the parsing shall continue
379
* @exception ProcessError if something fails
380
* @see LineHandler::report
381
*/
382
bool report(const std::string& result);
383
384
void printSummary();
385
386
387
protected:
388
/// @brief The edge container
389
NBEdgeCont& myEdgeCont;
390
NBDistrictCont& myDistrictCont;
391
392
/// @brief The date for which to build the network (in case some edges are still under construction)
393
time_t myConstructionTime;
394
time_t myCS_min;
395
time_t myCS_max;
396
int myConstructionEntries;
397
int myNotStarted;
398
int myUnderConstruction;
399
int myFinished;
400
int myRemovedEdges; // only counts those not already removed through other options
401
402
403
private:
404
/// @brief Invalidated copy constructor.
405
TimeRestrictionsHandler(const TimeRestrictionsHandler&);
406
407
/// @brief Invalidated assignment operator.
408
TimeRestrictionsHandler& operator=(const TimeRestrictionsHandler&);
409
410
};
411
412
413
/**
414
* @class ProhibitionHandler
415
* @brief Imports prohibitions regarding connectivity
416
*
417
* Being a LineHandler, this class retrieves each line from a LineReader
418
* and parses these information assuming they contain prohibited manoeuver definitions
419
* in DLRNavteq's format.
420
*/
421
class ProhibitionHandler : public LineHandler {
422
public:
423
/** @brief Constructor
424
* @param[in] file The name of the parsed file
425
* @param[filled] streetNames output container for read names
426
*/
427
ProhibitionHandler(NBEdgeCont& ne, const std::string& file, time_t constructionTime);
428
429
430
/// @brief Destructor
431
~ProhibitionHandler();
432
433
434
/** @brief Parsing method
435
*
436
* Implementation of the LineHandler-interface called by a LineReader;
437
* interprets the retrieved information and stores the streetNames
438
* @param[in] result The read line
439
* @return Whether the parsing shall continue
440
* @exception ProcessError if something fails
441
* @see LineHandler::report
442
*/
443
bool report(const std::string& result);
444
445
446
protected:
447
/// @brief The edge container to store loaded edges into
448
NBEdgeCont& myEdgeCont;
449
const std::string myFile;
450
double myVersion;
451
time_t myConstructionTime;
452
453
454
private:
455
/// @brief Invalidated copy constructor.
456
ProhibitionHandler(const ProhibitionHandler&);
457
458
/// @brief Invalidated assignment operator.
459
ProhibitionHandler& operator=(const ProhibitionHandler&);
460
461
};
462
463
464
/**
465
* @class ConnectedLanesHandler
466
* @brief Imports prohibitions regarding connectivity
467
*
468
* Being a LineHandler, this class retrieves each line from a LineReader
469
* and parses these information assuming they contain prohibited manoeuver definitions
470
* in DLRNavteq's format.
471
*/
472
class ConnectedLanesHandler : public LineHandler {
473
public:
474
/** @brief Constructor
475
* @param[in] file The name of the parsed file
476
* @param[filled] streetNames output container for read names
477
*/
478
ConnectedLanesHandler(NBEdgeCont& ne);
479
480
481
/// @brief Destructor
482
~ConnectedLanesHandler();
483
484
485
/** @brief Parsing method
486
*
487
* Implementation of the LineHandler-interface called by a LineReader;
488
* interprets the retrieved information and stores the streetNames
489
* @param[in] result The read line
490
* @return Whether the parsing shall continue
491
* @exception ProcessError if something fails
492
* @see LineHandler::report
493
*/
494
bool report(const std::string& result);
495
496
497
protected:
498
/// @brief The edge container to store loaded edges into
499
NBEdgeCont& myEdgeCont;
500
501
502
private:
503
/// @brief Invalidated copy constructor.
504
ConnectedLanesHandler(const ConnectedLanesHandler&);
505
506
/// @brief Invalidated assignment operator.
507
ConnectedLanesHandler& operator=(const ConnectedLanesHandler&);
508
509
};
510
511
512
static double readVersion(const std::string& line, const std::string& file);
513
static int readPrefixedInt(const std::string& s, const std::string& prefix, int fallBack = 0);
514
static time_t readTimeRec(const std::string& start, const std::string& duration);
515
static time_t readDate(const std::string& yyyymmdd);
516
517
};
518
519