<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Brad-<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I think you&#8217;re saying you want to make a Writer that gets its input from a special kind of Reader which gets its data directly from a PointBuffer instead of from a file or similar. We don&#8217;t have one of those, but it would be very easy to write&#8230;. except that our Writer imposes a &#8220;pull-from-the-data-source&#8221; style of operation, which means our writer is going to be the one in control, orchestrating how your app functions: your data supplier would be taking orders (&#8220;Get me another buffer!&#8221;) from our writer&#8230; &nbsp;which might not be what you want?<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>We didn&#8217;t put the makeReader/Writer functions into the PDAL library itself because at the time we didn&#8217;t have a generic driver system. We mostly have that now, though, so those functions could be folded into the StageFactory class and such I think.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>-mpg<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt'><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> pdal-bounces@lists.osgeo.org [mailto:pdal-bounces@lists.osgeo.org] <b>On Behalf Of </b>Bradley Chambers<br><b>Sent:</b> Friday, May 18, 2012 10:03 AM<br><b>To:</b> pdal@lists.osgeo.org<br><b>Subject:</b> [pdal] writing point cloud with no previous stage<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I'm looking at adding PDAL support to an existing application--one that is mature enough that I'm not sure I really want to embed PDAL throughout (e.g., converting my filtering methods to PDAL Filters), but I do want to use it for point cloud I/O.<br><br>My first step was to use PDAL to import data into the code's existing data structures, which works well enough. I'm able to get all the necessary information about each dimension, and to subsequently use getField to pull the data into memory. I then use existing code to filter the data and write it to disk. I'd like PDAL to take care of that last step, but I think I'm currently limited in my ability to use PDAL in this manner given that there is so much emphasis on stages and pipelines, neither of which I'm using. Is this by design?<br><br>Consider the following.<br><span style='font-family:"Courier New"'><br></span><span style='font-family:"Arial","sans-serif"'>First, I make the reader stage, inferring driver type from the filename.<br><br></span><span style='font-family:"Courier New"'>&nbsp; pdal::Options readerOptions;<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; readerOptions.add&lt;std::string&gt;(&quot;filename&quot;, in_filename);<br>&nbsp; }<br>&nbsp; pdal::Stage *reader = AppSupport::makeReader(readerOptions);<br><br></span><span style='font-family:"Arial","sans-serif"'>Next, I go ahead and read all of the data into a PointBuffer.</span><span style='font-family:"Courier New"'><br><br>&nbsp; pdal::PointBuffer in_buffer(schema, reader-&gt;getNumPoints());<br>&nbsp; pdal::StageSequentialIterator *iter = reader-&gt;createSequentialIterator(in_buffer);<br>&nbsp; boost::uint32_t num_read = iter-&gt;read(in_buffer);<br><br>&nbsp; for (boost::uint32_t point_idx = 0; point_idx &lt; num_read; ++point_idx)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; x[point_idx] = in_buffer.getField&lt;float&gt;(data.getSchema().getDimension(&quot;X&quot;), point_idx);<br>&nbsp; }<br><br></span><span style='font-family:"Arial","sans-serif"'>Here I'd like to do &quot;stuff.&quot; The operations do not necessarily retain the same number of points as the input. Points may also be scaled, smoothed, classified, etc.</span><span style='font-family:"Courier New"'><br><br></span><span style='font-family:"Arial","sans-serif"'>When I'm done filtering the data, I create a new buffer, using the existing schema, but limited to the number of points I've retained.</span><span style='font-family:"Courier New"'><br><br>&nbsp; pdal::PointBuffer out_buffer(reader-&gt;getSchema(), num_points_kept);<br><br></span><span style='font-family:"Arial","sans-serif"'>I then iterate over the points, setting the modified dimension to its new value.</span><span style='font-family:"Courier New"'><br><br>&nbsp; for (boost::int32_t point_idx = 0; point_idx &lt; num_points_kept; ++point_idx)<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; out_buffer.setField&lt;float&gt;(out_buffer.getSchema().getDimension(&quot;X&quot;), point_idx, x[point_idx]);<br>&nbsp; }<br><br></span><span style='font-family:"Arial","sans-serif"'>Here's the problem, I don't really want to create the writer using the reader as the previous stage (as shown below), but I also didn't want to go to the lengths of creating a filter to serve as the previous stage. Given the scenario, is there a way to write the modified cloud?</span><span style='font-family:"Courier New"'><br><br>&nbsp; pdal::Options writerOptions;<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; writerOptions.add&lt;std::string&gt;(&quot;filename&quot;, out_filename);<br>&nbsp; }<br>&nbsp; pdal::Writer *writer = AppSupport::makeWriter(writerOptions, *reader);<br>&nbsp; writer-&gt;initialize();<br>&nbsp; writer-&gt;write();</span><br><br>As an aside, note the use of makeReader and makeWriter. I like being able to infer the I/O drivers from the filename, as is done in the apps (e.g., pc2pc), hence the reuse here. Has there been any discussion about bringing these into the main library and exposing them?<br><br>Brad<o:p></o:p></p></div></div></body></html>