<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> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I think you’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’t have one of those, but it would be very easy to write…. except that our Writer imposes a “pull-from-the-data-source” 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 (“Get me another buffer!”) from our writer… 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> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>We didn’t put the makeReader/Writer functions into the PDAL library itself because at the time we didn’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> </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> </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> </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"'> pdal::Options readerOptions;<br> {<br> readerOptions.add<std::string>("filename", in_filename);<br> }<br> 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> pdal::PointBuffer in_buffer(schema, reader->getNumPoints());<br> pdal::StageSequentialIterator *iter = reader->createSequentialIterator(in_buffer);<br> boost::uint32_t num_read = iter->read(in_buffer);<br><br> for (boost::uint32_t point_idx = 0; point_idx < num_read; ++point_idx)<br> {<br> x[point_idx] = in_buffer.getField<float>(data.getSchema().getDimension("X"), point_idx);<br> }<br><br></span><span style='font-family:"Arial","sans-serif"'>Here I'd like to do "stuff." 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> pdal::PointBuffer out_buffer(reader->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> for (boost::int32_t point_idx = 0; point_idx < num_points_kept; ++point_idx)<br> {<br> out_buffer.setField<float>(out_buffer.getSchema().getDimension("X"), point_idx, x[point_idx]);<br> }<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> pdal::Options writerOptions;<br> {<br> writerOptions.add<std::string>("filename", out_filename);<br> }<br> pdal::Writer *writer = AppSupport::makeWriter(writerOptions, *reader);<br> writer->initialize();<br> writer->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>