55 #ifdef CHECK_MEMORY_LEAKS
57 #endif // CHECK_MEMORY_LEAKS
70 std::set<std::string> result;
71 result.insert(
"highway");
72 result.insert(
"waterway");
73 result.insert(
"aeroway");
74 result.insert(
"aerialway");
75 result.insert(
"power");
76 result.insert(
"man_made");
77 result.insert(
"building");
78 result.insert(
"leisure");
79 result.insert(
"amenity");
80 result.insert(
"shop");
81 result.insert(
"tourism");
82 result.insert(
"historic");
83 result.insert(
"landuse");
84 result.insert(
"natural");
85 result.insert(
"military");
86 result.insert(
"boundary");
87 result.insert(
"admin_level");
88 result.insert(
"sport");
89 result.insert(
"polygon");
90 result.insert(
"place");
91 result.insert(
"population");
92 result.insert(
"openGeoDB:population");
93 result.insert(
"openGeoDB:name");
100 if (!oc.
isSet(
"osm-files")) {
106 std::map<SUMOLong, PCOSMNode*> nodes;
107 bool withAttributes = oc.
getBool(
"all-attributes");
110 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
113 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
123 std::map<std::string, PCOSMEdge*> edges;
124 EdgesHandler edgesHandler(nodes, edges, withAttributes, *m);
125 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
133 const bool useName = oc.
getBool(
"osm.use-name");
135 for (std::map<std::string, PCOSMEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
151 WRITE_WARNING(
"Unable to project coordinates for polygon '" + e->
id +
"'.");
158 std::string unknownPolyType =
"";
159 for (std::map<std::string, std::string>::iterator it = e->
myAttributes.begin(); it != e->
myAttributes.end(); ++it) {
160 const std::string& key = it->first;
161 const std::string& value = it->second;
162 const std::string fullType = key +
"." + value;
163 if (tm.
has(key +
"." + value)) {
164 index =
addPolygon(e, vec, tm.
get(fullType), fullType, index, useName, toFill, ignorePruning, withAttributes);
165 }
else if (tm.
has(key)) {
166 index =
addPolygon(e, vec, tm.
get(key), fullType, index, useName, toFill, ignorePruning, withAttributes);
168 unknownPolyType = fullType;
172 if (index == 0 && !def.
discard && unknownPolyType !=
"") {
173 addPolygon(e, vec, def, unknownPolyType, index, useName, toFill, ignorePruning, withAttributes);
179 for (std::map<SUMOLong, PCOSMNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i) {
192 std::string unKnownPOIType =
"";
193 for (std::map<std::string, std::string>::iterator it = n->
myAttributes.begin(); it != n->
myAttributes.end(); ++it) {
194 const std::string& key = it->first;
195 const std::string& value = it->second;
196 const std::string fullType = key +
"." + value;
197 if (tm.
has(key +
"." + value)) {
198 index =
addPOI(n, pos, tm.
get(fullType), fullType, index, toFill, ignorePruning, withAttributes);
199 }
else if (tm.
has(key)) {
200 index =
addPOI(n, pos, tm.
get(key), fullType, index, toFill, ignorePruning, withAttributes);
202 unKnownPOIType = fullType;
206 if (index == 0 && !def.
discard && unKnownPOIType !=
"") {
207 addPOI(n, pos, def, unKnownPOIType, index, toFill, ignorePruning, withAttributes);
211 for (std::map<SUMOLong, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
215 for (std::map<std::string, PCOSMEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
226 const bool closedShape = vec.front() == vec.back();
227 const std::string idSuffix = (index == 0 ?
"" :
"#" +
toString(index));
228 const std::string
id = def.
prefix + (useName && edge->
name !=
"" ? edge->
name : edge->
id) + idSuffix;
233 if (withAttributes) {
236 if (!toFill.
insert(
id, poly, def.
layer, ignorePruning)) {
246 int index,
PCPolyContainer& toFill,
bool ignorePruning,
bool withAttributes) {
250 const std::string idSuffix = (index == 0 ?
"" :
"#" +
toString(index));
256 if (withAttributes) {
259 if (!toFill.
insert(
id, poi, def.
layer, ignorePruning)) {
272 bool withAttributes,
MsgHandler& errorHandler) :
273 SUMOSAXHandler(
"osm - file"), myWithAttributes(withAttributes), myErrorHandler(errorHandler),
274 myToFill(toFill), myLastNodeID(-1) {}
282 myParentElements.push_back(element);
290 if (myToFill.find(
id) == myToFill.end()) {
303 myToFill[toAdd->
id] = toAdd;
306 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_NODE
307 && myLastNodeID != -1) {
312 myErrorHandler.inform(
"Empty key in a a tag while parsing node '" +
toString(myLastNodeID) +
"' occured.");
318 myToFill[myLastNodeID]->myAttributes[key] = value;
328 myParentElements.pop_back();
336 std::map<std::string, PCOSMEdge*>& toFill,
bool withAttributes,
MsgHandler& errorHandler)
337 :
SUMOSAXHandler(
"osm - file"), myWithAttributes(withAttributes), myErrorHandler(errorHandler),
338 myOSMNodes(osmNodes), myEdgeMap(toFill) {
348 myParentElements.push_back(element);
357 myCurrentEdge->id = id;
358 myCurrentEdge->myIsClosed =
false;
366 if (myOSMNodes.find(ref) == myOSMNodes.end()) {
370 myCurrentEdge->myCurrentNodes.push_back(ref);
374 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY
375 && myCurrentEdge != 0) {
380 myErrorHandler.inform(
"Empty key in a a tag while parsing way '" +
toString(myCurrentEdge->id) +
"' occured.");
387 myCurrentEdge->name = value;
391 myCurrentEdge->myAttributes[key] = value;
398 myParentElements.pop_back();
401 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
403 delete myCurrentEdge;