+ check if pos is valid while iterating through
shapes (don't use eof()!) + handle null_shapes better (TODO:testing)
This commit is contained in:
parent
2317efe15f
commit
9a49b81318
1 changed files with 18 additions and 16 deletions
|
@ -134,13 +134,17 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
{
|
||||
while (!filter_.pass(shape_.current_extent()))
|
||||
{
|
||||
if (!shape_.shp().is_eof())
|
||||
std::streampos pos = shape_.shp().pos();
|
||||
if (pos > 0 && pos < std::streampos(file_length_ * 2))
|
||||
{
|
||||
std::streampos pos = shape_.shp().pos();
|
||||
if (shape_.type() != shape_io::shape_null)
|
||||
{
|
||||
pos += std::streampos(2 * shape_.reclength_ - 36);
|
||||
}
|
||||
else
|
||||
{
|
||||
pos += std::streampos(8 * 3);
|
||||
}
|
||||
shape_.move_to(pos);
|
||||
}
|
||||
else
|
||||
|
@ -256,20 +260,18 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
if (attr_ids_.size())
|
||||
{
|
||||
shape_.dbf().move_to(shape_.id_);
|
||||
std::vector<int>::const_iterator pos=attr_ids_.begin();
|
||||
std::vector<int>::const_iterator itr=attr_ids_.begin();
|
||||
std::vector<int>::const_iterator end=attr_ids_.end();
|
||||
|
||||
while (pos!=end)
|
||||
try
|
||||
{
|
||||
try
|
||||
for (;itr!=end;++itr)
|
||||
{
|
||||
shape_.dbf().add_attribute(*pos,*tr_,*feature);//TODO optimize!!!
|
||||
shape_.dbf().add_attribute(*itr,*tr_,*feature);//TODO optimize!!!
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::clog << "Shape Plugin: error processing attributes " << std::endl;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::clog << "Shape Plugin: error processing attributes " << std::endl;
|
||||
}
|
||||
}
|
||||
return feature;
|
||||
|
|
Loading…
Reference in a new issue