From 4344812ef5ef3b5b67e9f313e0c3cc87b3e95c46 Mon Sep 17 00:00:00 2001 From: Asheem Mamoowala Date: Thu, 26 Apr 2018 07:43:38 -0700 Subject: [core] Streaming TileCover for polygonal regions (#11267) A per-tile streaming algorithm for tile cover on points, lines, and polygons. Works for individual zoom levels, and not zoom ranges. --- include/mbgl/util/projection.hpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/mbgl/util/projection.hpp b/include/mbgl/util/projection.hpp index b4a34521a4..65a84d8dc2 100644 --- a/include/mbgl/util/projection.hpp +++ b/include/mbgl/util/projection.hpp @@ -78,8 +78,9 @@ public: return project_(latLng, worldSize(scale)); } - static Point project(const LatLng& latLng, uint8_t zoom) { - return project_(latLng, std::pow(2.0, zoom)); + //Returns point on tile + static Point project(const LatLng& latLng, int32_t zoom) { + return project_(latLng, 1 << zoom); } static LatLng unproject(const Point& p, double scale, LatLng::WrapMode wrapMode = LatLng::Unwrapped) { @@ -90,16 +91,7 @@ public: wrapMode }; } - - // Project lat, lon to point in a zoom-dependent world size - static Point project(const LatLng& point, uint8_t zoom, uint16_t tileSize) { - const double t2z = tileSize * std::pow(2, zoom); - Point pt = project_(point, t2z); - // Flip y coordinate - auto x = ::round(std::min(pt.x, t2z)); - auto y = ::round(std::min(t2z - pt.y, t2z)); - return { x, y }; - } + private: static Point project_(const LatLng& latLng, double worldSize) { return Point { -- cgit v1.2.1