Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatoly Serdtcev <serdtcev@maps.me>2019-01-16 12:28:11 +0300
committerSergey Yershov <syershov@maps.me>2019-01-31 14:04:45 +0300
commita576f983e44496819acaa0cfdba2a6dcbf390610 (patch)
treed3637fa6fd31dd7981d07f7504168bb76507c064 /indexer
parent758d1ab6c1558e6b89cb1b0cdf0b896b08eca971 (diff)
[indexer] Refact closeness weight: chebyshev distance at minimal cell level
Diffstat (limited to 'indexer')
-rw-r--r--indexer/locality_index.hpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/indexer/locality_index.hpp b/indexer/locality_index.hpp
index e4252a91f8..4d0722001c 100644
--- a/indexer/locality_index.hpp
+++ b/indexer/locality_index.hpp
@@ -66,6 +66,8 @@ public:
void ForClosestToPoint(ProcessCloseObject const & processObject, m2::PointD const & center,
double radiusM, uint32_t sizeHint) const
{
+ using Converter = CellIdConverter<MercatorBounds, m2::CellId<DEPTH_LEVELS>>;
+
auto const rect =
MercatorBounds::RectByCenterXYAndSizeInMeters(center, radiusM);
covering::CoveringGetter cov(rect, covering::CoveringMode::Spiral);
@@ -83,22 +85,25 @@ public:
std::map<uint64_t, double> objectWeights{};
- auto cellRelativeWeight = [&bestCells, cellDepth, center] (int64_t cellNumber)
- {
+ auto const centralCell = Converter::ToCellId(center.x, center.y);
+ auto const centralCellXY = centralCell.XY();
+
+ auto chebyshevDistance = [centralCellXY] (auto && cellXY) {
+ auto abs = [](auto && a, auto && b) { return a > b ? a - b : b - a; };
+ auto const distanceX = abs(centralCellXY.first, cellXY.first);
+ auto const distanceY = abs(centralCellXY.second, cellXY.second);
+ return std::max(distanceX, distanceY);
+ };
+
+ auto cellRelativeWeight = [&] (int64_t cellNumber) {
if (bestCells.find(cellNumber) != bestCells.end())
return 1.0;
- using Converter = CellIdConverter<MercatorBounds, m2::CellId<DEPTH_LEVELS>>;
-
auto const cell = m2::CellId<DEPTH_LEVELS>::FromInt64(cellNumber, cellDepth);
- auto const cellCenter = Converter::FromCellId(cell);
- auto const ratingDistance = MercatorBounds::DistanceOnEarth(center, cellCenter);
-
- double minCellX, minCellY, maxCellX, maxCellY;
- Converter::GetCellBounds(cell, minCellX, minCellY, maxCellX, maxCellY);
- auto const distanceError = (maxCellX - minCellX) / 2;
+ auto const distance = chebyshevDistance(cell.XY());
+ CHECK_GREATER(distance, 0, ());
- return 1 / (ratingDistance + distanceError);
+ return 1.0 / distance;
};
auto processAll = [&] (int64_t cellNumber, uint64_t storedId) {