Skip to content

Commit

Permalink
Remove iterator from las/nitf.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Sep 5, 2014
1 parent bf071fd commit 29c08b4
Show file tree
Hide file tree
Showing 19 changed files with 252 additions and 615 deletions.
88 changes: 18 additions & 70 deletions include/pdal/drivers/las/Reader.hpp
Expand Up @@ -40,8 +40,7 @@
#include <pdal/StreamFactory.hpp>
#include <pdal/drivers/las/Support.hpp>
#include <pdal/drivers/las/Header.hpp>

#include <boost/scoped_ptr.hpp>
#include <pdal/drivers/las/ZipPoint.hpp>

namespace pdal
{
Expand All @@ -67,96 +66,45 @@ class PDAL_DLL Reader : public pdal::Reader
SET_STAGE_LINK("http://pdal.io/stages/drivers.las.reader.html")
SET_STAGE_ENABLED(true)

Reader(const Options&);
Reader(const std::string&);
Reader(const Options& options) : pdal::Reader(options), m_index(0),
m_istream(NULL)
{}
virtual ~Reader();

static Options getDefaultOptions();
StreamFactory& getStreamFactory() const;

StageSequentialIterator* createSequentialIterator() const;

const LasHeader& getLasHeader() const
{ return m_lasHeader; }
point_count_t getNumPoints() const
{ return m_lasHeader.GetPointRecordsCount(); }

protected:
typedef std::unique_ptr<StreamFactory> StreamFactoryPtr;
LasHeader& getLasHeaderRef()
{
return m_lasHeader;
}

private:
typedef std::unique_ptr<StreamFactory> StreamFactoryPtr;
StreamFactoryPtr m_streamFactory;
LasHeader m_lasHeader;
std::string m_filename;
std::unique_ptr<ZipPoint> m_zipPoint;
std::unique_ptr<LASunzipper> m_unzipper;
point_count_t m_index;
std::istream* m_istream;

virtual StreamFactoryPtr createFactory() const
{ return StreamFactoryPtr(new FilenameStreamFactory(m_filename)); }
virtual void initialize();
virtual void initialize(MetadataNode& m);
virtual void addDimensions(PointContext ctx);
void extractMetadata(MetadataNode& m);
virtual void processOptions(const Options& options);
virtual StreamFactoryPtr createFactory() const
{ return StreamFactoryPtr(new FilenameStreamFactory(m_filename)); }
virtual void ready(PointContext ctx);
virtual point_count_t read(PointBuffer& buf, point_count_t count);
virtual void done(PointContext ctx);
virtual bool eof()
{ return m_index >= getNumPoints(); }
void loadPoint(PointBuffer& data, char *buf, size_t bufsize);

Reader& operator=(const Reader&); // not implemented
Reader(const Reader&); // not implemented
};


namespace iterators
{

class Base
{
public:
Base(pdal::drivers::las::Reader const& reader);
~Base();

protected:
point_count_t processBuffer(PointBuffer& PointBuffer,
std::istream& stream, point_count_t count, LASunzipper* unzipper,
ZipPoint* zipPoint);

Bounds<double> m_bounds;
const pdal::drivers::las::Reader& m_reader;
std::istream& m_istream;
#ifdef PDAL_HAVE_LASZIP
boost::scoped_ptr<ZipPoint> m_zipPoint;
boost::scoped_ptr<LASunzipper> m_unzipper;
#else
void* m_zipPoint;
void* m_unzipper;
#endif

private:
Base& operator=(Base const&);
Base(Base const&); // not implemented

void initialize();
void loadPoint(PointBuffer& data, char *buf, size_t bufsize);
};

namespace sequential
{

class Reader : public Base, public StageSequentialIterator
{
public:
Reader(const pdal::drivers::las::Reader& reader);

private:
boost::uint64_t skipImpl(boost::uint64_t);
point_count_t readBufferImpl(PointBuffer&);
point_count_t readImpl(PointBuffer&, point_count_t count);
bool atEndImpl() const
{ return getIndex() >= m_reader.getNumPoints(); }
};

} // sequential
} // iterators

} // namespace las
} // namespace drivers
} // namespace pdal
Expand Down
21 changes: 2 additions & 19 deletions include/pdal/drivers/las/Support.hpp
Expand Up @@ -32,35 +32,18 @@
* OF SUCH DAMAGE.
****************************************************************************/

#pragma once

#include <pdal/pdal_export.hpp>

#include <iostream>

#ifdef PDAL_HAVE_LASZIP
#include <laszip/laszip.hpp>
#include <laszip/lasunzipper.hpp>
#include <laszip/laszipper.hpp>
#include <pdal/pdal_internal.hpp>

#else
typedef struct LASzipH *LASzip;
typedef struct LASunzipperH *LASunzipper;
#endif
#pragma once

