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);
185 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
188 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
200 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
212 std::set<const Edge*, CompareEdges> dupsFinder;
213 for (std::map<SUMOLong, Edge*>::iterator it =
myEdges.begin(); it !=
myEdges.end();) {
214 if (dupsFinder.count(it->second) > 0) {
219 dupsFinder.insert(it->second);
230 std::map<SUMOLong, int> nodeUsage;
232 for (std::map<SUMOLong, Edge*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
233 Edge* e = (*i).second;
236 if (nodeUsage.find(*j) == nodeUsage.end()) {
239 nodeUsage[*j] = nodeUsage[*j] + 1;
243 for (std::map<SUMOLong, NIOSMNode*>::const_iterator nodesIt =
myOSMNodes.begin(); nodesIt !=
myOSMNodes.end(); ++nodesIt) {
244 if (nodesIt->second->tlsControlled) {
247 nodeUsage[nodesIt->first] += 1;
255 for (std::map<SUMOLong, Edge*>::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
256 Edge* e = (*i).second;
269 std::vector<SUMOLong> passed;
271 passed.push_back(*j);
274 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb);
275 currentFrom = currentTo;
282 insertEdge(e, running, currentFrom, last, passed, nb);
287 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
320 if (!tlsc.
insert(tlDef)) {
333 const std::vector<SUMOLong>& passed,
NBNetBuilder& nb) {
340 if (from == 0 || to == 0) {
341 WRITE_ERROR(
"Discarding edge " +
id +
" because the nodes could not be built.");
351 assert(passed.size() >= 2);
352 std::vector<SUMOLong> geom(passed);
355 index =
insertEdge(e, index, from, intermediate, geom, nb);
357 return insertEdge(e, index, intermediate, to, geom, nb);
359 const int newIndex = index + 1;
363 for (std::vector<SUMOLong>::const_iterator i = passed.begin(); i != passed.end(); ++i) {
367 WRITE_ERROR(
"Unable to project coordinates for edge " +
id +
".");
373 if (!tc.
knows(type)) {
377 std::set<std::string> types;
379 std::string t = tok.
next();
383 WRITE_WARNING(
"Discarding unknown compound \"" + t +
"\" for edge " +
id +
" with type \"" + type +
"\".");
386 switch (types.size()) {
388 WRITE_WARNING(
"Discarding edge " +
id +
" with type unknown compound type \"" + type +
"\".");
392 type = *(types.begin());
401 bool defaultIsOneWay =
false;
402 for (std::set<std::string>::iterator it = types.begin(); it != types.end(); it++) {
408 WRITE_MESSAGE(
"Adding new compound type \"" + type +
"\" for edge " +
id +
".");
427 bool addForward =
true;
428 bool addBackward =
true;
442 if (addForward && !addBackward) {
444 }
else if (!addForward && addBackward) {
454 numLanesBackward = e->
myNoLanes - numLanesForward;
457 numLanesForward =
MAX2(1, numLanesForward);
458 numLanesBackward =
MAX2(1, numLanesBackward);
461 WRITE_WARNING(
"Skipping edge '" +
id +
"' because it has zero lanes.");
475 assert(numLanesForward > 0);
486 assert(numLanesBackward > 0);
504 std::map<SUMOLong, NIOSMNode*>& toFill,
505 std::set<NIOSMNode*, CompareNodes>& uniqueNodes) :
509 myIsInValidNodeTag(false),
511 myUniqueNodes(uniqueNodes) {
523 if (myHierarchyLevel != 2) {
529 if (action ==
"delete") {
536 if (myToFill.find(
id) == myToFill.end()) {
561 myIsInValidNodeTag =
true;
563 std::set<NIOSMNode*, CompareNodes>::iterator similarNode =
myUniqueNodes.find(toAdd);
568 toAdd = *similarNode;
571 myToFill[id] = toAdd;
575 if (myHierarchyLevel != 3) {
576 WRITE_ERROR(
"Tag element on wrong XML hierarchy level.");
585 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos) {
586 myToFill[myLastNodeID]->tlsControlled =
true;
596 myIsInValidNodeTag =
false;
606 const std::map<SUMOLong, NIOSMNode*>& osmNodes,
607 std::map<SUMOLong, Edge*>& toFill) :
629 myParentElements.push_back(element);
635 if (action ==
"delete") {
643 myCurrentEdge =
new Edge(
id);
650 std::map<SUMOLong, NIOSMNode*>::const_iterator node =
myOSMNodes.find(ref);
655 ref = node->second->id;
656 if (myCurrentEdge->myCurrentNodes.size() == 0 ||
657 myCurrentEdge->myCurrentNodes.back() != ref) {
658 myCurrentEdge->myCurrentNodes.push_back(ref);
664 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY) {
665 if (myCurrentEdge == 0) {
674 if (key ==
"highway" || key ==
"railway") {
675 if (myCurrentEdge->myHighWayType !=
"") {
678 myCurrentEdge->myHighWayType = myCurrentEdge->myHighWayType +
compoundTypeSeparator + key +
"." + value;
680 myCurrentEdge->myHighWayType = key +
"." + value;
682 myCurrentEdge->myCurrentIsRoad =
true;
683 }
else if (key ==
"lanes") {
689 std::vector<std::string> list = st.
getVector();
690 if (list.size() >= 2) {
693 for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); ++i) {
695 minLanes =
MIN2(minLanes, numLanes);
697 myCurrentEdge->myNoLanes = minLanes;
698 WRITE_WARNING(
"Using minimum lane number from list (" + value +
") for edge '" +
toString(myCurrentEdge->id) +
"'.");
700 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
701 toString(myCurrentEdge->id) +
"'.");
705 }
else if (key ==
"lanes:forward") {
709 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
710 toString(myCurrentEdge->id) +
"'.");
712 }
else if (key ==
"lanes:backward") {
717 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
718 toString(myCurrentEdge->id) +
"'.");
720 }
else if (key ==
"maxspeed") {
721 if (mySpeedMap.find(value) != mySpeedMap.end()) {
722 myCurrentEdge->myMaxSpeed = mySpeedMap[value];
729 conversion = 1.609344;
734 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
735 toString(myCurrentEdge->id) +
"'.");
738 }
else if (key ==
"junction") {
739 if ((value ==
"roundabout") && (myCurrentEdge->myIsOneWay ==
"")) {
740 myCurrentEdge->myIsOneWay =
"yes";
742 }
else if (key ==
"oneway") {
743 myCurrentEdge->myIsOneWay = value;
744 }
else if (key ==
"name") {
745 myCurrentEdge->streetName = value;
753 myParentElements.pop_back();
755 if (myCurrentEdge != 0 && myCurrentEdge->myCurrentIsRoad) {
756 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
758 delete myCurrentEdge;
769 const std::map<SUMOLong, NIOSMNode*>& osmNodes,
770 const std::map<SUMOLong, Edge*>& osmEdges) :
773 myOSMEdges(osmEdges) {
784 myIsRestriction =
false;
789 myRestrictionType = RESTRICTION_UNKNOWN;
795 myParentElements.push_back(element);
801 if (action ==
"delete" || !ok) {
816 if (memberType ==
"way" && checkEdgeRef(ref)) {
818 }
else if (memberType ==
"node") {
825 }
else if (role ==
"from" && checkEdgeRef(ref)) {
827 }
else if (role ==
"to" && checkEdgeRef(ref)) {
840 if (key ==
"type" && value ==
"restriction") {
841 myIsRestriction =
true;
844 if (key ==
"restriction") {
845 if (value.substr(0, 5) ==
"only_") {
846 myRestrictionType = RESTRICTION_ONLY;
847 }
else if (value.substr(0, 3) ==
"no_") {
848 myRestrictionType = RESTRICTION_NO;
850 WRITE_WARNING(
"Found unknown restriction type '" + value +
"' in relation '" +
toString(myCurrentRelation) +
"'");
860 if (myOSMEdges.find(ref) != myOSMEdges.end()) {
871 myParentElements.pop_back();
873 if (myIsRestriction) {
876 if (myRestrictionType == RESTRICTION_UNKNOWN) {
877 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown type.");
881 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown from-way.");
885 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown to-way.");
889 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown via.");
892 if (ok && !applyRestriction()) {
914 WRITE_WARNING(
"from-edge of restriction relation could not be determined");
918 WRITE_WARNING(
"to-edge of restriction relation could not be determined");
921 if (myRestrictionType == RESTRICTION_ONLY) {
928 WRITE_WARNING(
"direction of restriction relation could not be determined");
937 const std::string prefix =
toString(wayRef);
938 const std::string backPrefix =
"-" + prefix;
941 for (EdgeVector::const_iterator it = candidates.begin(); it != candidates.end(); ++it) {
942 if (((*it)->getID().substr(0, prefix.size()) == prefix) ||
943 ((*it)->getID().substr(0, backPrefix.size()) == backPrefix)) {
949 WRITE_WARNING(
"Ambigous way reference '" + prefix +
"' in restriction relation");