Permalink
Browse files

use boost::ptr_containers to store Map elements

  • Loading branch information...
1 parent ee7f72d commit 18633adc7e0d9c603bb83721fdd789cf69ef06e4 @artemp artemp committed Jul 9, 2012
@@ -62,8 +62,8 @@ struct map_pickle_suite : boost::python::pickle_suite
for (; it != end; ++it)
{
std::string const& name = it->first;
- const mapnik::feature_type_style & style = it->second;
- boost::python::tuple style_pair = boost::python::make_tuple(name,style);
+ const mapnik::feature_type_style * style = it->second;
+ boost::python::tuple style_pair = boost::python::make_tuple(name,*style);
s.append(style_pair);
}
@@ -312,6 +312,7 @@ StyleModel::StyleModel(boost::shared_ptr<mapnik::Map> map, QObject * parent)
: QAbstractItemModel(parent),
root_(new node(map_node(map)))
{
+ /*
typedef std::map<std::string,mapnik::feature_type_style> style_type;
style_type const & styles = map->styles();
style_type::const_iterator itr = styles.begin();
@@ -331,6 +332,7 @@ StyleModel::StyleModel(boost::shared_ptr<mapnik::Map> map, QObject * parent)
}
}
}
+ */
}
StyleModel::~StyleModel() {}
@@ -31,6 +31,7 @@
// boost
#include <boost/optional.hpp>
+#include <boost/ptr_container/ptr_vector.hpp>
// stl
#include <vector>
@@ -45,7 +46,7 @@ enum filter_mode_enum {
DEFINE_ENUM( filter_mode_e, filter_mode_enum );
-typedef std::vector<rule> rules;
+typedef boost::ptr_vector<rule> rules;
typedef std::vector<rule*> rule_ptrs;
class MAPNIK_DECL feature_type_style
@@ -68,10 +69,10 @@ class MAPNIK_DECL feature_type_style
feature_type_style();
feature_type_style(feature_type_style const& rhs, bool deep_copy = false);
-
+
feature_type_style& operator=(feature_type_style const& rhs);
- void add_rule(rule const& rule);
+ void add_rule(std::auto_ptr<rule> rule);
rules const& get_rules() const;
rule_ptrs const& get_if_rules(double scale_denom);
View
@@ -33,6 +33,7 @@
// boost
#include <boost/optional/optional.hpp>
+#include <boost/ptr_container/ptr_map.hpp>
namespace mapnik
{
@@ -71,7 +72,7 @@ class MAPNIK_DECL Map
int buffer_size_;
boost::optional<color> background_;
boost::optional<std::string> background_image_;
- std::map<std::string,feature_type_style> styles_;
+ boost::ptr_map<std::string,feature_type_style> styles_;
std::map<std::string,metawriter_ptr> metawriters_;
std::map<std::string,font_set> fontsets_;
std::vector<layer> layers_;
@@ -83,8 +84,8 @@ class MAPNIK_DECL Map
public:
- typedef std::map<std::string,feature_type_style>::const_iterator const_style_iterator;
- typedef std::map<std::string,feature_type_style>::iterator style_iterator;
+ typedef boost::ptr_map<std::string,feature_type_style>::const_iterator const_style_iterator;
+ typedef boost::ptr_map<std::string,feature_type_style>::iterator style_iterator;
typedef std::map<std::string,font_set>::const_iterator const_fontset_iterator;
typedef std::map<std::string,font_set>::iterator fontset_iterator;
typedef std::map<std::string,metawriter_ptr>::const_iterator const_metawriter_iterator;
@@ -121,12 +122,12 @@ class MAPNIK_DECL Map
/*! \brief Get all styles
* @return Const reference to styles
*/
- std::map<std::string,feature_type_style> const& styles() const;
+ boost::ptr_map<std::string,feature_type_style> const& styles() const;
/*! \brief Get all styles
* @return Non-constant reference to styles
*/
- std::map<std::string,feature_type_style> & styles();
+ boost::ptr_map<std::string,feature_type_style> & styles();
/*! \brief Get first iterator in styles.
* @return Constant style iterator.
@@ -154,7 +155,7 @@ class MAPNIK_DECL Map
* @return true If success.
* @return false If no success.
*/
- bool insert_style(std::string const& name,feature_type_style const& style);
+ bool insert_style(std::string const& name, std::auto_ptr<feature_type_style> style);
/*! \brief Remove a style from the map.
* @param name The name of the style.
@@ -43,16 +43,22 @@ struct MAPNIK_DECL raster_symbolizer : public symbolizer_base
opacity_(1.0),
colorizer_(),
filter_factor_(-1),
- mesh_size_(16) {}
+ mesh_size_(16)
+ {
+ std::cout << "raster_symbolizer: default ctor called" << std::endl;
+ }
raster_symbolizer(const raster_symbolizer &rhs)
: symbolizer_base(rhs),
- mode_(rhs.get_mode()),
- scaling_(rhs.get_scaling()),
- opacity_(rhs.get_opacity()),
+ mode_(rhs.mode_),
+ scaling_(rhs.scaling_),
+ opacity_(rhs.opacity_),
colorizer_(rhs.colorizer_),
filter_factor_(rhs.filter_factor_),
- mesh_size_(rhs.mesh_size_) {}
+ mesh_size_(rhs.mesh_size_)
+ {
+ std::cout << "raster_symbolizer: copy ctor called" << std::endl;
+ }
std::string const& get_mode() const
{
@@ -166,7 +166,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
detector_->has_placement(transformed_bbox))
{
svg_renderer.render(*ras_ptr, sl, renb, matrix, sym.get_opacity(), bbox);
- if (/* DEBUG */ 0)
+ if (/* DEBUG */ 1)
{
debug_draw_box(buf, transformed_bbox, 0, 0, 0.0);
}
@@ -67,13 +67,13 @@ void agg_renderer<T>::process(raster_symbolizer const& sym,
if (raster_width > 0 && raster_height > 0)
{
+ double scale_factor = ext.width() / source->data_.width();
image_data_32 target_data(raster_width,raster_height);
raster target(target_ext, target_data);
-
reproject_raster(target, *source, prj_trans, err_offs_x, err_offs_y,
sym.get_mesh_size(),
sym.calculate_filter_factor(),
- scale_factor_,
+ scale_factor,
sym.get_scaling());
composite(current_buffer_->data(), target.data_, sym.comp_op(), sym.get_opacity(), start_x, start_y, true);
View
@@ -112,12 +112,12 @@ namespace mapnik { namespace util {
typedef std::map<std::string, feature_type_style> style_cont;
typedef style_cont::value_type value_type;
- style_cont const& styles = map_in.styles();
- BOOST_FOREACH ( value_type const& kv, styles )
+ //style_cont const& styles = map_in.styles();
+ //BOOST_FOREACH ( value_type const& kv, styles )
{
- feature_type_style const& style_in = kv.second;
- feature_type_style style_out(style_in,true); // deep copy
- map_out.insert_style(kv.first, style_out);
+ // feature_type_style const& style_in = kv.second;
+ //feature_type_style style_out(style_in,true); // deep copy
+ //map_out.insert_style(kv.first, style_out);
}
}
@@ -36,6 +36,7 @@
// boost
#include <boost/foreach.hpp>
#include <boost/concept_check.hpp>
+
//stl
#include <vector>
@@ -363,7 +364,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
continue;
}
- const std::vector<rule>& rules=(*style).get_rules();
+ const boost::ptr_vector<rule>& rules=(*style).get_rules();
bool active_rules=false;
BOOST_FOREACH(rule const& r, rules)
View
@@ -43,21 +43,28 @@ feature_type_style::feature_type_style()
{}
feature_type_style::feature_type_style(feature_type_style const& rhs, bool deep_copy)
- : filter_mode_(rhs.filter_mode_),
+ :
+ filter_mode_(rhs.filter_mode_),
filters_(rhs.filters_),
direct_filters_(rhs.direct_filters_),
comp_op_(rhs.comp_op_),
scale_denom_validity_(-1),
opacity_(rhs.opacity_)
{
- if (!deep_copy) {
+ if (!deep_copy)
+ {
+ //rules_= rhs.rules_.release();
rules_ = rhs.rules_;
- } else {
- rules::const_iterator it = rhs.rules_.begin(),
- end = rhs.rules_.end();
- for(; it != end; ++it) {
- rules_.push_back(rule(*it, deep_copy));
- }
+ }
+ else
+ {
+
+ //rules::const_iterator it = rhs.rules_.begin(),
+ // end = rhs.rules_.end();
+ //for(; it != end; ++it)
+ //{
+ // rules_.push_back(rule(*it, deep_copy));
+ // }
}
}
@@ -73,9 +80,9 @@ feature_type_style& feature_type_style::operator=(feature_type_style const& rhs)
return *this;
}
-void feature_type_style::add_rule(rule const& rule)
+void feature_type_style::add_rule(std::auto_ptr<rule> r)
{
- rules_.push_back(rule);
+ rules_.push_back(r);
scale_denom_validity_ = -1;
}
Oops, something went wrong.

0 comments on commit 18633ad

Please sign in to comment.