shape.input - read shx_file_length in shape_featureset and avoid passing wrong file length by mistake ref #3136

This commit is contained in:
artemp 2015-10-21 10:55:26 +01:00
parent 19c1c0afd0
commit 17ace8a3e8
4 changed files with 9 additions and 16 deletions

View file

@ -64,7 +64,6 @@ shape_datasource::shape_datasource(parameters const& params)
: datasource (params),
type_(datasource::Vector),
file_length_(0),
shx_file_length_(0),
indexed_(false),
row_limit_(*params.get<mapnik::value_integer>("row_limit",0)),
desc_(shape_datasource::name(), *params.get<std::string>("encoding","utf-8"))
@ -199,14 +198,6 @@ void shape_datasource::init(shape_io& shape)
const double hiy = header.read_double();
extent_.init(lox, loy, hix, hiy);
if (shape.shx().is_open())
{
shape_file::record_type shx_header(100);
shape.shx().read_record(shx_header);
shx_header.skip(6 * 4);
shx_file_length_ = shx_header.read_xdr_integer();
}
#ifdef MAPNIK_LOG
const double zmin = header.read_double();
const double zmax = header.read_double();
@ -265,7 +256,6 @@ featureset_ptr shape_datasource::features(query const& q) const
shape_name_,
q.property_names(),
desc_.get_encoding(),
shx_file_length_,
row_limit_);
}
}
@ -303,7 +293,6 @@ featureset_ptr shape_datasource::features_at_point(coord2d const& pt, double tol
shape_name_,
names,
desc_.get_encoding(),
shx_file_length_,
row_limit_);
}
}

View file

@ -69,7 +69,6 @@ private:
std::string shape_name_;
shape_io::shapeType shape_type_;
long file_length_;
long shx_file_length_;
box2d<double> extent_;
bool indexed_;
const int row_limit_;

View file

@ -41,19 +41,25 @@ shape_featureset<filterT>::shape_featureset(filterT const& filter,
std::string const& shape_name,
std::set<std::string> const& attribute_names,
std::string const& encoding,
long shx_file_length,
int row_limit)
: filter_(filter),
shape_(shape_name, false),
query_ext_(),
feature_bbox_(),
tr_(new transcoder(encoding)),
shx_file_length_(shx_file_length),
shx_file_length_(0),
row_limit_(row_limit),
count_(0),
ctx_(std::make_shared<mapnik::context_type>())
{
shape_.shx().skip(100);
if (!shape_.shx().is_open())
{
throw mapnik::datasource_exception("Shape Plugin: can't open '" + shape_name + ".shx' file");
}
shape_file::record_type shx_header(100);
shape_.shx().read_record(shx_header);
shx_header.skip(6 * 4);
shx_file_length_ = shx_header.read_xdr_integer();
setup_attributes(ctx_, attribute_names, shape_name, shape_, attr_ids_);
}

View file

@ -50,7 +50,6 @@ public:
std::string const& shape_file,
std::set<std::string> const& attribute_names,
std::string const& encoding,
long shx_file_length,
int row_limit);
virtual ~shape_featureset();
feature_ptr next();