1
/******************************************************************************
2
* $Id: lasspatialreference.hpp 1091 2009-03-10 20:17:35Z hobu $
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
8
******************************************************************************
9
* Copyright (c) 2009, Howard Butler
11
* All rights reserved.
13
* Redistribution and use in source and binary forms, with or without
14
* modification, are permitted provided that the following
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.
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
40
****************************************************************************/
42
#ifndef LIBLAS_LASSPATIALREFERENCE_HPP_INCLUDED
43
#define LIBLAS_LASSPATIALREFERENCE_HPP_INCLUDED
45
#include <liblas/lasvariablerecord.hpp>
46
#include <liblas/cstdint.hpp>
47
#include <liblas/detail/fwd.hpp>
48
#include <liblas/detail/utility.hpp>
49
#include <liblas/exception.hpp>
50
#include <liblas/capi/las_config.h>
54
#include "ogr_srs_api.h"
57
#include "geo_tiffp.h"
58
#define CPL_ERROR_H_INCLUDED
60
#include "geo_normalize.h"
61
#include "geovalues.h"
62
#include "ogr_spatialref.h"
65
#include "cpl_multiproc.h"
70
#ifdef HAVE_LIBGEOTIFF
72
#include "geo_simpletags.h"
73
#include "geo_normalize.h"
74
#include "geo_simpletags.h"
75
#include "geovalues.h"
76
#endif // HAVE_LIBGEOTIFF
79
#include <stdexcept> // std::out_of_range
80
#include <cstdlib> // std::size_t
83
// Fake out the compiler if we don't have libgeotiff
84
#ifndef HAVE_LIBGEOTIFF
85
typedef struct GTIFS * GTIF;
86
typedef struct ST_TIFFS * ST_TIFF;
91
/// Spatial Reference System container for libLAS
92
class LASSpatialReference
96
/// Default constructor.
97
LASSpatialReference();
100
/// If libgeotiff is enabled, deallocates libtiff and libgeotiff objects used internally.
101
~LASSpatialReference();
103
/// Constructor creating LASSpatialReference instance from given Variable-Length Record.
104
LASSpatialReference(const std::vector<LASVariableRecord>& vlrs);
106
/// Copy constryctor.
107
LASSpatialReference(LASSpatialReference const& other);
109
/// Assignment operator.
110
LASSpatialReference& operator=(LASSpatialReference const& rhs);
112
/// Returns a pointer to the internal GTIF*. Only available if
113
/// you have libgeotiff linked in.
114
const GTIF* GetGTIF();
116
void SetGTIF(const GTIF* gtiff, const ST_TIFF* tiff);
118
/// Returns the OGC WKT describing Spatial Reference System.
119
/// If GDAL is linked, it uses GDAL's operations and methods to determine
120
/// the WKT. If GDAL is not linked, no WKT is returned.
121
std::string GetWKT() const;
123
/// Sets the SRS using GDAL's OGC WKT. If GDAL is not linked, this
124
/// operation has no effect.
125
/// \param v - a string containing the WKT string.
126
void SetWKT(std::string const& v);
128
/// Returns the Proj.4 string describing the Spatial Reference System.
129
/// If GDAL is linked, it uses GDAL's operations and methods to determine
130
/// the Proj.4 string -- otherwise, if libgeotiff is linked, it uses
131
/// that. Note that GDAL's operations are much more mature and
132
/// support more coordinate systems and descriptions.
133
std::string GetProj4() const;
135
/// Sets the Proj.4 string describing the Spatial Reference System.
136
/// If GDAL is linked, it uses GDAL's operations and methods to determine
137
/// the Proj.4 string -- otherwise, if libgeotiff is linked, it uses
138
/// that. Note that GDAL's operations are much more mature and
139
/// support more coordinate systems and descriptions.
140
/// \param v - a string containing the Proj.4 string.
141
void SetProj4(std::string const& v);
143
/// Set the LASVLRs for the LASSpatialReference. SetVLRs will only copy
144
/// VLR records that pertain to the GeoTIFF keys, and extraneous
145
/// VLR records will not be copied.
146
/// \param vlrs - A list of VLRs that contains VLRs describing GeoTIFF keys
147
void SetVLRs(const std::vector<LASVariableRecord>& vlrs);
149
/// Add a VLR representing GeoTIFF keys to the SRS
150
void AddVLR(const LASVariableRecord& vlr);
152
/// Return a copy of the LASVLRs that LASSpatialReference maintains
153
std::vector<LASVariableRecord> GetVLRs() const;
160
std::vector<LASVariableRecord> m_vlrs;
161
bool IsGeoVLR(const LASVariableRecord& vlr) const;
163
/// Reset the VLRs of the LASSpatialReference using the existing GTIF* and ST_TIF*
164
/// Until this method is called,
165
/// the LASSpatialReference will only contain a SRS description using the VLRs
166
/// that it was first instantiated with. SetWKT and SetProj4 can
167
/// be used to change the GTIF*
171
} // namespace liblas
175
char LAS_DLL * GTIFGetOGISDefn(GTIF*, GTIFDefn*);
176
int LAS_DLL GTIFSetFromOGISDefn(GTIF*, const char*);
178
void SetLinearUnitCitation(GTIF* psGTIF, char* pszLinearUOMName);
179
void SetGeogCSCitation(GTIF* psGTIF, OGRSpatialReference* poSRS, char* angUnitName, int nDatum, short nSpheroid);
183
#endif // LIBLAS_LASSPATIALREFERENCE_HPP_INCLUDED