[generator] Process stop_position && funicular=yes.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako 2023-05-21 18:33:01 -03:00
parent e8e3627d01
commit a2c8415c22
2 changed files with 45 additions and 3 deletions

View file

@ -53,9 +53,12 @@ void TestSurfaceTypes(std::string const & surface, std::string const & smoothnes
"Got:", psurface));
}
FeatureBuilderParams GetFeatureBuilderParams(Tags const & tags)
FeatureBuilderParams GetFeatureBuilderParams(
Tags const & tags,
OsmElement::EntityType type = OsmElement::EntityType::Unknown)
{
OsmElement e;
e.m_type = type;
FillXmlElement(tags, &e);
FeatureBuilderParams params;
@ -1119,6 +1122,35 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_Subway)
}
}
UNIT_CLASS_TEST(TestWithClassificator, OsmType_PublicTransport)
{
{
Tags const tags = {
{ "name", "Платонава" },
{ "public_transport", "stop_position" },
{ "tram", "yes" },
};
auto const params = GetFeatureBuilderParams(tags, OsmElement::EntityType::Node);
TEST_EQUAL(params.m_types.size(), 1, (params));
TEST(params.IsTypeExist(GetType({"railway", "tram_stop"})), (params));
}
{
Tags const tags = {
{ "funicular", "yes" },
{ "name", "Gare Pfaffenthal-Kirchberg" },
{ "public_transport", "stop_position" },
};
auto const params = GetFeatureBuilderParams(tags, OsmElement::EntityType::Node);
TEST_EQUAL(params.m_types.size(), 1, (params));
TEST(params.IsTypeExist(GetType({"railway", "station", "funicular"})), (params));
}
}
UNIT_CLASS_TEST(TestWithClassificator, OsmType_Hospital)
{
{

View file

@ -659,6 +659,7 @@ void PreprocessElement(OsmElement * p, CalculateOriginFnT const & calcOrg)
bool isStopPosition = false;
bool isBus = false;
bool isTram = false;
bool isFunicular = false;
bool isCapital = false;
@ -677,6 +678,7 @@ void PreprocessElement(OsmElement * p, CalculateOriginFnT const & calcOrg)
{"bus", "yes", [&isBus] { isBus = true; }},
{"trolleybus", "yes", [&isBus] { isBus = true; }},
{"tram", "yes", [&isTram] { isTram = true; }},
{"funicular", "yes", [&isFunicular] { isFunicular = true; }},
/// @todo Unfortunately, it's not working in many cases (route=subway, transport=subway).
/// Actually, it's better to process subways after feature types assignment.
@ -704,8 +706,16 @@ void PreprocessElement(OsmElement * p, CalculateOriginFnT const & calcOrg)
// Convert public_transport tags to the older schema.
if (isPlatform && isBus)
p->AddTag("highway", "bus_stop");
if (isStopPosition && isTram)
p->AddTag("railway", "tram_stop");
if (isStopPosition)
{
if (isTram)
p->AddTag("railway", "tram_stop");
if (isFunicular)
{
p->AddTag("railway", "station");
p->AddTag("station", "funicular");
}
}
}
else if (p->m_type == OsmElement::EntityType::Relation && isMultipolygon)
{