diff --git a/bindings/python/mapnik_map.cpp b/bindings/python/mapnik_map.cpp index 444cab42b..eef527083 100644 --- a/bindings/python/mapnik_map.cpp +++ b/bindings/python/mapnik_map.cpp @@ -96,6 +96,7 @@ void export_map() .add_property("height",&Map::getHeight, &Map::setHeight, "The height of the map.") .add_property("srs",make_function(&Map::srs,return_value_policy()), &Map::set_srs,"Spatial reference in proj4 format e.g. \"+proj=latlong +datum=WGS84\"") + .add_property("buffer_size", &Map::buffer_size,&Map::set_buffer_size,"The size of buffer around map in pixels") .add_property("background",make_function (&Map::background,return_value_policy()), &Map::set_background, "The background color of the map.") diff --git a/include/mapnik/map.hpp b/include/mapnik/map.hpp index 1c67af440..450114fd2 100644 --- a/include/mapnik/map.hpp +++ b/include/mapnik/map.hpp @@ -41,22 +41,22 @@ namespace mapnik enum aspect_fix_mode { - /* grow the width or height of the specified geo bbox to fill the map size. default behaviour. */ - GROW_BBOX, - /* grow the width or height of the map to accomodate the specified geo bbox. */ - GROW_CANVAS, - /* shrink the width or height of the specified geo bbox to fill the map size. */ - SHRINK_BBOX, - /* shrink the width or height of the map to accomodate the specified geo bbox. */ + // grow the width or height of the specified geo bbox to fill the map size. default behaviour. + GROW_BBOX, + // grow the width or height of the map to accomodate the specified geo bbox. + GROW_CANVAS, + // shrink the width or height of the specified geo bbox to fill the map size. + SHRINK_BBOX, + // shrink the width or height of the map to accomodate the specified geo bbox. SHRINK_CANVAS, - /* adjust the width of the specified geo bbox, leave height and map size unchanged */ - ADJUST_BBOX_WIDTH, - /* adjust the height of the specified geo bbox, leave width and map size unchanged */ + // adjust the width of the specified geo bbox, leave height and map size unchanged + ADJUST_BBOX_WIDTH, + // adjust the height of the specified geo bbox, leave width and map size unchanged ADJUST_BBOX_HEIGHT, - /* adjust the width of the map, leave height and geo bbox unchanged */ - ADJUST_CANVAS_WIDTH, - /* adjust the height of the map, leave width and geo bbox unchanged */ - ADJUST_CANVAS_HEIGHT + // adjust the width of the map, leave height and geo bbox unchanged + ADJUST_CANVAS_WIDTH, + //adjust the height of the map, leave width and geo bbox unchanged + ADJUST_CANVAS_HEIGHT }; private: static const unsigned MIN_MAPSIZE=16; @@ -64,13 +64,14 @@ namespace mapnik unsigned width_; unsigned height_; std::string srs_; + int buffer_size_; boost::optional background_; std::map styles_; std::map fontsets_; std::vector layers_; aspect_fix_mode aspectFixMode_; Envelope currentExtent_; - + public: typedef std::map::const_iterator const_style_iterator; @@ -249,6 +250,17 @@ namespace mapnik */ boost::optional const& background() const; + /*! \brief Set buffer size + * @param buffer_size Buffer size in pixels. + */ + + void set_buffer_size(int buffer_size); + + /*! \brief Get the map buffer size + * @return Buffer size as int + */ + int buffer_size() const; + /*! \brief Zoom the map at the current position. * @param factor The factor how much the map is zoomed in or out. */ diff --git a/src/agg_renderer.cpp b/src/agg_renderer.cpp index 83b3f67e6..a10099d12 100644 --- a/src/agg_renderer.cpp +++ b/src/agg_renderer.cpp @@ -113,7 +113,7 @@ namespace mapnik t_(m.getWidth(),m.getHeight(),m.getCurrentExtent(),offset_x,offset_y), font_engine_(), font_manager_(font_engine_), - detector_(Envelope(-64, -64, m.getWidth() + 64 ,m.getHeight() + 64)), + detector_(Envelope(-m.buffer_size(), -m.buffer_size(), m.getWidth() + m.buffer_size() ,m.getHeight() + m.buffer_size())), ras_ptr(new rasterizer) { boost::optional bg = m.background(); diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 433cb7583..9c1f023f6 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -475,7 +475,7 @@ namespace mapnik font_engine_(new freetype_engine()), font_manager_(*font_engine_), face_manager_(font_engine_,font_manager_), - detector_(Envelope(-64 ,-64, m.getWidth() + 64 ,m.getHeight() + 64)) + detector_(Envelope(-m.buffer_size() ,-m.buffer_size() , m.getWidth() + m.buffer_size() ,m.getHeight() + m.buffer_size())) { #ifdef MAPNIK_DEBUG std::clog << "scale=" << m.scale() << "\n"; diff --git a/src/load_map.cpp b/src/load_map.cpp index 0817cfa8a..f41cb10e7 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -127,6 +127,12 @@ namespace mapnik } map.set_srs( get_attr(map_node, "srs", map.srs() )); + + optional buffer_size = get_opt_attr(map_node,"buffer_size"); + if (buffer_size) + { + map.set_buffer_size(*buffer_size); + } } catch (const config_error & ex) { @@ -864,7 +870,14 @@ namespace mapnik get_attr(sym, "placement", POINT_PLACEMENT); shield_symbol.set_label_placement( placement ); - + // don't render shields around edges + optional avoid_edges = + get_opt_attr(sym, "avoid_edges"); + if (avoid_edges) + { + shield_symbol.set_avoid_edges( *avoid_edges); + } + // halo fill and radius optional halo_fill = get_opt_attr(sym, "halo_fill"); if (halo_fill) diff --git a/src/map.cpp b/src/map.cpp index 583ab8844..0e42b81c2 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -35,18 +35,21 @@ namespace mapnik : width_(400), height_(400), srs_("+proj=latlong +datum=WGS84"), + buffer_size_(0), aspectFixMode_(GROW_BBOX) {} Map::Map(int width,int height, std::string const& srs) : width_(width), height_(height), srs_(srs), + buffer_size_(0), aspectFixMode_(GROW_BBOX) {} Map::Map(const Map& rhs) : width_(rhs.width_), height_(rhs.height_), srs_(rhs.srs_), + buffer_size_(rhs.buffer_size_), background_(rhs.background_), styles_(rhs.styles_), layers_(rhs.layers_), @@ -59,6 +62,7 @@ namespace mapnik width_=rhs.width_; height_=rhs.height_; srs_=rhs.srs_; + buffer_size_ = rhs.buffer_size_; background_=rhs.background_; styles_=rhs.styles_; layers_=rhs.layers_; @@ -213,11 +217,21 @@ namespace mapnik return srs_; } - void Map::set_srs(std::string const& srs) - { - srs_ = srs; - } - + void Map::set_srs(std::string const& srs) + { + srs_ = srs; + } + + void Map::set_buffer_size( int buffer_size) + { + buffer_size_ = buffer_size; + } + + int Map::buffer_size() const + { + return buffer_size_; + } + boost::optional const& Map::background() const { return background_;