avoid keeping open shape_io shared_ptr when the shapefile does not have an index
This commit is contained in:
parent
5876abcc30
commit
616aa2ed05
1 changed files with 11 additions and 5 deletions
|
@ -86,11 +86,11 @@ void shape_datasource::bind() const
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
shape_ = boost::shared_ptr<shape_io>(new shape_io(shape_name_));
|
boost::shared_ptr<shape_io> shape_ref = boost::shared_ptr<shape_io>(new shape_io(shape_name_));
|
||||||
init(*shape_);
|
init(*shape_ref);
|
||||||
for (int i=0;i<shape_->dbf().num_fields();++i)
|
for (int i=0;i<shape_ref->dbf().num_fields();++i)
|
||||||
{
|
{
|
||||||
field_descriptor const& fd=shape_->dbf().descriptor(i);
|
field_descriptor const& fd=shape_ref->dbf().descriptor(i);
|
||||||
std::string fld_name=fd.name_;
|
std::string fld_name=fd.name_;
|
||||||
switch (fd.type_)
|
switch (fd.type_)
|
||||||
{
|
{
|
||||||
|
@ -120,13 +120,18 @@ void shape_datasource::bind() const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// for indexed shapefiles we keep open the file descriptor for fast reads
|
||||||
|
if (indexed_) {
|
||||||
|
shape_ = shape_ref;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (datasource_exception& ex)
|
catch (datasource_exception& ex)
|
||||||
{
|
{
|
||||||
std::clog << "Shape Plugin: error processing field attributes, " << ex.what() << std::endl;
|
std::clog << "Shape Plugin: error processing field attributes, " << ex.what() << std::endl;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...) // exception: pipe_select_interrupter: Too many open files
|
||||||
{
|
{
|
||||||
std::clog << "Shape Plugin: error processing field attributes" << std::endl;
|
std::clog << "Shape Plugin: error processing field attributes" << std::endl;
|
||||||
throw;
|
throw;
|
||||||
|
@ -180,6 +185,7 @@ void shape_datasource::init(shape_io& shape) const
|
||||||
// check if we have an index file around
|
// check if we have an index file around
|
||||||
|
|
||||||
indexed_ = shape.has_index();
|
indexed_ = shape.has_index();
|
||||||
|
|
||||||
//std::string index_name(shape_name_+".index");
|
//std::string index_name(shape_name_+".index");
|
||||||
//std::ifstream file(index_name.c_str(),std::ios::in | std::ios::binary);
|
//std::ifstream file(index_name.c_str(),std::ios::in | std::ios::binary);
|
||||||
//if (file)
|
//if (file)
|
||||||
|
|
Loading…
Reference in a new issue