File: load_outdb-pre.pl

package info (click to toggle)
postgis 2.3.1%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 58,660 kB
  • ctags: 10,181
  • sloc: ansic: 132,858; sql: 131,148; xml: 46,460; sh: 4,832; perl: 4,476; makefile: 2,749; python: 1,198; yacc: 442; lex: 131
file content (67 lines) | stat: -rwxr-xr-x 1,694 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use File::Basename;
use Cwd 'abs_path';

my $REGDIR = abs_path(dirname($0));
my $RASTERDIR = abs_path($REGDIR . "/../raster/test/regress");
my $FILERASTER = $RASTERDIR . "/loader/testraster.tif";

# special handling for msys
if (lc($^O) eq "msys") {
	$FILERASTER = `cmd //c echo "$FILERASTER"`;
	$FILERASTER =~ s/^\s+//;
	$FILERASTER =~ s/\s+$//;
}

my $sql = <<"END";
WITH foo AS (
	SELECT postgis_raster_lib_version()
)
SELECT NULL FROM foo;
SET postgis.gdal_enabled_drivers = 'GTiff';
DROP TABLE IF EXISTS raster_outdb_template;
CREATE TABLE raster_outdb_template AS
SELECT
	1 AS rid,
	ST_AddBand( -- insert all three bands of out-db raster at index 1
		ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0),
		1, '$FILERASTER'::text, NULL::int[]
	) AS rast
UNION ALL
SELECT
	2 AS rid,
	ST_AddBand( -- append all three bands of out-db raster
		ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0),
		'$FILERASTER'::text, NULL::int[]
	) AS rast
UNION ALL
SELECT
	3 AS rid,
	ST_AddBand( -- append out-db band 2
		ST_AddBand( -- in-db band
			ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0),
			1, '8BUI', 1, 0
		),
		'$FILERASTER'::text, ARRAY[2]::int[]
	) AS rast
UNION ALL
SELECT
	4 AS rid,
	ST_AddBand( -- append out-db band 2
		ST_AddBand( -- in-db band
			ST_MakeEmptyRaster(90, 50, 0., 0., 1, -1, 0, 0, 0),
			1, '8BUI', 1, 0
		),
		'$FILERASTER'::text, ARRAY[2]::int[],
		1,
		255
	) AS rast
END

open(PRESQL, '>', $RASTERDIR . '/' . $TEST . '-pre.sql');
print PRESQL $sql;
close(PRESQL);

# no longer needed as the "clean" test takes care of it
#open(POSTSQL, '>', $RASTERDIR . '/' . $TEST . '-post.sql');
#print POSTSQL "DROP TABLE IF EXISTS raster_outdb_template;\n";
#close(POSTSQL);