summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-18 14:22:17 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-10-19 08:11:41 +0300
commitc50577d039c67b04a60155f7f7b7c6dc9d2c0d30 (patch)
tree5e83fa9664683413ed8a25bfe7c44e5a3b902852 /src/mbgl/annotation
parentef62b78fce06ad93de87e9a6a6775ae33fff214d (diff)
downloadqtlocation-mapboxgl-c50577d039c67b04a60155f7f7b7c6dc9d2c0d30.tar.gz
[core] Fix SymbolAnnotation coordinate system conversions
Diffstat (limited to 'src/mbgl/annotation')
-rw-r--r--src/mbgl/annotation/symbol_annotation_impl.cpp25
1 files changed, 5 insertions, 20 deletions
diff --git a/src/mbgl/annotation/symbol_annotation_impl.cpp b/src/mbgl/annotation/symbol_annotation_impl.cpp
index 040de21214..e5ae5f4b91 100644
--- a/src/mbgl/annotation/symbol_annotation_impl.cpp
+++ b/src/mbgl/annotation/symbol_annotation_impl.cpp
@@ -2,6 +2,7 @@
#include <mbgl/annotation/annotation_tile.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <mbgl/math/clamp.hpp>
+#include <mbgl/util/tile_coordinate.hpp>
namespace mbgl {
@@ -14,26 +15,10 @@ void SymbolAnnotationImpl::updateLayer(const CanonicalTileID& tileID, Annotation
std::unordered_map<std::string, std::string> featureProperties;
featureProperties.emplace("sprite", annotation.icon.empty() ? std::string("default_marker") : annotation.icon);
- const Point<double>& p = annotation.geometry;
-
- // Clamp to the latitude limits of Web Mercator.
- const double constrainedLatitude = util::clamp(p.y, -util::LATITUDE_MAX, util::LATITUDE_MAX);
-
- // Project a coordinate into unit space in a square map.
- const double sine = std::sin(constrainedLatitude * util::DEG2RAD);
- const double x = p.x / util::DEGREES_MAX + 0.5;
- const double y = 0.5 - 0.25 * std::log((1.0 + sine) / (1.0 - sine)) / M_PI;
-
- Point<double> projected(x, y);
- projected *= std::pow(2, tileID.z);
- projected.x = std::fmod(projected.x, 1);
- projected.y = std::fmod(projected.y, 1);
- projected *= double(util::EXTENT);
-
- layer.features.emplace_back(id,
- FeatureType::Point,
- GeometryCollection {{ {{ convertPoint<int16_t>(projected) }} }},
- featureProperties);
+ LatLng latLng { annotation.geometry.y, annotation.geometry.x };
+ TileCoordinate coordinate = TileCoordinate::fromLatLng(0, latLng);
+ GeometryCoordinate tilePoint = TileCoordinate::toGeometryCoordinate(UnwrappedTileID(0, tileID), coordinate.p);
+ layer.features.emplace_back(id, FeatureType::Point, GeometryCollection {{ {{ tilePoint }} }}, featureProperties);
}
} // namespace mbgl