[Liblas-commits] hg-main-tree: fix problem with writing zero points
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Jul 26 18:46:51 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/7f4fc73b65d2
changeset: 946:7f4fc73b65d2
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Jul 26 15:45:34 2011 -0700
description:
fix problem with writing zero points
Subject: hg-main-tree: don't need icky strings
details: http://hg.libpc.orghg-main-tree/rev/244e92c53a02
changeset: 947:244e92c53a02
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Jul 26 15:46:16 2011 -0700
description:
don't need icky strings
Subject: hg-main-tree: improve pipeline testing
details: http://hg.libpc.orghg-main-tree/rev/858fefc45f55
changeset: 948:858fefc45f55
user: Michael P. Gerlek <mpg at flaxen.com>
date: Tue Jul 26 15:46:44 2011 -0700
description:
improve pipeline testing
diffstat:
include/pdal/PipelineManager.hpp | 2 +-
include/pdal/Writer.hpp | 5 +++--
src/PipelineManager.cpp | 4 ++--
src/Writer.cpp | 17 +++--------------
src/filters/CropFilter.cpp | 4 +---
test/data/pipeline1.xml | 4 ++--
test/unit/PipelineManagerTest.cpp | 10 ++++++++--
test/unit/StageFactoryTest.cpp | 37 ++++++++++++++++++++-----------------
8 files changed, 40 insertions(+), 43 deletions(-)
diffs (206 lines):
diff -r a768f37245fd -r 858fefc45f55 include/pdal/PipelineManager.hpp
--- a/include/pdal/PipelineManager.hpp Tue Jul 26 15:14:02 2011 -0700
+++ b/include/pdal/PipelineManager.hpp Tue Jul 26 15:46:44 2011 -0700
@@ -62,7 +62,7 @@
MultiFilter* addMultiFilter(const std::string& type, const std::vector<const Stage*>& prevStages, const Options&);
Writer* addWriter(const std::string& type, const Stage& prevStage, const Options&);
- void readXml(const std::string&);
+ Writer* readWriterPipeline(const std::string&);
private:
void parsePipeline(const boost::property_tree::ptree&, Writer*& writer, Stage*& stage);
diff -r a768f37245fd -r 858fefc45f55 include/pdal/Writer.hpp
--- a/include/pdal/Writer.hpp Tue Jul 26 15:14:02 2011 -0700
+++ b/include/pdal/Writer.hpp Tue Jul 26 15:46:44 2011 -0700
@@ -57,10 +57,11 @@
void setChunkSize(boost::uint32_t);
boost::uint32_t getChunkSize() const;
- // Read the given number of points (or less, if the reader runs out first),
+ // Read the given number of points (or less, if the reader runs out first),
// and then write them out to wherever. Returns total number of points
// actually written.
- boost::uint64_t write(boost::uint64_t targetNumPointsToWrite);
+ // If given number of points is 0, do as many points as the reader supplies to us.
+ boost::uint64_t write(boost::uint64_t targetNumPointsToWrite=0);
protected:
// this is called once before the loop with the writeBuffer calls
diff -r a768f37245fd -r 858fefc45f55 src/PipelineManager.cpp
--- a/src/PipelineManager.cpp Tue Jul 26 15:14:02 2011 -0700
+++ b/src/PipelineManager.cpp Tue Jul 26 15:46:44 2011 -0700
@@ -367,7 +367,7 @@
}
-void PipelineManager::readXml(const std::string& filename)
+Writer* PipelineManager::readWriterPipeline(const std::string& filename)
{
boost::property_tree::ptree tree;
boost::property_tree::xml_parser::read_xml(filename, tree);
@@ -378,7 +378,7 @@
Stage* stage = NULL;
parsePipeline(pipeline, writer, stage);
- return;
+ return writer;
}
diff -r a768f37245fd -r 858fefc45f55 src/Writer.cpp
--- a/src/Writer.cpp Tue Jul 26 15:14:02 2011 -0700
+++ b/src/Writer.cpp Tue Jul 26 15:46:44 2011 -0700
@@ -81,20 +81,7 @@
{
m_targetNumPointsToWrite = targetNumPointsToWrite;
m_actualNumPointsWritten = 0;
-
- PointCountType count_type = m_prevStage.getPointCountType();
-
- // passing in a 0 for the number of points means "write to the end"
- // but we need to have an end to actually do that. This code isn't
- // currently sufficient to go on writing forever.
- if (targetNumPointsToWrite == 0)
- {
- if (count_type == PointCount_Unknown)
- {
- throw pdal_error("Unable to write points with an unknowable point count");
- }
- }
-
+
boost::scoped_ptr<StageSequentialIterator> iter(m_prevStage.createSequentialIterator());
if (!iter) throw pdal_error("Unable to obtain iterator from previous stage!");
@@ -112,6 +99,8 @@
{
numPointsWrittenThisChunk = writeBuffer(buffer);
m_actualNumPointsWritten += numPointsWrittenThisChunk;
+
+ buffer.setNumPoints(0); // reset the buffer, so we can use it again
numPointsReadThisChunk = iter->read(buffer);
}
} else
diff -r a768f37245fd -r 858fefc45f55 src/filters/CropFilter.cpp
--- a/src/filters/CropFilter.cpp Tue Jul 26 15:14:02 2011 -0700
+++ b/src/filters/CropFilter.cpp Tue Jul 26 15:46:44 2011 -0700
@@ -47,10 +47,8 @@
CropFilter::CropFilter(const Stage& prevStage, const Options& options)
: pdal::Filter(prevStage, options)
+ , m_bounds(options.getOption<Bounds<double> >("bounds").getValue())
{
- std::stringstream bounds_str ( options.getOption<std::string>("bounds").getValue() );
- bounds_str >> m_bounds;
-
initialize();
return;
diff -r a768f37245fd -r 858fefc45f55 test/data/pipeline1.xml
--- a/test/data/pipeline1.xml Tue Jul 26 15:14:02 2011 -0700
+++ b/test/data/pipeline1.xml Tue Jul 26 15:46:44 2011 -0700
@@ -11,14 +11,14 @@
<Type>filters.crop</Type>
<Option>
<Name>bounds</Name>
- <Value>([0,1],[0,1],[0,1])</Value>
+ <Value>([0,1000000],[0,1000000],[0,1000000])</Value>
</Option>
<Reader>
<Type>drivers.las.reader</Type>
<Option>
<Name>filename</Name>
<Value>../../test/data/1.2-with-color.las</Value>
- </option>
+ </Option>
</Reader>
</Filter>
</Writer>
diff -r a768f37245fd -r 858fefc45f55 test/unit/PipelineManagerTest.cpp
--- a/test/unit/PipelineManagerTest.cpp Tue Jul 26 15:14:02 2011 -0700
+++ b/test/unit/PipelineManagerTest.cpp Tue Jul 26 15:46:44 2011 -0700
@@ -57,13 +57,16 @@
Reader* reader = mgr.addReader("drivers.las.reader", optsR);
Options optsF;
- optsF.add("bounds", Bounds<double>(0,0,0,1,1,1), "crop bounds");
+ optsF.add("bounds", Bounds<double>(0,0,0,1000000,1000000,1000000), "crop bounds");
Filter* filter = mgr.addFilter("filters.crop", *reader, optsF);
Options optsW;
optsW.add("filename", "temp.las", "file to write to");
Writer* writer = mgr.addWriter("drivers.las.writer", *filter, optsW);
+ const boost::uint64_t np = writer->write( reader->getNumPoints() );
+ BOOST_CHECK(np == 1065);
+
return;
}
@@ -72,7 +75,10 @@
{
PipelineManager mgr;
- mgr.readXml(Support::datapath("pipeline1.xml"));
+ Writer* writer = mgr.readWriterPipeline(Support::datapath("pipeline1.xml"));
+
+ const boost::uint64_t np = writer->write();
+ BOOST_CHECK(np == 1065);
return;
}
diff -r a768f37245fd -r 858fefc45f55 test/unit/StageFactoryTest.cpp
--- a/test/unit/StageFactoryTest.cpp Tue Jul 26 15:14:02 2011 -0700
+++ b/test/unit/StageFactoryTest.cpp Tue Jul 26 15:46:44 2011 -0700
@@ -56,30 +56,33 @@
StageFactory factory;
Options optsR;
- optsR.add("filename", Support::datapath("1.2-with-color.las"), "file to read from");
- Reader* ptrR = factory.createReader("drivers.las.reader", optsR);
- BOOST_CHECK(ptrR->getName() == "drivers.las.reader");
+ optsR.add("filename", Support::datapath("1.2-with-color.las"));
+ Reader* reader = factory.createReader("drivers.las.reader", optsR);
+ BOOST_CHECK(reader->getName() == "drivers.las.reader");
Options optsF;
- optsF.add("bounds", Bounds<double>(0,0,0,1,1,1), "crop bounds");
- Filter* ptrF = factory.createFilter("filters.crop", *ptrR, optsF);
- BOOST_CHECK(ptrF->getName() == "filters.crop");
+ optsF.add("bounds", Bounds<double>(0,0,0,1000000,1000000,1000000));
+ Filter* filter = factory.createFilter("filters.crop", *reader, optsF);
+ BOOST_CHECK(filter->getName() == "filters.crop");
- Options optsM;
- std::vector<const Stage*> stages;
- stages.push_back(ptrR);
- MultiFilter* ptrM = factory.createMultiFilter("filters.mosaic", stages, optsM);
- BOOST_CHECK(ptrM->getName() == "filters.mosaic");
+ //Options optsM;
+ //std::vector<const Stage*> stages;
+ //stages.push_back(filter);
+ //MultiFilter* multifilter = factory.createMultiFilter("filters.mosaic", stages, optsM);
+ //BOOST_CHECK(multifilter->getName() == "filters.mosaic");
Options optsW;
optsW.add("filename", "temp.las", "file to write to");
- Writer* ptrW = factory.createWriter("drivers.las.writer", *ptrF, optsW);
- BOOST_CHECK(ptrW->getName() == "drivers.las.writer");
+ Writer* writer = factory.createWriter("drivers.las.writer", *filter, optsW);
+ BOOST_CHECK(writer->getName() == "drivers.las.writer");
- delete ptrW;
- delete ptrM;
- delete ptrF;
- delete ptrR;
+ const boost::uint64_t np = writer->write( reader->getNumPoints() );
+ BOOST_CHECK(np == 1065);
+
+ delete writer;
+ //delete multifilter;
+ delete filter;
+ delete reader;
return;
}
More information about the Liblas-commits
mailing list