summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2016-06-28 10:23:48 +0300
committerBruno de Oliveira Abinader <bruno@mapbox.com>2016-06-28 12:00:53 +0300
commit1d46e83e3087f0d392c74c40d6b562359ed91576 (patch)
tree7cf4ec38fba5e605106a6792792f4d2db4473eec /src
parente1be2c45c1efdbb5d6e14e9431444292adaf3c9a (diff)
downloadqtlocation-mapboxgl-1d46e83e3087f0d392c74c40d6b562359ed91576.tar.gz
[core] Use the right types for zoom scale logic
32 bit integers should be enough for zoom scale logic. In shape annotation logic, 'maxAmountOfTileFeatures' requires 64 bits because we are multiplying the zoom scale with the extent, which might give a number higher than std::numeric_limits<uint32_t>::max().
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/annotation/shape_annotation_impl.cpp4
-rw-r--r--src/mbgl/map/transform_state.cpp6
2 files changed, 5 insertions, 5 deletions
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp
index a61611cf18..f22debdd81 100644
--- a/src/mbgl/annotation/shape_annotation_impl.cpp
+++ b/src/mbgl/annotation/shape_annotation_impl.cpp
@@ -90,8 +90,8 @@ void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, Annotati
static const double baseTolerance = 4;
if (!shapeTiler) {
- const uint64_t maxAmountOfTiles = 1 << maxZoom;
- const double tolerance = baseTolerance / (maxAmountOfTiles * util::EXTENT);
+ const uint64_t maxAmountOfTileFeatures = (1ull << maxZoom) * util::EXTENT;
+ const double tolerance = baseTolerance / maxAmountOfTileFeatures;
std::vector<geojsonvt::ProjectedFeature> features = {
ShapeAnnotationGeometry::visit(geometry(), ToGeoJSONVT(tolerance))
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp
index fab5991de8..3d5a1a6798 100644
--- a/src/mbgl/map/transform_state.cpp
+++ b/src/mbgl/map/transform_state.cpp
@@ -16,13 +16,13 @@ TransformState::TransformState(ConstrainMode constrainMode_, ViewportMode viewpo
#pragma mark - Matrix
void TransformState::matrixFor(mat4& matrix, const UnwrappedTileID& tileID) const {
- const uint64_t tileScale = 1ull << tileID.canonical.z;
+ const uint32_t tileScale = 1u << tileID.canonical.z;
const double s = worldSize() / tileScale;
matrix::identity(matrix);
matrix::translate(matrix, matrix,
- static_cast<int64_t>(tileID.canonical.x + tileID.wrap * tileScale) * s,
- static_cast<int64_t>(tileID.canonical.y) * s, 0);
+ int64_t(tileID.canonical.x + tileID.wrap * tileScale) * s,
+ int64_t(tileID.canonical.y) * s, 0);
matrix::scale(matrix, matrix, s / util::EXTENT, s / util::EXTENT, 1);
}