libLAS API Reference  1.8.1
spatialreference.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * $Id: lasspatialreference.hpp 1091 2009-03-10 20:17:35Z hobu $
3  *
4  * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
5  * Purpose: LAS Spatial Reference class
6  * Author: Howard Butler, hobu.inc@gmail.com
7  *
8  ******************************************************************************
9  * Copyright (c) 2009, Howard Butler
10  *
11  * All rights reserved.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following
15  * conditions are met:
16  *
17  * * Redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer.
19  * * Redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in
21  * the documentation and/or other materials provided
22  * with the distribution.
23  * * Neither the name of the Martin Isenburg or Iowa Department
24  * of Natural Resources nor the names of its contributors may be
25  * used to endorse or promote products derived from this software
26  * without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
35  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
36  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
37  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
38  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
39  * OF SUCH DAMAGE.
40  ****************************************************************************/
41 
42 #ifndef LIBLAS_LASSPATIALREFERENCE_HPP_INCLUDED
43 #define LIBLAS_LASSPATIALREFERENCE_HPP_INCLUDED
44 
45 #include <liblas/detail/fwd.hpp>
46 #include <liblas/detail/private_utility.hpp>
48 #include <liblas/exception.hpp>
49 #include <liblas/capi/las_config.h>
50 #include <liblas/export.hpp>
51 #include <liblas/external/property_tree/ptree.hpp>
52 
53 // std
54 #include <stdexcept> // std::out_of_range
55 #include <cstdlib> // std::size_t
56 #include <string>
57 
58 // Fake out the compiler if we don't have libgeotiff includes already
59 #if !defined(__geotiff_h_) && !defined(LIBGEOTIFF_GEOTIFF_H_)
60 typedef struct GTIFS *GTIF;
61 #endif
62 #if !defined(__geo_simpletags_h_) && !defined(LIBGEOTIFF_GEO_SIMPLETAGS_H_)
63 typedef struct ST_TIFFS *ST_TIFF;
64 #endif
65 
66 namespace liblas {
67 
70 {
71 public:
73  {
74  eHorizontalOnly = 1,
75  eCompoundOK = 2
76  };
77 
79  {
80  eGeoTIFF = 1,
81  eOGRWKT = 2
82  };
83 
86 
90 
92  SpatialReference(std::vector<VariableRecord> const& vlrs);
93 
95  SpatialReference(SpatialReference const& other);
96 
98  SpatialReference& operator=(SpatialReference const& rhs);
99 
100  bool operator==(const SpatialReference& other) const;
101  bool operator!=(const SpatialReference& other) const { return !(*this == other); }
102 
105  const GTIF* GetGTIF();
106 
107  void SetGTIF(GTIF* pgtiff, ST_TIFF* ptiff);
108 
117  std::string GetWKT(WKTModeFlag mode_flag = eHorizontalOnly) const;
118  std::string GetWKT(WKTModeFlag mode_flag, bool pretty) const;
119 
123  void SetWKT(std::string const& v);
124 
137  void SetVerticalCS(int32_t verticalCSType,
138  std::string const& citation = std::string(0),
139  int32_t verticalDatum = -1,
140  int32_t verticalUnits = 9001);
141 
145  void SetFromUserInput(std::string const& v);
146 
152  std::string GetProj4() const;
153 
160  void SetProj4(std::string const& v);
161 
166  void SetVLRs(std::vector<VariableRecord> const& vlrs);
167 
169  void AddVLR(VariableRecord const& vlr);
170 
172  std::vector<VariableRecord> GetVLRs() const;
173 
174  void ClearVLRs( GeoVLRType eType );
175 
176  liblas::property_tree::ptree GetPTree() const;
177 private:
178 
179  // FIXME: Define as shared_ptr<GTIF> with custom deleter to get rid of bloated mem management, unsafe anyway --mloskot
180  GTIF* m_gtiff;
181  ST_TIFF* m_tiff;
182 
183  std::string m_wkt;
184 
185  std::vector<VariableRecord> m_vlrs;
186  bool IsGeoVLR(VariableRecord const& vlr) const;
187  std::string GetGTIFFText() const;
188 
194  void ResetVLRs();
195 };
196 
197 } // namespace liblas
198 
199 LAS_DLL std::ostream& operator<<(std::ostream& ostr, const liblas::SpatialReference& srs);
200 
202 #if defined(__geotiff_h_) || defined(LIBGEOTIFF_GEOTIFF_H_)
203 #if defined(GEO_NORMALIZE_H_INCLUDED)
204 char LAS_DLL * GTIFGetOGISDefn(GTIF*, GTIFDefn*);
205 #endif
206 
207 int LAS_DLL GTIFSetFromOGISDefn(GTIF*, const char*);
208 void SetLinearUnitCitation(GTIF* psGTIF, char* pszLinearUOMName);
209 
210 #if defined(_OGR_SRS_API_H_INCLUDED)
211 void SetGeogCSCitation(GTIF* psGTIF, OGRSpatialReference* poSRS, char* angUnitName, int nDatum, short nSpheroid);
212 #endif // defined _OGR_SRS_API_H_INCLUDED
213 #endif // defined __geotiff_h_ || defined LIBGEOTIFF_GEOTIFF_H_
214 
215 LAS_C_END
216 
217 #endif // LIBLAS_LASSPATIALREFERENCE_HPP_INCLUDED
struct ST_TIFFS * ST_TIFF
Definition: spatialreference.hpp:63
Representation of variable-length record data.
Definition: variablerecord.hpp:59
#define LAS_DLL
Definition: export.hpp:58
std::ostream & operator<<(std::ostream &os, Classification const &cls)
The output stream operator is based on std::bitset<N>::operator<<.
Definition: classification.hpp:247
GeoVLRType
Definition: spatialreference.hpp:78
bool operator==(Classification const &lhs, Classification const &rhs)
Equal-to operator implemented in terms of Classification::equal.
Definition: classification.hpp:226
#define LAS_C_END
Definition: las_config.h:55
Spatial Reference System container for libLAS.
Definition: spatialreference.hpp:69
Namespace grouping all elements of libLAS public interface.
Definition: bounds.hpp:60
struct GTIFS * GTIF
Definition: spatialreference.hpp:60
WKTModeFlag
Definition: spatialreference.hpp:72
#define LAS_C_START
Definition: las_config.h:54
bool operator!=(const SpatialReference &other) const
Definition: spatialreference.hpp:101