use boost::make_shared across plugins to avoid explicit new and ensure fast and exception safe allocation

This commit is contained in:
Dane Springmeyer 2011-05-16 23:41:34 +00:00
parent b3c258c9a8
commit 49fd1f93d1
24 changed files with 134 additions and 65 deletions

View file

@ -207,6 +207,7 @@ featureset_ptr gdal_datasource::features(query const& q) const
if (!is_bound_) bind();
gdal_query gq = q;
// TODO - move to boost::make_shared, but must reduce # of args to <= 9
return featureset_ptr(new gdal_featureset(*open_dataset(), band_, gq, extent_, width_, height_, nbands_, dx_, dy_, filter_factor_));
}

View file

@ -39,6 +39,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/make_shared.hpp>
// geos
#include <geos_c.h>
@ -267,13 +268,13 @@ featureset_ptr geos_datasource::features(query const& q) const
clog << "GEOS Plugin: using extent: " << s.str() << endl;
#endif
return featureset_ptr(new geos_featureset (*geometry_,
return boost::make_shared<geos_featureset>(*geometry_,
GEOSGeomFromWKT(s.str().c_str()),
geometry_id_,
geometry_data_,
geometry_data_name_,
desc_.get_encoding(),
multiple_geometries_));
multiple_geometries_);
}
featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
@ -287,12 +288,12 @@ featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const
clog << "GEOS Plugin: using point: " << s.str() << endl;
#endif
return featureset_ptr(new geos_featureset (*geometry_,
return boost::make_shared<geos_featureset>(*geometry_,
GEOSGeomFromWKT(s.str().c_str()),
geometry_id_,
geometry_data_,
geometry_data_name_,
desc_.get_encoding(),
multiple_geometries_));
multiple_geometries_);
}

View file

