From 162f82cba5b0fb984c425586c6a4b354917abc47 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Tue, 4 Aug 2015 13:29:16 +0000 Subject: [PATCH 1/7] ensure null text has no bbox --- include/mapnik/text/placement_finder.hpp | 2 +- src/text/placement_finder.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/mapnik/text/placement_finder.hpp b/include/mapnik/text/placement_finder.hpp index 0460b2c52..8bb63a759 100644 --- a/include/mapnik/text/placement_finder.hpp +++ b/include/mapnik/text/placement_finder.hpp @@ -74,7 +74,7 @@ private: // Checks for collision. bool collision(box2d const& box, const value_unicode_string &repeat_key, bool line_placement) const; // Adds marker to glyph_positions and to collision detector. Returns false if there is a collision. - bool add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos) const; + bool add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos, std::vector> & bboxes) const; // Maps upright==auto, left-only and right-only to left,right to simplify processing. // angle = angle of at start of line (to estimate best option for upright==auto) text_upright_e simplify_upright(text_upright_e upright, double angle) const; diff --git a/src/text/placement_finder.cpp b/src/text/placement_finder.cpp index 53dda7da7..4c97e4038 100644 --- a/src/text/placement_finder.cpp +++ b/src/text/placement_finder.cpp @@ -143,7 +143,7 @@ bool placement_finder::find_point_placement(pixel_position const& pos) /* For point placements it is faster to just check the bounding box. */ if (collision(bbox, layouts_.text(), false)) return false; - if (layout.num_lines()) bboxes.push_back(std::move(bbox)); + if (layout.glyphs_count()) bboxes.push_back(std::move(bbox)); pixel_position layout_offset = layout_center - glyphs->get_base_point(); layout_offset.y = -layout_offset.y; @@ -178,7 +178,7 @@ bool placement_finder::find_point_placement(pixel_position const& pos) } // add_marker first checks for collision and then updates the detector. - if (has_marker_ && !add_marker(glyphs, pos)) return false; + if (has_marker_ && !add_marker(glyphs, pos, bboxes)) return false; box2d label_box; bool first = true; @@ -418,7 +418,7 @@ void placement_finder::set_marker(marker_info_ptr m, box2d box, bool mar } -bool placement_finder::add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos) const +bool placement_finder::add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos, std::vector> & bboxes) const { pixel_position real_pos = (marker_unlocked_ ? pos : glyphs->get_base_point()) + marker_displacement_; box2d bbox = marker_box_; @@ -426,6 +426,7 @@ bool placement_finder::add_marker(glyph_positions_ptr & glyphs, pixel_position c glyphs->set_marker(marker_, real_pos); if (collision(bbox, layouts_.text(), false)) return false; detector_.insert(bbox); + bboxes.push_back(std::move(bbox)); return true; } From c1d8095d599d4c7c70fdf19e1abc489502516ff6 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Tue, 4 Aug 2015 13:38:52 +0000 Subject: [PATCH 2/7] shields: set marker after collision test --- src/text/placement_finder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/text/placement_finder.cpp b/src/text/placement_finder.cpp index 4c97e4038..086501e47 100644 --- a/src/text/placement_finder.cpp +++ b/src/text/placement_finder.cpp @@ -423,10 +423,10 @@ bool placement_finder::add_marker(glyph_positions_ptr & glyphs, pixel_position c pixel_position real_pos = (marker_unlocked_ ? pos : glyphs->get_base_point()) + marker_displacement_; box2d bbox = marker_box_; bbox.move(real_pos.x, real_pos.y); - glyphs->set_marker(marker_, real_pos); if (collision(bbox, layouts_.text(), false)) return false; detector_.insert(bbox); bboxes.push_back(std::move(bbox)); + glyphs->set_marker(marker_, real_pos); return true; } From 2913982d31454c0a50628e520778d6224e57a729 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 10 Aug 2015 11:19:11 +0200 Subject: [PATCH 3/7] const --- include/mapnik/svg/svg_converter.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/svg/svg_converter.hpp b/include/mapnik/svg/svg_converter.hpp index 0066a1f29..27fee3122 100644 --- a/include/mapnik/svg/svg_converter.hpp +++ b/include/mapnik/svg/svg_converter.hpp @@ -320,12 +320,12 @@ public: svg_height_ = h; } - double width() + double width() const { return svg_width_; } - double height() + double height() const { return svg_height_; } From 6c018703979ea320047b9fa9bf43e87720b1f832 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 11 Aug 2015 16:21:56 +0200 Subject: [PATCH 4/7] expose mapnik::geometry::polygon::rings_container to allow specialising interior rings container --- include/mapnik/geometry.hpp | 8 +++++++- include/mapnik/geometry_adapters.hpp | 7 +++---- include/mapnik/geometry_fusion_adapted.hpp | 5 ++--- include/mapnik/json/geometry_generator_grammar.hpp | 2 +- include/mapnik/util/spirit_transform_attribute.hpp | 9 ++++----- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index 970f8ddcf..3766ebf23 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -29,6 +29,8 @@ #include #include + + namespace mapnik { namespace geometry { template @@ -91,10 +93,14 @@ struct linear_ring : line_string }; template +using rings_container = std::vector>; + +template class InteriorRings = rings_container> struct polygon { linear_ring exterior_ring; - std::vector> interior_rings; + using rings_container = InteriorRings; + rings_container interior_rings; polygon() = default; inline void set_exterior_ring(linear_ring && ring) diff --git a/include/mapnik/geometry_adapters.hpp b/include/mapnik/geometry_adapters.hpp index 0c7a65713..3f08c2b92 100644 --- a/include/mapnik/geometry_adapters.hpp +++ b/include/mapnik/geometry_adapters.hpp @@ -47,7 +47,6 @@ #include #include -#include // register point BOOST_GEOMETRY_REGISTER_POINT_2D (mapnik::geometry::point, double, boost::geometry::cs::cartesian, x, y) @@ -180,13 +179,13 @@ struct ring_mutable_type > template struct interior_const_type > { - using type = typename std::vector > const&; + using type = typename mapnik::geometry::polygon::rings_container const&; }; template struct interior_mutable_type > { - using type = typename std::vector >&; + using type = typename mapnik::geometry::polygon::rings_container&; }; // exterior @@ -207,7 +206,7 @@ struct exterior_ring > template struct interior_rings > { - using holes_type = std::vector >; + using holes_type = typename mapnik::geometry::polygon::rings_container; static holes_type& get(mapnik::geometry::polygon & p) { return p.interior_rings; diff --git a/include/mapnik/geometry_fusion_adapted.hpp b/include/mapnik/geometry_fusion_adapted.hpp index 6889de61f..e3bdd7ef8 100644 --- a/include/mapnik/geometry_fusion_adapted.hpp +++ b/include/mapnik/geometry_fusion_adapted.hpp @@ -26,7 +26,6 @@ #include #include -#include BOOST_FUSION_ADAPT_STRUCT( mapnik::geometry::point, @@ -43,11 +42,11 @@ BOOST_FUSION_ADAPT_STRUCT( BOOST_FUSION_ADAPT_STRUCT( mapnik::geometry::polygon, (mapnik::geometry::linear_ring const&, exterior_ring) - (std::vector > const& , interior_rings)) + (mapnik::geometry::polygon::rings_container const& , interior_rings)) BOOST_FUSION_ADAPT_STRUCT( mapnik::geometry::polygon, (mapnik::geometry::linear_ring const&, exterior_ring) - (std::vector > const& , interior_rings)) + (mapnik::geometry::polygon::rings_container const& , interior_rings)) #endif // MAPNIK_GEOMETRY_FUSION_ADAPTED_HPP diff --git a/include/mapnik/json/geometry_generator_grammar.hpp b/include/mapnik/json/geometry_generator_grammar.hpp index 01b631804..1095d32c2 100644 --- a/include/mapnik/json/geometry_generator_grammar.hpp +++ b/include/mapnik/json/geometry_generator_grammar.hpp @@ -104,7 +104,7 @@ struct geometry_generator_grammar : karma::rule const&()> polygon; karma::rule const&()> polygon_coord; karma::rule const&()> exterior_ring_coord; - karma::rule > const&()> interior_ring_coord; + karma::rule::rings_container const&()> interior_ring_coord; karma::rule const& ()> multi_point; karma::rule const& ()> multi_point_coord; karma::rule const& ()> multi_linestring; diff --git a/include/mapnik/util/spirit_transform_attribute.hpp b/include/mapnik/util/spirit_transform_attribute.hpp index e924fd822..f7fb1ca43 100644 --- a/include/mapnik/util/spirit_transform_attribute.hpp +++ b/include/mapnik/util/spirit_transform_attribute.hpp @@ -26,7 +26,6 @@ #include #include -#include #include // boost @@ -76,9 +75,9 @@ namespace boost { namespace spirit { namespace traits { template <> struct transform_attribute const, - std::vector > const&, karma::domain> + mapnik::geometry::polygon::rings_container const&, karma::domain> { - using type = std::vector > const&; + using type = mapnik::geometry::polygon::rings_container const&; static type pre(mapnik::geometry::polygon const& poly) { return poly.interior_rings; @@ -164,9 +163,9 @@ namespace boost { namespace spirit { namespace traits { template <> struct transform_attribute const, - std::vector > const&, karma::domain> + mapnik::geometry::polygon::rings_container const&, karma::domain> { - using type = std::vector > const&; + using type = mapnik::geometry::polygon::rings_container const&; static type pre(mapnik::geometry::polygon const& poly) { return poly.interior_rings; From b5dedd0e699684d8f9e28fc2408a21631d1ba0eb Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 11 Aug 2015 17:13:54 +0200 Subject: [PATCH 5/7] JPEG - revive backward compatible quality format jpeg e.g jpeg80, jpeg90 etc. ref #3024 --- src/image_util_jpeg.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/image_util_jpeg.cpp b/src/image_util_jpeg.cpp index 22d6ed480..22cd3539d 100644 --- a/src/image_util_jpeg.cpp +++ b/src/image_util_jpeg.cpp @@ -38,8 +38,8 @@ namespace mapnik { -jpeg_saver::jpeg_saver(std::ostream & stream, std::string const& t): - stream_(stream), t_(t) {} +jpeg_saver::jpeg_saver(std::ostream & stream, std::string const& t) + : stream_(stream), t_(t) {} template void process_rgba8_jpeg(T const& image, std::string const& type, std::ostream & stream) @@ -54,6 +54,13 @@ void process_rgba8_jpeg(T const& image, std::string const& type, std::ostream & auto const& val = kv.second; if ( key == "jpeg" ) continue; + else if ( key.size() > 4 && key.substr(0,4) == "jpeg") + { + if (!mapnik::util::string2int(key.substr(4), quality)) + { + throw image_writer_exception("invalid jpeg quality: '" + key.substr(4) + "'"); + } + } else if ( key == "quality") { if (val && ! (*val).empty()) From ab2855a130c9f0fce5f24d700a66576c189cc3e6 Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Tue, 11 Aug 2015 11:34:35 -0500 Subject: [PATCH 6/7] Made it so that singleton deleted at exit could be turned off. --- SConstruct | 4 ++++ include/mapnik/util/singleton.hpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/SConstruct b/SConstruct index 359801da3..b1c7f30b7 100644 --- a/SConstruct +++ b/SConstruct @@ -301,6 +301,7 @@ opts.AddVariables( ('HOST', 'Set the target host for cross compiling', ''), ('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG), BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'), + BoolVariable('NO_ATEXIT', 'Will prevent Singletons from being deleted atexit of main thread', 'False'), # http://www.scons.org/wiki/GoFastButton # http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'), @@ -1706,6 +1707,9 @@ if not preconfigured: if env['THREADING'] == 'multi': env.Append(CPPDEFINES = '-DMAPNIK_THREADSAFE') + if env['NO_ATEXIT']: + env.Append(CPPDEFINES = '-DMAPNIK_NO_ATEXIT') + # Mac OSX (Darwin) special settings if env['PLATFORM'] == 'Darwin': pthread = '' diff --git a/include/mapnik/util/singleton.hpp b/include/mapnik/util/singleton.hpp index 2c4040603..e77b25b40 100644 --- a/include/mapnik/util/singleton.hpp +++ b/include/mapnik/util/singleton.hpp @@ -119,8 +119,10 @@ template ::create(); pInstance_.store(tmp, std::memory_order_release); +#ifndef MAPNIK_NO_ATEXIT // register destruction std::atexit(&DestroySingleton); +#endif } } } From bf009489d7f1fb9806450fb553b69ecdeb3ff87a Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Tue, 11 Aug 2015 15:31:09 -0500 Subject: [PATCH 7/7] Updated changelog with recent changes --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8facec37f..0810100b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ Developers: Please commit along with changes. For a complete change history, see the git log. +## Future + +Released: YYYY XX, 2015 + +(Packaged from xxxx) + +#### Summary + +- Fixed an issue with fields over size of int32 in OGR plugin (https://github.com/mapnik/node-mapnik/issues/499) +- Added 3 new image-filters to simulate types of colorblindness (`color-blind-protanope`,`color-blind-deuteranope`,`color-blind-tritanope`) +- Fix so that null text boxes have no bounding boxes when attempting placement ( 162f82cba5b0fb984c425586c6a4b354917abc47 ) +- Patch to add legacy method for setting JPEG quality in images ( #3024 ) + ## 3.0.2 Released: July 31, 2015