60 #ifdef CHECK_MEMORY_LEAKS
62 #endif // CHECK_MEMORY_LEAKS
107 importer.
load(oc, nb);
120 for (std::map<std::string, Edge*>::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
129 if (!oc.
isSet(
"osm-files")) {
139 tc.
insert(
"highway.trunk_link", 1, (
SUMOReal)(80. / 3.6), 10, WIDTH);
141 tc.
insert(
"highway.primary_link", 1, (
SUMOReal)(80. / 3.6), 8, WIDTH);
142 tc.
insert(
"highway.secondary", 2, (
SUMOReal)(100./ 3.6), 7, WIDTH);
143 tc.
insert(
"highway.secondary_link",1, (
SUMOReal)(80. / 3.6), 6, WIDTH);
144 tc.
insert(
"highway.tertiary", 1, (
SUMOReal)(80. / 3.6), 6, WIDTH);
145 tc.
insert(
"highway.tertiary_link", 1, (
SUMOReal)(80. / 3.6), 5, WIDTH);
146 tc.
insert(
"highway.unclassified", 1, (
SUMOReal)(80. / 3.6), 5, WIDTH);
147 tc.
insert(
"highway.residential", 1, (
SUMOReal)(50. / 3.6), 4, WIDTH);
148 tc.
insert(
"highway.living_street", 1, (
SUMOReal)(10. / 3.6), 3, WIDTH);
151 tc.
insert(
"highway.services", 1, (
SUMOReal)(30. / 3.6), 1, WIDTH);
152 tc.
insert(
"highway.unsurfaced", 1, (
SUMOReal)(30. / 3.6), 1, WIDTH);
181 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
184 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
196 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
208 std::set<const Edge*, CompareEdges> dupsFinder;
209 for (std::map<std::string, Edge*>::iterator it =
myEdges.begin(); it !=
myEdges.end();) {
210 if (dupsFinder.count(it->second) > 0) {
211 WRITE_MESSAGE(
"Found duplicate edges. Removing " + it->first);
215 dupsFinder.insert(it->second);
226 std::map<long, int> nodeUsage;
228 for (std::map<std::string, Edge*>::const_iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
229 Edge* e = (*i).second;
232 if (nodeUsage.find(*j) == nodeUsage.end()) {
235 nodeUsage[*j] = nodeUsage[*j] + 1;
239 for (std::map<long, NIOSMNode*>::const_iterator nodesIt =
myOSMNodes.begin(); nodesIt !=
myOSMNodes.end(); ++nodesIt) {
240 if (nodesIt->second->tlsControlled) {
243 nodeUsage[nodesIt->first] += 1;
252 for (std::map<std::string, Edge*>::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
253 Edge* e = (*i).second;
265 std::vector<long> passed;
267 passed.push_back(*j);
270 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb);
271 currentFrom = currentTo;
278 insertEdge(e, running, currentFrom, last, passed, nb);
304 if (!tlsc.
insert(tlDef)) {
324 std::string
id = e->
id;
332 assert(passed.size() >= 2);
333 std::vector<long> geom(passed);
336 index =
insertEdge(e, index, from, intermediate, geom, nb);
338 return insertEdge(e, index, intermediate, to, geom, nb);
340 const int newIndex = index + 1;
344 for (std::vector<long>::const_iterator i = passed.begin(); i != passed.end(); ++i) {
348 throw ProcessError(
"Unable to project coordinates for edge " +
id +
".");
354 if (!tc.
knows(type)) {
358 std::set<std::string> types;
360 std::string t = tok.
next();
364 WRITE_WARNING(
"Discarding unknown compound \"" + t +
"\" for edge " +
id +
" with type \"" + type +
"\".");
367 switch (types.size()) {
369 WRITE_WARNING(
"Discarding edge " +
id +
" with type unknown compound type \"" + type +
"\".");
373 type = *(types.begin());
382 bool defaultIsOneWay =
false;
383 for (std::set<std::string>::iterator it = types.begin(); it != types.end(); it++) {
389 WRITE_MESSAGE(
"Adding new compound type \"" + type +
"\" for edge " +
id +
".");
406 bool addSecond =
true;
423 if (noLanes != 0 && speed != 0) {
446 throw ProcessError(
"Could not add edge '-" +
id +
"'.");
458 std::map<long, NIOSMNode*> &toFill,
459 std::set<NIOSMNode*, CompareNodes> &uniqueNodes) :
462 myUniqueNodes(uniqueNodes),
464 myIsInValidNodeTag(false),
465 myHierarchyLevel(0) {
477 if (myHierarchyLevel != 2) {
483 if (action ==
"delete") {
490 if (myToFill.find(
id) == myToFill.end()) {
519 myIsInValidNodeTag =
true;
521 std::set<NIOSMNode*, CompareNodes>::iterator similarNode =
myUniqueNodes.find(toAdd);
526 toAdd = *similarNode;
529 myToFill[id] = toAdd;
533 if (myHierarchyLevel != 3) {
534 WRITE_ERROR(
"Tag element on wrong XML hierarchy level.");
543 if (key ==
"highway" && value.find(
"traffic_signal") != std::string::npos &&
545 myToFill[myLastNodeID]->tlsControlled =
true;
555 myIsInValidNodeTag =
false;
565 const std::map<long, NIOSMNode*> &osmNodes,
566 std::map<std::string, Edge*> &toFill)
587 myParentElements.push_back(element);
593 if (action ==
"delete") {
601 myCurrentEdge =
new Edge();
602 myCurrentEdge->id = id;
603 myCurrentEdge->myNoLanes = -1;
605 myCurrentEdge->myCurrentIsRoad =
false;
612 std::map<long, NIOSMNode*>::const_iterator node =
myOSMNodes.find(ref);
617 ref = node->second->id;
618 if (myCurrentEdge->myCurrentNodes.size() == 0 ||
619 myCurrentEdge->myCurrentNodes.back() != ref) {
620 myCurrentEdge->myCurrentNodes.push_back(ref);
626 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY) {
627 if (myCurrentEdge == 0) {
636 if (key ==
"highway" || key ==
"railway") {
637 if (myCurrentEdge->myHighWayType !=
"") {
640 myCurrentEdge->myHighWayType = myCurrentEdge->myHighWayType +
compoundTypeSeparator + key +
"." + value;
642 myCurrentEdge->myHighWayType = key +
"." + value;
644 myCurrentEdge->myCurrentIsRoad =
true;
645 }
else if (key ==
"lanes") {
651 std::vector<std::string> list = st.
getVector();
652 if (list.size() >= 2) {
655 for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); ++i) {
657 minLanes =
MIN2(minLanes, numLanes);
659 myCurrentEdge->myNoLanes = minLanes;
660 WRITE_WARNING(
"Using minimum lane number from list (" + value +
") for edge '" + myCurrentEdge->id +
"'.");
662 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" + myCurrentEdge->id +
"'.");
666 }
else if (key ==
"maxspeed") {
667 if (mySpeedMap.find(value) != mySpeedMap.end()) {
668 myCurrentEdge->myMaxSpeed = mySpeedMap[value];
675 conversion = 1.609344;
680 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" + myCurrentEdge->id +
"'.");
683 }
else if (key ==
"junction") {
684 if ((value ==
"roundabout") && (myCurrentEdge->myIsOneWay ==
"")) {
685 myCurrentEdge->myIsOneWay =
"yes";
687 }
else if (key ==
"oneway") {
688 myCurrentEdge->myIsOneWay = value;
689 }
else if (key ==
"name") {
690 myCurrentEdge->streetName = value;
698 myParentElements.pop_back();
700 if (myCurrentEdge != 0 && myCurrentEdge->myCurrentIsRoad) {
701 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
703 delete myCurrentEdge;