diff options
author | Anatoly Serdtcev <serdtcev@maps.me> | 2019-04-17 13:30:17 +0300 |
---|---|---|
committer | mpimenov <mpimenov@users.noreply.github.com> | 2019-04-19 13:40:36 +0300 |
commit | 79d9ac735ab5d710e4eba45cacb889a7657263ef (patch) | |
tree | d5809c92ce8629f1e0309b0f5d8340b1159af750 /generator | |
parent | a8581f918810d09c4e212265394c5d17d1a9b430 (diff) |
[generator:geo_objects] Fix for review
Diffstat (limited to 'generator')
-rw-r--r-- | generator/geo_objects/geo_objects.cpp | 13 | ||||
-rw-r--r-- | generator/geo_objects/streets_builder.cpp | 42 | ||||
-rw-r--r-- | generator/geo_objects/streets_builder.hpp | 1 |
3 files changed, 38 insertions, 18 deletions
diff --git a/generator/geo_objects/geo_objects.cpp b/generator/geo_objects/geo_objects.cpp index 162d104f6b..d380f98a88 100644 --- a/generator/geo_objects/geo_objects.cpp +++ b/generator/geo_objects/geo_objects.cpp @@ -207,6 +207,14 @@ void BuildGeoObjectsWithoutAddresses(GeoObjectInfoGetter const & geoObjectInfoGe feature::ForEachFromDatRawFormat(pathInGeoObjectsTmpMwm, fn); LOG(LINFO, ("Added ", countGeoObjects, "geo objects without addresses.")); } + +void BuildStreets(RegionInfoGetter const & regionInfoGetter, + std::string const & pathInGeoObjectsTmpMwm, + std::ostream & streamGeoObjectsKv, bool /* verbose */) +{ + StreetsBuilder streetsBuilder{regionInfoGetter}; + streetsBuilder.Build(pathInGeoObjectsTmpMwm, streamGeoObjectsKv); +} } // namespace bool GenerateGeoObjects(std::string const & pathInRegionsIndex, @@ -227,10 +235,9 @@ bool GenerateGeoObjects(std::string const & pathInRegionsIndex, RegionInfoGetter regionInfoGetter{pathInRegionsIndex, pathInRegionsKv}; LOG(LINFO, ("Size of regions key-value storage:", regionInfoGetter.GetStorage().Size())); - StreetsBuilder streetsBuilder{regionInfoGetter}; std::ofstream streamGeoObjectsKv(pathOutGeoObjectsKv); - streetsBuilder.Build(pathInGeoObjectsTmpMwm, streamGeoObjectsKv); - LOG(LINFO, ("Streets was built.")); + BuildStreets(regionInfoGetter, pathInGeoObjectsTmpMwm, streamGeoObjectsKv, verbose); + LOG(LINFO, ("Streets were built.")); BuildGeoObjectsWithAddresses(regionInfoGetter, pathInGeoObjectsTmpMwm, streamGeoObjectsKv, verbose); LOG(LINFO, ("Geo objects with addresses were built.")); diff --git a/generator/geo_objects/streets_builder.cpp b/generator/geo_objects/streets_builder.cpp index 10477a657d..db6de47a59 100644 --- a/generator/geo_objects/streets_builder.cpp +++ b/generator/geo_objects/streets_builder.cpp @@ -1,6 +1,7 @@ #include "generator/geo_objects/streets_builder.hpp" #include "indexer/classificator.hpp" +#include "indexer/ftypes_matcher.hpp" #include "base/logging.hpp" @@ -39,7 +40,11 @@ void StreetsBuilder::Build(std::string const & pathInGeoObjectsTmpMwm, std::ostr boost::optional<KeyValue> StreetsBuilder::FindStreetRegionOwner(FeatureBuilder1 & fb) { + if (fb.IsPoint()) + return FindStreetRegionOwner(fb.GetKeyPoint()); + auto const & line = fb.GetOuterGeometry(); + CHECK_GREATER_OR_EQUAL(line.size(), 2, ()); auto const & startPoint = line.front(); auto const & owner = FindStreetRegionOwner(startPoint); if (!owner) @@ -103,37 +108,44 @@ std::unique_ptr<char, JSONFreeDeleter> StreetsBuilder::MakeStreetValue( // static bool StreetsBuilder::IsStreet(OsmElement const & element) { - if (!element.IsWay() && !element.IsRelation()) - return false; - auto const & tags = element.Tags(); - auto const isHighway = std::any_of(std::cbegin(tags), std::cend(tags), [] (auto const & tag) { - return tag.key == "highway"; - }); - if (!isHighway) - return false; - auto const hasName = std::any_of(std::cbegin(tags), std::cend(tags), [] (auto const & tag) { return tag.key == "name"; }); if (!hasName) return false; - return true; + auto const isHighway = std::any_of(std::cbegin(tags), std::cend(tags), [] (auto const & tag) { + return tag.key == "highway"; + }); + if (isHighway && (element.IsWay() || element.IsRelation())) + return true; + + auto const isSquare = std::any_of(std::cbegin(tags), std::cend(tags), [] (auto const & tag) { + return tag.key == "place" && tag.value == "square"; + }); + if (isSquare) + return true; + + return false; } // static bool StreetsBuilder::IsStreet(FeatureBuilder1 const & fb) { - if (!fb.IsLine() && !fb.IsArea()) + if (fb.GetName().empty()) return false; - static auto const highwayType = classif().GetTypeByPath({"highway"}); - if (fb.FindType(highwayType, 1) == ftype::GetEmptyValue()) - return false; + auto const & wayChecker = ftypes::IsWayChecker::Instance(); + if (wayChecker(fb.GetTypes()) && (fb.IsLine() || fb.IsArea())) + return true; + + auto const & squareChecker = ftypes::IsSquareChecker::Instance(); + if (squareChecker(fb.GetTypes())) + return true; - return !fb.GetName().empty(); + return false; } } // namespace geo_objects } // namespace generator diff --git a/generator/geo_objects/streets_builder.hpp b/generator/geo_objects/streets_builder.hpp index 5de7aadc4c..af8cdf8e48 100644 --- a/generator/geo_objects/streets_builder.hpp +++ b/generator/geo_objects/streets_builder.hpp @@ -9,6 +9,7 @@ #include "geometry/point2d.hpp" +#include <memory> #include <ostream> #include <string> #include <unordered_map> |