libLAS API Reference (svn-trunk)
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>
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_)
60typedef struct GTIFS *GTIF;
61#endif
62#if !defined(__geo_simpletags_h_) && !defined(LIBGEOTIFF_GEO_SIMPLETAGS_H_)
63typedef struct ST_TIFFS *ST_TIFF;
64#endif
65
66namespace liblas {
67
70{
71public:
77
79 {
82 };
83
86
90
92 SpatialReference(std::vector<VariableRecord> const& vlrs);
93
96
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;
177private:
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
199LAS_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)
204char LAS_DLL * GTIFGetOGISDefn(GTIF*, GTIFDefn*);
205#endif
206
207int LAS_DLL GTIFSetFromOGISDefn(GTIF*, const char*);
208void SetLinearUnitCitation(GTIF* psGTIF, char* pszLinearUOMName);
209
210#if defined(_OGR_SRS_API_H_INCLUDED)
211void 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
216
217#endif // LIBLAS_LASSPATIALREFERENCE_HPP_INCLUDED
Spatial Reference System container for libLAS.
Definition spatialreference.hpp:70
SpatialReference(std::vector< VariableRecord > const &vlrs)
Constructor creating SpatialReference instance from given Variable-Length Record.
std::string GetWKT(WKTModeFlag mode_flag, bool pretty) const
SpatialReference(SpatialReference const &other)
Copy constryctor.
void SetVerticalCS(int32_t verticalCSType, std::string const &citation=std::string(0), int32_t verticalDatum=-1, int32_t verticalUnits=9001)
Sets the vertical coordinate system using geotiff key values.
SpatialReference()
Default constructor.
void SetFromUserInput(std::string const &v)
Sets the SRS using GDAL's SetFromUserInput function.
~SpatialReference()
Destructor.
WKTModeFlag
Definition spatialreference.hpp:73
@ eHorizontalOnly
Definition spatialreference.hpp:74
@ eCompoundOK
Definition spatialreference.hpp:75
const GTIF * GetGTIF()
Returns a pointer to the internal GTIF*.
GeoVLRType
Definition spatialreference.hpp:79
@ eGeoTIFF
Definition spatialreference.hpp:80
@ eOGRWKT
Definition spatialreference.hpp:81
void SetWKT(std::string const &v)
Sets the SRS using GDAL's OGC WKT.
SpatialReference & operator=(SpatialReference const &rhs)
Assignment operator.
std::string GetProj4() const
Returns the Proj.4 string describing the Spatial Reference System.
void ClearVLRs(GeoVLRType eType)
std::vector< VariableRecord > GetVLRs() const
Return a copy of the LASVLRs that SpatialReference maintains.
bool operator==(const SpatialReference &other) const
void SetProj4(std::string const &v)
Sets the Proj.4 string describing the Spatial Reference System.
void SetGTIF(GTIF *pgtiff, ST_TIFF *ptiff)
void AddVLR(VariableRecord const &vlr)
Add a VLR representing GeoTIFF keys to the SRS.
std::string GetWKT(WKTModeFlag mode_flag=eHorizontalOnly) const
Returns the OGC WKT describing Spatial Reference System.
void SetVLRs(std::vector< VariableRecord > const &vlrs)
Set the LASVLRs for the SpatialReference.
bool operator!=(const SpatialReference &other) const
Definition spatialreference.hpp:101
liblas::property_tree::ptree GetPTree() const
Representation of variable-length record data.
Definition variablerecord.hpp:60
#define LAS_DLL
Definition export.hpp:58
#define LAS_C_END
Definition las_config.h:55
#define LAS_C_START
Definition las_config.h:54
Namespace grouping all elements of libLAS public interface.
Definition bounds.hpp:60
LAS_DLL std::ostream & operator<<(std::ostream &ostr, const liblas::SpatialReference &srs)
struct GTIFS * GTIF
Definition spatialreference.hpp:60
struct ST_TIFFS * ST_TIFF
Definition spatialreference.hpp:63