70 lines
2.2 KiB
Diff
70 lines
2.2 KiB
Diff
|
diff -rupN --no-dereference ncl-6.6.2/ni/src/lib/nfp/TransformCoordinate.c ncl-6.6.2-new/ni/src/lib/nfp/TransformCoordinate.c
|
||
|
--- ncl-6.6.2/ni/src/lib/nfp/TransformCoordinate.c 2019-02-28 00:44:39.000000000 +0100
|
||
|
+++ ncl-6.6.2-new/ni/src/lib/nfp/TransformCoordinate.c 2021-03-10 19:16:04.100897315 +0100
|
||
|
@@ -1,48 +1,39 @@
|
||
|
#include <stdio.h>
|
||
|
-#include <proj_api.h>
|
||
|
+#include <proj.h>
|
||
|
#include "TransformCoordinate.h"
|
||
|
|
||
|
int TransformCoordinate(char * SrcProjStr, char * DstProjStr,
|
||
|
double * x, double * y, double * z,
|
||
|
unsigned int nPoint) {
|
||
|
- projPJ SrcProj, DstProj;
|
||
|
+ PJ *proj;
|
||
|
int Err, i;
|
||
|
+ PJ_COORD* c = (PJ_COORD*)malloc(nPoint * sizeof(PJ_COORD));
|
||
|
|
||
|
/* Constructing the projections */
|
||
|
- if (!(SrcProj = pj_init_plus(SrcProjStr))) {
|
||
|
- printf("FATAL ERROR: Can not make a projection out of <%s>\n", SrcProjStr);
|
||
|
+ if (!(proj = proj_create_crs_to_crs(PJ_DEFAULT_CTX, SrcProjStr, DstProjStr, NULL))) {
|
||
|
+ printf("FATAL ERROR: Can not create transform from <%s> to <%s>\n", SrcProjStr, DstProjStr);
|
||
|
return (1);
|
||
|
}
|
||
|
- if (!(DstProj = pj_init_plus(DstProjStr))) {
|
||
|
- printf("FATAL ERROR: Can not make a projection out of <%s>\n", DstProjStr);
|
||
|
- return (2);
|
||
|
- }
|
||
|
|
||
|
- /* Converting to radian if needed */
|
||
|
- if (pj_is_latlong(SrcProj)) {
|
||
|
- for (i = 0; i < nPoint; i++) {
|
||
|
- x[i] *= DEG_TO_RAD;
|
||
|
- y[i] *= DEG_TO_RAD;
|
||
|
- }
|
||
|
+ for (i = 0; i < nPoint; ++i) {
|
||
|
+ c[i].xyz.x = x[i];
|
||
|
+ c[i].xyz.y = y[i];
|
||
|
+ c[i].xyz.z = z[i];
|
||
|
}
|
||
|
|
||
|
/* Transforming the coordinates */
|
||
|
- if ((Err = pj_transform(SrcProj, DstProj, nPoint, 1, x, y, z)) != 0) {
|
||
|
- printf("FATAL ERROR: %s\n", pj_strerrno(Err));
|
||
|
- return (3);
|
||
|
- }
|
||
|
+ proj_trans_array(proj, PJ_FWD, nPoint, c);
|
||
|
|
||
|
- /* converting to degree if needed */
|
||
|
- if (pj_is_latlong(DstProj)) {
|
||
|
- for (i = 0; i < nPoint; i++) {
|
||
|
- x[i] *= RAD_TO_DEG;
|
||
|
- y[i] *= RAD_TO_DEG;
|
||
|
- }
|
||
|
+ for (i = 0; i < nPoint; ++i) {
|
||
|
+ x[i] = c[i].xyz.x;
|
||
|
+ y[i] = c[i].xyz.y;
|
||
|
+ z[i] = c[i].xyz.z;
|
||
|
}
|
||
|
|
||
|
/* freeing the projection */
|
||
|
- pj_free(DstProj);
|
||
|
- pj_free(SrcProj);
|
||
|
+ proj_destroy(proj);
|
||
|
+ free(c);
|
||
|
+
|
||
|
return (0);
|
||
|
}
|
||
|
|