Fix up shared_ptr impl. Fixes #1060.

This commit is contained in:
Tom MacWright 2012-02-02 13:22:38 -05:00
parent 9c1af869b6
commit 8d9fb2b540
4 changed files with 12 additions and 8 deletions

View file

@ -32,6 +32,7 @@
#include <mapnik/feature_layer_desc.hpp>
// boost
#include <boost/shared_container_iterator.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
@ -50,7 +51,9 @@ struct MAPNIK_DECL Featureset : private boost::noncopyable
};
typedef MAPNIK_DECL boost::shared_ptr<Featureset> featureset_ptr;
typedef MAPNIK_DECL std::map<std::string, mapnik::parameters> statistics;
typedef MAPNIK_DECL boost::shared_ptr< std::map<std::string, mapnik::parameters> > statistics_ptr;
typedef MAPNIK_DECL boost::shared_container_iterator< std::map<std::string, mapnik::parameters> > statistics_ptr_iterator;
class MAPNIK_DECL datasource_exception : public std::exception
{

View file

@ -487,7 +487,7 @@ mapnik::statistics_ptr sqlite_datasource::get_statistics() const
{
if (! is_bound_) bind();
mapnik::statistics_ptr _stats;
std::map<std::string, mapnik::parameters> stats_;
std::ostringstream s;
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
@ -534,12 +534,12 @@ mapnik::statistics_ptr sqlite_datasource::get_statistics() const
col++;
p["mean"] = rs->column_double(col);
col++;
stats_->insert(std::pair<std::string, mapnik::parameters>(itr->get_name(), p));
stats_[itr->get_name()] = p;
}
}
}
return stats_;
return boost::make_shared<mapnik::statistics>(stats_);
}
boost::optional<mapnik::datasource::geometry_t> sqlite_datasource::get_geometry_type() const

View file

@ -80,7 +80,6 @@ private:
mutable bool has_spatial_index_;
mutable bool using_subquery_;
mutable std::vector<std::string> init_statements_;
mutable mapnik::statistics_ptr stats_;
// Fill init_statements with any statements
// needed to attach auxillary databases

View file

@ -26,8 +26,10 @@
#include <mapnik/memory_featureset.hpp>
#include <mapnik/params.hpp>
#include <mapnik/feature_factory.hpp>
#include <boost/math/distributions/normal.hpp>
#include <mapnik/feature_kv_iterator.hpp>
#include <boost/make_shared.hpp>
#include <boost/math/distributions/normal.hpp>
// stl
#include <algorithm>
@ -120,7 +122,7 @@ layer_descriptor memory_datasource::get_descriptor() const
statistics_ptr memory_datasource::get_statistics() const
{
statistics_ptr _stats;
std::map<std::string, mapnik::parameters> _stats;
std::map<std::string, statistics_accumulator>::const_iterator it = accumulators_.begin();
std::map<std::string, statistics_accumulator>::const_iterator end = accumulators_.end();
for (; it != end; ++it) {
@ -130,9 +132,9 @@ statistics_ptr memory_datasource::get_statistics() const
p["min"] = boost::accumulators::min(it->second);
p["stddev"] = sqrt(boost::accumulators::variance(it->second));
p["max"] = boost::accumulators::max(it->second);
_stats->insert(std::pair<std::string, mapnik::parameters>(it->first, p));
_stats[it->first] = p;
}
return _stats;
return boost::make_shared<mapnik::statistics>(_stats);
}
size_t memory_datasource::size() const