aboutsummaryrefslogtreecommitdiff
path: root/src/PJ_geos.c
diff options
context:
space:
mode:
authorKristian Evers <kristianevers@gmail.com>2017-07-17 23:10:09 +0200
committerKristian Evers <kristianevers@gmail.com>2017-07-18 11:47:20 +0200
commitad7a7c1b1d54c69b9df442797a809418d00d647d (patch)
treead9a4dd1bb9aa1fcbc17e82508ec0482d1d6d06d /src/PJ_geos.c
parent2ec0759b8cdd45deae8b9aba70ec7d23c7c3ddd8 (diff)
downloadPROJ-ad7a7c1b1d54c69b9df442797a809418d00d647d.tar.gz
PROJ-ad7a7c1b1d54c69b9df442797a809418d00d647d.zip
Expanded *_ERROR* macros.
Expanded *_ERROR* macros with calls to proj_errno_set() and proper returns when necessary. Defined a bunch of new PJD_ERR_ constants in projects.h that corresponds to the error numbers in pj_strerrno.c. A few unknown error numbers were replaced by existing ones in pj_strerrno.c.
Diffstat (limited to 'src/PJ_geos.c')
-rw-r--r--src/PJ_geos.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/PJ_geos.c b/src/PJ_geos.c
index 56357c2b..b929c06b 100644
--- a/src/PJ_geos.c
+++ b/src/PJ_geos.c
@@ -28,7 +28,8 @@
*/
#define PJ_LIB__
-#include <projects.h>
+#include <proj.h>
+#include "projects.h"
struct pj_opaque {
double h;
@@ -91,8 +92,10 @@ static XY e_forward (LP lp, PJ *P) { /* Ellipsoidal, forward */
Vz = r * sin (lp.phi);
/* Check visibility. */
- if (((Q->radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * Q->radius_p_inv2) < 0.)
- F_ERROR;
+ if (((Q->radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * Q->radius_p_inv2) < 0.) {
+ proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
+ return xy;
+ }
/* Calculation based on view angles from satellite. */
tmp = Q->radius_g - Vx;
@@ -127,7 +130,10 @@ static LP s_inverse (XY xy, PJ *P) { /* Spheroidal, inverse */
/* Calculation of terms in cubic equation and determinant.*/
a = Vy * Vy + Vz * Vz + Vx * Vx;
b = 2 * Q->radius_g * Vx;
- if ((det = (b * b) - 4 * a * Q->C) < 0.) I_ERROR;
+ if ((det = (b * b) - 4 * a * Q->C) < 0.) {
+ proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
+ return lp;
+ }
/* Calculation of three components of vector from satellite to position.*/
k = (-b - sqrt(det)) / (2 * a);
@@ -163,7 +169,10 @@ static LP e_inverse (XY xy, PJ *P) { /* Ellipsoidal, inverse */
a = Vz / Q->radius_p;
a = Vy * Vy + a * a + Vx * Vx;
b = 2 * Q->radius_g * Vx;
- if ((det = (b * b) - 4 * a * Q->C) < 0.) I_ERROR;
+ if ((det = (b * b) - 4 * a * Q->C) < 0.) {
+ proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
+ return lp;
+ }
/* Calculation of three components of vector from satellite to position.*/
k = (-b - sqrt(det)) / (2. * a);
@@ -202,18 +211,24 @@ PJ *PROJECTION(geos) {
return freeup_new (P);
P->opaque = Q;
- if ((Q->h = pj_param(P->ctx, P->params, "dh").f) <= 0.) E_ERROR(-30);
+ if ((Q->h = pj_param(P->ctx, P->params, "dh").f) <= 0.){
+ proj_errno_set(P, PJD_ERR_H_LESS_THAN_ZERO);
+ return freeup_new(P);
+ }
- if (P->phi0 != 0.0) E_ERROR(-46);
+ if (P->phi0 != 0.0) {
+ proj_errno_set(P, PJD_ERR_UNKNOWN_PRIME_MERIDIAN);
+ return freeup_new(P);
+ }
Q->sweep_axis = pj_param(P->ctx, P->params, "ssweep").s;
if (Q->sweep_axis == NULL)
Q->flip_axis = 0;
else {
- if (Q->sweep_axis[1] != '\0' ||
- (Q->sweep_axis[0] != 'x' &&
- Q->sweep_axis[0] != 'y'))
- E_ERROR(-49);
+ if (Q->sweep_axis[1] != '\0' || (Q->sweep_axis[0] != 'x' && Q->sweep_axis[0] != 'y')) {
+ proj_errno_set(P, PJD_ERR_INVALID_SWEEP_AXIS);
+ return freeup_new(P);
+ }
if (Q->sweep_axis[0] == 'x')
Q->flip_axis = 1;
else