diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-02-22 02:07:11 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-03-01 20:58:54 +0000 |
commit | b325df880baf6f3a454c51d2e21d69114477c276 (patch) | |
tree | 7268047f2dc599c4f8ad72b304a06826c84a5d99 /src | |
parent | 9771b0e569d91c37ab3ac98ef8bee11c816ddc80 (diff) | |
download | qtlocation-mapboxgl-b325df880baf6f3a454c51d2e21d69114477c276.tar.gz |
[core] Simplify Screen to Geometry coordinate conversion
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/annotation/point_annotation_impl.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile.hpp | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/mbgl/annotation/point_annotation_impl.cpp b/src/mbgl/annotation/point_annotation_impl.cpp index b0bce8c308..b54995bfdd 100644 --- a/src/mbgl/annotation/point_annotation_impl.cpp +++ b/src/mbgl/annotation/point_annotation_impl.cpp @@ -12,15 +12,15 @@ void PointAnnotationImpl::updateLayer(const TileID& tileID, AnnotationTileLayer& std::unordered_map<std::string, std::string> featureProperties; featureProperties.emplace("sprite", point.icon.empty() ? std::string("default_marker") : point.icon); - const mbgl::ScreenCoordinate pp = point.position.project(); - const uint32_t z2 = 1 << tileID.z; - const uint32_t x = pp.x * z2; - const uint32_t y = pp.y * z2; - const GeometryCoordinate coordinate(GeometryTileFeature::defaultExtent * (pp.x * z2 - x), GeometryTileFeature::defaultExtent * (pp.y * z2 - y)); + mbgl::ScreenCoordinate projected = point.position.project(); + projected *= 1 << tileID.z; + projected.x -= int16_t(projected.x); + projected.y -= int16_t(projected.y); + projected *= GeometryTileFeature::defaultExtent; layer.features.emplace_back( std::make_shared<const AnnotationTileFeature>(FeatureType::Point, - GeometryCollection {{ {{ coordinate }} }}, + GeometryCollection {{ {{ GeometryCoordinate { projected } }} }}, featureProperties)); } diff --git a/src/mbgl/tile/geometry_tile.hpp b/src/mbgl/tile/geometry_tile.hpp index 3fcb910371..6236e4e889 100644 --- a/src/mbgl/tile/geometry_tile.hpp +++ b/src/mbgl/tile/geometry_tile.hpp @@ -25,6 +25,8 @@ enum class FeatureType : uint8_t { }; // Normalized vector tile coordinates. +// Each geometry coordinate represents a point in a bidimensional space, +// varying from -V...0...+V, where V is the maximum extent applicable. using GeometryCoordinate = vec2<int16_t>; using GeometryCoordinates = std::vector<GeometryCoordinate>; using GeometryCollection = std::vector<GeometryCoordinates>; |