From fea84e44169e112f96e2fb560da05e3ec5f59e6e Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 3 Nov 2021 15:10:17 -0400 Subject: [PATCH 1/2] fix projection rotation adjustment when more than 180deg Previously, it would correct to an upside down rotation if the rotation for locations where the rotation would have been more than 180 degrees. --- src/geo/projection/adjustments.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From 42fee259d1ab3fbfa39df6b12296cb78b53223e2 Mon Sep 17 00:00:00 2001 From: Ansis Brammanis Date: Wed, 3 Nov 2021 16:33:58 -0400 Subject: [PATCH 2/2] add render test --- .../rotation-correction-flip/expected.png | Bin 0 -> 511 bytes .../rotation-correction-flip/style.json | 59 ++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 test/integration/render-tests/map-projections/rotation-correction-flip/expected.png create mode 100644 test/integration/render-tests/map-projections/rotation-correction-flip/style.json 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 0000000000000000000000000000000000000000..124b55bfbb35dd4206855fa4c32362eef7d5cd27 GIT binary patch literal 511 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D%zcY3-whE&A8 zov!Q6nkdjZUppyigNDRWjjjaYKg_p$!VW%>H{vKe+&jxhtUF;tmxQa%A~o04!uTCA z@9GZCi=4Bw^!{DT&u1*H%h@gd^UnG1&%nWMp)Md;kk?Sb>BgeObdJ-7WsbDMHU}34 zr3Z5yTn_AHOyYLIB@yBNKq!Lc+S)l8ybsj#@A$MwKHO7yo#9>MRGA~z2I+##-t0?W zF5l<7Wrm3C=6a?A#y6{C6IdVc&X{{)O-%ougo9tsCM7T?aJ&(X_$wF@cI*Jt0rM&U zn5Sk<5?j5YUh0ow!IGjzsROzj0x#ZCH~1XS*z^A1BD>V)iK44A|Fb-ix)HR)f%Ac6 zM8<_FF0+?-9DeEjUw8$>942<&W%FfgGhfVT>;G@Pj%mW)o6EUH?lESwUbnh_y|Pj0 zw|!3y-+YF4VTC!2zt_4&e^z5{&`zj!IWN2+WWjrx8gTe~DWM4f-DA-- literal 0 HcmV?d00001 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" + } + ] +}