diff options
author | Arne Juul <arnej@verizonmedia.com> | 2020-07-15 12:47:19 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2020-07-15 15:39:25 +0000 |
commit | f32d6c6afbb367ac6bb53d1350e8743af6220cf8 (patch) | |
tree | 977a16e60c64568e3fe5908944dc4422e208cb5e /searchlib/src | |
parent | 7dc8a816fca0242fc00c0ee613252747b29d1f80 (diff) |
added comments and fixed style
Diffstat (limited to 'searchlib/src')
-rw-r--r-- | searchlib/src/vespa/searchlib/common/geo_location.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/searchlib/src/vespa/searchlib/common/geo_location.cpp b/searchlib/src/vespa/searchlib/common/geo_location.cpp index d7a0d7b8ef8..4b072713fdd 100644 --- a/searchlib/src/vespa/searchlib/common/geo_location.cpp +++ b/searchlib/src/vespa/searchlib/common/geo_location.cpp @@ -16,14 +16,22 @@ ZCurve::BoundingBox to_z(GeoLocation::Box box) { GeoLocation::Box adjust_bounding_box(GeoLocation::Box orig, GeoLocation::Point point, uint32_t radius, GeoLocation::Aspect x_aspect) { + if (radius == GeoLocation::radius_inf) { + // only happens if GeoLocation is explicitly constructed with "infinite" radius + return orig; + } uint32_t maxdx = radius; if (x_aspect.active()) { + // x_aspect is a 32-bit fixed-point number in range [0,1] + // so this implements maxdx = ceil(radius/x_aspect) uint64_t maxdx2 = ((static_cast<uint64_t>(radius) << 32) + 0xffffffffu) / x_aspect.multiplier; - if (maxdx2 >= 0xffffffffu) - maxdx = 0xffffffffu; - else - maxdx = static_cast<uint32_t>(maxdx2); + if (maxdx2 >= 0xffffffffu) { + maxdx = 0xffffffffu; + } else { + maxdx = static_cast<uint32_t>(maxdx2); + } } + // implied limits from radius and point: int64_t implied_max_x = int64_t(point.x) + int64_t(maxdx); int64_t implied_min_x = int64_t(point.x) - int64_t(maxdx); @@ -152,6 +160,8 @@ uint64_t GeoLocation::sq_distance_to(Point p) const { if (has_point) { uint64_t dx = (p.x > point.x) ? (p.x - point.x) : (point.x - p.x); if (x_aspect.active()) { + // x_aspect is a 32-bit fixed-point number in range [0,1] + // this implements dx = (dx * x_aspect) dx = (dx * x_aspect.multiplier) >> 32; } uint64_t dy = (p.y > point.y) ? (p.y - point.y) : (point.y - p.y); |