From: Jorge Arévalo Date: Sat, 5 Mar 2011 11:00:25 +0000 (+0000) Subject: is_nan function defined for Python versions under 2.6 X-Git-Tag: 2.0.0alpha1~1922 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b31a2ccca7bfc8c7af1abfedcc94f63449dcd8a;p=postgis 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 --- 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