diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-08-07 14:45:48 +0300 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-08-08 12:53:32 +0300 |
commit | 15a26231474d08e3884e424601b609c53d7ef086 (patch) | |
tree | d71c8c3edd53aadbbe2f29b4d8109055b6c62e1b | |
parent | fd73dea05e645041cf27a28ba67ce37eb6d4c6bc (diff) | |
download | qtlocation-mapboxgl-15a26231474d08e3884e424601b609c53d7ef086.tar.gz |
[core] Add lineMetrics to GeoJSONOptions
This patch also bumps geojson-vt-cpp version to 6.6.0,
which enables the `lineMetrics` option.
-rw-r--r-- | cmake/mason-dependencies.cmake | 2 | ||||
-rw-r--r-- | include/mbgl/style/sources/geojson_source.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/conversion/geojson_options.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.cpp | 1 | ||||
-rw-r--r-- | test/style/conversion/geojson_options.test.cpp | 5 |
5 files changed, 17 insertions, 2 deletions
diff --git a/cmake/mason-dependencies.cmake b/cmake/mason-dependencies.cmake index d4e0378804..cffce0a440 100644 --- a/cmake/mason-dependencies.cmake +++ b/cmake/mason-dependencies.cmake @@ -5,7 +5,7 @@ mason_use(variant VERSION 1.1.4 HEADER_ONLY) mason_use(unique_resource VERSION cba309e HEADER_ONLY) mason_use(rapidjson VERSION 1.1.0 HEADER_ONLY) mason_use(boost VERSION 1.65.1 HEADER_ONLY) -mason_use(geojsonvt VERSION 6.5.1 HEADER_ONLY) +mason_use(geojsonvt VERSION 6.6.0 HEADER_ONLY) mason_use(supercluster VERSION 0.2.2 HEADER_ONLY) mason_use(kdbush VERSION 0.1.1-1 HEADER_ONLY) mason_use(earcut VERSION 0.12.4 HEADER_ONLY) diff --git a/include/mbgl/style/sources/geojson_source.hpp b/include/mbgl/style/sources/geojson_source.hpp index 372e7c7a78..a03b910279 100644 --- a/include/mbgl/style/sources/geojson_source.hpp +++ b/include/mbgl/style/sources/geojson_source.hpp @@ -18,6 +18,7 @@ struct GeoJSONOptions { uint16_t tileSize = util::tileSize; uint16_t buffer = 128; double tolerance = 0.375; + bool lineMetrics = false; // Supercluster options bool cluster = false; diff --git a/src/mbgl/style/conversion/geojson_options.cpp b/src/mbgl/style/conversion/geojson_options.cpp index 52a5030c34..77340e5f1d 100644 --- a/src/mbgl/style/conversion/geojson_options.cpp +++ b/src/mbgl/style/conversion/geojson_options.cpp @@ -77,6 +77,16 @@ optional<GeoJSONOptions> Converter<GeoJSONOptions>::operator()(const Convertible } } + const auto lineMetricsValue = objectMember(value, "lineMetrics"); + if (lineMetricsValue) { + if (toBool(*lineMetricsValue)) { + options.lineMetrics = *toBool(*lineMetricsValue); + } else { + error = { "GeoJSON source lineMetrics value must be a boolean" }; + return nullopt; + } + } + return { options }; } diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index fd6d7d3013..5ec3909d3e 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -64,6 +64,7 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) vtOptions.extent = util::EXTENT; vtOptions.buffer = ::round(scale * options.buffer); vtOptions.tolerance = scale * options.tolerance; + vtOptions.lineMetrics = options.lineMetrics; data = std::make_unique<GeoJSONVTData>(geoJSON, vtOptions); } } diff --git a/test/style/conversion/geojson_options.test.cpp b/test/style/conversion/geojson_options.test.cpp index 4c5a0c9aa4..181189775b 100644 --- a/test/style/conversion/geojson_options.test.cpp +++ b/test/style/conversion/geojson_options.test.cpp @@ -32,6 +32,7 @@ TEST(GeoJSONOptions, RetainsDefaults) { ASSERT_EQ(converted.maxzoom, defaults.maxzoom); ASSERT_EQ(converted.buffer, defaults.buffer); ASSERT_EQ(converted.tolerance, defaults.tolerance); + ASSERT_EQ(converted.lineMetrics, defaults.lineMetrics); // Supercluster ASSERT_EQ(converted.cluster, defaults.cluster); @@ -47,7 +48,8 @@ TEST(GeoJSONOptions, FullConversion) { "tolerance": 3, "cluster": true, "clusterRadius": 4, - "clusterMaxZoom": 5 + "clusterMaxZoom": 5, + "lineMetrics": true })JSON", error); // GeoJSON-VT @@ -55,6 +57,7 @@ TEST(GeoJSONOptions, FullConversion) { ASSERT_EQ(converted.maxzoom, 1); ASSERT_EQ(converted.buffer, 2); ASSERT_EQ(converted.tolerance, 3); + ASSERT_TRUE(converted.lineMetrics); // Supercluster ASSERT_EQ(converted.cluster, true); |