avoid trying to open index for non-indexed shapefile reads for every feature query - good speedup
This commit is contained in:
parent
408de0c223
commit
a3be4f54ab
3 changed files with 16 additions and 12 deletions
|
@ -32,7 +32,7 @@ shape_featureset<filterT>::shape_featureset(const filterT& filter,
|
|||
long file_length )
|
||||
: filter_(filter),
|
||||
shape_type_(shape_io::shape_null),
|
||||
shape_(shape_file),
|
||||
shape_(shape_file, false),
|
||||
query_ext_(),
|
||||
tr_(new transcoder(encoding)),
|
||||
file_length_(file_length),
|
||||
|
|
|
@ -33,7 +33,7 @@ const std::string shape_io::SHP = ".shp";
|
|||
const std::string shape_io::DBF = ".dbf";
|
||||
const std::string shape_io::INDEX = ".index";
|
||||
|
||||
shape_io::shape_io(const std::string& shape_name)
|
||||
shape_io::shape_io(const std::string& shape_name, bool open_index)
|
||||
: type_(shape_null),
|
||||
shp_(shape_name + SHP),
|
||||
dbf_(shape_name + DBF),
|
||||
|
@ -45,18 +45,22 @@ shape_io::shape_io(const std::string& shape_name)
|
|||
{
|
||||
throw datasource_exception("Shape Plugin: cannot read shape file '" + shape_name + "'");
|
||||
}
|
||||
try
|
||||
if (open_index)
|
||||
{
|
||||
if (!boost::filesystem::exists(shape_name + INDEX))
|
||||
try
|
||||
{
|
||||
throw datasource_exception("Shape Plugin: could not open index: '" + shape_name + INDEX + "' does not exist");
|
||||
|
||||
if (!boost::filesystem::exists(shape_name + INDEX))
|
||||
{
|
||||
throw datasource_exception("Shape Plugin: could not open index: '" + shape_name + INDEX + "' does not exist");
|
||||
}
|
||||
|
||||
index_= boost::shared_ptr<shape_file>(new shape_file(shape_name + INDEX));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Shape Plugin: warning - could not open index: '" + shape_name + INDEX + "'" << std::endl;
|
||||
}
|
||||
|
||||
index_= boost::shared_ptr<shape_file>(new shape_file(shape_name + INDEX));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Shape Plugin: warning - could not open index: '" + shape_name + INDEX + "'" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
shape_multipatch = 31
|
||||
};
|
||||
|
||||
shape_io(const std::string& shape_name);
|
||||
shape_io(const std::string& shape_name, bool open_index=true);
|
||||
~shape_io();
|
||||
shape_file& shp();
|
||||
shape_file& shx();
|
||||
|
|
Loading…
Add table
Reference in a new issue