1
/******************************************************************************
4
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
5
* Purpose: LAS reader class
6
* Author: Mateusz Loskot, mateusz@loskot.net
8
******************************************************************************
9
* Copyright (c) 2008, Mateusz Loskot
10
* Copyright (c) 2008, Phil Vachon
12
* All rights reserved.
14
* Redistribution and use in source and binary forms, with or without
15
* modification, are permitted provided that the following
18
* * Redistributions of source code must retain the above copyright
19
* notice, this list of conditions and the following disclaimer.
20
* * Redistributions in binary form must reproduce the above copyright
21
* notice, this list of conditions and the following disclaimer in
22
* the documentation and/or other materials provided
23
* with the distribution.
24
* * Neither the name of the Martin Isenburg or Iowa Department
25
* of Natural Resources nor the names of its contributors may be
26
* used to endorse or promote products derived from this software
27
* without specific prior written permission.
29
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
36
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
37
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
39
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
41
****************************************************************************/
43
#include <liblas/version.hpp>
44
#include <liblas/reader.hpp>
45
#include <liblas/detail/reader/reader.hpp>
46
#include <liblas/detail/reader/cachedreader.hpp>
47
#include <liblas/utility.hpp>
50
#include <boost/cstdint.hpp>
56
#include <cstring> // std::memset
60
using namespace boost;
65
Reader::Reader(std::istream& ifs) :
66
m_pimpl(new detail::ReaderImpl(ifs))
72
Reader::Reader(ReaderIPtr reader) :
78
Reader::Reader(Reader const& other)
79
: m_pimpl(other.m_pimpl)
83
Reader& Reader::operator=(Reader const& rhs)
87
m_pimpl = rhs.m_pimpl;
97
Header const& Reader::GetHeader() const
99
return m_pimpl->GetHeader();
102
void Reader::SetHeader(Header const& header)
104
m_pimpl->SetHeader(header);
107
Point const& Reader::GetPoint() const
109
return m_pimpl->GetPoint();
112
bool Reader::ReadNextPoint()
116
m_pimpl->ReadNextPoint();
119
catch (std::out_of_range const&)
126
bool Reader::ReadPointAt(std::size_t n)
128
if (m_pimpl->GetHeader().GetPointRecordsCount() <= n)
130
throw std::out_of_range("point subscript out of range");
135
m_pimpl->ReadPointAt(n);
138
catch (std::out_of_range const&)
144
bool Reader::Seek(std::size_t n)
148
assert(n < m_pimpl->GetHeader().GetPointRecordsCount());
153
catch (std::out_of_range const&)
159
Point const& Reader::operator[](std::size_t n)
161
if (m_pimpl->GetHeader().GetPointRecordsCount() <= n)
163
throw std::out_of_range("point subscript out of range");
166
bool read = ReadPointAt(n);
170
throw std::out_of_range("no point record at given position");
173
return m_pimpl->GetPoint();
178
m_pimpl->ReadHeader();
186
void Reader::SetFilters(std::vector<liblas::FilterPtr> const& filters)
188
m_pimpl->SetFilters(filters);
191
std::vector<liblas::FilterPtr> Reader::GetFilters() const
193
return m_pimpl->GetFilters();
196
void Reader::SetTransforms(std::vector<liblas::TransformPtr> const& transforms)
198
m_pimpl->SetTransforms(transforms);
201
std::vector<liblas::TransformPtr> Reader::GetTransforms() const
203
return m_pimpl->GetTransforms();
206
} // namespace liblas