diff --git a/src/geo/projection/adjustments.js b/src/geo/projection/adjustments.js index 3ac895d4f73..f652d3e0662 100644 --- a/src/geo/projection/adjustments.js +++ b/src/geo/projection/adjustments.js @@ -88,7 +88,7 @@ function getShearAdjustment(projection, zoom, loc, interpT, withoutRotation?: bo // Calculate how much the map would need to be rotated to make east-west in // projected coordinates be left-right - const angleAdjust = -Math.atan(pdy / pdx); + const angleAdjust = -Math.atan2(pdy, pdx); // Pick a location identical to the original one except for poles to make sure we're within mercator bounds const mc2 = MercatorCoordinate.fromLngLat(loc); diff --git a/test/integration/render-tests/map-projections/rotation-correction-flip/expected.png b/test/integration/render-tests/map-projections/rotation-correction-flip/expected.png new file mode 100644 index 00000000000..124b55bfbb3 Binary files /dev/null and b/test/integration/render-tests/map-projections/rotation-correction-flip/expected.png differ diff --git a/test/integration/render-tests/map-projections/rotation-correction-flip/style.json b/test/integration/render-tests/map-projections/rotation-correction-flip/style.json new file mode 100644 index 00000000000..fbc3e43e96d --- /dev/null +++ b/test/integration/render-tests/map-projections/rotation-correction-flip/style.json @@ -0,0 +1,59 @@ +{ + "version": 8, + "metadata": { + "test": { + "projection": { + "name": "albers", + "parallels": [90, 90], + "center": [10, 30] + }, + "width": 64, + "height": 64 + } + }, + "zoom": 11, + "center": [ + -149.91780281066895, + 61.191643168038084 + ], + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Polygon", + "coordinates": [ + [ + [ + -149.92052793502808, + 61.18806530594994 + ], + [ + -149.91771697998047, + 61.18877884266747 + ], + [ + -149.9149489402771, + 61.188054964719335 + ], + [ + -149.91780281066895, + 61.191643168038084 + ], + [ + -149.92052793502808, + 61.18806530594994 + ] + ] + ] + } + } + }, + "sprite": "local://sprites/sprite", + "layers": [ + { + "id": "fill", + "type": "fill", + "source": "geojson" + } + ] +}