shape.input: remove set_id() method as it's no longer required ref #1020 #1019

This commit is contained in:
artemp 2015-10-20 14:18:17 +01:00
parent 5de3a3776d
commit ab2d86c617
4 changed files with 9 additions and 14 deletions

View file

@ -110,8 +110,6 @@ public:
inline mapnik::value_integer id() const { return id_;} inline mapnik::value_integer id() const { return id_;}
inline void set_id(mapnik::value_integer id) { id_ = id;}
template <typename T> template <typename T>
inline void put(context_type::key_type const& key, T const& val) inline void put(context_type::key_type const& key, T const& val)
{ {
@ -259,7 +257,7 @@ public:
} }
private: private:
mapnik::value_integer id_; const mapnik::value_integer id_;
context_ptr ctx_; context_ptr ctx_;
cont_type data_; cont_type data_;
geometry::geometry<double> geom_; geometry::geometry<double> geom_;

View file

@ -69,7 +69,8 @@ feature_ptr shape_featureset<filterT>::next()
{ {
int offset = shape_.shx().read_xdr_integer(); int offset = shape_.shx().read_xdr_integer();
int record_length = 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_); assert(record_length == shape_.reclength_);
shape_file::record_type record(record_length * 2); shape_file::record_type record(record_length * 2);
shape_.shp().read_record(record); shape_.shp().read_record(record);
@ -78,7 +79,7 @@ feature_ptr shape_featureset<filterT>::next()
// skip null shapes // skip null shapes
if (type == shape_io::shape_null) continue; 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) switch (type)
{ {
case shape_io::shape_point: case shape_io::shape_point:
@ -133,8 +134,6 @@ feature_ptr shape_featureset<filterT>::next()
return feature_ptr(); return feature_ptr();
} }
// FIXME: https://github.com/mapnik/mapnik/issues/1020
feature->set_id(shape_.id_);
if (attr_ids_.size()) if (attr_ids_.size())
{ {
shape_.dbf().move_to(shape_.id_); shape_.dbf().move_to(shape_.id_);

View file

@ -85,10 +85,11 @@ feature_ptr shape_index_featureset<filterT>::next()
while ( itr_ != offsets_.end()) while ( itr_ != offsets_.end())
{ {
shape_ptr_->move_to(*itr_++); shape_ptr_->move_to(*itr_++);
mapnik::value_integer feature_id = shape_ptr_->id();
shape_file::record_type record(shape_ptr_->reclength_ * 2); shape_file::record_type record(shape_ptr_->reclength_ * 2);
shape_ptr_->shp().read_record(record); shape_ptr_->shp().read_record(record);
int type = record.read_ndr_integer(); 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) switch (type)
{ {
@ -141,18 +142,14 @@ feature_ptr shape_index_featureset<filterT>::next()
return feature_ptr(); return feature_ptr();
} }
// FIXME: https://github.com/mapnik/mapnik/issues/1020
feature->set_id(shape_ptr_->id_);
if (attr_ids_.size()) if (attr_ids_.size())
{ {
shape_ptr_->dbf().move_to(shape_ptr_->id_); shape_ptr_->dbf().move_to(shape_ptr_->id_);
std::vector<int>::const_iterator itr = attr_ids_.begin();
std::vector<int>::const_iterator end = attr_ids_.end();
try 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 (...) catch (...)

View file

@ -75,6 +75,7 @@ public:
return (index_ && index_->is_open()); return (index_ && index_->is_open());
} }
inline int id() const { return id_;}
void move_to(std::streampos pos); void move_to(std::streampos pos);
static void read_bbox(shape_file::record_type & record, mapnik::box2d<double> & bbox); static void read_bbox(shape_file::record_type & record, mapnik::box2d<double> & bbox);
static mapnik::geometry::geometry<double> read_polyline(shape_file::record_type & record); static mapnik::geometry::geometry<double> read_polyline(shape_file::record_type & record);