+ 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
|
@ -133,14 +133,18 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
else
|
||||
{
|
||||
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))
|
||||
{
|
||||
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,21 +260,19 @@ 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
|
||||
{
|
||||
shape_.dbf().add_attribute(*pos,*tr_,*feature);//TODO optimize!!!
|
||||
for (;itr!=end;++itr)
|
||||
{
|
||||
shape_.dbf().add_attribute(*itr,*tr_,*feature);//TODO optimize!!!
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::clog << "Shape Plugin: error processing attributes " << std::endl;
|
||||
}
|
||||
++pos;
|
||||
}
|
||||
}
|
||||
return feature;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue