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

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoabinader committed Jun 30, 2016
1 parent d8c0488 commit 040566a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/mbgl/annotation/annotation_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ AnnotationSource::Impl::Impl(Source& base_)

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

void AnnotationSource::Impl::load(FileSource&) {
Expand Down
11 changes: 6 additions & 5 deletions src/mbgl/annotation/shape_annotation_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,10 @@ struct ToGeoJSONVT {
};

void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, AnnotationTileData& data) {
static const double baseTolerance = 4;
const uint64_t maxAmountOfTileFeatures = (1ull << maxZoom) * util::EXTENT;
const double tolerance = 4 / maxAmountOfTileFeatures;

if (!shapeTiler) {
const uint64_t maxAmountOfTileFeatures = (1ull << maxZoom) * util::EXTENT;
const double tolerance = baseTolerance / maxAmountOfTileFeatures;

std::vector<geojsonvt::ProjectedFeature> features = {
ShapeAnnotationGeometry::visit(geometry(), ToGeoJSONVT(tolerance))
};
Expand All @@ -101,7 +99,7 @@ void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, Annotati
options.maxZoom = maxZoom;
options.buffer = 255u;
options.extent = util::EXTENT;
options.tolerance = baseTolerance;
options.tolerance = tolerance;
shapeTiler = std::make_unique<mapbox::geojsonvt::GeoJSONVT>(features, options);
}

Expand All @@ -124,6 +122,9 @@ void ShapeAnnotationImpl::updateTileData(const CanonicalTileID& tileID, Annotati

assert(featureType != FeatureType::Unknown);

const auto& ring = shapeFeature.tileGeometry.get<geojsonvt::TileRings>().front();
printf("shapeFeature.tileGeometry.shapeRing.size: %u\n", uint32_t(ring.size()));

GeometryCollection renderGeometry;
for (const auto& shapeRing : shapeFeature.tileGeometry.get<geojsonvt::TileRings>()) {
GeometryCoordinates renderLine;
Expand Down
21 changes: 21 additions & 0 deletions test/api/annotations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ TEST(Annotations, LineAnnotation) {
test.checkRendering("line_annotation_max_zoom");
}

TEST(Annotations, AnnotationZoomRange) {
AnnotationTest test;

LineString<double> line = {{ { 0, 0 }, { 45, 45 } }};
LineAnnotation annotation { line };

test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json"));
test.map.addAnnotation(annotation);

const auto pixel = test.map.pixelForLatLng({ 0, 0 });
const uint8_t maxZoom = test.map.getMaxZoom();
for (uint8_t zoom = test.map.getMinZoom(); zoom <= maxZoom; ++zoom) {
test.map.setZoom(zoom);
test::render(test.map);
const auto features = test.map.queryRenderedFeatures(pixel);
if (features.empty()) {
printf("zoom: %lf (empty)\n", test.map.getZoom());
}
}
}

TEST(Annotations, FillAnnotation) {
AnnotationTest test;

Expand Down

0 comments on commit 040566a

Please sign in to comment.