From ab2d86c617c2cdb8d523973d518caf4bf6014f61 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 20 Oct 2015 14:18:17 +0100 Subject: [PATCH] shape.input: remove set_id() method as it's no longer required ref #1020 #1019 --- include/mapnik/feature.hpp | 4 +--- plugins/input/shape/shape_featureset.cpp | 7 +++---- plugins/input/shape/shape_index_featureset.cpp | 11 ++++------- plugins/input/shape/shape_io.hpp | 1 + 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index fff06a232..42bd10bdb 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -110,8 +110,6 @@ public: inline mapnik::value_integer id() const { return id_;} - inline void set_id(mapnik::value_integer id) { id_ = id;} - template inline void put(context_type::key_type const& key, T const& val) { @@ -259,7 +257,7 @@ public: } private: - mapnik::value_integer id_; + const mapnik::value_integer id_; context_ptr ctx_; cont_type data_; geometry::geometry geom_; diff --git a/plugins/input/shape/shape_featureset.cpp b/plugins/input/shape/shape_featureset.cpp index 4cf9dbf0e..44f58ce84 100644 --- a/plugins/input/shape/shape_featureset.cpp +++ b/plugins/input/shape/shape_featureset.cpp @@ -69,7 +69,8 @@ feature_ptr shape_featureset::next() { int offset = shape_.shx().read_xdr_integer(); int record_length = shape_.shx().read_xdr_integer(); - shape_.move_to(2*offset); + shape_.move_to(2 * offset); + mapnik::value_integer feature_id = shape_.id(); assert(record_length == shape_.reclength_); shape_file::record_type record(record_length * 2); shape_.shp().read_record(record); @@ -78,7 +79,7 @@ feature_ptr shape_featureset::next() // skip null shapes if (type == shape_io::shape_null) continue; - feature_ptr feature(feature_factory::create(ctx_, shape_.id_)); + feature_ptr feature(feature_factory::create(ctx_, feature_id)); switch (type) { case shape_io::shape_point: @@ -133,8 +134,6 @@ feature_ptr shape_featureset::next() return feature_ptr(); } - // FIXME: https://github.com/mapnik/mapnik/issues/1020 - feature->set_id(shape_.id_); if (attr_ids_.size()) { shape_.dbf().move_to(shape_.id_); diff --git a/plugins/input/shape/shape_index_featureset.cpp b/plugins/input/shape/shape_index_featureset.cpp index 32f261979..e352efd48 100644 --- a/plugins/input/shape/shape_index_featureset.cpp +++ b/plugins/input/shape/shape_index_featureset.cpp @@ -85,10 +85,11 @@ feature_ptr shape_index_featureset::next() while ( itr_ != offsets_.end()) { shape_ptr_->move_to(*itr_++); + mapnik::value_integer feature_id = shape_ptr_->id(); shape_file::record_type record(shape_ptr_->reclength_ * 2); shape_ptr_->shp().read_record(record); int type = record.read_ndr_integer(); - feature_ptr feature(feature_factory::create(ctx_,shape_ptr_->id_)); + feature_ptr feature(feature_factory::create(ctx_, feature_id)); switch (type) { @@ -141,18 +142,14 @@ feature_ptr shape_index_featureset::next() return feature_ptr(); } - // FIXME: https://github.com/mapnik/mapnik/issues/1020 - feature->set_id(shape_ptr_->id_); if (attr_ids_.size()) { shape_ptr_->dbf().move_to(shape_ptr_->id_); - std::vector::const_iterator itr = attr_ids_.begin(); - std::vector::const_iterator end = attr_ids_.end(); try { - for (; itr!=end; ++itr) + for (auto id : attr_ids_) { - shape_ptr_->dbf().add_attribute(*itr, *tr_, *feature); + shape_ptr_->dbf().add_attribute(id, *tr_, *feature); } } catch (...) diff --git a/plugins/input/shape/shape_io.hpp b/plugins/input/shape/shape_io.hpp index cc8f2584c..ab28f9999 100644 --- a/plugins/input/shape/shape_io.hpp +++ b/plugins/input/shape/shape_io.hpp @@ -75,6 +75,7 @@ public: return (index_ && index_->is_open()); } + inline int id() const { return id_;} void move_to(std::streampos pos); static void read_bbox(shape_file::record_type & record, mapnik::box2d & bbox); static mapnik::geometry::geometry read_polyline(shape_file::record_type & record);