60 #ifdef CHECK_MEMORY_LEAKS
62 #endif // CHECK_MEMORY_LEAKS
111 importer.
load(oc, nb);
124 for (std::map<SUMOLong, Edge*>::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
133 if (!oc.
isSet(
"osm-files")) {
143 tc.
insert(
"highway.trunk_link", 1, (
SUMOReal)(80. / 3.6), 10, WIDTH);
144 tc.
insert(
"highway.primary", 2, (
SUMOReal)(100. / 3.6), 9, WIDTH);
145 tc.
insert(
"highway.primary_link", 1, (
SUMOReal)(80. / 3.6), 8, WIDTH);
146 tc.
insert(
"highway.secondary", 2, (
SUMOReal)(100. / 3.6), 7, WIDTH);
147 tc.
insert(
"highway.secondary_link", 1, (
SUMOReal)(80. / 3.6), 6, WIDTH);
148 tc.
insert(
"highway.tertiary", 1, (
SUMOReal)(80. / 3.6), 6, WIDTH);
149 tc.
insert(
"highway.tertiary_link", 1, (
SUMOReal)(80. / 3.6), 5, WIDTH);
150 tc.
insert(
"highway.unclassified", 1, (
SUMOReal)(80. / 3.6), 5, WIDTH);
151 tc.
insert(
"highway.residential", 1, (
SUMOReal)(50. / 3.6), 4, WIDTH);
152 tc.
insert(
"highway.living_street", 1, (
SUMOReal)(10. / 3.6), 3, WIDTH);
155 tc.
insert(
"highway.services", 1, (
SUMOReal)(30. / 3.6), 1, WIDTH);
156 tc.
insert(
"highway.unsurfaced", 1, (
SUMOReal)(30. / 3.6), 1, WIDTH);
186 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
189 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
201 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
213 std::set<const Edge*, CompareEdges> dupsFinder;
214 for (std::map<SUMOLong, Edge*>::iterator it =
myEdges.begin(); it !=
myEdges.end();) {
215 if (dupsFinder.count(it->second) > 0) {
220 dupsFinder.insert(it->second);
231 std::map<SUMOLong, int> nodeUsage;
233 for (std::map<SUMOLong, Edge*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
234 Edge* e = (*i).second;
237 if (nodeUsage.find(*j) == nodeUsage.end()) {
240 nodeUsage[*j] = nodeUsage[*j] + 1;
244 for (std::map<SUMOLong, NIOSMNode*>::const_iterator nodesIt =
myOSMNodes.begin(); nodesIt !=
myOSMNodes.end(); ++nodesIt) {
245 if (nodesIt->second->tlsControlled) {
248 nodeUsage[nodesIt->first] += 1;
256 for (std::map<SUMOLong, Edge*>::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
257 Edge* e = (*i).second;
270 std::vector<SUMOLong> passed;
272 passed.push_back(*j);
275 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb);
276 currentFrom = currentTo;
283 insertEdge(e, running, currentFrom, last, passed, nb);
288 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
321 if (!tlsc.
insert(tlDef)) {
334 const std::vector<SUMOLong>& passed,
NBNetBuilder& nb) {
341 if (from == 0 || to == 0) {
342 WRITE_ERROR(
"Discarding edge " +
id +
" because the nodes could not be built.");
352 assert(passed.size() >= 2);
353 std::vector<SUMOLong> geom(passed);
356 index =
insertEdge(e, index, from, intermediate, geom, nb);
358 return insertEdge(e, index, intermediate, to, geom, nb);
360 const int newIndex = index + 1;
364 for (std::vector<SUMOLong>::const_iterator i = passed.begin(); i != passed.end(); ++i) {
368 WRITE_ERROR(
"Unable to project coordinates for edge " +
id +
".");
374 if (!tc.
knows(type)) {
382 std::vector<std::string> types;
384 std::string t = tok.
next();
386 if (std::find(types.begin(), types.end(), t) == types.end()) {
389 }
else if (tok.
size() > 1) {
390 WRITE_WARNING(
"Discarding unknown compound \"" + t +
"\" in type \"" + type +
"\" (first occurence for edge \"" +
id +
"\").");
393 if (types.size() == 0) {
394 WRITE_WARNING(
"Discarding unusable type \"" + type +
"\" (first occurence for edge \"" +
id +
"\").");
399 if (tc.
knows(newType)) {
410 bool defaultIsOneWay =
false;
412 for (std::vector<std::string>::iterator it = types.begin(); it != types.end(); it++) {
419 WRITE_MESSAGE(
"Adding new type \"" + type +
"\" (first occurence for edge \"" +
id +
"\").");
420 tc.
insert(newType, numLanes, maxSpeed, prio, permissions, width, defaultIsOneWay);
436 bool addForward =
true;
437 bool addBackward =
true;
451 if (addForward && !addBackward) {
453 }
else if (!addForward && addBackward) {
463 numLanesBackward = e->
myNoLanes - numLanesForward;
466 numLanesForward =
MAX2(1, numLanesForward);
467 numLanesBackward =
MAX2(1, numLanesBackward);
470 WRITE_WARNING(
"Skipping edge '" +
id +
"' because it has zero lanes.");
484 assert(numLanesForward > 0);
495 assert(numLanesBackward > 0);
513 std::map<SUMOLong, NIOSMNode*>& toFill,
514 std::set<NIOSMNode*, CompareNodes>& uniqueNodes) :
518 myIsInValidNodeTag(false),
520 myUniqueNodes(uniqueNodes) {
532 if (myHierarchyLevel != 2) {
538 if (action ==
"delete") {
545 if (myToFill.find(
id) == myToFill.end()) {
570 myIsInValidNodeTag =
true;
572 std::set<NIOSMNode*, CompareNodes>::iterator similarNode =
myUniqueNodes.find(toAdd);
577 toAdd = *similarNode;
580 myToFill[id] = toAdd;
584 if (myHierarchyLevel != 3) {
585 WRITE_ERROR(
"Tag element on wrong XML hierarchy level.");
591 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos) {
592 myToFill[myLastNodeID]->tlsControlled =
true;
602 myIsInValidNodeTag =
false;
612 const std::map<SUMOLong, NIOSMNode*>& osmNodes,
613 std::map<SUMOLong, Edge*>& toFill) :
635 myParentElements.push_back(element);
641 if (action ==
"delete") {
649 myCurrentEdge =
new Edge(
id);
656 std::map<SUMOLong, NIOSMNode*>::const_iterator node =
myOSMNodes.find(ref);
661 ref = node->second->id;
662 if (myCurrentEdge->myCurrentNodes.size() == 0 ||
663 myCurrentEdge->myCurrentNodes.back() != ref) {
664 myCurrentEdge->myCurrentNodes.push_back(ref);
670 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY) {
671 if (myCurrentEdge == 0) {
678 if (key ==
"highway" || key ==
"railway") {
679 if (myCurrentEdge->myHighWayType !=
"") {
682 myCurrentEdge->myHighWayType = myCurrentEdge->myHighWayType +
compoundTypeSeparator + key +
"." + value;
684 myCurrentEdge->myHighWayType = key +
"." + value;
686 myCurrentEdge->myCurrentIsRoad =
true;
687 }
else if (key ==
"lanes") {
693 std::vector<std::string> list = st.
getVector();
694 if (list.size() >= 2) {
697 for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); ++i) {
699 minLanes =
MIN2(minLanes, numLanes);
701 myCurrentEdge->myNoLanes = minLanes;
702 WRITE_WARNING(
"Using minimum lane number from list (" + value +
") for edge '" +
toString(myCurrentEdge->id) +
"'.");
704 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
705 toString(myCurrentEdge->id) +
"'.");
709 }
else if (key ==
"lanes:forward") {
713 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
714 toString(myCurrentEdge->id) +
"'.");
716 }
else if (key ==
"lanes:backward") {
721 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
722 toString(myCurrentEdge->id) +
"'.");
724 }
else if (key ==
"maxspeed") {
725 if (mySpeedMap.find(value) != mySpeedMap.end()) {
726 myCurrentEdge->myMaxSpeed = mySpeedMap[value];
733 conversion = 1.609344;
738 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
739 toString(myCurrentEdge->id) +
"'.");
742 }
else if (key ==
"junction") {
743 if ((value ==
"roundabout") && (myCurrentEdge->myIsOneWay ==
"")) {
744 myCurrentEdge->myIsOneWay =
"yes";
746 }
else if (key ==
"oneway") {
747 myCurrentEdge->myIsOneWay = value;
748 }
else if (key ==
"name") {
749 myCurrentEdge->streetName = value;
750 }
else if (key ==
"tracks") {
753 myCurrentEdge->myIsOneWay =
"false";
755 myCurrentEdge->myIsOneWay =
"true";
758 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
759 toString(myCurrentEdge->id) +
"'.");
768 myParentElements.pop_back();
770 if (myCurrentEdge != 0 && myCurrentEdge->myCurrentIsRoad) {
771 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
773 delete myCurrentEdge;
784 const std::map<SUMOLong, NIOSMNode*>& osmNodes,
785 const std::map<SUMOLong, Edge*>& osmEdges) :
788 myOSMEdges(osmEdges) {
799 myIsRestriction =
false;
804 myRestrictionType = RESTRICTION_UNKNOWN;
810 myParentElements.push_back(element);
816 if (action ==
"delete" || !ok) {
831 if (memberType ==
"way" && checkEdgeRef(ref)) {
833 }
else if (memberType ==
"node") {
840 }
else if (role ==
"from" && checkEdgeRef(ref)) {
842 }
else if (role ==
"to" && checkEdgeRef(ref)) {
853 if (key ==
"type" && value ==
"restriction") {
854 myIsRestriction =
true;
857 if (key ==
"restriction") {
858 if (value.substr(0, 5) ==
"only_") {
859 myRestrictionType = RESTRICTION_ONLY;
860 }
else if (value.substr(0, 3) ==
"no_") {
861 myRestrictionType = RESTRICTION_NO;
863 WRITE_WARNING(
"Found unknown restriction type '" + value +
"' in relation '" +
toString(myCurrentRelation) +
"'");
873 if (myOSMEdges.find(ref) != myOSMEdges.end()) {
884 myParentElements.pop_back();
886 if (myIsRestriction) {
889 if (myRestrictionType == RESTRICTION_UNKNOWN) {
890 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown type.");
894 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown from-way.");
898 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown to-way.");
902 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown via.");
905 if (ok && !applyRestriction()) {
927 WRITE_WARNING(
"from-edge of restriction relation could not be determined");
931 WRITE_WARNING(
"to-edge of restriction relation could not be determined");
934 if (myRestrictionType == RESTRICTION_ONLY) {
941 WRITE_WARNING(
"direction of restriction relation could not be determined");
950 const std::string prefix =
toString(wayRef);
951 const std::string backPrefix =
"-" + prefix;
954 for (EdgeVector::const_iterator it = candidates.begin(); it != candidates.end(); ++it) {
955 if (((*it)->getID().substr(0, prefix.size()) == prefix) ||
956 ((*it)->getID().substr(0, backPrefix.size()) == backPrefix)) {
962 WRITE_WARNING(
"Ambigous way reference '" + prefix +
"' in restriction relation");