diff --git a/data/osm_test_data/associated_street.osm b/data/osm_test_data/associated_street.osm
new file mode 100644
index 0000000000..fcd393f818
--- /dev/null
+++ b/data/osm_test_data/associated_street.osm
@@ -0,0 +1,543 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/osm_test_data/village_relation.osm b/data/osm_test_data/village_relation.osm
new file mode 100644
index 0000000000..67257f92fd
--- /dev/null
+++ b/data/osm_test_data/village_relation.osm
@@ -0,0 +1,2176 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/generator/generator_tests/raw_generator_test.cpp b/generator/generator_tests/raw_generator_test.cpp
index 19c49a7ee2..3aec9c93dd 100644
--- a/generator/generator_tests/raw_generator_test.cpp
+++ b/generator/generator_tests/raw_generator_test.cpp
@@ -1,6 +1,7 @@
#include "testing/testing.hpp"
#include "generator/generator_tests_support/test_generator.hpp"
+#include "generator/descriptions_section_builder.hpp"
#include "search/cities_boundaries_table.hpp"
@@ -380,4 +381,74 @@ UNIT_CLASS_TEST(TestRawGenerator, MiniRoundabout)
ReadSpeedCamsFromMwm(*(guard.GetHandle().GetValue()), camerasMap);
LOG(LINFO, (camerasMap));
}
+
+UNIT_CLASS_TEST(TestRawGenerator, Relation_Wiki)
+{
+ std::string const mwmName = "Relation";
+
+ BuildFB("./data/osm_test_data/village_relation.osm", mwmName);
+
+ uint32_t const villageType = classif().GetTypeByPath({"place", "village"});
+
+ size_t count = 0;
+ ForEachFB(mwmName, [&](feature::FeatureBuilder const & fb)
+ {
+ switch (fb.GetGeomType())
+ {
+ case feature::GeomType::Point:
+ {
+ TEST(fb.HasType(villageType), ());
+ ++count;
+ TEST_EQUAL(fb.GetMetadata().Get(feature::Metadata::FMD_WIKIPEDIA),
+ "fr:Charmois-l'Orgueilleux", ());
+ break;
+ }
+ case feature::GeomType::Line:
+ {
+ TEST(fb.GetMetadata().Get(feature::Metadata::FMD_WIKIPEDIA).empty(), ());
+ break;
+ }
+ }
+ });
+
+ TEST_EQUAL(count, 1, ());
+}
+
+UNIT_CLASS_TEST(TestRawGenerator, AssociatedStreet_Wiki)
+{
+ uint32_t const roadType = classif().GetTypeByPath({"highway", "residential"});
+
+ std::string const mwmName = "Street";
+ BuildFB("./data/osm_test_data/associated_street.osm", mwmName, false /* makeWorld */);
+
+ size_t count = 0;
+ ForEachFB(mwmName, [&](feature::FeatureBuilder const & fb)
+ {
+ if (fb.HasType(roadType))
+ {
+ TEST_EQUAL(fb.GetMetadata().Get(feature::Metadata::FMD_WIKIPEDIA), "uk:Вулиця Боричів Тік", ());
+ ++count;
+ }
+ });
+
+ TEST_EQUAL(count, 5, ());
+
+ BuildFeatures(mwmName);
+ generator::WikidataHelper wikidata(GetMwmPath(mwmName), GetGenInfo().GetIntermediateFileName(kWikidataFilename));
+
+ count = 0;
+ ForEachFeature(mwmName, [&](std::unique_ptr ft)
+ {
+ if (feature::TypesHolder(*ft).Has(roadType))
+ {
+ ++count;
+ auto const data = wikidata.GetWikidataId(ft->GetID().m_index);
+ TEST(data, ());
+ TEST_EQUAL(*data, "Q4471511", ());
+ }
+ });
+
+ TEST_EQUAL(count, 5, ());
+}
+
} // namespace raw_generator_tests
diff --git a/generator/generator_tests/relation_tags_tests.cpp b/generator/generator_tests/relation_tags_tests.cpp
index 4f41f1237c..d1783dd0bf 100644
--- a/generator/generator_tests/relation_tags_tests.cpp
+++ b/generator/generator_tests/relation_tags_tests.cpp
@@ -156,7 +156,7 @@ UNIT_TEST(Process_associatedStreet)
*/
// Create relation.
- std::vector testMembers = {{2, "house"}, {3, "house"}};
+ std::vector testMembers = {{2, "house"}, {3, "house"}, {4, "street"}};
RelationElement e1;
e1.m_ways = testMembers;
@@ -169,7 +169,10 @@ UNIT_TEST(Process_associatedStreet)
// Create buildings polygons.
auto buildingWay2 = MakeOsmElement(2, {{"building", "yes"}, {"addr:housenumber", "121"}}, OsmElement::EntityType::Way);
- auto buildingWay3 = MakeOsmElement(3, {{"auto const", "yes"}, {"addr:housenumber", "123"}, {"addr:street", "The Main Street"}, {"wikipedia", "en:Mega Theater"}}, OsmElement::EntityType::Way);
+ auto buildingWay3 = MakeOsmElement(3, {{"shop", "convenience"}, {"addr:housenumber", "123"},
+ {"addr:street", "The Main Street"}, {"wikipedia", "en:Mega Theater"}},
+ OsmElement::EntityType::Way);
+ auto highway4 = MakeOsmElement(4, {{"highway", "residential"}}, OsmElement::EntityType::Way);
// Process buildings tags using relation tags.
RelationTagsWay rtw;
@@ -180,12 +183,17 @@ UNIT_TEST(Process_associatedStreet)
rtw.Reset(3, &buildingWay3);
rtw(1, reader);
- // Verify ways tags.
+ rtw.Reset(4, &highway4);
+ rtw(1, reader);
+
+ // Aggreagte wiki from associatedStreet only for highway.
TEST_EQUAL(buildingWay2.GetTag("addr:street"), "Main Street", ());
- TEST_EQUAL(buildingWay2.HasTag("wikipedia"), false, ());
+ TEST(buildingWay2.GetTag("wikipedia").empty(), ());
TEST_EQUAL(buildingWay3.GetTag("addr:street"), "The Main Street", ());
- TEST_EQUAL(buildingWay3.HasTag("wikipedia"), true, ());
+ TEST_EQUAL(buildingWay3.GetTag("wikipedia"), "en:Mega Theater", ());
+
+ TEST_EQUAL(highway4.GetTag("wikipedia"), "en:Main Street", ());
}
UNIT_TEST(Process_boundary)
@@ -205,7 +213,7 @@ UNIT_TEST(Process_boundary)
*/
// Create relation.
- std::vector testMembers = {{5, "outer"}, {6, "outer"}};
+ std::vector testMembers = {{5, "outer"}, {6, "outer"}, {7, "outer"}};
RelationElement e1;
e1.m_ways = testMembers;
@@ -221,6 +229,7 @@ UNIT_TEST(Process_boundary)
// Create ways.
auto outerWay5 = MakeOsmElement(5, {{"natural", "coastline"}}, OsmElement::EntityType::Way);
auto outerWay6 = MakeOsmElement(6, {{"natural", "coastline"}, {"name", "Cala Rossa"}}, OsmElement::EntityType::Way);
+ auto outerWay7 = MakeOsmElement(6, {{"place", "locality"}}, OsmElement::EntityType::Way);
// Process ways tags using relation tags.
RelationTagsWay rtw;
@@ -231,16 +240,23 @@ UNIT_TEST(Process_boundary)
rtw.Reset(6, &outerWay6);
rtw(1, reader);
- // Verify ways tags.
- TEST_EQUAL(outerWay5.HasTag("place"), false, ());
- TEST_EQUAL(outerWay5.HasTag("name"), false, ());
- TEST_EQUAL(outerWay5.HasTag("name:en"), false, ());
- TEST_EQUAL(outerWay5.GetTag("wikidata"), "Q145694", ());
+ rtw.Reset(7, &outerWay7);
+ rtw(1, reader);
- TEST_EQUAL(outerWay6.HasTag("place"), false, ());
- TEST_EQUAL(outerWay6.HasTag("name"), true, ());
- TEST_EQUAL(outerWay6.HasTag("name:en"), false, ());
- TEST_EQUAL(outerWay6.GetTag("wikidata"), "Q145694", ());
+ // We don't aggregate name and wiki from type=boundary Relation if destination Way (Node) is not a place.
+ TEST(!outerWay5.HasTag("place"), ());
+ TEST(!outerWay5.HasTag("name"), ());
+ TEST(!outerWay5.HasTag("name:en"), ());
+ TEST(outerWay5.GetTag("wikidata").empty(), ());
+
+ TEST(!outerWay6.HasTag("place"), ());
+ TEST(outerWay6.HasTag("name"), ());
+ TEST(!outerWay6.HasTag("name:en"), ());
+ TEST(outerWay6.GetTag("wikidata").empty(), ());
+
+ /// @todo Take name for places?
+ TEST(!outerWay7.HasTag("name"), ());
+ TEST_EQUAL(outerWay7.GetTag("wikidata"), "Q145694", ());
}
} // namespace relation_tags_tests
diff --git a/generator/generator_tests_support/test_generator.cpp b/generator/generator_tests_support/test_generator.cpp
index ad2dd5ae92..58e7552497 100644
--- a/generator/generator_tests_support/test_generator.cpp
+++ b/generator/generator_tests_support/test_generator.cpp
@@ -24,6 +24,8 @@ namespace generator
namespace tests_support
{
+char const * TestRawGenerator::kWikidataFilename = "wiki_urls.csv";
+
bool MakeFakeBordersFile(std::string const & intemediatePath, std::string const & filename)
{
auto const borderPath = base::JoinPath(intemediatePath, BORDERS_DIR);
@@ -71,6 +73,7 @@ void TestRawGenerator::BuildFB(std::string const & osmFilePath, std::string cons
m_genInfo.m_tmpDir = m_genInfo.m_targetDir = GetTmpPath();
m_genInfo.m_fileName = mwmName;
+ m_genInfo.m_idToWikidataFilename = m_genInfo.GetIntermediateFileName(kWikidataFilename);
m_genInfo.m_citiesBoundariesFilename = GetCitiesBoundariesPath();
diff --git a/generator/generator_tests_support/test_generator.hpp b/generator/generator_tests_support/test_generator.hpp
index ce07c75914..009b3408af 100644
--- a/generator/generator_tests_support/test_generator.hpp
+++ b/generator/generator_tests_support/test_generator.hpp
@@ -58,6 +58,8 @@ public:
feature::GenerateInfo const & GetGenInfo() const { return m_genInfo; }
bool IsWorld(std::string const & mwmName) const;
+
+ static char const * kWikidataFilename;
};
} // namespace tests_support
diff --git a/generator/relation_tags.cpp b/generator/relation_tags.cpp
index 6b90566952..bca232106b 100644
--- a/generator/relation_tags.cpp
+++ b/generator/relation_tags.cpp
@@ -28,6 +28,9 @@ bool RelationTagsBase::IsKeyTagExists(std::string const & key) const
void RelationTagsBase::AddCustomTag(std::pair const & p)
{
+ /// @todo UpdateTag is better here, because caller doesn't always make IsKeyTagExists check ?!
+ /// I suspect that it works ok now, because duplicating key tag is added to the end of tags vector
+ /// and GetNameAndType function grabs it last.
m_current->AddTag(p.first, p.second);
}
@@ -37,6 +40,8 @@ void RelationTagsNode::Process(RelationElement const & e)
if (Base::IsSkipRelation(type))
return;
+ bool const isBoundary = (type == "boundary");
+ bool const isPlaceDest = Base::IsKeyTagExists("place") || Base::IsKeyTagExists("de:place");
bool const processAssociatedStreet = type == "associatedStreet" &&
Base::IsKeyTagExists("addr:housenumber") &&
!Base::IsKeyTagExists("addr:street");
@@ -52,9 +57,16 @@ void RelationTagsNode::Process(RelationElement const & e)
if (!Base::IsKeyTagExists(p.first))
Base::AddCustomTag(p);
}
- // Convert associatedStreet relation name to addr:street tag if we don't have one.
else if (p.first == "name" && processAssociatedStreet)
+ {
+ // Convert associatedStreet relation name to addr:street tag if we don't have one.
Base::AddCustomTag({"addr:street", p.second});
+ }
+ else if (isBoundary && isPlaceDest && (p.first == "wikipedia" || p.first == "wikidata"))
+ {
+ if (!Base::IsKeyTagExists(p.first))
+ Base::AddCustomTag(p);
+ }
}
}
@@ -86,14 +98,17 @@ void RelationTagsWay::Process(RelationElement const & e)
std::string ref(e.GetTagValue("ref"));
if (!ref.empty())
{
+ auto refBase = m_current->GetTag("ref");
+ if (refBase == ref)
+ refBase.clear();
+
auto const network = e.GetTagValue("network");
// Not processing networks with more than 15 chars (see road_shields_parser.cpp).
if (!network.empty() && network.find('/') == std::string::npos && network.size() < 15)
ref = std::string(network).append(1, '/').append(ref);
- auto const refBase = m_current->GetTag("ref");
if (!refBase.empty())
- ref = std::string(refBase).append(1, ';').append(ref);
+ ref = refBase + ';' + ref;
Base::AddCustomTag({"ref", std::move(ref)});
}
@@ -105,6 +120,7 @@ void RelationTagsWay::Process(RelationElement const & e)
return;
bool const isBoundary = (type == "boundary") && IsAcceptBoundary(e);
+ bool const isPlaceDest = Base::IsKeyTagExists("place") || Base::IsKeyTagExists("de:place");
bool const isAssociatedStreet = type == "associatedStreet";
bool const processAssociatedStreet = isAssociatedStreet &&
Base::IsKeyTagExists("addr:housenumber") &&
@@ -128,13 +144,16 @@ void RelationTagsWay::Process(RelationElement const & e)
continue;
}
- if (isAssociatedStreet && p.first == "wikipedia")
- continue;
+ if (p.first == "wikipedia" || p.first == "wikidata")
+ {
+ if ((isBoundary && !isPlaceDest) || (!isHighway && isAssociatedStreet) || Base::IsKeyTagExists(p.first))
+ continue;
+ }
if (!isBoundary && p.first == "boundary")
continue;
- if (p.first == "place")
+ if (p.first == "place" || p.first == "de:place" || p.first == "capital")
continue;
// Do not pass "ref" tags from boundaries and other, non-route relations to highways.