From 01686c72103cec6e4c45916d815b8e9cb695f0f1 Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Wed, 13 Jul 2016 19:09:33 +0300 Subject: [PATCH] [generator] Mark buildings that have 3D parts inside --- data/mapcss-mapping.csv | 1 + generator/intermediate_elements.hpp | 16 ++++++++++++++++ generator/osm2type.cpp | 4 ++++ generator/osm_source.cpp | 3 ++- generator/osm_translator.hpp | 8 ++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/data/mapcss-mapping.csv b/data/mapcss-mapping.csv index b973cff873..5c5cbfa4fa 100644 --- a/data/mapcss-mapping.csv +++ b/data/mapcss-mapping.csv @@ -1121,3 +1121,4 @@ psurface|unpaved_bad;1120; wheelchair|yes;1121; wheelchair|no;1122; wheelchair|limited;1123; +building|has_parts;1124; diff --git a/generator/intermediate_elements.hpp b/generator/intermediate_elements.hpp index b05aefee26..8267f1599a 100644 --- a/generator/intermediate_elements.hpp +++ b/generator/intermediate_elements.hpp @@ -110,6 +110,22 @@ public: toDo(ways[i].first, ways[i].second); } + string GetNodeRole(uint64_t const id) const + { + for (size_t i = 0; i < nodes.size(); ++i) + if (nodes[i].first == id) + return nodes[i].second; + return string(); + } + + string GetWayRole(uint64_t const id) const + { + for (size_t i = 0; i < ways.size(); ++i) + if (ways[i].first == id) + return ways[i].second; + return string(); + } + void Swap(RelationElement & rhs) { nodes.swap(rhs.nodes); diff --git a/generator/osm2type.cpp b/generator/osm2type.cpp index afa8e22b03..da9d63210d 100644 --- a/generator/osm2type.cpp +++ b/generator/osm2type.cpp @@ -217,6 +217,7 @@ namespace ftype public: enum EType { ENTRANCE, HIGHWAY, ADDRESS, ONEWAY, PRIVATE, LIT, NOFOOT, YESFOOT, NOBICYCLE, YESBICYCLE, BICYCLE_BIDIR, SURFPGOOD, SURFPBAD, SURFUGOOD, SURFUBAD, + HASPARTS, RW_STATION, RW_STATION_SUBWAY, WHEELCHAIR_YES }; CachedTypes() @@ -233,6 +234,7 @@ namespace ftype {"hwtag", "nobicycle"}, {"hwtag", "yesbicycle"}, {"hwtag", "bidir_bicycle"}, {"psurface", "paved_good"}, {"psurface", "paved_bad"}, {"psurface", "unpaved_good"}, {"psurface", "unpaved_bad"}, + {"building", "has_parts"} }; for (auto const & e : arr) m_types.push_back(c.GetTypeByPath(e)); @@ -548,6 +550,8 @@ namespace ftype TagProcessor(p).ApplyRules ({ { "wheelchair", "designated", [¶ms] { params.AddType(types.Get(CachedTypes::WHEELCHAIR_YES)); }}, + { "building:part", "no", [¶ms] { params.AddType(types.Get(CachedTypes::HASPARTS)); }}, + { "building:parts", "~", [¶ms] { params.AddType(types.Get(CachedTypes::HASPARTS)); }}, }); bool highwayDone = false; diff --git a/generator/osm_source.cpp b/generator/osm_source.cpp index 6d62f44780..236303b92f 100644 --- a/generator/osm_source.cpp +++ b/generator/osm_source.cpp @@ -134,7 +134,8 @@ public: { string const & relationType = e.GetType(); if (!(relationType == "multipolygon" || relationType == "route" || - relationType == "boundary" || relationType == "associatedStreet")) + relationType == "boundary" || relationType == "associatedStreet" || + relationType == "building")) return; m_relations.Write(id, e); diff --git a/generator/osm_translator.hpp b/generator/osm_translator.hpp index bf5595c426..f312752518 100644 --- a/generator/osm_translator.hpp +++ b/generator/osm_translator.hpp @@ -207,6 +207,14 @@ protected: if (TBase::IsSkipRelation(type) || type == "route") return; + if (type == "building") + { + // If this way has "outline" role, add [building=has_parts] type. + if (e.GetWayRole(m_current->id) == "outline") + TBase::AddCustomTag({"building", "has_parts"}); + return; + } + bool const isBoundary = (type == "boundary") && IsAcceptBoundary(e); bool const processAssociatedStreet = type == "associatedStreet" && TBase::IsKeyTagExists("addr:housenumber") && !TBase::IsKeyTagExists("addr:street");