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);
140 tc.
insert(
"highway.primary", 2, (
SUMOReal)(100. / 3.6), 9, 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<SUMOLong, 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<SUMOLong, NIOSMNode*>::const_iterator nodesIt =
myOSMNodes.begin(); nodesIt !=
myOSMNodes.end(); ++nodesIt) {
240 if (nodesIt->second->tlsControlled) {
243 nodeUsage[nodesIt->first] += 1;
251 for (std::map<std::string, Edge*>::iterator i =
myEdges.begin(); i !=
myEdges.end(); ++i) {
252 Edge* e = (*i).second;
264 std::vector<SUMOLong> passed;
266 passed.push_back(*j);
269 running =
insertEdge(e, running, currentFrom, currentTo, passed, nb);
270 currentFrom = currentTo;
277 insertEdge(e, running, currentFrom, last, passed, nb);
303 if (!tlsc.
insert(tlDef)) {
316 const std::vector<SUMOLong>& passed,
NBNetBuilder& nb) {
323 std::string
id = e->
id;
331 assert(passed.size() >= 2);
332 std::vector<SUMOLong> geom(passed);
335 index =
insertEdge(e, index, from, intermediate, geom, nb);
337 return insertEdge(e, index, intermediate, to, geom, nb);
339 const int newIndex = index + 1;
343 for (std::vector<SUMOLong>::const_iterator i = passed.begin(); i != passed.end(); ++i) {
347 throw ProcessError(
"Unable to project coordinates for edge " +
id +
".");
353 if (!tc.
knows(type)) {
357 std::set<std::string> types;
359 std::string t = tok.
next();
363 WRITE_WARNING(
"Discarding unknown compound \"" + t +
"\" for edge " +
id +
" with type \"" + type +
"\".");
366 switch (types.size()) {
368 WRITE_WARNING(
"Discarding edge " +
id +
" with type unknown compound type \"" + type +
"\".");
372 type = *(types.begin());
381 bool defaultIsOneWay =
false;
382 for (std::set<std::string>::iterator it = types.begin(); it != types.end(); it++) {
388 WRITE_MESSAGE(
"Adding new compound type \"" + type +
"\" for edge " +
id +
".");
405 bool addSecond =
true;
422 if (noLanes != 0 && speed != 0) {
445 throw ProcessError(
"Could not add edge '-" +
id +
"'.");
457 std::map<SUMOLong, NIOSMNode*>& toFill,
458 std::set<NIOSMNode*, CompareNodes>& uniqueNodes) :
462 myIsInValidNodeTag(false),
464 myUniqueNodes(uniqueNodes) {
476 if (myHierarchyLevel != 2) {
482 if (action ==
"delete") {
489 if (myToFill.find(
id) == myToFill.end()) {
518 myIsInValidNodeTag =
true;
520 std::set<NIOSMNode*, CompareNodes>::iterator similarNode =
myUniqueNodes.find(toAdd);
525 toAdd = *similarNode;
528 myToFill[id] = toAdd;
532 if (myHierarchyLevel != 3) {
533 WRITE_ERROR(
"Tag element on wrong XML hierarchy level.");
543 myToFill[myLastNodeID]->tlsControlled =
true;
553 myIsInValidNodeTag =
false;
563 const std::map<SUMOLong, NIOSMNode*>& osmNodes,
564 std::map<std::string, Edge*>& toFill)
585 myParentElements.push_back(element);
591 if (action ==
"delete") {
599 myCurrentEdge =
new Edge();
600 myCurrentEdge->id = id;
601 myCurrentEdge->myNoLanes = -1;
603 myCurrentEdge->myCurrentIsRoad =
false;
610 std::map<SUMOLong, NIOSMNode*>::const_iterator node =
myOSMNodes.find(ref);
615 ref = node->second->id;
616 if (myCurrentEdge->myCurrentNodes.size() == 0 ||
617 myCurrentEdge->myCurrentNodes.back() != ref) {
618 myCurrentEdge->myCurrentNodes.push_back(ref);
624 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY) {
625 if (myCurrentEdge == 0) {
634 if (key ==
"highway" || key ==
"railway") {
635 if (myCurrentEdge->myHighWayType !=
"") {
638 myCurrentEdge->myHighWayType = myCurrentEdge->myHighWayType +
compoundTypeSeparator + key +
"." + value;
640 myCurrentEdge->myHighWayType = key +
"." + value;
642 myCurrentEdge->myCurrentIsRoad =
true;
643 }
else if (key ==
"lanes") {
649 std::vector<std::string> list = st.
getVector();
650 if (list.size() >= 2) {
653 for (std::vector<std::string>::iterator i = list.begin(); i != list.end(); ++i) {
655 minLanes =
MIN2(minLanes, numLanes);
657 myCurrentEdge->myNoLanes = minLanes;
658 WRITE_WARNING(
"Using minimum lane number from list (" + value +
") for edge '" + myCurrentEdge->id +
"'.");
660 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" + myCurrentEdge->id +
"'.");
664 }
else if (key ==
"maxspeed") {
665 if (mySpeedMap.find(value) != mySpeedMap.end()) {
666 myCurrentEdge->myMaxSpeed = mySpeedMap[value];
673 conversion = 1.609344;
678 WRITE_WARNING(
"Value of key '" + key +
"' is not numeric ('" + value +
"') in edge '" + myCurrentEdge->id +
"'.");
681 }
else if (key ==
"junction") {
682 if ((value ==
"roundabout") && (myCurrentEdge->myIsOneWay ==
"")) {
683 myCurrentEdge->myIsOneWay =
"yes";
685 }
else if (key ==
"oneway") {
686 myCurrentEdge->myIsOneWay = value;
687 }
else if (key ==
"name") {
688 myCurrentEdge->streetName = value;
696 myParentElements.pop_back();
698 if (myCurrentEdge != 0 && myCurrentEdge->myCurrentIsRoad) {
699 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
701 delete myCurrentEdge;