~ubuntu-branches/ubuntu/trusty/liblas/trusty-proposed

« back to all changes in this revision

Viewing changes to include/liblas/spatialreference.hpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2014-01-05 17:00:29 UTC
  • mfrom: (7.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20140105170029-ddtp0j63x5jvck2u
Tags: 1.7.0+dfsg-2
Fixed missing linking of system boost component.
(closes: #733282)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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>
 
47
#include <liblas/variablerecord.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_)
 
60
typedef struct GTIFS *GTIF;
 
61
#endif
 
62
#if !defined(__geo_simpletags_h_)
 
63
typedef struct ST_TIFFS *ST_TIFF;
 
64
#endif
 
65
 
 
66
namespace liblas {
 
67
 
 
68
/// Spatial Reference System container for libLAS
 
69
class LAS_DLL SpatialReference
 
70
{
 
71
public:
 
72
    enum WKTModeFlag
 
73
    {
 
74
        eHorizontalOnly = 1,
 
75
        eCompoundOK = 2
 
76
    };
 
77
 
 
78
    enum GeoVLRType
 
79
    {
 
80
        eGeoTIFF = 1,
 
81
        eOGRWKT = 2
 
82
    };
 
83
 
 
84
    /// Default constructor.
 
85
    SpatialReference();
 
86
 
 
87
    /// Destructor.
 
88
    /// If libgeotiff is enabled, deallocates libtiff and libgeotiff objects used internally.
 
89
    ~SpatialReference();
 
90
 
 
91
    /// Constructor creating SpatialReference instance from given Variable-Length Record.
 
92
    SpatialReference(std::vector<VariableRecord> const& vlrs);
 
93
 
 
94
    /// Copy constryctor.
 
95
    SpatialReference(SpatialReference const& other);
 
96
 
 
97
    /// Assignment operator.
 
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
    
 
103
    /// Returns a pointer to the internal GTIF*.  Only available if 
 
104
    /// you have libgeotiff linked in.
 
105
    const GTIF* GetGTIF();
 
106
 
 
107
    void SetGTIF(GTIF* pgtiff, ST_TIFF* ptiff);
 
108
 
 
109
    /// Returns the OGC WKT describing Spatial Reference System.
 
110
    /// If GDAL is linked, it uses GDAL's operations and methods to determine 
 
111
    /// the WKT.  If GDAL is not linked, no WKT is returned.
 
112
    /// \param mode_flag May be eHorizontalOnly indicating the WKT will not 
 
113
    /// include vertical coordinate system info (the default), or 
 
114
    /// eCompoundOK indicating the the returned WKT may be a compound 
 
115
    /// coordinate system if there is vertical coordinate system info 
 
116
    /// available.
 
117
    std::string GetWKT(WKTModeFlag mode_flag = eHorizontalOnly) const;
 
118
    std::string GetWKT(WKTModeFlag mode_flag, bool pretty) const;
 
119
    
 
120
    /// Sets the SRS using GDAL's OGC WKT. If GDAL is not linked, this 
 
121
    /// operation has no effect.
 
122
    /// \param v - a string containing the WKT string.  
 
123
    void SetWKT(std::string const& v);
 
124
 
 
125
    /// Sets the vertical coordinate system using geotiff key values.
 
126
    /// This operation should normally be done after setting the horizontal
 
127
    /// portion of the coordinate system with something like SetWKT(), 
 
128
    /// SetProj4(), SetGTIF() or SetFromUserInput()
 
129
    /// \param verticalCSType - An EPSG vertical coordinate system code, 
 
130
    /// normally in the range 5600 to 5799, or -1 if one is not available.
 
131
    /// \param citation - a textual description of the vertical coordinate 
 
132
    /// system or an empty string if nothing is available.
 
133
    /// \param verticalDatum - the EPSG vertical datum code, often in the 
 
134
    /// range 5100 to 5299 - implied by verticalCSType if that is provided, or 
 
135
    /// -1 if no value is available.
 
136
    /// \param verticalUnits - the EPSG vertical units code, often 9001 for Metre.
 
137
    void SetVerticalCS(boost::int32_t verticalCSType, 
 
138
                       std::string const& citation = std::string(0),
 
139
                       boost::int32_t verticalDatum = -1,
 
140
                       boost::int32_t verticalUnits = 9001);
 
141
 
 
142
    /// Sets the SRS using GDAL's SetFromUserInput function. If GDAL is not linked, this 
 
143
    /// operation has no effect.
 
144
    /// \param v - a string containing the definition (filename, proj4, wkt, etc).  
 
145
    void SetFromUserInput(std::string const& v);
 
146
        
 
147
    /// Returns the Proj.4 string describing the Spatial Reference System.
 
148
    /// If GDAL is linked, it uses GDAL's operations and methods to determine 
 
149
    /// the Proj.4 string -- otherwise, if libgeotiff is linked, it uses 
 
150
    /// that.  Note that GDAL's operations are much more mature and 
 
151
    /// support more coordinate systems and descriptions.
 
152
    std::string GetProj4() const;
 
153
 
 
154
    /// Sets the Proj.4 string describing the Spatial Reference System.
 
155
    /// If GDAL is linked, it uses GDAL's operations and methods to determine 
 
156
    /// the Proj.4 string -- otherwise, if libgeotiff is linked, it uses 
 
157
    /// that.  Note that GDAL's operations are much more mature and 
 
158
    /// support more coordinate systems and descriptions.
 
159
    /// \param v - a string containing the Proj.4 string.
 
160
    void SetProj4(std::string const& v);
 
161
    
 
162
    /// Set the LASVLRs for the SpatialReference.  SetVLRs will only copy 
 
163
    /// VLR records that pertain to the GeoTIFF keys, and extraneous 
 
164
    /// VLR records will not be copied.
 
165
    /// \param vlrs - A list of VLRs that contains VLRs describing GeoTIFF keys
 
166
    void SetVLRs(std::vector<VariableRecord> const& vlrs);
 
167
    
 
168
    /// Add a VLR representing GeoTIFF keys to the SRS
 
169
    void AddVLR(VariableRecord const& vlr);
 
170
    
 
171
    /// Return a copy of the LASVLRs that SpatialReference maintains
 
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
 
 
189
    /// Reset the VLRs of the SpatialReference using the existing GTIF* and ST_TIF*
 
190
    /// Until this method is called, 
 
191
    /// the SpatialReference will only contain a SRS description using the VLRs 
 
192
    /// that it was first instantiated with.  SetWKT and SetProj4 can 
 
193
    /// be used to change the GTIF* 
 
194
    void ResetVLRs();
 
195
};
 
196
 
 
197
} // namespace liblas
 
198
 
 
199
LAS_DLL std::ostream& operator<<(std::ostream& ostr, const liblas::SpatialReference& srs);
 
200
 
 
201
LAS_C_START
 
202
#if defined(__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_
 
214
 
 
215
LAS_C_END
 
216
 
 
217
#endif // LIBLAS_LASSPATIALREFERENCE_HPP_INCLUDED