aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ell_set.cpp3
-rw-r--r--src/geocent.cpp24
-rw-r--r--src/projections/aea.cpp4
-rw-r--r--src/projections/eqdc.cpp2
-rw-r--r--src/projections/geos.cpp8
-rw-r--r--src/projections/isea.cpp2
-rw-r--r--src/transformations/helmert.cpp2
7 files changed, 38 insertions, 7 deletions
diff --git a/src/ell_set.cpp b/src/ell_set.cpp
index 0d7fb6d5..d2930ca4 100644
--- a/src/ell_set.cpp
+++ b/src/ell_set.cpp
@@ -389,6 +389,9 @@ static int ellps_spherification (PJ *P) {
return proj_errno_set (P, PJD_ERR_REF_RAD_LARGER_THAN_90);
t = sin (t);
t = 1 - P->es * t * t;
+ if (t == 0.) {
+ return proj_errno_set(P, PJD_ERR_INVALID_ECCENTRICITY);
+ }
if (i==5) /* arithmetic */
P->a *= (1. - P->es + t) / (2 * t * sqrt(t));
else /* geometric */
diff --git a/src/geocent.cpp b/src/geocent.cpp
index c023bdd3..cbcc1df5 100644
--- a/src/geocent.cpp
+++ b/src/geocent.cpp
@@ -399,7 +399,17 @@ void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo *gi,
*/
CT = Z/RR;
ST = P/RR;
- RX = 1.0/sqrt(1.0-gi->Geocent_e2*(2.0-gi->Geocent_e2)*ST*ST);
+ {
+ const double denominator = 1.0-gi->Geocent_e2*(2.0-gi->Geocent_e2)*ST*ST;
+ if( denominator == 0 )
+ {
+ *Latitude = HUGE_VAL;
+ *Longitude = HUGE_VAL;
+ *Height = HUGE_VAL;
+ return;
+ }
+ RX = 1.0/sqrt(denominator);
+ }
CPHI0 = ST*(1.0-gi->Geocent_e2)*RX;
SPHI0 = CT*RX;
iter = 0;
@@ -420,7 +430,17 @@ void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo *gi,
return;
}
RK = gi->Geocent_e2*RN/(RN+*Height);
- RX = 1.0/sqrt(1.0-RK*(2.0-RK)*ST*ST);
+ {
+ const double denominator = 1.0-RK*(2.0-RK)*ST*ST;
+ if( denominator == 0 )
+ {
+ *Latitude = HUGE_VAL;
+ *Longitude = HUGE_VAL;
+ *Height = HUGE_VAL;
+ return;
+ }
+ RX = 1.0/sqrt(denominator);
+ }
CPHI = ST*(1.0-RK)*RX;
SPHI = CT*RX;
SDPHI = SPHI*CPHI0-CPHI*SPHI0;
diff --git a/src/projections/aea.cpp b/src/projections/aea.cpp
index d1c1ad37..7b5c0fb5 100644
--- a/src/projections/aea.cpp
+++ b/src/projections/aea.cpp
@@ -127,6 +127,10 @@ static PJ_LP aea_e_inverse (PJ_XY xy, PJ *P) { /* Ellipsoid/spheroid, inverse
if (Q->ellips) {
lp.phi = (Q->c - lp.phi * lp.phi) / Q->n;
if (fabs(Q->ec - fabs(lp.phi)) > TOL7) {
+ if (fabs(lp.phi) > 2 ) {
+ proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
+ return lp;
+ }
if ((lp.phi = phi1_(lp.phi, P->e, P->one_es)) == HUGE_VAL) {
proj_errno_set(P, PJD_ERR_TOLERANCE_CONDITION);
return lp;
diff --git a/src/projections/eqdc.cpp b/src/projections/eqdc.cpp
index 83443e5b..84e37910 100644
--- a/src/projections/eqdc.cpp
+++ b/src/projections/eqdc.cpp
@@ -117,6 +117,8 @@ PJ *PROJECTION(eqdc) {
} else {
if (secant)
Q->n = (cosphi - cos(Q->phi2)) / (Q->phi2 - Q->phi1);
+ if (Q->n == 0)
+ return destructor (P, PJD_ERR_CONIC_LAT_EQUAL);
Q->c = Q->phi1 + cos(Q->phi1) / Q->n;
Q->rho0 = Q->c - P->phi0;
}
diff --git a/src/projections/geos.cpp b/src/projections/geos.cpp
index 62b66a19..fcd7d4ee 100644
--- a/src/projections/geos.cpp
+++ b/src/projections/geos.cpp
@@ -126,11 +126,11 @@ static PJ_LP geos_s_inverse (PJ_XY xy, PJ *P) { /* Spheroidal, inverse
/* Setting three components of vector from satellite to position.*/
Vx = -1.0;
if(Q->flip_axis) {
- Vz = tan (xy.y / (Q->radius_g - 1.0));
- Vy = tan (xy.x / (Q->radius_g - 1.0)) * sqrt (1.0 + Vz * Vz);
+ Vz = tan (xy.y / Q->radius_g_1);
+ Vy = tan (xy.x / Q->radius_g_1) * sqrt (1.0 + Vz * Vz);
} else {
- Vy = tan (xy.x / (Q->radius_g - 1.0));
- Vz = tan (xy.y / (Q->radius_g - 1.0)) * sqrt (1.0 + Vy * Vy);
+ Vy = tan (xy.x / Q->radius_g_1);
+ Vz = tan (xy.y / Q->radius_g_1) * sqrt (1.0 + Vy * Vy);
}
/* Calculation of terms in cubic equation and determinant.*/
diff --git a/src/projections/isea.cpp b/src/projections/isea.cpp
index b1841338..c712d7ea 100644
--- a/src/projections/isea.cpp
+++ b/src/projections/isea.cpp
@@ -902,7 +902,7 @@ static int isea_hex(struct isea_dgg *g, int tri,
{
throw "Invalid shift";
}
- hex->x = ((int)v.x << 4) + quad;
+ hex->x = ((int)v.x * 16) + quad;
hex->y = v.y;
return 1;
diff --git a/src/transformations/helmert.cpp b/src/transformations/helmert.cpp
index 63785ea5..7a3e64d0 100644
--- a/src/transformations/helmert.cpp
+++ b/src/transformations/helmert.cpp
@@ -612,6 +612,8 @@ PJ *TRANSFORMATION(helmert, 0) {
/* Scale */
if (pj_param (P->ctx, P->params, "ts").i) {
Q->scale_0 = pj_param (P->ctx, P->params, "ds").f;
+ if( Q->scale_0 <= -1.0e6 )
+ return pj_default_destructor (P, PJD_ERR_INVALID_SCALE);
if (pj_param (P->ctx, P->params, "ttheta").i && Q->scale_0 == 0.0)
return pj_default_destructor (P, PJD_ERR_INVALID_SCALE);
}