[pdal] About mathematical expressions in AssignFilter

A Huarte ahuarte47 at yahoo.es
Tue Feb 19 08:43:45 PST 2019


Hi PDAL community, I would like to propose a new feature for the Assign filter. This filter allows you assign a new value to a specific dimension. This is great but I think that it could have a new interesting feature.
My proposal is that you can define a mathematical expresion to assign the value. 
For example:
{      "type": "filters.assign",      "assignment": "Z[-1000:1000]=$( 10 * [Z] )"},{
      "type": "filters.assign",      "assignment": "Z[-1000:1000]=$( 10 * 2 + [Z] + (25 * [X]) )"},{      "type": "filters.assign",      "assignment": "Classification[0:10]=PointSourceId:$( [PointSourceId] == 3 )"},{      "type": "filters.assign",      "assignment": "Classification[0:10]=Z:$( 10 * ([Classification]>=2 && [Classification]<=4) )"},
The optional expression could be marked with a $(....) text. 
I have implemented my own version in a simple manner. It supports the tipical calc operators ( * / + -  && || >= == != <= > < ) and "(...)" for priorizing them. You can write "[dimension_name]" to extract the attribute value of a dimension in the current point. Also you can define an optional dimension target, different of the first dimension that acts as filter, specifing it just after the "=" item.
For a fully calc parser (Including functions) I could use the amazing https://www.antlr.org, but It would add a new dependency to the PDAL software. I think these simple operators already give a plus to this filter.
Any opinions?If you agree I could try to create a pull request with my code.

Best regards
https://github.com/ahuarte47
Alvaro

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20190219/f63dc031/attachment-0001.html>


More information about the pdal mailing list