[pdal] How to invoke my custom writer?

Paul Schrum paul.schrum at gmail.com
Tue Jul 11 11:37:32 PDT 2017


Andrew,

We have become interested in that second option you mention, "executing
code programmatically, you can simply add your writer to the end of a
pipeline and call prepare() and execute()".  Are there examples of how to
do this?

We looked at PipelineManager and see
PointTableRef pointTable() const

Is that what we would consume?  If so, how do I get to the point where that
has data in it and is ready for me to iterate over

- Paul


On Tue, Jul 11, 2017 at 11:16 AM, Andrew Bell <andrew.bell.ia at gmail.com>
wrote:

> You need to build your writer (a plugin) into a shared object that can be
> loaded by the plugin manager.  It needs to be called libpdal_plugin_writer_PdalVectorMapWriter.<your
> shared library extension>.  The shared library needs to be located
> somewhere that the plugin manager can find it.  By default, PDAL will look
> in the following directories for plugins:
>
> ".", "./lib", "../lib", "./bin", "../bin"
>
> If you're using cmake, you can use the PDAL build to generate the shared
> library for you.  Here's an example plugin:
>
> https://github.com/gadomski/cpd.git
>
> Note that you don't have to do ANY of this if you're not using the
> pipeline/plugin manager to run your writer from a JSON pipeline.  If you're
> executing code programmatically, you can simply add your writer to the end
> of a pipeline and call prepare() and execute() on the pipeline that you've
> created in code.
>
>
> On Tue, Jul 11, 2017 at 10:59 AM, Paul Schrum <paul.schrum at gmail.com>
> wrote:
>
>> Thank you Andrew.
>>
>> In the cpp file containing the class, I have the following lines:
>>
>>   static PluginInfo const s_info = PluginInfo(
>>     "writers.PdalVectorMapWriter",
>>     "Custom Writer to write a GRASS Vector Map",
>>     "http://no/documentation/yet" );
>>
>>   CREATE_SHARED_PLUGIN(1, 0, PdalVectorMapWriter, Writer, s_info);
>>
>> So would the only other thing I need to do be to tell pdal where to find
>> the class?  I don't have to instantiate the class and pass it the instance?
>>
>> The class lives in my GRASS executable, v.in.pdal.  How do I tell pdal to
>> append PDAL_DRIVER_PATH with v.in.pdal's path, and is that sufficient?
>>
>> I see in https://github.com/PDAL/PDAL/tree/master/plugins that these are
>> built using CMake.  But GRASS uses make, so I don't know how to make these
>> work together.  Is it not possible for me simply to pass an instance of my
>> class to some kind of pdal->registerPlugIn() function or something similar
>> which happens at runtime?
>>
>> - Paul
>>
>>
>> On Mon, Jul 10, 2017 at 7:56 PM, Andrew Bell <andrew.bell.ia at gmail.com>
>> wrote:
>>
>>> You need to build your writer as a shared plugin and make sure that the
>>> dll/so that you create is in a folder where the plugin manager will look
>>> for it (or set PDAL_DRIVER_PATH).  Take a look at one of the existing
>>> plugins in the "plutgins" subdirectory of pdal.  Let me know if you need
>>> more help.
>>>
>>> On Mon, Jul 10, 2017 at 5:11 PM, Paul Schrum <paul.schrum at gmail.com>
>>> wrote:
>>>
>>>> I am developing a custom PDAL writer for my GSoC project. (Link
>>>> <https://trac.osgeo.org/grass/wiki/GSoC/2017/IntegrationOfPDALintoGRASSGIS>)
>>>> Source Code is on github <https://github.com/PaulSchrum/v_in_pdal>.
>>>> The module compiles, but it is an intermediate state since I am in the
>>>> process of developing it.
>>>>
>>>> I have the custom writer, PdalVectorMapWriter,  inheriting from writer
>>>> and it compiles okay.  Currently all functions just print out their own
>>>> name and return.
>>>>
>>>> In main.cpp I create the pipeline json string and create a
>>>> PipelineExecutor with it.  I then call pipeline-> validate.  This throws an
>>>> exception stating
>>>>
>>>> terminate called after throwing an instance of 'pdal::pdal_error'
>>>>   what():  Couldn't create writer stage of type
>>>> 'writers.PdalVectorMapWriter'.
>>>>
>>>> So I am thinking that I need somehow to inform Pdal about an instance
>>>> of the class.  But as I go over the Pdal documentation, I do not see how to
>>>> do that.  Can someone help me understand what I need to do?
>>>>
>>>> - Paul
>>>>
>>>> Here is a key code snippet:
>>>> 81    std::string pipeline_json =
>>>> 82            pipelineJson::basicVectorMapReaderWriter(inFile,outFile);
>>>> 83
>>>> 84    cout << pipeline_json << endl;  //diagnostic only
>>>> 85    cout << endl;
>>>> 86    G_important_message(_("Running the pipeline ..."));
>>>> 87    auto pipeline = new pdal::PipelineExecutor(pipeline_json);
>>>> 88
>>>> 87    cout << "is valid?  " << pipeline->validate() << endl;
>>>>
>>>> Line 87 throws the exception.
>>>>
>>>>
>>>> Here is the json string being passed to the PipelineExecutor
>>>> constructor:
>>>>
>>>> { "pipeline":[
>>>>    "/home/user/Desktop/ALL/SourceModules/cpp/grass7_trunk/vecto
>>>> r/v.in.pdal/testFiles/100-points.las",
>>>> {
>>>>    "type":"writers.PdalVectorMapWriter",
>>>>    "filename":"100-points"
>>>> }
>>>>  ]
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> pdal mailing list
>>>> pdal at lists.osgeo.org
>>>> https://lists.osgeo.org/mailman/listinfo/pdal
>>>>
>>>
>>>
>>>
>>> --
>>> Andrew Bell
>>> andrew.bell.ia at gmail.com
>>>
>>
>>
>
>
> --
> Andrew Bell
> andrew.bell.ia at gmail.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20170711/319fad35/attachment-0001.html>


More information about the pdal mailing list