From 19179e08bc58e10361bdb387122a6db59552b9ec Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Sun, 12 Aug 2018 12:32:49 +0300 Subject: [PATCH] [core] Do not constrain on X axis in ConstrainMode::HeightOnly --- platform/node/test/ignores.json | 9 ++---- src/mbgl/map/transform_state.cpp | 29 ++++++++++-------- .../offline_database/offline_sideload.db | Bin 0 -> 4096 bytes test/style/expression/expression.test.cpp | 21 +++++++------ 4 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 test/fixtures/offline_database/offline_sideload.db diff --git a/platform/node/test/ignores.json b/platform/node/test/ignores.json index 335ca1a53..e6ef57bd1 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 9ff68a1a6..5cbd30769 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -352,20 +352,25 @@ 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(rotatedNorth() ? size.height : size.width) / util::tileSize, - static_cast(rotatedNorth() ? size.width : size.height) / util::tileSize); - - // Constrain min/max pan to avoid showing off-world areas. - if (constrainMode == ConstrainMode::WidthAndHeight) { - 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) { + return; } - 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)); + 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)); + + 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)); } } diff --git a/test/fixtures/offline_database/offline_sideload.db b/test/fixtures/offline_database/offline_sideload.db new file mode 100644 index 0000000000000000000000000000000000000000..8909c402b226547ece61086b4460889329da7d58 GIT binary patch literal 4096 zcmd5*XIPWlvQFq-sX=ONbde%WL25uCR1+W&K}vu~APAu&T?tjHbOGrCp`#!cdasHg zMI%+3B0aK|6TIp@=k9&~++X*5o>{Zzo${=icfRW;P&5t&cEozP+Ty^n04e|w2v7rq z0RVt1S=h<)`(q+ssD2qI$r?x&nqT@C{5Pcvkfc_lCc_kzd&f>T%0tRM3J~SNpU7}_ zDq0W-1iVL$v$eyZaA*w5^XEaMX$nz?LBKF|4JZWs69S7cfWc@7u&yBtq60An8ydmD zhHxkpY;3A)pl*r)>q8J=bvVpO*N~iS05OC~kQ2N-Fg7@pt2@S)+$aoULC*P=ckFdX z`=T&59=13%_HT8M{r>-m`u-#8_m3#b*B$MF^8D>PF6xSPKs%yQe>yqFP&iwspU*os z9Bgs6U=65|#<5|Kb#*5f@ci%iKOKOzAlmA1C=4uh9B6BA|IcB^PPn122^<0z`S)>1 z{CoQnV1Eg)uLRgnltEOKng*l-0s_!(4k%yG+Z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q2*ah;6e51nG{pA#QCPU(L189Lk|2`{rb5a}+|mrkp_{jz>$j>`EC zE5$I|NUxT9eyl>;vND~TA(BMb+31I*}Kyp!r(M%QyJa1>0fLgn+bo~KIPx+VhIlrLms z4PVhp+O8@C+o~&0z-Lcqg_h44J5Tz_DzfPoAPL$!lUBAukGkh>w7mSRh%cAepW;hx zb6+vMJAj&3*%4#6F#Ke7g0wzIyC!+zNto&Rd8VW2uh<2J@DN(8@k%V?IxFA>$h06ivhe{lTO%P~Y-!8uIR> zS#Nt0TM5Fg{9Bw`AO7W?8p&)6!P7F$icY?h$YT3f$yVQhQT^@JTJqFJc%?@JGKENG z5RLHT6PGGd*-dv3aRs;aA5~w$HbgA=8)Cyr0U_dTRBaWVctEZ&|7J&HFPE_c>|B0C z(e#9$9pfEFOj~X%-Ho~vSH13yR!{RSz7t!yqR|{Yz9oEP+!^n_e2GQSra7QM(K5y3#^VsW#_G$w~G{fW4g9b(b`Cz VHwBsZ!rzOY@FrM`NwzJ2{1?*Q6Z!xE literal 0 HcmV?d00001 diff --git a/test/style/expression/expression.test.cpp b/test/style/expression/expression.test.cpp index 4c2ec5cf9..bed3d4f06 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; } }