forked from organicmaps/organicmaps
[generator:geo_objects] Fix for review
This commit is contained in:
parent
015425a4b8
commit
705807bce9
5 changed files with 86 additions and 34 deletions
|
@ -94,6 +94,8 @@ set(SRC
|
|||
geo_objects/geo_objects.hpp
|
||||
geo_objects/geo_object_info_getter.cpp
|
||||
geo_objects/geo_object_info_getter.hpp
|
||||
geo_objects/geo_objects_filter.cpp
|
||||
geo_objects/geo_objects_filter.hpp
|
||||
geo_objects/key_value_storage.cpp
|
||||
geo_objects/key_value_storage.hpp
|
||||
geo_objects/region_info_getter.cpp
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "generator/feature_builder.hpp"
|
||||
#include "generator/geo_objects/geo_object_info_getter.hpp"
|
||||
#include "generator/geo_objects/geo_objects_filter.hpp"
|
||||
#include "generator/geo_objects/key_value_storage.hpp"
|
||||
#include "generator/geo_objects/region_info_getter.hpp"
|
||||
#include "generator/geo_objects/streets_builder.hpp"
|
||||
|
@ -39,17 +40,6 @@ namespace
|
|||
{
|
||||
using IndexReader = ReaderPtr<Reader>;
|
||||
|
||||
bool IsBuilding(FeatureBuilder1 const & fb)
|
||||
{
|
||||
auto const & checker = ftypes::IsBuildingChecker::Instance();
|
||||
return checker(fb.GetTypes());
|
||||
}
|
||||
|
||||
bool HasHouse(FeatureBuilder1 const & fb)
|
||||
{
|
||||
return !fb.GetParams().house.IsEmpty();
|
||||
}
|
||||
|
||||
bool HouseHasAddress(base::Json json)
|
||||
{
|
||||
auto properties = json_object_get(json.get(), "properties");
|
||||
|
@ -163,7 +153,7 @@ void BuildGeoObjectsWithAddresses(RegionInfoGetter const & regionInfoGetter,
|
|||
{
|
||||
size_t countGeoObjects = 0;
|
||||
auto const fn = [&](FeatureBuilder1 & fb, uint64_t /* currPos */) {
|
||||
if (!(IsBuilding(fb) || HasHouse(fb)))
|
||||
if (!(GeoObjectsFilter::IsBuilding(fb) || GeoObjectsFilter::HasHouse(fb)))
|
||||
return;
|
||||
|
||||
auto regionKeyValue = regionInfoGetter.FindDeepest(fb.GetKeyPoint());
|
||||
|
@ -187,7 +177,9 @@ void BuildGeoObjectsWithoutAddresses(GeoObjectInfoGetter const & geoObjectInfoGe
|
|||
{
|
||||
size_t countGeoObjects = 0;
|
||||
auto const fn = [&](FeatureBuilder1 & fb, uint64_t /* currPos */) {
|
||||
if (IsBuilding(fb) || HasHouse(fb) || StreetsBuilder::IsStreet(fb))
|
||||
if (!GeoObjectsFilter::IsPoi(fb))
|
||||
return;
|
||||
if (GeoObjectsFilter::IsBuilding(fb) || GeoObjectsFilter::HasHouse(fb) || GeoObjectsFilter::IsStreet(fb))
|
||||
return;
|
||||
|
||||
auto const house = FindHousePoi(fb, geoObjectInfoGetter);
|
||||
|
|
52
generator/geo_objects/geo_objects_filter.cpp
Normal file
52
generator/geo_objects/geo_objects_filter.cpp
Normal file
|
@ -0,0 +1,52 @@
|
|||
#include "generator/geo_objects/geo_objects_filter.hpp"
|
||||
|
||||
#include "generator/geo_objects/streets_builder.hpp"
|
||||
#include "generator/osm_element_helpers.hpp"
|
||||
|
||||
#include "indexer/ftypes_matcher.hpp"
|
||||
|
||||
namespace generator
|
||||
{
|
||||
namespace geo_objects
|
||||
{
|
||||
bool GeoObjectsFilter::IsAccepted(OsmElement const & element)
|
||||
{
|
||||
return osm_element::IsBuilding(element) || osm_element::HasHouse(element) || osm_element::IsPoi(element) ||
|
||||
geo_objects::StreetsBuilder::IsStreet(element);
|
||||
}
|
||||
|
||||
bool GeoObjectsFilter::IsAccepted(FeatureBuilder1 const & feature)
|
||||
{
|
||||
if (!feature.GetParams().IsValid())
|
||||
return false;
|
||||
|
||||
return IsBuilding(feature) || HasHouse(feature) || IsPoi(feature) || IsStreet(feature);
|
||||
}
|
||||
|
||||
// static
|
||||
bool GeoObjectsFilter::IsBuilding(FeatureBuilder1 const & fb)
|
||||
{
|
||||
auto const & checker = ftypes::IsBuildingChecker::Instance();
|
||||
return checker(fb.GetTypes());
|
||||
}
|
||||
|
||||
// static
|
||||
bool GeoObjectsFilter::HasHouse(FeatureBuilder1 const & fb)
|
||||
{
|
||||
return !fb.GetParams().house.IsEmpty();
|
||||
}
|
||||
|
||||
// static
|
||||
bool GeoObjectsFilter::IsPoi(FeatureBuilder1 const & fb)
|
||||
{
|
||||
auto const & poiChecker = ftypes::IsPoiChecker::Instance();
|
||||
return poiChecker(fb.GetTypes());
|
||||
}
|
||||
|
||||
// static
|
||||
bool GeoObjectsFilter::IsStreet(FeatureBuilder1 const & fb)
|
||||
{
|
||||
return geo_objects::StreetsBuilder::IsStreet(fb);
|
||||
}
|
||||
} // namespace geo_objects
|
||||
} // namespace generator
|
25
generator/geo_objects/geo_objects_filter.hpp
Normal file
25
generator/geo_objects/geo_objects_filter.hpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include "generator/feature_builder.hpp"
|
||||
#include "generator/filter_interface.hpp"
|
||||
#include "generator/intermediate_data.hpp"
|
||||
#include "generator/osm_element.hpp"
|
||||
|
||||
namespace generator
|
||||
{
|
||||
namespace geo_objects
|
||||
{
|
||||
class GeoObjectsFilter : public FilterInterface
|
||||
{
|
||||
public:
|
||||
// FilterInterface overrides:
|
||||
bool IsAccepted(OsmElement const & element) override;
|
||||
bool IsAccepted(FeatureBuilder1 const & feature) override;
|
||||
|
||||
static bool IsBuilding(FeatureBuilder1 const & fb);
|
||||
static bool HasHouse(FeatureBuilder1 const & fb);
|
||||
static bool IsPoi(FeatureBuilder1 const & fb);
|
||||
static bool IsStreet(FeatureBuilder1 const & fb);
|
||||
};
|
||||
} // namespace geo_objects
|
||||
} // namespace generator
|
|
@ -2,37 +2,18 @@
|
|||
|
||||
#include "generator/feature_maker.hpp"
|
||||
#include "generator/filter_interface.hpp"
|
||||
#include "generator/geo_objects/streets_builder.hpp"
|
||||
#include "generator/geo_objects/geo_objects_filter.hpp"
|
||||
#include "generator/intermediate_data.hpp"
|
||||
#include "generator/osm_element.hpp"
|
||||
#include "generator/osm_element_helpers.hpp"
|
||||
|
||||
namespace generator
|
||||
{
|
||||
namespace
|
||||
{
|
||||
class FilterGeoObjects : public FilterInterface
|
||||
{
|
||||
public:
|
||||
// FilterInterface overrides:
|
||||
bool IsAccepted(OsmElement const & element) override
|
||||
{
|
||||
return osm_element::IsBuilding(element) || osm_element::IsPoi(element) ||
|
||||
geo_objects::StreetsBuilder::IsStreet(element);
|
||||
}
|
||||
|
||||
bool IsAccepted(FeatureBuilder1 const & feature) override
|
||||
{
|
||||
return feature.GetParams().IsValid();
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
||||
TranslatorGeoObjects::TranslatorGeoObjects(std::shared_ptr<EmitterInterface> emitter,
|
||||
cache::IntermediateDataReader & cache)
|
||||
: Translator(emitter, cache, std::make_shared<FeatureMakerSimple>(cache))
|
||||
|
||||
{
|
||||
AddFilter(std::make_shared<FilterGeoObjects>());
|
||||
AddFilter(std::make_shared<geo_objects::GeoObjectsFilter>());
|
||||
}
|
||||
} // namespace generator
|
||||
|
|
Loading…
Add table
Reference in a new issue