1-- 2-- These tests serve the purpose of ensuring compatibility with 3-- old versions of postgis users. 4-- 5-- Their use rely on loading the legacy.sql script. 6-- This file also serves as a testcase for uninstall_legacy.sql 7-- 8 9SET client_min_messages TO WARNING; 10 11\cd :scriptdir 12\i legacy.sql 13 14SELECT 'Starting up MapServer/Geoserver tests...'; 15-- Set up the data table 16SELECT 'Setting up the data table...'; 17CREATE TABLE wmstest ( id INTEGER ); 18SELECT AddGeometryColumn( 'wmstest', 'pt', 4326, 'POLYGON', 2 ); 19INSERT INTO wmstest SELECT lon * 100 + lat AS id, st_setsrid(st_buffer(st_makepoint(lon, lat),1.0),4326) AS pt 20FROM (select lon, generate_series(-80,80, 5) AS lat FROM (SELECT generate_series(-175, 175, 5) AS lon) AS sq1) AS sq2; 21ALTER TABLE wmstest add PRIMARY KEY ( id ); 22CREATE INDEX wmstest_geomidx ON wmstest using gist ( pt ); 23 24-- Geoserver 2.0 NG tests 25SELECT 'Running Geoserver 2.0 NG tests...'; 26-- Run a Geoserver 2.0 NG metadata query 27SELECT 'Geoserver1', TYPE FROM GEOMETRY_COLUMNS WHERE F_TABLE_SCHEMA = 'public' AND F_TABLE_NAME = 'wmstest' AND F_GEOMETRY_COLUMN = 'pt'; 28SELECT 'Geoserver2', SRID FROM GEOMETRY_COLUMNS WHERE F_TABLE_SCHEMA = 'public' AND F_TABLE_NAME = 'wmstest' AND F_GEOMETRY_COLUMN = 'pt'; 29-- Run a Geoserver 2.0 NG WMS query 30SELECT 'Geoserver3', "id",substr(encode(asBinary(force_2d("pt"),'XDR'),'base64'),0,16) as "pt" FROM "public"."wmstest" WHERE "pt" && GeomFromText('POLYGON ((-6.58216065979069 -0.7685569763184591, -6.58216065979069 0.911225433349509, -3.050569931030911 0.911225433349509, -3.050569931030911 -0.7685569763184591, -6.58216065979069 -0.7685569763184591))', 4326); 31-- Run a Geoserver 2.0 NG KML query 32SELECT 'Geoserver4', count(*) FROM "public"."wmstest" WHERE "pt" && GeomFromText('POLYGON ((-1.504017942347938 24.0332272532341, -1.504017942347938 25.99364254836741, 1.736833353559741 25.99364254836741, 1.736833353559741 24.0332272532341, -1.504017942347938 24.0332272532341))', 4326); 33SELECT 'Geoserver5', "id",substr(encode(asBinary(force_2d("pt"),'XDR'),'base64'),0,16) as "pt" FROM "public"."wmstest" WHERE "pt" && GeomFromText('POLYGON ((-1.504017942347938 24.0332272532341, -1.504017942347938 25.99364254836741, 1.736833353559741 25.99364254836741, 1.736833353559741 24.0332272532341, -1.504017942347938 24.0332272532341))', 4326); 34SELECT 'Geoserver6', "id",substr(encode(asBinary(force_2d("pt"),'XDR'),'base64'),0,16) as "pt" FROM "public"."wmstest" WHERE "pt" && GeomFromText('POLYGON ((-1.507182836191598 24.031312785172446, -1.507182836191598 25.995557016429064, 1.7399982474034008 25.995557016429064, 1.7399982474034008 24.031312785172446, -1.507182836191598 24.031312785172446))', 4326); 35 36-- MapServer 5.4 tests 37select 'MapServer1', attname from pg_attribute, pg_constraint, pg_class where pg_constraint.conrelid = pg_class.oid and pg_class.oid = pg_attribute.attrelid and pg_constraint.contype = 'p' and pg_constraint.conkey[1] = pg_attribute.attnum and pg_class.relname = 'wmstest' and pg_table_is_visible(pg_class.oid) and pg_constraint.conkey[2] is null; 38select 'MapServer2', "id",substr(encode(AsBinary(force_collection(force_2d("pt")),'NDR'),'base64'),0,16) as geom,"id" from wmstest where pt && GeomFromText('POLYGON((-98.5 32,-98.5 39,-91.5 39,-91.5 32,-98.5 32))',find_srid('','wmstest','pt')) order by "id"; 39 40-- MapServer 5.6 tests 41select * from wmstest where false limit 0; 42select 'MapServer3', attname from pg_attribute, pg_constraint, pg_class where pg_constraint.conrelid = pg_class.oid and pg_class.oid = pg_attribute.attrelid and pg_constraint.contype = 'p' and pg_constraint.conkey[1] = pg_attribute.attnum and pg_class.relname = 'wmstest' and pg_table_is_visible(pg_class.oid) and pg_constraint.conkey[2] is null; 43select 'MapServer4', "id",substr(encode(AsBinary(force_collection(force_2d("pt")),'NDR'),'hex'),0,16) as geom,"id" from wmstest where pt && GeomFromText('POLYGON((-98.5 32,-98.5 39,-91.5 39,-91.5 32,-98.5 32))',find_srid('','wmstest','pt')) order by "id"; 44 45-- Drop the data table 46SELECT 'Removing the data table...'; 47DROP TABLE wmstest; 48DELETE FROM geometry_columns WHERE f_table_name = 'wmstest' AND f_table_schema = 'public'; 49SELECT 'Done.'; 50 51-- test #1869 ST_AsBinary is not unique -- 52SELECT 1869 As ticket_id, ST_AsText(ST_AsBinary('POINT(1 2)')); 53 54\i uninstall_legacy.sql 55