From: Jorge Arévalo Date: Thu, 24 Feb 2011 17:16:35 +0000 (+0000) Subject: Now is not possible to load rasters with different scale in the same table. Related... X-Git-Tag: 2.0.0alpha1~1941 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=12c656a0b36dfb25527abcac520e6d85b06d73ba;p=postgis Now is not possible to load rasters with different scale in the same table. Related ticket #153 git-svn-id: http://svn.osgeo.org/postgis/trunk@6860 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/raster/scripts/python/raster2pgsql.py b/raster/scripts/python/raster2pgsql.py index 29bfe1429..b4880a708 100755 --- a/raster/scripts/python/raster2pgsql.py +++ b/raster/scripts/python/raster2pgsql.py @@ -909,7 +909,7 @@ def wkblify_raster_level(options, ds, level, band_range, infile, i): return (gen_table, tile_count) -def wkblify_raster(options, infile, i): +def wkblify_raster(options, infile, i, previous_gt = None): """Writes given raster dataset using GDAL features into HEX-encoded of WKB for WKT Raster output.""" @@ -931,6 +931,12 @@ def wkblify_raster(options, infile, i): else: band_range = ( 1, ds.RasterCount + 1 ) + # Compare this px size with previous one + current_gt = get_gdal_geotransform(ds) + if previous_gt is not None: + if previous_gt[1] != current_gt[1] or previous_gt[5] != current_gt[5]: + sys.exit('Error: Cannot load raster with different pixel size in the same raster table') + # Generate requested overview level (base raster if level = 1) summary = wkblify_raster_level(options, ds, options.overview_level, band_range, infile, i) SUMMARY.append( summary ) @@ -938,6 +944,8 @@ def wkblify_raster(options, infile, i): # Cleanup ds = None + return current_gt + ################################################################################ def main(): @@ -979,6 +987,7 @@ def main(): i = 0 # Burn all specified input raster files into single WKTRaster table + gt = None for infile in opts.raster: filelist = glob.glob(infile) assert len(filelist) > 0, "No input raster files found for '" + str(infile) + "'" @@ -987,7 +996,7 @@ def main(): logit("MSG: Dataset #%d: %s\n" % (i + 1, filename)) # Write raster data to WKB and send it to opts.output - wkblify_raster(opts, filename.replace( '\\', '/') , i) + gt = wkblify_raster(opts, filename.replace( '\\', '/') , i, gt) i += 1 # INDEX @@ -1008,7 +1017,7 @@ def main(): sys.stdout = saved_out print "------------------------------------------------------------" - print " Summary of GDAL to WKT Raster processing:" + print " Summary of GDAL to PostGIS Raster processing:" print "------------------------------------------------------------" if i == 1: m = '%d (%s)' % (i, infile)