forked from organicmaps/organicmaps
[generator] Removed unused files.
This commit is contained in:
parent
fb08b8b826
commit
dc74351cbf
10 changed files with 0 additions and 476 deletions
|
@ -1,49 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "generator/emitter_interface.hpp"
|
||||
#include "generator/feature_builder.hpp"
|
||||
#include "generator/feature_generator.hpp"
|
||||
|
||||
#include "indexer/feature_data.hpp"
|
||||
|
||||
#include "base/geo_object_id.hpp"
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace generator
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
template <typename Dataset>
|
||||
class EmitterBooking : public EmitterInterface
|
||||
{
|
||||
public:
|
||||
EmitterBooking(Dataset const & dataset, map<base::GeoObjectId, feature::FeatureBuilder> & features)
|
||||
: m_dataset(dataset), m_features(features)
|
||||
{
|
||||
}
|
||||
|
||||
// EmitterInterface overrides:
|
||||
void Process(feature::FeatureBuilder & fb) override
|
||||
{
|
||||
if (m_dataset.NecessaryMatchingConditionHolds(fb))
|
||||
m_features.emplace(fb.GetMostGenericOsmId(), fb);
|
||||
}
|
||||
|
||||
void GetNames(vector<string> & names) const override
|
||||
{
|
||||
names.clear();
|
||||
}
|
||||
|
||||
bool Finish() override
|
||||
{
|
||||
LOG_SHORT(LINFO, ("Num of booking elements:", m_features.size()));
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
Dataset const & m_dataset;
|
||||
map<base::GeoObjectId, feature::FeatureBuilder> & m_features;
|
||||
};
|
||||
} // namespace generator
|
|
@ -1,66 +0,0 @@
|
|||
#include "generator/emitter_coastline.hpp"
|
||||
|
||||
#include "generator/coastlines_generator.hpp"
|
||||
#include "generator/feature_builder.hpp"
|
||||
#include "generator/feature_processing_layers.hpp"
|
||||
#include "generator/feature_generator.hpp"
|
||||
#include "generator/generate_info.hpp"
|
||||
#include "generator/type_helper.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "defines.hpp"
|
||||
|
||||
using namespace feature;
|
||||
|
||||
namespace generator
|
||||
{
|
||||
EmitterCoastline::EmitterCoastline(feature::GenerateInfo const & info)
|
||||
: m_generator(std::make_shared<CoastlineFeaturesGenerator>(ftypes::IsCoastlineChecker::Instance().GetCoastlineType()))
|
||||
, m_coastlineGeomFilename(info.GetIntermediateFileName(WORLD_COASTS_FILE_NAME, ".geom"))
|
||||
, m_coastlineRawGeomFilename(info.GetIntermediateFileName(WORLD_COASTS_FILE_NAME, RAW_GEOM_FILE_EXTENSION))
|
||||
{
|
||||
m_processingChain = std::make_shared<RepresentationCoastlineLayer>();
|
||||
m_processingChain->Add(std::make_shared<PrepareCoastlineFeatureLayer>());
|
||||
m_processingChain->Add(std::make_shared<CoastlineMapperLayer>(m_generator));
|
||||
}
|
||||
|
||||
void EmitterCoastline::Process(FeatureBuilder & feature)
|
||||
{
|
||||
m_processingChain->Handle(feature);
|
||||
}
|
||||
|
||||
bool EmitterCoastline::Finish()
|
||||
{
|
||||
feature::FeaturesAndRawGeometryCollector collector(m_coastlineGeomFilename, m_coastlineRawGeomFilename);
|
||||
// Check and stop if some coasts were not merged
|
||||
if (!m_generator->Finish())
|
||||
return false;
|
||||
|
||||
LOG(LINFO, ("Generating coastline polygons"));
|
||||
|
||||
size_t totalFeatures = 0;
|
||||
size_t totalPoints = 0;
|
||||
size_t totalPolygons = 0;
|
||||
|
||||
vector<FeatureBuilder> features;
|
||||
m_generator->GetFeatures(features);
|
||||
for (auto & feature : features)
|
||||
{
|
||||
collector.Collect(feature);
|
||||
|
||||
++totalFeatures;
|
||||
totalPoints += feature.GetPointsCount();
|
||||
totalPolygons += feature.GetPolygonsCount();
|
||||
}
|
||||
|
||||
LOG(LINFO, ("Total features:", totalFeatures, "total polygons:", totalPolygons,
|
||||
"total points:", totalPoints));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EmitterCoastline::GetNames(std::vector<std::string> &) const {}
|
||||
} // namespace generator
|
|
@ -1,54 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "generator/emitter_booking.hpp"
|
||||
#include "generator/emitter_coastline.hpp"
|
||||
#include "generator/emitter_country.hpp"
|
||||
#include "generator/emitter_interface.hpp"
|
||||
#include "generator/emitter_noop.hpp"
|
||||
#include "generator/emitter_restaurants.hpp"
|
||||
#include "generator/emitter_simple.hpp"
|
||||
#include "generator/emitter_world.hpp"
|
||||
#include "generator/factory_utils.hpp"
|
||||
|
||||
#include "base/assert.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
namespace generator
|
||||
{
|
||||
enum class EmitterType
|
||||
{
|
||||
Restaurants,
|
||||
Simple,
|
||||
SimpleWithPreserialize,
|
||||
Country,
|
||||
Coastline,
|
||||
World,
|
||||
Noop
|
||||
// Booking
|
||||
};
|
||||
|
||||
template <class... Args>
|
||||
std::shared_ptr<EmitterInterface> CreateEmitter(EmitterType type, Args&&... args)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case EmitterType::Coastline:
|
||||
return create<EmitterCoastline>(std::forward<Args>(args)...);
|
||||
case EmitterType::Country:
|
||||
return create<EmitterCountry>(std::forward<Args>(args)...);
|
||||
case EmitterType::Simple:
|
||||
return create<EmitterSimple>(std::forward<Args>(args)...);
|
||||
case EmitterType::SimpleWithPreserialize:
|
||||
return create<EmitterPreserialize>(std::forward<Args>(args)...);
|
||||
case EmitterType::Restaurants:
|
||||
return create<EmitterRestaurants>(std::forward<Args>(args)...);
|
||||
case EmitterType::World:
|
||||
return create<EmitterWorld>(std::forward<Args>(args)...);
|
||||
case EmitterType::Noop:
|
||||
return create<EmitterNoop>(std::forward<Args>(args)...);
|
||||
}
|
||||
UNREACHABLE();
|
||||
}
|
||||
} // namespace generator
|
|
@ -1,29 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class FeatureParams;
|
||||
namespace feature
|
||||
{
|
||||
class FeatureBuilder;
|
||||
} // namespace feature
|
||||
|
||||
namespace generator
|
||||
{
|
||||
// Implementing this interface allows an object to process FeatureBuilder1 objects and broadcast them.
|
||||
class EmitterInterface
|
||||
{
|
||||
public:
|
||||
virtual ~EmitterInterface() = default;
|
||||
|
||||
// This method is used by OsmTranslator to pass |fb| to Emitter for further processing.
|
||||
virtual void Process(feature::FeatureBuilder & fb) = 0;
|
||||
// Finish is used in GenerateFeatureImpl to make whatever work is needed after all OsmElements
|
||||
// are processed.
|
||||
virtual bool Finish() = 0;
|
||||
// Sets buckets (mwm names).
|
||||
// TODO(syershov): Make this topic clear.
|
||||
virtual void GetNames(std::vector<std::string> & names) const = 0;
|
||||
};
|
||||
} // namespace generator
|
|
@ -1,25 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "emitter_interface.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class FeatureParams;
|
||||
|
||||
namespace feature
|
||||
{
|
||||
class FeatureBuilder;
|
||||
} // namespace feature
|
||||
|
||||
namespace generator
|
||||
{
|
||||
class EmitterNoop : public EmitterInterface
|
||||
{
|
||||
public:
|
||||
// EmitterInterface overrides:
|
||||
void Process(feature::FeatureBuilder &) override {}
|
||||
bool Finish() override { return true; }
|
||||
void GetNames(std::vector<std::string> &) const override {}
|
||||
};
|
||||
} // namespace generator
|
|
@ -1,46 +0,0 @@
|
|||
#include "generator/emitter_restaurants.hpp"
|
||||
|
||||
#include "indexer/ftypes_matcher.hpp"
|
||||
#include "generator/feature_builder.hpp"
|
||||
|
||||
using namespace feature;
|
||||
|
||||
namespace generator
|
||||
{
|
||||
EmitterRestaurants::EmitterRestaurants(std::vector<FeatureBuilder> & features)
|
||||
: m_features(features)
|
||||
{
|
||||
}
|
||||
|
||||
void EmitterRestaurants::Process(FeatureBuilder & fb)
|
||||
{
|
||||
if (!ftypes::IsEatChecker::Instance()(fb.GetParams().m_types) || fb.GetParams().name.IsEmpty())
|
||||
{
|
||||
++m_stats.m_unexpectedFeatures;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (fb.GetGeomType())
|
||||
{
|
||||
case feature::GeomType::Point: ++m_stats.m_restaurantsPoi; break;
|
||||
case feature::GeomType::Area: ++m_stats.m_restaurantsBuilding; break;
|
||||
default: ++m_stats.m_unexpectedFeatures;
|
||||
}
|
||||
m_features.emplace_back(fb);
|
||||
}
|
||||
|
||||
void EmitterRestaurants::GetNames(std::vector<std::string> & names) const
|
||||
{
|
||||
// We do not need to create any data file. See generator_tool.cpp and osm_source.cpp.
|
||||
names.clear();
|
||||
}
|
||||
|
||||
bool EmitterRestaurants::Finish()
|
||||
{
|
||||
LOG_SHORT(LINFO, ("Number of restaurants: POI:", m_stats.m_restaurantsPoi,
|
||||
"BUILDING:", m_stats.m_restaurantsBuilding,
|
||||
"TOTAL:", m_features.size(),
|
||||
"INVALID:", m_stats.m_unexpectedFeatures));
|
||||
return true;
|
||||
}
|
||||
} // namespace generator
|
|
@ -1,31 +0,0 @@
|
|||
#include "generator/emitter_interface.hpp"
|
||||
#include "generator/feature_builder.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace generator
|
||||
{
|
||||
class EmitterRestaurants : public EmitterInterface
|
||||
{
|
||||
public:
|
||||
EmitterRestaurants(std::vector<feature::FeatureBuilder> & features);
|
||||
|
||||
// EmitterInterface overrides:
|
||||
void Process(feature::FeatureBuilder & fb) override;
|
||||
void GetNames(std::vector<std::string> & names) const override;
|
||||
bool Finish() override;
|
||||
|
||||
private:
|
||||
struct Stats
|
||||
{
|
||||
// Number of features of any "food type".
|
||||
uint32_t m_restaurantsPoi = 0;
|
||||
uint32_t m_restaurantsBuilding = 0;
|
||||
uint32_t m_unexpectedFeatures = 0;
|
||||
};
|
||||
|
||||
std::vector<feature::FeatureBuilder> & m_features;
|
||||
Stats m_stats;
|
||||
};
|
||||
} // namespace generator
|
|
@ -1,33 +0,0 @@
|
|||
#include "generator/emitter_simple.hpp"
|
||||
|
||||
#include "generator/feature_builder.hpp"
|
||||
|
||||
#include "base/macros.hpp"
|
||||
|
||||
using namespace feature;
|
||||
|
||||
namespace generator
|
||||
{
|
||||
EmitterSimple::EmitterSimple(feature::GenerateInfo const & info) :
|
||||
m_regionGenerator(std::make_unique<SimpleGenerator>(info)) {}
|
||||
|
||||
void EmitterSimple::GetNames(std::vector<std::string> & names) const
|
||||
{
|
||||
names = m_regionGenerator->Parent().GetNames();
|
||||
}
|
||||
|
||||
void EmitterSimple::Process(FeatureBuilder & fb)
|
||||
{
|
||||
auto & polygonizer = m_regionGenerator->Parent();
|
||||
// Emit each feature independently: clear current country names (see Polygonizer::GetCurrentNames()).
|
||||
polygonizer.Start();
|
||||
(*m_regionGenerator)(fb);
|
||||
polygonizer.Finish();
|
||||
}
|
||||
|
||||
void EmitterPreserialize::Process(FeatureBuilder & fb)
|
||||
{
|
||||
UNUSED_VALUE(fb.PreSerialize());
|
||||
EmitterSimple::Process(fb);
|
||||
}
|
||||
} // namespace generator
|
|
@ -1,40 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "generator/emitter_interface.hpp"
|
||||
#include "generator/feature_generator.hpp"
|
||||
#include "generator/generate_info.hpp"
|
||||
#include "generator/polygonizer.hpp"
|
||||
#include "generator/world_map_generator.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace generator
|
||||
{
|
||||
// EmitterSimple class is a simple emitter. It does not filter objects.
|
||||
class EmitterSimple : public EmitterInterface
|
||||
{
|
||||
public:
|
||||
explicit EmitterSimple(feature::GenerateInfo const & info);
|
||||
|
||||
// EmitterInterface overrides:
|
||||
void GetNames(std::vector<std::string> & names) const override;
|
||||
void Process(feature::FeatureBuilder & fb) override;
|
||||
bool Finish() override { return true; }
|
||||
|
||||
private:
|
||||
using SimpleGenerator = SimpleCountryMapGenerator<feature::Polygonizer<feature::FeaturesCollector>>;
|
||||
|
||||
std::unique_ptr<SimpleGenerator> m_regionGenerator;
|
||||
};
|
||||
|
||||
class EmitterPreserialize : public EmitterSimple
|
||||
{
|
||||
public:
|
||||
using EmitterSimple::EmitterSimple;
|
||||
|
||||
// EmitterInterface overrides:
|
||||
void Process(feature::FeatureBuilder & fb) override;
|
||||
};
|
||||
} // namespace generator
|
|
@ -1,103 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "generator/borders.hpp"
|
||||
#include "generator/feature_builder.hpp"
|
||||
#include "generator/generate_info.hpp"
|
||||
|
||||
#include "geometry/rect2d.hpp"
|
||||
#include "geometry/mercator.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace feature
|
||||
{
|
||||
// Groups features according to country polygons.
|
||||
template <class FeatureOut>
|
||||
class Polygonizer
|
||||
{
|
||||
public:
|
||||
Polygonizer(feature::GenerateInfo const & info)
|
||||
: m_info(info)
|
||||
{
|
||||
if (info.m_splitByPolygons)
|
||||
{
|
||||
CHECK(borders::LoadCountriesList(info.m_targetDir, m_countries),
|
||||
("Error loading country polygons files."));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Insert fake country polygon equal to whole world to
|
||||
// create only one output file which contains all features.
|
||||
borders::RegionsContainer regions;
|
||||
auto const rect = MercatorBounds::FullRect();
|
||||
std::vector<m2::PointD> points {rect.LeftBottom(), rect.LeftTop(), rect.RightTop(),
|
||||
rect.RightBottom(), rect.LeftBottom()};
|
||||
regions.Add(m2::RegionD(std::move(points)), rect);
|
||||
auto countries = borders::CountryPolygons(info.m_fileName, regions);
|
||||
m_countries.Add(std::move(countries), rect);
|
||||
}
|
||||
}
|
||||
|
||||
~Polygonizer()
|
||||
{
|
||||
Finish();
|
||||
}
|
||||
|
||||
void operator()(FeatureBuilder & fb)
|
||||
{
|
||||
m_countries.ForEachInRect(fb.GetLimitRect(), [&](auto const & countryPolygons) {
|
||||
auto const need = fb.ForAnyGeometryPoint([&](auto const & point) {
|
||||
return countryPolygons.Contains(point);
|
||||
});
|
||||
|
||||
if (need)
|
||||
this->EmitFeature(countryPolygons, fb);
|
||||
});
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
m_currentNames.clear();
|
||||
}
|
||||
|
||||
void Finish()
|
||||
{
|
||||
}
|
||||
|
||||
void EmitFeature(borders::CountryPolygons const & countryPolygons, FeatureBuilder const & fb)
|
||||
{
|
||||
if (countryPolygons.m_index == -1)
|
||||
{
|
||||
m_names.push_back(countryPolygons.GetName());
|
||||
m_buckets.emplace_back(new FeatureOut(m_info.GetTmpFileName(countryPolygons.GetName())));
|
||||
countryPolygons.m_index = static_cast<int>(m_buckets.size()) - 1;
|
||||
}
|
||||
|
||||
if (!m_currentNames.empty())
|
||||
m_currentNames += ';';
|
||||
|
||||
m_currentNames += countryPolygons.GetName();
|
||||
m_buckets[countryPolygons.m_index]->Collect(fb);
|
||||
}
|
||||
|
||||
std::vector<std::string> const & GetNames() const
|
||||
{
|
||||
return m_names;
|
||||
}
|
||||
|
||||
std::string const & GetCurrentNames() const
|
||||
{
|
||||
return m_currentNames;
|
||||
}
|
||||
|
||||
private:
|
||||
feature::GenerateInfo const & m_info;
|
||||
std::vector<std::unique_ptr<FeatureOut>> m_buckets;
|
||||
std::vector<std::string> m_names;
|
||||
borders::CountriesContainer m_countries;
|
||||
std::string m_currentNames;
|
||||
};
|
||||
} // namespace feature
|
Loading…
Add table
Reference in a new issue