ST_Area NaN on some polygons
|Reported by:||rfc2616||Owned by:||pramsey|
In one of our African datasets, we need to calculate ST_Area on the sphere for all polygons. ST_Area is returning NaN for some, but not all, polygons. The affected polygons appear to be equator crossing but otherwise there is no obvious connection and not all equator crossing polygons are affected.
We're confirming the issue on running PostGIS instances as far back as 2.1.2, but chronologically this only surfaced recently for us — at some point in the past year or two these calculations used to pass without any NaN.
The failing polygons vary depending on the exact system and PostGIS version and seem somewhat bizarre and random.
The results below come from 2 systems, my Mac laptop and a Linux server and are slightly different but both broken.
PostgreSQL 9.4.5 on x86_64-apple-darwin15.0.0, compiled by Apple LLVM version 7.0.0 (clang-700.1.76), 64-bit, POSTGIS="2.2.0 r14208" GEOS="3.5.0-CAPI-1.9.0 r4084" PROJ="Rel. 4.9.2, 08 September 2015" GDAL="GDAL 1.11.3, released 2015/09/16" LIBXML="2.9.3" LIBJSON="0.12" RASTER
PostgreSQL 9.3.10 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit, POSTGIS="2.1.2 r12389" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10.1, released 2013/08/26" LIBXML="2.9.1" LIBJSON="UNKNOWN" RASTER
This test polygon is taken from #2918 and still yields NaN on both systems:
select ST_Area('POLYGON((0 78.703946026663,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026663))'::geography,false);
Here I made 1 digit difference in the starting point (…662 vs …663)
select ST_Area('POLYGON((0 78.703946026662,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026662))'::geography,false);
This gets a result, 127516467322130, on the server … but NaN on the laptop.
A different one digit change, …664:
select ST_Area('POLYGON((0 78.703946026664,0 0,179.999997913235 0,179.999997913235 -33.0888306884702,0 78.703946026664))'::geography,false);
yields 127516467322130 on the *laptop* … but NaN on the *server*.
I have no idea how to even go about troubleshooting this, but it's causing us a major headache. Happy to step up with whatever support we can offer to help isolate it! Thanks in advance for any help.