diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2015-12-08 18:17:21 -0800 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-12-10 12:54:58 -0800 |
commit | da7b6bb8b943c8c49c140bd3350500582dc9280f (patch) | |
tree | 1533b187659ce3a26c1664db13d76d4fcc94e848 | |
parent | 655b777635439d64f46930b20e6436c2f36364dc (diff) | |
download | qtlocation-mapboxgl-da7b6bb8b943c8c49c140bd3350500582dc9280f.tar.gz |
[core] upgrade to GeoJSON VT 3.0.0
-rw-r--r-- | scripts/android/configure.sh | 2 | ||||
-rw-r--r-- | scripts/ios/configure.sh | 2 | ||||
-rw-r--r-- | scripts/linux/configure.sh | 2 | ||||
-rw-r--r-- | scripts/osx/configure.sh | 2 | ||||
-rw-r--r-- | src/mbgl/annotation/shape_annotation_impl.cpp | 46 | ||||
-rw-r--r-- | 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 ff3d88b546..bc19d546a1 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 7eb4a5b416..06d66c5850 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 fb6b3b1bdc..0f7e6d167e 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 71bb2c360e..d2eee36479 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 28d4b1e3d4..a09430e829 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -1,4 +1,4 @@ -#include <mapbox/geojsonvt/geojsonvt_convert.hpp> +#include <mapbox/geojsonvt/convert.hpp> #include <mbgl/annotation/shape_annotation_impl.hpp> #include <mbgl/annotation/annotation_manager.hpp> @@ -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<LineAnnotationProperties>()) { - type = ProjectedFeatureType::LineString; + type = geojsonvt::ProjectedFeatureType::LineString; std::unique_ptr<LineLayer> layer = std::make_unique<LineLayer>(); 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<FillAnnotationProperties>()) { - type = ProjectedFeatureType::Polygon; + type = geojsonvt::ProjectedFeatureType::Polygon; std::unique_ptr<FillLayer> layer = std::make_unique<FillLayer>(); @@ -66,8 +66,8 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { std::unique_ptr<StyleLayer> layer = sourceLayer->clone(); type = layer->is<LineLayer>() - ? 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<LonLat> points; + geojsonvt::ProjectedRings rings; + std::vector<geojsonvt::LonLat> 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<ProjectedFeature> features; - features.push_back(Convert::create(Tags(), type, rings)); + std::vector<geojsonvt::ProjectedFeature> features; + features.push_back(geojsonvt::Convert::create(geojsonvt::Tags(), type, rings)); - shapeTiler = std::make_unique<mapbox::util::geojsonvt::GeoJSONVT>(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<mapbox::geojsonvt::GeoJSONVT>(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<geojsonvt::TileRings>()) { std::vector<Coordinate> renderLine; - auto& shapeRing = shapeGeometry.get<TileRing>(); - 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 6134e605c2..5095d4310f 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 <mapbox/geojsonvt/geojsonvt.hpp> +#include <mapbox/geojsonvt.hpp> #include <mbgl/annotation/annotation.hpp> #include <mbgl/annotation/shape_annotation.hpp> @@ -32,8 +32,8 @@ public: private: const uint8_t maxZoom; - mapbox::util::geojsonvt::ProjectedFeatureType type; - std::unique_ptr<mapbox::util::geojsonvt::GeoJSONVT> shapeTiler; + mapbox::geojsonvt::ProjectedFeatureType type; + std::unique_ptr<mapbox::geojsonvt::GeoJSONVT> shapeTiler; }; } // namespace mbgl |