namespace pdal
{

class Stage;

namespace drivers
{
namespace las
{

class Reader;
class SummaryData;
class ZipPoint;

class PDAL_DLL Support
{
Expand Down
8 changes: 3 additions & 5 deletions include/pdal/drivers/las/Writer.hpp
Expand Up @@ -38,9 +38,9 @@
#include <pdal/drivers/las/Support.hpp>
#include <pdal/drivers/las/Header.hpp>
#include <pdal/drivers/las/SummaryData.hpp>
#include <pdal/drivers/las/ZipPoint.hpp>
#include <pdal/StreamFactory.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/scoped_ptr.hpp>

namespace pdal
{
Expand Down Expand Up @@ -107,11 +107,9 @@ class PDAL_DLL Writer : public pdal::Writer
LasHeader m_lasHeader;
boost::uint32_t m_numPointsWritten;
SummaryData m_summaryData;
std::unique_ptr<LASzipper> m_zipper;
std::unique_ptr<ZipPoint> m_zipPoint;

#ifdef PDAL_HAVE_LASZIP
boost::scoped_ptr<LASzipper> m_zipper;
boost::scoped_ptr<ZipPoint> m_zipPoint;
#endif
virtual void processOptions(const Options& options);
virtual void ready(PointContext ctx);
virtual void write(const PointBuffer& pointBuffer);
Expand Down
Expand Up @@ -32,20 +32,25 @@
* OF SUCH DAMAGE.
****************************************************************************/

#ifndef INCLUDED_DRIVERS_LAS_ZIPPOINT_HPP
#define INCLUDED_DRIVERS_LAS_ZIPPOINT_HPP
#pragma once

#ifdef PDAL_HAVE_LASZIP
#include <laszip/laszip.hpp>
#include <laszip/lasunzipper.hpp>
#include <laszip/laszipper.hpp>
#endif

#include <pdal/drivers/las/Header.hpp>

#include <boost/shared_ptr.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>

#include <vector>

namespace pdal { namespace drivers { namespace las {
namespace pdal {
namespace drivers {
namespace las {

#ifdef PDAL_HAVE_LASZIP
class VariableLengthRecord;

class ZipPoint
Expand All @@ -70,14 +75,19 @@ class ZipPoint
int his_vlr_num;
unsigned char* his_vlr_data;

boost::scoped_ptr<LASzip> m_zip;
std::unique_ptr<LASzip> m_zip;

unsigned char** m_lz_point;
boost::scoped_array<boost::uint8_t> m_lz_point_data;
unsigned int m_lz_point_size;
};
#else // PDAL_HAVE_LASZIP
typedef void LASzipper;
typedef void LASunzipper;
typedef void ZipPoint;
#endif

} } } // namespace
} // namespace las
} // namespace drivers
} // namespace pdal


#endif // LIBLAS_DETAIL_ZIPPOINT_HPP_INCLUDED
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -133,12 +133,12 @@ set (PDAL_DRIVERS_LAS_HPP
"${PDAL_LAS_SRC}/GeotiffSupport.hpp"
"${PDAL_LAS_SRC}/LasHeaderReader.hpp"
"${PDAL_LAS_SRC}/LasHeaderWriter.hpp"
"${PDAL_LAS_SRC}/ZipPoint.hpp"
"${PDAL_LAS_HEADERS}/Header.hpp"
"${PDAL_LAS_HEADERS}/Reader.hpp"
"${PDAL_LAS_HEADERS}/SummaryData.hpp"
"${PDAL_LAS_HEADERS}/Support.hpp"
"${PDAL_LAS_HEADERS}/Writer.hpp"
"${PDAL_LAS_HEADERS}/ZipPoint.hpp"
"${PDAL_LAS_HEADERS}/VariableLengthRecord.hpp"
)

Expand Down
18 changes: 3 additions & 15 deletions src/drivers/las/LasHeaderReader.cpp
@@ -1,11 +1,4 @@
/******************************************************************************
* $Id$
*
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
* Purpose: LAS header class
* Author: Mateusz Loskot, mateusz@loskot.net
*
******************************************************************************
* Copyright (c) 2008, Mateusz Loskot
* Copyright (c) 2008, Phil Vachon
*
Expand Down Expand Up @@ -47,7 +40,7 @@
#include <pdal/drivers/las/Reader.hpp>
#include <pdal/drivers/las/Header.hpp>
#include <pdal/drivers/las/VariableLengthRecord.hpp>
#include "ZipPoint.hpp"
#include <pdal/drivers/las/ZipPoint.hpp>

#include <boost/uuid/uuid_io.hpp>
#include <boost/scoped_array.hpp>
Expand All @@ -62,12 +55,8 @@ namespace las


LasHeaderReader::LasHeaderReader(LasHeader& header, std::istream& istream)
: m_header(header)
, m_istream(istream)
, m_numVLRs(0)
{
return;
}
: m_header(header), m_istream(istream), m_numVLRs(0)
{}


void LasHeaderReader::read(Reader& stage)
Expand Down Expand Up @@ -115,7 +104,6 @@ void LasHeaderReader::read(Reader& stage)
// 8. Version major
Utils::read_n(n1, m_istream, sizeof(n1));
m_header.SetVersionMajor(n1);

// 9. Version minor
Utils::read_n(n1, m_istream, sizeof(n1));
m_header.SetVersionMinor(n1);
Expand Down
12 changes: 1 addition & 11 deletions src/drivers/las/LasHeaderWriter.cpp
@@ -1,11 +1,4 @@
/******************************************************************************
* $Id$
*
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
* Purpose: LAS header class
* Author: Mateusz Loskot, mateusz@loskot.net
*
******************************************************************************
* Copyright (c) 2008, Mateusz Loskot
* Copyright (c) 2008, Phil Vachon
*
Expand Down Expand Up @@ -42,21 +35,18 @@

#include "LasHeaderWriter.hpp"

#include "ZipPoint.hpp"

#include <pdal/drivers/las/Header.hpp>
#include <pdal/drivers/las/ZipPoint.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <boost/scoped_ptr.hpp>


namespace pdal
{
namespace drivers
{
namespace las
{


LasHeaderWriter::LasHeaderWriter(LasHeader& header, std::ostream& ostream, boost::uint64_t firstPos)
: m_header(header)
, m_ostream(ostream)
Expand Down

0 comments on commit 29c08b4

Please sign in to comment.