]> granicus.if.org Git - postgis/commitdiff
use a new arg identifier winset for window functions.
authorRegina Obe <lr@pcorp.us>
Sat, 27 Feb 2016 08:05:34 +0000 (08:05 +0000)
committerRegina Obe <lr@pcorp.us>
Sat, 27 Feb 2016 08:05:34 +0000 (08:05 +0000)
Update window functions to be flagged as taking input geometry winset
Update templste.xml (to instruct how to flag window and aggregate functions)
Update the comments generation to handle the new geometry winset type arg
Closes #3474
Mark ST_ClusterWithin and ST_ClusterIntersecting
as taking geometry set (so flagged as aggregates)
Closes #3476

git-svn-id: http://svn.osgeo.org/postgis/trunk@14711 b70326c6-7e19-0410-871a-916f4a2858ee

doc/reference_measure.xml
doc/template.xml
doc/xsl/postgis_aggs_mm.xml.xsl
doc/xsl/postgis_comments.sql.xsl

index d1dbf6d467834245886b03232479bce8df6fdcee..78aa03bd6c21a5aebbc64d2a4bd4cd1cfbff6978 100644 (file)
@@ -1062,7 +1062,7 @@ SELECT ST_AsText(
                  <funcprototype>
                        <funcdef>integer <function>ST_ClusterDBSCAN</function></funcdef>
 
-                       <paramdef><type>geometry </type>
+                       <paramdef><type>geometry winset </type>
                        <parameter>geom</parameter></paramdef>
 
                        <paramdef><type>float8 </type>
@@ -1130,7 +1130,7 @@ GROUP BY cid;
         <funcsynopsis>
           <funcprototype>
             <funcdef>geometry[] <function>ST_ClusterIntersecting</function></funcdef>
-            <paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
+            <paramdef><type>geometry set</type> <parameter>g</parameter></paramdef>
           </funcprototype>
         </funcsynopsis>
       </refsynopsisdiv>
@@ -1187,7 +1187,7 @@ GEOMETRYCOLLECTION(LINESTRING(6 6,7 7))
                  <funcprototype>
                        <funcdef>integer <function>ST_ClusterKMeans</function></funcdef>
 
-                       <paramdef><type>geometry </type>
+                       <paramdef><type>geometry winset </type>
                        <parameter>geom</parameter></paramdef>
 
                        <paramdef><type>integer </type>
@@ -1235,7 +1235,7 @@ FROM parcels;
         <funcsynopsis>
           <funcprototype>
             <funcdef>geometry[] <function>ST_ClusterWithin</function></funcdef>
-            <paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
+            <paramdef><type>geometry set </type> <parameter>g</parameter></paramdef>
             <paramdef><type>float8 </type> <parameter>distance</parameter></paramdef>
           </funcprototype>
         </funcsynopsis>
index 8f05ad5ec24d6c4259552416f734c0ccacc38887..56254df3a909a7ad4fd3aa2955a21e7c996ed638 100644 (file)
@@ -14,7 +14,7 @@
         <paramdef><type>geometry </type> <parameter>g2</parameter></paramdef>
       </funcprototype>
 
-      <!-- an optional second method prototype -->
+      <!-- an optional second method prototype with default args -->
       <funcprototype>
         <funcdef>boolean <function>ST_MyMethod</function></funcdef>
         <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
         
         <paramdef choice="opt"><type>varchar </type> <parameter>myparam=the_default_value</parameter></paramdef>
       </funcprototype>
+      
+      <!-- example of a spatial aggregate prototype -->
+      <!-- If your function is an aggregate, the input for the
+        set part eg. set of geometries, should be of type geometry set/geometry set instead of geometry/geography -->
+      <funcprototype>
+        <funcdef>geometry <function>ST_MyMethod</function></funcdef>
+        <paramdef><type>geometry set </type> <parameter>g1</parameter></paramdef>
+      </funcprototype>
+      
+      <!-- example of a spatial window function prototype -->
+      <!-- If your function is window function, the input for the
+        set part (the input to the window) eg. set of geometries, should be of type geometry winset/geometry winset instead of geometry/geography -->
+      <funcprototype>
+        <funcdef>geometry <function>ST_MyMethod</function></funcdef>
+        <paramdef><type>geometry winset </type> <parameter>g1</parameter></paramdef>
+      </funcprototype>
     </funcsynopsis>
   </refsynopsisdiv>
 
index f43d65bd34132796aeb4a255c2a120f629820c2e..92f32752795e4ce76d625859b3372992695cde9a 100644 (file)
                        </xsl:for-each>
                        </itemizedlist>
                </sect1>
+               
+               <sect1 id="PostGIS_Window_Functions">
+                       <title>PostGIS Window Functions</title>
+                       <para>The functions given below are spatial window functions provided with PostGIS that can be used just like any other sql window function such as row_numer(), lead(), lag(). All these require an SQL OVER() clause.</para>
+                       <itemizedlist>
+                       <!-- Pull out the purpose section for each ref entry and strip whitespace and put in a variable to be tagged unto each function comment  -->
+                       <xsl:for-each select='//refentry'>
+                               <xsl:sort select="refnamediv/refname"/>
+                               <xsl:variable name='comment'>
+                                       <xsl:value-of select="normalize-space(translate(translate(refnamediv/refpurpose,'&#x0d;&#x0a;', ' '), '&#09;', ' '))"/>
+                               </xsl:variable>
+                               <xsl:variable name="refid">
+                                       <xsl:value-of select="@id" />
+                               </xsl:variable>
+                               <xsl:variable name="refname">
+                                       <xsl:value-of select="refnamediv/refname" />
+                               </xsl:variable>
+
+                       <!-- For each function prototype if it takes a geometry set then catalog it as an aggregate function  -->
+                               <xsl:for-each select="refsynopsisdiv/funcsynopsis/funcprototype">
+                                       <xsl:choose>
+                                               <xsl:when test="contains(paramdef/type,' winset')">
+                                                        <listitem><simpara><link linkend="{$refid}"><xsl:value-of select="$refname" /></link> - <xsl:value-of select="$comment" /></simpara></listitem>
+                                               </xsl:when>
+                                       </xsl:choose>
+                               </xsl:for-each>
+                       </xsl:for-each>
+                       </itemizedlist>
+               </sect1>
 
                <sect1 id="PostGIS_SQLMM_Functions">
                        <title>PostGIS SQL-MM Compliant Functions</title>
index c0987a4066c4dd1e02de5b2022a4c593641bd1cd..9921e33a745f78e2f10f7852ccf1f1420cd14705 100644 (file)
                </xsl:choose>\r
 <!-- For each function prototype generate the DDL comment statement\r
        If its input is a geometry set - we know it is an aggregate function rather than a regular function \r
+       If its input is a geometry winset we know it is a window function but comment signature of those are the same just have to strip off the winset\r
        Do not output OUT params since they define output rather than act as input and do not put a comma after argument just before an OUT parameter -->\r
                <xsl:for-each select="refsynopsisdiv/funcsynopsis/funcprototype">\r
 COMMENT ON <xsl:choose><xsl:when test="contains(paramdef/type,'geometry set')">AGGREGATE</xsl:when><xsl:otherwise>FUNCTION</xsl:otherwise></xsl:choose><xsl:text> </xsl:text> <xsl:value-of select="funcdef/function" />(<xsl:for-each select="paramdef"><xsl:choose><xsl:when test="count(parameter) &gt; 0"> \r
-<xsl:choose><xsl:when test="contains(parameter,'OUT')"></xsl:when><xsl:when test="contains(type,'geometry set')">geometry</xsl:when><xsl:otherwise><xsl:value-of select="type" /></xsl:otherwise></xsl:choose><xsl:if test="position()&lt;last() and not(contains(parameter,'OUT')) and not(contains(following-sibling::paramdef[1],'OUT'))"><xsl:text>, </xsl:text></xsl:if></xsl:when>\r
+<xsl:choose><xsl:when test="contains(parameter,'OUT')"></xsl:when><xsl:when test="contains(type,'geometry set')">geometry</xsl:when><xsl:when test="contains(type,'geometry winset')">geometry</xsl:when><xsl:when test="contains(type,'geography winset')">geography</xsl:when><xsl:otherwise><xsl:value-of select="type" /></xsl:otherwise></xsl:choose><xsl:if test="position()&lt;last() and not(contains(parameter,'OUT')) and not(contains(following-sibling::paramdef[1],'OUT'))"><xsl:text>, </xsl:text></xsl:if></xsl:when>\r
 </xsl:choose></xsl:for-each>) IS '<xsl:call-template name="listparams"><xsl:with-param name="func" select="." /></xsl:call-template> <xsl:value-of select='$comment' />';\r
                        </xsl:for-each>\r
                </xsl:for-each>\r