From 3bc599a115ecfb086caaae93fe31a9a347802f19 Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Wed, 21 Jun 2017 11:01:58 -0700 Subject: [PATCH] Implement icon-pitch-alignment following model of text-pitch-alignment. --- src/render/draw_symbol.js | 4 +- src/style-spec/reference/v8.json | 30 +++++++++++++ src/style/style_layer/symbol_style_layer.js | 2 + .../auto-rotation-alignment-map/expected.png | Bin 0 -> 291 bytes .../auto-rotation-alignment-map/style.json | 39 +++++++++++++++++ .../expected.png | Bin 0 -> 213 bytes .../style.json | 38 +++++++++++++++++ .../expected.png | Bin 0 -> 247 bytes .../style.json | 40 ++++++++++++++++++ .../expected.png | Bin 0 -> 365 bytes .../style.json | 40 ++++++++++++++++++ 11 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-map/expected.png create mode 100644 test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-map/style.json create mode 100644 test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-viewport/expected.png create mode 100644 test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-viewport/style.json create mode 100644 test/integration/render-tests/icon-pitch-alignment/map-rotation-alignment-viewport/expected.png create mode 100644 test/integration/render-tests/icon-pitch-alignment/map-rotation-alignment-viewport/style.json create mode 100644 test/integration/render-tests/icon-pitch-alignment/viewport-rotation-alignment-map/expected.png create mode 100644 test/integration/render-tests/icon-pitch-alignment/viewport-rotation-alignment-map/style.json diff --git a/src/render/draw_symbol.js b/src/render/draw_symbol.js index b76558896da..5d17f4c3003 100644 --- a/src/render/draw_symbol.js +++ b/src/render/draw_symbol.js @@ -38,9 +38,7 @@ function drawSymbols(painter, sourceCache, layer, coords) { layer.paint['icon-translate'], layer.paint['icon-translate-anchor'], layer.layout['icon-rotation-alignment'], - // icon-pitch-alignment is not yet implemented - // and we simply inherit the rotation alignment - layer.layout['icon-rotation-alignment'], + layer.layout['icon-pitch-alignment'], layer.layout['icon-keep-upright'] ); diff --git a/src/style-spec/reference/v8.json b/src/style-spec/reference/v8.json index 37e63832e6c..8e8f2bb65af 100644 --- a/src/style-spec/reference/v8.json +++ b/src/style-spec/reference/v8.json @@ -1019,6 +1019,36 @@ } } }, + "icon-pitch-alignment": { + "type": "enum", + "function": "piecewise-constant", + "zoom-function": true, + "values": { + "map": { + "doc": "The icon is aligned to the plane of the map." + }, + "viewport": { + "doc": "The icon is aligned to the plane of the viewport." + }, + "auto": { + "doc": "Automatically matches the value of `icon-rotation-alignment`." + } + }, + "default": "auto", + "doc": "Orientation of icon when map is pitched.", + "requires": [ + "icon-image" + ], + "sdk-support": { + "basic functionality": { + "js": "0.39.0", + "android": null, + "ios": null, + "macos": null + }, + "data-driven styling": {} + } + }, "text-pitch-alignment": { "type": "enum", "function": "piecewise-constant", diff --git a/src/style/style_layer/symbol_style_layer.js b/src/style/style_layer/symbol_style_layer.js index cf7db947238..eea7b256ba2 100644 --- a/src/style/style_layer/symbol_style_layer.js +++ b/src/style/style_layer/symbol_style_layer.js @@ -17,6 +17,8 @@ class SymbolStyleLayer extends StyleLayer { return this.getLayoutValue('symbol-placement', globalProperties, featureProperties) === 'line' ? 'map' : 'viewport'; case 'text-pitch-alignment': return this.getLayoutValue('text-rotation-alignment', globalProperties, featureProperties); + case 'icon-pitch-alignment': + return this.getLayoutValue('icon-rotation-alignment', globalProperties, featureProperties); default: return value; } diff --git a/test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-map/expected.png b/test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-map/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..6a14024dd33bc25593769a4ff64f55d362423d5c GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Or9=|Ar*{or0OmKd3Qj(w+HRL znF?hNJY2v0?!x_^2Ir1h^k)?XPT)SMl3r}bBwlWwnN`4%bA9E~jo|`!ugPZ>WpI>E ze8g8&Je~P{=pEkgm2!+gvml_sB2}q!X_wIE9+ek2>Wrn`)z4tKiX5Hs`%irHS z?UOWRGK*=Hc$+xS;dik*Sz@k)8;2iyn7Ze?|<*`#CcdXZK8FI8 Y1b)dKI+h_OT5=!}Pgg&ebxsLQ01!HI5dZ)H literal 0 HcmV?d00001 diff --git a/test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-map/style.json b/test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-map/style.json new file mode 100644 index 00000000000..72dc6325691 --- /dev/null +++ b/test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-map/style.json @@ -0,0 +1,39 @@ +{ + "version": 8, + "metadata": { + "test": { + "ignored": { + "native": "https://github.com/mapbox/mapbox-gl-native/issues/9345" + }, + "width": 64, + "height": 64 + } + }, + "bearing": 45, + "pitch": 45, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + } + }, + "sprite": "local://sprites/sprite", + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "symbol-placement": "point", + "icon-rotation-alignment": "map", + "icon-image": "oneway" + } + } + ] +} diff --git a/test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-viewport/expected.png b/test/integration/render-tests/icon-pitch-alignment/auto-rotation-alignment-viewport/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..d14c291ff065e80e99c7251c70e318e322e19c3e GIT binary patch literal 213 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Or9=|Ar*{or0OmKd3_+>+k<;~ z85t!QF8Hr;dYHr@`z;{DHHn!s%%DN2FzVLkBbpjp9;LJPEGSgDSIr321OyI_Y==F= zR;sT3(Ny%O!Ee2Nw#n_gSwZ>t^`2k;TV?6$=oL8OrA_UT*=8?`_QbAt3v3Ab(*P1U yt$4nCc8Q_YyU#lRP9|8K)Y`g46k;U92SNX=9V**z_S!E1iFmsDxvX_LhOT;bD(XjgL0pe|`8nyT!%RLu>0Vm+Q)bm5W_eCZC#KhxC)7{W7didW#b_-P ek|hU@?`3%SPk*)IO{2{qdp%wKT-G@yGywo`17h9) literal 0 HcmV?d00001 diff --git a/test/integration/render-tests/icon-pitch-alignment/map-rotation-alignment-viewport/style.json b/test/integration/render-tests/icon-pitch-alignment/map-rotation-alignment-viewport/style.json new file mode 100644 index 00000000000..4b7ebe020ae --- /dev/null +++ b/test/integration/render-tests/icon-pitch-alignment/map-rotation-alignment-viewport/style.json @@ -0,0 +1,40 @@ +{ + "version": 8, + "metadata": { + "test": { + "ignored": { + "native": "https://github.com/mapbox/mapbox-gl-native/issues/9345" + }, + "width": 64, + "height": 64 + } + }, + "bearing": 45, + "pitch": 45, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + } + }, + "sprite": "local://sprites/sprite", + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "symbol-placement": "point", + "icon-rotation-alignment": "viewport", + "icon-pitch-alignment": "map", + "icon-image": "oneway" + } + } + ] +} diff --git a/test/integration/render-tests/icon-pitch-alignment/viewport-rotation-alignment-map/expected.png b/test/integration/render-tests/icon-pitch-alignment/viewport-rotation-alignment-map/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..5e681c3bd2337f69c5b8a99d90bbbbb31032ed3b GIT binary patch literal 365 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Or9=|Ar*{or0Om)FfgitcyABx z^=2xRIq>lP-*-nouRTyO$;7*hLuS!5rKpw+L(Q03Qc>Ak6r-eLVmEKUy4Ep=b8#C> zVEcvzc?H^0Jr2CmpVse?{$tY*G#m;xv<97;pm_PQ>~)i+cb2^rm(F~&;K!dsyMks3 z_8k+7o3Hak~X)OFUXopfby2*|tsp4n%mE_-32FTDt9Pn5eX7;f24s zn(L=r;+=l_@9p>hBi8Hp@6G!jowMYK;>Mdhr@qNtcWv96Sv*^3eJ%RBu;{C~#FwLP zZ59eMz2tNA(*3%ow;o=8>h8}=uWqfo{e`9KZk~J2vd-S7g%?87^6l5Z-W9mV!urRr zKNZsh1!s2ZKj*qWxA)7rjXkSQ-uSWz<`o8p2IhZ^MJ}ETR=WQB0}}Og^>bP0l+XkK DZu6rp literal 0 HcmV?d00001 diff --git a/test/integration/render-tests/icon-pitch-alignment/viewport-rotation-alignment-map/style.json b/test/integration/render-tests/icon-pitch-alignment/viewport-rotation-alignment-map/style.json new file mode 100644 index 00000000000..0739185f044 --- /dev/null +++ b/test/integration/render-tests/icon-pitch-alignment/viewport-rotation-alignment-map/style.json @@ -0,0 +1,40 @@ +{ + "version": 8, + "metadata": { + "test": { + "ignored": { + "native": "https://github.com/mapbox/mapbox-gl-native/issues/9345" + }, + "width": 64, + "height": 64 + } + }, + "bearing": 45, + "pitch": 45, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + } + }, + "sprite": "local://sprites/sprite", + "layers": [ + { + "id": "symbol", + "type": "symbol", + "source": "geojson", + "layout": { + "symbol-placement": "point", + "icon-rotation-alignment": "map", + "icon-pitch-alignment": "viewport", + "icon-image": "oneway" + } + } + ] +}