[Liblas-devel] Throwing out_of_range exceptions on read
Mateusz Loskot
mateusz at loskot.net
Mon Apr 28 21:07:30 EDT 2008
Howard Butler wrote:
> Here is what I propose for a LASPoint::Validate() method:
>
> bool LASPoint::Validate() const
> {
>
> if (eScanAngleRankMin > this->GetScanAngleRank() ||
> this->GetScanAngleRank() > eScanAngleRankMax)
> throw std::out_of_range("scan angle rank out of range");
>
> if (this->GetFlightLineEdge() > 0x01)
> throw std::out_of_range("edge of flight line out of range");
>
> if (this->GetScanDirection() > 0x01)
> throw std::out_of_range("scan direction flag out of range");
>
> if (this->GetNumberOfReturns() > 0x07)
> throw std::out_of_range("number of returns out of range");
>
> if (this->GetReturnNumber() > 0x07)
> throw std::out_of_range("return number out of range");
>
> if (this->GetTime() < 0.0)
> throw std::out_of_range("time value is < 0 ");
>
> if (this->GetClassification() > 31)
> throw std::out_of_range("classification value is > 31");
>
>
> return true;
> }
Hobu,
I'm not sure if Validate should throw. Instead, I'd just return false.
If a point is invalid, the checking condition is never false:
if (validate())
{
// we love this point, writing to file
}
so invalid points are not just skipped but the writing process is
interrupted.
Or there is a good reason Validate throws?
Greetings
--
Mateusz Loskot
http://mateusz.loskot.net
More information about the Liblas-devel
mailing list