54 #ifdef CHECK_MEMORY_LEAKS
56 #endif // CHECK_MEMORY_LEAKS
69 std::set<std::string> result;
70 result.insert(
"waterway");
71 result.insert(
"aeroway");
72 result.insert(
"aerialway");
73 result.insert(
"power");
74 result.insert(
"man_made");
75 result.insert(
"building");
76 result.insert(
"leisure");
77 result.insert(
"amenity");
78 result.insert(
"shop");
79 result.insert(
"tourism");
80 result.insert(
"historic");
81 result.insert(
"landuse");
82 result.insert(
"natural");
83 result.insert(
"military");
84 result.insert(
"boundary");
85 result.insert(
"admin_level");
86 result.insert(
"sport");
87 result.insert(
"polygon");
88 result.insert(
"place");
89 result.insert(
"population");
90 result.insert(
"openGeoDB:population");
91 result.insert(
"openGeoDB:name");
98 if (!oc.
isSet(
"osm-files")) {
104 std::map<SUMOLong, PCOSMNode*> nodes;
105 bool withAttributes = oc.
getBool(
"all-attributes");
108 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
111 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
121 std::map<std::string, PCOSMEdge*> edges;
122 EdgesHandler edgesHandler(nodes, edges, withAttributes, *m);
123 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
131 const bool useName = oc.
getBool(
"osm.use-name");
133 for (std::map<std::string, PCOSMEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
149 WRITE_WARNING(
"Unable to project coordinates for polygon '" + e->
id +
"'.");
156 std::string unknownPolyType =
"";
157 for (std::map<std::string, std::string>::iterator it = e->
myAttributes.begin(); it != e->
myAttributes.end(); ++it) {
158 const std::string& key = it->first;
159 const std::string& value = it->second;
160 const std::string fullType = key +
"." + value;
161 if (tm.
has(key +
"." + value)) {
162 index =
addPolygon(e, vec, tm.
get(fullType), fullType, index, useName, toFill, ignorePruning, withAttributes);
163 }
else if (tm.
has(key)) {
164 index =
addPolygon(e, vec, tm.
get(key), fullType, index, useName, toFill, ignorePruning, withAttributes);
166 unknownPolyType = fullType;
170 if (index == 0 && !def.
discard && unknownPolyType !=
"") {
171 addPolygon(e, vec, def, unknownPolyType, index, useName, toFill, ignorePruning, withAttributes);
177 for (std::map<SUMOLong, PCOSMNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i) {
190 std::string unKnownPOIType =
"";
191 for (std::map<std::string, std::string>::iterator it = n->
myAttributes.begin(); it != n->
myAttributes.end(); ++it) {
192 const std::string& key = it->first;
193 const std::string& value = it->second;
194 const std::string fullType = key +
"." + value;
195 if (tm.
has(key +
"." + value)) {
196 index =
addPOI(n, pos, tm.
get(fullType), fullType, index, toFill, ignorePruning, withAttributes);
197 }
else if (tm.
has(key)) {
198 index =
addPOI(n, pos, tm.
get(key), fullType, index, toFill, ignorePruning, withAttributes);
200 unKnownPOIType = fullType;
204 if (index == 0 && !def.
discard && unKnownPOIType !=
"") {
205 addPOI(n, pos, def, unKnownPOIType, index, toFill, ignorePruning, withAttributes);
209 for (std::map<SUMOLong, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
213 for (std::map<std::string, PCOSMEdge*>::iterator i = edges.begin(); i != edges.end(); ++i) {
224 const bool closedShape = vec.front() == vec.back();
225 const std::string idSuffix = (index == 0 ?
"" :
"#" +
toString(index));
226 const std::string
id = def.
prefix + (useName && edge->
name !=
"" ? edge->
name : edge->
id) + idSuffix;
231 if (withAttributes) {
234 if (!toFill.
insert(
id, poly, def.
layer, ignorePruning)) {
235 WRITE_ERROR(
"Polygon '" +
id +
"' could not be added.");
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)) {
260 WRITE_ERROR(
"POI '" +
id +
"' could not be added.");
274 bool withAttributes,
MsgHandler& errorHandler) :
275 SUMOSAXHandler(
"osm - file"), myWithAttributes(withAttributes), myErrorHandler(errorHandler),
276 myToFill(toFill), myLastNodeID(-1) {}
284 myParentElements.push_back(element);
292 if (myToFill.find(
id) == myToFill.end()) {
305 myToFill[toAdd->
id] = toAdd;
308 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_NODE
309 && myLastNodeID != -1) {
314 myErrorHandler.inform(
"Empty key in a a tag while parsing node '" +
toString(myLastNodeID) +
"' occured.");
320 myToFill[myLastNodeID]->myAttributes[key] = value;
330 myParentElements.pop_back();
338 std::map<std::string, PCOSMEdge*>& toFill,
bool withAttributes,
MsgHandler& errorHandler)
339 :
SUMOSAXHandler(
"osm - file"), myWithAttributes(withAttributes), myErrorHandler(errorHandler),
340 myOSMNodes(osmNodes), myEdgeMap(toFill) {
350 myParentElements.push_back(element);
359 myCurrentEdge->id = id;
360 myCurrentEdge->myIsClosed =
false;
368 if (myOSMNodes.find(ref) == myOSMNodes.end()) {
372 myCurrentEdge->myCurrentNodes.push_back(ref);
376 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY
377 && myCurrentEdge != 0) {
382 myErrorHandler.inform(
"Empty key in a a tag while parsing way '" +
toString(myCurrentEdge->id) +
"' occured.");
389 myCurrentEdge->name = value;
393 myCurrentEdge->myAttributes[key] = value;
400 myParentElements.pop_back();
403 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
405 delete myCurrentEdge;