On Dec 19, 2010, at 8:38 PM, Howard Butler wrote:

> The proper way to ask for HasColor or HasTime now is to ask the schema if the 
> color or time dimensions exist.
> 
> bool bColorExists = false;
> try {
> 
>       liblas::Dimension const& red = schema.GetDimension("Red");
>       liblas::Dimension const& green = schema.GetDimension("Green");
>       liblas::Dimension const& blue = schema.GetDimension("Blue");
>       bColorExists = true;
> 
> } catch (std::runtime_error const&)
> {
> }

David,

I have changed this again to no longer throw an exception if nothing is found.  
Instead, as suggested by Mateusz, the Dimension is wrapped in a boost::optional 
that may be null.

boost::optional< Dimension const& > red = schema.GetDimension("Red");
boost::optional< Dimension const& > green = schema.GetDimension("Green");
boost::optional< Dimension const& > blue = schema.GetDimension("Blue");

if (red && green && blue)
    bColorExists = true;

A boost::optional can be dereferenced to get the const &.  For example,

red->GetName();  

Thanks for the feedback.  I think this is better :)

Howard_______________________________________________
Liblas-devel mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/liblas-devel

Reply via email to