[postgis-commits] svn - r3674 - in spike/wktraster/rt_pg: . test

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Mon Feb 9 10:23:40 PST 2009


Author: strk
Date: 2009-02-09 10:23:40 -0800 (Mon, 09 Feb 2009)
New Revision: 3674

Added:
   spike/wktraster/rt_pg/test/ops.sql
Modified:
   spike/wktraster/rt_pg/rt_pg.c
Log:
Layout infrastructure for testing operators


Modified: spike/wktraster/rt_pg/rt_pg.c
===================================================================
--- spike/wktraster/rt_pg/rt_pg.c	2009-02-09 18:08:47 UTC (rev 3673)
+++ spike/wktraster/rt_pg/rt_pg.c	2009-02-09 18:23:40 UTC (rev 3674)
@@ -43,9 +43,9 @@
 
 
 /* Define this to debug pgsql RASTER activity */
-#define RT_PG_DEBUG 1
+/*#define RT_PG_DEBUG 1*/
 
-//#define RT_PG_DEBUG_MEM 1
+/*#define RT_PG_DEBUG_MEM 1*/
 
 /*
  * This is required for builds against pgsql 8.2

Added: spike/wktraster/rt_pg/test/ops.sql
===================================================================
--- spike/wktraster/rt_pg/test/ops.sql	2009-02-09 18:08:47 UTC (rev 3673)
+++ spike/wktraster/rt_pg/test/ops.sql	2009-02-09 18:23:40 UTC (rev 3674)
@@ -0,0 +1,114 @@
+-----------------------------------------------------------------------
+-- makeTileGrid( <gridColumns>, <gridRows>, <gridExtent>,
+--               <tileWidth>, <tileHeight> )
+--
+-- Return a set of tuples in the form:
+--     x int, y int, t raster
+-- Containing a subdivision of given extent 
+-- into a grid composed by rasters of the given
+-- dimension in pixels.
+--
+-----------------------------------------------------------------------
+CREATE TYPE tile AS (x int, y int, tile raster);
+CREATE OR REPLACE FUNCTION makegrid (int, int, box2d, int, int)
+    RETURNS SETOF tile
+AS
+'
+DECLARE
+    gridCols alias for $1;
+    gridRows alias for $2;
+    extent alias for $3;
+    tileWidth alias for $4;
+    tileHeight alias for $5;
+    rec tile;
+    scalex float8;
+    scaley float8;
+    ipx float8;
+    ipy float8;
+BEGIN
+	
+    -- compute some sizes
+    -- each tile extent width is extent.width / gridRows
+    scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth;
+    scaley = ((ST_ymax(extent)-ST_ymin(extent))/gridRows)/tileHeight;
+
+    FOR y IN 0..gridRows-1 LOOP
+        ipy = y*scaley + (scaley/2);
+        FOR x IN 0..gridCols-1 LOOP
+            ipx = x*scalex + (scalex/2);
+            rec.x = x;
+            rec.y = y;
+            rec.tile = rt_MakeEmptyRaster(tileWidth, tileHeight, ipx, ipy,
+                                          scalex, scaley, 0, 0, -1);
+            RETURN NEXT rec;
+        END LOOP;
+    END LOOP;
+
+    RETURN;
+END;
+'
+LANGUAGE 'plpgsql';
+
+-----------------------------------------------------------------------
+-- Create a grid of 100x100 rasters
+-----------------------------------------------------------------------
+
+CREATE TABLE rt_test_grid as select * from makegrid(100, 100,
+	'BOX(-100 -100, 100 100)', 1, 1);
+
+
+-----------------------------------------------------------------------
+-- Test = operator
+-----------------------------------------------------------------------
+
+SELECT x, y from rt_test_grid where tile &&
+		rt_MakeEmptyRaster(1, 1, 0.5, 0.5, 1, 1, 0, 0, -1);
+
+-----------------------------------------------------------------------
+-- Test &< operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test >& operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test << operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test >> operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test &<| operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test |&> operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test <<| operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test |>> operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test ~= operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test @ operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test ~ operator
+-----------------------------------------------------------------------
+
+-----------------------------------------------------------------------
+-- Test && operator
+-----------------------------------------------------------------------
+


Property changes on: spike/wktraster/rt_pg/test/ops.sql
___________________________________________________________________
Name: svn:mergeinfo
   + 



More information about the postgis-commits mailing list