66 if (!oc.
isSet(
"dlr-navteq-prefix")) {
75 std::map<std::string, PositionVector> myGeoms;
77 std::string file = oc.
getString(
"dlr-navteq-prefix") +
"_nodes_unsplitted.txt";
80 throw ProcessError(
"The file '" + file +
"' could not be opened.");
86 std::map<std::string, std::string> streetNames;
87 if (oc.
getBool(
"output.street-names")) {
88 file = oc.
getString(
"dlr-navteq-prefix") +
"_names.txt";
95 WRITE_WARNING(
"Output will not contain street names because the file '" + file +
"' was not found");
101 file = oc.
getString(
"dlr-navteq-prefix") +
"_links_unsplitted.txt";
105 throw ProcessError(
"The file '" + file +
"' could not be opened.");
112 file = oc.
getString(
"dlr-navteq-prefix") +
"_traffic_signals.txt";
121 file = oc.
getString(
"dlr-navteq-prefix") +
"_prohibited_manoeuvres.txt";
130 file = oc.
getString(
"dlr-navteq-prefix") +
"_connected_lanes.txt";
139 file = oc.
getString(
"dlr-navteq-prefix") +
"_links_timerestrictions.txt";
142 if (!oc.
isDefault(
"construction-date")) {
155 assert(line[0] ==
'#');
156 const std::string marker =
"extraction version: v";
158 if (lowerCase.find(marker) == std::string::npos) {
161 const int vStart = (int)(lowerCase.find(marker) + marker.size());
162 const int vEnd = (int)line.find(
" ", vStart);
166 throw ProcessError(
"Invalid version number '" +
toString(version) +
"' in file '" + file +
"'.");
170 throw ProcessError(
"Non-numerical value '" + line.substr(vStart, vEnd - vStart) +
"' for version string in file '" + file +
"'.");
179 const std::string& file,
180 std::map<std::string, PositionVector>& geoms)
181 : myNodeCont(nc), myGeoms(geoms) {
191 if (result[0] ==
'#') {
196 int no_geoms, intermediate;
198 std::istringstream stream(result);
202 throw ProcessError(
"Something is wrong with the following data line\n" + result);
205 stream >> intermediate;
207 if (myNodeCont.size() == 0) {
210 throw ProcessError(
"Non-numerical value for intermediate status in node " +
id +
".");
215 throw ProcessError(
"Non-numerical value for number of geometries in node " +
id +
".");
219 for (
int i = 0; i < no_geoms; i++) {
222 throw ProcessError(
"Non-numerical value for x-position in node " +
id +
".");
226 throw ProcessError(
"Non-numerical value for y-position in node " +
id +
".");
230 throw ProcessError(
"Unable to project coordinates for node " +
id +
".");
232 geoms.push_back(pos);
235 if (intermediate == 0) {
237 if (!myNodeCont.insert(n)) {
253 std::map<std::string, PositionVector>& geoms,
254 std::map<std::string, std::string>& streetNames):
259 myStreetNames(streetNames),
271 if (result[0] ==
'#') {
272 if (!myColumns.empty()) {
275 const double version =
readVersion(result, myFile);
279 const int NUM_COLUMNS = 25;
280 const int MC = MISSING_COLUMN;
282 const int columns[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, MC, 12, 13, 14, 15, 16, 17, 18, 19, 20, MC, MC, -21};
283 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
284 }
else if (myVersion < 6) {
285 const int columns[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, MC, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, -23};
286 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
288 const int columns[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
289 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
294 if (myColumns.empty()) {
295 throw ProcessError(
"Missing version string in file '" + myFile +
"'.");
299 const std::string
id = getColumn(st, LINK_ID);
305 throw ProcessError(
"Non-numerical value for form_of_way of link '" +
id +
"'.");
312 throw ProcessError(
"Non-numerical value for brunnel_type of link '" +
id +
"'.");
319 if (form_of_way == 11) {
321 }
else if (form_of_way > 11) {
325 throw ProcessError(
"Non-numerical value for street_type of link '" +
id +
"').");
328 std::string streetName = getStreetNameFromIDs(
329 getColumn(st, NAME_ID1_REGIONAL),
330 getColumn(st, NAME_ID2_LOCAL));
332 const std::string fromID = getColumn(st, NODE_ID_FROM);
333 const std::string toID = getColumn(st, NODE_ID_TO);
334 NBNode* from = myNodeCont.retrieve(fromID);
335 NBNode* to = myNodeCont.retrieve(toID);
336 if (from ==
nullptr) {
337 throw ProcessError(
"The from-node '" + fromID +
"' of link '" +
id +
"' could not be found");
340 throw ProcessError(
"The to-node '" + toID +
"' of link '" +
id +
"' could not be found");
347 throw ProcessError(
"Non-numerical value for the SPEED_RESTRICTION of link '" +
id +
"'.");
358 if (numLanes == -1) {
362 throw ProcessError(
"Non-numerical value for the number of lanes of link '" +
id +
"'.");
365 const std::string navTeqTypeId = getColumn(st, VEHICLE_TYPE) +
"_" + getColumn(st, FORM_OF_WAY);
368 const std::string interID = getColumn(st, BETWEEN_NODE_ID);
369 if (interID ==
"-1") {
370 e =
new NBEdge(
id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId :
"", speed, numLanes, priority,
380 e =
new NBEdge(
id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId :
"", speed, numLanes, priority,
391 if (myTypeCont.knows(navTeqTypeId)) {
392 e->
setPermissions(myTypeCont.getEdgeTypePermissions(navTeqTypeId));
395 const SVCPermissions allPermissions = myTypeCont.getEdgeTypePermissions(
"");
397 if (myVersion < 6.0) {
403 if (form_of_way == 14) {
408 if (brunnel_type == 10) {
414 if (!myEdgeCont.insert(e)) {
424 assert(!myColumns.empty());
425 if (myColumns[name] == MISSING_COLUMN) {
426 if (fallback ==
"") {
431 }
else if (myColumns[name] >= 0) {
432 return st.
get((
int)(myColumns[name]));
435 if ((
int) st.
size() <= -myColumns[name]) {
437 if (fallback ==
"") {
443 return st.
get((
int)(-myColumns[name]));
451 const std::string& regionalID,
const std::string& localID)
const {
452 std::string result =
"";
453 bool hadRegional =
false;
454 if (myStreetNames.count(regionalID) > 0) {
456 result += myStreetNames[regionalID];
458 if (myStreetNames.count(localID) > 0) {
462 result += myStreetNames[localID];
473 const std::string& file) :
488 if (result[0] ==
'#') {
492 const std::string edgeID = st.
get(5);
493 NBEdge* edge = myEdgeCont.retrieve(edgeID);
494 if (edge ==
nullptr) {
495 WRITE_WARNINGF(
"The traffic light edge '%' could not be found.", edgeID);
504 if (!myTLLogicCont.insert(tlDef)) {
519 const std::string& file, std::map<std::string, std::string>& streetNames) :
520 myStreetNames(streetNames) {
531 if (result[0] ==
'#') {
535 if (st.
size() == 1) {
538 assert(st.
size() >= 2);
539 const std::string
id = st.
next();
541 const std::string permanent_id_info = st.
next();
543 myStreetNames[id] = st.
next();
554 myConstructionTime(constructionTime),
555 myCS_min(std::numeric_limits<time_t>::max()),
556 myCS_max(std::numeric_limits<time_t>::min()),
557 myConstructionEntries(0),
559 myUnderConstruction(0),
571 if (result[0] ==
'#') {
575 const std::string
id = st.
next();
576 const std::string type = st.
next();
577 const std::string directionOfFlow = st.
next();
578 const std::string throughTraffic = st.
next();
579 const std::string vehicleType = st.
next();
580 const std::string validityPeriod = st.
next();
581 const std::string warning =
"Unrecognized TIME_REC '" + validityPeriod +
"'";
583 myConstructionEntries++;
584 if (validityPeriod.size() > 1024) {
593 matched = sscanf(validityPeriod.c_str(),
"[(%[^)]){%[^}]}]", start, duration);
597 myCS_min =
MIN2(myCS_min, tStart);
598 myCS_max =
MAX2(myCS_max, tEnd);
601 if (myConstructionTime < tEnd) {
602 NBEdge* edge = myEdgeCont.retrieve(
id);
603 if (edge !=
nullptr) {
605 myEdgeCont.extract(myDistrictCont, edge,
true);
607 if (myConstructionTime < tStart) {
610 myUnderConstruction++;
625 if (myConstructionEntries > 0) {
627 std::ostringstream msg;
628 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myCS_min));
629 msg <<
"Parsed " << myConstructionEntries <<
" construction entries between " << buff;
630 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myCS_max));
631 msg <<
" and " << buff <<
".\n";
632 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myConstructionTime));
633 msg <<
"Removed " << myRemovedEdges <<
" edges not yet constructed at " << buff <<
".\n";
634 msg <<
" not yet started: " << myNotStarted <<
"\n";
635 msg <<
" under construction: " << myUnderConstruction <<
"\n";
636 msg <<
" finished: " << myFinished <<
"\n";
644 int result = fallBack;
645 size_t pos = s.find(prefix);
646 if (pos != std::string::npos) {
647 sscanf(s.substr(pos).c_str(), (prefix +
"%i").c_str(), &result);
656 timeinfo.tm_hour = 0;
659 timeinfo.tm_year = 0;
661 timeinfo.tm_mday = 1;
662 timeinfo.tm_wday = 0;
663 timeinfo.tm_yday = 0;
664 timeinfo.tm_isdst = 0;
671 time_t result = mktime(&timeinfo);
679 timeinfo.tm_hour = 0;
682 timeinfo.tm_wday = 0;
683 timeinfo.tm_yday = 0;
684 timeinfo.tm_isdst = 0;
686 if (yyyymmdd.size() == 10
687 && yyyymmdd[4] ==
'-'
688 && yyyymmdd[7] ==
'-') {
693 return mktime(&timeinfo);
697 WRITE_ERROR(
"Could not parse YYYY-MM-DD date '" + yyyymmdd +
"'");
707 NBEdgeCont& ec,
const std::string& file, time_t constructionTime) :
711 myConstructionTime(constructionTime) {
721 if (result[0] ==
'#') {
722 if (myVersion == 0) {
723 const double version =
readVersion(result, myFile);
731 if (st.
size() == 1) {
734 if (myVersion >= 6) {
735 assert(st.
size() >= 7);
736 const std::string
id = st.
next();
737 const std::string permanent = st.
next();
738 const std::string validityPeriod = st.
next();
739 const std::string throughTraffic = st.
next();
740 const std::string vehicleType = st.
next();
742 WRITE_WARNINGF(
"Ignoring temporary prohibited manoeuvre (%).", validityPeriod);
746 const std::string startEdge = st.
next();
747 const std::string endEdge = st.
get(st.
size() - 1);
749 NBEdge* from = myEdgeCont.retrieve(startEdge);
750 if (from ==
nullptr) {
751 WRITE_WARNINGF(
"Ignoring prohibition from unknown start edge '%'.", startEdge);
754 NBEdge* to = myEdgeCont.retrieve(endEdge);
756 WRITE_WARNINGF(
"Ignoring prohibition from unknown end edge '%'.", endEdge);
778 if (result[0] ==
'#') {
782 if (st.
size() == 1) {
785 assert(st.
size() >= 7);
786 const std::string nodeID = st.
next();
787 const std::string vehicleType = st.
next();
788 const std::string fromLaneS = st.
next();
789 const std::string toLaneS = st.
next();
790 const std::string throughTraffic = st.
next();
791 const std::string startEdge = st.
next();
792 const std::string endEdge = st.
get(st.
size() - 1);
794 NBEdge* from = myEdgeCont.retrieve(startEdge);
795 if (from ==
nullptr) {
796 WRITE_WARNINGF(
"Ignoring prohibition from unknown start edge '%'.", startEdge);
799 NBEdge* to = myEdgeCont.retrieve(endEdge);
801 WRITE_WARNINGF(
"Ignoring prohibition from unknown end edge '%'.", endEdge);
805 if (fromLane < 0 || fromLane >= from->
getNumLanes()) {
806 WRITE_WARNINGF(
"Ignoring invalid lane index '%' in connection from edge '%' with % lanes.", fromLaneS, startEdge, from->
getNumLanes());
811 WRITE_WARNINGF(
"Ignoring invalid lane index '%' in connection to edge '%' with % lanes", toLaneS, endEdge, to->
getNumLanes());
820 const bool warnOnly = st.
size() > 7;
#define WRITE_WARNINGF(...)
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
@ SVC_SHIP
is an arbitrary ship
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
#define UNUSED_PARAMETER(x)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Retrieves a file linewise and reports the lines to a handler.
bool setFile(const std::string &file)
Reinitialises the reader for reading from the given file.
void readAll(LineHandler &lh)
Reads the whole file linewise, reporting every line to the given LineHandler.
A container for districts.
Storage for edges, including some functionality operating on multiple edges.
void recheckLaneSpread()
Rechecks whether the lane spread is proper.
The representation of a single edge during network building.
void setPermissions(SVCPermissions permissions, int lane=-1)
set allowed/disallowed classes for the given lane or for all lanes if -1 is given
void disallowVehicleClass(int lane, SUMOVehicleClass vclass)
set disallowed class for the given lane or for all lanes if -1 is given
const std::string & getID() const
NBNode * getToNode() const
Returns the destination node of the edge.
@ INIT
The edge has been loaded, nothing is computed yet.
static const double UNSPECIFIED_LOADED_LENGTH
no length override given
int getNumLanes() const
Returns the number of lanes.
static const double UNSPECIFIED_CONTPOS
unspecified internal junction position
void removeFromConnections(NBEdge *toEdge, int fromLane=-1, int toLane=-1, bool tryLater=false, const bool adaptToLaneRemoval=false, const bool keepPossibleTurns=false)
Removes the specified connection(s)
static const double UNSPECIFIED_VISIBILITY_DISTANCE
unspecified foe visibility for connections
std::string getLaneID(int lane) const
get lane ID
static const double UNSPECIFIED_SPEED
unspecified lane speed
@ USER
The connection was given by the user.
static const double UNSPECIFIED_WIDTH
unspecified lane width
void declareConnectionsAsLoaded(EdgeBuildingStep step=EdgeBuildingStep::LANES2LANES_USER)
declares connections as fully loaded. This is needed to avoid recomputing connections if an edge has ...
static const double UNSPECIFIED_OFFSET
unspecified lane offset
bool addLane2LaneConnection(int fromLane, NBEdge *dest, int toLane, Lane2LaneInfoType type, bool mayUseSameDestination=false, bool mayDefinitelyPass=false, KeepClear keepClear=KEEPCLEAR_UNSPECIFIED, double contPos=UNSPECIFIED_CONTPOS, double visibility=UNSPECIFIED_VISIBILITY_DISTANCE, double speed=UNSPECIFIED_SPEED, double length=myDefaultConnectionLength, const PositionVector &customShape=PositionVector::EMPTY, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED, SVCPermissions=SVC_UNSPECIFIED, bool postProcess=false)
Adds a connection between the specified this edge's lane and an approached one.
Lane & getLaneStruct(int lane)
void setLoadedLength(double val)
set loaded length
Instance responsible for building networks.
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
NBTypeCont & getTypeCont()
Returns a reference to the type container.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=0)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
NBEdgeCont & getEdgeCont()
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
Container for nodes during the netbuilding process.
Represents a single node (junction) during network building.
void reinit(const Position &position, SumoXMLNodeType type, bool updateEdgeGeometries=false)
Resets initial values.
SumoXMLNodeType getType() const
Returns the type of this node.
const Position & getPosition() const
A traffic light logics which must be computed (only nodes/edges are given)
The base class for traffic light logic definitions.
A container for traffic light definitions and built programs.
A storage for available edgeTypes of edges.
Imports prohibitions regarding connectivity.
bool report(const std::string &result)
Parsing method.
~ConnectedLanesHandler()
Destructor.
ConnectedLanesHandler(NBEdgeCont &ne)
Constructor.
Importer of edges stored in unsplit elmar format.
~EdgesHandler()
Destructor.
std::string getStreetNameFromIDs(const std::string ®ionalID, const std::string &localID) const
build the street name for the given ids
static const int MISSING_COLUMN
std::string getColumn(const StringTokenizer &st, ColumnName name, const std::string fallback="")
EdgesHandler(NBNodeCont &nc, NBEdgeCont &ec, NBTypeCont &tc, const std::string &file, std::map< std::string, PositionVector > &geoms, std::map< std::string, std::string > &streetNames)
Constructor.
bool report(const std::string &result)
Parsing method.
Importer of street names in DLRNavteq's (aka elmar) format.
bool report(const std::string &result)
Parsing method.
NamesHandler(const std::string &file, std::map< std::string, std::string > &streetNames)
Constructor.
~NamesHandler()
Destructor.
Importer of nodes stored in unsplit elmar format.
NodesHandler(NBNodeCont &nc, const std::string &file, std::map< std::string, PositionVector > &geoms)
Constructor.
~NodesHandler()
Destructor.
bool report(const std::string &result)
Parsing method.
Imports prohibitions regarding connectivity.
bool report(const std::string &result)
Parsing method.
ProhibitionHandler(NBEdgeCont &ne, const std::string &file, time_t constructionTime)
Constructor.
~ProhibitionHandler()
Destructor.
Importer of street names in DLRNavteq's (aka elmar) format.
~TimeRestrictionsHandler()
Destructor.
TimeRestrictionsHandler(NBEdgeCont &ec, NBDistrictCont &dc, time_t constructionTime)
Constructor.
bool report(const std::string &result)
Parsing method.
Importer of traffic lights stored in DLRNavteq's (aka elmar) format.
TrafficlightsHandler(NBNodeCont &nc, NBTrafficLightLogicCont &tlc, NBEdgeCont &ne, const std::string &file)
Constructor.
~TrafficlightsHandler()
Destructor.
bool report(const std::string &result)
Parsing method.
static double readVersion(const std::string &line, const std::string &file)
static time_t readTimeRec(const std::string &start, const std::string &duration)
static int readPrefixedInt(const std::string &s, const std::string &prefix, int fallBack=0)
static void loadNetwork(const OptionsCont &oc, NBNetBuilder &nb)
Loads content of the optionally given dlr-navteq (aka Elmar-fomat) folder.
static const std::string GEO_SCALE
scaling factor for geo coordinates (DLRNavteq format uses this to increase floating point precisions)
static const std::string UNDEFINED
magic value for undefined stuff
static time_t readDate(const std::string &yyyymmdd)
static bool keepLength
decides whether the edge length of the input format should be used
static void addVehicleClasses(NBEdge &e, const std::string &classS, const SVCPermissions allPermissions, const SVCPermissions defaultPermissions)
Adds vehicle classes parsing the given list of allowed vehicles.
static void addVehicleClassesV6(NBEdge &e, const std::string &classS, const SVCPermissions allPermissions, const SVCPermissions defaultPermissions)
same as addVehicleClasses but for version 6+
static int getLaneNumber(const std::string &id, const std::string &laneNoS, double speed)
Returns the lane number evaluating the given Navteq-description.
static double getSpeed(const std::string &id, const std::string &speedClassS)
Returns the speed evaluating the given Navteq-description.
const std::string & getID() const
Returns the id.
A storage for options typed value containers)
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
std::string getString(const std::string &name) const
Returns the string-value of the named option (only for Option_String)
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
A point in 2D or 3D with translation and scaling methods.
static const PositionVector EMPTY
empty Vector
PositionVector reverse() const
reverse position vector
static StringBijection< TrafficLightType > TrafficLightTypes
traffic light types
T get(const std::string &str) const
int size() const
returns the number of existing substrings
static const int WHITECHARS
identifier for splitting the given string at all whitespace characters
std::string get(int pos) const
returns the item at the given position
static const int TAB
the ascii index of the tab character
std::string next()
returns the next substring when it exists. Otherwise the behaviour is undefined
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static std::string to_lower_case(std::string str)
Transfers the content to lower case.
static int toInt(const std::string &sData)
converts a string into the integer value described by it by calling the char-type converter,...
bool connectionsDone
Whether connection information for this lane is already completed.