]> granicus.if.org Git - postgis/commitdiff
Expose versions of ST_IsValid and ST_IsValidReason accepting "the ESRI flag" and...
authorSandro Santilli <strk@keybit.net>
Wed, 16 Feb 2011 10:19:22 +0000 (10:19 +0000)
committerSandro Santilli <strk@keybit.net>
Wed, 16 Feb 2011 10:19:22 +0000 (10:19 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@6828 b70326c6-7e19-0410-871a-916f4a2858ee

doc/reference_accessor.xml
postgis/postgis.sql.in.c
regress/isvaliddetail.sql
regress/isvaliddetail_expected

index fe159e8c91907a463645072ff49c1e017bbfe972..ad6d9368c39df3dc92cf685ee591032ef042bd1e 100644 (file)
@@ -1057,6 +1057,12 @@ FROM (SELECT 'LINESTRING(0 0, 0 1, 1 0, 1 1, 0 0)'::geometry AS the_geom) AS foo
 
                        <paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
                  </funcprototype>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_IsValid</function></funcdef>
+
+                       <paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
+                       <paramdef><type>integer </type> <parameter>flags</parameter></paramdef>
+                 </funcprototype>
                </funcsynopsis>
          </refsynopsisdiv>
 
@@ -1066,15 +1072,24 @@ FROM (SELECT 'LINESTRING(0 0, 0 1, 1 0, 1 1, 0 0)'::geometry AS the_geom) AS foo
                <para>Test if an ST_Geometry value is well formed.  For geometries that are invalid,
                        the PostgreSQL NOTICE will provide details of why it is not valid.  For more
                        information on the OGC's definition of geometry simplicity and validity, refer
-                       to <link linkend="OGC_Validity">"Ensuring OpenGIS compliancy of geometries"</link></para>
+                       to <link linkend="OGC_Validity">"Ensuring OpenGIS compliancy of geometries"</link>
+               </para>
                <note>
                        <para>SQL-MM defines the result of ST_IsValid(NULL) to be 0, while
                        PostGIS returns NULL.</para>
                </note>
 
+               <para>
+The version accepting flags is available starting with 2.0.0
+and requires GEOS &gt;= 3.3.0. Such version does not print a NOTICE
+explaining the invalidity.
+Allowed <varname>flags</varname> are documented in <xref linkend="ST_IsValidDetail" />.
+               </para>
+
                <para>&sfs_compliant;</para>
                <para>&sqlmm_compliant; SQL-MM 3: 5.1.9</para>
 
+
          </refsection>
 
          <refsection>
@@ -1115,6 +1130,11 @@ NOTICE:  Self-intersection at or near point 0 0
                        <funcdef>text <function>ST_IsValidReason</function></funcdef>
                        <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
                  </funcprototype>
+                 <funcprototype>
+                       <funcdef>text <function>ST_IsValidReason</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>integer </type> <parameter>flags</parameter></paramdef>
+                 </funcprototype>
                </funcsynopsis>
          </refsynopsisdiv>
 
@@ -1124,7 +1144,13 @@ NOTICE:  Self-intersection at or near point 0 0
                <para>Returns text stating if a geometry is valid or not an if not valid, a reason why.</para>
 
                <para>Useful in combination with ST_IsValid to generate a detailed report of invalid geometries and reasons.</para>
+
+               <para>
+Allowed <varname>flags</varname> are documented in <xref linkend="ST_IsValidDetail" />.
+               </para>
+
                <para>Availability: 1.4 - requires GEOS &gt;= 3.1.0.</para>
+               <para>Availability: 2.0 - requires GEOS &gt;= 3.3.0 for the version taking flags.</para>
 
          </refsection>
 
index 751fbc73c400cee833538e55a59fa3c3e134952c..f6593fc95b68614066a8a77ffced93c2025804f9 100644 (file)
@@ -2945,6 +2945,31 @@ CREATE OR REPLACE FUNCTION ST_IsValidDetail(geometry, int4)
        LANGUAGE 'C' IMMUTABLE STRICT
        COST 100;
 
+#if POSTGIS_GEOS_VERSION >= 33
+-- Requires GEOS >= 3.3.0
+-- Availability: 2.0.0
+CREATE OR REPLACE FUNCTION ST_IsValidReason(geometry, int4)
+       RETURNS text
+       AS $$
+SELECT CASE WHEN valid THEN 'Valid Geometry' ELSE reason END FROM (
+       SELECT (ST_isValidDetail($1, $2)).*
+) foo
+       $$
+       LANGUAGE 'sql' IMMUTABLE STRICT
+       COST 100;
+#endif
+
+#if POSTGIS_GEOS_VERSION >= 33
+-- Requires GEOS >= 3.3.0
+-- Availability: 2.0.0
+CREATE OR REPLACE FUNCTION ST_IsValid(geometry, int4)
+       RETURNS boolean
+       AS 'SELECT (ST_isValidDetail($1, $2)).valid'
+       LANGUAGE 'sql' IMMUTABLE STRICT
+       COST 100;
+#endif
+
+
 #if POSTGIS_GEOS_VERSION >= 32
 -- Requires GEOS >= 3.2.0
 -- Availability: 1.5.0
index 552ae1c2e97ef9f57047b10df54ea69f38925a19..994d57f50da0681f80c19ec414a80730265185b8 100644 (file)
@@ -30,6 +30,10 @@ select 5, valid, reason, st_astext(location) FROM (
   0 -- No flags
   )).*
 ) foo;
+select '5s', ST_IsValid(
+'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 0);
+select '5r', ST_IsValidReason(
+'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 0);
 
 -- Self-touching ring forming hole with ESRI flag
 select 6, valid, reason, st_astext(location) FROM (
@@ -39,3 +43,9 @@ select 6, valid, reason, st_astext(location) FROM (
   1 -- ESRI flag
   )).*
 ) foo;
+select '6s', ST_IsValid(
+'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 1);
+select '5r', ST_IsValidReason(
+'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 1);
+
+
index 50a057ca5332eb3b420165d29d3a383e8e5c35f6..1ae00d1b6a70c2d37d1d14422027a204ed061ef3 100644 (file)
@@ -3,4 +3,8 @@
 3|f|Self-intersection|POINT(70 400)
 4|f|Self-intersection|POINT(70 400)
 5|f|Ring Self-intersection|POINT(70 250)
+5s|f
+5r|Ring Self-intersection
 6|t||
+6s|t
+5r|Valid Geometry