[pdal] Array Dimensions

Howard Butler hobu.inc at gmail.com
Mon Jul 1 06:34:30 PDT 2013


On Jun 30, 2013, at 8:32 PM, Chris Foster <chris.foster at roames.com.au> wrote:

> Hi all,
> 
> Sorry to bombard the list with so much mail, I'll try to hold off a bit after
> this one.

Not a problem at all. Keep emailing as you explore and find dumb stuff :)

> After a bit of hacking on the weekend I'm fairly confident that pdal will work
> for us, with the possible exception of one major feature which appears to be
> missing from PointBuffer: Dimensions which hold short fixed size arrays rather
> than single elements.

I hadn't thought of this. 

Were you planing to use PDAL for something other than data translation? 

> The problem is that sometimes a Dimension logically contains more than one
> element, and it doesn't make sense to name the elements independently.  For
> example, suppose I want to write a filter which computes local geometric
> properties using the eigenstructure of the local covariance matrix.  The
> output from this is naturally represented as a 3-vector of eigenvalues and a
> 3x3 matrix of eigenvectors per point.  Now, I could name each of these using
> their own Dimension, but that introduces unnecessary overhead and the
> resulting components don't make logical sense on their own.
> 

You could kind of do this now with a dimension type pdal::dimension::UnsignedByte and an explicit size. Nothing useful other than yourself would be able to interpret it though.

> I'm imagining something like
> 
> PointBuffer buf(...);
> const Dimension& eigenValuesDim = buf.getSchema().getDimension("EigenValues");
> // ...
> float* vals = buf.getArrayField<float>(eigenValuesDim, 0);
> 
> If the size is known at compile time, the following would pretty much work
> already
> 
> const boost::array<float,9>& vals =
>    buf.getField<boost::array<float,9> >(eigenValuesDim, 0);
> 
> 
> Other libraries agree that this is a useful feature, for example PCL has
> explicit support for it in their PCD file format.

Yes, this makes total sense.

> 
> I'm certainly willing to write code to make this work, but I'm not sure how
> large a job it would be, so I'd need some guidance about whether it's a
> desired feature before I start anything.  If not, I may have to implement a
> point buffer class of my own, but I like to avoid reinventing wheels where
> possible.

Thinking out loud, we'd need:

* pdal::dimension::ArrayType
* pdal::Dimension::getElementCount() (or appropriate name)
* pdal::Dimension::getByteSize() needs to be made dynamic when the dimension type is array
* getField/setField *should* just work as-is.
* other stuff I'm sure I forgot.

Please start a pull request with this effort, and I'll make sure to track its development. If you get stuck, don't hesitate to ask or catch me on IRC.

Thanks for the contribution!

Howard



More information about the pdal mailing list