pgLatLon
changeset 72:8fa0ef5e4ee6
Fixed longitude wraparound for values equal to or greater than 360 degrees
author | jbe |
---|---|
date | Wed Feb 12 13:11:04 2020 +0100 (2020-02-12) |
parents | 57ec3281fbb7 |
children | b5bc6b35b716 |
files | latlon-v0010.c |
line diff
1.1 --- a/latlon-v0010.c Wed Feb 12 12:43:46 2020 +0100 1.2 +++ b/latlon-v0010.c Wed Feb 12 13:11:04 2020 +0100 1.3 @@ -271,12 +271,14 @@ 1.4 if (warn) { 1.5 ereport(NOTICE, (errmsg("longitude west of 180th meridian normalized"))); 1.6 } 1.7 - lon += 360 - trunc(lon / 360) * 360; 1.8 + lon = fmod(lon, 360); 1.9 + if (lon < -180) lon += 360; 1.10 } else if (lon > 180) { 1.11 if (warn) { 1.12 ereport(NOTICE, (errmsg("longitude east of 180th meridian normalized"))); 1.13 } 1.14 - lon -= 360 + trunc(lon / 360) * 360; 1.15 + lon = fmod(lon, 360); 1.16 + if (lon > 180) lon -= 360; 1.17 } 1.18 return lon; 1.19 }