1 /**********************************************************************
2  * $Id: geoconcept_syscoord.h
3  *
4  * Name:     geoconcept_syscoord.h
5  * Project:  OpenGIS Simple Features Reference Implementation
6  * Purpose:  Implements translation between Geoconcept SysCoord
7  *           and OGRSpatialRef format
8  * Language: C
9  *
10  **********************************************************************
11  * Copyright (c) 2007,  Geoconcept and IGN
12  * Copyright (c) 2008, Even Rouault <even dot rouault at mines-paris dot org>
13  *
14  * Permission is hereby granted, free of charge, to any person obtaining a
15  * copy of this software and associated documentation files (the "Software"),
16  * to deal in the Software without restriction, including without limitation
17  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18  * and/or sell copies of the Software, and to permit persons to whom the
19  * Software is furnished to do so, subject to the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be included
22  * in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
27  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30  * DEALINGS IN THE SOFTWARE.
31  **********************************************************************/
32 #ifndef _GEOCONCEPT_SYSCOORD_H_INCLUDED
33 #define _GEOCONCEPT_SYSCOORD_H_INCLUDED
34 
35 #include "ogr_srs_api.h"
36 
37 #ifdef GCSRS_DLLEXPORT
38 #  define GCSRSAPI_CALL     __declspec(dllexport)
39 #  define GCSRSAPI_CALL1(x) __declspec(dllexport) x
40 #endif
41 
42 #ifndef GCSRSAPI_CALL
43 #  define GCSRSAPI_CALL
44 #endif
45 
46 #ifndef GCSRSAPI_CALL1
47 #  define GCSRSAPI_CALL1(x) x GCSRSAPI_CALL
48 #endif
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 /* -------------------------------------------------------------------- */
55 /*      GCSRS API Types                                                 */
56 /* -------------------------------------------------------------------- */
57 typedef struct _tSpheroidInfo_GCSRS GCSpheroidInfo;
58 typedef struct _tDatumInfo_GCSRS GCDatumInfo;
59 typedef struct _tProjectionInfo_GCSRS GCProjectionInfo;
60 typedef struct _tSysCoord_GCSRS GCSysCoord;
61 
62 struct _tSpheroidInfo_GCSRS {
63   const char *pszSpheroidName;
64   double      dfA; /* semi major axis in meters */
65   double      dfE; /* excentricity */
66   int         nEllipsoidID;
67 };
68 
69 struct _tDatumInfo_GCSRS {
70   const char *pszDatumName;
71   double      dfShiftX;
72   double      dfShiftY;
73   double      dfShiftZ;
74   double      dfRotX;
75   double      dfRotY;
76   double      dfRotZ;
77   double      dfScaleFactor;
78   double      dfDiffA; /*
79                         * semi-major difference to-datum minus from-datum :
80                         * http://home.hiwaay.net/~taylorc/bookshelf/math-science/geodesy/datum/transform/molodensky/
81                         */
82   double      dfDiffFlattening; /*
83                                  * Change in flattening : "to" minus "from"
84                                  */
85   int         nEllipsoidID;
86   int         nDatumID;
87 };
88 
89 struct _tProjectionInfo_GCSRS {
90   const char *pszProjName;
91   int         nSphere;/*
92                        * 1 = sphere de courbure
93                        * 2 = sphere equatoriale
94                        * 3 = sphere bitangeante
95                        * 4 = sphere polaire nord
96                        * 5 = sphere polaire sud
97                        * 6 = Hotine
98                        */
99   int         nProjID;
100 };
101 
102 struct _tSysCoord_GCSRS {
103   char   *pszSysCoordName;
104   char   *pszUnit;
105 
106   double  dfPM;
107   /* inherited : */
108   double  dfLambda0;
109   double  dfPhi0;
110   double  dfk0;
111   double  dfX0;
112   double  dfY0;
113   double  dfPhi1;
114   double  dfPhi2;
115 
116   int     nDatumID;
117   int     nProjID;
118   int     coordSystemID;
119   int     timeZoneValue;/* when 0, replace by zone */
120 };
121 
122 /* -------------------------------------------------------------------- */
123 /*      GCSRS API Prototypes                                            */
124 /* -------------------------------------------------------------------- */
125 
126 #define GetInfoSpheroidID_GCSRS(theSpheroid)              (theSpheroid)->nEllipsoidID
127 #define GetInfoSpheroidName_GCSRS(theSpheroid)            (theSpheroid)->pszSpheroidName
128 #define GetInfoSpheroidSemiMajor_GCSRS(theSpheroid)       (theSpheroid)->dfA
129 #define GetInfoSpheroidExcentricity_GCSRS(theSpheroid)    (theSpheroid)->dfE
130 
131 #define GetInfoDatumID_GCSRS(theDatum)                    (theDatum)->nDatumID
132 #define GetInfoDatumName_GCSRS(theDatum)                  (theDatum)->pszDatumName
133 #define GetInfoDatumShiftX_GCSRS(theDatum)                (theDatum)->dfShiftX
134 #define GetInfoDatumShiftY_GCSRS(theDatum)                (theDatum)->dfShiftY
135 #define GetInfoDatumShiftZ_GCSRS(theDatum)                (theDatum)->dfShiftZ
136 #define GetInfoDatumDiffA_GCSRS(theDatum)                 (theDatum)->dfDiffA
137 #define GetInfoDatumRotationX_GCSRS(theDatum)             (theDatum)->dfRotX
138 #define GetInfoDatumRotationY_GCSRS(theDatum)             (theDatum)->dfRotY
139 #define GetInfoDatumRotationZ_GCSRS(theDatum)             (theDatum)->dfRotZ
140 #define GetInfoDatumScaleFactor_GCSRS(theDatum)           (theDatum)->dfScaleFactor
141 #define GetInfoDatumDiffFlattening_GCSRS(theDatum)        (theDatum)->dfDiffFlattening
142 #define GetInfoDatumSpheroidID_GCSRS(theDatum)            (theDatum)->nEllipsoidID
143 
144 #define GetInfoProjID_GCSRS(theProj)                      (theProj)->nProjID
145 #define GetInfoProjName_GCSRS(theProj)                    (theProj)->pszProjName
146 #define GetInfoProjSphereType_GCSRS(theProj)              (theProj)->nSphere
147 #define GetInfoProjSpheroidID_GCSRS(theProj)              (theProj)->nEllipsoidID
148 
149 GCSysCoord GCSRSAPI_CALL1(*) CreateSysCoord_GCSRS ( int srsid, int timezone );
150 void GCSRSAPI_CALL DestroySysCoord_GCSRS ( GCSysCoord** theSysCoord );
151 #define GetSysCoordSystemID_GCSRS(theSysCoord)            (theSysCoord)->coordSystemID
152 #define SetSysCoordSystemID_GCSRS(theSysCoord,v)          (theSysCoord)->coordSystemID= (v)
153 #define GetSysCoordTimeZone_GCSRS(theSysCoord)            (theSysCoord)->timeZoneValue
154 #define SetSysCoordTimeZone_GCSRS(theSysCoord,v)          (theSysCoord)->timeZoneValue= (v)
155 #define GetSysCoordName_GCSRS(theSysCoord)                (theSysCoord)->pszSysCoordName
156 #define SetSysCoordName_GCSRS(theSysCoord,v)              (theSysCoord)->pszSysCoordName= (v)
157 #define GetSysCoordUnit_GCSRS(theSysCoord)                (theSysCoord)->pszUnit
158 #define SetSysCoordUnit_GCSRS(theSysCoord,v)              (theSysCoord)->pszUnit= (v)
159 #define GetSysCoordPrimeMeridian_GCSRS(theSysCoord)       (theSysCoord)->dfPM
160 #define SetSysCoordPrimeMeridian_GCSRS(theSysCoord,v)     (theSysCoord)->dfPM= (v)
161 #define GetSysCoordCentralMeridian_GCSRS(theSysCoord)     (theSysCoord)->dfLambda0
162 #define SetSysCoordCentralMeridian_GCSRS(theSysCoord,v)   (theSysCoord)->dfLambda0= (v)
163 #define GetSysCoordLatitudeOfOrigin_GCSRS(theSysCoord)    (theSysCoord)->dfPhi0
164 #define SetSysCoordLatitudeOfOrigin_GCSRS(theSysCoord,v)  (theSysCoord)->dfPhi0= (v)
165 #define GetSysCoordStandardParallel1_GCSRS(theSysCoord)   (theSysCoord)->dfPhi1
166 #define SetSysCoordStandardParallel1_GCSRS(theSysCoord,v) (theSysCoord)->dfPhi1= (v)
167 #define GetSysCoordStandardParallel2_GCSRS(theSysCoord)   (theSysCoord)->dfPhi2
168 #define SetSysCoordStandardParallel2_GCSRS(theSysCoord,v) (theSysCoord)->dfPhi2= (v)
169 #define GetSysCoordScaleFactor_GCSRS(theSysCoord)         (theSysCoord)->dfk0
170 #define SetSysCoordScaleFactor_GCSRS(theSysCoord,v)       (theSysCoord)->dfk0= (v)
171 #define GetSysCoordFalseEasting_GCSRS(theSysCoord)        (theSysCoord)->dfX0
172 #define SetSysCoordFalseEasting_GCSRS(theSysCoord,v)      (theSysCoord)->dfX0= (v)
173 #define GetSysCoordFalseNorthing_GCSRS(theSysCoord)       (theSysCoord)->dfY0
174 #define SetSysCoordFalseNorthing_GCSRS(theSysCoord,v)     (theSysCoord)->dfY0= (v)
175 #define GetSysCoordDatumID_GCSRS(theSysCoord)             (theSysCoord)->nDatumID
176 #define SetSysCoordDatumID_GCSRS(theSysCoord,v)           (theSysCoord)->nDatumID= (v)
177 #define GetSysCoordProjID_GCSRS(theSysCoord)              (theSysCoord)->nProjID
178 #define SetSysCoordProjID_GCSRS(theSysCoord,v)            (theSysCoord)->nProjID= (v)
179 
180 GCSysCoord GCSRSAPI_CALL1(*) OGRSpatialReference2SysCoord_GCSRS ( OGRSpatialReferenceH poSR );
181 OGRSpatialReferenceH GCSRSAPI_CALL SysCoord2OGRSpatialReference_GCSRS ( GCSysCoord* syscoord );
182 
183 #ifdef __cplusplus
184 }
185 #endif
186 
187 
188 #endif /* ndef _GEOCONCEPT_SYSCOORD_H_INCLUDED */
189