From 3b31a2ccca7bfc8c7af1abfedcc94f63449dcd8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Ar=C3=A9valo?= Date: Sat, 5 Mar 2011 11:00:25 +0000 Subject: [PATCH] is_nan function defined for Python versions under 2.6 git-svn-id: http://svn.osgeo.org/postgis/trunk@6879 b70326c6-7e19-0410-871a-916f4a2858ee --- raster/scripts/python/raster2pgsql.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/raster/scripts/python/raster2pgsql.py b/raster/scripts/python/raster2pgsql.py index b4880a708..7c977e1e4 100755 --- a/raster/scripts/python/raster2pgsql.py +++ b/raster/scripts/python/raster2pgsql.py @@ -70,6 +70,12 @@ g_rt_schema = 'public' VERBOSE = False SUMMARY = [] +def is_nan(x): + if sys.hexversion < 0x02060000: + return str(float(x)).lower() == 'nan' + else: + return math.isnan(x) + def parse_command_line(): """Collects, parses and validates command line arguments.""" @@ -529,7 +535,7 @@ def collect_nodata_values(ds, band_from, band_to): for i in range(band_from, band_to): band = ds.GetRasterBand(i) nodata = band.GetNoDataValue() - if nodata is not None and not math.isnan(nodata): + if nodata is not None and not is_nan(nodata): nd.append(nodata) return nd