[Liblas-devel] HasColor() and HasTime() removed from Schema class public interface

Trudgett, David D.Trudgett at aamgroup.com
Sun Jan 16 18:40:56 EST 2011


Hello, Howard,

> 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.

Yes, that sounds reasonable. :-)

I've been away on holidays, in case you're wondering about the delayed
response... ;-)

Regards,
David Trudgett
 





 
-----Original Message-----
From: Howard Butler [mailto:hobu.inc at gmail.com] 
Sent: Friday, 24 December 2010 05:44
To: Trudgett, David
Cc: liblas-devel at lists.osgeo.org
Subject: Re: [Liblas-devel] HasColor() and HasTime() removed from Schema
class public interface


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
Attention

Email Disclaimer Notice - This message is the property of AAM Pty Ltd. The information in this email is confidential and may be legally privileged.
It is intended solely for the
addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it is prohibited and may be unlawful.

If you have received this message in error please notify AAM Pty Ltd. immediately via email to mailadmin at aamgroup.com <mailto:mailadmin at aamgroup.com> 

This email has been scanned and cleared by NetIQ Mail Marshal, however AAM Pty Ltd does not guarantee this message free of viruses, or interference. 
________________________________


More information about the Liblas-devel mailing list