<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:11pt;">
<div>Howard,</div>
<div> </div>
<div>Recently I have had a need for feeding user data to the programmable filter. I have an application that creates a PDAL pipeline based on the input and various settings determine the output. In some cases I use the programmable filter to do something that
is outside the current scope of PDAL. If it were possible to access the pipeline JSON, and the userData section of the pipeline, from the Python function behind the filter I would be able to make more generic filters. </div>
<div>A recent example is that I wanted to create a vertical gridshift filter (similar to what Proj.4 does). I would have liked to pass the grid name to the programmable filter as a PDAL pipeline parameter but that is not possible. Instead I ended up hard coding
it. It did the job but wasn't a very satisfying solution. I have since realized that I can in fact use the reprojection filter to do this (via Proj.4). This is just the example that came to mind – I have been in similar situations before but the exact details
escape my memory.</div>
<div> </div>
<div>The Python function prototype will have to be changed. It is best demonstrated with an example. I have extended the multiply_z function from the filters.programmable doc page with my suggestion:</div>
<div> </div>
<div style="padding-left:65.2pt;"><font face="Consolas" size="2"><span style="font-size:10pt;">import numpy as np</span></font></div>
<div style="padding-left:65.2pt;"><font face="Consolas" size="2"><span style="font-size:10pt;"> </span></font></div>
<div style="padding-left:65.2pt;"><font face="Consolas" size="2"><span style="font-size:10pt;">def multiply_z(ins, outs, pipeline):</span></font></div>
<div style="padding-left:65.2pt;"><font face="Consolas" size="2"><span style="font-size:10pt;"> f = pipeline[1]['userData']['z_factor']</span></font></div>
<div style="padding-left:65.2pt;"><font face="Consolas" size="2"><span style="font-size:10pt;"> Z = ins['Z']</span></font></div>
<div style="padding-left:65.2pt;"><font face="Consolas" size="2"><span style="font-size:10pt;"> Z = Z * f</span></font></div>
<div style="padding-left:65.2pt;"><font face="Consolas" size="2"><span style="font-size:10pt;"> outs['Z'] = Z</span></font></div>
<div style="padding-left:65.2pt;"><font face="Consolas" size="2"><span style="font-size:10pt;"> return True</span></font></div>
<div> </div>
<div>Info about the other stages in a pipeline should also be available. For the above case the pipeline dictionary would be constructed with:</div>
<div> </div>
<div> <font face="Consolas" size="2"><span style="font-size:10pt;">with open(‘pipeline.json’) as </span></font><font face="Consolas" size="2"><span style="font-size:10pt;">json_file</span></font><font face="Consolas" size="2"><span style="font-size:10pt;">:</span></font></div>
<div><font face="Consolas" size="2"><span style="font-size:10pt;"> pipeline = json.load(json_file)[‘pipeline’]</span></font></div>
<div> </div>
<div> </div>
<div> </div>
<div>It is not exactly what you are asking about here but I think it is a nice addition to the "userData" concept that you are introducing. My suggestion can of course be extended to filters.predicate as well.</div>
<div> </div>
<div>/Kristian</div>
<div> </div>
<div> </div>
<div>> -----Oprindelig meddelelse-----</div>
<div>> Fra: pdal [<a href="mailto:pdal-bounces@lists.osgeo.org">mailto:pdal-bounces@lists.osgeo.org</a>] På vegne af Howard Butler</div>
<div>> Sendt: 29. december 2016 19:45</div>
<div>> Til: pdal</div>
<div>> Emne: Re: [pdal] PDAL Pipeline Extensibility</div>
<div>> </div>
<div>> </div>
<div>> > On Dec 22, 2016, at 10:51 AM, Howard Butler <<a href="mailto:howard@hobu.co">howard@hobu.co</a>> wrote:</div>
<div>> ></div>
<div>> ></div>
<div>> >> On Dec 21, 2016, at 9:36 PM, Rob Emanuele <<a href="mailto:rdemanuele@gmail.com">rdemanuele@gmail.com</a>></div>
<div>> wrote:</div>
<div>> >></div>
<div>> >> If that's correct, I would say instead of "application", some better terms</div>
<div>> would be "tags", "userData", "userTags", or something along those lines.</div>
<div>> ></div>
<div>> > Yes, I was hoping for a better name here. I was also hoping there was a</div>
<div>> standard way that people were extending JSON like this, and that we would</div>
<div>> just support it. I haven't found anything thus far though.</div>
<div>> </div>
<div>> I renamed it to 'userData'. Thanks for the feedback.</div>
<div>> </div>
<div>> Howard</div>
<div>> _______________________________________________</div>
<div>> pdal mailing list</div>
<div>> <a href="mailto:pdal@lists.osgeo.org">pdal@lists.osgeo.org</a></div>
<div>> <a href="http://lists.osgeo.org/mailman/listinfo/pdal">http://lists.osgeo.org/mailman/listinfo/pdal</a></div>
<div> </div>
</span></font>
</body>
</html>