diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-08-12 12:32:49 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-10-02 06:16:13 -0700 |
commit | 19179e08bc58e10361bdb387122a6db59552b9ec (patch) | |
tree | edf30fe1e0da98f28d0e04de4b3c7605ed1b2b80 | |
parent | 0ef0a9763c2132a3c5b3bf5833622c235e606f29 (diff) | |
download | qtlocation-mapboxgl-19179e08bc58e10361bdb387122a6db59552b9ec.tar.gz |
[core] Do not constrain on X axis in ConstrainMode::HeightOnly
-rw-r--r-- | platform/node/test/ignores.json | 9 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 25 | ||||
-rw-r--r-- | test/fixtures/offline_database/offline_sideload.db | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | test/style/expression/expression.test.cpp | 21 |
4 files changed, 30 insertions, 25 deletions
diff --git a/platform/node/test/ignores.json b/platform/node/test/ignores.json index 335ca1a53f..e6ef57bd1e 100644 --- a/platform/node/test/ignores.json +++ b/platform/node/test/ignores.json @@ -82,8 +82,6 @@ "query-tests/feature-state/default": "skip - port https://github.com/mapbox/mapbox-gl-js/pull/6263 - needs issue", "query-tests/regressions/mapbox-gl-js#6555": "skip - no querySourceFeatures in mbgl-node; needs issue", "render-tests/background-color/transition": "https://github.com/mapbox/mapbox-gl-native/issues/10619", - "render-tests/basic-v9/z0-wide": "https://github.com/mapbox/mapbox-gl-native/pull/12611", - "render-tests/bright-v9/z0-wide": "https://github.com/mapbox/mapbox-gl-native/pull/12611", "render-tests/collator/resolved-locale": "Some test platforms don't resolve 'en' locale", "render-tests/collator/default": "Some test platforms don't resolve 'en' locale", "render-tests/custom-layer-js/null-island": "skip - js specific", @@ -127,7 +125,6 @@ "render-tests/runtime-styling/image-add-sdf": "https://github.com/mapbox/mapbox-gl-native/issues/9847", "render-tests/runtime-styling/paint-property-fill-flat-to-extrude": "https://github.com/mapbox/mapbox-gl-native/issues/6745", "render-tests/runtime-styling/set-style-paint-property-fill-flat-to-extrude": "https://github.com/mapbox/mapbox-gl-native/issues/6745", - "render-tests/satellite-v9/z0-wide": "https://github.com/mapbox/mapbox-gl-native/pull/12611", "render-tests/symbol-cross-fade/chinese": "https://github.com/mapbox/mapbox-gl-native/issues/10619", "render-tests/symbol-placement/line-overscaled": "https://github.com/mapbox/mapbox-gl-js/issues/5654", "render-tests/symbol-visibility/visible": "https://github.com/mapbox/mapbox-gl-native/issues/10409", @@ -160,8 +157,8 @@ "render-tests/combinations/line-translucent--fill-extrusion-translucent": "needs investigation", "render-tests/combinations/raster-translucent--fill-extrusion-translucent": "needs investigation", "render-tests/combinations/symbol-translucent--fill-extrusion-translucent": "needs investigation", - "render-tests/feature-state/composite-expression": "skip - port https://github.com/mapbox/mapbox-gl-js/pull/6263 - needs issue", - "render-tests/feature-state/data-expression": "skip - port https://github.com/mapbox/mapbox-gl-js/pull/6263 - needs issue", + "render-tests/feature-state/composite-expression": "https://github.com/mapbox/mapbox-gl-native/issues/12613", + "render-tests/feature-state/data-expression": "https://github.com/mapbox/mapbox-gl-native/issues/12613", "render-tests/feature-state/set-paint-property": "skip - port https://github.com/mapbox/mapbox-gl-js/pull/6263 - needs issue", - "render-tests/feature-state/vector-source": "skip - port https://github.com/mapbox/mapbox-gl-js/pull/6263 - needs issue" + "render-tests/feature-state/vector-source": "https://github.com/mapbox/mapbox-gl-native/issues/12613" } diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index 9ff68a1a60..5cbd307698 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -352,21 +352,26 @@ bool TransformState::rotatedNorth() const { } void TransformState::constrain(double& scale_, double& x_, double& y_) const { - // Constrain minimum scale to avoid zooming out far enough to show off-world areas. - scale_ = util::max(scale_, - static_cast<double>(rotatedNorth() ? size.height : size.width) / util::tileSize, - static_cast<double>(rotatedNorth() ? size.width : size.height) / util::tileSize); + if (constrainMode == ConstrainMode::None) { + return; + } + + const double ratioX = (rotatedNorth() ? size.height : size.width) / util::tileSize; + const double ratioY = (rotatedNorth() ? size.width : size.height) / util::tileSize; + + // Constrain minimum scale to avoid zooming out far enough to show off-world areas on the Y axis. + // If Y axis ratio is too small to be constrained, use X axis ratio instead. + scale_ = util::max(scale_, ratioY < 1.0 ? ratioX : ratioY); + + // Constrain min/max pan to avoid showing off-world areas on the Y axis. + double max_y = (scale_ * util::tileSize - (rotatedNorth() ? size.width : size.height)) / 2; + y_ = std::max(-max_y, std::min(y_, max_y)); - // Constrain min/max pan to avoid showing off-world areas. if (constrainMode == ConstrainMode::WidthAndHeight) { + // Constrain min/max pan to avoid showing off-world areas on the X axis. double max_x = (scale_ * util::tileSize - (rotatedNorth() ? size.height : size.width)) / 2; x_ = std::max(-max_x, std::min(x_, max_x)); } - - if (constrainMode != ConstrainMode::None) { - double max_y = (scale_ * util::tileSize - (rotatedNorth() ? size.width : size.height)) / 2; - y_ = std::max(-max_y, std::min(y_, max_y)); - } } void TransformState::moveLatLng(const LatLng& latLng, const ScreenCoordinate& anchor) { diff --git a/test/fixtures/offline_database/offline_sideload.db b/test/fixtures/offline_database/offline_sideload.db Binary files differnew file mode 100644 index 0000000000..8909c402b2 --- /dev/null +++ b/test/fixtures/offline_database/offline_sideload.db diff --git a/test/style/expression/expression.test.cpp b/test/style/expression/expression.test.cpp index 4c2ec5cf92..bed3d4f063 100644 --- a/test/style/expression/expression.test.cpp +++ b/test/style/expression/expression.test.cpp @@ -29,18 +29,21 @@ TEST(Expression, IsExpression) { for(auto& entry : allExpressions.GetObject()) { const std::string name { entry.name.GetString(), entry.name.GetStringLength() }; - if (name == "line-progress" || - name == "feature-state" || - name == "interpolate-hcl" || - name == "interpolate-lab" || - name == "format") { - // Not yet implemented - continue; - } JSDocument document; document.Parse<0>(R"([")" + name + R"("])"); - const JSValue* expression = &document; + + // TODO: "feature-state": https://github.com/mapbox/mapbox-gl-native/issues/12613 + // TODO: "interpolate-hcl": https://github.com/mapbox/mapbox-gl-native/issues/8720 + // TODO: "interpolate-lab": https://github.com/mapbox/mapbox-gl-native/issues/8720 + // TODO: "format": https://github.com/mapbox/mapbox-gl-native/issues/12612 + if (name == "feature-state" || name == "interpolate-hcl" || name == "interpolate-lab" || name == "format") { + if (expression::isExpression(conversion::Convertible(expression))) { + ASSERT_TRUE(false) << "Expression name" << name << "is implemented - please update Expression.IsExpression test."; + } + continue; + } + EXPECT_TRUE(expression::isExpression(conversion::Convertible(expression))) << name; } } |