Browse Source

libproj: use 4D type with PROJ 5+

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@72440 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 7 years ago
parent
commit
1f0460b150
2 changed files with 38 additions and 30 deletions
  1. 22 22
      lib/proj/do_proj.c
  2. 16 8
      lib/proj/do_proj_ll.c

+ 22 - 22
lib/proj/do_proj.c

@@ -99,10 +99,10 @@ int pj_do_proj(double *x, double *y,
 
     if (strncmp(info_in->proj, "ll", 2) == 0) {
 	/* convert to radians */
-	c.lp.lam = (*x) / RAD_TO_DEG;
-	c.lp.phi = (*y) / RAD_TO_DEG;
-	c.lp.z = 0;
-	c.lp.t = 0;
+	c.lpzt.lam = (*x) / RAD_TO_DEG;
+	c.lpzt.phi = (*y) / RAD_TO_DEG;
+	c.lpzt.z = 0;
+	c.lpzt.t = 0;
 	c = proj_trans(P, PJ_FWD, c);
 	ok = proj_errno(P);
 
@@ -119,10 +119,10 @@ int pj_do_proj(double *x, double *y,
     }
     else {
 	/* convert to meters */
-	c.xy.x = *x * METERS_in;
-	c.xy.y = *y * METERS_in;
-	c.xy.z = 0;
-	c.xy.t = 0;
+	c.xyzt.x = *x * METERS_in;
+	c.xyzt.y = *y * METERS_in;
+	c.xyzt.z = 0;
+	c.xyzt.t = 0;
 	c = proj_trans(P, PJ_FWD, c);
 	ok = proj_errno(P);
 
@@ -245,13 +245,13 @@ int pj_do_transform(int count, double *x, double *y, double *h,
     }
     ok = 0;
     if (strncmp(info_in->proj, "ll", 2) == 0) {
-	c.lp.t = 0;
+	c.lpzt.t = 0;
 	if (strncmp(info_out->proj, "ll", 2) == 0) {
 	    for (i = 0; i < count; i++) {
 		/* convert to radians */
-		c.lp.lam = x[i] / RAD_TO_DEG;
-		c.lp.phi = y[i] / RAD_TO_DEG;
-		c.lp.z = h[i];
+		c.lpzt.lam = x[i] / RAD_TO_DEG;
+		c.lpzt.phi = y[i] / RAD_TO_DEG;
+		c.lpzt.z = h[i];
 		c = proj_trans(P, PJ_FWD, c);
 		if ((ok = proj_errno(P)) < 0)
 		    break;
@@ -263,9 +263,9 @@ int pj_do_transform(int count, double *x, double *y, double *h,
 	else {
 	    for (i = 0; i < count; i++) {
 		/* convert to radians */
-		c.lp.lam = x[i] / RAD_TO_DEG;
-		c.lp.phi = y[i] / RAD_TO_DEG;
-		c.lp.z = h[i];
+		c.lpzt.lam = x[i] / RAD_TO_DEG;
+		c.lpzt.phi = y[i] / RAD_TO_DEG;
+		c.lpzt.z = h[i];
 		c = proj_trans(P, PJ_FWD, c);
 		if ((ok = proj_errno(P)) < 0)
 		    break;
@@ -276,13 +276,13 @@ int pj_do_transform(int count, double *x, double *y, double *h,
 	}
     }
     else {
-	c.xy.t = 0;
+	c.xyzt.t = 0;
 	if (strncmp(info_out->proj, "ll", 2) == 0) {
 	    for (i = 0; i < count; i++) {
 		/* convert to meters */
-		c.xy.x = x[i] * METERS_in;
-		c.xy.y = y[i] * METERS_in;
-		c.xy.z = h[i];
+		c.xyzt.x = x[i] * METERS_in;
+		c.xyzt.y = y[i] * METERS_in;
+		c.xyzt.z = h[i];
 		c = proj_trans(P, PJ_FWD, c);
 		if ((ok = proj_errno(P)) < 0)
 		    break;
@@ -294,9 +294,9 @@ int pj_do_transform(int count, double *x, double *y, double *h,
 	else {
 	    for (i = 0; i < count; i++) {
 		/* convert to meters */
-		c.xy.x = x[i] * METERS_in;
-		c.xy.y = y[i] * METERS_in;
-		c.xy.z = h[i];
+		c.xyzt.x = x[i] * METERS_in;
+		c.xyzt.y = y[i] * METERS_in;
+		c.xyzt.z = h[i];
 		c = proj_trans(P, PJ_FWD, c);
 		if ((ok = proj_errno(P)) < 0)
 		    break;

+ 16 - 8
lib/proj/do_proj_ll.c

@@ -83,8 +83,10 @@ int GPJ_do_proj_ll(double *x, double *y,
 	/* from ll to projected */
 
 	/* convert to radians */
-	c.lp.lam = (*x) / RAD_TO_DEG;
-	c.lp.phi = (*y) / RAD_TO_DEG;
+	c.lpzt.lam = (*x) / RAD_TO_DEG;
+	c.lpzt.phi = (*y) / RAD_TO_DEG;
+	c.lpzt.z = 0;
+	c.lpzt.t = 0;
 
 	c = proj_trans(P, PJ_FWD, c);
 	ok = proj_errno(P);
@@ -97,8 +99,10 @@ int GPJ_do_proj_ll(double *x, double *y,
 	/* from projected to ll */
 
 	/* convert to meters */
-	c.xy.x = *x * METERS_in;
-	c.xy.y = *y * METERS_in;
+	c.xyzt.x = *x * METERS_in;
+	c.xyzt.y = *y * METERS_in;
+	c.xyzt.z = 0;
+	c.xyzt.t = 0;
 
 	c = proj_trans(P, PJ_INV, c);
 	ok = proj_errno(P);
@@ -178,8 +182,10 @@ int GPJ_do_transform_ll(int count, double *x, double *y, double *h,
 
 	for (i = 0; i < count; i++) {
 	    /* convert to radians */
-	    c.lp.lam = x[i] / RAD_TO_DEG;
-	    c.lp.phi = y[i] / RAD_TO_DEG;
+	    c.lpzt.lam = x[i] / RAD_TO_DEG;
+	    c.lpzt.phi = y[i] / RAD_TO_DEG;
+	    c.lpzt.z = h[i];
+	    c.lpzt.t = 0;
 
 	    c = proj_trans(P, PJ_FWD, c);
 	    if ((ok = proj_errno(P)) < 0)
@@ -195,8 +201,10 @@ int GPJ_do_transform_ll(int count, double *x, double *y, double *h,
 
 	for (i = 0; i < count; i++) {
 	    /* convert to meters */
-	    c.xy.x = x[i] * METERS_in;
-	    c.xy.y = y[i] * METERS_in;
+	    c.xyzt.x = x[i] * METERS_in;
+	    c.xyzt.y = y[i] * METERS_in;
+	    c.xyzt.z = h[i];
+	    c.xyzt.t = 0;
 
 	    c = proj_trans(P, PJ_INV, c);
 	    if ((ok = proj_errno(P)) < 0)