@ -33,6 +33,7 @@
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/wkb.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/feature_factory.hpp>
// ogr
#include "geos_featureset.hpp"
@ -48,6 +49,7 @@ using mapnik::Feature;
using mapnik::feature_ptr;
using mapnik::geometry_utils;
using mapnik::transcoder;
using mapnik::feature_factory;
geos_featureset::geos_featureset(GEOSGeometry* geometry,
@ -116,7 +118,7 @@ feature_ptr geos_featureset::next()
geos_wkb_ptr wkb(geometry_);
if (wkb.is_valid())
{
feature_ptr feature(new Feature(identifier_));
feature_ptr feature(feature_factory::create(identifier_));
geometry_utils::from_wkb(*feature,
wkb.data(),

View file

@ -40,6 +40,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <boost/bind.hpp>
#include <boost/make_shared.hpp>
#include "kismet_datasource.hpp"
#include "kismet_featureset.hpp"
@ -90,7 +91,7 @@ kismet_datasource::kismet_datasource(parameters const& params, bool bind)
boost::optional<std::string> ext = params_.get<std::string>("extent");
if (ext) extent_initialized_ = extent_.from_string(*ext);
kismet_thread.reset (new boost::thread (boost::bind (&kismet_datasource::run, this, host_, port_)));
kismet_thread.reset (boost::make_shared<boost::thread>(boost::bind (&kismet_datasource::run, this, host_, port_)));
if (bind)
{
@ -140,7 +141,7 @@ featureset_ptr kismet_datasource::features(query const& q) const
//mapnik::box2d<double> const& e = q.get_bbox();
boost::mutex::scoped_lock lock(knd_list_mutex);
return featureset_ptr (new kismet_featureset(knd_list, desc_.get_encoding()));
return boost::make_shared<kismet_featureset>(knd_list, desc_.get_encoding());
// TODO: if illegal:
// return featureset_ptr();

View file

@ -21,6 +21,7 @@
*****************************************************************************/
//$Id$
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/box2d.hpp>
@ -29,6 +30,7 @@
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/wkb.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/feature_factory.hpp>
#include "kismet_featureset.hpp"
@ -37,6 +39,7 @@ using mapnik::feature_ptr;
using mapnik::geometry_type;
using mapnik::geometry_utils;
using mapnik::transcoder;
using mapnik::feature_factory;
kismet_featureset::kismet_featureset(const std::list<kismet_network_data> &knd_list,
std::string const& encoding)
@ -73,7 +76,7 @@ feature_ptr kismet_featureset::next()
value = "wlan_crypted";
}
feature_ptr feature(new Feature(feature_id_));
feature_ptr feature(feature_factory::create(feature_id_));
++feature_id_;
geometry_type* pt = new geometry_type(mapnik::Point);

View file

@ -32,6 +32,7 @@
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <boost/make_shared.hpp>
// stl
#include <string>
@ -547,14 +548,14 @@ featureset_ptr occi_datasource::features(query const& q) const
std::clog << "OCCI Plugin: " << s.str() << std::endl;
#endif
return featureset_ptr (new occi_featureset (pool_,
return boost::make_shared<occi_featureset>(pool_,
conn_,
s.str(),
desc_.get_encoding(),
multiple_geometries_,
use_connection_pool_,
row_prefetch_,
props.size()));
props.size());
}
featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
@ -630,13 +631,13 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
std::clog << "OCCI Plugin: " << s.str() << std::endl;
#endif
return featureset_ptr (new occi_featureset (pool_,
return boost::make_shared<occi_featureset>(pool_,
conn_,
s.str(),
desc_.get_encoding(),
multiple_geometries_,
use_connection_pool_,
row_prefetch_,
size));
size);
}

View file

@ -30,6 +30,7 @@
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/wkb.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/feature_factory.hpp>
// ogr
#include "occi_featureset.hpp"
@ -43,6 +44,7 @@ using mapnik::geometry_type;
using mapnik::geometry_utils;
using mapnik::transcoder;
using mapnik::datasource_exception;
using mapnik::feature_factory
using oracle::occi::Connection;
using oracle::occi::Statement;
@ -90,7 +92,7 @@ feature_ptr occi_featureset::next()
{
if (rs_ && rs_->next())
{
feature_ptr feature(new Feature(feature_id_));
feature_ptr feature(feature_factory::create(feature_id_));
++feature_id_;
boost::scoped_ptr<SDOGeometry> geom (dynamic_cast<SDOGeometry*> (rs_->getObject(1)));

View file

@ -20,17 +20,24 @@
*
*****************************************************************************/
// mapnik
#include <mapnik/geom_util.hpp>
#include <mapnik/query.hpp>
// boost
#include <boost/make_shared.hpp>
// stl
#include <iostream>
#include <fstream>
#include <stdexcept>
#include <mapnik/geom_util.hpp>
#include <mapnik/query.hpp>
#include <set>
#include "osm_datasource.hpp"
#include "osm_featureset.hpp"
#include "dataset_deliverer.h"
#include "osmtagtypes.h"
#include "osmparser.h"
#include <set>
DATASOURCE_PLUGIN(osm_datasource)
@ -142,11 +149,10 @@ featureset_ptr osm_datasource::features(const query& q) const
filter_in_box filter(q.get_bbox());
// so we need to filter osm features by bbox here...
return featureset_ptr
(new osm_featureset<filter_in_box>(filter,
return boost::make_shared<osm_featureset<filter_in_box> >(filter,
osm_data_,
q.property_names(),
desc_.get_encoding()));
desc_.get_encoding());
}
featureset_ptr osm_datasource::features_at_point(coord2d const& pt) const
@ -167,11 +173,10 @@ featureset_ptr osm_datasource::features_at_point(coord2d const& pt) const
++itr;
}
return featureset_ptr
(new osm_featureset<filter_at_point>(filter,
return boost::make_shared<osm_featureset<filter_at_point> >(filter,
osm_data_,
names,
desc_.get_encoding()));
desc_.get_encoding());
}
box2d<double> osm_datasource::envelope() const

View file

