<div dir="ltr"><div><div>Thank you so much Andrew for your help.<br><br></div>In discussion with my mentor (Vashek), we decided to try to read the Point View after executing a pipeline with no Writer stage.  This succeeds, so we are proceeding with this direction.  However, your code is still very valuable in that it helps me understand how things work behind the scenes a little better.<br><br></div>- Paul<br><br><div><div><br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 3:17 PM, Andrew Bell <span dir="ltr"><<a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This might be helpful:<div><br></div><div><a href="https://www.pdal.io/development/overview.html" target="_blank">https://www.pdal.io/<wbr>development/overview.html</a><br></div><div><br></div><div>More concise are the tests.  Here is an example from the LAS writer:</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">TEST(LasWriterTest, srs)<br>{<br>    Options readerOps;<br>    readerOps.add("filename", Support::datapath("las/utm15.<wbr>las"));<br>    LasReader reader;<br>    reader.setOptions(readerOps);<br>    Options writerOps;<br>    writerOps.add("filename", Support::temppath("out.las"));<br>    LasWriter writer;<br>    writer.setInput(reader);<br>    writer.setOptions(writerOps);<br>    PointTable table;<br>    writer.prepare(table);<br>    writer.execute(table);<br>    LasTester tester;<br>    SpatialReference srs = tester.srs(writer);<br>    EXPECT_EQ(srs, SpatialReference("EPSG:26915")<wbr>);<br>}</blockquote></div><div><br></div><div>This code reads data from the input file "utm15.las" and writes it to "out.las".  Since you've written a writer, PdalVectorMapWriter, your similar code might look like:</div><div><br></div><div>int main()</div><div>{</div><div><br></div><div>    Options readerOps;<br>    readerOps.add("filename", Support::datapath("las/utm15.<wbr>las"));<br>    LasReader reader;<br>    reader.setOptions(readerOps);<br><br></div><div>    Options writerOps;<br>    writerOps.add("filename", Support::temppath("out.las"));<br>    PdalVectorMapWriter writer;</div><div>    writer.setInput(reader);  // This essentially creates a pipeline from reader -> writer.<br>    writer.setOptions(writerOps);<br><br></div><div>    PointTable table;<br>    writer.prepare(table);<br>    writer.execute(table);  // Executing the terminal stage runs the pipeline.<br></div><div><br></div><div>    return 0;</div><div>}</div><div><br></div><div>When you compile, link and run this program, points will be read from utm15.las and made available to your writer, calling either the run() or write() function that you've implemented.</div><div><br></div><div>There are lots of more complicated things you can do, but this is about the most simple example.</div><div><br></div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 2:37 PM, Paul Schrum <span dir="ltr"><<a href="mailto:paul.schrum@gmail.com" target="_blank">paul.schrum@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Andrew,<br><br></div><div>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?<br><br></div><div>We looked at PipelineManager and see<br><span style="color:rgb(36,41,46);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:pre-wrap;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">PointTableRef </span><span class="m_-1803346375346969497m_6881102850458370969gmail-pl-en" style="box-sizing:border-box;color:rgb(111,66,193);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:pre-wrap;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">pointTable</span><span style="color:rgb(36,41,46);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:pre-wrap;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;display:inline;float:none">() </span><span class="m_-1803346375346969497m_6881102850458370969gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73);font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:pre-wrap;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">const</span><br><br></div><div>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<span class="m_-1803346375346969497HOEnZb"><font color="#888888"><br></font></span></div><span class="m_-1803346375346969497HOEnZb"><font color="#888888"><div><br></div>- Paul<br><br></font></span></div><div class="m_-1803346375346969497HOEnZb"><div class="m_-1803346375346969497h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 11:16 AM, Andrew Bell <span dir="ltr"><<a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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_PdalVect<wbr>orMapWriter.<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:<div><br></div><div>".", "./lib", "../lib", "./bin", "../bin"<br></div><div><br></div><div>If you're using cmake, you can use the PDAL build to generate the shared library for you.  Here's an example plugin:</div><div><br></div><div><a href="https://github.com/gadomski/cpd.git" target="_blank">https://github.com/gadomski/cp<wbr>d.git</a><br></div><div><br></div><div>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.</div><div> </div></div><div class="gmail_extra"><div><div class="m_-1803346375346969497m_6881102850458370969h5"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 10:59 AM, Paul Schrum <span dir="ltr"><<a href="mailto:paul.schrum@gmail.com" target="_blank">paul.schrum@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thank you Andrew.<br><br></div><div>In the cpp file containing the class, I have the following lines:<br><br><span style="font-family:monospace,monospace">  static PluginInfo const s_info = PluginInfo(<br>    "writers.PdalVectorMapWriter",<br>    "Custom Writer to write a GRASS Vector Map",<br>    "<a href="http://no/documentation/yet" target="_blank">http://no/documentation/yet</a>" );<br><br>  CREATE_SHARED_PLUGIN(1, 0, PdalVectorMapWriter, Writer, s_info);<br></span><br></div><div>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?<br><br></div><div>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?<br><br></div><div>I see in <a href="https://github.com/PDAL/PDAL/tree/master/plugins" target="_blank">https://github.com/PDAL/PDAL/t<wbr>ree/master/plugins</a> 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?<span class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461HOEnZb"><font color="#888888"><br></font></span></div><span class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461HOEnZb"><font color="#888888"><div><br></div>- Paul<br><br></font></span></div><div class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461HOEnZb"><div class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 10, 2017 at 7:56 PM, Andrew Bell <span dir="ltr"><<a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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.</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461m_-2429901598987662413h5">On Mon, Jul 10, 2017 at 5:11 PM, Paul Schrum <span dir="ltr"><<a href="mailto:paul.schrum@gmail.com" target="_blank">paul.schrum@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461m_-2429901598987662413h5"><div dir="ltr"><div><div><div><div><div><div>I am developing a custom PDAL writer for my GSoC project. (<a href="https://trac.osgeo.org/grass/wiki/GSoC/2017/IntegrationOfPDALintoGRASSGIS" target="_blank">Link</a>)  Source Code is on <a href="https://github.com/PaulSchrum/v_in_pdal" target="_blank">github</a>.  The module compiles, but it is an intermediate state since I am in the process of developing it.<br><br></div>I have the custom writer, PdalVectorMapWriter,  inheriting from writer and it compiles okay.  Currently all functions just print out their own name and return.<br><br></div>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 <br><br><span style="font-family:monospace,monospace">terminate called after throwing an instance of 'pdal::pdal_error'<br>  what():  Couldn't create writer stage of type 'writers.PdalVectorMapWriter'.</span><br><br></div>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?<br><br></div>- Paul<br><br></div>Here is a key code snippet:<br><span style="font-family:monospace,monospace">81    std::string pipeline_json =<br>82            pipelineJson::basicVectorMapRe<wbr>aderWriter(inFile,outFile);<br>83<br>84    cout << pipeline_json << endl;  //diagnostic only<br>85    cout << endl;<br>86    G_important_message(_("Running the pipeline ..."));<br>87    auto pipeline = new pdal::PipelineExecutor(pipelin<wbr>e_json);<br>88    <br>87    cout << "is valid?  " << pipeline->validate() << endl;<br></span><br></div><div>Line 87 throws the exception.<br></div><br><br>Here is the json string being passed to the PipelineExecutor constructor:<br><div><font size="2"><span style="font-family:monospace,monospace"><br>{ "pipeline":[<br><font size="1">   "/home/user/Desktop/ALL/Source<wbr>Modules/cpp/grass7_trunk/vecto<wbr>r/v.in.pdal/testFiles/100-poin<wbr>ts.las",<br></font>{<br>   "type":"writers.PdalVectorMapW<wbr>riter",<br>   "filename":"100-points"<br>}<br> ]<br>}</span></font><br><br><div><div><br><br></div></div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
pdal mailing list<br>
<a href="mailto:pdal@lists.osgeo.org" target="_blank">pdal@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/pdal" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/pdal</a><span class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461m_-2429901598987662413HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461m_-2429901598987662413HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461m_-2429901598987662413m_-1955143350056331847gmail_signature" data-smartmail="gmail_signature">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div>
</font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="m_-1803346375346969497m_6881102850458370969HOEnZb"><font color="#888888">-- <br><div class="m_-1803346375346969497m_6881102850458370969m_-1805110591558864461gmail_signature" data-smartmail="gmail_signature">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div>
</font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_-1803346375346969497gmail_signature" data-smartmail="gmail_signature">Andrew Bell<br><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div>
</font></span></div>
</blockquote></div><br></div>