Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Attempt constraining Y axis ratio first, then X axis #12611

Merged
merged 1 commit into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions platform/node/test/ignores.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
25 changes: 15 additions & 10 deletions src/mbgl/map/transform_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Binary file not shown.
21 changes: 12 additions & 9 deletions test/style/expression/expression.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

brunoabinader marked this conversation as resolved.
Show resolved Hide resolved
EXPECT_TRUE(expression::isExpression(conversion::Convertible(expression))) << name;
}
}
Expand Down