[generator:geo_objects] Change for review

This commit is contained in:
Anatoly Serdtcev 2019-11-01 11:55:52 +03:00 committed by Sergey Yershov
parent 546de0847f
commit 3fafbb3633
4 changed files with 33 additions and 36 deletions

View file

@ -28,9 +28,9 @@ GeoObjectsIndex<IndexReader> GenerateStreetsIndex(std::vector<OsmElementData> 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};

View file

@ -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
{

View file

@ -252,10 +252,27 @@ bool GenerateGeoObjectsData(string const & featuresFile,
needSerialize, featuresFile, dataFile);
}
bool GenerateGeoObjectsData(string const & geoObjectsFeaturesFile,
string const & streetFeaturesFile,
boost::optional<string> const & nodesFile,
string const & dataFile)
bool IsGeoObjectAccepted(FeatureBuilder & fb, bool allowStreet, set<uint64_t> 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<string> 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);

View file

@ -13,10 +13,10 @@ namespace feature
bool GenerateGeoObjectsData(std::string const & geoObjectsFeaturesFile,
boost::optional<std::string> const & nodesFile,
std::string const & out);
bool GenerateGeoObjectsData(std::string const & geoObjectsFeaturesFile,
std::string const & streetFeaturesFile,
boost::optional<std::string> const & nodesFile,
std::string const & out);
bool GenerateGeoObjectsAndStreetsData(std::string const & geoObjectsFeaturesFile,
std::string const & streetFeaturesFile,
boost::optional<std::string> const & nodesFile,
std::string const & out);
// Generates data for RegionsIndexBuilder from input feature-dat-files.
// @param featuresDir - path to folder with pregenerated features data;