-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[generator] Actualized and improved popularity generation. #13649
base: release-102
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
#include "geometry/rect2d.hpp" | ||
|
||
#include "base/assert.hpp" | ||
#include "base/math.hpp" | ||
#include "base/stl_helpers.hpp" | ||
|
||
#include <algorithm> | ||
|
@@ -113,16 +114,15 @@ HierarchyLinker::Node::Ptr HierarchyLinker::FindPlaceParent(HierarchyPlace const | |
// is contained in a object with tag 'building'. This case is second. We suppose a building part is | ||
// only inside a building. | ||
static auto const & buildingChecker = ftypes::IsBuildingChecker::Instance(); | ||
static auto const & buildingPartChecker = ftypes::IsBuildingPartChecker::Instance(); | ||
auto const & candidate = candidateNode->GetData(); | ||
if (buildingPartChecker(place.GetTypes()) && | ||
!(buildingChecker(candidate.GetTypes()) || buildingPartChecker(candidate.GetTypes()))) | ||
if (mainTypeIsBuildingPart(place.GetTypes()) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. а есть вообще примеры когда building_part оказывался чем-то полезным? из плохого -- мы начали выделять https://www.openstreetmap.org/relation/1834831 в отдельный объект |
||
!(buildingChecker(candidate.GetTypes()) || mainTypeIsBuildingPart(candidate.GetTypes()))) | ||
{ | ||
return; | ||
} | ||
|
||
// A building part must have children only with 'building:part' type. | ||
if (!buildingPartChecker(place.GetTypes()) && buildingPartChecker(candidate.GetTypes())) | ||
if (!mainTypeIsBuildingPart(place.GetTypes()) && mainTypeIsBuildingPart(candidate.GetTypes())) | ||
return; | ||
|
||
if (place.GetCompositeId() == candidate.GetCompositeId()) | ||
|
@@ -162,7 +162,7 @@ HierarchyLinker::Node::Ptrs HierarchyLinker::Link() | |
} | ||
|
||
HierarchyEntryEnricher::HierarchyEntryEnricher(std::string const & osm2FtIdsPath, | ||
std::string const & countryFullPath) | ||
std::string const & countryFullPath) | ||
: m_featureGetter(countryFullPath) | ||
{ | ||
CHECK(m_osm2FtIds.ReadFromFile(osm2FtIdsPath), (osm2FtIdsPath)); | ||
|
@@ -268,16 +268,26 @@ HierarchyEntry HierarchyLinesBuilder::Transform(HierarchyLinker::Node::Ptr const | |
return line; | ||
} | ||
|
||
HierarchyLinker::Node::Ptrs BuildHierarchy(std::vector<feature::FeatureBuilder> && fbs, | ||
GetMainTypeFn const & getMainType, | ||
HierarchyLinker::Node::Ptrs BuildHierarchy(std::vector<feature::FeatureBuilder> const & fbs, | ||
std::shared_ptr<FilterInterface> const & filter) | ||
{ | ||
base::EraseIf(fbs, [&](auto const & fb) { return !filter->IsAccepted(fb); }); | ||
HierarchyLinker::Node::Ptrs places; | ||
places.reserve(fbs.size()); | ||
base::Transform(fbs, std::back_inserter(places), [](auto const & fb) { | ||
return tree_node::MakeTreeNode(HierarchyPlace(fb)); | ||
}); | ||
for (auto const & fb : fbs) | ||
{ | ||
if (!filter->IsAccepted(fb)) | ||
continue; | ||
|
||
auto hierarchyPlace = HierarchyPlace(fb); | ||
if (!hierarchyPlace.IsPoint() && | ||
base::AlmostEqualAbs(hierarchyPlace.GetArea(), 0.0, std::numeric_limits<double>::epsilon())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. это какой-то популярный вид мусорных объектов? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Линейные объекты у нас могут быть HierarchyPlace? Вроде мы хотим сохранять условный арбат + никто не мешает повесить tourism=attraction на линейный. В FilterComplexPopularity::IsAccepted вижу что линейные выкидываются, не для популярити тоже всегда будем выкидывать? Если да, то почему? |
||
{ | ||
continue; | ||
} | ||
|
||
places.emplace_back(tree_node::MakeTreeNode(std::move(hierarchyPlace))); | ||
} | ||
|
||
auto nodes = HierarchyLinker(std::move(places)).Link(); | ||
// We leave only the trees. | ||
base::EraseIf(nodes, [](auto const & node) { | ||
|
@@ -310,7 +320,6 @@ void FlattenBuildingParts(HierarchyLinker::Node::Ptrs & trees) | |
{ | ||
for (auto & tree : trees) | ||
{ | ||
|
||
CHECK(!tree->HasParent(), ()); | ||
|
||
std::vector< | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ | |
#include "indexer/feature_utils.hpp" | ||
#include "indexer/ftypes_matcher.hpp" | ||
|
||
#include "geometry/latlon.hpp" | ||
#include "geometry/mercator.hpp" | ||
|
||
#include "coding/string_utf8_multilang.hpp" | ||
|
||
#include "base/assert.hpp" | ||
|
@@ -52,8 +55,9 @@ std::string DebugPrint(HierarchyEntry const & entry) | |
ToJSONObject(*obj, "country", entry.m_country); | ||
|
||
auto center = base::NewJSONObject(); | ||
ToJSONObject(*center, "x", entry.m_center.x); | ||
ToJSONObject(*center, "y", entry.m_center.y); | ||
auto const latLon = mercator::ToLatLon(entry.m_center); | ||
ToJSONObject(*center, "lat", latLon.m_lat); | ||
ToJSONObject(*center, "lon", latLon.m_lon); | ||
ToJSONObject(*obj, "center", center); | ||
return DumpToString(obj); | ||
} | ||
|
@@ -82,6 +86,12 @@ uint32_t GetMainType(FeatureParams::Types const & types) | |
return it != std::cend(types) ? *it : ftype::GetEmptyValue(); | ||
} | ||
|
||
bool mainTypeIsBuildingPart(FeatureParams::Types const & types) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. название с большой буквы? |
||
{ | ||
static auto const buildingPartType = classif().GetTypeByPath({"building:part"}); | ||
return GetMainType(types) == buildingPartType; | ||
} | ||
|
||
std::string GetName(StringUtf8Multilang const & str) { return GetRussianName(str); } | ||
|
||
std::string HierarchyEntryToCsvString(HierarchyEntry const & entry, char delim) | ||
|
@@ -99,8 +109,9 @@ coding::CSVReader::Row HierarchyEntryToCsvRow(HierarchyEntry const & entry) | |
|
||
row.emplace_back(parentId); | ||
row.emplace_back(strings::to_string(entry.m_depth)); | ||
row.emplace_back(strings::to_string_dac(entry.m_center.x, 7)); | ||
row.emplace_back(strings::to_string_dac(entry.m_center.y, 7)); | ||
auto const latLon = mercator::ToLatLon(entry.m_center); | ||
row.emplace_back(strings::to_string_dac(latLon.m_lat, 7)); | ||
row.emplace_back(strings::to_string_dac(latLon.m_lon, 7)); | ||
row.emplace_back(strings::to_string(classif().GetReadableObjectName(entry.m_type))); | ||
row.emplace_back(strings::to_string(entry.m_name)); | ||
row.emplace_back(strings::to_string(entry.m_country)); | ||
|
@@ -114,8 +125,8 @@ HierarchyEntry HierarchyEntryFromCsvRow(coding::CSVReader::Row const & row) | |
auto const & id = row[0]; | ||
auto const & parentId = row[1]; | ||
auto const & depth = row[2]; | ||
auto const & x = row[3]; | ||
auto const & y = row[4]; | ||
auto const & lat = row[3]; | ||
auto const & lon = row[4]; | ||
auto const & type = row[5]; | ||
auto const & name = row[6]; | ||
auto const & country = row[7]; | ||
|
@@ -126,8 +137,12 @@ HierarchyEntry HierarchyEntryFromCsvRow(coding::CSVReader::Row const & row) | |
entry.m_parentId = CompositeId(parentId); | ||
|
||
VERIFY(strings::to_size_t(depth, entry.m_depth), (row)); | ||
VERIFY(strings::to_double(x, entry.m_center.x), (row)); | ||
VERIFY(strings::to_double(y, entry.m_center.y), (row)); | ||
|
||
ms::LatLon latLon; | ||
VERIFY(strings::to_double(lat, latLon.m_lat), (row)); | ||
VERIFY(strings::to_double(lon, latLon.m_lon), (row)); | ||
entry.m_center = mercator::FromLatLon(latLon); | ||
|
||
entry.m_type = classif().GetTypeByReadableObjectName(type); | ||
entry.m_name = name; | ||
entry.m_country = country; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
а почему? бывают линейные объекты для которых мы хотим считать popularity, например
https://www.openstreetmap.org/way/385648322
такие объекты могут находиться внутри каких-то площадных