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);
171 const bool oneWay = oc.
getBool(
"osm.railway.oneway-default");
184 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
187 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
190 nodesHandler.setFileName(*file);
199 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
208 if (!oc.
getBool(
"osm.skip-duplicates-check")) {
211 std::set<const Edge*, CompareEdges> dupsFinder;
212 for (std::map<SUMOLong, Edge*>::iterator it =
myEdges.begin(); it !=
myEdges.end();) {
213 if (dupsFinder.count(it->second) > 0) {
218 dupsFinder.insert(it->second);
229 std::map<SUMOLong, int> nodeUsage;
231 for (std::map<SUMOLong, Edge*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
232 Edge* e = (*i).second;
235 if (nodeUsage.find(*j) == nodeUsage.end()) {
238 nodeUsage[*j] = nodeUsage[*j] + 1;
242 for (std::map<SUMOLong, NIOSMNode*>::const_iterator nodesIt =
myOSMNodes.begin(); nodesIt !=
myOSMNodes.end(); ++nodesIt) {
243 if (nodesIt->second->tlsControlled) {
246 nodeUsage[nodesIt->first] += 1;
254 for (std::map<SUMOLong, Edge*>::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
255 Edge* e = (*i).second;
268 std::vector<SUMOLong> passed;
270 passed.push_back(*j);
273 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb);
274 currentFrom = currentTo;
281 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;
364 for (std::vector<SUMOLong>::const_iterator i = passed.begin(); i != passed.end(); ++i) {
368 WRITE_ERROR(
"Unable to project coordinates for edge " +
id +
".");
375 if (!tc.
knows(type)) {
383 std::vector<std::string> types;
385 std::string t = tok.
next();
387 if (std::find(types.begin(), types.end(), t) == types.end()) {
390 }
else if (tok.
size() > 1) {
391 WRITE_WARNING(
"Discarding unknown compound \"" + t +
"\" in type \"" + type +
"\" (first occurence for edge \"" +
id +
"\").");
394 if (types.size() == 0) {
395 WRITE_WARNING(
"Discarding unusable type \"" + type +
"\" (first occurence for edge \"" +
id +
"\").");
400 if (tc.
knows(newType)) {
412 bool defaultIsOneWay =
false;
414 for (std::vector<std::string>::iterator it = types.begin(); it != types.end(); it++) {
426 WRITE_MESSAGE(
"Adding new type \"" + type +
"\" (first occurence for edge \"" +
id +
"\").");
427 tc.
insert(newType, numLanes, maxSpeed, prio, permissions, width, defaultIsOneWay, sidewalkWidth);
444 bool addForward =
true;
445 bool addBackward =
true;
459 if (addForward && !addBackward) {
461 }
else if (!addForward && addBackward) {
471 numLanesBackward = e->
myNoLanes - numLanesForward;
474 numLanesForward =
MAX2(1, numLanesForward);
475 numLanesBackward =
MAX2(1, numLanesBackward);
478 WRITE_WARNING(
"Skipping edge '" +
id +
"' because it has zero lanes.");
492 assert(numLanesForward > 0);
506 assert(numLanesBackward > 0);
527 std::map<SUMOLong, NIOSMNode*>& toFill,
528 std::set<NIOSMNode*, CompareNodes>& uniqueNodes,
529 bool importElevation) :
533 myIsInValidNodeTag(false),
535 myUniqueNodes(uniqueNodes),
536 myImportElevation(importElevation)
548 if (myHierarchyLevel != 2) {
554 if (action ==
"delete") {
561 if (myToFill.find(
id) == myToFill.end()) {
586 myIsInValidNodeTag =
true;
588 std::set<NIOSMNode*, CompareNodes>::iterator similarNode =
myUniqueNodes.find(toAdd);
593 toAdd = *similarNode;
596 myToFill[id] = toAdd;
600 if (myHierarchyLevel != 3) {
601 WRITE_ERROR(
"Tag element on wrong XML hierarchy level.");
607 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos) {
608 myToFill[myLastNodeID]->tlsControlled =
true;
609 }
else if (myImportElevation && key ==
"ele") {
613 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in node '" +
625 myIsInValidNodeTag =
false;
635 const std::map<SUMOLong, NIOSMNode*>& osmNodes,
636 std::map<SUMOLong, Edge*>& toFill) :
658 myParentElements.push_back(element);
664 if (action ==
"delete") {
672 myCurrentEdge =
new Edge(
id);
679 std::map<SUMOLong, NIOSMNode*>::const_iterator node =
myOSMNodes.find(ref);
684 ref = node->second->id;
685 if (myCurrentEdge->myCurrentNodes.size() == 0 ||
686 myCurrentEdge->myCurrentNodes.back() != ref) {
687 myCurrentEdge->myCurrentNodes.push_back(ref);
693 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY) {
694 if (myCurrentEdge == 0) {
701 if (key ==
"highway" || key ==
"railway") {
702 if (myCurrentEdge->myHighWayType !=
"") {
705 myCurrentEdge->myHighWayType = myCurrentEdge->myHighWayType +
compoundTypeSeparator + key +
"." + value;
707 myCurrentEdge->myHighWayType = key +
"." + value;
709 myCurrentEdge->myCurrentIsRoad =
true;
710 }
else if (key ==
"lanes") {
716 std::vector<std::string> list = st.
getVector();
717 if (list.size() >= 2) {
720 for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); ++i) {
722 minLanes =
MIN2(minLanes, numLanes);
724 myCurrentEdge->myNoLanes = minLanes;
725 WRITE_WARNING(
"Using minimum lane number from list (" + value +
") for edge '" +
toString(myCurrentEdge->id) +
"'.");
727 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
728 toString(myCurrentEdge->id) +
"'.");
732 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
733 toString(myCurrentEdge->id) +
"'.");
735 }
else if (key ==
"lanes:forward") {
739 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
740 toString(myCurrentEdge->id) +
"'.");
742 }
else if (key ==
"lanes:backward") {
747 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
748 toString(myCurrentEdge->id) +
"'.");
750 }
else if (key ==
"maxspeed") {
751 if (mySpeedMap.find(value) != mySpeedMap.end()) {
752 myCurrentEdge->myMaxSpeed = mySpeedMap[value];
759 conversion = 1.609344;
764 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
765 toString(myCurrentEdge->id) +
"'.");
768 }
else if (key ==
"junction") {
769 if ((value ==
"roundabout") && (myCurrentEdge->myIsOneWay ==
"")) {
770 myCurrentEdge->myIsOneWay =
"yes";
772 }
else if (key ==
"oneway") {
773 myCurrentEdge->myIsOneWay = value;
774 }
else if (key ==
"name") {
775 myCurrentEdge->streetName = value;
776 }
else if (key ==
"tracks") {
779 myCurrentEdge->myIsOneWay =
"false";
781 myCurrentEdge->myIsOneWay =
"true";
784 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" +
785 toString(myCurrentEdge->id) +
"'.");
794 myParentElements.pop_back();
796 if (myCurrentEdge != 0 && myCurrentEdge->myCurrentIsRoad) {
797 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
799 delete myCurrentEdge;
810 const std::map<SUMOLong, NIOSMNode*>& osmNodes,
811 const std::map<SUMOLong, Edge*>& osmEdges) :
814 myOSMEdges(osmEdges) {
825 myIsRestriction =
false;
830 myRestrictionType = RESTRICTION_UNKNOWN;
836 myParentElements.push_back(element);
842 if (action ==
"delete" || !ok) {
857 if (memberType ==
"way" && checkEdgeRef(ref)) {
859 }
else if (memberType ==
"node") {
866 }
else if (role ==
"from" && checkEdgeRef(ref)) {
868 }
else if (role ==
"to" && checkEdgeRef(ref)) {
879 if (key ==
"type" && value ==
"restriction") {
880 myIsRestriction =
true;
883 if (key ==
"restriction") {
884 if (value.substr(0, 5) ==
"only_") {
885 myRestrictionType = RESTRICTION_ONLY;
886 }
else if (value.substr(0, 3) ==
"no_") {
887 myRestrictionType = RESTRICTION_NO;
889 WRITE_WARNING(
"Found unknown restriction type '" + value +
"' in relation '" +
toString(myCurrentRelation) +
"'");
899 if (myOSMEdges.find(ref) != myOSMEdges.end()) {
910 myParentElements.pop_back();
912 if (myIsRestriction) {
915 if (myRestrictionType == RESTRICTION_UNKNOWN) {
916 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown type.");
920 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown from-way.");
924 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown to-way.");
928 WRITE_WARNING(
"Ignoring restriction relation '" +
toString(myCurrentRelation) +
"' with unknown via.");
931 if (ok && !applyRestriction()) {
953 WRITE_WARNING(
"from-edge of restriction relation could not be determined");
957 WRITE_WARNING(
"to-edge of restriction relation could not be determined");
960 if (myRestrictionType == RESTRICTION_ONLY) {
967 WRITE_WARNING(
"direction of restriction relation could not be determined");
976 const std::string prefix =
toString(wayRef);
977 const std::string backPrefix =
"-" + prefix;
980 for (EdgeVector::const_iterator it = candidates.begin(); it != candidates.end(); ++it) {
981 if (((*it)->getID().substr(0, prefix.size()) == prefix) ||
982 ((*it)->getID().substr(0, backPrefix.size()) == backPrefix)) {
988 WRITE_WARNING(
"Ambigous way reference '" + prefix +
"' in restriction relation");