From 095d2204f8bb05d172936aebbb1e9e44852c049f Mon Sep 17 00:00:00 2001 From: Chris Mayo Date: Fri, 29 Mar 2019 19:17:37 +0000 Subject: Remove duplicate instances of #include "proj_internal.h" Introduced by "Merge projects.h into proj_internal.h" 8ab6f683. --- src/conversions/cart.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/conversions/cart.cpp') diff --git a/src/conversions/cart.cpp b/src/conversions/cart.cpp index d9aea9b8..e6942d65 100644 --- a/src/conversions/cart.cpp +++ b/src/conversions/cart.cpp @@ -42,7 +42,6 @@ #define PJ_LIB__ -#include "proj_internal.h" #include "proj_internal.h" #include "proj_math.h" -- cgit v1.2.3 From 3ff04e06a2ba9d40ead861be0ebdb22af45eaa0d Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 19 Apr 2019 14:21:42 +0200 Subject: Inverse cart: better deal with x,y,z equal of very close to zero In that case, for a non-spherical ellipsoid, a phi = 180deg was returned, which caused a division by zero in the foward path of moll.cpp Fixup the latitude to be 0 when that happens. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14348 Credit to OSS Fuzz --- src/conversions/cart.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/conversions/cart.cpp') diff --git a/src/conversions/cart.cpp b/src/conversions/cart.cpp index e6942d65..c1f6f09d 100644 --- a/src/conversions/cart.cpp +++ b/src/conversions/cart.cpp @@ -162,6 +162,12 @@ static PJ_LPZ geodetic (PJ_XYZ cart, PJ *P) { c = cos(theta); s = sin(theta); lpz.phi = atan2 (cart.z + P->e2s*P->b*s*s*s, p - P->es*P->a*c*c*c); + if( fabs(lpz.phi) > M_HALFPI ) { + // this happen on non-sphere ellipsoid when x,y,z is very close to 0 + // there is no single solution to the cart->geodetic conversion in + // that case, so arbitrarily pickup phi = 0. + lpz.phi = 0; + } lpz.lam = atan2 (cart.y, cart.x); N = normal_radius_of_curvature (P->a, P->es, lpz.phi); -- cgit v1.2.3