lambert_ruby 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/lambert_ruby/lambert.c +183 -51
- data/ext/lambert_ruby/lambert.h +25 -20
- data/ext/lambert_ruby/lambert/src/lambert.c +183 -51
- data/ext/lambert_ruby/lambert/src/lambert.h +25 -20
- data/ext/lambert_ruby/lambert/src/rgf93.c +36 -21
- data/ext/lambert_ruby/lambert/src/rgf93.h +9 -2
- data/ext/lambert_ruby/lambert/tests/test_lambert_cunit.c +98 -50
- data/ext/lambert_ruby/lambert_ruby.c +6 -7
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 900b0dd2218561188f32fd7f9395b3aa3c410af8
|
4
|
+
data.tar.gz: 0d7cd916c3805017fe7487daf9ce18a2c3e3cc25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8c387e9da5afad324b67d74769afa5a1fbfada0da0d275d9b9ae950db9152098c5f2207061407fbb3d4db5f9ba305676a0b91aab62f39fc1e6bd382a43bf335
|
7
|
+
data.tar.gz: 9e0250d316f5fece7acdcb243fb96b7d3cb0684ca29266cdbeff5ce33898b52db81c3467e014822b41b32ec7ac864c895ff3d7ed1e2254ad2b9d894f8c84dce8
|
data/ext/lambert_ruby/lambert.c
CHANGED
@@ -7,36 +7,167 @@
|
|
7
7
|
#include <math.h>
|
8
8
|
#include <stdio.h>
|
9
9
|
|
10
|
-
#define RAD_TO_DEG(x) x*180/M_PI
|
11
|
-
|
12
|
-
#define DISPLAY_YGLambertPoint(YGLambertPoint) printf(#YGLambertPoint" X:%f | Y:%f | Z:%f\n",YGLambertPoint.x,YGLambertPoint.y,YGLambertPoint.z);
|
13
|
-
#define DISPLAY_YGLambertPoint_REF(YGLambertPoint) printf(#YGLambertPoint" X:%f | Y:%f | Z:%f\n",YGLambertPoint->x,YGLambertPoint->y,YGLambertPoint->z);
|
14
10
|
|
15
11
|
static double lambert_n[6] = {0.7604059656, 0.7289686274, 0.6959127966, 0.6712679322, 0.7289686274, 0.7256077650};
|
16
12
|
static double lambert_c[6] = {11603796.98, 11745793.39, 11947992.52, 12136281.99, 11745793.39, 11754255.426};
|
17
13
|
static double lambert_xs[6]= {600000.0, 600000.0, 600000.0, 234.358, 600000.0, 700000.0};
|
18
14
|
static double lambert_ys[6]= {5657616.674, 6199695.768, 6791905.085, 7239161.542, 8199695.768, 12655612.050};
|
19
15
|
|
20
|
-
YGPoint
|
16
|
+
YGPoint __YGDegreeToRadian(YGPoint pt)
|
17
|
+
{
|
18
|
+
pt.x = pt.x * M_PI / 180.0;
|
19
|
+
pt.y = pt.y * M_PI / 180.0;
|
20
|
+
pt.z = pt.z * M_PI / 180.0;
|
21
|
+
|
22
|
+
pt.unit = RADIAN;
|
23
|
+
|
24
|
+
return pt;
|
25
|
+
}
|
26
|
+
|
27
|
+
YGPoint __YGRadianToDegree(YGPoint pt)
|
28
|
+
{
|
29
|
+
pt.x = pt.x * 180/ M_PI;
|
30
|
+
pt.y = pt.y * 180/ M_PI;
|
31
|
+
pt.z = pt.z * 180/ M_PI;
|
32
|
+
|
33
|
+
pt.unit = DEGREE;
|
34
|
+
|
35
|
+
return pt;
|
36
|
+
}
|
37
|
+
|
38
|
+
YGPoint __YGGradToRadian(YGPoint pt)
|
39
|
+
{
|
40
|
+
pt.x = pt.x * M_PI/200.0;
|
41
|
+
pt.y = pt.y * M_PI/200.0;
|
42
|
+
pt.z = pt.z * M_PI/200.0;
|
43
|
+
|
44
|
+
pt.unit = RADIAN;
|
45
|
+
|
46
|
+
return pt;
|
47
|
+
}
|
48
|
+
YGPoint __YGRadianToGrad(YGPoint pt)
|
49
|
+
{
|
50
|
+
pt.x = pt.x * 200.0/M_PI;
|
51
|
+
pt.y = pt.y * 200.0/M_PI;
|
52
|
+
pt.z = pt.z * 200.0/M_PI;
|
53
|
+
|
54
|
+
pt.unit = GRAD;
|
55
|
+
|
56
|
+
return pt;
|
57
|
+
}
|
58
|
+
|
59
|
+
YGPoint __YGGradToDegree(YGPoint pt)
|
60
|
+
{
|
61
|
+
pt.x = pt.x * 180.0/200.0;
|
62
|
+
pt.y = pt.y * 180.0/200.0;
|
63
|
+
pt.z = pt.z * 180.0/200.0;
|
64
|
+
|
65
|
+
pt.unit = DEGREE;
|
66
|
+
|
67
|
+
return pt;
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
YGPoint __YGDegreeToGrad(YGPoint pt)
|
72
|
+
{
|
73
|
+
pt.x = pt.x * 200.0/180.0;
|
74
|
+
pt.y = pt.y * 200.0/180.0;
|
75
|
+
pt.z = pt.z * 200.0/180.0;
|
76
|
+
|
77
|
+
pt.unit = GRAD;
|
78
|
+
|
79
|
+
return pt;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
YGPoint YGPointToDegree(YGPoint pt)
|
21
84
|
{
|
22
|
-
|
23
|
-
p.x = p.x * 180/M_PI;
|
24
|
-
p.y = p.y * 180/M_PI;
|
25
|
-
p.z = p.z * 180/M_PI;
|
26
85
|
|
27
|
-
|
86
|
+
switch (pt.unit)
|
87
|
+
{
|
88
|
+
case RADIAN :
|
89
|
+
{
|
90
|
+
pt = __YGRadianToDegree(pt);
|
91
|
+
}
|
92
|
+
break;
|
93
|
+
case GRAD :
|
94
|
+
{
|
95
|
+
pt = __YGGradToDegree(pt);
|
96
|
+
}
|
97
|
+
break;
|
98
|
+
default:
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
|
102
|
+
return pt;
|
103
|
+
|
28
104
|
}
|
29
105
|
|
30
|
-
|
106
|
+
|
107
|
+
YGPoint YGPointToRadian(YGPoint pt)
|
31
108
|
{
|
32
|
-
|
33
|
-
|
34
|
-
|
109
|
+
switch (pt.unit)
|
110
|
+
{
|
111
|
+
case DEGREE :
|
112
|
+
{
|
113
|
+
pt = __YGDegreeToRadian(pt);
|
114
|
+
}
|
115
|
+
break;
|
116
|
+
case GRAD :
|
117
|
+
{
|
118
|
+
pt = __YGGradToRadian(pt);
|
119
|
+
}
|
120
|
+
break;
|
121
|
+
default:
|
122
|
+
break;
|
123
|
+
}
|
35
124
|
|
36
|
-
return
|
125
|
+
return pt;
|
37
126
|
}
|
38
127
|
|
39
|
-
|
128
|
+
YGPoint YGPointToGrad(YGPoint pt)
|
129
|
+
{
|
130
|
+
switch (pt.unit)
|
131
|
+
{
|
132
|
+
case RADIAN :
|
133
|
+
{
|
134
|
+
pt = __YGRadianToGrad(pt);
|
135
|
+
}
|
136
|
+
break;
|
137
|
+
case DEGREE :
|
138
|
+
{
|
139
|
+
pt = __YGDegreeToGrad(pt);
|
140
|
+
}
|
141
|
+
break;
|
142
|
+
default:
|
143
|
+
break;
|
144
|
+
}
|
145
|
+
|
146
|
+
return pt;
|
147
|
+
}
|
148
|
+
|
149
|
+
YGPoint YGPointToUnit(YGPoint point, CoordUnit unit)
|
150
|
+
{
|
151
|
+
switch (unit) {
|
152
|
+
case DEGREE:
|
153
|
+
return YGPointToDegree(point);
|
154
|
+
break;
|
155
|
+
case GRAD:
|
156
|
+
return YGPointToGrad(point);
|
157
|
+
case RADIAN :
|
158
|
+
return YGPointToDegree(point);
|
159
|
+
break;
|
160
|
+
default:
|
161
|
+
return point;
|
162
|
+
break;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
/*****************
|
167
|
+
** IGN algorithms
|
168
|
+
*****************/
|
169
|
+
|
170
|
+
double __YGLatitudeISOFromLatitude(double lat, double e)
|
40
171
|
{
|
41
172
|
return log(tan(M_PI_4+lat/2)*pow((1-e*sin(lat))/(1+e*sin(lat)),e/2));
|
42
173
|
}
|
@@ -45,7 +176,7 @@ double latitude_iso_from_lat(double lat, double e)
|
|
45
176
|
* ALGO0002
|
46
177
|
*/
|
47
178
|
|
48
|
-
double
|
179
|
+
double __YGLatitudeFromLatitudeISO(double lat_iso, double e,double eps)
|
49
180
|
{
|
50
181
|
|
51
182
|
double phi_0 = 2*atan(exp(lat_iso)) - M_PI_2;
|
@@ -64,15 +195,15 @@ double lat_from_lat_iso(double lat_iso, double e,double eps)
|
|
64
195
|
* ALGO0004 - Lambert vers geographiques
|
65
196
|
*/
|
66
197
|
|
67
|
-
|
198
|
+
YGPoint __YGLambertToGeographic(YGPoint org, YGLambertZone zone, double lon_merid, double e, double eps)
|
68
199
|
{
|
69
200
|
double n = lambert_n[zone];
|
70
201
|
double C = lambert_c[zone];
|
71
202
|
double x_s = lambert_xs[zone];
|
72
203
|
double y_s = lambert_ys[zone];
|
73
204
|
|
74
|
-
double x = org
|
75
|
-
double y = org
|
205
|
+
double x = org.x;
|
206
|
+
double y = org.y;
|
76
207
|
|
77
208
|
double lon, gamma, R, lat_iso;
|
78
209
|
|
@@ -84,10 +215,12 @@ void lambert_to_geographic(const YGPoint * org,YGPoint *dest, YGLambertZone zone
|
|
84
215
|
|
85
216
|
lat_iso = -1/n*log(fabs(R/C));
|
86
217
|
|
87
|
-
double lat =
|
218
|
+
double lat = __YGLatitudeFromLatitudeISO(lat_iso,e,eps);
|
88
219
|
|
89
|
-
|
90
|
-
|
220
|
+
org.x = lon;
|
221
|
+
org.y = lat;
|
222
|
+
|
223
|
+
return org;
|
91
224
|
}
|
92
225
|
|
93
226
|
|
@@ -96,7 +229,7 @@ void lambert_to_geographic(const YGPoint * org,YGPoint *dest, YGLambertZone zone
|
|
96
229
|
*
|
97
230
|
*/
|
98
231
|
|
99
|
-
double
|
232
|
+
double __YGLambertNormal(double lat, double a, double e)
|
100
233
|
{
|
101
234
|
|
102
235
|
return a/sqrt(1-e*e*sin(lat)*sin(lat));
|
@@ -108,9 +241,9 @@ double lambert_normal(double lat, double a, double e)
|
|
108
241
|
*
|
109
242
|
*/
|
110
243
|
|
111
|
-
YGPoint
|
244
|
+
YGPoint __YGGeographicToCartesian(double lon, double lat, double he, double a, double e)
|
112
245
|
{
|
113
|
-
double N =
|
246
|
+
double N = __YGLambertNormal(lat,a,e);
|
114
247
|
|
115
248
|
YGPoint pt = {0,0,0};
|
116
249
|
pt.x = (N+he)*cos(lat)*cos(lon);
|
@@ -127,7 +260,7 @@ double lambert_normal(double lat, double a, double e)
|
|
127
260
|
* ALGO0012 - Passage des coordonnées cartésiennes aux coordonnées géographiques
|
128
261
|
*/
|
129
262
|
|
130
|
-
YGPoint
|
263
|
+
YGPoint __YGCartesianToGeographic(YGPoint org, double meridien, double a, double e , double eps)
|
131
264
|
{
|
132
265
|
double x = org.x, y = org.y, z = org.z;
|
133
266
|
|
@@ -150,7 +283,8 @@ double lambert_normal(double lat, double a, double e)
|
|
150
283
|
YGPoint pt;
|
151
284
|
pt.x = lon;
|
152
285
|
pt.y = phi_i;
|
153
|
-
pt.z = he;
|
286
|
+
pt.z = he;
|
287
|
+
pt.unit = RADIAN;
|
154
288
|
|
155
289
|
return pt;
|
156
290
|
}
|
@@ -161,50 +295,48 @@ double lambert_normal(double lat, double a, double e)
|
|
161
295
|
*
|
162
296
|
*/
|
163
297
|
|
164
|
-
|
298
|
+
YGPoint YGPointConvertWGS84(YGPoint point, YGLambertZone zone){
|
165
299
|
|
300
|
+
if(point.unit != METER)
|
301
|
+
{
|
302
|
+
perror("Could not operate on a non METER based point!\n The points returned will be the same!\n");
|
303
|
+
return point;
|
304
|
+
}
|
166
305
|
|
167
|
-
|
168
306
|
if(LAMBERT_93 == zone)
|
169
307
|
{
|
170
|
-
|
308
|
+
point = __YGLambertToGeographic(point,zone,LON_MERID_IERS,E_WGS84,DEFAULT_EPS);
|
309
|
+
|
171
310
|
}
|
172
311
|
else
|
173
312
|
{
|
174
|
-
|
175
|
-
|
313
|
+
point = __YGLambertToGeographic(point,zone,LON_MERID_PARIS,E_CLARK_IGN,DEFAULT_EPS);
|
314
|
+
point = __YGGeographicToCartesian(point.x,point.y,point.z,A_CLARK_IGN,E_CLARK_IGN);
|
176
315
|
|
177
|
-
|
178
|
-
|
179
|
-
|
316
|
+
point.x-= 168;
|
317
|
+
point.y-= 60;
|
318
|
+
point.z+= 320;
|
180
319
|
|
181
320
|
//WGS84 refers to greenwich
|
182
|
-
|
183
|
-
|
184
|
-
dest->x = temp.x;
|
185
|
-
dest->y = temp.y;
|
321
|
+
point = __YGCartesianToGeographic(point, LON_MERID_GREENWICH, A_WGS84,E_WGS84,DEFAULT_EPS);
|
186
322
|
}
|
323
|
+
|
324
|
+
point.unit = RADIAN;
|
325
|
+
return point;
|
187
326
|
}
|
188
327
|
|
189
328
|
|
190
|
-
void lambert_to_wgs84_deg(const YGPoint * org, YGPoint *dest, YGLambertZone zone)
|
191
|
-
{
|
192
|
-
YGPoint temp = {0,0,0};
|
193
|
-
|
194
|
-
lambert_to_wgs84(org,&temp,zone);
|
195
|
-
*dest = pointToDegree(temp);
|
196
|
-
}
|
197
329
|
|
198
|
-
double
|
330
|
+
double __YGLatitudeISO(double lat, double e)
|
199
331
|
{
|
200
332
|
return log(tan(M_PI_4 + lat/2)*pow((1-e*sin(lat))/(1+e*sin(lat)),e/2));
|
201
333
|
}
|
202
334
|
|
203
|
-
YGPoint
|
335
|
+
YGPoint __YGCoordinatesTransform(double e, double n, double c, double lambda_c, double x_s, double y_s , double lon, double lat)
|
204
336
|
{
|
205
337
|
YGPoint dest = {0,0,0};
|
206
338
|
|
207
|
-
double latiso =
|
339
|
+
double latiso = __YGLatitudeISO(lat,e);
|
208
340
|
dest.x = x_s + e*exp(-n*latiso)*sin(n*(lon-lambda_c));
|
209
341
|
dest.y = y_s + e*exp(n*latiso)*cos(n*(lon-lambda_c));
|
210
342
|
|
@@ -212,7 +344,7 @@ YGPoint coord_transform(double e, double n, double c, double lambda_c, double x_
|
|
212
344
|
|
213
345
|
}
|
214
346
|
|
215
|
-
YGPoint
|
347
|
+
YGPoint __YGSwitchGeodesicSystem(YGPoint u, Vector t, double d, Vector r)
|
216
348
|
{
|
217
349
|
YGPoint v = {0,0,0};
|
218
350
|
|
data/ext/lambert_ruby/lambert.h
CHANGED
@@ -18,8 +18,6 @@
|
|
18
18
|
#define ct_x0 700000.0
|
19
19
|
#define ct_y0 6600000.0
|
20
20
|
|
21
|
-
#define DISPLAY_YGPoint(YGPoint) printf(#YGPoint" X:%f | Y:%f | Z:%f\n",YGPoint.x,YGPoint.y,YGPoint.z);
|
22
|
-
#define DISPLAY_YGPoint_REF(YGPoint) printf(#YGPoint" X:%f | Y:%f | Z:%f\n",YGPoint->x,YGPoint->y,YGPoint->z);
|
23
21
|
|
24
22
|
typedef enum {
|
25
23
|
LAMBERT_I=0,
|
@@ -33,7 +31,8 @@ typedef enum {
|
|
33
31
|
typedef enum {
|
34
32
|
DEGREE,
|
35
33
|
GRAD,
|
36
|
-
RADIAN
|
34
|
+
RADIAN,
|
35
|
+
METER
|
37
36
|
} CoordUnit;
|
38
37
|
|
39
38
|
typedef struct {
|
@@ -52,43 +51,49 @@ typedef struct
|
|
52
51
|
|
53
52
|
typedef YGPoint Vector;
|
54
53
|
|
55
|
-
|
56
|
-
|
54
|
+
#define __YGPointWithUnit(_x,_y,_z,_unit) {.x=_x, .y=_y,.z=_z,.unit=_unit};
|
55
|
+
|
56
|
+
#define YGDegreePoint(x,y,z) __YGPointWithUnit(x,y,z,DEGREE)
|
57
|
+
#define YGRadianPoint(x,y,z) __YGPointWithUnit(x,y,z,RADIAN)
|
58
|
+
#define YGGradPoint(x,y,z) __YGPointWithUnit(x,y,z,GRAD)
|
59
|
+
#define YGMeterPoint(x,y,z) __YGPointWithUnit(x,y,z,METER)
|
60
|
+
|
61
|
+
|
62
|
+
YGPoint YGPointToRadian(YGPoint p);
|
63
|
+
YGPoint YGPointToDegree(YGPoint p);
|
64
|
+
YGPoint YGPointToGrad(YGPoint p);
|
65
|
+
YGPoint YGPointToUnit(YGPoint point, CoordUnit unit);
|
57
66
|
|
58
67
|
/*
|
59
68
|
* ALGO0021 - Calcul de la grande Normale
|
60
69
|
*
|
61
70
|
*/
|
62
|
-
double
|
71
|
+
double __YGLambertNormal(double lat, double a, double e);
|
63
72
|
|
64
73
|
/*
|
65
74
|
* Convert a YGPoint struct from one lambert zone to WGS84 (Rad)
|
66
75
|
*
|
67
76
|
*/
|
68
|
-
void lambert_to_wgs84(const YGPoint * org, YGPoint *dest, YGLambertZone zone);
|
69
77
|
|
70
|
-
|
71
|
-
|
72
|
-
*
|
73
|
-
*/
|
74
|
-
void lambert_to_wgs84_deg(const YGPoint * org, YGPoint *dest, YGLambertZone zone);
|
78
|
+
|
79
|
+
YGPoint YGPointConvertWGS84(YGPoint point, YGLambertZone zone);
|
75
80
|
|
76
81
|
/*
|
77
82
|
* ALGO0002
|
78
83
|
*/
|
79
84
|
|
80
|
-
double
|
85
|
+
double __YGLatitudeFromLatitudeISO(double lat_iso, double e, double eps);
|
81
86
|
|
82
87
|
/*
|
83
88
|
* ALGO0012
|
84
89
|
*/
|
85
90
|
|
86
|
-
YGPoint
|
91
|
+
YGPoint __YGCartesianToGeographic(YGPoint org, double meridien, double a, double e , double eps);
|
87
92
|
|
88
93
|
/*
|
89
94
|
* ALGO004
|
90
95
|
*/
|
91
|
-
|
96
|
+
YGPoint __YGLambertToGeographic(YGPoint org, YGLambertZone zone, double lon_merid, double e, double eps);
|
92
97
|
|
93
98
|
/**
|
94
99
|
* ALGO0009 - Transformations geographiques -> cartésiennes
|
@@ -96,26 +101,26 @@ void lambert_to_geographic(const YGPoint * org,YGPoint *dest, YGLambertZone zone
|
|
96
101
|
*
|
97
102
|
*/
|
98
103
|
|
99
|
-
YGPoint
|
104
|
+
YGPoint __YGGeographicToCartesian(double lon, double lat, double he, double a, double e);
|
100
105
|
|
101
106
|
/**
|
102
107
|
* ALGO13 Transformation de Coordonnées à 7 paramètres entre deux systèmes géodésiques
|
103
108
|
*/
|
104
109
|
|
105
|
-
YGPoint
|
110
|
+
YGPoint __YGSwitchGeodesicSystem(YGPoint u, Vector t, double d, Vector r);
|
106
111
|
|
107
112
|
/**
|
108
113
|
* Algo0001 Calcul de la latitude isomérique
|
109
114
|
*/
|
110
|
-
double
|
115
|
+
double __YGLatitudeISO(double lat, double e);
|
111
116
|
|
112
117
|
/**
|
113
118
|
* Algo003
|
114
119
|
*/
|
115
|
-
YGPoint
|
120
|
+
YGPoint __YGCoordinatesTransform(double e, double n, double c, double lambda_c, double x_s, double y_s , double lon, double lat);
|
116
121
|
|
117
122
|
/**
|
118
123
|
* Algo 01
|
119
124
|
*/
|
120
|
-
double
|
125
|
+
double __YGLatitudeISOFromLatitude(double lat, double e);
|
121
126
|
#endif
|
@@ -7,36 +7,167 @@
|
|
7
7
|
#include <math.h>
|
8
8
|
#include <stdio.h>
|
9
9
|
|
10
|
-
#define RAD_TO_DEG(x) x*180/M_PI
|
11
|
-
|
12
|
-
#define DISPLAY_YGLambertPoint(YGLambertPoint) printf(#YGLambertPoint" X:%f | Y:%f | Z:%f\n",YGLambertPoint.x,YGLambertPoint.y,YGLambertPoint.z);
|
13
|
-
#define DISPLAY_YGLambertPoint_REF(YGLambertPoint) printf(#YGLambertPoint" X:%f | Y:%f | Z:%f\n",YGLambertPoint->x,YGLambertPoint->y,YGLambertPoint->z);
|
14
10
|
|
15
11
|
static double lambert_n[6] = {0.7604059656, 0.7289686274, 0.6959127966, 0.6712679322, 0.7289686274, 0.7256077650};
|
16
12
|
static double lambert_c[6] = {11603796.98, 11745793.39, 11947992.52, 12136281.99, 11745793.39, 11754255.426};
|
17
13
|
static double lambert_xs[6]= {600000.0, 600000.0, 600000.0, 234.358, 600000.0, 700000.0};
|
18
14
|
static double lambert_ys[6]= {5657616.674, 6199695.768, 6791905.085, 7239161.542, 8199695.768, 12655612.050};
|
19
15
|
|
20
|
-
YGPoint
|
16
|
+
YGPoint __YGDegreeToRadian(YGPoint pt)
|
17
|
+
{
|
18
|
+
pt.x = pt.x * M_PI / 180.0;
|
19
|
+
pt.y = pt.y * M_PI / 180.0;
|
20
|
+
pt.z = pt.z * M_PI / 180.0;
|
21
|
+
|
22
|
+
pt.unit = RADIAN;
|
23
|
+
|
24
|
+
return pt;
|
25
|
+
}
|
26
|
+
|
27
|
+
YGPoint __YGRadianToDegree(YGPoint pt)
|
28
|
+
{
|
29
|
+
pt.x = pt.x * 180/ M_PI;
|
30
|
+
pt.y = pt.y * 180/ M_PI;
|
31
|
+
pt.z = pt.z * 180/ M_PI;
|
32
|
+
|
33
|
+
pt.unit = DEGREE;
|
34
|
+
|
35
|
+
return pt;
|
36
|
+
}
|
37
|
+
|
38
|
+
YGPoint __YGGradToRadian(YGPoint pt)
|
39
|
+
{
|
40
|
+
pt.x = pt.x * M_PI/200.0;
|
41
|
+
pt.y = pt.y * M_PI/200.0;
|
42
|
+
pt.z = pt.z * M_PI/200.0;
|
43
|
+
|
44
|
+
pt.unit = RADIAN;
|
45
|
+
|
46
|
+
return pt;
|
47
|
+
}
|
48
|
+
YGPoint __YGRadianToGrad(YGPoint pt)
|
49
|
+
{
|
50
|
+
pt.x = pt.x * 200.0/M_PI;
|
51
|
+
pt.y = pt.y * 200.0/M_PI;
|
52
|
+
pt.z = pt.z * 200.0/M_PI;
|
53
|
+
|
54
|
+
pt.unit = GRAD;
|
55
|
+
|
56
|
+
return pt;
|
57
|
+
}
|
58
|
+
|
59
|
+
YGPoint __YGGradToDegree(YGPoint pt)
|
60
|
+
{
|
61
|
+
pt.x = pt.x * 180.0/200.0;
|
62
|
+
pt.y = pt.y * 180.0/200.0;
|
63
|
+
pt.z = pt.z * 180.0/200.0;
|
64
|
+
|
65
|
+
pt.unit = DEGREE;
|
66
|
+
|
67
|
+
return pt;
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
YGPoint __YGDegreeToGrad(YGPoint pt)
|
72
|
+
{
|
73
|
+
pt.x = pt.x * 200.0/180.0;
|
74
|
+
pt.y = pt.y * 200.0/180.0;
|
75
|
+
pt.z = pt.z * 200.0/180.0;
|
76
|
+
|
77
|
+
pt.unit = GRAD;
|
78
|
+
|
79
|
+
return pt;
|
80
|
+
}
|
81
|
+
|
82
|
+
|
83
|
+
YGPoint YGPointToDegree(YGPoint pt)
|
21
84
|
{
|
22
|
-
|
23
|
-
p.x = p.x * 180/M_PI;
|
24
|
-
p.y = p.y * 180/M_PI;
|
25
|
-
p.z = p.z * 180/M_PI;
|
26
85
|
|
27
|
-
|
86
|
+
switch (pt.unit)
|
87
|
+
{
|
88
|
+
case RADIAN :
|
89
|
+
{
|
90
|
+
pt = __YGRadianToDegree(pt);
|
91
|
+
}
|
92
|
+
break;
|
93
|
+
case GRAD :
|
94
|
+
{
|
95
|
+
pt = __YGGradToDegree(pt);
|
96
|
+
}
|
97
|
+
break;
|
98
|
+
default:
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
|
102
|
+
return pt;
|
103
|
+
|
28
104
|
}
|
29
105
|
|
30
|
-
|
106
|
+
|
107
|
+
YGPoint YGPointToRadian(YGPoint pt)
|
31
108
|
{
|
32
|
-
|
33
|
-
|
34
|
-
|
109
|
+
switch (pt.unit)
|
110
|
+
{
|
111
|
+
case DEGREE :
|
112
|
+
{
|
113
|
+
pt = __YGDegreeToRadian(pt);
|
114
|
+
}
|
115
|
+
break;
|
116
|
+
case GRAD :
|
117
|
+
{
|
118
|
+
pt = __YGGradToRadian(pt);
|
119
|
+
}
|
120
|
+
break;
|
121
|
+
default:
|
122
|
+
break;
|
123
|
+
}
|
35
124
|
|
36
|
-
return
|
125
|
+
return pt;
|
37
126
|
}
|
38
127
|
|
39
|
-
|
128
|
+
YGPoint YGPointToGrad(YGPoint pt)
|
129
|
+
{
|
130
|
+
switch (pt.unit)
|
131
|
+
{
|
132
|
+
case RADIAN :
|
133
|
+
{
|
134
|
+
pt = __YGRadianToGrad(pt);
|
135
|
+
}
|
136
|
+
break;
|
137
|
+
case DEGREE :
|
138
|
+
{
|
139
|
+
pt = __YGDegreeToGrad(pt);
|
140
|
+
}
|
141
|
+
break;
|
142
|
+
default:
|
143
|
+
break;
|
144
|
+
}
|
145
|
+
|
146
|
+
return pt;
|
147
|
+
}
|
148
|
+
|
149
|
+
YGPoint YGPointToUnit(YGPoint point, CoordUnit unit)
|
150
|
+
{
|
151
|
+
switch (unit) {
|
152
|
+
case DEGREE:
|
153
|
+
return YGPointToDegree(point);
|
154
|
+
break;
|
155
|
+
case GRAD:
|
156
|
+
return YGPointToGrad(point);
|
157
|
+
case RADIAN :
|
158
|
+
return YGPointToDegree(point);
|
159
|
+
break;
|
160
|
+
default:
|
161
|
+
return point;
|
162
|
+
break;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
/*****************
|
167
|
+
** IGN algorithms
|
168
|
+
*****************/
|
169
|
+
|
170
|
+
double __YGLatitudeISOFromLatitude(double lat, double e)
|
40
171
|
{
|
41
172
|
return log(tan(M_PI_4+lat/2)*pow((1-e*sin(lat))/(1+e*sin(lat)),e/2));
|
42
173
|
}
|
@@ -45,7 +176,7 @@ double latitude_iso_from_lat(double lat, double e)
|
|
45
176
|
* ALGO0002
|
46
177
|
*/
|
47
178
|
|
48
|
-
double
|
179
|
+
double __YGLatitudeFromLatitudeISO(double lat_iso, double e,double eps)
|
49
180
|
{
|
50
181
|
|
51
182
|
double phi_0 = 2*atan(exp(lat_iso)) - M_PI_2;
|
@@ -64,15 +195,15 @@ double lat_from_lat_iso(double lat_iso, double e,double eps)
|
|
64
195
|
* ALGO0004 - Lambert vers geographiques
|
65
196
|
*/
|
66
197
|
|
67
|
-
|
198
|
+
YGPoint __YGLambertToGeographic(YGPoint org, YGLambertZone zone, double lon_merid, double e, double eps)
|
68
199
|
{
|
69
200
|
double n = lambert_n[zone];
|
70
201
|
double C = lambert_c[zone];
|
71
202
|
double x_s = lambert_xs[zone];
|
72
203
|
double y_s = lambert_ys[zone];
|
73
204
|
|
74
|
-
double x = org
|
75
|
-
double y = org
|
205
|
+
double x = org.x;
|
206
|
+
double y = org.y;
|
76
207
|
|
77
208
|
double lon, gamma, R, lat_iso;
|
78
209
|
|
@@ -84,10 +215,12 @@ void lambert_to_geographic(const YGPoint * org,YGPoint *dest, YGLambertZone zone
|
|
84
215
|
|
85
216
|
lat_iso = -1/n*log(fabs(R/C));
|
86
217
|
|
87
|
-
double lat =
|
218
|
+
double lat = __YGLatitudeFromLatitudeISO(lat_iso,e,eps);
|
88
219
|
|
89
|
-
|
90
|
-
|
220
|
+
org.x = lon;
|
221
|
+
org.y = lat;
|
222
|
+
|
223
|
+
return org;
|
91
224
|
}
|
92
225
|
|
93
226
|
|
@@ -96,7 +229,7 @@ void lambert_to_geographic(const YGPoint * org,YGPoint *dest, YGLambertZone zone
|
|
96
229
|
*
|
97
230
|
*/
|
98
231
|
|
99
|
-
double
|
232
|
+
double __YGLambertNormal(double lat, double a, double e)
|
100
233
|
{
|
101
234
|
|
102
235
|
return a/sqrt(1-e*e*sin(lat)*sin(lat));
|
@@ -108,9 +241,9 @@ double lambert_normal(double lat, double a, double e)
|
|
108
241
|
*
|
109
242
|
*/
|
110
243
|
|
111
|
-
YGPoint
|
244
|
+
YGPoint __YGGeographicToCartesian(double lon, double lat, double he, double a, double e)
|
112
245
|
{
|
113
|
-
double N =
|
246
|
+
double N = __YGLambertNormal(lat,a,e);
|
114
247
|
|
115
248
|
YGPoint pt = {0,0,0};
|
116
249
|
pt.x = (N+he)*cos(lat)*cos(lon);
|
@@ -127,7 +260,7 @@ double lambert_normal(double lat, double a, double e)
|
|
127
260
|
* ALGO0012 - Passage des coordonnées cartésiennes aux coordonnées géographiques
|
128
261
|
*/
|
129
262
|
|
130
|
-
YGPoint
|
263
|
+
YGPoint __YGCartesianToGeographic(YGPoint org, double meridien, double a, double e , double eps)
|
131
264
|
{
|
132
265
|
double x = org.x, y = org.y, z = org.z;
|
133
266
|
|
@@ -150,7 +283,8 @@ double lambert_normal(double lat, double a, double e)
|
|
150
283
|
YGPoint pt;
|
151
284
|
pt.x = lon;
|
152
285
|
pt.y = phi_i;
|
153
|
-
pt.z = he;
|
286
|
+
pt.z = he;
|
287
|
+
pt.unit = RADIAN;
|
154
288
|
|
155
289
|
return pt;
|
156
290
|
}
|
@@ -161,50 +295,48 @@ double lambert_normal(double lat, double a, double e)
|
|
161
295
|
*
|
162
296
|
*/
|
163
297
|
|
164
|
-
|
298
|
+
YGPoint YGPointConvertWGS84(YGPoint point, YGLambertZone zone){
|
165
299
|
|
300
|
+
if(point.unit != METER)
|
301
|
+
{
|
302
|
+
perror("Could not operate on a non METER based point!\n The points returned will be the same!\n");
|
303
|
+
return point;
|
304
|
+
}
|
166
305
|
|
167
|
-
|
168
306
|
if(LAMBERT_93 == zone)
|
169
307
|
{
|
170
|
-
|
308
|
+
point = __YGLambertToGeographic(point,zone,LON_MERID_IERS,E_WGS84,DEFAULT_EPS);
|
309
|
+
|
171
310
|
}
|
172
311
|
else
|
173
312
|
{
|
174
|
-
|
175
|
-
|
313
|
+
point = __YGLambertToGeographic(point,zone,LON_MERID_PARIS,E_CLARK_IGN,DEFAULT_EPS);
|
314
|
+
point = __YGGeographicToCartesian(point.x,point.y,point.z,A_CLARK_IGN,E_CLARK_IGN);
|
176
315
|
|
177
|
-
|
178
|
-
|
179
|
-
|
316
|
+
point.x-= 168;
|
317
|
+
point.y-= 60;
|
318
|
+
point.z+= 320;
|
180
319
|
|
181
320
|
//WGS84 refers to greenwich
|
182
|
-
|
183
|
-
|
184
|
-
dest->x = temp.x;
|
185
|
-
dest->y = temp.y;
|
321
|
+
point = __YGCartesianToGeographic(point, LON_MERID_GREENWICH, A_WGS84,E_WGS84,DEFAULT_EPS);
|
186
322
|
}
|
323
|
+
|
324
|
+
point.unit = RADIAN;
|
325
|
+
return point;
|
187
326
|
}
|
188
327
|
|
189
328
|
|
190
|
-
void lambert_to_wgs84_deg(const YGPoint * org, YGPoint *dest, YGLambertZone zone)
|
191
|
-
{
|
192
|
-
YGPoint temp = {0,0,0};
|
193
|
-
|
194
|
-
lambert_to_wgs84(org,&temp,zone);
|
195
|
-
*dest = pointToDegree(temp);
|
196
|
-
}
|
197
329
|
|
198
|
-
double
|
330
|
+
double __YGLatitudeISO(double lat, double e)
|
199
331
|
{
|
200
332
|
return log(tan(M_PI_4 + lat/2)*pow((1-e*sin(lat))/(1+e*sin(lat)),e/2));
|
201
333
|
}
|
202
334
|
|
203
|
-
YGPoint
|
335
|
+
YGPoint __YGCoordinatesTransform(double e, double n, double c, double lambda_c, double x_s, double y_s , double lon, double lat)
|
204
336
|
{
|
205
337
|
YGPoint dest = {0,0,0};
|
206
338
|
|
207
|
-
double latiso =
|
339
|
+
double latiso = __YGLatitudeISO(lat,e);
|
208
340
|
dest.x = x_s + e*exp(-n*latiso)*sin(n*(lon-lambda_c));
|
209
341
|
dest.y = y_s + e*exp(n*latiso)*cos(n*(lon-lambda_c));
|
210
342
|
|
@@ -212,7 +344,7 @@ YGPoint coord_transform(double e, double n, double c, double lambda_c, double x_
|
|
212
344
|
|
213
345
|
}
|
214
346
|
|
215
|
-
YGPoint
|
347
|
+
YGPoint __YGSwitchGeodesicSystem(YGPoint u, Vector t, double d, Vector r)
|
216
348
|
{
|
217
349
|
YGPoint v = {0,0,0};
|
218
350
|
|
@@ -18,8 +18,6 @@
|
|
18
18
|
#define ct_x0 700000.0
|
19
19
|
#define ct_y0 6600000.0
|
20
20
|
|
21
|
-
#define DISPLAY_YGPoint(YGPoint) printf(#YGPoint" X:%f | Y:%f | Z:%f\n",YGPoint.x,YGPoint.y,YGPoint.z);
|
22
|
-
#define DISPLAY_YGPoint_REF(YGPoint) printf(#YGPoint" X:%f | Y:%f | Z:%f\n",YGPoint->x,YGPoint->y,YGPoint->z);
|
23
21
|
|
24
22
|
typedef enum {
|
25
23
|
LAMBERT_I=0,
|
@@ -33,7 +31,8 @@ typedef enum {
|
|
33
31
|
typedef enum {
|
34
32
|
DEGREE,
|
35
33
|
GRAD,
|
36
|
-
RADIAN
|
34
|
+
RADIAN,
|
35
|
+
METER
|
37
36
|
} CoordUnit;
|
38
37
|
|
39
38
|
typedef struct {
|
@@ -52,43 +51,49 @@ typedef struct
|
|
52
51
|
|
53
52
|
typedef YGPoint Vector;
|
54
53
|
|
55
|
-
|
56
|
-
|
54
|
+
#define __YGPointWithUnit(_x,_y,_z,_unit) {.x=_x, .y=_y,.z=_z,.unit=_unit};
|
55
|
+
|
56
|
+
#define YGDegreePoint(x,y,z) __YGPointWithUnit(x,y,z,DEGREE)
|
57
|
+
#define YGRadianPoint(x,y,z) __YGPointWithUnit(x,y,z,RADIAN)
|
58
|
+
#define YGGradPoint(x,y,z) __YGPointWithUnit(x,y,z,GRAD)
|
59
|
+
#define YGMeterPoint(x,y,z) __YGPointWithUnit(x,y,z,METER)
|
60
|
+
|
61
|
+
|
62
|
+
YGPoint YGPointToRadian(YGPoint p);
|
63
|
+
YGPoint YGPointToDegree(YGPoint p);
|
64
|
+
YGPoint YGPointToGrad(YGPoint p);
|
65
|
+
YGPoint YGPointToUnit(YGPoint point, CoordUnit unit);
|
57
66
|
|
58
67
|
/*
|
59
68
|
* ALGO0021 - Calcul de la grande Normale
|
60
69
|
*
|
61
70
|
*/
|
62
|
-
double
|
71
|
+
double __YGLambertNormal(double lat, double a, double e);
|
63
72
|
|
64
73
|
/*
|
65
74
|
* Convert a YGPoint struct from one lambert zone to WGS84 (Rad)
|
66
75
|
*
|
67
76
|
*/
|
68
|
-
void lambert_to_wgs84(const YGPoint * org, YGPoint *dest, YGLambertZone zone);
|
69
77
|
|
70
|
-
|
71
|
-
|
72
|
-
*
|
73
|
-
*/
|
74
|
-
void lambert_to_wgs84_deg(const YGPoint * org, YGPoint *dest, YGLambertZone zone);
|
78
|
+
|
79
|
+
YGPoint YGPointConvertWGS84(YGPoint point, YGLambertZone zone);
|
75
80
|
|
76
81
|
/*
|
77
82
|
* ALGO0002
|
78
83
|
*/
|
79
84
|
|
80
|
-
double
|
85
|
+
double __YGLatitudeFromLatitudeISO(double lat_iso, double e, double eps);
|
81
86
|
|
82
87
|
/*
|
83
88
|
* ALGO0012
|
84
89
|
*/
|
85
90
|
|
86
|
-
YGPoint
|
91
|
+
YGPoint __YGCartesianToGeographic(YGPoint org, double meridien, double a, double e , double eps);
|
87
92
|
|
88
93
|
/*
|
89
94
|
* ALGO004
|
90
95
|
*/
|
91
|
-
|
96
|
+
YGPoint __YGLambertToGeographic(YGPoint org, YGLambertZone zone, double lon_merid, double e, double eps);
|
92
97
|
|
93
98
|
/**
|
94
99
|
* ALGO0009 - Transformations geographiques -> cartésiennes
|
@@ -96,26 +101,26 @@ void lambert_to_geographic(const YGPoint * org,YGPoint *dest, YGLambertZone zone
|
|
96
101
|
*
|
97
102
|
*/
|
98
103
|
|
99
|
-
YGPoint
|
104
|
+
YGPoint __YGGeographicToCartesian(double lon, double lat, double he, double a, double e);
|
100
105
|
|
101
106
|
/**
|
102
107
|
* ALGO13 Transformation de Coordonnées à 7 paramètres entre deux systèmes géodésiques
|
103
108
|
*/
|
104
109
|
|
105
|
-
YGPoint
|
110
|
+
YGPoint __YGSwitchGeodesicSystem(YGPoint u, Vector t, double d, Vector r);
|
106
111
|
|
107
112
|
/**
|
108
113
|
* Algo0001 Calcul de la latitude isomérique
|
109
114
|
*/
|
110
|
-
double
|
115
|
+
double __YGLatitudeISO(double lat, double e);
|
111
116
|
|
112
117
|
/**
|
113
118
|
* Algo003
|
114
119
|
*/
|
115
|
-
YGPoint
|
120
|
+
YGPoint __YGCoordinatesTransform(double e, double n, double c, double lambda_c, double x_s, double y_s , double lon, double lat);
|
116
121
|
|
117
122
|
/**
|
118
123
|
* Algo 01
|
119
124
|
*/
|
120
|
-
double
|
125
|
+
double __YGLatitudeISOFromLatitude(double lat, double e);
|
121
126
|
#endif
|
@@ -12,6 +12,9 @@
|
|
12
12
|
#define MAX_PATH_SIZE 1024
|
13
13
|
#define DELTA_REALLOCATION 10
|
14
14
|
|
15
|
+
#ifndef OPEN_MAX
|
16
|
+
#define OPEN_MAX 256
|
17
|
+
#endif
|
15
18
|
|
16
19
|
typedef struct {
|
17
20
|
|
@@ -25,7 +28,6 @@ typedef struct {
|
|
25
28
|
|
26
29
|
static char currentNTVPath[OPEN_MAX];
|
27
30
|
static FILE * gridFD = NULL;
|
28
|
-
static char grd3dparams[4][MAX_LINE_BUFFER] = {{0}};
|
29
31
|
|
30
32
|
static NTV2Reg *regcache = NULL;
|
31
33
|
static int lastRegPos = 0;
|
@@ -108,21 +110,6 @@ int loadGrid()
|
|
108
110
|
return 0;
|
109
111
|
}
|
110
112
|
|
111
|
-
|
112
|
-
void printParameters()
|
113
|
-
{
|
114
|
-
printf("===== Parameters =====\n");
|
115
|
-
printf("%s\n", grd3dparams[0]);
|
116
|
-
printf("%s\n", grd3dparams[1]);
|
117
|
-
printf("%s\n", grd3dparams[2]);
|
118
|
-
printf("%s\n", grd3dparams[3]);
|
119
|
-
|
120
|
-
}
|
121
|
-
|
122
|
-
void printReg(NTV2Reg reg)
|
123
|
-
{
|
124
|
-
printf("LON:%f - LAT:%f - TX:%f - TY:%f - TZ:%f - PRE:%f\n",reg.lon,reg.lat,reg.tx,reg.ty,reg.tz,reg.precision);
|
125
|
-
}
|
126
113
|
void unloadGrid()
|
127
114
|
{
|
128
115
|
fclose(gridFD);
|
@@ -168,7 +155,7 @@ void ntvreg_around_point(const YGPoint pt, NTV2Reg *t1, NTV2Reg *t2, NTV2Reg * t
|
|
168
155
|
*t3 = *(--searchReg);
|
169
156
|
|
170
157
|
}
|
171
|
-
YGTransform
|
158
|
+
YGTransform __YGTransformNTFoRGF93(YGPoint pt)
|
172
159
|
{
|
173
160
|
if(!gridFD)
|
174
161
|
loadGrid();
|
@@ -189,7 +176,8 @@ YGTransform ntf_to_rgf93(YGPoint pt)
|
|
189
176
|
regToBuff(t3Buf,t3);
|
190
177
|
regToBuff(t4Buf,t4);
|
191
178
|
|
192
|
-
|
179
|
+
int i;
|
180
|
+
for(i = 0; i< 3; ++i)
|
193
181
|
{
|
194
182
|
d[i] = (1-x)*(1-y)*t1Buf[i] + (1-x)*y*t2Buf[i] + (1-y)*x*t3Buf[i] + x*y*t4Buf[i];
|
195
183
|
}
|
@@ -198,9 +186,36 @@ YGTransform ntf_to_rgf93(YGPoint pt)
|
|
198
186
|
return tm;
|
199
187
|
}
|
200
188
|
|
201
|
-
YGTransform
|
189
|
+
YGTransform __YGTransformRGF93ToNTF(YGPoint pt)
|
202
190
|
{
|
203
|
-
YGTransform tm =
|
191
|
+
YGTransform tm = __YGTransformNTFoRGF93(pt);
|
204
192
|
YGTransform val = {-1*tm.tx,-1*tm.ty,-1*tm.tz};
|
205
193
|
return val;
|
206
|
-
}
|
194
|
+
}
|
195
|
+
|
196
|
+
|
197
|
+
YGPoint YGPointConvertRGF93_NTF(YGPoint point)
|
198
|
+
{
|
199
|
+
CoordUnit oldUnit = point.unit;
|
200
|
+
|
201
|
+
YGTransform tr = __YGTransformRGF93ToNTF(point);
|
202
|
+
|
203
|
+
YGPoint t = {tr.tx,tr.ty,tr.tz};
|
204
|
+
YGPoint null= {0,0,0};
|
205
|
+
|
206
|
+
point = YGPointToRadian(point);
|
207
|
+
point = __YGGeographicToCartesian(point.x,point.y,point.z,A_WGS84,E_WGS84);
|
208
|
+
|
209
|
+
point = __YGSwitchGeodesicSystem(point, t, 0, null);
|
210
|
+
point = __YGCartesianToGeographic(point, LON_MERID_PARIS, A_CLARK_IGN, E_CLARK_IGN, DEFAULT_EPS);
|
211
|
+
|
212
|
+
point = YGPointToUnit(point, oldUnit);
|
213
|
+
|
214
|
+
return point;
|
215
|
+
|
216
|
+
}
|
217
|
+
|
218
|
+
YGPoint YGPointConvertNTF_RGF93(YGPoint point)
|
219
|
+
{
|
220
|
+
return (YGPoint){0,0,0,0};
|
221
|
+
}
|
@@ -2,6 +2,13 @@
|
|
2
2
|
#define __NTV2_H
|
3
3
|
#include "lambert.h"
|
4
4
|
|
5
|
-
YGTransform
|
6
|
-
YGTransform
|
5
|
+
YGTransform __YGTransformNTFToRGF93(YGPoint pt);
|
6
|
+
YGTransform __YGTransformRGF93ToNTF(YGPoint pt);
|
7
|
+
|
8
|
+
YGPoint YGPointConvertRGF93_NTF(YGPoint point);
|
9
|
+
|
10
|
+
YGPoint YGPointConvertNTF_RGF93(YGPoint point);
|
11
|
+
|
12
|
+
|
13
|
+
|
7
14
|
#endif
|
@@ -6,7 +6,6 @@
|
|
6
6
|
#include "../src/lambert.h"
|
7
7
|
#include "../src/rgf93.h"
|
8
8
|
|
9
|
-
#define DISPLAY_POINT(point) printf(#point" X:%f | Y:%f | Z:%f\n",point.x,point.y,point.z);
|
10
9
|
|
11
10
|
int init_suite_success(void) { return 0; }
|
12
11
|
int init_suite_failure(void) { return -1; }
|
@@ -29,26 +28,6 @@ double rounded_down(double val,int n){
|
|
29
28
|
return floorf(val*p)/p;
|
30
29
|
}
|
31
30
|
|
32
|
-
void test_lambert_deg(void)
|
33
|
-
{
|
34
|
-
YGPoint org = {994300.623,113409.981,0};
|
35
|
-
YGPoint dest = {0,0,0};
|
36
|
-
YGLambertZone zone = LAMBERT_I;
|
37
|
-
|
38
|
-
lambert_to_wgs84_deg(&org, &dest, zone);
|
39
|
-
printf("(Deg)Lon:%.11f - Lat:%.11f - H:%.11f\n",dest.x,dest.y,dest.z);
|
40
|
-
}
|
41
|
-
|
42
|
-
void test_lambert(void)
|
43
|
-
{
|
44
|
-
|
45
|
-
YGPoint org = {999534.581,112186.569,0};
|
46
|
-
YGPoint dest = {0,0,0};
|
47
|
-
YGLambertZone zone = LAMBERT_I;
|
48
|
-
|
49
|
-
lambert_to_wgs84(&org, &dest, zone);
|
50
|
-
}
|
51
|
-
|
52
31
|
void test_algo009(void)
|
53
32
|
{
|
54
33
|
double lon[3] = {0.01745329248 ,0.00290888212 ,0.00581776423};
|
@@ -56,13 +35,22 @@ void test_algo009(void)
|
|
56
35
|
double he[3] = {100.0000,10.0000 ,2000.0000};
|
57
36
|
double a[3] = {6378249.2000 ,6378249.2000 ,6378249.2000};
|
58
37
|
double e[3] = {0.08248325679 ,0.08248325679 ,0.08248325679};
|
38
|
+
|
39
|
+
YGPoint expected[3] = {
|
40
|
+
{6376064.6955,111294.6230,128984.7250, METER },
|
41
|
+
{6378232.2149,18553.5780,0, METER },
|
42
|
+
{6376897.5369,37099.7050,-202730.9070, METER }
|
43
|
+
};
|
59
44
|
|
60
45
|
|
61
46
|
unsigned int i;
|
62
47
|
for (i =0; i < 3;++i)
|
63
48
|
{
|
64
|
-
YGPoint pt =
|
65
|
-
|
49
|
+
YGPoint pt = __YGGeographicToCartesian(lon[i],lat[i],he[i],a[i],e[i]);
|
50
|
+
CU_ASSERT(fabs(pt.x - expected[i].x) <= 1e-4);
|
51
|
+
CU_ASSERT(fabs(pt.y - expected[i].y) <= 1e-4);
|
52
|
+
CU_ASSERT(fabs(pt.z - expected[i].z) <= 1e-4);
|
53
|
+
|
66
54
|
}
|
67
55
|
|
68
56
|
}
|
@@ -75,8 +63,7 @@ void test_algo0021 (void)
|
|
75
63
|
double a = 6378388.0000;
|
76
64
|
double e = 0.081991890;
|
77
65
|
|
78
|
-
double calc =
|
79
|
-
printf("Expected:%.4f | Computed:%.4f\n",n,calc);
|
66
|
+
double calc = __YGLambertNormal(lat,a,e);
|
80
67
|
CU_ASSERT(n == truncate(calc,4));
|
81
68
|
|
82
69
|
}
|
@@ -97,7 +84,7 @@ void test_algo0002(void)
|
|
97
84
|
|
98
85
|
for(index = 0;index < 3;index++)
|
99
86
|
{
|
100
|
-
double result =
|
87
|
+
double result = __YGLatitudeFromLatitudeISO(lat_iso[index], e[index], eps[index]);
|
101
88
|
result = truncate(result,11);
|
102
89
|
CU_ASSERT(result == phi[index]);
|
103
90
|
}
|
@@ -124,7 +111,7 @@ void test_algo0012(void)
|
|
124
111
|
{
|
125
112
|
YGPoint sample = {x[i],y[i],z[i]};
|
126
113
|
YGPoint val ;
|
127
|
-
val =
|
114
|
+
val = __YGCartesianToGeographic(sample,LON_MERID_PARIS,a[i],e[i],eps[i]);
|
128
115
|
|
129
116
|
// printf("X Computed:%.11f - Expected:%.11f\n",val.x,lon[i]);
|
130
117
|
CU_ASSERT(fabs(val.x - lon[i]) <= ign_eps);
|
@@ -144,39 +131,98 @@ void test_algo004(void)
|
|
144
131
|
YGPoint expected = {0.145512099,0.872664626};
|
145
132
|
|
146
133
|
|
147
|
-
|
148
|
-
|
134
|
+
dest = __YGLambertToGeographic(org, LAMBERT_I, LON_MERID_GREENWICH,E_CLARK_IGN,1e-9);
|
135
|
+
|
149
136
|
CU_ASSERT(fabs(dest.x - expected.x) <= 1e-9);
|
150
137
|
CU_ASSERT(fabs(dest.y - expected.y) <= 1e-9);
|
151
138
|
}
|
152
139
|
|
153
|
-
|
154
|
-
void testBug2(void)
|
140
|
+
void testBugLambert93(void)
|
155
141
|
{
|
156
|
-
YGPoint org =
|
157
|
-
|
158
|
-
|
142
|
+
YGPoint org = YGMeterPoint(668832.5384,6950138.7285,0);
|
143
|
+
YGPoint expected = YGDegreePoint(2.56865, 49.64961, 0);
|
144
|
+
YGPoint dest;
|
145
|
+
YGLambertZone zone = LAMBERT_93;
|
159
146
|
|
160
|
-
|
161
|
-
|
147
|
+
dest = YGPointConvertWGS84(org,zone);
|
148
|
+
dest = YGPointToDegree(dest);
|
149
|
+
|
150
|
+
CU_ASSERT(fabs(dest.x - expected.x) <= 1e-5);
|
151
|
+
CU_ASSERT(fabs(dest.y - expected.y) <= 1e-5);
|
162
152
|
|
163
153
|
}
|
154
|
+
|
155
|
+
|
156
|
+
void testZenithStrasbourg(void)
|
157
|
+
{
|
158
|
+
YGPoint org = YGMeterPoint(994300.623,113409.981,0);
|
159
|
+
YGPoint expected = YGDegreePoint(7.68639475277068, 48.5953456709144, 0);
|
160
|
+
YGPoint dest;
|
161
|
+
YGLambertZone zone = LAMBERT_I;
|
162
|
+
|
163
|
+
dest = YGPointConvertWGS84(org,zone);
|
164
|
+
dest = YGPointToDegree(dest);
|
165
|
+
|
166
|
+
CU_ASSERT(fabs(dest.x - expected.x) <= 1e-5);
|
167
|
+
CU_ASSERT(fabs(dest.y - expected.y) <= 1e-5);
|
168
|
+
}
|
169
|
+
void testBugLambertIIE(void)
|
170
|
+
{
|
171
|
+
YGPoint org = YGMeterPoint(369419,1986498,0);
|
172
|
+
YGPoint expected = YGDegreePoint( -0.579117201473994,44.84071560809383, 0);
|
173
|
+
YGPoint dest;
|
174
|
+
YGLambertZone zone = LAMBERT_II_E;
|
175
|
+
|
176
|
+
dest = YGPointConvertWGS84(org,zone);
|
177
|
+
dest = YGPointToDegree(dest);
|
178
|
+
|
179
|
+
CU_ASSERT(fabs(dest.x - expected.x) <= 1e-4);
|
180
|
+
CU_ASSERT(fabs(dest.y - expected.y) <= 1e-4);
|
181
|
+
}
|
164
182
|
void testOpenGrid(void)
|
165
183
|
{
|
166
|
-
YGPoint org =
|
167
|
-
|
168
|
-
YGTransform tr =
|
184
|
+
YGPoint org = YGDegreePoint(2.424971108, 48.844445839,0);
|
185
|
+
|
186
|
+
YGTransform tr = __YGTransformRGF93ToNTF(org);
|
169
187
|
|
170
188
|
YGPoint t = {tr.tx,tr.ty,tr.tz};
|
171
|
-
YGPoint null= {0,0,0};
|
189
|
+
YGPoint null= {0,0,0,RADIAN};
|
190
|
+
|
191
|
+
org = YGPointToRadian(org);
|
192
|
+
org = __YGGeographicToCartesian(org.x,org.y,org.z,A_WGS84,E_WGS84);
|
193
|
+
|
194
|
+
org = __YGSwitchGeodesicSystem(org, t, 0, null);
|
195
|
+
org = __YGCartesianToGeographic(org, LON_MERID_PARIS, A_CLARK_IGN, E_CLARK_IGN, DEFAULT_EPS);
|
172
196
|
|
173
|
-
org =
|
174
|
-
org = geographic_to_cartesian(org.x,org.y,org.z,A_WGS84,E_WGS84);
|
197
|
+
org = YGPointToDegree(org);
|
175
198
|
|
176
|
-
|
177
|
-
|
199
|
+
printf("Point value :\n");
|
200
|
+
}
|
201
|
+
|
202
|
+
void test_RGF93_NTF_degree(void)
|
203
|
+
{
|
204
|
+
YGPoint org = YGDegreePoint(2.424971108, 48.844445839,0);
|
205
|
+
YGPoint expected = YGDegreePoint(2.42567186, 48.84451225, 0);
|
206
|
+
|
207
|
+
|
208
|
+
YGPoint dest = YGPointConvertRGF93_NTF(org);
|
209
|
+
CU_ASSERT(fabs(expected.x - dest.x) <= 1e-8);
|
210
|
+
CU_ASSERT(fabs(expected.y - dest.y) <= 1e-8);
|
211
|
+
}
|
212
|
+
|
213
|
+
void test_RGF93_NTF_degree_to_cartesian(void)
|
214
|
+
{
|
215
|
+
YGPoint org = YGDegreePoint(2.424971108, 48.844445839,0);
|
216
|
+
YGPoint expected = YGDegreePoint(606491.571, 127112.233, 0);
|
217
|
+
|
218
|
+
|
219
|
+
YGPoint dest = YGPointConvertRGF93_NTF(org);
|
220
|
+
dest = YGPointToRadian(dest);
|
221
|
+
|
222
|
+
|
178
223
|
|
179
|
-
|
224
|
+
CU_ASSERT(fabs(expected.x - dest.x) <= 1e-3);
|
225
|
+
CU_ASSERT(fabs(expected.y - dest.y) <= 1e-3);
|
180
226
|
}
|
181
227
|
|
182
228
|
int main(int argc, char **argv){
|
@@ -194,17 +240,19 @@ int main(int argc, char **argv){
|
|
194
240
|
return CU_get_error();
|
195
241
|
}
|
196
242
|
|
197
|
-
/* add the tests to the suite */
|
243
|
+
/* add the tests to the suite testProjectionsecant*/
|
198
244
|
if ( NULL == CU_add_test(pSuite, "Test Algo0002", test_algo0002) ||
|
199
245
|
NULL == CU_add_test(pSuite, "Test Algo0012", test_algo0012) ||
|
200
246
|
NULL == CU_add_test(pSuite,"Test Algo004",test_algo004) ||
|
201
247
|
NULL == CU_add_test(pSuite,"Test algo0021",test_algo0021) ||
|
202
248
|
NULL == CU_add_test(pSuite,"test_algo009",test_algo009) ||
|
203
|
-
|
204
|
-
NULL == CU_add_test(pSuite,"
|
249
|
+
NULL == CU_add_test(pSuite,"Test Zenith Strasbourg",testZenithStrasbourg) ||
|
250
|
+
NULL == CU_add_test(pSuite,"Test Bug Lambert 93",testBugLambert93) ||
|
251
|
+
NULL == CU_add_test(pSuite,"Test Bug Lambert II E",testBugLambertIIE) ||
|
205
252
|
NULL == CU_add_test(pSuite,"testNTFRGF93",testOpenGrid) ||
|
206
|
-
NULL == CU_add_test(pSuite, "Test
|
207
|
-
|
253
|
+
NULL == CU_add_test(pSuite, "Test (Degree)RGF93 ->NTF (Degree)", test_RGF93_NTF_degree) ||
|
254
|
+
NULL == CU_add_test(pSuite, "Test (Degree)RGF93 ->NTF (Meter)", test_RGF93_NTF_degree_to_cartesian)
|
255
|
+
)
|
208
256
|
{
|
209
257
|
CU_cleanup_registry();
|
210
258
|
return CU_get_error();
|
@@ -36,14 +36,13 @@ static VALUE p_convert(VALUE self,VALUE zone){
|
|
36
36
|
y = NUM2DBL(rb_iv_get(self,"@y"));
|
37
37
|
z = NUM2DBL(rb_iv_get(self,"@z"));
|
38
38
|
|
39
|
-
YGPoint org =
|
40
|
-
|
39
|
+
YGPoint org = YGMeterPoint(x,y,z);
|
40
|
+
org = YGPointConvertWGS84(org,cZone);
|
41
|
+
org = YGPointToDegree(org);
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
rb_iv_set(self, "@
|
45
|
-
rb_iv_set(self, "@y", rb_float_new(dest.y));
|
46
|
-
rb_iv_set(self, "@z", rb_float_new(dest.z));
|
43
|
+
rb_iv_set(self, "@x", rb_float_new(org.x));
|
44
|
+
rb_iv_set(self, "@y", rb_float_new(org.y));
|
45
|
+
rb_iv_set(self, "@z", rb_float_new(org.z));
|
47
46
|
|
48
47
|
|
49
48
|
return Qnil;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lambert_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yannick Heinrich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby wrapper for the lambert library
|
14
14
|
email: yannick.heinrich@gmail.com
|
@@ -36,17 +36,17 @@ require_paths:
|
|
36
36
|
- lib
|
37
37
|
required_ruby_version: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
48
|
rubyforge_project:
|
49
|
-
rubygems_version: 2.0.
|
49
|
+
rubygems_version: 2.0.14
|
50
50
|
signing_key:
|
51
51
|
specification_version: 4
|
52
52
|
summary: Ruby wrapper for the lambert library
|