liblas.hpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id$
00003  *
00004  * Project:  libLAS - http://liblas.org - A BSD library for LAS format data.
00005  * Purpose:  LAS include file
00006  * Author:   Mateusz Loskot, mateusz@loskot.net
00007  *
00008  ******************************************************************************
00009  * Copyright (c) 2008, Mateusz Loskot
00010  * Copyright (c) 2008, Phil Vachon
00011  * Copyright (c) 2008, Howard Butler
00012  *
00013  * All rights reserved.
00014  * 
00015  * Redistribution and use in source and binary forms, with or without 
00016  * modification, are permitted provided that the following 
00017  * conditions are met:
00018  * 
00019  *     * Redistributions of source code must retain the above copyright 
00020  *       notice, this list of conditions and the following disclaimer.
00021  *     * Redistributions in binary form must reproduce the above copyright 
00022  *       notice, this list of conditions and the following disclaimer in 
00023  *       the documentation and/or other materials provided 
00024  *       with the distribution.
00025  *     * Neither the name of the Martin Isenburg or Iowa Department 
00026  *       of Natural Resources nor the names of its contributors may be 
00027  *       used to endorse or promote products derived from this software 
00028  *       without specific prior written permission.
00029  * 
00030  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00031  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00032  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
00033  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
00034  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
00035  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
00036  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
00037  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00038  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
00039  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
00040  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00041  * OF SUCH DAMAGE.
00042  ****************************************************************************/
00043 
00044 
00045 #ifndef LIBLAS_HPP_INCLUDED
00046 #define LIBLAS_HPP_INCLUDED
00047 
00048 // liblas
00049 #include <liblas/detail/fwd.hpp>
00050 // booost
00051 #include <boost/array.hpp>
00052 #include <boost/concept_check.hpp>
00053 #include <boost/cstdint.hpp>
00054 #include <boost/shared_ptr.hpp>
00055 // std
00056 #include <fstream>
00057 #include <string>
00058 
00059 typedef boost::shared_ptr< liblas::Header > HeaderPtr;
00060 typedef boost::shared_ptr< liblas::Point > PointPtr;
00061 typedef boost::shared_ptr< liblas::TransformI > TransformPtr;
00062 
00070 namespace liblas
00071 {
00072 
00081 inline bool Open(std::ifstream& ifs, std::string const& filename) // throw()
00082 {
00083     ifs.open(filename.c_str(), std::ios::in | std::ios::binary);
00084     return ifs.is_open();
00085 }
00086 
00095 inline bool Create(std::ofstream& ofs, std::string const& filename) // throw()
00096 {
00097     ofs.open(filename.c_str(), std::ios::out | std::ios::binary);
00098     return ofs.is_open();
00099 }
00100 
00102 inline bool IsGDALEnabled()
00103 {
00104 #ifdef HAVE_GDAL
00105     return true;
00106 #else
00107     return false;
00108 #endif
00109 }
00110 
00112 inline bool IsLibGeoTIFFEnabled()
00113 {
00114 #ifdef HAVE_LIBGEOTIFF
00115     return true;
00116 #else
00117     return false;
00118 #endif
00119 }
00120 
00122 inline bool IsLibSpatialIndexEnabled()
00123 {
00124 #ifdef HAVE_SPATIALINDEX
00125     return true;
00126 #else
00127     return false;
00128 #endif
00129 }
00130 
00132 enum FormatVersion
00133 {
00134     eVersionMajorMin = 1, 
00135     eVersionMajorMax = 1, 
00136     eVersionMinorMin = 0, 
00137     eVersionMinorMax = 3 
00138 };
00139 
00141 enum PointFormatName
00142 {
00143     ePointFormat0 = 0, 
00144     ePointFormat1 = 1, 
00145     ePointFormat2 = 2, 
00146     ePointFormat3 = 3,  
00147     ePointFormat4 = 4,  
00148     ePointFormat5 = 5,  
00149     ePointFormatUnknown = -99 
00150 };
00151 
00153 enum PointSize
00154 {
00155     ePointSize0 = 20, 
00156     ePointSize1 = 28, 
00157     ePointSize2 = 26, 
00158     ePointSize3 = 34  
00159 
00160 };
00161 
00162 
00163 class ReaderI
00164 {
00165 public:
00166 
00167     virtual HeaderPtr ReadHeader() = 0;
00168     virtual PointPtr ReadNextPoint(HeaderPtr header) = 0;
00169     virtual Point const& ReadPointAt(std::size_t n, HeaderPtr header) = 0;
00170     virtual void Seek(std::size_t n, HeaderPtr header) = 0;
00171     
00172     virtual void Reset(HeaderPtr header) = 0;
00173     
00174     virtual std::istream& GetStream() const = 0;
00175     
00176     virtual ~ReaderI() {};    
00177 };
00178 
00179 class WriterI
00180 {
00181 public:
00182 
00183     virtual Header const& WriteHeader(const Header& header) = 0;
00184     virtual void UpdateHeader(const Header& header) = 0;
00185     virtual void WritePoint(const Point& point, const Header& header) = 0;
00186 
00187     virtual std::ostream& GetStream() const = 0;
00188 
00189     virtual ~WriterI() {};    
00190 
00191 };
00192 
00194 class FilterI
00195 {
00196 public:
00197     
00200     enum FilterType
00201     {
00202         eExclusion = 0, 
00203         eInclusion = 1 
00204     };
00205     
00206     virtual bool filter(const Point& point) = 0;
00207     
00208     void SetType(FilterType t) {m_type = t;}
00209     FilterType GetType() const {return m_type; }
00210 
00211     virtual ~FilterI() {};
00212 
00213     FilterI(FilterType t) : m_type(t) {}
00214     
00215 private:
00216 
00217     FilterI(FilterI const& other);
00218     FilterI& operator=(FilterI const& rhs);
00219 
00220     FilterType m_type;
00221 
00222     
00223 };
00224 
00226 class TransformI
00227 {
00228 public:
00229     
00230     virtual bool transform(Point& point) = 0;
00231     virtual ~TransformI() {};
00232 
00233 };
00234 
00235 } // namespace liblas
00236 
00237 #endif // LIBLAS_HPP_INCLUDED

Generated on Fri Jul 30 19:30:13 2010 for libLAS API Reference by  doxygen 1.6.1