From da7b6bb8b943c8c49c140bd3350500582dc9280f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Tue, 8 Dec 2015 18:17:21 -0800 Subject: [PATCH] [core] upgrade to GeoJSON VT 3.0.0 --- scripts/android/configure.sh | 2 +- scripts/ios/configure.sh | 2 +- scripts/linux/configure.sh | 2 +- scripts/osx/configure.sh | 2 +- src/mbgl/annotation/shape_annotation_impl.cpp | 46 ++++++++++--------- src/mbgl/annotation/shape_annotation_impl.hpp | 6 +-- 6 files changed, 32 insertions(+), 28 deletions(-) diff --git a/scripts/android/configure.sh b/scripts/android/configure.sh index ff3d88b54..bc19d546a 100644 --- a/scripts/android/configure.sh +++ b/scripts/android/configure.sh @@ -8,7 +8,7 @@ LIBUV_VERSION=1.7.5 ZLIB_VERSION=system NUNICODE_VERSION=1.6 LIBZIP_VERSION=0.11.2 -GEOJSONVT_VERSION=2.1.6.3 +GEOJSONVT_VERSION=3.0.0 VARIANT_VERSION=1.0 RAPIDJSON_VERSION=1.0.2 diff --git a/scripts/ios/configure.sh b/scripts/ios/configure.sh index 7eb4a5b41..06d66c585 100644 --- a/scripts/ios/configure.sh +++ b/scripts/ios/configure.sh @@ -4,6 +4,6 @@ BOOST_VERSION=1.59.0 SQLITE_VERSION=system LIBUV_VERSION=1.7.5 ZLIB_VERSION=system -GEOJSONVT_VERSION=2.1.6.3 +GEOJSONVT_VERSION=3.0.0 VARIANT_VERSION=1.0 RAPIDJSON_VERSION=1.0.2 diff --git a/scripts/linux/configure.sh b/scripts/linux/configure.sh index fb6b3b1bd..0f7e6d167 100644 --- a/scripts/linux/configure.sh +++ b/scripts/linux/configure.sh @@ -10,7 +10,7 @@ SQLITE_VERSION=3.9.1 LIBUV_VERSION=1.7.5 ZLIB_VERSION=system NUNICODE_VERSION=1.6 -GEOJSONVT_VERSION=2.1.6.3 +GEOJSONVT_VERSION=3.0.0 VARIANT_VERSION=1.0 RAPIDJSON_VERSION=1.0.2 GTEST_VERSION=1.7.0 diff --git a/scripts/osx/configure.sh b/scripts/osx/configure.sh index 71bb2c360..d2eee3647 100644 --- a/scripts/osx/configure.sh +++ b/scripts/osx/configure.sh @@ -10,7 +10,7 @@ SQLITE_VERSION=3.9.1 LIBUV_VERSION=1.7.5 ZLIB_VERSION=system NUNICODE_VERSION=1.6 -GEOJSONVT_VERSION=2.1.6.3 +GEOJSONVT_VERSION=3.0.0 VARIANT_VERSION=1.0 RAPIDJSON_VERSION=1.0.2 GTEST_VERSION=1.7.0 diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index 28d4b1e3d..a09430e82 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -11,7 +11,7 @@ namespace mbgl { -using namespace mapbox::util::geojsonvt; +namespace geojsonvt = mapbox::geojsonvt; ShapeAnnotationImpl::ShapeAnnotationImpl(const AnnotationID id_, const ShapeAnnotation& shape_, @@ -27,7 +27,7 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { return; if (shape.properties.is()) { - type = ProjectedFeatureType::LineString; + type = geojsonvt::ProjectedFeatureType::LineString; std::unique_ptr layer = std::make_unique(); layer->layout.join = JoinType::Round; @@ -44,7 +44,7 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { style.addLayer(std::move(layer), AnnotationManager::PointLayerID); } else if (shape.properties.is()) { - type = ProjectedFeatureType::Polygon; + type = geojsonvt::ProjectedFeatureType::Polygon; std::unique_ptr layer = std::make_unique(); @@ -66,8 +66,8 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { std::unique_ptr layer = sourceLayer->clone(); type = layer->is() - ? ProjectedFeatureType::LineString - : ProjectedFeatureType::Polygon; + ? geojsonvt::ProjectedFeatureType::LineString + : geojsonvt::ProjectedFeatureType::Polygon; layer->id = layerID; layer->ref = ""; @@ -87,26 +87,31 @@ void ShapeAnnotationImpl::updateTile(const TileID& tileID, AnnotationTile& tile) const uint64_t maxAmountOfTiles = 1 << maxZoom; const double tolerance = baseTolerance / (maxAmountOfTiles * extent); - ProjectedGeometryContainer rings; - std::vector points; + geojsonvt::ProjectedRings rings; + std::vector points; for (size_t i = 0; i < shape.segments[0].size(); ++i) { // first segment for now (no holes) const double constraintedLatitude = ::fmin(::fmax(shape.segments[0][i].latitude, -util::LATITUDE_MAX), util::LATITUDE_MAX); - points.push_back(LonLat(shape.segments[0][i].longitude, constraintedLatitude)); + points.push_back(geojsonvt::LonLat(shape.segments[0][i].longitude, constraintedLatitude)); } - if (type == ProjectedFeatureType::Polygon && + if (type == geojsonvt::ProjectedFeatureType::Polygon && (points.front().lon != points.back().lon || points.front().lat != points.back().lat)) { - points.push_back(LonLat(points.front().lon, points.front().lat)); + points.push_back(geojsonvt::LonLat(points.front().lon, points.front().lat)); } - ProjectedGeometryContainer ring = Convert::project(points, tolerance); - rings.members.push_back(ring); + auto ring = geojsonvt::Convert::projectRing(points, tolerance); + rings.push_back(ring); - std::vector features; - features.push_back(Convert::create(Tags(), type, rings)); + std::vector features; + features.push_back(geojsonvt::Convert::create(geojsonvt::Tags(), type, rings)); - shapeTiler = std::make_unique(features, maxZoom, 4, 100, 10); + mapbox::geojsonvt::Options options; + options.maxZoom = maxZoom; + options.indexMaxZoom = 4; + options.indexMaxPoints = 100; + options.tolerance = 10; + shapeTiler = std::make_unique(features, options); } const auto& shapeTile = shapeTiler->getTile(tileID.z, tileID.x, tileID.y); @@ -119,20 +124,19 @@ void ShapeAnnotationImpl::updateTile(const TileID& tileID, AnnotationTile& tile) for (auto& shapeFeature : shapeTile.features) { FeatureType featureType = FeatureType::Unknown; - if (shapeFeature.type == TileFeatureType::LineString) { + if (shapeFeature.type == geojsonvt::TileFeatureType::LineString) { featureType = FeatureType::LineString; - } else if (shapeFeature.type == TileFeatureType::Polygon) { + } else if (shapeFeature.type == geojsonvt::TileFeatureType::Polygon) { featureType = FeatureType::Polygon; } assert(featureType != FeatureType::Unknown); GeometryCollection renderGeometry; - for (auto& shapeGeometry : shapeFeature.tileGeometry) { + for (auto& shapeRing : shapeFeature.tileGeometry.get()) { std::vector renderLine; - auto& shapeRing = shapeGeometry.get(); - for (auto& shapePoint : shapeRing.points) { + for (auto& shapePoint : shapeRing) { renderLine.emplace_back(shapePoint.x, shapePoint.y); } diff --git a/src/mbgl/annotation/shape_annotation_impl.hpp b/src/mbgl/annotation/shape_annotation_impl.hpp index 6134e605c..5095d4310 100644 --- a/src/mbgl/annotation/shape_annotation_impl.hpp +++ b/src/mbgl/annotation/shape_annotation_impl.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_SHAPE_ANNOTATION_IMPL #define MBGL_SHAPE_ANNOTATION_IMPL -#include +#include #include #include @@ -32,8 +32,8 @@ public: private: const uint8_t maxZoom; - mapbox::util::geojsonvt::ProjectedFeatureType type; - std::unique_ptr shapeTiler; + mapbox::geojsonvt::ProjectedFeatureType type; + std::unique_ptr shapeTiler; }; } // namespace mbgl