67 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")) {
147 handler5.printSummary();
154 assert(line[0] ==
'#');
155 const std::string marker =
"extraction version: v";
157 if (lowerCase.find(marker) == std::string::npos) {
160 const int vStart = (int)(lowerCase.find(marker) + marker.size());
161 const int vEnd = (int)line.find(
" ", vStart);
165 throw ProcessError(
"Invalid version number '" +
toString(version) +
"' in file '" + file +
"'.");
169 throw ProcessError(
"Non-numerical value '" + line.substr(vStart, vEnd - vStart) +
"' for version string in file '" + file +
"'.");
178 const std::string& file,
179 std::map<std::string, PositionVector>& geoms)
180 : myNodeCont(nc), myGeoms(geoms) {
190 if (result[0] ==
'#') {
195 int no_geoms, intermediate;
197 std::istringstream stream(result);
201 throw ProcessError(
"Something is wrong with the following data line\n" + result);
204 stream >> intermediate;
206 if (myNodeCont.size() == 0) {
209 throw ProcessError(
"Non-numerical value for intermediate status in node " +
id +
".");
214 throw ProcessError(
"Non-numerical value for number of geometries in node " +
id +
".");
218 for (
int i = 0; i < no_geoms; i++) {
221 throw ProcessError(
"Non-numerical value for x-position in node " +
id +
".");
225 throw ProcessError(
"Non-numerical value for y-position in node " +
id +
".");
229 throw ProcessError(
"Unable to project coordinates for node " +
id +
".");
231 geoms.push_back(pos);
234 if (intermediate == 0) {
236 if (!myNodeCont.insert(n)) {
252 std::map<std::string, PositionVector>& geoms,
253 std::map<std::string, std::string>& streetNames):
258 myStreetNames(streetNames),
270 if (result[0] ==
'#') {
271 if (!myColumns.empty()) {
274 const double version =
readVersion(result, myFile);
278 const int NUM_COLUMNS = 25;
279 const int MC = MISSING_COLUMN;
281 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};
282 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
283 }
else if (myVersion < 6) {
284 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};
285 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
287 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};
288 myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
293 if (myColumns.empty()) {
294 throw ProcessError(
"Missing version string in file '" + myFile +
"'.");
298 const std::string
id = getColumn(st, LINK_ID);
304 throw ProcessError(
"Non-numerical value for form_of_way of link '" +
id +
"'.");
311 throw ProcessError(
"Non-numerical value for brunnel_type of link '" +
id +
"'.");
318 if (form_of_way == 11) {
320 }
else if (form_of_way > 11) {
324 throw ProcessError(
"Non-numerical value for street_type of link '" +
id +
"').");
327 std::string streetName = getStreetNameFromIDs(
328 getColumn(st, NAME_ID1_REGIONAL),
329 getColumn(st, NAME_ID2_LOCAL));
331 const std::string fromID = getColumn(st, NODE_ID_FROM);
332 const std::string toID = getColumn(st, NODE_ID_TO);
333 NBNode* from = myNodeCont.retrieve(fromID);
334 NBNode* to = myNodeCont.retrieve(toID);
335 if (from ==
nullptr) {
336 throw ProcessError(
"The from-node '" + fromID +
"' of link '" +
id +
"' could not be found");
339 throw ProcessError(
"The to-node '" + toID +
"' of link '" +
id +
"' could not be found");
346 throw ProcessError(
"Non-numerical value for the SPEED_RESTRICTION of link '" +
id +
"'.");
357 if (numLanes == -1) {
361 throw ProcessError(
"Non-numerical value for the number of lanes of link '" +
id +
"'.");
364 const std::string navTeqTypeId = getColumn(st, VEHICLE_TYPE) +
"_" + getColumn(st, FORM_OF_WAY);
367 const std::string interID = getColumn(st, BETWEEN_NODE_ID);
368 if (interID ==
"-1") {
369 e =
new NBEdge(
id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId :
"", speed, numLanes, priority,
373 if (getColumn(st, CONNECTION,
"0") ==
"1") {
379 e =
new NBEdge(
id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId :
"", speed, numLanes, priority,
384 if (myTypeCont.knows(navTeqTypeId)) {
388 if (myVersion < 6.0) {
397 if (form_of_way == 14) {
402 if (brunnel_type == 10) {
408 if (!myEdgeCont.insert(e)) {
418 assert(!myColumns.empty());
419 if (myColumns[name] == MISSING_COLUMN) {
420 if (fallback ==
"") {
425 }
else if (myColumns[name] >= 0) {
426 return st.
get((
int)(myColumns[name]));
429 if ((
int) st.
size() <= -myColumns[name]) {
431 if (fallback ==
"") {
437 return st.
get((
int)(-myColumns[name]));
445 const std::string& regionalID,
const std::string& localID)
const {
446 std::string result =
"";
447 bool hadRegional =
false;
448 if (myStreetNames.count(regionalID) > 0) {
450 result += myStreetNames[regionalID];
452 if (myStreetNames.count(localID) > 0) {
456 result += myStreetNames[localID];
467 const std::string& file) :
482 if (result[0] ==
'#') {
486 const std::string edgeID = st.
get(5);
487 NBEdge* edge = myEdgeCont.retrieve(edgeID);
488 if (edge ==
nullptr) {
489 WRITE_WARNING(
"The traffic light edge '" + edgeID +
"' could not be found");
498 if (!myTLLogicCont.insert(tlDef)) {
513 const std::string& file, std::map<std::string, std::string>& streetNames) :
514 myStreetNames(streetNames) {
525 if (result[0] ==
'#') {
529 if (st.
size() == 1) {
532 assert(st.
size() >= 2);
533 const std::string
id = st.
next();
535 const std::string permanent_id_info = st.
next();
537 myStreetNames[id] = st.
next();
548 myConstructionTime(constructionTime),
549 myCS_min(std::numeric_limits<time_t>::max()),
550 myCS_max(std::numeric_limits<time_t>::min()),
551 myConstructionEntries(0),
553 myUnderConstruction(0),
565 if (result[0] ==
'#') {
569 const std::string
id = st.
next();
570 const std::string type = st.
next();
571 const std::string directionOfFlow = st.
next();
572 const std::string throughTraffic = st.
next();
573 const std::string vehicleType = st.
next();
574 const std::string validityPeriod = st.
next();
575 const std::string warning =
"Unrecognized TIME_REC '" + validityPeriod +
"'";
577 myConstructionEntries++;
578 if (validityPeriod.size() > 1024) {
587 matched = sscanf(validityPeriod.c_str(),
"[(%[^)]){%[^}]}]", start, duration);
591 myCS_min =
MIN2(myCS_min, tStart);
592 myCS_max =
MAX2(myCS_max, tEnd);
595 if (myConstructionTime < tEnd) {
596 NBEdge* edge = myEdgeCont.retrieve(
id);
597 if (edge !=
nullptr) {
599 myEdgeCont.extract(myDistrictCont, edge,
true);
601 if (myConstructionTime < tStart) {
604 myUnderConstruction++;
619 if (myConstructionEntries > 0) {
621 std::ostringstream msg;
622 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myCS_min));
623 msg <<
"Parsed " << myConstructionEntries <<
" construction entries between " << buff;
624 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myCS_max));
625 msg <<
" and " << buff <<
".\n";
626 strftime(buff, 1024,
"%Y-%m-%d", localtime(&myConstructionTime));
627 msg <<
"Removed " << myRemovedEdges <<
" edges not yet constructed at " << buff <<
".\n";
628 msg <<
" not yet started: " << myNotStarted <<
"\n";
629 msg <<
" under construction: " << myUnderConstruction <<
"\n";
630 msg <<
" finished: " << myFinished <<
"\n";
638 int result = fallBack;
639 size_t pos = s.find(prefix);
640 if (pos != std::string::npos) {
641 sscanf(s.substr(pos).c_str(), (prefix +
"%i").c_str(), &result);
650 timeinfo.tm_hour = 0;
653 timeinfo.tm_year = 0;
655 timeinfo.tm_mday = 1;
656 timeinfo.tm_wday = 0;
657 timeinfo.tm_yday = 0;
658 timeinfo.tm_isdst = 0;
665 time_t result = mktime(&timeinfo);
673 timeinfo.tm_hour = 0;
676 timeinfo.tm_wday = 0;
677 timeinfo.tm_yday = 0;
678 timeinfo.tm_isdst = 0;
680 if (yyyymmdd.size() == 10
681 && yyyymmdd[4] ==
'-'
682 && yyyymmdd[7] ==
'-') {
687 return mktime(&timeinfo);
691 WRITE_ERROR(
"Could not parse YYYY-MM-DD date '" + yyyymmdd +
"'");
701 NBEdgeCont& ec,
const std::string& file, time_t constructionTime) :
705 myConstructionTime(constructionTime) {
715 if (result[0] ==
'#') {
716 if (myVersion == 0) {
717 const double version =
readVersion(result, myFile);
725 if (st.
size() == 1) {
728 if (myVersion >= 6) {
729 assert(st.
size() >= 7);
730 const std::string
id = st.
next();
731 const std::string permanent = st.
next();
732 const std::string validityPeriod = st.
next();
733 const std::string throughTraffic = st.
next();
734 const std::string vehicleType = st.
next();
736 WRITE_WARNING(
"Ignoring temporary prohibited manoeuvre (" + validityPeriod +
")");
740 const std::string startEdge = st.
next();
741 const std::string endEdge = st.
get(st.
size() - 1);
743 NBEdge* from = myEdgeCont.retrieve(startEdge);
744 if (from ==
nullptr) {
745 WRITE_WARNING(
"Ignoring prohibition from unknown start edge '" + startEdge +
"'");
748 NBEdge* to = myEdgeCont.retrieve(endEdge);
750 WRITE_WARNING(
"Ignoring prohibition from unknown end edge '" + endEdge +
"'");
772 if (result[0] ==
'#') {
776 if (st.
size() == 1) {
779 assert(st.
size() >= 7);
780 const std::string nodeID = st.
next();
781 const std::string vehicleType = st.
next();
782 const std::string fromLaneS = st.
next();
783 const std::string toLaneS = st.
next();
784 const std::string throughTraffic = st.
next();
785 const std::string startEdge = st.
next();
786 const std::string endEdge = st.
get(st.
size() - 1);
788 NBEdge* from = myEdgeCont.retrieve(startEdge);
789 if (from ==
nullptr) {
790 WRITE_WARNING(
"Ignoring prohibition from unknown start edge '" + startEdge +
"'");
793 NBEdge* to = myEdgeCont.retrieve(endEdge);
795 WRITE_WARNING(
"Ignoring prohibition from unknown end edge '" + endEdge +
"'");
799 if (fromLane < 0 || fromLane >= from->
getNumLanes()) {
800 WRITE_WARNING(
"Ignoring invalid lane index '" + fromLaneS +
"' in connection from edge '" + startEdge +
"' with " +
toString(from->
getNumLanes()) +
" lanes");
814 const bool warnOnly = st.
size() > 7;
815 myEdgeCont.addPostProcessConnection(from->
getID(), fromLane, to->
getID(), toLane,
false,
true,