1select 1, valid, reason, st_astext(location) FROM ( 2 SELECT (ST_IsValidDetail('LINESTRING (70 250, 190 340)')).* 3) foo; 4 5select 2, valid, reason, st_astext(location) FROM ( 6 SELECT (ST_IsValidDetail('LINESTRING (70 250, 70 250)')).* 7) foo; 8 9-- Twisted polygon 10select 3, valid, reason, st_astext(location) FROM ( 11 SELECT (ST_IsValidDetail( 12'POLYGON ((70 250, 70 500, 80 400, 40 400, 70 250))' 13 )).* 14) foo; 15 16-- Twisted polygon is also invalid for ESRI 17select 4, valid, reason, st_astext(location) FROM ( 18 SELECT (ST_IsValidDetail( 19'POLYGON ((70 250, 70 500, 80 400, 40 400, 70 250))' 20 , 21 1 -- ESRI flag 22 )).* 23) foo; 24 25-- Self-touching ring forming hole 26select 5, valid, reason, st_astext(location) FROM ( 27 SELECT (ST_IsValidDetail( 28'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' 29 , 30 0 -- No flags 31 )).* 32) foo; 33select '5s', ST_IsValid( 34'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 0); 35select '5r', ST_IsValidReason( 36'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 0); 37 38-- Self-touching ring forming hole with ESRI flag 39select 6, valid, reason, st_astext(location) FROM ( 40 SELECT (ST_IsValidDetail( 41'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' 42 , 43 1 -- ESRI flag 44 )).* 45) foo; 46select '6s', ST_IsValid( 47'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 1); 48select '5r', ST_IsValidReason( 49'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 1); 50 51-- Check that it works without the extension schema being available 52BEGIN; 53SET search_path TO pg_catalog; 54select 7, valid, reason, :schema st_astext(location) FROM ( 55 SELECT (:schema ST_IsValidDetail( 56 'POLYGON ((70 250, 70 500, 80 400, 40 400, 70 250))':: :schema geometry 57 )).* 58) foo; 59ROLLBACK; 60 61