1 /******************************************************************************
2  * Project:  libgeotiff
3  * Purpose:  Include file related to geo_normalize.c containing Code to
4  *           normalize PCS and other composite codes in a GeoTIFF file.
5  * Author:   Frank Warmerdam, warmerda@home.com
6  *
7  ******************************************************************************
8  * Copyright (c) 1999, Frank Warmerdam
9  *
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  * DEALINGS IN THE SOFTWARE.
27  ******************************************************************************
28  *
29  * $Log$
30  * Revision 1.12  2005/08/26 16:08:14  fwarmerdam
31  * Include void in empty argument list for prototype.
32  *
33  * Revision 1.11  2004/02/03 17:19:50  warmerda
34  * export GTIFAngleToDD() - used by GDAL mrsiddataset.cpp
35  *
36  * Revision 1.10  2003/01/15 04:39:16  warmerda
37  * Added GTIFDeaccessCSV
38  *
39  * Revision 1.9  2003/01/15 03:37:40  warmerda
40  * added GTIFFreeMemory()
41  *
42  * Revision 1.8  2002/11/28 22:27:42  warmerda
43  * preliminary upgrade to EPSG 6.2.2 tables
44  *
45  * Revision 1.7  1999/09/17 00:55:26  warmerda
46  * added GTIFGetUOMAngleInfo(), and UOMAngle in GTIFDefn
47  *
48  * Revision 1.6  1999/05/04 03:13:42  warmerda
49  * Added prototype
50  *
51  * Revision 1.5  1999/04/29 23:02:55  warmerda
52  * added docs, and MapSys related stuff
53  *
54  * Revision 1.4  1999/03/18 21:35:19  geotiff
55  * Added PROJ.4 related stuff
56  *
57  * Revision 1.3  1999/03/17 20:44:04  geotiff
58  * added CPL_DLL related support
59  *
60  * Revision 1.2  1999/03/10 18:24:06  geotiff
61  * corrected to use int'
62  *
63  */
64 
65 #ifndef GEO_NORMALIZE_H_INCLUDED
66 #define GEO_NORMALIZE_H_INCLUDED
67 
68 #include <stdio.h>
69 #include "geotiff.h"
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 
75 /**
76  * \file geo_normalize.h
77  *
78  * Include file for extended projection definition normalization api.
79  */
80 
81 #define MAX_GTIF_PROJPARMS         10
82 
83 /**
84  * Holds a definition of a coordinate system in normalized form.
85  */
86 
87 typedef struct {
88     /** From GTModelTypeGeoKey tag.  Can have the values ModelTypeGeographic
89         or ModelTypeProjected. */
90     short        Model;
91 
92     /** From ProjectedCSTypeGeoKey tag.  For example PCS_NAD27_UTM_zone_3N.*/
93     short        PCS;
94 
95     /** From GeographicTypeGeoKey tag.  For example GCS_WGS_84 or
96         GCS_Voirol_1875_Paris.  Includes datum and prime meridian value. */
97     short        GCS;
98 
99     /** From ProjLinearUnitsGeoKey.  For example Linear_Meter. */
100     short        UOMLength;
101 
102     /** One UOMLength = UOMLengthInMeters meters. */
103     double        UOMLengthInMeters;
104 
105     /** The angular units of the GCS. */
106     short       UOMAngle;
107 
108     /** One UOMAngle = UOMLengthInDegrees degrees. */
109     double      UOMAngleInDegrees;
110 
111     /** Datum from GeogGeodeticDatumGeoKey tag. For example Datum_WGS84 */
112     short        Datum;
113 
114     /** Prime meridian from GeogPrimeMeridianGeoKey.  For example PM_Greenwich
115         or PM_Paris. */
116     short        PM;
117 
118     /** Decimal degrees of longitude between this prime meridian and
119         Greenwich.  Prime meridians to the west of Greenwich are negative. */
120     double        PMLongToGreenwich;
121 
122     /** Ellipsoid identifier from GeogELlipsoidGeoKey.  For example
123         Ellipse_Clarke_1866. */
124     short        Ellipsoid;
125 
126     /** The length of the semi major ellipse axis in meters. */
127     double        SemiMajor;
128 
129     /** The length of the semi minor ellipse axis in meters. */
130     double        SemiMinor;
131 
132     /** Projection id from ProjectionGeoKey.  For example Proj_UTM_11S. */
133     short        ProjCode;
134 
135     /** EPSG identifier for underlying projection method.  From the EPSG
136         TRF_METHOD table.  */
137     short        Projection;
138 
139     /** GeoTIFF identifier for underlying projection method.  While some of
140       these values have corresponding vlaues in EPSG (Projection field),
141       others do not.  For example CT_TransverseMercator. */
142     short        CTProjection;
143 
144     /** Number of projection parameters in ProjParm and ProjParmId. */
145     int                nParms;
146 
147     /** Projection parameter value.  The identify of this parameter
148         is established from the corresponding entry in ProjParmId.  The
149         value will be measured in meters, or decimal degrees if it is a
150         linear or angular measure. */
151     double        ProjParm[MAX_GTIF_PROJPARMS];
152 
153     /** Projection parameter identifier.  For example ProjFalseEastingGeoKey.
154         The value will be 0 for unused table entries. */
155     int                ProjParmId[MAX_GTIF_PROJPARMS]; /* geokey identifier,
156                                                    eg. ProjFalseEastingGeoKey*/
157 
158     /** Special zone map system code (MapSys_UTM_South, MapSys_UTM_North,
159         MapSys_State_Plane or KvUserDefined if none apply. */
160     int                MapSys;
161 
162     /** UTM, or State Plane Zone number, zero if not known. */
163     int                Zone;
164 
165 } GTIFDefn;
166 
167 int CPL_DLL GTIFGetPCSInfo( int nPCSCode, char **ppszEPSGName,
168                             short *pnProjOp,
169                             short *pnUOMLengthCode, short *pnGeogCS );
170 int CPL_DLL GTIFGetProjTRFInfo( int nProjTRFCode,
171                                 char ** ppszProjTRFName,
172                                 short * pnProjMethod,
173                                 double * padfProjParms );
174 int CPL_DLL GTIFGetGCSInfo( int nGCSCode, char **ppszName,
175                             short *pnDatum, short *pnPM, short *pnUOMAngle );
176 int CPL_DLL GTIFGetDatumInfo( int nDatumCode, char **ppszName,
177                               short * pnEllipsoid );
178 int CPL_DLL GTIFGetEllipsoidInfo( int nEllipsoid, char ** ppszName,
179                                   double * pdfSemiMajor,
180                                   double * pdfSemiMinor );
181 int CPL_DLL GTIFGetPMInfo( int nPM, char **ppszName,
182                            double * pdfLongToGreenwich );
183 
184 double CPL_DLL GTIFAngleStringToDD( const char *pszAngle, int nUOMAngle );
185 int CPL_DLL GTIFGetUOMLengthInfo( int nUOMLengthCode,
186                                   char **ppszUOMName,
187                                   double * pdfInMeters );
188 int CPL_DLL GTIFGetUOMAngleInfo( int nUOMAngleCode,
189                                  char **ppszUOMName,
190                                  double * pdfInDegrees );
191 double CPL_DLL GTIFAngleToDD( double dfAngle, int nUOMAngle );
192 
193 
194 /* this should be used to free strings returned by GTIFGet... funcs */
195 void CPL_DLL GTIFFreeMemory( char * );
196 void CPL_DLL GTIFDeaccessCSV( void );
197 
198 int CPL_DLL GTIFGetDefn( GTIF *psGTIF, GTIFDefn * psDefn );
199 void CPL_DLL GTIFPrintDefn( GTIFDefn *, FILE * );
200 void CPL_DLL GTIFFreeDefn( GTIF * );
201 
202 void CPL_DLL SetCSVFilenameHook( const char *(*CSVFileOverride)(const char *) );
203 
204 const char CPL_DLL *GTIFDecToDMS( double, const char *, int );
205 
206 /*
207  * These are useful for recognising UTM and State Plane, with or without
208  * CSV files being found.
209  */
210 
211 #define MapSys_UTM_North        -9001
212 #define MapSys_UTM_South        -9002
213 #define MapSys_State_Plane_27        -9003
214 #define MapSys_State_Plane_83        -9004
215 
216 int CPL_DLL   GTIFMapSysToPCS( int MapSys, int Datum, int nZone );
217 int CPL_DLL   GTIFMapSysToProj( int MapSys, int nZone );
218 int CPL_DLL   GTIFPCSToMapSys( int PCSCode, int * pDatum, int * pZone );
219 int CPL_DLL   GTIFProjToMapSys( int ProjCode, int * pZone );
220 
221 /*
222  * These are only useful if using libgeotiff with libproj (PROJ.4+).
223  */
224 char CPL_DLL *GTIFGetProj4Defn( GTIFDefn * );
225 int  CPL_DLL  GTIFProj4ToLatLong( GTIFDefn *, int, double *, double * );
226 int  CPL_DLL  GTIFProj4FromLatLong( GTIFDefn *, int, double *, double * );
227 
228 #if defined(HAVE_LIBPROJ) && defined(HAVE_PROJECTS_H)
229 #  define HAVE_GTIFPROJ4
230 #endif
231 
232 #ifdef __cplusplus
233 }
234 #endif
235 
236 #endif /* ndef GEO_NORMALIZE_H_INCLUDED */
237