1 /******************************************************************************
2 * Copyright (c) 2014, Hobu Inc. (hobu@hobu.co)
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following
8 * conditions are met:
9 *
10 *     * Redistributions of source code must retain the above copyright
11 *       notice, this list of conditions and the following disclaimer.
12 *     * Redistributions in binary form must reproduce the above copyright
13 *       notice, this list of conditions and the following disclaimer in
14 *       the documentation and/or other materials provided
15 *       with the distribution.
16 *     * Neither the name of Hobu, Inc. nor the names of its contributors
17 *       may be used to endorse or promote products derived from this
18 *       software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31 * OF SUCH DAMAGE.
32 ****************************************************************************/
33 
34 #pragma once
35 
36 #include <pdal/Reader.hpp>
37 #include <pdal/XMLSchema.hpp>
38 
39 namespace pdal
40 {
41 
42 class PDAL_DLL DbReader : public Reader
43 {
44 protected:
DbReader()45     DbReader() : m_orientation(Orientation::PointMajor), m_packedPointSize(0)
46     {}
47 
48     DimTypeList dbDimTypes() const;
49     void loadSchema(PointLayoutPtr layout, const std::string& schemaString);
50     void loadSchema(PointLayoutPtr layout, const XMLSchema& schema);
51     void updateSchema(const XMLSchema& schema);
52     void writeField(PointRef& point, const char *pos, const DimType& dim);
53     void writePoint(PointRef& point, const char *buf);
packedPointSize() const54     size_t packedPointSize() const
55         { return m_packedPointSize; }
56     size_t dimOffset(Dimension::Id id) const;
orientation() const57     Orientation orientation() const
58         { return m_orientation; }
59 
60 private:
61     PointLayoutPtr m_layout;
62     XMLDimList m_dims;
63     Orientation m_orientation;
64     size_t m_packedPointSize;
65 
66     DbReader& operator=(const DbReader&); // not implemented
67     DbReader(const DbReader&); // not implemented
68 };
69 
70 } // namespace pdal
71 
72