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";
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_WARNINGF(
TL(
"Output will not contain street names because the file '%' was not found"), file);
101 file = oc.
getString(
"dlr-navteq-prefix") +
"_links_unsplitted.txt";
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(
TLF(
"Non-numerical value for intermediate status in node %.",
id));
215 throw ProcessError(
TLF(
"Non-numerical value for number of geometries in node %.",
id));
219 for (
int i = 0; i < no_geoms; i++) {
222 throw ProcessError(
TLF(
"Non-numerical value for x-position in node %.",
id));
226 throw ProcessError(
TLF(
"Non-numerical value for y-position in node %.",
id));
230 throw ProcessError(
TLF(
"Unable to project coordinates for node %.",
id));
232 geoms.push_back(pos);
235 if (intermediate == 0) {
237 if (!myNodeCont.insert(n)) {
257 std::map<std::string, PositionVector>& geoms,
258 std::map<std::string, std::string>& streetNames):
263 myStreetNames(streetNames),
275 if (result[0] ==
'#') {
276 if (!myColumns.empty()) {
279 const double version =
readVersion(result, myFile);
283 const int NUM_COLUMNS = 25;
284 const int MC = MISSING_COLUMN;
286 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};
287 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
288 }
else if (myVersion < 6) {
289 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};
290 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
292 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};
293 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
298 if (myColumns.empty()) {
299 throw ProcessError(
TLF(
"Missing version string in file '%'.", myFile));
303 const std::string
id = getColumn(st, LINK_ID);
309 throw ProcessError(
TLF(
"Non-numerical value for form_of_way of link '%'.",
id));
316 throw ProcessError(
TLF(
"Non-numerical value for brunnel_type of link '%'.",
id));
323 if (form_of_way == 11) {
325 }
else if (form_of_way > 11) {
329 throw ProcessError(
TLF(
"Non-numerical value for street_type of link '%'.",
id));
332 std::string streetName = getStreetNameFromIDs(
333 getColumn(st, NAME_ID1_REGIONAL),
334 getColumn(st, NAME_ID2_LOCAL));
336 const std::string fromID = getColumn(st, NODE_ID_FROM);
337 const std::string toID = getColumn(st, NODE_ID_TO);
338 NBNode* from = myNodeCont.retrieve(fromID);
339 NBNode* to = myNodeCont.retrieve(toID);
340 if (from ==
nullptr) {
341 throw ProcessError(
"The from-node '" + fromID +
"' of link '" +
id +
"' could not be found");
344 throw ProcessError(
"The to-node '" + toID +
"' of link '" +
id +
"' could not be found");
351 throw ProcessError(
TLF(
"Non-numerical value for the SPEED_RESTRICTION of link '%'.",
id));
362 if (numLanes == -1) {
366 throw ProcessError(
TLF(
"Non-numerical value for the number of lanes of link '%'.",
id));
369 const std::string navTeqTypeId = getColumn(st, VEHICLE_TYPE) +
"_" + getColumn(st, FORM_OF_WAY);
372 const std::string interID = getColumn(st, BETWEEN_NODE_ID);
373 if (interID ==
"-1") {
395 if (myTypeCont.knows(navTeqTypeId)) {
396 e->
setPermissions(myTypeCont.getEdgeTypePermissions(navTeqTypeId));
399 const SVCPermissions allPermissions = myTypeCont.getEdgeTypePermissions(
"");
401 if (myVersion < 6.0) {
407 if (form_of_way == 14) {
412 if (brunnel_type == 10) {
418 if (!myEdgeCont.insert(e)) {
428 assert(!myColumns.empty());
429 if (myColumns[name] == MISSING_COLUMN) {
430 if (fallback ==
"") {
435 }
else if (myColumns[name] >= 0) {
436 return st.
get((
int)(myColumns[name]));
439 if ((
int) st.
size() <= -myColumns[name]) {
441 if (fallback ==
"") {
447 return st.
get((
int)(-myColumns[name]));
455 const std::string& regionalID,
const std::string& localID)
const {
456 std::string result =
"";
457 bool hadRegional =
false;
458 if (myStreetNames.count(regionalID) > 0) {
460 result += myStreetNames[regionalID];
462 if (myStreetNames.count(localID) > 0) {
466 result += myStreetNames[localID];
477 const std::string& file) :
492 if (result[0] ==
'#') {
496 const std::string edgeID = st.
get(5);
497 NBEdge* edge = myEdgeCont.retrieve(edgeID);
498 if (edge ==
nullptr) {
499 WRITE_WARNINGF(
TL(
"The traffic light edge '%' could not be found."), edgeID);
508 if (!myTLLogicCont.insert(tlDef)) {
523 const std::string& file, std::map<std::string, std::string>& streetNames) :
524 myStreetNames(streetNames) {
535 if (result[0] ==
'#') {
539 if (st.
size() == 1) {
542 assert(st.
size() >= 2);
543 const std::string
id = st.
next();
545 const std::string permanent_id_info = st.
next();
547 myStreetNames[id] = st.
next();
558 myConstructionTime(constructionTime),
559 myCS_min(
std::numeric_limits<time_t>::max()),
560 myCS_max(
std::numeric_limits<time_t>::min()),
561 myConstructionEntries(0),
563 myUnderConstruction(0),
575 if (result[0] ==
'#') {
579 const std::string
id = st.
next();
580 const std::string type = st.
next();
581 const std::string directionOfFlow = st.
next();
582 const std::string throughTraffic = st.
next();
583 const std::string vehicleType = st.
next();
584 const std::string validityPeriod = st.
next();
585 const std::string warning =
"Unrecognized TIME_REC '" + validityPeriod +
"'";
587 myConstructionEntries++;
588 if (validityPeriod.size() > 1024) {
597 matched = sscanf(validityPeriod.c_str(),
"[(%[^)]){%[^}]}]", start, duration);
601 myCS_min =
MIN2(myCS_min, tStart);
602 myCS_max =
MAX2(myCS_max, tEnd);
605 if (myConstructionTime < tEnd) {
606 NBEdge* edge = myEdgeCont.retrieve(
id);
607 if (edge !=
nullptr) {
609 myEdgeCont.extract(myDistrictCont, edge,
true);
611 if (myConstructionTime < tStart) {
614 myUnderConstruction++;
629 if (myConstructionEntries > 0) {
631 std::ostringstream msg;
632 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myCS_min));
633 msg <<
"Parsed " << myConstructionEntries <<
" construction entries between " << buff;
634 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myCS_max));
635 msg <<
" and " << buff <<
".\n";
636 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myConstructionTime));
637 msg <<
"Removed " << myRemovedEdges <<
" edges not yet constructed at " << buff <<
".\n";
638 msg <<
" not yet started: " << myNotStarted <<
"\n";
639 msg <<
" under construction: " << myUnderConstruction <<
"\n";
640 msg <<
" finished: " << myFinished <<
"\n";
648 int result = fallBack;
649 const size_t pos = s.find(prefix);
650 if (pos != std::string::npos) {
651 sscanf(s.substr(pos + prefix.size()).c_str(),
"%i", &result);
661 timeinfo.tm_hour = 0;
664 timeinfo.tm_year = 0;
666 timeinfo.tm_mday = 1;
667 timeinfo.tm_wday = 0;
668 timeinfo.tm_yday = 0;
669 timeinfo.tm_isdst = 0;
676 time_t result = mktime(&timeinfo);
684 timeinfo.tm_hour = 0;
687 timeinfo.tm_wday = 0;
688 timeinfo.tm_yday = 0;
689 timeinfo.tm_isdst = 0;
691 if (yyyymmdd.size() == 10
692 && yyyymmdd[4] ==
'-'
693 && yyyymmdd[7] ==
'-') {
698 return mktime(&timeinfo);
702 WRITE_ERRORF(
TL(
"Could not parse YYYY-MM-DD date '%'"), yyyymmdd);
712 NBEdgeCont& ec,
const std::string& file, time_t constructionTime) :
716 myConstructionTime(constructionTime) {
726 if (result[0] ==
'#') {
727 if (myVersion == 0) {
728 const double version =
readVersion(result, myFile);
736 if (st.
size() == 1) {
739 if (myVersion >= 6) {
740 assert(st.
size() >= 7);
741 const std::string
id = st.
next();
742 const std::string permanent = st.
next();
743 const std::string validityPeriod = st.
next();
744 const std::string throughTraffic = st.
next();
745 const std::string vehicleType = st.
next();
747 WRITE_WARNINGF(
TL(
"Ignoring temporary prohibited manoeuvre (%)."), validityPeriod);
751 const std::string startEdge = st.
next();
752 const std::string endEdge = st.
get(st.
size() - 1);
754 NBEdge* from = myEdgeCont.retrieve(startEdge);
755 if (from ==
nullptr) {
756 WRITE_WARNINGF(
TL(
"Ignoring prohibition from unknown start edge '%'."), startEdge);
759 NBEdge* to = myEdgeCont.retrieve(endEdge);
761 WRITE_WARNINGF(
TL(
"Ignoring prohibition from unknown end edge '%'."), endEdge);
783 if (result[0] ==
'#') {
787 if (st.
size() == 1) {
790 assert(st.
size() >= 7);
791 const std::string nodeID = st.
next();
792 const std::string vehicleType = st.
next();
793 const std::string fromLaneS = st.
next();
794 const std::string toLaneS = st.
next();
795 const std::string throughTraffic = st.
next();
796 const std::string startEdge = st.
next();
797 const std::string endEdge = st.
get(st.
size() - 1);
799 NBEdge* from = myEdgeCont.retrieve(startEdge);
800 if (from ==
nullptr) {
801 WRITE_WARNINGF(
TL(
"Ignoring prohibition from unknown start edge '%'."), startEdge);
804 NBEdge* to = myEdgeCont.retrieve(endEdge);
806 WRITE_WARNINGF(
TL(
"Ignoring prohibition from unknown end edge '%'."), endEdge);
810 if (fromLane < 0 || fromLane >= from->
getNumLanes()) {
811 WRITE_WARNINGF(
TL(
"Ignoring invalid lane index '%' in connection from edge '%' with % lanes."), fromLaneS, startEdge, from->
getNumLanes());
825 const bool warnOnly = st.
size() > 7;
#define WRITE_WARNINGF(...)
#define WRITE_ERRORF(...)
#define WRITE_MESSAGE(msg)
#define WRITE_WARNING(msg)
#define PROGRESS_DONE_MESSAGE()
#define PROGRESS_BEGIN_MESSAGE(msg)
long long int SVCPermissions
bitset where each bit declares whether a certain SVC may use this edge/lane
@ SVC_SHIP
is an arbitrary ship
@ SVC_PASSENGER
vehicle is a passenger car (a "normal" car)
#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
NBNode * getToNode() const
Returns the destination node of the edge.
static const double UNSPECIFIED_FRICTION
unspecified lane friction
Lane & getLaneStruct(int lane)
void disallowVehicleClass(int lane, SUMOVehicleClass vclass)
set disallowed class for the given lane or for all lanes if -1 is given
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 friction=UNSPECIFIED_FRICTION, double length=myDefaultConnectionLength, const PositionVector &customShape=PositionVector::EMPTY, const bool uncontrolled=UNSPECIFIED_CONNECTION_UNCONTROLLED, SVCPermissions permissions=SVC_UNSPECIFIED, const bool indirectLeft=false, const std::string &edgeType="", SVCPermissions changeLeft=SVC_UNSPECIFIED, SVCPermissions changeRight=SVC_UNSPECIFIED, bool postProcess=false)
Adds a connection between the specified this edge's lane and an approached one.
@ INIT
The edge has been loaded, nothing is computed yet.
const std::string & getID() const
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
void setLoadedLength(double val)
set loaded length
Instance responsible for building networks.
NBNodeCont & getNodeCont()
Returns a reference to the node container.
NBEdgeCont & getEdgeCont()
NBDistrictCont & getDistrictCont()
Returns a reference the districts container.
NBTypeCont & getTypeCont()
Returns a reference to the type container.
NBTrafficLightLogicCont & getTLLogicCont()
Returns a reference to the traffic light logics container.
static bool transformCoordinate(Position &from, bool includeInBoundary=true, GeoConvHelper *from_srs=nullptr)
transforms loaded coordinates handles projections, offsets (using GeoConvHelper) and import of height...
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 std::string to_lower_case(const std::string &str)
Transfers the content to lower case.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
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.