66 if (!oc.
isSet(
"dlr-navteq-prefix")) {
74 std::map<std::string, PositionVector> myGeoms;
76 std::string file = oc.
getString(
"dlr-navteq-prefix") +
"_nodes_unsplitted.txt";
79 throw ProcessError(
"The file '" + file +
"' could not be opened.");
85 std::map<std::string, std::string> streetNames;
86 if (oc.
getBool(
"output.street-names")) {
87 file = oc.
getString(
"dlr-navteq-prefix") +
"_names.txt";
94 WRITE_WARNING(
"Output will not contain street names because the file '" + file +
"' was not found");
100 file = oc.
getString(
"dlr-navteq-prefix") +
"_links_unsplitted.txt";
104 throw ProcessError(
"The file '" + file +
"' could not be opened.");
111 file = oc.
getString(
"dlr-navteq-prefix") +
"_traffic_signals.txt";
120 file = oc.
getString(
"dlr-navteq-prefix") +
"_prohibited_manoeuvres.txt";
129 file = oc.
getString(
"dlr-navteq-prefix") +
"_connected_lanes.txt";
138 file = oc.
getString(
"dlr-navteq-prefix") +
"_links_timerestrictions.txt";
141 if (!oc.
isDefault(
"construction-date")) {
146 handler5.printSummary();
153 assert(line[0] ==
'#');
154 const std::string marker =
"extraction version: v";
156 if (lowerCase.find(marker) == std::string::npos) {
159 const int vStart = (int)(lowerCase.find(marker) + marker.size());
160 const int vEnd = (int)line.find(
" ", vStart);
164 throw ProcessError(
"Invalid version number '" +
toString(version) +
"' in file '" + file +
"'.");
168 throw ProcessError(
"Non-numerical value '" + line.substr(vStart, vEnd - vStart) +
"' for version string in file '" + file +
"'.");
177 const std::string& file,
178 std::map<std::string, PositionVector>& geoms)
179 : myNodeCont(nc), myGeoms(geoms) {
189 if (result[0] ==
'#') {
194 int no_geoms, intermediate;
196 std::istringstream stream(result);
200 throw ProcessError(
"Something is wrong with the following data line\n" + result);
203 stream >> intermediate;
205 if (myNodeCont.size() == 0) {
208 throw ProcessError(
"Non-numerical value for intermediate status in node " +
id +
".");
213 throw ProcessError(
"Non-numerical value for number of geometries in node " +
id +
".");
217 for (
int i = 0; i < no_geoms; i++) {
220 throw ProcessError(
"Non-numerical value for x-position in node " +
id +
".");
224 throw ProcessError(
"Non-numerical value for y-position in node " +
id +
".");
228 throw ProcessError(
"Unable to project coordinates for node " +
id +
".");
230 geoms.push_back(pos);
233 if (intermediate == 0) {
235 if (!myNodeCont.insert(n)) {
251 std::map<std::string, PositionVector>& geoms,
252 std::map<std::string, std::string>& streetNames):
257 myStreetNames(streetNames),
269 if (result[0] ==
'#') {
270 if (!myColumns.empty()) {
273 const double version =
readVersion(result, myFile);
277 const int NUM_COLUMNS = 25;
278 const int MC = MISSING_COLUMN;
280 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};
281 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
282 }
else if (myVersion < 6) {
283 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};
284 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
286 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};
287 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
292 if (myColumns.empty()) {
293 throw ProcessError(
"Missing version string in file '" + myFile +
"'.");
297 const std::string
id = getColumn(st, LINK_ID);
303 throw ProcessError(
"Non-numerical value for form_of_way of link '" +
id +
"'.");
310 throw ProcessError(
"Non-numerical value for brunnel_type of link '" +
id +
"'.");
317 if (form_of_way == 11) {
319 }
else if (form_of_way > 11) {
323 throw ProcessError(
"Non-numerical value for street_type of link '" +
id +
"').");
326 std::string streetName = getStreetNameFromIDs(
327 getColumn(st, NAME_ID1_REGIONAL),
328 getColumn(st, NAME_ID2_LOCAL));
330 const std::string fromID = getColumn(st, NODE_ID_FROM);
331 const std::string toID = getColumn(st, NODE_ID_TO);
332 NBNode* from = myNodeCont.retrieve(fromID);
333 NBNode* to = myNodeCont.retrieve(toID);
334 if (from ==
nullptr) {
335 throw ProcessError(
"The from-node '" + fromID +
"' of link '" +
id +
"' could not be found");
338 throw ProcessError(
"The to-node '" + toID +
"' of link '" +
id +
"' could not be found");
345 throw ProcessError(
"Non-numerical value for the SPEED_RESTRICTION of link '" +
id +
"'.");
356 if (numLanes == -1) {
360 throw ProcessError(
"Non-numerical value for the number of lanes of link '" +
id +
"'.");
363 const std::string navTeqTypeId = getColumn(st, VEHICLE_TYPE) +
"_" + getColumn(st, FORM_OF_WAY);
366 const std::string interID = getColumn(st, BETWEEN_NODE_ID);
367 if (interID ==
"-1") {
368 e =
new NBEdge(
id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId :
"", speed, numLanes, priority,
372 if (getColumn(st, CONNECTION,
"0") ==
"1") {
378 e =
new NBEdge(
id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId :
"", speed, numLanes, priority,
383 if (myTypeCont.knows(navTeqTypeId)) {
387 if (myVersion < 6.0) {
396 if (form_of_way == 14) {
401 if (brunnel_type == 10) {
407 if (!myEdgeCont.insert(e)) {
417 assert(!myColumns.empty());
418 if (myColumns[name] == MISSING_COLUMN) {
419 if (fallback ==
"") {
424 }
else if (myColumns[name] >= 0) {
425 return st.
get((
int)(myColumns[name]));
428 if ((
int) st.
size() <= -myColumns[name]) {
430 if (fallback ==
"") {
436 return st.
get((
int)(-myColumns[name]));
444 const std::string& regionalID,
const std::string& localID)
const {
445 std::string result =
"";
446 bool hadRegional =
false;
447 if (myStreetNames.count(regionalID) > 0) {
449 result += myStreetNames[regionalID];
451 if (myStreetNames.count(localID) > 0) {
455 result += myStreetNames[localID];
466 const std::string& file) :
481 if (result[0] ==
'#') {
485 const std::string edgeID = st.
get(5);
486 NBEdge* edge = myEdgeCont.retrieve(edgeID);
487 if (edge ==
nullptr) {
488 WRITE_WARNINGF(
"The traffic light edge '%' could not be found.", edgeID);
497 if (!myTLLogicCont.insert(tlDef)) {
512 const std::string& file, std::map<std::string, std::string>& streetNames) :
513 myStreetNames(streetNames) {
524 if (result[0] ==
'#') {
528 if (st.
size() == 1) {
531 assert(st.
size() >= 2);
532 const std::string
id = st.
next();
534 const std::string permanent_id_info = st.
next();
536 myStreetNames[id] = st.
next();
547 myConstructionTime(constructionTime),
548 myCS_min(std::numeric_limits<time_t>::max()),
549 myCS_max(std::numeric_limits<time_t>::min()),
550 myConstructionEntries(0),
552 myUnderConstruction(0),
564 if (result[0] ==
'#') {
568 const std::string
id = st.
next();
569 const std::string type = st.
next();
570 const std::string directionOfFlow = st.
next();
571 const std::string throughTraffic = st.
next();
572 const std::string vehicleType = st.
next();
573 const std::string validityPeriod = st.
next();
574 const std::string warning =
"Unrecognized TIME_REC '" + validityPeriod +
"'";
576 myConstructionEntries++;
577 if (validityPeriod.size() > 1024) {
586 matched = sscanf(validityPeriod.c_str(),
"[(%[^)]){%[^}]}]", start, duration);
590 myCS_min =
MIN2(myCS_min, tStart);
591 myCS_max =
MAX2(myCS_max, tEnd);
594 if (myConstructionTime < tEnd) {
595 NBEdge* edge = myEdgeCont.retrieve(
id);
596 if (edge !=
nullptr) {
598 myEdgeCont.extract(myDistrictCont, edge,
true);
600 if (myConstructionTime < tStart) {
603 myUnderConstruction++;
618 if (myConstructionEntries > 0) {
620 std::ostringstream msg;
621 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myCS_min));
622 msg <<
"Parsed " << myConstructionEntries <<
" construction entries between " << buff;
623 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myCS_max));
624 msg <<
" and " << buff <<
".\n";
625 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myConstructionTime));
626 msg <<
"Removed " << myRemovedEdges <<
" edges not yet constructed at " << buff <<
".\n";
627 msg <<
" not yet started: " << myNotStarted <<
"\n";
628 msg <<
" under construction: " << myUnderConstruction <<
"\n";
629 msg <<
" finished: " << myFinished <<
"\n";
637 int result = fallBack;
638 size_t pos = s.find(prefix);
639 if (pos != std::string::npos) {
640 sscanf(s.substr(pos).c_str(), (prefix +
"%i").c_str(), &result);
649 timeinfo.tm_hour = 0;
652 timeinfo.tm_year = 0;
654 timeinfo.tm_mday = 1;
655 timeinfo.tm_wday = 0;
656 timeinfo.tm_yday = 0;
657 timeinfo.tm_isdst = 0;
664 time_t result = mktime(&timeinfo);
672 timeinfo.tm_hour = 0;
675 timeinfo.tm_wday = 0;
676 timeinfo.tm_yday = 0;
677 timeinfo.tm_isdst = 0;
679 if (yyyymmdd.size() == 10
680 && yyyymmdd[4] ==
'-'
681 && yyyymmdd[7] ==
'-') {
686 return mktime(&timeinfo);
690 WRITE_ERROR(
"Could not parse YYYY-MM-DD date '" + yyyymmdd +
"'");
700 NBEdgeCont& ec,
const std::string& file, time_t constructionTime) :
704 myConstructionTime(constructionTime) {
714 if (result[0] ==
'#') {
715 if (myVersion == 0) {
716 const double version =
readVersion(result, myFile);
724 if (st.
size() == 1) {
727 if (myVersion >= 6) {
728 assert(st.
size() >= 7);
729 const std::string
id = st.
next();
730 const std::string permanent = st.
next();
731 const std::string validityPeriod = st.
next();
732 const std::string throughTraffic = st.
next();
733 const std::string vehicleType = st.
next();
735 WRITE_WARNINGF(
"Ignoring temporary prohibited manoeuvre (%).", validityPeriod);
739 const std::string startEdge = st.
next();
740 const std::string endEdge = st.
get(st.
size() - 1);
742 NBEdge* from = myEdgeCont.retrieve(startEdge);
743 if (from ==
nullptr) {
744 WRITE_WARNINGF(
"Ignoring prohibition from unknown start edge '%'.", startEdge);
747 NBEdge* to = myEdgeCont.retrieve(endEdge);
749 WRITE_WARNINGF(
"Ignoring prohibition from unknown end edge '%'.", endEdge);
771 if (result[0] ==
'#') {
775 if (st.
size() == 1) {
778 assert(st.
size() >= 7);
779 const std::string nodeID = st.
next();
780 const std::string vehicleType = st.
next();
781 const std::string fromLaneS = st.
next();
782 const std::string toLaneS = st.
next();
783 const std::string throughTraffic = st.
next();
784 const std::string startEdge = st.
next();
785 const std::string endEdge = st.
get(st.
size() - 1);
787 NBEdge* from = myEdgeCont.retrieve(startEdge);
788 if (from ==
nullptr) {
789 WRITE_WARNINGF(
"Ignoring prohibition from unknown start edge '%'.", startEdge);
792 NBEdge* to = myEdgeCont.retrieve(endEdge);
794 WRITE_WARNINGF(
"Ignoring prohibition from unknown end edge '%'.", endEdge);
798 if (fromLane < 0 || fromLane >= from->
getNumLanes()) {
799 WRITE_WARNINGF(
"Ignoring invalid lane index '%' in connection from edge '%' with % lanes.", fromLaneS, startEdge, from->
getNumLanes());
804 WRITE_WARNINGF(
"Ignoring invalid lane index '%' in connection to edge '%' with % lanes", toLaneS, endEdge, to->
getNumLanes());
813 const bool warnOnly = st.
size() > 7;
814 myEdgeCont.addPostProcessConnection(from->
getID(), fromLane, to->
getID(), toLane,
false,
true,