From 9cdb99ec0fa9fcbfa010c4bdfffac57df80a44c8 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 17 Jan 2012 14:22:21 -0500 Subject: [PATCH] adapt occi, geos, and kismet plugins to new feature impl --- plugins/input/gdal/gdal_featureset.cpp | 4 ++-- plugins/input/geos/geos_featureset.cpp | 8 +++++--- plugins/input/geos/geos_featureset.hpp | 1 + plugins/input/kismet/kismet_featureset.cpp | 10 ++++++---- plugins/input/kismet/kismet_featureset.hpp | 5 +++-- plugins/input/occi/occi_datasource.cpp | 17 +++++++++-------- plugins/input/occi/occi_featureset.cpp | 16 ++++++++-------- plugins/input/occi/occi_featureset.hpp | 6 +++--- 8 files changed, 37 insertions(+), 30 deletions(-) diff --git a/plugins/input/gdal/gdal_featureset.cpp b/plugins/input/gdal/gdal_featureset.cpp index 218faf158..9af84afa6 100644 --- a/plugins/input/gdal/gdal_featureset.cpp +++ b/plugins/input/gdal/gdal_featureset.cpp @@ -64,9 +64,9 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset, dy_(dy), nbands_(nbands), filter_factor_(filter_factor), - first_(true) + first_(true), + ctx_(boost::make_shared()) { - ctx_ = boost::make_shared(); ctx_->push("NODATA"); } diff --git a/plugins/input/geos/geos_featureset.cpp b/plugins/input/geos/geos_featureset.cpp index afd2d71af..e2e80f99b 100644 --- a/plugins/input/geos/geos_featureset.cpp +++ b/plugins/input/geos/geos_featureset.cpp @@ -60,8 +60,10 @@ geos_featureset::geos_featureset(GEOSGeometry* geometry, identifier_(identifier), field_(field), field_name_(field_name), - already_rendered_(false) + already_rendered_(false), + ctx_(boost::make_shared()) { + ctx_->push(field_name); } geos_featureset::~geos_featureset() @@ -114,14 +116,14 @@ feature_ptr geos_featureset::next() geos_wkb_ptr wkb(geometry_); if (wkb.is_valid()) { - feature_ptr feature(feature_factory::create(identifier_)); + feature_ptr feature(feature_factory::create(ctx_,identifier_)); geometry_utils::from_wkb(feature->paths(), wkb.data(), wkb.size()); if (field_ != "") { - boost::put(*feature, field_name_, tr_->transcode(field_.c_str())); + feature->put(field_name_, tr_->transcode(field_.c_str())); } return feature; diff --git a/plugins/input/geos/geos_featureset.hpp b/plugins/input/geos/geos_featureset.hpp index 713f9ff4c..f3fcb9d81 100644 --- a/plugins/input/geos/geos_featureset.hpp +++ b/plugins/input/geos/geos_featureset.hpp @@ -56,6 +56,7 @@ private: std::string field_; std::string field_name_; bool already_rendered_; + mapnik::context_ptr ctx_; geos_featureset(const geos_featureset&); const geos_featureset& operator=(const geos_featureset&); diff --git a/plugins/input/kismet/kismet_featureset.cpp b/plugins/input/kismet/kismet_featureset.cpp index ab1d198fa..a766e364b 100644 --- a/plugins/input/kismet/kismet_featureset.cpp +++ b/plugins/input/kismet/kismet_featureset.cpp @@ -40,15 +40,17 @@ using mapnik::geometry_utils; using mapnik::transcoder; using mapnik::feature_factory; -kismet_featureset::kismet_featureset(const std::list& knd_list, +kismet_featureset::kismet_featureset(std::list const& knd_list, std::string const& srs, std::string const& encoding) : knd_list_(knd_list), tr_(new transcoder(encoding)), feature_id_(1), knd_list_it(knd_list_.begin()), - source_(srs) + source_(srs), + ctx_(boost::make_shared()) { + ctx_->push("internet_access"); } kismet_featureset::~kismet_featureset() @@ -76,14 +78,14 @@ feature_ptr kismet_featureset::next() value = "wlan_crypted"; } - feature_ptr feature(feature_factory::create(feature_id_)); + feature_ptr feature(feature_factory::create(ctx_,feature_id_)); ++feature_id_; geometry_type* pt = new geometry_type(mapnik::Point); pt->move_to(knd.bestlon(), knd.bestlat()); feature->add_geometry(pt); - boost::put(*feature, key, tr_->transcode(value.c_str())); + feature->put(key, tr_->transcode(value.c_str())); ++knd_list_it; diff --git a/plugins/input/kismet/kismet_featureset.hpp b/plugins/input/kismet/kismet_featureset.hpp index 363f3425a..0efdf537c 100644 --- a/plugins/input/kismet/kismet_featureset.hpp +++ b/plugins/input/kismet/kismet_featureset.hpp @@ -40,19 +40,20 @@ class kismet_featureset : public mapnik::Featureset { public: - kismet_featureset(const std::list& knd_list, + kismet_featureset(std::list const& knd_list, std::string const& srs, std::string const& encoding); virtual ~kismet_featureset(); mapnik::feature_ptr next(); private: - const std::list& knd_list_; + std::list const& knd_list_; boost::scoped_ptr tr_; mapnik::wkbFormat format_; int feature_id_; std::list::const_iterator knd_list_it; mapnik::projection source_; + mapnik::context_ptr ctx_; }; #endif // KISMET_FEATURESET_HPP diff --git a/plugins/input/occi/occi_datasource.cpp b/plugins/input/occi/occi_datasource.cpp index 335146174..fa056bebf 100644 --- a/plugins/input/occi/occi_datasource.cpp +++ b/plugins/input/occi/occi_datasource.cpp @@ -492,10 +492,11 @@ featureset_ptr occi_datasource::features(query const& q) const std::set const& props = q.property_names(); std::set::const_iterator pos = props.begin(); std::set::const_iterator end = props.end(); - while (pos != end) + mapnik::context_ptr ctx = boost::make_shared(); + for ( ;pos != end;++pos) { s << ", " << *pos; - ++pos; + ctx->push(*pos); } s << " FROM "; @@ -557,11 +558,11 @@ featureset_ptr occi_datasource::features(query const& q) const return boost::make_shared(pool_, conn_, + ctx, s.str(), desc_.get_encoding(), use_connection_pool_, - row_prefetch_, - props.size()); + row_prefetch_); } featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const @@ -572,12 +573,12 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const s << "SELECT " << geometry_field_; std::vector::const_iterator itr = desc_.get_descriptors().begin(); std::vector::const_iterator end = desc_.get_descriptors().end(); - unsigned size = 0; + mapnik::context_ptr ctx = boost::make_shared(); while (itr != end) { s << ", " << itr->get_name(); + ctx->push(itr->get_name()); ++itr; - ++size; } s << " FROM "; @@ -638,9 +639,9 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const return boost::make_shared(pool_, conn_, + ctx, s.str(), desc_.get_encoding(), use_connection_pool_, - row_prefetch_, - size); + row_prefetch_); } diff --git a/plugins/input/occi/occi_featureset.cpp b/plugins/input/occi/occi_featureset.cpp index b4ea397ad..22073a7c8 100644 --- a/plugins/input/occi/occi_featureset.cpp +++ b/plugins/input/occi/occi_featureset.cpp @@ -57,14 +57,14 @@ using oracle::occi::Blob; occi_featureset::occi_featureset(StatelessConnectionPool* pool, Connection* conn, + mapnik::context_ptr const& ctx, std::string const& sqlstring, std::string const& encoding, bool use_connection_pool, - unsigned prefetch_rows, - unsigned num_attrs) + unsigned prefetch_rows) : tr_(new transcoder(encoding)), - num_attrs_(num_attrs), - feature_id_(1) + feature_id_(1), + ctx_(ctx) { if (use_connection_pool) { @@ -93,7 +93,7 @@ feature_ptr occi_featureset::next() { if (rs_ && rs_->next()) { - feature_ptr feature(feature_factory::create(feature_id_)); + feature_ptr feature(feature_factory::create(ctx_,feature_id_)); ++feature_id_; boost::scoped_ptr geom(dynamic_cast(rs_->getObject(1))); @@ -125,7 +125,7 @@ feature_ptr occi_featureset::next() case oracle::occi::OCCIINT: case oracle::occi::OCCIUNSIGNED_INT: case oracle::occi::OCCIROWID: - boost::put(*feature,fld_name,rs_->getInt (i + 1)); + feature->put(fld_name,rs_->getInt (i + 1)); break; case oracle::occi::OCCIFLOAT: case oracle::occi::OCCIBFLOAT: @@ -133,7 +133,7 @@ feature_ptr occi_featureset::next() case oracle::occi::OCCIBDOUBLE: case oracle::occi::OCCINUMBER: case oracle::occi::OCCI_SQLT_NUM: - boost::put(*feature,fld_name,rs_->getDouble (i + 1)); + feature->put(fld_name,rs_->getDouble (i + 1)); break; case oracle::occi::OCCICHAR: case oracle::occi::OCCISTRING: @@ -147,7 +147,7 @@ feature_ptr occi_featureset::next() case oracle::occi::OCCI_SQLT_VNU: case oracle::occi::OCCI_SQLT_VBI: case oracle::occi::OCCI_SQLT_VST: - boost::put(*feature,fld_name,(UnicodeString) tr_->transcode (rs_->getString (i + 1).c_str())); + feature->put(fld_name,(UnicodeString) tr_->transcode (rs_->getString (i + 1).c_str())); break; case oracle::occi::OCCIDATE: case oracle::occi::OCCITIMESTAMP: diff --git a/plugins/input/occi/occi_featureset.hpp b/plugins/input/occi/occi_featureset.hpp index 4c2a0db67..1ad3be653 100644 --- a/plugins/input/occi/occi_featureset.hpp +++ b/plugins/input/occi/occi_featureset.hpp @@ -40,11 +40,11 @@ class occi_featureset : public mapnik::Featureset public: occi_featureset(oracle::occi::StatelessConnectionPool* pool, oracle::occi::Connection* conn, + mapnik::context_ptr const& ctx, std::string const& sqlstring, std::string const& encoding, bool use_connection_pool, - unsigned prefetch_rows, - unsigned num_attrs); + unsigned prefetch_rows); virtual ~occi_featureset(); mapnik::feature_ptr next(); @@ -68,8 +68,8 @@ private: oracle::occi::ResultSet* rs_; boost::scoped_ptr tr_; const char* fidcolumn_; - unsigned num_attrs_; mutable int feature_id_; + mapnik::context_ptr ctx_; }; #endif // OCCI_FEATURESET_HPP