@ -21,13 +21,19 @@
*
*****************************************************************************/
#include <iostream>
#include "osm_featureset.hpp"
// mapnik
#include <mapnik/geometry.hpp>
#include <mapnik/feature_factory.hpp>
#include "osm_featureset.hpp"
// stl
#include <iostream>
using mapnik::Feature;
using mapnik::feature_ptr;
using mapnik::geometry_type;
using mapnik::feature_factory;
using std::cerr;
using std::endl;
@ -58,14 +64,14 @@ feature_ptr osm_featureset<filterT>::next()
{
if(dataset_->current_item_is_node())
{
feature= feature_ptr(new Feature(feature_id_));
feature = feature_factory::create(feature_id_);
++feature_id_;
double lat = static_cast<osm_node*>(cur_item)->lat;
double lon = static_cast<osm_node*>(cur_item)->lon;
geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(lon,lat);
feature->add_geometry(point);
success=true;
success = true;
}
else if (dataset_->current_item_is_way())
{
@ -84,13 +90,13 @@ feature_ptr osm_featureset<filterT>::next()
{
if(static_cast<osm_way*>(cur_item)->nodes.size())
{
feature=feature_ptr(new Feature(feature_id_++));
feature = feature_factory::create(feature_id_);
++feature_id_;
geometry_type *geom;
if(static_cast<osm_way*>(cur_item)->is_polygon())
geom=new geometry_type(mapnik::Polygon);
geom = new geometry_type(mapnik::Polygon);
else
geom=new geometry_type(mapnik::LineString);
geom = new geometry_type(mapnik::LineString);
geom->set_capacity(static_cast<osm_way*>(cur_item)->
nodes.size());
@ -108,7 +114,7 @@ feature_ptr osm_featureset<filterT>::next()
->nodes[count]->lat);
}
feature->add_geometry(geom);
success=true;
success = true;
}
}
}

View file

@ -40,6 +40,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <boost/format.hpp>
#include <boost/make_shared.hpp>
// stl
#include <string>
@ -396,7 +397,7 @@ boost::shared_ptr<IResultSet> postgis_datasource::get_resultset(boost::shared_pt
if (!conn->execute(csql.str()))
throw mapnik::datasource_exception("Postgis Plugin: error creating cursor for data select." );
return shared_ptr<CursorResultSet>(new CursorResultSet(conn, cursor_name, cursor_fetch_size_));
return boost::make_shared<CursorResultSet>(conn, cursor_name, cursor_fetch_size_);
}
else
@ -479,7 +480,7 @@ featureset_ptr postgis_datasource::features(const query& q) const
}
boost::shared_ptr<IResultSet> rs = get_resultset(conn, s.str());
return featureset_ptr(new postgis_featureset(rs,desc_.get_encoding(),multiple_geometries_,props.size()));
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(),multiple_geometries_,props.size());
}
else
{
@ -551,7 +552,7 @@ featureset_ptr postgis_datasource::features_at_point(coord2d const& pt) const
}
boost::shared_ptr<IResultSet> rs = get_resultset(conn, s.str());
return featureset_ptr(new postgis_featureset(rs,desc_.get_encoding(),multiple_geometries_, size));
return boost::make_shared<postgis_featureset>(rs,desc_.get_encoding(),multiple_geometries_, size);
}
}
return featureset_ptr();

View file

@ -28,6 +28,7 @@
#include <mapnik/unicode.hpp>
#include <mapnik/sql_utils.hpp>
#include <mapnik/feature_factory.hpp>
#include "postgis_featureset.hpp"
#include "resultset.hpp"
#include "cursorresultset.hpp"
@ -35,6 +36,7 @@
// boost
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
// stl
#include <sstream>
#include <string>

View file

@ -24,6 +24,7 @@
// boost
#include <boost/lexical_cast.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/make_shared.hpp>
// mapnik
#include <mapnik/image_reader.hpp>
@ -171,7 +172,7 @@ featureset_ptr raster_datasource::features(query const& q) const
#endif
tiled_file_policy policy(filename_, format_, 256, extent_, q.get_bbox(), width_, height_);
return featureset_ptr(new raster_featureset<tiled_file_policy>(policy, extent_, q));
return boost::make_shared<raster_featureset<tiled_file_policy> >(policy, extent_, q);
}
else
{
@ -181,12 +182,13 @@ featureset_ptr raster_datasource::features(query const& q) const
raster_info info(filename_, format_, extent_, width_, height_);
single_file_policy policy(info);
return featureset_ptr(new raster_featureset<single_file_policy>(policy, extent_, q));
return boost::make_shared<raster_featureset<single_file_policy> >(policy, extent_, q);
}
}
featureset_ptr raster_datasource::features_at_point(coord2d const&) const
{
std::clog << "Raster Plugin: ##WARNING: feature_at_point not supported for raster.input" << std::endl;
return featureset_ptr();
}

