Merge branch 'master' of github.com:mapnik/mapnik
This commit is contained in:
commit
e90ccb7a3a
17 changed files with 207 additions and 89 deletions
|
@ -91,6 +91,18 @@ struct layer_pickle_suite : boost::python::pickle_suite
|
||||||
|
|
||||||
std::vector<std::string> & (mapnik::layer::*_styles_)() = &mapnik::layer::styles;
|
std::vector<std::string> & (mapnik::layer::*_styles_)() = &mapnik::layer::styles;
|
||||||
|
|
||||||
|
void set_maximum_extent(mapnik::layer & l, boost::optional<mapnik::box2d<double> > const& box)
|
||||||
|
{
|
||||||
|
if (box)
|
||||||
|
{
|
||||||
|
l.set_maximum_extent(*box);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
l.reset_maximum_extent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void export_layer()
|
void export_layer()
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
@ -196,6 +208,27 @@ void export_layer()
|
||||||
"<mapnik.Datasource object at 0x65470>\n"
|
"<mapnik.Datasource object at 0x65470>\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
.add_property("buffer_size",
|
||||||
|
&layer::buffer_size,
|
||||||
|
&layer::set_buffer_size,
|
||||||
|
"Get/Set the size of buffer around layer in pixels.\n"
|
||||||
|
"\n"
|
||||||
|
"Usage:\n"
|
||||||
|
">>> l.buffer_size\n"
|
||||||
|
"0 # zero by default\n"
|
||||||
|
">>> l.buffer_size = 2\n"
|
||||||
|
">>> l.buffer_size\n"
|
||||||
|
"2\n"
|
||||||
|
)
|
||||||
|
.add_property("maximum_extent",make_function
|
||||||
|
(&layer::maximum_extent,return_value_policy<copy_const_reference>()),
|
||||||
|
&set_maximum_extent,
|
||||||
|
"The maximum extent of the map.\n"
|
||||||
|
"\n"
|
||||||
|
"Usage:\n"
|
||||||
|
">>> m.maximum_extent = Box2d(-180,-90,180,90)\n"
|
||||||
|
)
|
||||||
|
|
||||||
.add_property("maxzoom",
|
.add_property("maxzoom",
|
||||||
&layer::max_zoom,
|
&layer::max_zoom,
|
||||||
&layer::set_max_zoom,
|
&layer::set_max_zoom,
|
||||||
|
|
|
@ -117,7 +117,7 @@ struct map_pickle_suite : boost::python::pickle_suite
|
||||||
std::vector<layer>& (Map::*layers_nonconst)() = &Map::layers;
|
std::vector<layer>& (Map::*layers_nonconst)() = &Map::layers;
|
||||||
std::vector<layer> const& (Map::*layers_const)() const = &Map::layers;
|
std::vector<layer> const& (Map::*layers_const)() const = &Map::layers;
|
||||||
mapnik::parameters& (Map::*params_nonconst)() = &Map::get_extra_parameters;
|
mapnik::parameters& (Map::*params_nonconst)() = &Map::get_extra_parameters;
|
||||||
boost::optional<mapnik::box2d<double> > const& (Map::*maximum_extent_const)() const = &Map::maximum_extent;
|
//boost::optional<mapnik::box2d<double> > const& (Map::*maximum_extent_const)() const = &Map::maximum_extent;
|
||||||
|
|
||||||
mapnik::feature_type_style find_style(mapnik::Map const& m, std::string const& name)
|
mapnik::feature_type_style find_style(mapnik::Map const& m, std::string const& name)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,6 @@ mapnik::Map map_deepcopy(mapnik::Map & m, boost::python::dict memo)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO - find a simplier way to set optional to uninitialized
|
|
||||||
void set_maximum_extent(mapnik::Map & m, boost::optional<mapnik::box2d<double> > const& box)
|
void set_maximum_extent(mapnik::Map & m, boost::optional<mapnik::box2d<double> > const& box)
|
||||||
{
|
{
|
||||||
if (box)
|
if (box)
|
||||||
|
@ -201,7 +200,7 @@ void set_maximum_extent(mapnik::Map & m, boost::optional<mapnik::box2d<double> >
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m.maximum_extent().reset();
|
m.reset_maximum_extent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -562,7 +561,7 @@ void export_map()
|
||||||
)
|
)
|
||||||
|
|
||||||
.add_property("maximum_extent",make_function
|
.add_property("maximum_extent",make_function
|
||||||
(maximum_extent_const,return_value_policy<copy_const_reference>()),
|
(&Map::maximum_extent,return_value_policy<copy_const_reference>()),
|
||||||
&set_maximum_extent,
|
&set_maximum_extent,
|
||||||
"The maximum extent of the map.\n"
|
"The maximum extent of the map.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
|
@ -249,7 +249,7 @@ public:
|
||||||
|
|
||||||
struct directive_collector : public boost::static_visitor<>
|
struct directive_collector : public boost::static_visitor<>
|
||||||
{
|
{
|
||||||
directive_collector(double * filter_factor)
|
directive_collector(double & filter_factor)
|
||||||
: filter_factor_(filter_factor) {}
|
: filter_factor_(filter_factor) {}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -257,10 +257,10 @@ struct directive_collector : public boost::static_visitor<>
|
||||||
|
|
||||||
void operator () (raster_symbolizer const& sym)
|
void operator () (raster_symbolizer const& sym)
|
||||||
{
|
{
|
||||||
*filter_factor_ = sym.calculate_filter_factor();
|
filter_factor_ = sym.calculate_filter_factor();
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
double * filter_factor_;
|
double & filter_factor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace mapnik
|
} // namespace mapnik
|
||||||
|
|
|
@ -65,21 +65,12 @@ struct MAPNIK_DECL coord_transform
|
||||||
|
|
||||||
unsigned vertex(double *x, double *y) const
|
unsigned vertex(double *x, double *y) const
|
||||||
{
|
{
|
||||||
unsigned command = SEG_MOVETO;
|
unsigned command = geom_.vertex(x, y);
|
||||||
bool ok = false;
|
if ( command != SEG_END)
|
||||||
bool skipped_points = false;
|
{
|
||||||
double z = 0;
|
double z = 0;
|
||||||
while (!ok && command != SEG_END)
|
if (!prj_trans_->backward(*x, *y, z))
|
||||||
{
|
return SEG_END;
|
||||||
command = geom_.vertex(x, y);
|
|
||||||
ok = prj_trans_->backward(*x, *y, z);
|
|
||||||
if (!ok) {
|
|
||||||
skipped_points = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (skipped_points && (command == SEG_LINETO))
|
|
||||||
{
|
|
||||||
command = SEG_MOVETO;
|
|
||||||
}
|
}
|
||||||
t_->forward(x, y);
|
t_->forward(x, y);
|
||||||
return command;
|
return command;
|
||||||
|
|
|
@ -43,7 +43,9 @@ namespace mapnik
|
||||||
class MAPNIK_DECL layer
|
class MAPNIK_DECL layer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit layer(std::string const& name, std::string const& srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
|
layer(std::string const& name,
|
||||||
|
std::string const& srs="+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs");
|
||||||
|
|
||||||
layer(layer const& l);
|
layer(layer const& l);
|
||||||
layer& operator=(layer const& l);
|
layer& operator=(layer const& l);
|
||||||
bool operator==(layer const& other) const;
|
bool operator==(layer const& other) const;
|
||||||
|
@ -57,7 +59,7 @@ public:
|
||||||
* @return the name of the layer.
|
* @return the name of the layer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const std::string& name() const;
|
std::string const& name() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Set the SRS of the layer.
|
* @brief Set the SRS of the layer.
|
||||||
|
@ -188,6 +190,11 @@ public:
|
||||||
*/
|
*/
|
||||||
box2d<double> envelope() const;
|
box2d<double> envelope() const;
|
||||||
|
|
||||||
|
void set_maximum_extent(box2d<double> const& box);
|
||||||
|
boost::optional<box2d<double> > const& maximum_extent() const;
|
||||||
|
void reset_maximum_extent();
|
||||||
|
void set_buffer_size(int size);
|
||||||
|
int buffer_size() const;
|
||||||
~layer();
|
~layer();
|
||||||
private:
|
private:
|
||||||
void swap(const layer& other);
|
void swap(const layer& other);
|
||||||
|
@ -204,6 +211,8 @@ private:
|
||||||
std::string group_by_;
|
std::string group_by_;
|
||||||
std::vector<std::string> styles_;
|
std::vector<std::string> styles_;
|
||||||
datasource_ptr ds_;
|
datasource_ptr ds_;
|
||||||
|
int buffer_size_;
|
||||||
|
boost::optional<box2d<double> > maximum_extent_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -337,9 +337,7 @@ public:
|
||||||
*/
|
*/
|
||||||
boost::optional<box2d<double> > const& maximum_extent() const;
|
boost::optional<box2d<double> > const& maximum_extent() const;
|
||||||
|
|
||||||
/*! \brief Get the non-const map maximum extent as box2d<double>
|
void reset_maximum_extent();
|
||||||
*/
|
|
||||||
boost::optional<box2d<double> > & maximum_extent();
|
|
||||||
|
|
||||||
/*! \brief Get the map base path where paths should be relative to.
|
/*! \brief Get the map base path where paths should be relative to.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -191,7 +191,24 @@ void agg_renderer<T>::start_layer_processing(layer const& lay, box2d<double> con
|
||||||
{
|
{
|
||||||
detector_->clear();
|
detector_->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
query_extent_ = query_extent;
|
query_extent_ = query_extent;
|
||||||
|
int buffer_size = lay.buffer_size();
|
||||||
|
if (buffer_size != 0 )
|
||||||
|
{
|
||||||
|
double padding = buffer_size * (double)(query_extent.width()/pixmap_.width());
|
||||||
|
double x0 = query_extent_.minx();
|
||||||
|
double y0 = query_extent_.miny();
|
||||||
|
double x1 = query_extent_.maxx();
|
||||||
|
double y1 = query_extent_.maxy();
|
||||||
|
query_extent_.init(x0 - padding, y0 - padding, x1 + padding , y1 + padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::optional<box2d<double> > const& maximum_extent = lay.maximum_extent();
|
||||||
|
if (maximum_extent)
|
||||||
|
{
|
||||||
|
query_extent_.clip(*maximum_extent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
|
@ -81,8 +81,6 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
||||||
|
|
||||||
if (!pat) return;
|
if (!pat) return;
|
||||||
|
|
||||||
box2d<double> ext = query_extent_ * 1.0;
|
|
||||||
|
|
||||||
agg::rendering_buffer buf(current_buffer_->raw_data(),width_,height_, width_ * 4);
|
agg::rendering_buffer buf(current_buffer_->raw_data(),width_,height_, width_ * 4);
|
||||||
pixfmt_type pixf(buf);
|
pixfmt_type pixf(buf);
|
||||||
pixf.comp_op(static_cast<agg::comp_op_e>(sym.comp_op()));
|
pixf.comp_op(static_cast<agg::comp_op_e>(sym.comp_op()));
|
||||||
|
@ -100,7 +98,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
||||||
typedef boost::mpl::vector<clip_line_tag,transform_tag,smooth_tag> conv_types;
|
typedef boost::mpl::vector<clip_line_tag,transform_tag,smooth_tag> conv_types;
|
||||||
vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer,
|
vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer,
|
||||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||||
converter(ext,ras,sym,t_,prj_trans,tr,scale_factor_);
|
converter(query_extent_,ras,sym,t_,prj_trans,tr,scale_factor_);
|
||||||
|
|
||||||
if (sym.clip()) converter.set<clip_line_tag>(); //optional clip (default: true)
|
if (sym.clip()) converter.set<clip_line_tag>(); //optional clip (default: true)
|
||||||
converter.set<transform_tag>(); //always transform
|
converter.set<transform_tag>(); //always transform
|
||||||
|
|
|
@ -80,7 +80,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
||||||
agg::trans_affine tr;
|
agg::trans_affine tr;
|
||||||
evaluate_transform(tr, feature, sym.get_transform());
|
evaluate_transform(tr, feature, sym.get_transform());
|
||||||
|
|
||||||
box2d<double> ext = query_extent_ * 1.1;
|
box2d<double> ext = query_extent_ * 1.0;
|
||||||
|
|
||||||
if (sym.get_rasterizer() == RASTERIZER_FAST)
|
if (sym.get_rasterizer() == RASTERIZER_FAST)
|
||||||
{
|
{
|
||||||
|
|
|
@ -365,7 +365,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
||||||
bbox, marker_trans, sym, *detector_, scale_factor_);
|
bbox, marker_trans, sym, *detector_, scale_factor_);
|
||||||
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
||||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||||
converter(query_extent_* 1.1,rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
|
converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
|
||||||
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
|
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
|
||||||
{
|
{
|
||||||
eGeomType type = feature.paths()[0].type();
|
eGeomType type = feature.paths()[0].type();
|
||||||
|
@ -398,7 +398,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
||||||
bbox, marker_trans, sym, *detector_, scale_factor_);
|
bbox, marker_trans, sym, *detector_, scale_factor_);
|
||||||
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
||||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||||
converter(query_extent_* 1.1,rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
|
converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
|
||||||
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
|
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
|
||||||
{
|
{
|
||||||
eGeomType type = feature.paths()[0].type();
|
eGeomType type = feature.paths()[0].type();
|
||||||
|
@ -429,7 +429,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
||||||
marker_trans, sym, *detector_, scale_factor_);
|
marker_trans, sym, *detector_, scale_factor_);
|
||||||
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
||||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||||
converter(query_extent_* 1.1, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
|
converter(query_extent_, rasterizer_dispatch, sym,t_,prj_trans,tr,scale_factor_);
|
||||||
|
|
||||||
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
|
if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true)
|
||||||
{
|
{
|
||||||
|
|
|
@ -139,11 +139,10 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
||||||
agg::trans_affine tr;
|
agg::trans_affine tr;
|
||||||
evaluate_transform(tr, feature, sym.get_transform());
|
evaluate_transform(tr, feature, sym.get_transform());
|
||||||
|
|
||||||
box2d<double> inflated_extent = query_extent_ * 1.0;
|
|
||||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,smooth_tag> conv_types;
|
typedef boost::mpl::vector<clip_poly_tag,transform_tag,smooth_tag> conv_types;
|
||||||
vertex_converter<box2d<double>, rasterizer, polygon_pattern_symbolizer,
|
vertex_converter<box2d<double>, rasterizer, polygon_pattern_symbolizer,
|
||||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||||
converter(inflated_extent,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
|
converter(query_extent_,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
|
||||||
|
|
||||||
if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
|
if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
|
||||||
converter.set<transform_tag>(); //always transform
|
converter.set<transform_tag>(); //always transform
|
||||||
|
|
|
@ -48,15 +48,13 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
||||||
ras_ptr->reset();
|
ras_ptr->reset();
|
||||||
set_gamma_method(sym,ras_ptr);
|
set_gamma_method(sym,ras_ptr);
|
||||||
|
|
||||||
box2d<double> inflated_extent = query_extent_ * 1.0;
|
|
||||||
|
|
||||||
agg::trans_affine tr;
|
agg::trans_affine tr;
|
||||||
evaluate_transform(tr, feature, sym.get_transform());
|
evaluate_transform(tr, feature, sym.get_transform());
|
||||||
|
|
||||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types;
|
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types;
|
||||||
vertex_converter<box2d<double>, rasterizer, polygon_symbolizer,
|
vertex_converter<box2d<double>, rasterizer, polygon_symbolizer,
|
||||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||||
converter(inflated_extent,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
|
converter(query_extent_,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
|
||||||
|
|
||||||
if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
|
if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
|
||||||
converter.set<transform_tag>(); //always transform
|
converter.set<transform_tag>(); //always transform
|
||||||
|
|
|
@ -320,9 +320,11 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
||||||
// if we've got this far, now prepare the unbuffered extent
|
// if we've got this far, now prepare the unbuffered extent
|
||||||
// which is used as a bbox for clipping geometries
|
// which is used as a bbox for clipping geometries
|
||||||
box2d<double> query_ext = m_.get_current_extent(); // unbuffered
|
box2d<double> query_ext = m_.get_current_extent(); // unbuffered
|
||||||
if (maximum_extent) {
|
if (maximum_extent)
|
||||||
|
{
|
||||||
query_ext.clip(*maximum_extent);
|
query_ext.clip(*maximum_extent);
|
||||||
}
|
}
|
||||||
|
|
||||||
box2d<double> layer_ext2 = lay.envelope();
|
box2d<double> layer_ext2 = lay.envelope();
|
||||||
if (fw_success)
|
if (fw_success)
|
||||||
{
|
{
|
||||||
|
@ -350,8 +352,8 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
||||||
query q(layer_ext,res,scale_denom,m_.get_current_extent());
|
query q(layer_ext,res,scale_denom,m_.get_current_extent());
|
||||||
std::vector<feature_type_style*> active_styles;
|
std::vector<feature_type_style*> active_styles;
|
||||||
attribute_collector collector(names);
|
attribute_collector collector(names);
|
||||||
double filt_factor = 1;
|
double filt_factor = 1.0;
|
||||||
directive_collector d_collector(&filt_factor);
|
directive_collector d_collector(filt_factor);
|
||||||
|
|
||||||
// iterate through all named styles collecting active styles and attribute names
|
// iterate through all named styles collecting active styles and attribute names
|
||||||
BOOST_FOREACH(std::string const& style_name, style_names)
|
BOOST_FOREACH(std::string const& style_name, style_names)
|
||||||
|
@ -661,4 +663,3 @@ template class feature_style_processor<grid_renderer<grid> >;
|
||||||
template class feature_style_processor<agg_renderer<image_32> >;
|
template class feature_style_processor<agg_renderer<image_32> >;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,8 @@ layer::layer(std::string const& name, std::string const& srs)
|
||||||
clear_label_cache_(false),
|
clear_label_cache_(false),
|
||||||
cache_features_(false),
|
cache_features_(false),
|
||||||
group_by_(""),
|
group_by_(""),
|
||||||
ds_() {}
|
ds_(),
|
||||||
|
buffer_size_(0) {}
|
||||||
|
|
||||||
layer::layer(const layer& rhs)
|
layer::layer(const layer& rhs)
|
||||||
: name_(rhs.name_),
|
: name_(rhs.name_),
|
||||||
|
@ -55,7 +56,9 @@ layer::layer(const layer& rhs)
|
||||||
cache_features_(rhs.cache_features_),
|
cache_features_(rhs.cache_features_),
|
||||||
group_by_(rhs.group_by_),
|
group_by_(rhs.group_by_),
|
||||||
styles_(rhs.styles_),
|
styles_(rhs.styles_),
|
||||||
ds_(rhs.ds_) {}
|
ds_(rhs.ds_),
|
||||||
|
buffer_size_(rhs.buffer_size_),
|
||||||
|
maximum_extent_(rhs.maximum_extent_) {}
|
||||||
|
|
||||||
layer& layer::operator=(const layer& rhs)
|
layer& layer::operator=(const layer& rhs)
|
||||||
{
|
{
|
||||||
|
@ -82,6 +85,8 @@ void layer::swap(const layer& rhs)
|
||||||
group_by_ = rhs.group_by_;
|
group_by_ = rhs.group_by_;
|
||||||
styles_=rhs.styles_;
|
styles_=rhs.styles_;
|
||||||
ds_=rhs.ds_;
|
ds_=rhs.ds_;
|
||||||
|
buffer_size_ = rhs.buffer_size_;
|
||||||
|
maximum_extent_ = rhs.maximum_extent_;
|
||||||
}
|
}
|
||||||
|
|
||||||
layer::~layer() {}
|
layer::~layer() {}
|
||||||
|
@ -176,6 +181,31 @@ void layer::set_datasource(datasource_ptr const& ds)
|
||||||
ds_ = ds;
|
ds_ = ds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void layer::set_maximum_extent(box2d<double> const& box)
|
||||||
|
{
|
||||||
|
maximum_extent_.reset(box);
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::optional<box2d<double> > const& layer::maximum_extent() const
|
||||||
|
{
|
||||||
|
return maximum_extent_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void layer::reset_maximum_extent()
|
||||||
|
{
|
||||||
|
maximum_extent_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void layer::set_buffer_size(int size)
|
||||||
|
{
|
||||||
|
buffer_size_ = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
int layer::buffer_size() const
|
||||||
|
{
|
||||||
|
return buffer_size_;
|
||||||
|
}
|
||||||
|
|
||||||
box2d<double> layer::envelope() const
|
box2d<double> layer::envelope() const
|
||||||
{
|
{
|
||||||
if (ds_) return ds_->envelope();
|
if (ds_) return ds_->envelope();
|
||||||
|
|
|
@ -574,66 +574,95 @@ bool map_parser::parse_font(font_set &fset, xml_node const& f)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void map_parser::parse_layer(Map & map, xml_node const& lay)
|
void map_parser::parse_layer(Map & map, xml_node const& node)
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
name = lay.get_attr("name", std::string("Unnamed"));
|
name = node.get_attr("name", std::string("Unnamed"));
|
||||||
|
|
||||||
// XXX if no projection is given inherit from map? [DS]
|
// XXX if no projection is given inherit from map? [DS]
|
||||||
std::string srs = lay.get_attr("srs", map.srs());
|
std::string srs = node.get_attr("srs", map.srs());
|
||||||
|
|
||||||
layer lyr(name, srs);
|
layer lyr(name, srs);
|
||||||
|
|
||||||
optional<boolean> status = lay.get_opt_attr<boolean>("status");
|
optional<boolean> status = node.get_opt_attr<boolean>("status");
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
lyr.set_active(* status);
|
lyr.set_active(* status);
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<double> min_zoom = lay.get_opt_attr<double>("minzoom");
|
optional<double> min_zoom = node.get_opt_attr<double>("minzoom");
|
||||||
if (min_zoom)
|
if (min_zoom)
|
||||||
{
|
{
|
||||||
lyr.set_min_zoom(* min_zoom);
|
lyr.set_min_zoom(* min_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
optional<double> max_zoom = lay.get_opt_attr<double>("maxzoom");
|
optional<double> max_zoom = node.get_opt_attr<double>("maxzoom");
|
||||||
if (max_zoom)
|
if (max_zoom)
|
||||||
{
|
{
|
||||||
lyr.set_max_zoom(* max_zoom);
|
lyr.set_max_zoom(* max_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<boolean> queryable = lay.get_opt_attr<boolean>("queryable");
|
optional<boolean> queryable = node.get_opt_attr<boolean>("queryable");
|
||||||
if (queryable)
|
if (queryable)
|
||||||
{
|
{
|
||||||
lyr.set_queryable(* queryable);
|
lyr.set_queryable(* queryable);
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<boolean> clear_cache =
|
optional<boolean> clear_cache =
|
||||||
lay.get_opt_attr<boolean>("clear-label-cache");
|
node.get_opt_attr<boolean>("clear-label-cache");
|
||||||
if (clear_cache)
|
if (clear_cache)
|
||||||
{
|
{
|
||||||
lyr.set_clear_label_cache(* clear_cache);
|
lyr.set_clear_label_cache(* clear_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<boolean> cache_features =
|
optional<boolean> cache_features =
|
||||||
lay.get_opt_attr<boolean>("cache-features");
|
node.get_opt_attr<boolean>("cache-features");
|
||||||
if (cache_features)
|
if (cache_features)
|
||||||
{
|
{
|
||||||
lyr.set_cache_features(* cache_features);
|
lyr.set_cache_features(* cache_features);
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<std::string> group_by =
|
optional<std::string> group_by =
|
||||||
lay.get_opt_attr<std::string>("group-by");
|
node.get_opt_attr<std::string>("group-by");
|
||||||
if (group_by)
|
if (group_by)
|
||||||
{
|
{
|
||||||
lyr.set_group_by(* group_by);
|
lyr.set_group_by(* group_by);
|
||||||
}
|
}
|
||||||
|
|
||||||
xml_node::const_iterator child = lay.begin();
|
optional<unsigned> buffer_size = node.get_opt_attr<unsigned>("buffer-size");
|
||||||
xml_node::const_iterator end = lay.end();
|
if (buffer_size)
|
||||||
|
{
|
||||||
|
lyr.set_buffer_size(*buffer_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
optional<std::string> maximum_extent = node.get_opt_attr<std::string>("maximum-extent");
|
||||||
|
if (maximum_extent)
|
||||||
|
{
|
||||||
|
box2d<double> box;
|
||||||
|
if (box.from_string(*maximum_extent))
|
||||||
|
{
|
||||||
|
lyr.set_maximum_extent(box);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::ostringstream s_err;
|
||||||
|
s_err << "failed to parse 'maximum-extent' in layer " << name;
|
||||||
|
if (strict_)
|
||||||
|
{
|
||||||
|
throw config_error(s_err.str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MAPNIK_LOG_WARN(load_map) << "map_parser: " << s_err.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
xml_node::const_iterator child = node.begin();
|
||||||
|
xml_node::const_iterator end = node.end();
|
||||||
|
|
||||||
for(; child != end; ++child)
|
for(; child != end; ++child)
|
||||||
{
|
{
|
||||||
|
@ -718,7 +747,7 @@ void map_parser::parse_layer(Map & map, xml_node const& lay)
|
||||||
{
|
{
|
||||||
if (!name.empty())
|
if (!name.empty())
|
||||||
{
|
{
|
||||||
ex.append_context(std::string(" encountered during parsing of layer '") + name + "'", lay);
|
ex.append_context(std::string(" encountered during parsing of layer '") + name + "'", node);
|
||||||
}
|
}
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,7 +352,7 @@ void Map::set_background_image(std::string const& image_filename)
|
||||||
|
|
||||||
void Map::set_maximum_extent(box2d<double> const& box)
|
void Map::set_maximum_extent(box2d<double> const& box)
|
||||||
{
|
{
|
||||||
maximum_extent_ = box;
|
maximum_extent_.reset(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<box2d<double> > const& Map::maximum_extent() const
|
boost::optional<box2d<double> > const& Map::maximum_extent() const
|
||||||
|
@ -360,9 +360,9 @@ boost::optional<box2d<double> > const& Map::maximum_extent() const
|
||||||
return maximum_extent_;
|
return maximum_extent_;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<box2d<double> > & Map::maximum_extent()
|
void Map::reset_maximum_extent()
|
||||||
{
|
{
|
||||||
return maximum_extent_;
|
maximum_extent_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& Map::base_path() const
|
std::string const& Map::base_path() const
|
||||||
|
|
|
@ -741,6 +741,22 @@ void serialize_layer( ptree & map_node, const layer & layer, bool explicit_defau
|
||||||
set_attr( layer_node, "group-by", layer.group_by() );
|
set_attr( layer_node, "group-by", layer.group_by() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int buffer_size = layer.buffer_size();
|
||||||
|
if ( buffer_size || explicit_defaults)
|
||||||
|
{
|
||||||
|
set_attr( layer_node, "buffer-size", buffer_size );
|
||||||
|
}
|
||||||
|
|
||||||
|
optional<box2d<double> > const& maximum_extent = layer.maximum_extent();
|
||||||
|
if ( maximum_extent)
|
||||||
|
{
|
||||||
|
std::ostringstream s;
|
||||||
|
s << std::setprecision(16)
|
||||||
|
<< maximum_extent->minx() << "," << maximum_extent->miny() << ","
|
||||||
|
<< maximum_extent->maxx() << "," << maximum_extent->maxy();
|
||||||
|
set_attr( layer_node, "maximum-extent", s.str() );
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<std::string> const& style_names = layer.styles();
|
std::vector<std::string> const& style_names = layer.styles();
|
||||||
for (unsigned i = 0; i < style_names.size(); ++i)
|
for (unsigned i = 0; i < style_names.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -788,7 +804,7 @@ void serialize_map(ptree & pt, Map const & map, bool explicit_defaults)
|
||||||
set_attr( map_node, "background-image", *image_filename );
|
set_attr( map_node, "background-image", *image_filename );
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned buffer_size = map.buffer_size();
|
int buffer_size = map.buffer_size();
|
||||||
if ( buffer_size || explicit_defaults)
|
if ( buffer_size || explicit_defaults)
|
||||||
{
|
{
|
||||||
set_attr( map_node, "buffer-size", buffer_size );
|
set_attr( map_node, "buffer-size", buffer_size );
|
||||||
|
|
Loading…
Reference in a new issue