60 std::set<std::string> result;
61 result.insert(
"highway");
62 result.insert(
"railway");
63 result.insert(
"railway:position");
64 result.insert(
"railway:position:exact");
65 result.insert(
"waterway");
66 result.insert(
"aeroway");
67 result.insert(
"aerialway");
68 result.insert(
"power");
69 result.insert(
"man_made");
70 result.insert(
"building");
71 result.insert(
"leisure");
72 result.insert(
"amenity");
73 result.insert(
"shop");
74 result.insert(
"tourism");
75 result.insert(
"historic");
76 result.insert(
"landuse");
77 result.insert(
"natural");
78 result.insert(
"military");
79 result.insert(
"boundary");
80 result.insert(
"admin_level");
81 result.insert(
"sport");
82 result.insert(
"polygon");
83 result.insert(
"place");
84 result.insert(
"population");
85 result.insert(
"openGeoDB:population");
86 result.insert(
"openGeoDB:name");
93 if (!oc.
isSet(
"osm-files")) {
99 std::map<long long int, PCOSMNode*> nodes;
100 bool withAttributes = oc.
getBool(
"all-attributes");
103 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
106 WRITE_ERROR(
"Could not open osm-file '" + *file +
"'.");
112 for (std::map<long long int, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
122 RelationsHandler relationsHandler(additionalWays, relations, withAttributes, *m);
123 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
133 EdgesHandler edgesHandler(nodes, edges, additionalWays, withAttributes, *m);
134 for (std::vector<std::string>::const_iterator file = files.begin(); file != files.end(); ++file) {
143 const bool useName = oc.
getBool(
"osm.use-name");
146 if (mergeRelationsThreshold >= 0) {
148 if (!rel->keep || rel->myWays.empty()) {
153 for (
auto it = rel->myWays.begin(); it != rel->myWays.end();) {
154 if (edges.count(*it) == 0 || edges[*it]->myCurrentNodes.empty()) {
155 it = rel->myWays.erase(it);
157 numNodes += (int)edges[*it]->myCurrentNodes.size();
172 std::set<long long int> remaining(rel->myWays.begin(), rel->myWays.end());
173 PCOSMEdge* minEdge = edges[rel->myWays.front()];
176 minEdge->standalone =
false;
177 remaining.erase(minEdge->id);
179 while (!remaining.empty()) {
181 double minDist = std::numeric_limits<double>::max();
182 bool minFront =
false;
183 for (
long long int wayID : remaining) {
189 if (frontDist < minDist) {
194 if (backDist < minDist) {
200 if (minDist > mergeRelationsThreshold) {
202 for (
long long int wayID : remaining) {
216 if (length > mergeRelationsThreshold) {
218 "' (name:" + e->
name +
" reason: found gap of " +
toString(minDist) +
219 "m to way '" +
toString(minEdge->id) +
220 "')\n Total length of remaining ways: " +
toString(length) +
"m.");
232 minEdge->standalone =
false;
233 remaining.erase(minEdge->id);
241 for (
long long int wayID : rel->myWays) {
250 for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
256 if (!e->
standalone && mergeRelationsThreshold >= 0) {
277 std::string unknownPolyType =
"";
278 for (std::map<std::string, std::string>::iterator it = e->
myAttributes.begin(); it != e->
myAttributes.end(); ++it) {
279 const std::string& key = it->first;
280 const std::string& value = it->second;
281 const std::string fullType = key +
"." + value;
282 if (tm.
has(key +
"." + value)) {
283 index =
addPolygon(e, vec, tm.
get(fullType), fullType, index, useName, toFill, ignorePruning, withAttributes);
284 }
else if (tm.
has(key)) {
285 index =
addPolygon(e, vec, tm.
get(key), fullType, index, useName, toFill, ignorePruning, withAttributes);
287 unknownPolyType = fullType;
291 if (index == 0 && !def.
discard && unknownPolyType !=
"") {
292 addPolygon(e, vec, def, unknownPolyType, index, useName, toFill, ignorePruning, withAttributes);
298 for (std::map<long long int, PCOSMNode*>::iterator i = nodes.begin(); i != nodes.end(); ++i) {
311 std::string unKnownPOIType =
"";
312 for (std::map<std::string, std::string>::iterator it = n->
myAttributes.begin(); it != n->
myAttributes.end(); ++it) {
313 const std::string& key = it->first;
314 const std::string& value = it->second;
315 const std::string fullType = key +
"." + value;
316 if (tm.
has(key +
"." + value)) {
317 index =
addPOI(n, pos, tm.
get(fullType), fullType, index, useName, toFill, ignorePruning, withAttributes);
318 }
else if (tm.
has(key)) {
319 index =
addPOI(n, pos, tm.
get(key), fullType, index, useName, toFill, ignorePruning, withAttributes);
321 unKnownPOIType = fullType;
325 if (index == 0 && !def.
discard && unKnownPOIType !=
"") {
326 addPOI(n, pos, def, unKnownPOIType, index, useName, toFill, ignorePruning, withAttributes);
330 for (std::map<long long int, PCOSMNode*>::const_iterator i = nodes.begin(); i != nodes.end(); ++i) {
334 for (EdgeMap::iterator i = edges.begin(); i != edges.end(); ++i) {
338 for (Relations::iterator i = relations.begin(); i != relations.end(); ++i) {
357 const bool closedShape = vec.front() == vec.back();
358 const std::string idSuffix = (index == 0 ?
"" :
"#" +
toString(index));
364 if (withAttributes) {
367 if (!toFill.
add(poly, ignorePruning)) {
378 int index,
bool useName,
PCPolyContainer& toFill,
bool ignorePruning,
bool withAttributes) {
382 const std::string idSuffix = (index == 0 ?
"" :
"#" +
toString(index));
387 def.
color, pos,
false,
"", 0, 0, (
double)def.
layer);
388 if (withAttributes) {
391 if (!toFill.
add(poi, ignorePruning)) {
404 bool withAttributes,
MsgHandler& errorHandler) :
405 SUMOSAXHandler(
"osm - file"), myWithAttributes(withAttributes), myErrorHandler(errorHandler),
406 myToFill(toFill), myLastNodeID(-1) {}
414 myParentElements.push_back(element);
417 long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
422 if (myToFill.find(
id) == myToFill.end()) {
435 myToFill[toAdd->
id] = toAdd;
438 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_NODE
439 && myLastNodeID != -1) {
444 myToFill[myLastNodeID]->name = value;
445 }
else if (key ==
"") {
446 myErrorHandler.inform(
"Empty key in a a tag while parsing node '" +
toString(myLastNodeID) +
"' occurred.");
452 myToFill[myLastNodeID]->myAttributes[key] = value;
462 myParentElements.pop_back();
474 myAdditionalWays(additionalWays),
475 myRelations(relations),
476 myWithAttributes(withAttributes),
477 myErrorHandler(errorHandler),
478 myCurrentRelation(nullptr) {
488 myParentElements.push_back(element);
491 myCurrentWays.clear();
493 if (action ==
"delete") {
494 myCurrentRelation =
nullptr;
497 myCurrentRelation->keep =
false;
499 myCurrentRelation->id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
500 myRelations.push_back(myCurrentRelation);
503 }
else if (myCurrentRelation ==
nullptr) {
511 if (role ==
"outer" || role ==
"inner") {
513 if (memberType ==
"way") {
514 myCurrentWays.push_back(ref);
521 && myCurrentRelation !=
nullptr) {
526 myErrorHandler.inform(
"Empty key in a a tag while parsing way '" +
toString(myCurrentRelation) +
"' occurred.");
533 myCurrentRelation->name = value;
535 myCurrentRelation->keep =
true;
536 for (std::vector<long long int>::iterator it = myCurrentWays.begin(); it != myCurrentWays.end(); ++it) {
537 myAdditionalWays[*it] = myCurrentRelation;
540 myCurrentRelation->myAttributes[key] = value;
547 myParentElements.pop_back();
549 myCurrentRelation->myWays = myCurrentWays;
550 myCurrentRelation =
nullptr;
551 myCurrentWays.clear();
562 bool withAttributes,
MsgHandler& errorHandler) :
564 myWithAttributes(withAttributes),
565 myErrorHandler(errorHandler),
566 myOSMNodes(osmNodes),
568 myAdditionalWays(additionalWays) {
578 myParentElements.push_back(element);
582 const long long int id = attrs.
get<
long long int>(
SUMO_ATTR_ID,
nullptr, ok);
584 if (action ==
"delete" || !ok) {
585 myCurrentEdge =
nullptr;
589 myCurrentEdge->id = id;
590 myCurrentEdge->myIsClosed =
false;
591 myCurrentEdge->standalone =
false;
592 myKeep = (myAdditionalWays.find(
id) != myAdditionalWays.end());
595 if (element ==
SUMO_TAG_ND && myCurrentEdge !=
nullptr) {
597 const long long int ref = attrs.
get<
long long int>(
SUMO_ATTR_REF,
nullptr, ok);
599 if (myOSMNodes.find(ref) == myOSMNodes.end()) {
603 myCurrentEdge->myCurrentNodes.push_back(ref);
607 if (element ==
SUMO_TAG_TAG && myParentElements.size() > 2 && myParentElements[myParentElements.size() - 2] ==
SUMO_TAG_WAY
608 && myCurrentEdge !=
nullptr) {
613 myErrorHandler.inform(
"Empty key in a a tag while parsing way '" +
toString(myCurrentEdge->id) +
"' occurred.");
620 myCurrentEdge->name = value;
623 myCurrentEdge->standalone =
true;
625 myCurrentEdge->myAttributes[key] = value;
632 myParentElements.pop_back();
633 if (element ==
SUMO_TAG_WAY && myCurrentEdge !=
nullptr) {
635 RelationsMap::const_iterator it = myAdditionalWays.find(myCurrentEdge->id);
636 if (it != myAdditionalWays.end()) {
637 myCurrentEdge->myAttributes.insert((*it).second->myAttributes.begin(), (*it).second->myAttributes.end());
639 myEdgeMap[myCurrentEdge->id] = myCurrentEdge;
641 delete myCurrentEdge;
643 myCurrentEdge =
nullptr;