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)) {
378 std::set<std::string> types;
380 std::string t = tok.
next();
384 WRITE_WARNING(
"Discarding unknown compound \"" + t +
"\" for edge " +
id +
" with type \"" + type +
"\".");
387 switch (types.size()) {
389 WRITE_WARNING(
"Discarding edge " +
id +
" with type unknown compound type \"" + type +
"\".");
393 type = *(types.begin());
402 bool defaultIsOneWay =
false;
403 for (std::set<std::string>::iterator it = types.begin(); it != types.end(); it++) {
409 WRITE_MESSAGE(
"Adding new compound type \"" + type +
"\" for edge " +
id +
".");
428 bool addForward =
true;
429 bool addBackward =
true;
443 if (addForward && !addBackward) {
445 }
else if (!addForward && addBackward) {
455 numLanesBackward = e->
myNoLanes - numLanesForward;
458 numLanesForward =
MAX2(1, numLanesForward);
459 numLanesBackward =
MAX2(1, numLanesBackward);
462 WRITE_WARNING(
"Skipping edge '" +
id +
"' because it has zero lanes.");
476 assert(numLanesForward > 0);
487 assert(numLanesBackward > 0);
505 std::map<SUMOLong, NIOSMNode*>& toFill,
506 std::set<NIOSMNode*, CompareNodes>& uniqueNodes) :
510 myIsInValidNodeTag(false),
512 myUniqueNodes(uniqueNodes) {
524 if (myHierarchyLevel != 2) {
530 if (action ==
"delete") {
537 if (myToFill.find(
id) == myToFill.end()) {
562 myIsInValidNodeTag =
true;
564 std::set<NIOSMNode*, CompareNodes>::iterator similarNode =
myUniqueNodes.find(toAdd);
569 toAdd = *similarNode;
572 myToFill[id] = toAdd;
576 if (myHierarchyLevel != 3) {
577 WRITE_ERROR(
"Tag element on wrong XML hierarchy level.");
586 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos) {
587 myToFill[myLastNodeID]->tlsControlled =
true;
597 myIsInValidNodeTag =
false;
607 const std::map<SUMOLong, NIOSMNode*>& osmNodes,
608 std::map<SUMOLong, Edge*>& toFill) :
630 myParentElements.push_back(element);
636 if (action ==
"delete") {
644 myCurrentEdge =
new Edge(
id);
651 std::map<SUMOLong, NIOSMNode*>::const_iterator node =
myOSMNodes.find(ref);
656 ref = node->second->id;
657 if (myCurrentEdge->myCurrentNodes.size() == 0 ||
658 myCurrentEdge->myCurrentNodes.back() != ref) {
659 myCurrentEdge->myCurrentNodes.push_back(ref);
665 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY) {
666 if (myCurrentEdge == 0) {
675 if (key ==
"highway" || key ==
"railway") {
676 if (myCurrentEdge->myHighWayType !=
"") {
679 myCurrentEdge->myHighWayType = myCurrentEdge->myHighWayType +
compoundTypeSeparator + key +
"." + value;
681 myCurrentEdge->myHighWayType = key +
"." + value;
683 myCurrentEdge->myCurrentIsRoad =
true;
684 }
else if (key ==
"lanes") {
690 std::vector<std::string> list = st.
getVector();
691 if (list.size() >= 2) {
694 for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); ++i) {
696 minLanes =
MIN2(minLanes, numLanes);
698 myCurrentEdge->myNoLanes = minLanes;
699 WRITE_WARNING(
"Using minimum lane number from list (" + value +
") for edge '" +
toString(myCurrentEdge->id) +
"'.");
701 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
702 toString(myCurrentEdge->id) +
"'.");
706 }
else if (key ==
"lanes:forward") {
710 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
711 toString(myCurrentEdge->id) +
"'.");
713 }
else if (key ==
"lanes:backward") {
718 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
719 toString(myCurrentEdge->id) +
"'.");
721 }
else if (key ==
"maxspeed") {
722 if (mySpeedMap.find(value) != mySpeedMap.end()) {
723 myCurrentEdge->myMaxSpeed = mySpeedMap[value];
730 conversion = 1.609344;
735 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
736 toString(myCurrentEdge->id) +
"'.");
739 }
else if (key ==
"junction") {
740 if ((value ==
"roundabout") && (myCurrentEdge->myIsOneWay ==
"")) {
741 myCurrentEdge->myIsOneWay =
"yes";
743 }
else if (key ==
"oneway") {
744 myCurrentEdge->myIsOneWay = value;
745 }
else if (key ==
"name") {
746 myCurrentEdge->streetName = value;
747 }
else if (key ==
"tracks") {
749 myCurrentEdge->myIsOneWay =
"false";
751 myCurrentEdge->myIsOneWay =
"true";
760 myParentElements.pop_back();
762 if (myCurrentEdge != 0 && myCurrentEdge->myCurrentIsRoad) {
763 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
765 delete myCurrentEdge;
776 const std::map<SUMOLong, NIOSMNode*>& osmNodes,
777 const std::map<SUMOLong, Edge*>& osmEdges) :
780 myOSMEdges(osmEdges) {
791 myIsRestriction =
false;
796 myRestrictionType = RESTRICTION_UNKNOWN;
802 myParentElements.push_back(element);
808 if (action ==
"delete" || !ok) {
823 if (memberType ==
"way" && checkEdgeRef(ref)) {
825 }
else if (memberType ==
"node") {
832 }
else if (role ==
"from" && checkEdgeRef(ref)) {
834 }
else if (role ==
"to" && checkEdgeRef(ref)) {
847 if (key ==
"type" && value ==
"restriction") {
848 myIsRestriction =
true;
851 if (key ==
"restriction") {
852 if (value.substr(0, 5) ==
"only_") {
853 myRestrictionType = RESTRICTION_ONLY;
854 }
else if (value.substr(0, 3) ==
"no_") {
855 myRestrictionType = RESTRICTION_NO;
857 WRITE_WARNING(
"Found unknown restriction type '" + value +
"' in relation '" +
toString(myCurrentRelation) +
"'");
867 if (myOSMEdges.find(ref) != myOSMEdges.end()) {
878 myParentElements.pop_back();
880 if (myIsRestriction) {
883 if (myRestrictionType == RESTRICTION_UNKNOWN) {
884 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown type.");
888 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown from-way.");
892 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown to-way.");
896 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown via.");
899 if (ok && !applyRestriction()) {
921 WRITE_WARNING(
"from-edge of restriction relation could not be determined");
925 WRITE_WARNING(
"to-edge of restriction relation could not be determined");
928 if (myRestrictionType == RESTRICTION_ONLY) {
935 WRITE_WARNING(
"direction of restriction relation could not be determined");
944 const std::string prefix =
toString(wayRef);
945 const std::string backPrefix =
"-" + prefix;
948 for (EdgeVector::const_iterator it = candidates.begin(); it != candidates.end(); ++it) {
949 if (((*it)->getID().substr(0, prefix.size()) == prefix) ||
950 ((*it)->getID().substr(0, backPrefix.size()) == backPrefix)) {
956 WRITE_WARNING(
"Ambigous way reference '" + prefix +
"' in restriction relation");