1 /******************************************************************************
2  * $Id: hfa.h f9a7f39dfcdd2cbbfec35ecbe69515fc411731e7 2017-05-15 12:57:00Z Kurt Schwehr $
3  *
4  * Project:  Erdas Imagine (.img) Translator
5  * Purpose:  Public (C callable) interface for the Erdas Imagine reading
6  *           code.  This include files, and its implementing code depends
7  *           on CPL, but not GDAL.
8  * Author:   Frank Warmerdam, warmerdam@pobox.com
9  *
10  ******************************************************************************
11  * Copyright (c) 1999, Intergraph Corporation
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 #ifndef HFAOPEN_H_INCLUDED
33 #define HFAOPEN_H_INCLUDED
34 
35 #include <cstdio>
36 
37 #include "cpl_conv.h"
38 #include "cpl_string.h"
39 
40 typedef struct hfainfo *HFAHandle;
41 
42 /* -------------------------------------------------------------------- */
43 /*      Structure definitions from eprj.h, with some type               */
44 /*      simplifications.                                                */
45 /* -------------------------------------------------------------------- */
46 typedef struct {
47         double x;                       /* coordinate x-value */
48         double y;                       /* coordinate y-value */
49 } Eprj_Coordinate;
50 
51 typedef struct {
52         double width;                   /* pixelsize width */
53         double height;                  /* pixelsize height */
54 } Eprj_Size;
55 
56 typedef struct {
57         char * proName;             /* projection name */
58         Eprj_Coordinate upperLeftCenter;    /* map coordinates of center of
59                                                upper left pixel */
60         Eprj_Coordinate lowerRightCenter;   /* map coordinates of center of
61                                                lower right pixel */
62         Eprj_Size pixelSize;        /* pixel size in map units */
63         char * units;               /* units of the map */
64 } Eprj_MapInfo;
65 
66 typedef enum {
67         EPRJ_INTERNAL,          /* Indicates that the projection is built into
68                                    the eprj package as function calls */
69         EPRJ_EXTERNAL           /* Indicates that the projection is accessible
70                                    as an EXTERNal executable */
71 } Eprj_ProType;
72 
73 typedef enum {
74         EPRJ_NAD27=1,           /* Use the North America Datum 1927 */
75         EPRJ_NAD83=2,           /* Use the North America Datum 1983 */
76         EPRJ_HARN               /* Use the North America Datum High Accuracy
77                                    Reference Network */
78 } Eprj_NAD;
79 
80 typedef enum {
81         EPRJ_DATUM_PARAMETRIC,          /* The datum info is 7 doubles */
82         EPRJ_DATUM_GRID,                /* The datum info is a name */
83         EPRJ_DATUM_REGRESSION,
84         EPRJ_DATUM_NONE
85 } Eprj_DatumType;
86 
87 typedef struct {
88         char *datumname;                /* name of the datum */
89         Eprj_DatumType type;            /* The datum type */
90         double  params[7];              /* The parameters for type
91                                            EPRJ_DATUM_PARAMETRIC */
92         char *gridname;                 /* name of the grid file */
93 } Eprj_Datum;
94 
95 typedef struct {
96         char * sphereName;              /* name of the ellipsoid */
97         double a;                       /* semi-major axis of ellipsoid */
98         double b;                       /* semi-minor axis of ellipsoid */
99         double eSquared;                /* eccentricity-squared */
100         double radius;                  /* radius of the sphere */
101 } Eprj_Spheroid;
102 
103 typedef struct {
104         Eprj_ProType proType;           /* projection type */
105         int proNumber;                  /* projection number for internal
106                                            projections */
107         char * proExeName;              /* projection executable name for
108                                            EXTERNal projections */
109         char * proName;                 /* projection name */
110         int proZone;                    /* projection zone (UTM, SP only) */
111         double proParams[15];           /* projection parameters array in the
112                                            GCTP form */
113         Eprj_Spheroid proSpheroid;      /* projection spheroid */
114 } Eprj_ProParameters;
115 
116 typedef struct {
117     int         order;
118     double      polycoefmtx[18];
119     double      polycoefvector[2];
120 } Efga_Polynomial;
121 
122 /* -------------------------------------------------------------------- */
123 /*      data types.                                                     */
124 /* -------------------------------------------------------------------- */
125 typedef enum
126 {
127     EPT_MIN = 0,
128     EPT_u1 = 0,
129     EPT_u2 = 1,
130     EPT_u4 = 2,
131     EPT_u8 = 3,
132     EPT_s8 = 4,
133     EPT_u16 = 5,
134     EPT_s16 = 6,
135     EPT_u32 = 7,
136     EPT_s32 = 8,
137     EPT_f32 = 9,
138     EPT_f64 = 10,
139     EPT_c64 = 11,
140     EPT_c128 = 12,
141     EPT_MAX = EPT_c128
142 } EPTType;
143 
144 /* -------------------------------------------------------------------- */
145 /*      Prototypes                                                      */
146 /* -------------------------------------------------------------------- */
147 
148 CPL_C_START
149 
150 HFAHandle CPL_DLL HFAOpen( const char * pszFilename, const char * pszMode );
151 int CPL_DLL HFAClose( HFAHandle ); /* 0 = success */
152 CPLErr HFADelete( const char *pszFilename );
153 CPLErr HFARenameReferences( HFAHandle, const char *, const char * );
154 
155 HFAHandle CPL_DLL HFACreateLL( const char *pszFilename );
156 HFAHandle CPL_DLL HFACreate( const char *pszFilename, int nXSize, int nYSize,
157                              int nBands, EPTType eDataType, char ** papszOptions );
158 const char CPL_DLL *HFAGetIGEFilename( HFAHandle );
159 CPLErr CPL_DLL HFAFlush( HFAHandle );
160 int CPL_DLL HFACreateOverview( HFAHandle hHFA, int nBand, int nOverviewLevel,
161                                const char *pszResampling );
162 
163 const Eprj_MapInfo CPL_DLL *HFAGetMapInfo( HFAHandle );
164 int CPL_DLL HFAGetGeoTransform( HFAHandle, double* );
165 CPLErr CPL_DLL HFASetGeoTransform( HFAHandle, const char*,
166                                    const char*, double *);
167 CPLErr CPL_DLL HFASetMapInfo( HFAHandle, const Eprj_MapInfo * );
168 const Eprj_Datum CPL_DLL *HFAGetDatum( HFAHandle );
169 CPLErr CPL_DLL HFASetDatum( HFAHandle, const Eprj_Datum * );
170 const Eprj_ProParameters CPL_DLL *HFAGetProParameters( HFAHandle );
171 char CPL_DLL *HFAGetPEString( HFAHandle );
172 CPLErr CPL_DLL HFASetPEString( HFAHandle hHFA, const char *pszPEString );
173 CPLErr CPL_DLL HFASetProParameters( HFAHandle, const Eprj_ProParameters * );
174 
175 CPLErr CPL_DLL HFAGetRasterInfo( HFAHandle hHFA, int *pnXSize, int *pnYSize,
176                                  int *pnBands );
177 CPLErr CPL_DLL HFAGetBandInfo( HFAHandle hHFA, int nBand, EPTType* peDataType,
178                                int * pnBlockXSize, int * pnBlockYSize,
179                                int *pnCompressionType );
180 int    CPL_DLL HFAGetBandNoData( HFAHandle hHFA, int nBand, double *pdfValue );
181 CPLErr CPL_DLL HFASetBandNoData( HFAHandle hHFA, int nBand, double dfValue );
182 int    CPL_DLL HFAGetOverviewCount( HFAHandle hHFA, int nBand );
183 CPLErr CPL_DLL HFAGetOverviewInfo( HFAHandle hHFA, int nBand, int nOverview,
184                                    int * pnXSize, int * pnYSize,
185                                    int * pnBlockXSize, int * pnBlockYSize,
186                                    EPTType * peHFADataType );
187 CPLErr CPL_DLL HFAGetRasterBlock( HFAHandle hHFA, int nBand, int nXBlock,
188                                   int nYBlock, void * pData );
189 CPLErr CPL_DLL HFAGetRasterBlockEx( HFAHandle hHFA, int nBand, int nXBlock,
190                                     int nYBlock, void * pData, int nDataSize );
191 CPLErr CPL_DLL HFAGetOverviewRasterBlock( HFAHandle hHFA, int nBand,
192                                           int iOverview,
193                                    int nXBlock, int nYBlock, void * pData );
194 CPLErr CPL_DLL HFAGetOverviewRasterBlockEx(
195                    HFAHandle hHFA, int nBand, int iOverview,
196                    int nXBlock, int nYBlock, void * pData, int nDataSize );
197 CPLErr CPL_DLL HFASetRasterBlock( HFAHandle hHFA, int nBand,
198                                   int nXBlock, int nYBlock,
199                                   void * pData );
200 CPLErr CPL_DLL HFASetOverviewRasterBlock(
201     HFAHandle hHFA, int nBand, int iOverview, int nXBlock, int nYBlock,
202     void * pData );
203 const char * HFAGetBandName( HFAHandle hHFA, int nBand );
204 void HFASetBandName( HFAHandle hHFA, int nBand, const char *pszName );
205 int     CPL_DLL HFAGetDataTypeBits( EPTType eDataType );
206 const char CPL_DLL *HFAGetDataTypeName( EPTType eDataType );
207 CPLErr  CPL_DLL HFAGetPCT( HFAHandle, int, int *,
208                            double **, double **, double ** , double **,
209                            double **);
210 CPLErr  CPL_DLL HFASetPCT( HFAHandle, int, int, double *, double *, double *, double * );
211 void    CPL_DLL HFADumpTree( HFAHandle, FILE * );
212 void    CPL_DLL HFADumpDictionary( HFAHandle, FILE * );
213 CPLErr  CPL_DLL HFAGetDataRange( HFAHandle, int, double *, double * );
214 char  CPL_DLL **HFAGetMetadata( HFAHandle hHFA, int nBand );
215 CPLErr  CPL_DLL HFASetMetadata( HFAHandle hHFA, int nBand, char ** );
216 char  CPL_DLL **HFAGetClassNames( HFAHandle hHFA, int nBand );
217 
218 int CPL_DLL
219 HFAReadXFormStack( HFAHandle psInfo,
220                    Efga_Polynomial **ppasPolyListForward,
221                    Efga_Polynomial **ppasPolyListReverse );
222 CPLErr CPL_DLL
223 HFAWriteXFormStack( HFAHandle psInfo, int nBand, int nXFormCount,
224                     Efga_Polynomial **ppasPolyListForward,
225                     Efga_Polynomial **ppasPolyListReverse );
226 int CPL_DLL
227 HFAEvaluateXFormStack( int nStepCount, int bForward,
228                        Efga_Polynomial *pasPolyList,
229                        double *pdfX, double *pdfY );
230 
231 char CPL_DLL **HFAReadCameraModel( HFAHandle psInfo );
232 const char CPL_DLL *HFAReadElevationUnit( HFAHandle psInfo, int iBand );
233 
234 /* -------------------------------------------------------------------- */
235 /*      Projection codes.                                               */
236 /* -------------------------------------------------------------------- */
237 #define EPRJ_LATLONG                            0
238 #define EPRJ_UTM                                1
239 #define EPRJ_STATE_PLANE                        2
240 #define EPRJ_ALBERS_CONIC_EQUAL_AREA            3
241 #define EPRJ_LAMBERT_CONFORMAL_CONIC            4
242 #define EPRJ_MERCATOR                           5
243 #define EPRJ_POLAR_STEREOGRAPHIC                6
244 #define EPRJ_POLYCONIC                          7
245 #define EPRJ_EQUIDISTANT_CONIC                  8
246 #define EPRJ_TRANSVERSE_MERCATOR                9
247 #define EPRJ_STEREOGRAPHIC                      10
248 #define EPRJ_LAMBERT_AZIMUTHAL_EQUAL_AREA       11
249 #define EPRJ_AZIMUTHAL_EQUIDISTANT              12
250 #define EPRJ_GNOMONIC                           13
251 #define EPRJ_ORTHOGRAPHIC                       14
252 #define EPRJ_GENERAL_VERTICAL_NEAR_SIDE_PERSPECTIVE 15
253 #define EPRJ_SINUSOIDAL                         16
254 #define EPRJ_EQUIRECTANGULAR                    17
255 #define EPRJ_MILLER_CYLINDRICAL                 18
256 #define EPRJ_VANDERGRINTEN                      19
257 #define EPRJ_HOTINE_OBLIQUE_MERCATOR            20
258 #define EPRJ_SPACE_OBLIQUE_MERCATOR             21
259 #define EPRJ_MODIFIED_TRANSVERSE_MERCATOR       22
260 #define EPRJ_EOSAT_SOM                          23
261 #define EPRJ_ROBINSON                           24
262 #define EPRJ_SOM_A_AND_B                        25
263 #define EPRJ_ALASKA_CONFORMAL                   26
264 #define EPRJ_INTERRUPTED_GOODE_HOMOLOSINE       27
265 #define EPRJ_MOLLWEIDE                          28
266 #define EPRJ_INTERRUPTED_MOLLWEIDE              29
267 #define EPRJ_HAMMER                             30
268 #define EPRJ_WAGNER_IV                          31
269 #define EPRJ_WAGNER_VII                         32
270 #define EPRJ_OBLATED_EQUAL_AREA                 33
271 #define EPRJ_PLATE_CARREE                       34
272 #define EPRJ_EQUIDISTANT_CYLINDRICAL            35
273 #define EPRJ_GAUSS_KRUGER                       36
274 #define EPRJ_ECKERT_VI                          37
275 #define EPRJ_ECKERT_V                           38
276 #define EPRJ_ECKERT_IV                          39
277 #define EPRJ_ECKERT_III                         40
278 #define EPRJ_ECKERT_II                          41
279 #define EPRJ_ECKERT_I                           42
280 #define EPRJ_GALL_STEREOGRAPHIC                 43
281 #define EPRJ_BEHRMANN                           44
282 #define EPRJ_WINKEL_I                           45
283 #define EPRJ_WINKEL_II                          46
284 #define EPRJ_QUARTIC_AUTHALIC                   47
285 #define EPRJ_LOXIMUTHAL                         48
286 #define EPRJ_BONNE                              49
287 #define EPRJ_STEREOGRAPHIC_EXTENDED             50
288 #define EPRJ_CASSINI                            51
289 #define EPRJ_TWO_POINT_EQUIDISTANT              52
290 #define EPRJ_ANCHORED_LSR                       53
291 #define EPRJ_KROVAK                             54
292 #define EPRJ_DOUBLE_STEREOGRAPHIC               55
293 #define EPRJ_AITOFF                             56
294 #define EPRJ_CRASTER_PARABOLIC                  57
295 #define EPRJ_CYLINDRICAL_EQUAL_AREA             58
296 #define EPRJ_FLAT_POLAR_QUARTIC                 59
297 #define EPRJ_TIMES                              60
298 #define EPRJ_WINKEL_TRIPEL                      61
299 #define EPRJ_HAMMER_AITOFF                      62
300 #define EPRJ_VERTICAL_NEAR_SIDE_PERSPECTIVE     63
301 #define EPRJ_HOTINE_OBLIQUE_MERCATOR_AZIMUTH_CENTER           64
302 #define EPRJ_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_CENTER         65
303 #define EPRJ_HOTINE_OBLIQUE_MERCATOR_TWO_POINT_NATURAL_ORIGIN 66
304 #define EPRJ_LAMBERT_CONFORMAL_CONIC_1SP        67
305 #define EPRJ_PSEUDO_MERCATOR                    68
306 #define EPRJ_MERCATOR_VARIANT_A                 69
307 #define EPRJ_HOTINE_OBLIQUE_MERCATOR_VARIANT_A                70
308 #define EPRJ_TRANSVERSE_MERCATOR_SOUTH_ORIENTATED             71
309 
310 #define EPRJ_EXTERNAL_RSO                       "eprj_rso"
311 #define EPRJ_EXTERNAL_NZMG                      "nzmg"
312 #define EPRJ_EXTERNAL_INTEGERIZED_SINUSOIDAL    "isin"
313 
314 CPL_C_END
315 
316 #endif /* ndef HFAOPEN_H_INCLUDED */
317