From 4436721371653d26ee4a22949cfa0e8d126c3c18 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 30 Nov 2012 11:27:06 -0800 Subject: [PATCH 1/8] fix potential compile due to error problematic defines that did not get properly cleaned up in a986aedd057476702688b7 - refs #1400 --- src/debug.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index 864ff6c38..83cf02705 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -60,14 +60,10 @@ logger::severity_type logger::severity_level_ = #if MAPNIK_DEFAULT_LOG_SEVERITY == 0 logger::debug #elif MAPNIK_DEFAULT_LOG_SEVERITY == 1 - logger::info - #elif MAPNIK_DEFAULT_LOG_SEVERITY == 2 logger::warn - #elif MAPNIK_DEFAULT_LOG_SEVERITY == 3 + #elif MAPNIK_DEFAULT_LOG_SEVERITY == 2 logger::error - #elif MAPNIK_DEFAULT_LOG_SEVERITY == 4 - logger::fatal - #elif MAPNIK_DEFAULT_LOG_SEVERITY == 5 + #elif MAPNIK_DEFAULT_LOG_SEVERITY == 3 logger::none #else #error "Wrong default log severity level specified!" From be05aa5b60f1ca5c65fcbae74b737b1b75a64bdc Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Fri, 30 Nov 2012 12:31:58 -0800 Subject: [PATCH 2/8] add palette.to_string() method and add python tests of fixed palette functionality --- bindings/python/mapnik_palette.cpp | 3 ++ include/mapnik/palette.hpp | 1 + src/palette.cpp | 30 +++++++++++ tests/data/palettes/palette256.act | Bin 0 -> 772 bytes tests/data/palettes/palette64.act | Bin 0 -> 772 bytes .../images/support/mapnik-palette-test.png | Bin 0 -> 12148 bytes tests/python_tests/palette_test.py | 49 ++++++++++++++++++ 7 files changed, 83 insertions(+) create mode 100644 tests/data/palettes/palette256.act create mode 100644 tests/data/palettes/palette64.act create mode 100644 tests/python_tests/images/support/mapnik-palette-test.png create mode 100644 tests/python_tests/palette_test.py diff --git a/bindings/python/mapnik_palette.cpp b/bindings/python/mapnik_palette.cpp index d21901735..16a614757 100644 --- a/bindings/python/mapnik_palette.cpp +++ b/bindings/python/mapnik_palette.cpp @@ -51,5 +51,8 @@ void export_palette () // "Creates a new color palette from a file\n" // ) .def( "__init__", boost::python::make_constructor(make_palette)) + .def("to_string", &mapnik::rgba_palette::to_string, + "Returns the palette as a string.\n" + ) ; } diff --git a/include/mapnik/palette.hpp b/include/mapnik/palette.hpp index 4dcbe2ab4..ed94fd07e 100644 --- a/include/mapnik/palette.hpp +++ b/include/mapnik/palette.hpp @@ -151,6 +151,7 @@ public: } bool valid() const; + std::string to_string() const; private: void parse(std::string const& pal, palette_type type); diff --git a/src/palette.cpp b/src/palette.cpp index f402b5dbd..669a44130 100644 --- a/src/palette.cpp +++ b/src/palette.cpp @@ -23,6 +23,10 @@ #include #include +// stl +#include +#include + namespace mapnik { @@ -74,6 +78,32 @@ bool rgba_palette::valid() const return colors_ > 0; } +std::string rgba_palette::to_string() const +{ + unsigned length = rgb_pal_.size(); + unsigned alphaLength = alpha_pal_.size(); + std::ostringstream str(""); + str << "[Palette " << length; + if (length == 1) + { + str << " color"; + } + else + { + str << " colors"; + } + str << std::hex << std::setfill('0'); + for (unsigned i = 0; i < length; i++) { + str << " #"; + str << std::setw(2) << (unsigned)rgb_pal_[i].r; + str << std::setw(2) << (unsigned)rgb_pal_[i].g; + str << std::setw(2) << (unsigned)rgb_pal_[i].b; + if (i < alphaLength) str << std::setw(2) << alpha_pal_[i]; + } + str << "]"; + return str.str(); +} + // return color index in returned earlier palette unsigned char rgba_palette::quantize(rgba const& c) const { diff --git a/tests/data/palettes/palette256.act b/tests/data/palettes/palette256.act new file mode 100644 index 0000000000000000000000000000000000000000..60ab72c457d959cf24008852471fbdba7f9c67f9 GIT binary patch literal 772 zcmWlO%}*Og0L7dCpod<2Myjf)hbl@X8a1k_P~{ehR6QW|R6;LprADBthbUFPHVt1T zX+tS#A$1&+gcM9-3~>x=*g6Yd)`LCZ@p>?mWx!*5AOo2;LwB>h!|(l`UPD7eV`F1e z(}~k3kAHFMvv~PUvK@WqrE-;?cqxoFPLZFnf>9zN9R86 zy?XxZzQ^6&-C^yUzMp?8o_nwJ`foRX{l&c2+%piWTz>y<|7Gp=Q{%>$<*ueb|G0$* z-+X!PNO|Zj-ghD#zT@{E9lzH#bbpeD-!6|F9(^#^PE$};zcSMHz)5)5jNzK&tVS!B<{ zg^dM*5yhZFViZGG%9V(_UrbU0DM9SH$uZigUwKjMWx*u4>Hypq0{92Q)jyZM|Q5-esbZaBUjHJS-SPooHIwZ{XXb^ z^~B&L%;cmI!q(GZ|41Q;Ct{|5k@9@!57 literal 0 HcmV?d00001 diff --git a/tests/python_tests/images/support/mapnik-palette-test.png b/tests/python_tests/images/support/mapnik-palette-test.png new file mode 100644 index 0000000000000000000000000000000000000000..e657620adecda0b657394e7895c640572ba8cbea GIT binary patch literal 12148 zcmV-)FN@HLP)l z5Qm0^;i43hi-M?%aO#LO=cpaaja874kd%{*;g3l6jW%zTx8bWUj+L9omS&llm;aJD z@03TWnuzhUERme1p`f4euuF=hzxcd4v#gKNrh4PJSE#6`|HDP1t+}tRtNE*Gue+qg z#EP`Cuin9TnzGNMzPs17k+#jAwbGoq$fEJdX~oB$ySll`y{e|X(ayxD=gf)P*^1T4 zqx!vy!PlzJ#kA4UrPU&+XmA-P_jH+u#5Hk>lIb{`{He+tTXY&EwzG>(|rW-QCpQ=HlPi{M^9j+t=sc z)9d8R^zOLh-`nTk*X!QZ=i}G@{-)vV*6iie=i}Sn*w3>?9=7u*wF^*wR`>)!9@;OOt*=kwp|>*MF^==JT{@9X2^ z>+$LD=j-e0@9XFA@8az9<^KK2@9*dH@8|XN;qve4>F)IZ?ceY3@AL2L^YiQQ_v`!j z;r{;E^Yicb^Xu;O_xJbe^Yiob_wV=f@ALEb_w)1j_wWDy zU2pR!6NdNf5hc7Q(e|L0+-9X{4_f(b|Nmcm&G2Eq4K`p%xuxBwO&rIGug(m^F#I+D zLJ@?nzJ!<8Us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R@tFnZuUUA6OJ2YiEVk zV2xnDDfI>xugJP)N5Y|a^#>LhEOOP}aYK>n4=lQ^2}WaB*tog_YxRXRPA6CGN;nj! z{=k|s;z@@=R>SHLEb0we27V+M+EtHWK~)yUqw2k7bqN+tz|&e%Iy@X?wW&VA0;4tN za9UQcV1d=T`Vxlx>KClU2INC^)iYQ_4QqfkR73-;p&}Y!4HeM Date: Sun, 2 Dec 2012 18:30:32 -0800 Subject: [PATCH 3/8] add make check target that aliases make test-local - refs #1618 --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7fc6e1b0a..b98d0d993 100755 --- a/Makefile +++ b/Makefile @@ -39,13 +39,15 @@ test: @python tests/run_tests.py -q test-local: - @echo "*** boostrapping local test environment..." - export ${LINK_FIX}=`pwd`/src:${${LINK_FIX}} && \ + @echo "*** Boostrapping local test environment..." + @export ${LINK_FIX}=`pwd`/src:${${LINK_FIX}} && \ export PYTHONPATH=`pwd`/bindings/python/:${PYTHONPATH} && \ export MAPNIK_FONT_DIRECTORY=`pwd`/fonts/dejavu-fonts-ttf-2.33/ttf/ && \ export MAPNIK_INPUT_PLUGINS_DIRECTORY=`pwd`/plugins/input/ && \ make test +check: test-local + demo: @echo "*** Running rundemo.cpp…" cd demo/c++; ./rundemo `mapnik-config --prefix`/lib/mapnik From 388ac9799d1429070eb0baa4aa490156d9dcfd79 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 2 Dec 2012 19:15:22 -0800 Subject: [PATCH 4/8] add a local symlink on linux to libmapnik.so.MAJOR.MINOR to enable easy local testing (without install) - refs #1618 --- src/build.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/build.py b/src/build.py index 68f021f21..e40777915 100644 --- a/src/build.py +++ b/src/build.py @@ -393,5 +393,13 @@ else: env['create_uninstall_target'](env, target1) env['create_uninstall_target'](env, target) + # to enable local testing + lib_major_minor = "%s.%d.%d" % (os.path.basename(env.subst(env['MAPNIK_LIB_NAME'])), int(major), int(minor)) + local_lib = os.path.basename(env.subst(env['MAPNIK_LIB_NAME'])) + if os.path.islink(lib_major_minor) or os.path.exists(lib_major_minor): + os.remove(lib_major_minor) + os.symlink(local_lib,lib_major_minor) + Clean(mapnik,lib_major_minor); + if not env['RUNTIME_LINK'] == 'static': Depends(mapnik, env.subst('../deps/agg/libagg.a')) From 7d408d523c6bd0331a3650aae2e84ee3aa3e31b8 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 2 Dec 2012 19:53:44 -0800 Subject: [PATCH 5/8] close #1548 with explict handling of point geometries and amend 629d768eae5 for cairo/grid renderers to ensure proper placement on lines (refs #1604,#1350,#1607) --- include/mapnik/grid/grid_marker_helpers.hpp | 20 +++++++-- include/mapnik/marker_helpers.hpp | 6 ++- src/cairo_renderer.cpp | 20 +++++++-- tests/visual_tests/compare.py | 2 +- ...ine_placement_on_points-500-reference.json | 40 ++++++++++++++++++ ...line_placement_on_points-500-reference.png | Bin 0 -> 2356 bytes .../marker_line_placement_on_points.xml | 36 ++++++++++++++++ tests/visual_tests/test.py | 1 + 8 files changed, 114 insertions(+), 11 deletions(-) create mode 100644 tests/visual_tests/grids/marker_line_placement_on_points-500-reference.json create mode 100644 tests/visual_tests/images/marker_line_placement_on_points-500-reference.png create mode 100644 tests/visual_tests/styles/marker_line_placement_on_points.xml diff --git a/include/mapnik/grid/grid_marker_helpers.hpp b/include/mapnik/grid/grid_marker_helpers.hpp index a77bd7510..f5e3629a7 100644 --- a/include/mapnik/grid/grid_marker_helpers.hpp +++ b/include/mapnik/grid/grid_marker_helpers.hpp @@ -78,11 +78,17 @@ struct raster_markers_rasterizer_dispatch_grid { marker_placement_e placement_method = sym_.get_marker_placement(); box2d bbox_(0,0, src_.width(),src_.height()); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; - if (placement_method == MARKER_INTERIOR_PLACEMENT) + if (path.type() == LineString) + { + if (!label::middle_point(path, x, y)) + return; + } + else if (placement_method == MARKER_INTERIOR_PLACEMENT) { if (!label::interior_position(path, x, y)) return; @@ -209,11 +215,17 @@ struct vector_markers_rasterizer_dispatch_grid void add_path(T & path) { marker_placement_e placement_method = sym_.get_marker_placement(); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; - if (placement_method == MARKER_INTERIOR_PLACEMENT) + if (path.type() == LineString) + { + if (!label::middle_point(path, x, y)) + return; + } + else if (placement_method == MARKER_INTERIOR_PLACEMENT) { if (!label::interior_position(path, x, y)) return; diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 594617702..7d9861528 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -87,7 +87,8 @@ struct vector_markers_rasterizer_dispatch { marker_placement_e placement_method = sym_.get_marker_placement(); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; @@ -188,7 +189,8 @@ struct raster_markers_rasterizer_dispatch marker_placement_e placement_method = sym_.get_marker_placement(); box2d bbox_(0,0, src_.width(),src_.height()); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 7f43ba5cf..32d38bcf0 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -1550,11 +1550,17 @@ struct markers_dispatch { marker_placement_e placement_method = sym_.get_marker_placement(); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; - if (placement_method == MARKER_INTERIOR_PLACEMENT) + if (path.type() == LineString) + { + if (!label::middle_point(path, x, y)) + return; + } + else if (placement_method == MARKER_INTERIOR_PLACEMENT) { if (!label::interior_position(path, x, y)) return; @@ -1633,11 +1639,17 @@ struct markers_dispatch_2 { marker_placement_e placement_method = sym_.get_marker_placement(); - if (placement_method != MARKER_LINE_PLACEMENT) + if (placement_method != MARKER_LINE_PLACEMENT || + path.type() == Point) { double x = 0; double y = 0; - if (placement_method == MARKER_INTERIOR_PLACEMENT) + if (path.type() == LineString) + { + if (!label::middle_point(path, x, y)) + return; + } + else if (placement_method == MARKER_INTERIOR_PLACEMENT) { if (!label::interior_position(path, x, y)) return; diff --git a/tests/visual_tests/compare.py b/tests/visual_tests/compare.py index 92bea4ad8..3530688c5 100644 --- a/tests/visual_tests/compare.py +++ b/tests/visual_tests/compare.py @@ -85,7 +85,7 @@ def summary(generate=False): global passed if len(errors) != 0: - msg = "Visual text rendering: %s failures" % len(errors) + msg = "Visual text rendering: %s failed / %s passed" % (len(errors),passed) print "-"*len(msg) print msg print "-"*len(msg) diff --git a/tests/visual_tests/grids/marker_line_placement_on_points-500-reference.json b/tests/visual_tests/grids/marker_line_placement_on_points-500-reference.json new file mode 100644 index 000000000..eb5e8d76b --- /dev/null +++ b/tests/visual_tests/grids/marker_line_placement_on_points-500-reference.json @@ -0,0 +1,40 @@ +{ + "keys": [ + "", + "4", + "3", + "6", + "5", + "7", + "1", + "2" + ], + "data": {}, + "grid": [ + " !!!!!! ###### ", + " !!!!! ##### ", + " !! ## ", + " ", + " ", + " ", + " ", + " ", + " $$$$ ", + " $$$$$$ ", + " $$$$$$$ ", + " $$$$$$ ", + " %%%$$%% ", + " %%&&&&% ", + " &&&&&& ", + " &&&&&&& ", + " &&&&&& ", + " && ", + " ", + " ", + " ", + " ", + " ", + " ''' ((( ", + " ''''' ((((( " + ] +} \ No newline at end of file diff --git a/tests/visual_tests/images/marker_line_placement_on_points-500-reference.png b/tests/visual_tests/images/marker_line_placement_on_points-500-reference.png new file mode 100644 index 0000000000000000000000000000000000000000..71b1fb1f10acd634a249358b225acd66401101e8 GIT binary patch literal 2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?sDh(Kn$(m?q4 zi{V#Nb6=p-dd?Rc@cX_Pt;Wh2=?`o4tqf8 z#`sqr2Juh@>!Sy}MPp}{yhR#diSXm%60?=KFjjY2=duGPVWN1k-ZJX5PePvYM0wDrSDTXZd1?q}+1DzW>W$9S+gBK?1C@V=AreOxnis778^c{>yG2e|nc(WR+$ajn)GQ3WO+}vtEUBt)j~Z_Bq$G?$mX5-^Z9)*JuW8&uNi_M`bQMXFa+&f$6W z=$<;s&>BoU@C%4^@22b9`A)wcd8)qV-1rVw(fNROJx*h2xiB^j9tQqRfcPx{AT1vW z0OHO7VZc9aME|Hid(_C}*^}hma<}B({azC?V=yr58*Ywm));TOYQ+yQHZ4s$0qgE& z8}h`e*8w+IgTvGfK+WrTmlr?|XbjVY8qnyr(cm4rLgYwki;dYjOcm^ropOlactQ4h;>WyF48ffnOf&>jOYt(lDJ6~-VR%}f{lsn$5D;kjV2s_g!t%>Sw}_b=^tQ0~&C z<&&SCZ8mHMbyC|_Guv;>(w$bCOb0VgsgJklTpuin&x;>R7L9bI+xhIXa4vpv;$nCc g6Tf}u-^U73|I58YW?{zd;4}o-**e&iTcdG*0NTlCBme*a literal 0 HcmV?d00001 diff --git a/tests/visual_tests/styles/marker_line_placement_on_points.xml b/tests/visual_tests/styles/marker_line_placement_on_points.xml new file mode 100644 index 000000000..db11328c6 --- /dev/null +++ b/tests/visual_tests/styles/marker_line_placement_on_points.xml @@ -0,0 +1,36 @@ + + + + + + 1 + + csv + + x,y,id + 0,0,1 + 5,0,1 + 5,5,1 + 0,5,1 + 2.5,2.5,2 + 2.5,3,3 + 2.5,2,3 + 3,2.5,3 + 2,2.5,3 + + + + \ No newline at end of file diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index d5192bc80..6cfb1e002 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -38,6 +38,7 @@ files = [ {'name': "lines-3", 'sizes': sizes_few_square,'bbox':default_text_box}, {'name': "lines-shield", 'sizes': sizes_few_square,'bbox':default_text_box}, {'name': "marker-multi-policy", 'sizes':[(600,400)]}, + {'name': "marker_line_placement_on_points"}, {'name': "whole-centroid", 'sizes':[(600,400)], 'bbox': mapnik.Box2d(736908, 4390316, 2060771, 5942346)}, {'name': "simple-E", 'bbox':mapnik.Box2d(-0.05, -0.01, 0.95, 0.01)}, From 9da47afc05a9e08ecb37263c4b9dfeb9eb8332c2 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 2 Dec 2012 19:58:40 -0800 Subject: [PATCH 6/8] update changelog after #1614 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d6bfd47..a5b716508 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ For a complete change history, see the git log. ## Future +- Added support for DBF `Logical` type: #1614 + - Added serialization of `line-offset` to save_map (#1562) - Enabled default input plugin directory and fonts path to be set inherited from environment settings in From e9ca5b47e2c2d711f69d9047e66c0afba6572020 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 2 Dec 2012 21:37:39 -0800 Subject: [PATCH 7/8] finish support for dbf logical type, strip handling of memo, and add tests for all basic types - refs #1614 --- plugins/input/shape/dbfile.cpp | 4 ++-- plugins/input/shape/shape_datasource.cpp | 7 +++++-- tests/data/csv/long_lat.vrt | 2 +- tests/data/shp/long_lat.dbf | Bin 0 -> 688 bytes tests/data/shp/long_lat.dbt | Bin 0 -> 519 bytes tests/data/shp/long_lat.prj | 1 + tests/data/shp/long_lat.shp | Bin 0 -> 128 bytes tests/data/shp/long_lat.shx | Bin 0 -> 108 bytes tests/python_tests/shapefile_test.py | 17 +++++++++++++++++ 9 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 tests/data/shp/long_lat.dbf create mode 100644 tests/data/shp/long_lat.dbt create mode 100644 tests/data/shp/long_lat.prj create mode 100644 tests/data/shp/long_lat.shp create mode 100644 tests/data/shp/long_lat.shx diff --git a/plugins/input/shape/dbfile.cpp b/plugins/input/shape/dbfile.cpp index 7ed0da535..d2583200c 100644 --- a/plugins/input/shape/dbfile.cpp +++ b/plugins/input/shape/dbfile.cpp @@ -134,8 +134,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f) switch (fields_[col].type_) { case 'C': - case 'D'://todo handle date? - case 'M': + case 'D': { // FIXME - avoid constructing std::string on stack std::string str(record_+fields_[col].offset_,fields_[col].length_); @@ -152,6 +151,7 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature & f) } else { + // NOTE: null logical fields use '?' f.put(name,false); } break; diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index 366ea46f5..736f7e913 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -50,6 +50,7 @@ DATASOURCE_PLUGIN(shape_datasource) using mapnik::String; using mapnik::Double; using mapnik::Integer; +using mapnik::Boolean; using mapnik::datasource_exception; using mapnik::filter_in_box; using mapnik::filter_at_point; @@ -121,10 +122,12 @@ void shape_datasource::bind() const case 'C': // character case 'D': // Date case 'M': // Memo, a string - case 'L': // logical case '@': // timestamp desc_.add_descriptor(attribute_descriptor(fld_name, String)); break; + case 'L': // logical + desc_.add_descriptor(attribute_descriptor(fld_name, Boolean)); + break; case 'N': case 'O': // double case 'F': // float @@ -153,7 +156,7 @@ void shape_datasource::bind() const } } - catch (const datasource_exception& ex) + catch (datasource_exception const& ex) { MAPNIK_LOG_ERROR(shape) << "Shape Plugin: error processing field attributes, " << ex.what(); throw; diff --git a/tests/data/csv/long_lat.vrt b/tests/data/csv/long_lat.vrt index 45513c909..2fa0a9f41 100644 --- a/tests/data/csv/long_lat.vrt +++ b/tests/data/csv/long_lat.vrt @@ -1,6 +1,6 @@ - long_lat.csv + long_lat.csv wkbPoint WGS84 diff --git a/tests/data/shp/long_lat.dbf b/tests/data/shp/long_lat.dbf new file mode 100644 index 0000000000000000000000000000000000000000..d3716daf8e7576feed41c8f52328381cf1f901ee GIT binary patch literal 688 zcmZSP;bCHAU|?WmTnC~sfRDeQJ5QaRJdBsL~9) l3I+<)1=Kb##LdXmgt|@~Ql=Rj=@}Rp85kNF8W|W#0RZDjNt*xw literal 0 HcmV?d00001 diff --git a/tests/data/shp/long_lat.dbt b/tests/data/shp/long_lat.dbt new file mode 100644 index 0000000000000000000000000000000000000000..608c3574087e8e1b6c97f9ced23e5f6f7d217ff0 GIT binary patch literal 519 UcmZQ#7zHCa1k6lLjZLJa01J!(J^%m! literal 0 HcmV?d00001 diff --git a/tests/data/shp/long_lat.prj b/tests/data/shp/long_lat.prj new file mode 100644 index 000000000..a30c00a55 --- /dev/null +++ b/tests/data/shp/long_lat.prj @@ -0,0 +1 @@ +GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]] \ No newline at end of file diff --git a/tests/data/shp/long_lat.shp b/tests/data/shp/long_lat.shp new file mode 100644 index 0000000000000000000000000000000000000000..0112cd7431dd7097ebdbb33080103bf093267f16 GIT binary patch literal 128 dcmZQzQ0HR64jf)EGcYh>mm^gaWDFNJvjC3#0crpM literal 0 HcmV?d00001 diff --git a/tests/data/shp/long_lat.shx b/tests/data/shp/long_lat.shx new file mode 100644 index 0000000000000000000000000000000000000000..cc0b42ae71278ead5436b5b39b9af072f35d15d9 GIT binary patch literal 108 ccmZQzQ0HR64$NLKGcYh>mm^iw2&jPz0C0Z+kN^Mx literal 0 HcmV?d00001 diff --git a/tests/python_tests/shapefile_test.py b/tests/python_tests/shapefile_test.py index 1a706eed3..c447f1e04 100644 --- a/tests/python_tests/shapefile_test.py +++ b/tests/python_tests/shapefile_test.py @@ -52,6 +52,23 @@ if 'shape' in mapnik.DatasourceCache.plugin_names(): query.add_property_name('bogus') fs = ds.features(query) + def test_dbf_logical_field_is_boolean(): + ds = mapnik.Shapefile(file='../data/shp/long_lat') + eq_(len(ds.fields()),7) + eq_(ds.fields(),['LONG', 'LAT', 'LOGICAL_TR', 'LOGICAL_FA', 'CHARACTER', 'NUMERIC', 'DATE']) + eq_(ds.field_types(),['str', 'str', 'bool', 'bool', 'str', 'float', 'str']) + query = mapnik.Query(ds.envelope()) + for fld in ds.fields(): + query.add_property_name(fld) + feat = ds.all_features()[0] + eq_(feat.id(),1) + eq_(feat['LONG'],'0') + eq_(feat['LAT'],'0') + eq_(feat['LOGICAL_TR'],True) + eq_(feat['LOGICAL_FA'],False) + eq_(feat['CHARACTER'],'254') + eq_(feat['NUMERIC'],32) + eq_(feat['DATE'],'20121202') if __name__ == "__main__": setup() From 95ceee84fac2cd9dffad0931889522a87c723537 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 2 Dec 2012 22:46:58 -0800 Subject: [PATCH 8/8] sync cairo shield rendering with agg - closes #1602 - amends bd9609c370dd8aed --- src/agg/agg_renderer.cpp | 7 +++++-- src/cairo_renderer.cpp | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index b7642a7b3..651f33e32 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -272,8 +272,11 @@ void agg_renderer::end_style_processing(feature_type_style const& st) } template -void agg_renderer::render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, - double opacity, composite_mode_e comp_op) +void agg_renderer::render_marker(pixel_position const& pos, + marker const& marker, + agg::trans_affine const& tr, + double opacity, + composite_mode_e comp_op) { typedef agg::rgba8 color_type; typedef agg::order_rgba order_type; diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 32d38bcf0..2ef9506ec 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -54,6 +54,7 @@ // boost #include #include +#include // agg #include "agg_conv_clip_polyline.h" @@ -1212,7 +1213,13 @@ void cairo_renderer_base::render_marker(pixel_position const& pos, marker const& else if (marker.is_bitmap()) { agg::trans_affine matrix = tr; - matrix *= agg::trans_affine_translation(pos.x, pos.y); + double width = (*marker.get_bitmap_data())->width(); + double height = (*marker.get_bitmap_data())->height(); + double cx = 0.5 * width; + double cy = 0.5 * height; + matrix *= agg::trans_affine_translation( + boost::math::iround(pos.x - cx), + boost::math::iround(pos.y - cy)); context.add_image(matrix, **marker.get_bitmap_data(), opacity); } } @@ -1294,14 +1301,16 @@ void cairo_renderer_base::process(shield_symbolizer const& sym, placements_type const& placements = helper.placements(); for (unsigned int ii = 0; ii < placements.size(); ++ii) { - pixel_position marker_pos = helper.get_marker_position(placements[ii]); + pixel_position pos = helper.get_marker_position(placements[ii]); + pos.x += 0.5 * helper.get_marker_width(); + pos.y += 0.5 * helper.get_marker_height(); double dx = 0.5 * helper.get_marker_width(); double dy = 0.5 * helper.get_marker_height(); agg::trans_affine marker_tr = agg::trans_affine_translation(-dx,-dy); marker_tr *= agg::trans_affine_scaling(scale_factor_); marker_tr *= agg::trans_affine_translation(dx,dy); marker_tr *= helper.get_image_transform(); - render_marker(marker_pos, + render_marker(pos, helper.get_marker(), marker_tr, sym.get_opacity());