From dfd40b27a54115cdf769abdda3ec4d3a1329758c Mon Sep 17 00:00:00 2001 From: Jesse Bounds Date: Tue, 16 Aug 2016 15:04:12 -0700 Subject: [PATCH] [tests] Add tests for shape overlays crossing the antimeridian This adds two tests: AntimeridianAnnotationSmall: Test that a shape that is represented with +-180 longitudinal values is drawn spanning the antimeridian. In other words, it is rendered as a "small" shape as opposed to one that spans around the world to reach the other side of the antimeridian. This test is currently failing at the time of this commit. AntimeridianAnnotationLarge: Test that a shape that is represented with points that do not cross the +-180 boundary is rendered as a "large" shape. In other words, it is rendered by wrapping around the world to reach the other side of the meridian. This test is currently passing at the time of this commit. --- test/api/annotations.cpp | 42 ++++++++++++++++++ .../expected.png | Bin 0 -> 1579 bytes .../expected.png | Bin 0 -> 1652 bytes 3 files changed, 42 insertions(+) create mode 100644 test/fixtures/annotations/antimeridian_annotation_large/expected.png create mode 100644 test/fixtures/annotations/antimeridian_annotation_small/expected.png diff --git a/test/api/annotations.cpp b/test/api/annotations.cpp index 9ec449758..b6f861f90 100644 --- a/test/api/annotations.cpp +++ b/test/api/annotations.cpp @@ -79,6 +79,48 @@ TEST(Annotations, FillAnnotation) { test.checkRendering("fill_annotation_max_zoom"); } +TEST(Annotations, AntimeridianAnnotationSmall) { + AnnotationTest test; + + double antimeridian = 180; + test.map.setLatLngZoom(mbgl::LatLng(0, antimeridian), 0); + test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + + LineString line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; + LineAnnotation lineAnnotation { line }; + lineAnnotation.color = { { 255, 0, 0, 1 } }; + lineAnnotation.width = { 2 }; + test.map.addAnnotation(lineAnnotation); + + Polygon polygon = {{ {{ { antimeridian+10, 0 }, { antimeridian - 10, 10 }, { antimeridian-10, -10 } }} }}; + FillAnnotation polygonAnnotation { polygon }; + polygonAnnotation.color = { { 0, 0, 255, 1 } }; + test.map.addAnnotation(polygonAnnotation); + + test.checkRendering("antimeridian_annotation_small"); +} + +TEST(Annotations, AntimeridianAnnotationLarge) { + AnnotationTest test; + + double antimeridian = 180; + test.map.setLatLngZoom(mbgl::LatLng(0, antimeridian), 0); + test.map.setStyleJSON(util::read_file("test/fixtures/api/empty.json")); + + LineString line = {{ { antimeridian, 20 }, { antimeridian, -20 } }}; + LineAnnotation lineAnnotation { line }; + lineAnnotation.color = { { 255, 0, 0, 1 } }; + lineAnnotation.width = { 2 }; + test.map.addAnnotation(lineAnnotation); + + Polygon polygon = {{ {{ { antimeridian-10, 0 }, { -antimeridian+10, 10 }, { -antimeridian+10, -10 } }} }}; + FillAnnotation polygonAnnotation { polygon }; + polygonAnnotation.color = { { 0, 0, 255, 1 } }; + test.map.addAnnotation(polygonAnnotation); + + test.checkRendering("antimeridian_annotation_large"); +} + TEST(Annotations, OverlappingFillAnnotation) { AnnotationTest test; diff --git a/test/fixtures/annotations/antimeridian_annotation_large/expected.png b/test/fixtures/annotations/antimeridian_annotation_large/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..3e8de0b38c422584e55a375c7366355e2aaaf882 GIT binary patch literal 1579 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;3=FJKJzX3_ zDj471e(2X6z{7Uo?2muzZJyqb@Yr@&B=2_hv>6D>*bUFfy@l2q=s) zhFBmdcs(fGZM&_1#n&~#{tuSNozzluQ1EhKaPf?4cW`863@FI(QWH>BU|6KG)_K8# z1_lia6IJ03ApwTKN!Jtu0vs4bWM)m`bm8P^(C~aMprN6_z{Tf#l4TJKi^G&9r5qw6 z0t~F}%TkyEnV1y3E?Kc~ad9*>IR_gxYA`YisAkGCv9i{2Ut9A;gz0v@Q2ftb_t)Fp z)_N|)u-a!=&HQlobAl231%w#fi?{V3Sm@9uaEq&(TZys2BEy<9MXZBc$(+&nd}J<* zpO^rHI&<_qhcrgU36)k^$_1Mm7%U`jd}1-;=4d!`IZ(QBGAql0lLw}$Pl$A2NSW7n zi(`(?hyOATckYYWuQz??*mnN>%egEZd$@e61Tx%S?Af+2mwS=2=4RqDQkFZ+ z5m|R;scsM#V5sJgW|;;IH1FQ%%`D%Tm=fM6b{_}=(klzIryYoMV0dGjBNzb;cOBEb zvqCqxL5_%T(Pd)UC)iP4=FU*__}$)a?jx}kkqWF1K$kr3b=cqi-uLkInn;G2Lw7!^ z=$+sTE*0KzSmdii0x(i|4q5g%uro4VNbIUoFaSmh+d~<*1mdKI;Vst0G7v4q5uE@ literal 0 HcmV?d00001 diff --git a/test/fixtures/annotations/antimeridian_annotation_small/expected.png b/test/fixtures/annotations/antimeridian_annotation_small/expected.png new file mode 100644 index 0000000000000000000000000000000000000000..cfe564feabf0edce908aa411913523b250abebdc GIT binary patch literal 1652 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G!U;i$lZxy-8q?;3=C{~o-U3d z6^w6hU(Ay-6k)lrwCl>h|JS$qOHau9su*yzpnT(TcFo96iRAeQCwnyJ7Are6FfcN) za0n=jGKN?nEO1J=zis~Y^?!eT-JN7td`9y_^10M#Q${9HCawie7iCz~L<1Nmv!&l; z(P9yCXkBE<;iI*HL5=s^Ce9EJjRr2)Vu2YU4vaohb5ey@2m~;Qc0E%tSlPfd!^GmW zT7cpL1}%}ZjtN1GtOl6{(|i{=IWUH3%xXTcgo!KR(gU5@4y_GLD*{Z|8$DS?4lFrX z8~g3;AbRi`>N=oP$_=m4KRpCfR&7X6RCQn)Eu!TT100nb${s<5JMQ==|;R1NlQ%2bORpGzc7vZECj9Gc(l=W-#qb+-&h9vC-~M zA5(?L=12T8f360FGptsvE8oxeFLoO1yATHMmOmNY_4a&!j?Z?K<9vGmeJ#UJ$@@1S zJ}t8Sv;WM~XOv%`0+8>^n)y$fHZX#j20e4w%~01&sD>8(ptaG``e8Nz-olS)78&q Iol`;+03ZsM)Bpeg literal 0 HcmV?d00001