From fa0b97fff7390eb8ac9a2295c1931088b2b71fe6 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Mon, 28 Jul 2014 15:36:10 +0000 Subject: [PATCH 1/5] add markers placement methods vertex-first and vertex-last --- include/mapnik/markers_placement.hpp | 10 +- .../markers_placements/vertext_first.hpp | 98 +++++++++++++++++ .../markers_placements/vertext_last.hpp | 103 ++++++++++++++++++ include/mapnik/symbolizer_enumerations.hpp | 2 + src/symbolizer_enumerations.cpp | 2 + 5 files changed, 213 insertions(+), 2 deletions(-) create mode 100644 include/mapnik/markers_placements/vertext_first.hpp create mode 100644 include/mapnik/markers_placements/vertext_last.hpp diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp index 6a784a790..bbc15b85e 100644 --- a/include/mapnik/markers_placement.hpp +++ b/include/mapnik/markers_placement.hpp @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include @@ -41,7 +43,9 @@ class markers_placement_finder : mapnik::noncopyable public: using markers_placement = boost::variant, markers_line_placement, - markers_interior_placement>; + markers_interior_placement, + markers_vertex_first_placement, + markers_vertex_last_placement>; class get_point_visitor : public boost::static_visitor { @@ -110,7 +114,9 @@ private: { { MARKER_POINT_PLACEMENT, boost::value_factory>() }, { MARKER_INTERIOR_PLACEMENT, boost::value_factory>() }, - { MARKER_LINE_PLACEMENT, boost::value_factory>() } + { MARKER_LINE_PLACEMENT, boost::value_factory>() }, + { MARKER_VERTEX_FIRST_PLACEMENT, boost::value_factory>() }, + { MARKER_VERTEX_LAST_PLACEMENT, boost::value_factory>() } }; return factories.at(placement_type)(locator, size, tr, detector, spacing, max_error, allow_overlap); } diff --git a/include/mapnik/markers_placements/vertext_first.hpp b/include/mapnik/markers_placements/vertext_first.hpp new file mode 100644 index 000000000..57608fbdd --- /dev/null +++ b/include/mapnik/markers_placements/vertext_first.hpp @@ -0,0 +1,98 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_MARKERS_PLACEMENTS_VERTEXT_FIRST_HPP +#define MAPNIK_MARKERS_PLACEMENTS_VERTEXT_FIRST_HPP + +#include + +namespace mapnik { + +template +class markers_vertex_first_placement : public markers_point_placement +{ +public: + markers_vertex_first_placement( + Locator &locator, + box2d const& size, + agg::trans_affine const& tr, + Detector &detector, + double spacing, + double max_error, + bool allow_overlap) + : markers_point_placement( + locator, size, tr, detector, + spacing, max_error, allow_overlap) + { + } + + bool get_point(double &x, double &y, double &angle, bool ignore_placement) + { + if (this->done_) + { + return false; + } + + if (this->locator_.type() == mapnik::geometry_type::types::Point) + { + return markers_point_placement::get_point(x, y, angle, ignore_placement); + } + + double x0, y0; + + if (agg::is_stop(this->locator_.vertex(&x0, &y0))) + { + this->done_ = true; + return false; + } + + x = x0; + y = y0; + angle = 0; + + double x1, y1; + + if (agg::is_line_to(this->locator_.vertex(&x1, &y1))) + { + angle = std::atan2(y1 - y0, x1 - x0); + } + + box2d box = this->perform_transform(angle, x, y); + + if (!this->allow_overlap_ && !this->detector_.has_placement(box)) + { + return false; + } + + if (!ignore_placement) + { + this->detector_.insert(box); + } + + this->done_ = true; + return true; + } +}; + +} + +#endif // MAPNIK_MARKERS_PLACEMENTS_VERTEXT_FIRST_HPP diff --git a/include/mapnik/markers_placements/vertext_last.hpp b/include/mapnik/markers_placements/vertext_last.hpp new file mode 100644 index 000000000..2ff1f740a --- /dev/null +++ b/include/mapnik/markers_placements/vertext_last.hpp @@ -0,0 +1,103 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_MARKERS_PLACEMENTS_VERTEXT_LAST_HPP +#define MAPNIK_MARKERS_PLACEMENTS_VERTEXT_LAST_HPP + +#include + +namespace mapnik { + +template +class markers_vertex_last_placement : public markers_point_placement +{ +public: + markers_vertex_last_placement( + Locator &locator, + box2d const& size, + agg::trans_affine const& tr, + Detector &detector, + double spacing, + double max_error, + bool allow_overlap) + : markers_point_placement( + locator, size, tr, detector, + spacing, max_error, allow_overlap) + { + } + + bool get_point(double &x, double &y, double &angle, bool ignore_placement) + { + if (this->done_) + { + return false; + } + + double next_x, next_y; + double x0, y0; + double x1, y1; + unsigned command0, command1 = agg::path_cmd_stop; + + while (!agg::is_stop(command0 = this->locator_.vertex(&next_x, &next_y))) + { + command1 = command0; + x1 = x0; + y1 = y0; + x0 = next_x; + y0 = next_y; + } + + // If path stopped on the very firts vertex. + if (agg::is_stop(command1)) + { + this->done_ = true; + return false; + } + + x = x0; + y = y0; + + if (agg::is_line_to(command1)) + { + angle = std::atan2(y0 - y1, x0 - x1); + } + + box2d box = this->perform_transform(angle, x, y); + + if (!this->allow_overlap_ && !this->detector_.has_placement(box)) + { + return false; + } + + if (!ignore_placement) + { + this->detector_.insert(box); + } + + this->done_ = true; + return true; + } +}; + +} + +#endif // MAPNIK_MARKERS_PLACEMENTS_VERTEXT_LAST_HPP diff --git a/include/mapnik/symbolizer_enumerations.hpp b/include/mapnik/symbolizer_enumerations.hpp index 0b3179815..b4b81c1de 100644 --- a/include/mapnik/symbolizer_enumerations.hpp +++ b/include/mapnik/symbolizer_enumerations.hpp @@ -102,6 +102,8 @@ enum marker_placement_enum MARKER_POINT_PLACEMENT, MARKER_INTERIOR_PLACEMENT, MARKER_LINE_PLACEMENT, + MARKER_VERTEX_FIRST_PLACEMENT, + MARKER_VERTEX_LAST_PLACEMENT, marker_placement_enum_MAX }; diff --git a/src/symbolizer_enumerations.cpp b/src/symbolizer_enumerations.cpp index 27e3f9b14..257de804d 100644 --- a/src/symbolizer_enumerations.cpp +++ b/src/symbolizer_enumerations.cpp @@ -65,6 +65,8 @@ static const char * marker_placement_strings[] = { "point", "interior", "line", + "vertex-first", + "vertex-last", "" }; From 3e5b85032849f8306c138f184b3f5c9af7ef0e64 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Thu, 7 Aug 2014 05:37:16 +0000 Subject: [PATCH 2/5] visual tests - markers placement methods vertex-first and vertex-last --- ...-placement-600-400-1.0-grid-reference.json | 111 ++++++++++++++++++ ...-placement-600-400-1.0-grid-reference.json | 111 ++++++++++++++++++ ...st-placement-600-400-1.0-agg-reference.png | Bin 0 -> 878 bytes ...-placement-600-400-1.0-cairo-reference.png | Bin 0 -> 1103 bytes ...st-placement-600-400-2.0-agg-reference.png | Bin 0 -> 1381 bytes ...-placement-600-400-2.0-cairo-reference.png | Bin 0 -> 1449 bytes ...st-placement-600-400-1.0-agg-reference.png | Bin 0 -> 876 bytes ...-placement-600-400-1.0-cairo-reference.png | Bin 0 -> 1097 bytes ...st-placement-600-400-2.0-agg-reference.png | Bin 0 -> 1360 bytes ...-placement-600-400-2.0-cairo-reference.png | Bin 0 -> 1450 bytes ...ker-on-line-and-vertex-first-placement.xml | 28 +++++ ...rker-on-line-and-vertex-last-placement.xml | 28 +++++ tests/visual_tests/test.py | 4 + 13 files changed, 282 insertions(+) create mode 100644 tests/visual_tests/grids/marker-on-line-and-vertex-first-placement-600-400-1.0-grid-reference.json create mode 100644 tests/visual_tests/grids/marker-on-line-and-vertex-last-placement-600-400-1.0-grid-reference.json create mode 100644 tests/visual_tests/images/marker-on-line-and-vertex-first-placement-600-400-1.0-agg-reference.png create mode 100644 tests/visual_tests/images/marker-on-line-and-vertex-first-placement-600-400-1.0-cairo-reference.png create mode 100644 tests/visual_tests/images/marker-on-line-and-vertex-first-placement-600-400-2.0-agg-reference.png create mode 100644 tests/visual_tests/images/marker-on-line-and-vertex-first-placement-600-400-2.0-cairo-reference.png create mode 100644 tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-1.0-agg-reference.png create mode 100644 tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-1.0-cairo-reference.png create mode 100644 tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-2.0-agg-reference.png create mode 100644 tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-2.0-cairo-reference.png create mode 100644 tests/visual_tests/styles/marker-on-line-and-vertex-first-placement.xml create mode 100644 tests/visual_tests/styles/marker-on-line-and-vertex-last-placement.xml diff --git a/tests/visual_tests/grids/marker-on-line-and-vertex-first-placement-600-400-1.0-grid-reference.json b/tests/visual_tests/grids/marker-on-line-and-vertex-first-placement-600-400-1.0-grid-reference.json new file mode 100644 index 000000000..84f2841b3 --- /dev/null +++ b/tests/visual_tests/grids/marker-on-line-and-vertex-first-placement-600-400-1.0-grid-reference.json @@ -0,0 +1,111 @@ +{ + "keys": [ + "", + "3", + "2", + "1" + ], + "data": {}, + "grid": [ + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ! ! ! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !!! ! !! ! !! ", + " !!! ", + " ! ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ## ", + " ############################################################################################################################### ", + " ## ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " $$ ", + " $$$ ", + " $ ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " + ] +} \ No newline at end of file diff --git a/tests/visual_tests/grids/marker-on-line-and-vertex-last-placement-600-400-1.0-grid-reference.json b/tests/visual_tests/grids/marker-on-line-and-vertex-last-placement-600-400-1.0-grid-reference.json new file mode 100644 index 000000000..8f0444cb9 --- /dev/null +++ b/tests/visual_tests/grids/marker-on-line-and-vertex-last-placement-600-400-1.0-grid-reference.json @@ -0,0 +1,111 @@ +{ + "keys": [ + "", + "3", + "2", + "1" + ], + "data": {}, + "grid": [ + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " !! ", + " ! ! !!! ", + " !! ! !! ! !!!! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " !! ! !! ! !! ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ## ", + " ############################################################################################################################## ", + " ## ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " $$ ", + " $$$ ", + " $ ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " + ] +} \ No newline at end of file diff --git a/tests/visual_tests/images/marker-on-line-and-vertex-first-placement-600-400-1.0-agg-reference.png b/tests/visual_tests/images/marker-on-line-and-vertex-first-placement-600-400-1.0-agg-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..cf1c4e93671f1674552981b278cd065ab757e00b GIT binary patch literal 878 zcmeAS@N?(olHy`uVBq!ia0y~yV2WU1V4T3h3>0aQW?l`XbOU@sT!AzyFa~qY7#Qpr z7?KzmrZX_yWMFv0!0`V+5S#Ah1WI$41o;Isa4GpUOgcCF@U=Jc2aoOoTJY4<#WAE} z&f7coc~=}n4kRwt73ghs*y6E8M5FxyQ;d?S`U4h`DSuPb zd{cn3S;0jPKHX~^WjQU&#By48<**zR%VpVhiQ}~H9ggC)f+8_{1fR@z^VsB|e5Ag& zA!DLjgS6Dm&8<>5@7_2eqj&AZn`v&>N)Eb(Z8tMI)@^3AYw<+g_#G3^&h7PK7RgU3 z@>f31A!@Q|$M%Vd9a>V7JsD@@7Ed~svslWQedRL4%O{Sl3Dn9uW3uO-qg)Xn4ZL2mJ9*oM{dnq>b=b}|*;iCIu!}qLyCC9Sr zUTA9njH&Net>V|e`hL}-{-eBaR?X6nnRO#nHU6pTrqx>eRPxfoMgRP{aA957{|#5K zth@Gkb551bkHw)$$RbHw9Qt+Vsqe7)O!{{Fqv^upfLADQ1LcOLWm|Kf4k@6SKqA2{}r%?Tuu z7ujE*vwgo``-x*eby@Bo7wTPCzv=EzlNL8KZOfAD`|s($ek~9kd9v_a>a?wsnh$mF z;ko|k1Ka;P4O@3%zJ9*D0abl!GV)&Smx@guK6>o;(sEY8ABET|9z;|p^nR&dX1k3@NbJp`3OW$IZf(x3B$|an9?Z)2z7dcLQJxHB#K)QyhpO14+ kitnSxd0yF{caVIatiPXaRt(NfhkzlmVv>6 zfgzcJA)0|v+rn9)GtY)8SC@5{dZWG z7xwv*f6>fsR;#{G3;eF~wlw5zvfJLtTW$ufJug}6cPY<(>b`R;@+WPxUiG=wEq3yj z`+-yE8^4;FA|reChwb7%&tsPZTOS)e@;6%7_o456hwaH9R!-Ks%I{Pjzu|cOrDw+E zp6$v@J{vvqHG0=qaPEAEX=h)6-suiw5Ou!85J+80nKIwSUE`(EDZfR^Q?^JxRl6wY z^{dBd@(T`C|6?CORQ$0GAS(Y@0f?$UW&os8XY~95Q9F9}fT$ZiH6ZFoj}4Go>f`py zv!o?RPx-Bim6PV|iFrb@3#XjlvC9`^VNyzr9gupI5@QD9rOvSj@lxlQpR6fet=w0U ze$~2m(v0FQmkKw{0J3u@?EtYS?EtdtCfxwBx7+}-^CtZOv8VhoRLgWZvXuTFv&2{~vHY^6S2NOZHhty{y=} zcj?PdiJL29^88n?e!r$_zWU1IzA&q@ZSAGs|7`kNV?MXsbYAHD$0}dX0poFr{hFtj zPoKN|YMJ(5ljqg5m%Or^_40{kOqv^D6$;3#W%{ zyKwQW+3&+q*XttQ?g`u8*jFy!%3oS9B6MoE{JrUX-6^|Hmi#Y0d?az=nRncmj(`1? z_?{4lD7?x27PQv?oy%yE!C^Zu-f6C)Rth(Zirm OAf2ABelF{r5}E+ZCcJ+D literal 0 HcmV?d00001 diff --git a/tests/visual_tests/images/marker-on-line-and-vertex-first-placement-600-400-2.0-agg-reference.png b/tests/visual_tests/images/marker-on-line-and-vertex-first-placement-600-400-2.0-agg-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..f558b77b79af3fa2418fe91bb443a8fd14e16946 GIT binary patch literal 1381 zcmb_cYf#d86#d!5)C?b~q5WHRq=y@>FqJI2q2U8*6x0>eGGDm%n9?Fjja_@JQ!6M6 zqE4BjX=@LtH7z4c3nP_sESkj((j_D;vY7;&T@fs-#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pMhMB+l%92WK=APa^>D&{GnSSlL z_g!jJWz`oO`P`dYqITSK=Hj=zSFE=GXE(RbR^xx=hf=G*cJH>=y5D}8&^Jf-=!tEU z`ktK#b?wp7ep%2bvsYMox0lsCWpnu>Css|eJuz{ze^N^D$$3vs9F;QMv?8Uy=t;s^ ziHF)ZH_Kei6;Liwt)8L0i8r}rZHj-f%U0K(2~*z`_H}IQ5nMOP_Pn5Puf#&FiON%E z86FBza@Vl#5L_f=>2x!&=bAQ9RQ6cLRuH$a=Nd>6i(%ACm%ad@qZxaEqMj0qFM2)U zP%Z2^29jh;G70LGS!g1nT&Y^raw(x_$mh9+#-_v932`mo6|gTj$cJ zR%^B9fT7tcm%g;UQr8|N`%T$`!Qo!3Y3jK`SD3+ z#NW^DH?_Y%|7+wn(Z8o$`{bIwbx&UCwtanj{!OoadTI~EynRPfRj}v0Qk$19eMPqRa?{(t{#ZQy z;fA=-N!ha8vL_7V&p)WD4Bve7tHJ5S(ibPT-zh$G-FR1|?6tENmw^HkPVE5+{EIbQ z6S(d0s|y=$-R6e(6t7(0*@cmJC$!-Esfn)3=}R=grqwZ#JKv z!2Ms&cV5htezkZxzHq&R$LxL@u;!%qo)C@gSmkke(Y8hP|DMgh_x}9vHrLvtr#M&N=jr~{)y2%h(|xOJ zs&JTmABfTAJd3A$7u(TK>(Vx7A6~Ss@aTrTF3sNuH+U%B-LNW-YyBRPpy;Fe@5S3( zb3ulDzn8bbE`P!#7sE(fuw^gi-`#sJwDQoZ#K76d(>xZ{TzLQC)%)hU^X`dKVp}Us zW=>%{Y$?AC)$I%n4Hk1YoXYztr97$Nkd`OV!C=}VajJ@pf`gD>ges@{nn_Kzopr08hR{h5!Hn literal 0 HcmV?d00001 diff --git a/tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-1.0-agg-reference.png b/tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-1.0-agg-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..f892d137f520ed2f4a9ec2c1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FN;M zv-j|#MKAffU1z>qJ;C+kX=~q#I}XBf6E2-9F!`R2-If_0+jE2F|M!`vw&!1y+MW&V zYI~A;#ID74d2sV}o7IS3YKgy>dFV0QtPc%S!uI3}V>g9F(OEy`WoLR7>CJ3=1=8v1 L>gTe~DWM4fCv&gF literal 0 HcmV?d00001 diff --git a/tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-2.0-agg-reference.png b/tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-2.0-agg-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..69045d7a5d2d31ee027949c08a60ba78d1fed407 GIT binary patch literal 1360 zcmbtUeNfVO82`4_5-(rqrcs#MM9ifUTH$YoI1&Y4iPV^LT4b)yOy%5R>2ev)6azzQ z8K|YH&3C40Il)T>UrJZ5v?OVs5WbbuiIt@6XMcA6wLN#w^W5`!KKH!bJ@@3$L;TH5 zx0nI|%xF|!1^}Nh0a%l7@+pi^re9UT?mK!=7zOqpll1^t0ALQlMgT0|6E*+dxxS= zrCVIk>;IY8FTBB77*YUO%cJ>z9hNG2IjV{n@j-n?*U%}xd#~w5ZN?*)4^{tkENiEx zBzcw>eI+YiUYKYVguOAmy2<~No_)(%b=`hS`7r@YN>Y50b7^s5edkz1yWVnUqLz4W z?s58=G%qi7y60LigR1!Mo2BcKr*9W;7&5tdIpYEvb} zZCf*CE-DXs{m`>ewfWuXtBaC>YO|I~qN4Od1+hTa&ms!aaw+KGG`E;NJU#pA0hbYG zQ)Ncu)9R|$NnKRULxtkzG~R|h09n7>Jo=-{&}e-+Z+Gh(S^li>T>*zrNegMQiWkL8 zuWE0jWGgB?bEJpZT}nLXnwT|QD7TX1eC2_IJtY7AcIx3x+lC#T9lD(=(OB8LTz&GI z`6!_~`%(W*lEl79$H`1FXml-@a?MRKGL(Rul(<^_Ky2Qc?mc(Pl?FjmaZOHtR^B3X zJaZ#w5GUWd&}h(zSPNmA)$Up{?Aaoz*L<_>!M<>ll%h&sC_&bVt#v`P5ZB1?!2oydEI zrSR$Ic4gw6iw>e)cs>bYbA@ioWG5=0KB)9mV|tMROQ`O`?GV}d=x-X6a*E4lWh*K^i?;!(<@!tGMK7Iaz)SC^XUP{A+*2K|>sz+$fA7zsB;_w=i z7d7Wm5GjHa?hJkW;;*5X$H?u|`|14C;=1*e6>G;WL3MUj<=NA{f9bz}5HdRbhix@M z&?sjm1AXtpuaR@Ri2Gees=Hr5zG{%N9!3-E_uLP);tfr$UTDb<>)OXSvEuZdFqe_3 zVX>^LO3YO(^;<~GnVeioyuX_@sZ09Y^sRGxsuQ9TP3=H1gh{k)OcWQ3P{mP8pH6UA z!24Wd(k98l6?UN+8&+MFU3Kssos<+N!#&{vLj)NWrTwH+@LeOrHu$bAl zPJnXAiLuS4n&whAs!eH~*&Ja~>sgG%-VyOj3bliBOxTd{GiGl>0cIu$>qt28L6`p! b`dnTCWgE8Jhsz}J!vlau3GuBXAIkg}Q`;XX literal 0 HcmV?d00001 diff --git a/tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-2.0-cairo-reference.png b/tests/visual_tests/images/marker-on-line-and-vertex-last-placement-600-400-2.0-cairo-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..3e1c3cffeef9c08f28f56d27ebf14282d87b3d35 GIT binary patch literal 1450 zcmbW0dr(q&6vuztV=Y(I%Go8uc6`)URx7&|p|EC(BKaUv@{t&2o938CnMSTV1dAI(DSL8 zP4-LnZaAOLv3}h)-SG0tMn}IrXD|FLy;PMdu*MB{-=Q>RFaPM<;^BXW7HUI@VZi@B zBa+9g^^&>d-h?=|bpPmYv(ng6>WSCp2Emgf=9kXtw_*)Tf0dr!snVHW#+iqmwfALg z|LY_u4!f+HIPcEwSoP?zBVf7<6Wu;dUXBbw^Ec%?n=60>5TSic=!zZ9HB~89-3cs*>@S`VQrLJKhVmI zaVqeFX_0{Cek|-L_c7b{8pGBwP}<2X^OOdyjBTmb`wZegj0#7muPT`+yM|{^GYI5a z!bJMvaVSL#{n#CB$1)Adr=y$#D+DIj<^x38qrQIe!O$<|s6-*RR7qj;g&}x`)MtuG z)ruvZc@8@RlUbdsn~jRr_o4)LRWWns3b*tsg?$#*WtWdbG3!EFr(8|$sc!NxjR*t% z!sYWGn9I1Ozfsr)uZ+ddJ0{J&X|l;l)89tDOE#44$sZM%);Es`RgWS)3o|mqG#z?e zSKf)5(i}YHgNNK}h}=lmv|{=)&4xcx-JIPA6S%aTo4!tgw<+u*VH;075)rVtaxs2u z0@^ib1?z-nE5}}-TtwN1^}OcCrABc&5)jJbJY19Kde#Q(Spm}@I}{S2B)%DuFW9HX)`hzSta55n(qMYTK?uRLOopzeBeXfb8a}?z zUMPU+3NlB594|(nMi%YH9<70|%~5D85RKz29nyS(9;t+BR&)Ac*aK|~2ZyXb*))-e zlvK`6#8TrPb1gix+CzbOC~HT5k1WjEOAx`M);wd_DNJptNF#MP7Tzt?T+2A#c@ATz zC{wRlJOJG z<*JF^+2RXqkHU48-{n40isOBVglKwV!G2#^N&VEspX~lAtvJ3$TD56crpH=GQ8F$k zb^3`ozDnAI>C)k3B^BH6){82q@(xAd%&rm}LpifUdnrfmy{CuQIFe1;8_oDjZIi1Q zg1@$cX9tV%$!GW^;$5~>B&zTpY~MvB#8izOI5fm-zj3d2X&u>WhAZ`6Zu0VGwe#qk z3xh(0#^3FBeEM2VeUjkrKKCSLV^UFEZ{l2)B};S)ReHT7_|rT8yNm6 Lh+oat-C6$tyb4}R literal 0 HcmV?d00001 diff --git a/tests/visual_tests/styles/marker-on-line-and-vertex-first-placement.xml b/tests/visual_tests/styles/marker-on-line-and-vertex-first-placement.xml new file mode 100644 index 000000000..e001cd4d2 --- /dev/null +++ b/tests/visual_tests/styles/marker-on-line-and-vertex-first-placement.xml @@ -0,0 +1,28 @@ + + + + + + + lines + markers + + csv + + wkt, placement + "LINESTRING(0 0)", "vertex-first" + "LINESTRING(0 1, 10 1)", "vertex-first" + "LINESTRING(0 2, 2 3, 4 2, 6 3, 8 2, 10 3)", "vertex-first" + + + + diff --git a/tests/visual_tests/styles/marker-on-line-and-vertex-last-placement.xml b/tests/visual_tests/styles/marker-on-line-and-vertex-last-placement.xml new file mode 100644 index 000000000..b35a65d1a --- /dev/null +++ b/tests/visual_tests/styles/marker-on-line-and-vertex-last-placement.xml @@ -0,0 +1,28 @@ + + + + + + + lines + markers + + csv + + wkt, placement + "LINESTRING(0 0)", "vertex-last" + "LINESTRING(0 1, 10 1)", "vertex-last" + "LINESTRING(0 2, 2 3, 4 2, 6 3, 8 2, 10 3)", "vertex-last" + + + + diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index 4e1324e53..887901a51 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -121,6 +121,10 @@ files = { 'marker-on-line-spacing-eq-width': {'sizes':[(600,400)]}, 'marker-on-line-spacing-eq-width-overlap': {'sizes':[(600,400)]}, 'marker_line_placement_on_points':{}, + 'marker-on-line-and-vertex-first-placement':{'sizes':[(600,400)], + 'bbox': mapnik.Box2d(-1, -1, 11, 4)}, + 'marker-on-line-and-vertex-last-placement':{'sizes':[(600,400)], + 'bbox': mapnik.Box2d(-1, -1, 11, 4)}, 'marker-with-background-image-linear-comp-op': {}, 'marker-with-background-image': {'sizes':[(600,400),(400,600),(257,256)]}, 'marker-with-background-image-and-hsla-transform': {'sizes':[(600,400),(400,600),(257,256)]}, From 04effe9a36df84f34fef27988ced9427c250f569 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Thu, 7 Aug 2014 05:47:37 +0000 Subject: [PATCH 3/5] remove duplicate import --- tests/visual_tests/test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index 887901a51..da095b1b8 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -6,7 +6,6 @@ import mapnik #mapnik.logger.set_severity(mapnik.severity_type.None) #mapnik.logger.set_severity(mapnik.severity_type.Debug) import shutil -import sys import os.path from compare import compare, compare_grids From 9b0953a9550a662a8f7dc50e6a11f2fc526423c5 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Fri, 8 Aug 2014 05:09:01 +0000 Subject: [PATCH 4/5] remove needless virtual inheritance --- include/mapnik/markers_placements/point.hpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/mapnik/markers_placements/point.hpp b/include/mapnik/markers_placements/point.hpp index 4329761c2..bbe97a103 100644 --- a/include/mapnik/markers_placements/point.hpp +++ b/include/mapnik/markers_placements/point.hpp @@ -55,13 +55,12 @@ public: { rewind(); } - virtual ~markers_point_placement() {} /** Start again at first marker. * \note Returns the same list of markers only works when they were NOT added * to the detector. */ - virtual void rewind() + void rewind() { locator_.rewind(0); done_ = false; @@ -75,7 +74,7 @@ public: * \param ignore_placement Whether to add selected position to detector * \return True if a place is found, false if none is found. */ - virtual bool get_point(double &x, double &y, double &angle, bool ignore_placement) + bool get_point(double &x, double &y, double &angle, bool ignore_placement) { if (done_) { From 705260aa06ea91ec36320b903b04ea3b07bdc363 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Fri, 8 Aug 2014 06:11:05 +0000 Subject: [PATCH 5/5] prefer c++ style comments --- include/mapnik/markers_placement.hpp | 12 ++---------- include/mapnik/markers_placements/line.hpp | 6 +++--- include/mapnik/markers_placements/point.hpp | 17 +++-------------- 3 files changed, 8 insertions(+), 27 deletions(-) diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp index bbc15b85e..ca7cf967a 100644 --- a/include/mapnik/markers_placement.hpp +++ b/include/mapnik/markers_placement.hpp @@ -78,22 +78,14 @@ public: { } - /** Get a point where the marker should be placed. - * Each time this function is called a new point is returned. - * \param x Return value for x position - * \param y Return value for x position - * \param angle Return value for rotation angle - * \param ignore_placement Whether to add selected position to detector - * \return True if a place is found, false if none is found. - */ + // Get next point where the marker should be placed. Returns true if a place is found, false if none is found. bool get_point(double &x, double &y, double &angle, bool ignore_placement) { return boost::apply_visitor(get_point_visitor(x, y, angle, ignore_placement), placement_); } private: - /** Factory function for particular placement implementations. - */ + // Factory function for particular placement implementations. static markers_placement create(marker_placement_e placement_type, Locator &locator, box2d const& size, diff --git a/include/mapnik/markers_placements/line.hpp b/include/mapnik/markers_placements/line.hpp index 3244ede79..782a4a04e 100644 --- a/include/mapnik/markers_placements/line.hpp +++ b/include/mapnik/markers_placements/line.hpp @@ -206,13 +206,13 @@ private: double last_y; double next_x; double next_y; - /** If a marker could not be placed at the exact point where it should - * go the next marker's distance will be a bit lower. */ + // If a marker could not be placed at the exact point where it should + // go the next marker's distance will be a bit lower. double error_; double spacing_left_; unsigned marker_nr_; - /** Set spacing_left_, adjusts error_ and performs sanity checks. */ + // Set spacing_left_, adjusts error_ and performs sanity checks. void set_spacing_left(double sl, bool allow_negative=false) { double delta_error = sl - spacing_left_; diff --git a/include/mapnik/markers_placements/point.hpp b/include/mapnik/markers_placements/point.hpp index bbe97a103..60ec39320 100644 --- a/include/mapnik/markers_placements/point.hpp +++ b/include/mapnik/markers_placements/point.hpp @@ -56,24 +56,14 @@ public: rewind(); } - /** Start again at first marker. - * \note Returns the same list of markers only works when they were NOT added - * to the detector. - */ + // Start again at first marker. Returns the same list of markers only works when they were NOT added to the detector. void rewind() { locator_.rewind(0); done_ = false; } - /** Get a point where the marker should be placed. - * Each time this function is called a new point is returned. - * \param x Return value for x position - * \param y Return value for x position - * \param angle Return value for rotation angle - * \param ignore_placement Whether to add selected position to detector - * \return True if a place is found, false if none is found. - */ + // Get next point where the marker should be placed. Returns true if a place is found, false if none is found. bool get_point(double &x, double &y, double &angle, bool ignore_placement) { if (done_) @@ -128,7 +118,7 @@ protected: double marker_width_; bool done_; - /** Rotates the size_ box and translates the position. */ + // Rotates the size_ box and translates the position. box2d perform_transform(double angle, double dx, double dy) { double x1 = size_.minx(); @@ -155,4 +145,3 @@ protected: } #endif // MAPNIK_MARKERS_PLACEMENTS_POINT_HPP -