View file

@ -19,9 +19,11 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
// mapnik
#include <mapnik/image_reader.hpp>
#include <mapnik/image_util.hpp>
#include <mapnik/feature_factory.hpp>
#include "raster_featureset.hpp"
@ -33,6 +35,7 @@ using mapnik::Feature;
using mapnik::feature_ptr;
using mapnik::image_data_32;
using mapnik::raster;
using mapnik::feature_factory;
template <typename LookupPolicy>
raster_featureset<LookupPolicy>::raster_featureset(LookupPolicy const& policy,
@ -54,7 +57,7 @@ feature_ptr raster_featureset<LookupPolicy>::next()
{
if (curIter_!=endIter_)
{
feature_ptr feature(new Feature(feature_id_));
feature_ptr feature(feature_factory::create(feature_id_));
++feature_id_;
try
{
@ -98,7 +101,7 @@ feature_ptr raster_featureset<LookupPolicy>::next()
image_data_32 image(width,height);
reader->read(x_off,y_off,image);
feature->set_raster(mapnik::raster_ptr(new raster(intersect,image)));
feature->set_raster(boost::make_shared<raster>(intersect,image));
}
}
}

View file

@ -26,6 +26,7 @@
// boost
#include <boost/filesystem/operations.hpp>
#include <boost/make_shared.hpp>
// mapnik
#include <mapnik/ptree_helpers.hpp>
@ -191,7 +192,7 @@ featureset_ptr rasterlite_datasource::features(query const& q) const
if (!is_bound_) bind();
rasterlite_query gq = q;
return featureset_ptr(new rasterlite_featureset(open_dataset(), gq));
return boost::make_shared<rasterlite_featureset>(open_dataset(), gq);
}
featureset_ptr rasterlite_datasource::features_at_point(coord2d const& pt) const
@ -199,6 +200,6 @@ featureset_ptr rasterlite_datasource::features_at_point(coord2d const& pt) const
if (!is_bound_) bind();
rasterlite_query gq = pt;
return featureset_ptr(new rasterlite_featureset(open_dataset(), gq));
return boost::make_shared<rasterlite_featureset>(open_dataset(), gq);
}

View file

@ -25,6 +25,11 @@
// mapnik
#include <mapnik/image_util.hpp>
#include <mapnik/feature_factory.hpp>
// boost
#include <boost/make_shared.hpp>
using mapnik::query;
using mapnik::coord2d;
@ -34,6 +39,7 @@ using mapnik::feature_ptr;
using mapnik::CoordTransform;
using mapnik::geometry_type;
using mapnik::query;
using mapnik::feature_factory;
rasterlite_featureset::rasterlite_featureset(void* dataset, rasterlite_query q)
@ -80,7 +86,7 @@ feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
std::clog << "Rasterlite Plugin: get_feature" << std::endl;
#endif
feature_ptr feature(new Feature(1));
feature_ptr feature(feature_factory::create(1));
double x0, y0, x1, y1;
rasterliteGetExtent (dataset_, &x0, &y0, &x1, &y1);
@ -123,7 +129,7 @@ feature_ptr rasterlite_featureset::get_feature(mapnik::query const& q)
memcpy (image_data, raster_data, size);
feature->set_raster(mapnik::raster_ptr(new mapnik::raster(intersect,image)));
feature->set_raster(boost::make_shared<mapnik::raster>(intersect,image));
free (raster);

View file

