Skip to content

Commit

Permalink
Merge branch 'master' of github.com:/PDAL/PDAL
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgerlek committed Feb 7, 2012
2 parents eb321a9 + 6432b76 commit 1adc434
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 145 deletions.
18 changes: 14 additions & 4 deletions apps/pcinfo.cpp
Expand Up @@ -71,8 +71,10 @@ class PcInfo : public Application
bool m_showStats;
bool m_showSchema;
bool m_showStage;
pdal::Options m_options;
boost::uint64_t m_pointNumber;
std::ostream* m_outputStream;
boost::uint32_t m_seed;
};


Expand Down Expand Up @@ -115,14 +117,15 @@ void PcInfo::addSwitches()
addSwitchSet(file_options);

po::options_description* processing_options = new po::options_description("processing options");

processing_options->add_options()
("point,p", po::value<boost::uint64_t>(&m_pointNumber)->implicit_value(0), "point to dump")
("stats,a", po::value<bool>(&m_showStats)->zero_tokens()->implicit_value(true), "dump stats on all points (reads entire dataset)")
("schema,s", po::value<bool>(&m_showSchema)->zero_tokens()->implicit_value(true), "dump the schema")
("stage,r", po::value<bool>(&m_showStage)->zero_tokens()->implicit_value(true), "dump the stage info")
("seed", po::value<boost::uint32_t>(&m_seed)->default_value(0), "Seed value for random sample")
;

addSwitchSet(processing_options);

addPositionalSwitch("input", 1);
Expand Down Expand Up @@ -229,8 +232,15 @@ int PcInfo::execute()
}

Stage* reader = AppSupport::makeReader(readerOptions);

pdal::filters::Stats* filter = new pdal::filters::Stats(*reader);

if (m_seed != 0)
{
Option seed_option("seed", m_seed, "seed value");
m_options.add(seed_option);
}
pdal::Options options = m_options + readerOptions;

pdal::filters::Stats* filter = new pdal::filters::Stats(*reader, options);

filter->initialize();

Expand Down
21 changes: 21 additions & 0 deletions include/pdal/Options.hpp
Expand Up @@ -273,6 +273,27 @@ class PDAL_DLL Options
return *this;
}

// assignment operator
Options& operator+=(const Options& rhs)
{

if (&rhs != this)
{
map_t::const_iterator i;
for (i = rhs.m_options.begin(); i != rhs.m_options.end(); ++i)
{
m_options.insert(std::pair<std::string, Option>(i->first, i->second));
}

}
return *this;
}

Options const operator+(const Options& rhs)
{
return Options(*this) += rhs;
}

