Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[core] Fix shape annotations disappearing after maxZoom-1 #5418

Merged
merged 3 commits into from
Jun 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/mbgl/util/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ constexpr float tileSize = 512;
* In practice, all features are converted to this extent before being added.
*
* Positions are stored as signed 16bit integers.
* One bit is lost for signedness to support featuers extending past the left edge of the tile.
* One bit is lost for signedness to support features extending past the left edge of the tile.
* One bit is lost because the line vertex buffer packs 1 bit of other data into the int.
* One bit is lost to support features extending past the extent on the right edge of the tile.
* This leaves us with 2^13 = 8192
Expand Down
3 changes: 2 additions & 1 deletion src/mbgl/annotation/annotation_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ AnnotationSource::Impl::Impl(Source& base_)
}

Range<uint8_t> AnnotationSource::Impl::getZoomRange() {
return { 0, 22 };
// Same as default geojson-vt-cpp.
return { 0, 18 };
}

void AnnotationSource::Impl::load(FileSource&) {
Expand Down
4 changes: 2 additions & 2 deletions src/mbgl/annotation/shape_annotation_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions src/mbgl/map/transform_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
10 changes: 10 additions & 0 deletions test/api/annotations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ TEST(Annotations, SymbolAnnotation) {
test.map.addAnnotationIcon("default_marker", namedMarker("default_marker.png"));
test.map.addAnnotation(SymbolAnnotation { Point<double>(0, 0), "default_marker" });
test.checkRendering("point_annotation");

// FIXME: https://github.com/mapbox/mapbox-gl-native/issues/5419
//test.map.setZoom(test.map.getMaxZoom());
//test.checkRendering("point_annotation");
}

TEST(Annotations, LineAnnotation) {
Expand All @@ -55,6 +59,9 @@ TEST(Annotations, LineAnnotation) {
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotation(annotation);
test.checkRendering("line_annotation");

test.map.setZoom(test.map.getMaxZoom());
test.checkRendering("line_annotation_max_zoom");
}

TEST(Annotations, FillAnnotation) {
Expand All @@ -67,6 +74,9 @@ TEST(Annotations, FillAnnotation) {
test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotation(annotation);
test.checkRendering("fill_annotation");

test.map.setZoom(test.map.getMaxZoom());
test.checkRendering("fill_annotation_max_zoom");
}

TEST(Annotations, StyleSourcedShapeAnnotation) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.