@ -20,9 +20,7 @@
*
*****************************************************************************/
#include <iostream>
#include <fstream>
#include <stdexcept>
// mapnik
#include <mapnik/geom_util.hpp>
// boost
@ -30,7 +28,12 @@
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/make_shared.hpp>
// stl
#include <iostream>
#include <fstream>
#include <stdexcept>
#include "shape_datasource.hpp"
#include "shape_featureset.hpp"
@ -92,7 +95,7 @@ void shape_datasource::bind() const
try
{
boost::shared_ptr<shape_io> shape_ref = boost::shared_ptr<shape_io>(new shape_io(shape_name_));
boost::shared_ptr<shape_io> shape_ref = boost::make_shared<shape_io>(shape_name_);
init(*shape_ref);
for (int i=0;i<shape_ref->dbf().num_fields();++i)
{
@ -241,6 +244,7 @@ featureset_ptr shape_datasource::features(const query& q) const
if (indexed_)
{
shape_->shp().seek(0);
// TODO - use boost::make_shared - #760
return featureset_ptr
(new shape_index_featureset<filter_in_box>(filter,
*shape_,
@ -249,12 +253,11 @@ featureset_ptr shape_datasource::features(const query& q) const
}
else
{
return featureset_ptr
(new shape_featureset<filter_in_box>(filter,
return boost::make_shared<shape_featureset<filter_in_box> >(filter,
shape_name_,
q.property_names(),
desc_.get_encoding(),
file_length_));
file_length_);
}
}
@ -278,6 +281,7 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt) const
if (indexed_)
{
shape_->shp().seek(0);
// TODO - use boost::make_shared - #760
return featureset_ptr
(new shape_index_featureset<filter_at_point>(filter,
*shape_,
@ -286,12 +290,11 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt) const
}
else
{
return featureset_ptr
(new shape_featureset<filter_at_point>(filter,
return boost::make_shared<shape_featureset<filter_at_point> >(filter,
shape_name_,
names,
desc_.get_encoding(),
file_length_));
file_length_);
}
}

View file

@ -21,9 +21,17 @@
*
*****************************************************************************/
// mapnik
#include <mapnik/feature_factory.hpp>
// stl
#include <iostream>
#include "shape_featureset.hpp"
using mapnik::geometry_type;
using mapnik::feature_factory;
template <typename filterT>
shape_featureset<filterT>::shape_featureset(const filterT& filter,
const std::string& shape_file,
@ -74,14 +82,13 @@ shape_featureset<filterT>::shape_featureset(const filterT& filter,
template <typename filterT>
feature_ptr shape_featureset<filterT>::next()
{
using mapnik::geometry_type;
std::streampos pos=shape_.shp().pos();
if (pos < std::streampos(file_length_ * 2))
{
shape_.move_to(pos);
int type=shape_.type();
feature_ptr feature(new Feature(shape_.id_));
feature_ptr feature(feature_factory::create(shape_.id_));
if (type == shape_io::shape_point)
{
double x=shape_.shp().read_double();
@ -113,7 +120,7 @@ feature_ptr shape_featureset<filterT>::next()
{
shape_.shp().skip(8);
}
geometry_type * point=new geometry_type(mapnik::Point);
geometry_type * point = new geometry_type(mapnik::Point);
point->move_to(x,y);
feature->add_geometry(point);
++count_;

View file

@ -22,13 +22,21 @@
//$Id: shape_index_featureset.cc 36 2005-04-05 14:32:18Z pavlenko $
// mapnik
#include <mapnik/feature_factory.hpp>
// boost
#include <boost/interprocess/streams/bufferstream.hpp>
#include "shape_index_featureset.hpp"
// stl
#include <fstream>
#include "shape_index_featureset.hpp"
using mapnik::feature_factory;
using mapnik::geometry_type;
template <typename filterT>
shape_index_featureset<filterT>::shape_index_featureset(const filterT& filter,
shape_io& shape,
@ -94,8 +102,6 @@ shape_index_featureset<filterT>::shape_index_featureset(const filterT& filter,
template <typename filterT>
feature_ptr shape_index_featureset<filterT>::next()
{
using mapnik::feature_factory;
using mapnik::geometry_type;
if (itr_!=ids_.end())
{
int pos=*itr_++;

View file

@ -25,8 +25,10 @@
#include "shape_io.hpp"
#include <mapnik/datasource.hpp>
// boost
#include <boost/filesystem/operations.hpp>
#include <boost/make_shared.hpp>
using mapnik::datasource_exception;
using mapnik::geometry_type;
@ -52,7 +54,7 @@ shape_io::shape_io(const std::string& shape_name, bool open_index)
try
{
index_= boost::shared_ptr<shape_file>(new shape_file(shape_name + INDEX));
index_= boost::make_shared<shape_file>(shape_name + INDEX);
}
catch (...)
{
@ -390,7 +392,7 @@ geometry_type * shape_io::read_polygonz()
int num_parts=record.read_ndr_integer();
int num_points=record.read_ndr_integer();
std::vector<int> parts(num_parts);
geometry_type * poly=new geometry_type(mapnik::Polygon);
geometry_type * poly = new geometry_type(mapnik::Polygon);
poly->set_capacity(num_points + num_parts);
for (int i=0;i<num_parts;++i)
{

View file

@ -25,13 +25,16 @@
#ifndef SHAPEFILE_HPP
#define SHAPEFILE_HPP
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/mapped_memory_cache.hpp>
// boost
#include <boost/utility.hpp>
#include <boost/cstdint.hpp>
#include <boost/interprocess/streams/bufferstream.hpp>
// stl
#include <cstring>
#include <fstream>

View file

@ -33,6 +33,7 @@
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/make_shared.hpp>
using boost::lexical_cast;
using boost::bad_lexical_cast;
@ -409,7 +410,7 @@ featureset_ptr sqlite_datasource::features(query const& q) const
boost::shared_ptr<sqlite_resultset> rs (dataset_->execute_query (s.str()));
return featureset_ptr (new sqlite_featureset(rs, desc_.get_encoding(), format_, multiple_geometries_));
return boost::make_shared<sqlite_featureset>(rs, desc_.get_encoding(), format_, multiple_geometries_);
}
return featureset_ptr();
@ -473,7 +474,7 @@ featureset_ptr sqlite_datasource::features_at_point(coord2d const& pt) const
boost::shared_ptr<sqlite_resultset> rs (dataset_->execute_query (s.str()));
return featureset_ptr (new sqlite_featureset(rs, desc_.get_encoding(), format_, multiple_geometries_));
return boost::make_shared<sqlite_featureset>(rs, desc_.get_encoding(), format_, multiple_geometries_);
}
return featureset_ptr();

View file

@ -21,6 +21,7 @@
*****************************************************************************/
//$Id$
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/box2d.hpp>
@ -29,6 +30,7 @@
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/wkb.hpp>
#include <mapnik/unicode.hpp>
#include <mapnik/feature_factory.hpp>
// ogr
#include "sqlite_featureset.hpp"
@ -40,6 +42,7 @@ using mapnik::Feature;
using mapnik::feature_ptr;
using mapnik::geometry_utils;
using mapnik::transcoder;
using mapnik::feature_factory;
sqlite_featureset::sqlite_featureset(boost::shared_ptr<sqlite_resultset> rs,
std::string const& encoding,
@ -68,7 +71,7 @@ feature_ptr sqlite_featureset::next()
// std::clog << "Sqlite Plugin: feature_oid=" << feature_id << std::endl;
#endif
feature_ptr feature(new Feature(feature_id));
feature_ptr feature(feature_factory::create(feature_id));
geometry_utils::from_wkb(*feature,data,size,multiple_geometries_,format_);
for (int i = 2; i < rs_->column_count (); ++i)

View file

@ -2,6 +2,10 @@
#include "hello_datasource.hpp"
#include "hello_featureset.hpp"
// boost
#include <boost/make_shared.hpp>
using mapnik::datasource;
using mapnik::parameters;
@ -69,7 +73,7 @@ mapnik::featureset_ptr hello_datasource::features(mapnik::query const& q) const
// if the query box intersects our world extent then query for features
if (extent_.intersects(q.get_bbox()))
{
return mapnik::featureset_ptr(new hello_featureset(q.get_bbox(),desc_.get_encoding()));
return boost::make_shared<hello_featureset>(q.get_bbox(),desc_.get_encoding());
}
// otherwise return an empty featureset pointer

View file

@ -1,6 +1,9 @@
#include "hello_featureset.hpp"
// mapnik
#include <mapnik/feature_factory.hpp>
#include <mapnik/geometry.hpp>
#include "hello_featureset.hpp"
hello_featureset::hello_featureset(mapnik::box2d<double> const& box, std::string const& encoding)
: box_(box),
feature_id_(1),
@ -13,7 +16,7 @@ mapnik::feature_ptr hello_featureset::next()
if (feature_id_ == 1)
{
// create a new feature
mapnik::feature_ptr feature(new mapnik::Feature(feature_id_));
mapnik::feature_ptr feature(mapnik::feature_factory::create(feature_id_));
// increment the count so that we only return one feature
++feature_id_;