bool equals(const Options& rhs) const
{
if (m_options== rhs.m_options)
Expand Down
16 changes: 12 additions & 4 deletions include/pdal/filters/Stats.hpp
Expand Up @@ -52,7 +52,7 @@
#include <boost/accumulators/statistics/count.hpp>
#include <boost/accumulators/statistics/density.hpp>

#include <boost/random/random_device.hpp>
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/uniform_int_distribution.hpp>

namespace pdal { namespace filters {
Expand Down Expand Up @@ -85,19 +85,25 @@ class PDAL_DLL Summary
density_accumulator m_histogram;
std::vector<double> m_sample;
boost::uint32_t m_sample_size;
boost::random::random_device m_rng;
boost::random::mt19937 m_rng;
boost::random::uniform_int_distribution<> m_distribution;
public:

Summary( boost::uint32_t num_bins=20,
boost::uint32_t sample_size=1000,
boost::uint32_t cache_size=1000)
boost::uint32_t cache_size=1000,
boost::uint32_t seed=0)
: m_histogram( boost::accumulators::tag::density::num_bins = num_bins,
boost::accumulators::tag::density::cache_size = cache_size)
, m_sample_size(sample_size)
, m_distribution(0, cache_size)
{

if (seed != 0)
{
m_rng.seed(seed);
m_distribution.reset();
}

return;
}

Expand Down Expand Up @@ -199,6 +205,8 @@ class PDAL_DLL Stats : public pdal::FilterSequentialIterator
bool atEndImpl() const;

const pdal::filters::Stats& m_statsFilter;

std::vector<DimensionPtr> m_dimensions;

double getValue(PointBuffer& data, Dimension& dim, boost::uint32_t pointIndex);

Expand Down
69 changes: 41 additions & 28 deletions src/filters/Stats.cpp
Expand Up @@ -116,10 +116,12 @@ const Options Stats::getDefaultOptions() const
Option sample_size("sample_size", 1000, "Number of points to return for uniform random 'sample'");
Option num_bins("num_bins", 20, "Number of bins to use for histogram");
Option stats_cache_size("stats_cache_size", 1000, "Number of points to use for histogram bin determination. Defaults to total number of points read if no option is specified.");
Option seed("seed", 0, "Seed to use for repeatable random sample. A seed value of 0 means no seed is used");

options.add(sample_size);
options.add(num_bins);
options.add(stats_cache_size);
options.add(seed);
return options;
}

Expand Down Expand Up @@ -281,44 +283,50 @@ bool Stats::atEndImpl() const
void Stats::readBufferBeginImpl(PointBuffer& buffer)
{
// We'll assume you're not changing the schema per-read call
Schema const& schema = buffer.getSchema();

if (m_stats.size() == 0)
{
Schema const& schema = buffer.getSchema();

boost::uint64_t numPoints = getStage().getPrevStage().getNumPoints();
boost::uint32_t stats_cache_size(1000);
boost::uint64_t numPoints = getStage().getPrevStage().getNumPoints();
boost::uint32_t stats_cache_size(1000);


try
{
stats_cache_size = getStage().getOptions().getValueOrThrow<boost::uint32_t>("stats_cache_size");
getStage().log()->get(logDEBUG2) << "Using " << stats_cache_size << "for histogram cache size set from option" << std::endl;
try
{
stats_cache_size = getStage().getOptions().getValueOrThrow<boost::uint32_t>("stats_cache_size");
getStage().log()->get(logDEBUG2) << "Using " << stats_cache_size << "for histogram cache size set from option" << std::endl;

}
catch (pdal::option_not_found const&)
{
if (numPoints != 0)
{
stats_cache_size = numPoints;
getStage().log()->get(logDEBUG2) << "Using point count, " << numPoints << ", for histogram cache size" << std::endl;
}
catch (pdal::option_not_found const&)
{
if (numPoints != 0)
{
stats_cache_size = numPoints;
getStage().log()->get(logDEBUG2) << "Using point count, " << numPoints << ", for histogram cache size" << std::endl;

}
}
}
}


boost::uint32_t sample_size = getStage().getOptions().getValueOrDefault<boost::uint32_t>("sample_size", 1000);
boost::uint32_t sample_size = getStage().getOptions().getValueOrDefault<boost::uint32_t>("sample_size", 1000);
boost::uint32_t seed = getStage().getOptions().getValueOrDefault<boost::uint32_t>("seed", 0);

getStage().log()->get(logDEBUG2) << "Using " << sample_size << "for sample size" << std::endl;
getStage().log()->get(logDEBUG2) << "Using " << sample_size << " for sample size" << std::endl;
getStage().log()->get(logDEBUG2) << "Using " << seed << " for sample seed" << std::endl;


boost::uint32_t bin_count = getStage().getOptions().getValueOrDefault<boost::uint32_t>("num_bins", 20);
if (m_stats.size() == 0)
{
schema::index_by_index const& dims = schema.getDimensions().get<schema::index>();
boost::uint32_t bin_count = getStage().getOptions().getValueOrDefault<boost::uint32_t>("num_bins", 20);

schema::index_by_index const& dims = schema.getDimensions().get<schema::index>();
for (schema::index_by_index::const_iterator iter = dims.begin(); iter != dims.end(); ++iter)
{
DimensionPtr d = boost::shared_ptr<Dimension>(new Dimension( *iter));
getStage().log()->get(logDEBUG2) << "Cumulating stats for dimension " << d->getName() << std::endl;
stats::SummaryPtr c = boost::shared_ptr<stats::Summary>(new stats::Summary(bin_count, sample_size, stats_cache_size));

std::pair<DimensionPtr, stats::SummaryPtr> p(d,c);
m_dimensions.push_back(d);
m_stats.insert(p);
}

Expand All @@ -330,15 +338,20 @@ boost::property_tree::ptree Stats::toPTree() const
{
boost::property_tree::ptree tree;

std::multimap<DimensionPtr, stats::SummaryPtr>::const_iterator p;
std::vector<DimensionPtr>::const_iterator p;
boost::uint32_t position(0);
for (p = m_stats.begin(); p != m_stats.end(); ++p)
for (p = m_dimensions.begin(); p != m_dimensions.end(); ++p)
{

const stats::SummaryPtr stat = p->second;
std::multimap<DimensionPtr, stats::SummaryPtr>::const_iterator i;
DimensionPtr d = *p;
i = m_stats.find(d);
if (i == m_stats.end())
throw pdal_error("unable to find dimension in summary!");
const stats::SummaryPtr stat = i->second;

boost::property_tree::ptree subtree = stat->toPTree();
subtree.add("position", position);
tree.add_child(p->first->getName(), subtree);
tree.add_child(d->getName(), subtree);
position++;
}

Expand Down
11 changes: 9 additions & 2 deletions test/BuildSetup.jenkins
Expand Up @@ -4,7 +4,13 @@ SET(WITH_TESTS ON CACHE TYPE "")
SET(WITH_PKGCONFIG OFF CACHE TYPE "")
SET(WITH_CTEST OFF CACHE TYPE "")
SET(WITH_GDAL ON CACHE TYPE "")
SET(GDAL_CONFIG "/var/lib/jenkins/local/bin/gdal-config" CACHE TYPE "")
SET(GDAL_INCLUDE_DIR "/var/lib/jenkins/local/include" CACHE TYPE "")
SET(GDAL_LIBRARY "/var/lib/jenkins/local/lib/libgdal.so" CACHE TYPE "")
SET(GDAL_VERSION_STRING "1.9.0" CACHE TYPE "")
SET(WITH_GEOTIFF ON CACHE TYPE "")
SET(GEOTIFF_INCLUDE_DIR "/var/lib/jenkins/local/include" CACHE TYPE "")
SET(GEOTIFF_LIBRARY "/var/lib/jenkins/local/lib/libgeotiff.so" CACHE TYPE "")
SET(WITH_SWIG_CSHARP OFF CACHE TYPE "")
SET(WITH_SWIG_PYTHON OFF CACHE TYPE "")
SET(WITH_ICONV ON CACHE TYPE "")
Expand All @@ -13,7 +19,8 @@ SET(WITH_ORACLE ON CACHE TYPE "")
SET(WITH_LASZIP ON CACHE TYPE "")
SET(LASZIP_INCLUDE_DIR "/var/lib/jenkins/local/include" CACHE TYPE "")
SET(LASZIP_LIBRARY "/var/lib/jenkins/local/lib/liblaszip.so" CACHE TYPE "")
SET(BOOST_ROOT "/var/lib/jenkins/local/include" CACHE TYPE "")
SET(Boost_INCLUDE_DIR "/var/lib/jenkins/local/include" CACHE TYPE "")
SET(Boost_LIBRARY_DIRS "/var/lib/jenkins/local/lib/liblaszip.so" CACHE TYPE "")
SET(Boost_ADDITIONAL_VERSIONS "1.48.0 1.48")
SET(Boost_LIBRARY_DIRS "/var/lib/jenkins/local/lib/" CACHE TYPE "")
SET(Boost_ADDITIONAL_VERSIONS "1.48.0" "1.48")
SET(WITH_MRSID OFF CACHE TYPE "")

0 comments on commit 1adc434

Please sign in to comment.