aboutsummaryrefslogtreecommitdiff
path: root/src/geocent.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/geocent.c')
-rw-r--r--src/geocent.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/geocent.c b/src/geocent.c
index 66e2c314..e340e73d 100644
--- a/src/geocent.c
+++ b/src/geocent.c
@@ -414,6 +414,11 @@ void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo *gi,
/* ellipsoidal (geodetic) height */
*Height = P*CPHI0+Z*SPHI0-RN*(1.0-gi->Geocent_e2*SPHI0*SPHI0);
+ /* avoid zero division */
+ if (RN+*Height==0.0) {
+ *Latitude = 0.0;
+ return;
+ }
RK = gi->Geocent_e2*RN/(RN+*Height);
RX = 1.0/sqrt(1.0-RK*(2.0-RK)*ST*ST);
CPHI = ST*(1.0-RK)*RX;