Skip to content

Commit

Permalink
tpeqd: avoid division by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Mar 29, 2019
1 parent 2ed1216 commit 6625a40
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/projections/tpeqd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ PJ *PROJECTION(tpeqd) {
Q->sc = Q->sp1 * Q->cp2;
Q->ccs = Q->cp1 * Q->cp2 * sin(Q->dlam2);
Q->z02 = aacos(P->ctx, Q->sp1 * Q->sp2 + Q->cp1 * Q->cp2 * cos (Q->dlam2));
if( Q->z02 == 0.0 ) {
// Actually happens when both lat_1 = lat_2 and [lat_1| = 90
return pj_default_destructor(P, PJD_ERR_LAT_1_OR_2_ZERO_OR_90);
}
Q->hz0 = .5 * Q->z02;
A12 = atan2(Q->cp2 * sin (Q->dlam2),
Q->cp1 * Q->sp2 - Q->sp1 * Q->cp2 * cos (Q->dlam2));
Expand Down
8 changes: 6 additions & 2 deletions test/gie/builtins.gie
Original file line number Diff line number Diff line change
Expand Up @@ -5243,7 +5243,7 @@ Two Point Equidistant
===============================================================================

-------------------------------------------------------------------------------
operation +proj=tpeqd +ellps=GRS80 +lat_1=0.5 +lat_2=2 +n=0.5
operation +proj=tpeqd +ellps=GRS80 +lat_1=0.5 +lat_2=2
-------------------------------------------------------------------------------
tolerance 0.18 mm
accept 2 1
Expand All @@ -5266,7 +5266,7 @@ accept -200 -100
expect 0.000898554 1.248203369

-------------------------------------------------------------------------------
operation +proj=tpeqd +a=6400000 +lat_1=0.5 +lat_2=2 +n=0.5
operation +proj=tpeqd +a=6400000 +lat_1=0.5 +lat_2=2
-------------------------------------------------------------------------------
tolerance 0.1 mm
accept 2 1
Expand All @@ -5288,6 +5288,10 @@ expect -0.000895485 1.248209507
accept -200 -100
expect 0.000895485 1.248209507

-------------------------------------------------------------------------------
operation +proj=tpeqd +a=6400000 +lat_1=90 +lat_2=90 +lon_1=0 +lon_2=1
-------------------------------------------------------------------------------
expect failure

===============================================================================
Tilted perspective
Expand Down

0 comments on commit 6625a40

Please sign in to comment.