+ expose buffer_size parameter (default 0)

influences envelope used by placement detector 
  ( i.e. 'avoid_edges' parameter)
This commit is contained in:
Artem Pavlenko 2008-09-21 10:14:38 +00:00
parent 565da55742
commit 20f3a9460d
6 changed files with 63 additions and 23 deletions

View File

@ -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<copy_const_reference>()),
&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<copy_const_reference>()),
&Map::set_background, "The background color of the map.")

View File

@ -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<Color> background_;
std::map<std::string,feature_type_style> styles_;
std::map<std::string,FontSet> fontsets_;
std::vector<Layer> layers_;
aspect_fix_mode aspectFixMode_;
Envelope<double> currentExtent_;
public:
typedef std::map<std::string,feature_type_style>::const_iterator const_style_iterator;
@ -249,6 +250,17 @@ namespace mapnik
*/
boost::optional<Color> 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.
*/

View File

@ -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<double>(-64, -64, m.getWidth() + 64 ,m.getHeight() + 64)),
detector_(Envelope<double>(-m.buffer_size(), -m.buffer_size(), m.getWidth() + m.buffer_size() ,m.getHeight() + m.buffer_size())),
ras_ptr(new rasterizer)
{
boost::optional<Color> bg = m.background();

View File

@ -475,7 +475,7 @@ namespace mapnik
font_engine_(new freetype_engine()),
font_manager_(*font_engine_),
face_manager_(font_engine_,font_manager_),
detector_(Envelope<double>(-64 ,-64, m.getWidth() + 64 ,m.getHeight() + 64))
detector_(Envelope<double>(-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";

View File

@ -127,6 +127,12 @@ namespace mapnik
}
map.set_srs( get_attr(map_node, "srs", map.srs() ));
optional<unsigned> buffer_size = get_opt_attr<unsigned>(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<label_placement_e>(sym, "placement", POINT_PLACEMENT);
shield_symbol.set_label_placement( placement );
// don't render shields around edges
optional<boolean> avoid_edges =
get_opt_attr<boolean>(sym, "avoid_edges");
if (avoid_edges)
{
shield_symbol.set_avoid_edges( *avoid_edges);
}
// halo fill and radius
optional<Color> halo_fill = get_opt_attr<Color>(sym, "halo_fill");
if (halo_fill)

View File

@ -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<Color> const& Map::background() const
{
return background_;