diff --git a/generator/generator_tests/streets_index_tests.cpp b/generator/generator_tests/streets_index_tests.cpp index 1e193d5..aefc0f0 100644 --- a/generator/generator_tests/streets_index_tests.cpp +++ b/generator/generator_tests/streets_index_tests.cpp @@ -28,9 +28,9 @@ GeoObjectsIndex GenerateStreetsIndex(std::vector co auto const locDataFile = GetFileName("streets"s + LOC_DATA_FILE_EXTENSION); bool locDataGeneration = - feature::GenerateGeoObjectsData(geoObjectsFeatures.GetFullPath(), - streetsFeatures.GetFullPath(), - boost::none, locDataFile); + feature::GenerateGeoObjectsAndStreetsData(geoObjectsFeatures.GetFullPath(), + streetsFeatures.GetFullPath(), + boost::none /* nodesFile */, locDataFile); CHECK(locDataGeneration, ()); ScopedFile const streetsIndex{"streets"s + LOC_IDX_FILE_EXTENSION, ScopedFile::Mode::DoNotCreate}; diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index a61d9bc..8971590 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -316,9 +316,9 @@ int GeneratorToolMain(int argc, char ** argv) bool dataGenerated = false; if (!options.m_streets_features.empty()) { - dataGenerated = feature::GenerateGeoObjectsData(options.m_geo_objects_features, - options.m_streets_features, - nodesListPath, locDataFile); + dataGenerated = feature::GenerateGeoObjectsAndStreetsData(options.m_geo_objects_features, + options.m_streets_features, + nodesListPath, locDataFile); } else { diff --git a/generator/locality_sorter.cpp b/generator/locality_sorter.cpp index d24c20d..aa841f5 100644 --- a/generator/locality_sorter.cpp +++ b/generator/locality_sorter.cpp @@ -252,10 +252,27 @@ bool GenerateGeoObjectsData(string const & featuresFile, needSerialize, featuresFile, dataFile); } -bool GenerateGeoObjectsData(string const & geoObjectsFeaturesFile, - string const & streetFeaturesFile, - boost::optional const & nodesFile, - string const & dataFile) +bool IsGeoObjectAccepted(FeatureBuilder & fb, bool allowStreet, set const & includedPois) +{ + using generator::geo_objects::GeoObjectsFilter; + using generator::streets::StreetsFilter; + + if (GeoObjectsFilter::IsBuilding(fb) || GeoObjectsFilter::HasHouse(fb)) + return true; + + if (allowStreet && StreetsFilter::IsStreet(fb)) + return true; + + if (GeoObjectsFilter::IsPoi(fb)) + return 0 != includedPois.count(fb.GetMostGenericOsmId().GetEncodedId()); + + return false; +} + +bool GenerateGeoObjectsAndStreetsData(string const & geoObjectsFeaturesFile, + string const & streetFeaturesFile, + boost::optional const & nodesFile, + string const & dataFile) { auto featuresDirectory = base::GetDirectory(geoObjectsFeaturesFile); auto featuresFile = @@ -271,19 +288,7 @@ bool GenerateGeoObjectsData(string const & geoObjectsFeaturesFile, return false; auto const needSerialize = [&nodeIds](FeatureBuilder & fb) { - using generator::geo_objects::GeoObjectsFilter; - using generator::streets::StreetsFilter; - - if (GeoObjectsFilter::IsBuilding(fb) || GeoObjectsFilter::HasHouse(fb)) - return true; - - if (StreetsFilter::IsStreet(fb)) - return true; - - if (GeoObjectsFilter::IsPoi(fb)) - return 0 != nodeIds.count(fb.GetMostGenericOsmId().GetEncodedId()); - - return false; + return IsGeoObjectAccepted(fb, true /* allowStreet */, nodeIds); }; return GenerateGeoObjectsData(featuresFile, needSerialize, dataFile); @@ -298,15 +303,7 @@ bool GenerateGeoObjectsData(string const & geoObjectsFeaturesFile, return false; auto const needSerialize = [&nodeIds](FeatureBuilder & fb) { - using generator::geo_objects::GeoObjectsFilter; - - if (GeoObjectsFilter::IsBuilding(fb) || GeoObjectsFilter::HasHouse(fb)) - return true; - - if (GeoObjectsFilter::IsPoi(fb)) - return 0 != nodeIds.count(fb.GetMostGenericOsmId().GetEncodedId()); - - return false; + return IsGeoObjectAccepted(fb, false /* allowStreet */, nodeIds); }; return GenerateGeoObjectsData(geoObjectsFeaturesFile, needSerialize, dataFile); diff --git a/generator/locality_sorter.hpp b/generator/locality_sorter.hpp index ce6354b..adc21f8 100644 --- a/generator/locality_sorter.hpp +++ b/generator/locality_sorter.hpp @@ -13,10 +13,10 @@ namespace feature bool GenerateGeoObjectsData(std::string const & geoObjectsFeaturesFile, boost::optional const & nodesFile, std::string const & out); -bool GenerateGeoObjectsData(std::string const & geoObjectsFeaturesFile, - std::string const & streetFeaturesFile, - boost::optional const & nodesFile, - std::string const & out); +bool GenerateGeoObjectsAndStreetsData(std::string const & geoObjectsFeaturesFile, + std::string const & streetFeaturesFile, + boost::optional const & nodesFile, + std::string const & out); // Generates data for RegionsIndexBuilder from input feature-dat-files. // @param featuresDir - path to folder with pregenerated features data;