]> granicus.if.org Git - postgis/commitdiff
Improve Doc Reference section
authorDarafei Praliaskouski <me@komzpa.net>
Wed, 27 Mar 2019 21:35:38 +0000 (21:35 +0000)
committerDarafei Praliaskouski <me@komzpa.net>
Wed, 27 Mar 2019 21:35:38 +0000 (21:35 +0000)
Patch by Martin Davis

Reorganize functions into new sections:

Spatial Reference System Functions
Affine Transformations
Spatial Relationships
Measurement Functions
Clustering Functions

Also various wording improvements.

References #4332
Closes https://github.com/postgis/postgis/pull/385

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

12 files changed:
doc/Makefile.in
doc/postgis.xml
doc/reference.xml
doc/reference_accessor.xml
doc/reference_cluster.xml [new file with mode: 0644]
doc/reference_editor.xml
doc/reference_measure.xml
doc/reference_processing.xml
doc/reference_relationship.xml [new file with mode: 0644]
doc/reference_srs.xml [new file with mode: 0644]
doc/reference_transaction.xml
doc/reference_transformation.xml [new file with mode: 0644]

index 1c748420170d67484eced21ca1dd8113c8a5ee78..6f4156506ac25a710c7c84ca3a2759e797d52d0f 100644 (file)
@@ -123,6 +123,7 @@ XML_SOURCES = \
        postgis.xml \
        reference_accessor.xml \
        reference_bbox.xml \
+       reference_cluster.xml \
        reference_constructor.xml \
        reference_editor.xml \
        reference_guc.xml \
@@ -134,8 +135,11 @@ XML_SOURCES = \
        reference_output.xml \
        reference_processing.xml \
        reference_raster.xml \
+       reference_relationship.xml \
+       reference_srs.xml \
        reference_trajectory.xml \
        reference_transaction.xml \
+       reference_transformation.xml \
        reference_troubleshooting.xml \
        reference_type.xml \
        reference_version.xml \
index 6bdea852c8ce49cc1502c47f8f1d65830682e604..546d40097e969bb78ebbfe10b14da134e10f8c5e 100644 (file)
@@ -29,6 +29,7 @@
 <!ENTITY reference_type SYSTEM "reference_type.xml">
 <!ENTITY reference_guc SYSTEM "reference_guc.xml">
 <!ENTITY reference_management SYSTEM "reference_management.xml">
+<!ENTITY reference_cluster SYSTEM "reference_cluster.xml">
 <!ENTITY reference_constructor SYSTEM "reference_constructor.xml">
 <!ENTITY reference_accessor SYSTEM "reference_accessor.xml">
 <!ENTITY reference_bbox SYSTEM "reference_bbox.xml">
 <!ENTITY reference_output SYSTEM "reference_output.xml">
 <!ENTITY reference_operator SYSTEM "reference_operator.xml">
 <!ENTITY reference_measure SYSTEM "reference_measure.xml">
+<!ENTITY reference_relationship SYSTEM "reference_relationship.xml">
 <!ENTITY reference_sfcgal SYSTEM "reference_sfcgal.xml">
 <!ENTITY reference_processing SYSTEM "reference_processing.xml">
 <!ENTITY reference_lrs SYSTEM "reference_lrs.xml">
+<!ENTITY reference_srs SYSTEM "reference_srs.xml">
 <!ENTITY reference_trajectory SYSTEM "reference_trajectory.xml">
 <!ENTITY reference_transaction SYSTEM "reference_transaction.xml">
+<!ENTITY reference_transformation SYSTEM "reference_transformation.xml">
 <!ENTITY reference_misc SYSTEM "reference_misc.xml">
 <!ENTITY reference_troubleshooting SYSTEM "reference_troubleshooting.xml">
 <!ENTITY reference_version SYSTEM "reference_version.xml">
index 725f7b650d37ad2c43219f2b61abb7af9c80d05d..a4c707b9a891d2bcf2368e8a3ff397cd1146091d 100644 (file)
   &reference_constructor;
   &reference_accessor;
   &reference_editor;
+  &reference_srs;
+  &reference_transformation;
   &reference_output;
   &reference_operator;
+  &reference_relationship;
   &reference_measure;
   &reference_processing;
+  &reference_cluster;
   &reference_bbox;
   &reference_lrs;
   &reference_trajectory;
index 8399a66d157ae38f91211e45087321f89b2de261..84e428972b670bc061e45726f8b58ccc174ab7c3 100644 (file)
@@ -822,7 +822,50 @@ SELECT ST_AsEWKT(ST_GeometryN(geom,2)) as wkt
                </refsection>
        </refentry>
 
+       <refentry id="ST_HasArc">
+         <refnamediv>
+               <refname>ST_HasArc</refname>
+
+               <refpurpose>Returns true if a geometry or geometry collection contains a circular string</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_HasArc</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns true if a geometry or geometry collection contains a circular string</para>
+
+               <para>Availability: 1.2.3?</para>
+               <para>&Z_support;</para>
+               <para>&curve_support;</para>
+         </refsection>
+
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>SELECT ST_HasArc(ST_Collect('LINESTRING(1 2, 3 4, 5 6)', 'CIRCULARSTRING(1 1, 2 3, 4 5, 6 7, 5 6)'));
+               st_hasarc
+               --------
+               t
+               </programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
 
+               <para><xref linkend="ST_CurveToLine" />, <xref linkend="ST_LineToCurve" /></para>
+         </refsection>
+       </refentry>
 
        <refentry id="ST_InteriorRingN">
          <refnamediv>
@@ -2303,49 +2346,6 @@ MULTIPOINT Z (30 10 4,10 30 5,40 40 6, 30 10 4)
                </refsection>
        </refentry>
 
-       <refentry id="ST_SRID">
-         <refnamediv>
-               <refname>ST_SRID</refname>
-               <refpurpose>Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>integer <function>ST_SRID</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table. <xref linkend="spatial_ref_sys" /></para>
-               <para><note><para>spatial_ref_sys
-               table is a table that catalogs all spatial reference systems known to PostGIS and is used for transformations from one spatial
-                       reference system to another.  So verifying you have the right spatial reference system identifier is important if you plan to ever transform your geometries.</para></note></para>
-               <para>&sfs_compliant; s2.1.1.1</para>
-               <para>&sqlmm_compliant; SQL-MM 3: 5.1.5</para>
-               <para>&curve_support;</para>
-
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>SELECT ST_SRID(ST_GeomFromText('POINT(-71.1043 42.315)',4326));
-               --result
-               4326
-               </programlisting>
-         </refsection>
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="spatial_ref_sys" />, <xref linkend="ST_GeomFromText" />, <xref linkend="ST_SetSRID" />, <xref linkend="ST_Transform" /></para>
-         </refsection>
-       </refentry>
-
        <refentry id="ST_StartPoint">
        <refnamediv>
          <refname>ST_StartPoint</refname>
diff --git a/doc/reference_cluster.xml b/doc/reference_cluster.xml
new file mode 100644 (file)
index 0000000..a33fdd5
--- /dev/null
@@ -0,0 +1,377 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <sect1 id="Clustering_Functions">
+    <sect1info>
+    <abstract>
+    <para>These functions implement clustering algorithms for sets of geometries.</para>
+    </abstract>
+    </sect1info>
+       <title>Clustering Functions</title>
+
+    <refentry id="ST_ClusterDBSCAN">
+         <refnamediv>
+               <refname>ST_ClusterDBSCAN</refname>
+
+        <refpurpose>Window function that returns a cluster id for each input geometry using the DBSCAN algorithm.</refpurpose>
+    </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>integer <function>ST_ClusterDBSCAN</function></funcdef>
+
+                       <paramdef><type>geometry winset </type>
+                       <parameter>geom</parameter></paramdef>
+
+                       <paramdef><type>float8 </type>
+                       <parameter>eps</parameter></paramdef>
+
+                       <paramdef><type>integer </type>
+                       <parameter>minpoints</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+      <title>Description</title>
+
+         <para>
+                 Returns cluster number for each input geometry, based on a 2D implementation of the
+          <ulink url="https://en.wikipedia.org/wiki/DBSCAN">Density-based spatial clustering of applications with noise (DBSCAN)</ulink>
+                 algorithm.  Unlike <xref linkend="ST_ClusterKMeans" />, it does not require the number of clusters to be specified, but instead
+                 uses the desired <link linkend="ST_Distance">distance</link> (<varname>eps</varname>) and density (<varname>minpoints</varname>) parameters to construct each cluster.
+         </para>
+
+         <para>
+                 An input geometry will be added to a cluster if it is either:
+                 <itemizedlist>
+              <listitem>
+                  <para>
+                      A "core" geometry, that is within <varname>eps</varname> <link linkend="ST_Distance">distance</link> of at least <varname>minpoints</varname> input geometries (including itself) or
+                  </para>
+                         </listitem>
+                         <listitem>
+                  <para>
+                      A "border" geometry, that is within <varname>eps</varname> <link linkend="ST_Distance">distance</link> of a core geometry.
+                  </para>
+                         </listitem>
+                 </itemizedlist>
+               </para>
+
+               <para>
+                 Note that border geometries may be within <varname>eps</varname> distance of core geometries in more than one cluster; in this
+                 case, either assignment would be correct, and the border geometry will be arbitrarily asssigned to one of the available clusters.
+                 In these cases, it is possible for a correct cluster to be generated with fewer than <varname>minpoints</varname> geometries.
+                 When assignment of a border geometry is ambiguous, repeated calls to ST_ClusterDBSCAN will produce identical results if an ORDER BY
+                 clause is included in the window definition, but cluster assignments may differ from other implementations of the same algorithm.
+         </para>
+
+         <note><para>
+                 Input geometries that do not meet the criteria to join any other cluster will be assigned a cluster number of NULL.
+         </para></note>
+
+      <para>Availability: 2.3.0</para>
+    </refsection>
+
+    <refsection>
+      <title>Examples</title>
+      <para>
+          Assigning a cluster number to each polygon within 50 meters of each other.  Require at least 2 polygons per cluster
+      </para>
+       <informaltable>
+                                 <tgroup cols="2">
+                                       <tbody>
+                                 <row>
+                                               <entry><para><informalfigure>
+                                                       <mediaobject>
+                                                         <imageobject>
+                                                               <imagedata fileref="images/st_clusterdbscan01.png" />
+                                                         </imageobject>
+                                                         <caption><para>within 50 meters at least 2 per cluster. singletons have NULL for cid</para></caption>
+                                                       </mediaobject>
+                                                 </informalfigure>
+  <programlisting>SELECT name, ST_ClusterDBSCAN(geom, eps := 50, minpoints := 2) over () AS cid
+FROM boston_polys
+WHERE name > '' AND building > ''
+       AND ST_DWithin(geom,
+        ST_Transform(
+            ST_GeomFromText('POINT(-71.04054 42.35141)', 4326), 26986),
+           500);</programlisting>
+                                                 </para></entry>
+
+                                               <entry><para><screen><![CDATA[                name                 | bucket
+-------------------------------------+--------
+ Manulife Tower                      |      0
+ Park Lane Seaport I                 |      0
+ Park Lane Seaport II                |      0
+ Renaissance Boston Waterfront Hotel |      0
+ Seaport Boston Hotel                |      0
+ Seaport Hotel & World Trade Center  |      0
+ Waterside Place                     |      0
+ World Trade Center East             |      0
+ 100 Northern Avenue                 |      1
+ 100 Pier 4                          |      1
+ The Institute of Contemporary Art   |      1
+ 101 Seaport                         |      2
+ District Hall                       |      2
+ One Marina Park Drive               |      2
+ Twenty Two Liberty                  |      2
+ Vertex                              |      2
+ Vertex                              |      2
+ Watermark Seaport                   |      2
+ Blue Hills Bank Pavilion            |   NULL
+ World Trade Center West             |   NULL
+(20 rows)]]></screen></para>
+                               </entry>
+                                         </row>
+                               </tbody>
+                               </tgroup>
+                       </informaltable>
+
+
+        <para>
+            Combining parcels with the same cluster number into a single geometry. This uses named argument calling
+        </para>
+                   <programlisting>
+SELECT cid, ST_Collect(geom) AS cluster_geom, array_agg(parcel_id) AS ids_in_cluster FROM (
+    SELECT parcel_id, ST_ClusterDBSCAN(geom, eps := 0.5, minpoints := 5) over () AS cid, geom
+    FROM parcels) sq
+GROUP BY cid;
+    </programlisting>
+    </refsection>
+
+    <refsection>
+                 <title>See Also</title>
+          <para><xref linkend="ST_DWithin"/>,
+              <xref linkend="ST_ClusterKMeans"/>,
+              <xref linkend="ST_ClusterIntersecting"/>,
+              <xref linkend="ST_ClusterWithin"/>
+          </para>
+         </refsection>
+
+    </refentry>
+
+    <refentry id="ST_ClusterIntersecting">
+      <refnamediv>
+        <refname>ST_ClusterIntersecting</refname>
+
+        <refpurpose>Aggregate function that clusters the input geometries into connected sets.</refpurpose>
+      </refnamediv>
+
+      <refsynopsisdiv>
+        <funcsynopsis>
+          <funcprototype>
+            <funcdef>geometry[] <function>ST_ClusterIntersecting</function></funcdef>
+            <paramdef><type>geometry set</type> <parameter>g</parameter></paramdef>
+          </funcprototype>
+        </funcsynopsis>
+      </refsynopsisdiv>
+
+      <refsection>
+        <title>Description</title>
+
+        <para>ST_ClusterIntersecting is an aggregate function that returns an array of GeometryCollections, where each GeometryCollection represents an interconnected set of geometries.</para>
+
+        <para>Availability: 2.2.0</para>
+      </refsection>
+
+      <refsection>
+        <title>Examples</title>
+        <programlisting>
+WITH testdata AS
+  (SELECT unnest(ARRAY['LINESTRING (0 0, 1 1)'::geometry,
+                      'LINESTRING (5 5, 4 4)'::geometry,
+                      'LINESTRING (6 6, 7 7)'::geometry,
+                      'LINESTRING (0 0, -1 -1)'::geometry,
+                      'POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))'::geometry]) AS geom)
+
+SELECT ST_AsText(unnest(ST_ClusterIntersecting(geom))) FROM testdata;
+
+--result
+
+st_astext
+---------
+GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(5 5,4 4),LINESTRING(0 0,-1 -1),POLYGON((0 0,4 0,4 4,0 4,0 0)))
+GEOMETRYCOLLECTION(LINESTRING(6 6,7 7))
+        </programlisting>
+      </refsection>
+      <refsection>
+        <title>See Also</title>
+        <para>
+            <xref linkend="ST_ClusterDBSCAN" />,
+            <xref linkend="ST_ClusterKMeans" />,
+            <xref linkend="ST_ClusterWithin" />
+        </para>
+      </refsection>
+
+    </refentry>
+
+
+       <refentry id="ST_ClusterKMeans">
+         <refnamediv>
+               <refname>ST_ClusterKMeans</refname>
+
+               <refpurpose>Window function that returns a cluster id for each input geometry using the K-means algorithm.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>integer <function>ST_ClusterKMeans</function></funcdef>
+
+                       <paramdef><type>geometry winset </type>
+                       <parameter>geom</parameter></paramdef>
+
+                       <paramdef><type>integer </type>
+                       <parameter>number_of_clusters</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+      <title>Description</title>
+
+      <para>Returns 2D distance based
+        <ulink url="https://en.wikipedia.org/wiki/K-means_clustering">K-means</ulink>
+        cluster number for each input geometry. The distance used for clustering is the
+        distance between the centroids of the geometries.
+      </para>
+      <para>Availability: 2.3.0</para>
+    </refsection>
+
+    <refsection>
+      <title>Examples</title>
+               <para>Generate dummy set of parcels for examples</para>
+               <programlisting>CREATE TABLE parcels AS
+SELECT lpad((row_number() over())::text,3,'0') As parcel_id, geom,
+('{residential, commercial}'::text[])[1 + mod(row_number()OVER(),2)] As type
+FROM
+    ST_Subdivide(ST_Buffer('LINESTRING(40 100, 98 100, 100 150, 60 90)'::geometry,
+    40, 'endcap=square'),12) As geom;
+</programlisting>
+
+       <informaltable>
+                         <tgroup cols="1">
+                               <tbody>
+                                 <row>
+                                       <entry>
+                                               <para><informalfigure>
+                                               <mediaobject>
+                                                 <imageobject>
+                                                       <imagedata fileref="images/st_clusterkmeans01.png" />
+                                                 </imageobject>
+                                                 <caption><para>Original Parcels</para></caption>
+                                               </mediaobject>
+                                               </informalfigure>
+                                               </para>
+                                       </entry>
+                                       <entry><para><informalfigure>
+                                               <mediaobject>
+                                                 <imageobject>
+                                                       <imagedata fileref="images/st_clusterkmeans02.png" />
+                                                 </imageobject>
+                                                 <caption><para>Parcels color-coded by cluster number (cid)</para></caption>
+                                               </mediaobject>
+                                         </informalfigure>
+                                               <programlisting>SELECT ST_ClusterKMeans(geom, 5) OVER() AS cid, parcel_id, geom
+FROM parcels;
+-- result
+ cid | parcel_id |   geom
+-----+-----------+---------------
+   0 | 001       | 0103000000...
+   0 | 002       | 0103000000...
+   1 | 003       | 0103000000...
+   0 | 004       | 0103000000...
+   1 | 005       | 0103000000...
+   2 | 006       | 0103000000...
+   2 | 007       | 0103000000...
+(7 rows)</programlisting>
+                                       </para></entry>
+                                 </row>
+                       </tbody>
+                       </tgroup>
+               </informaltable>
+
+                   <programlisting> -- Partitioning parcel clusters by type
+SELECT ST_ClusterKMeans(geom,3) over (PARTITION BY type) AS cid, parcel_id, type
+FROM parcels;
+-- result
+ cid | parcel_id |    type
+-----+-----------+-------------
+   1 | 005       | commercial
+   1 | 003       | commercial
+   2 | 007       | commercial
+   0 | 001       | commercial
+   1 | 004       | residential
+   0 | 002       | residential
+   2 | 006       | residential
+(7 rows)</programlisting>
+
+    </refsection>
+
+    <refsection>
+                 <title>See Also</title>
+          <para>
+              <xref linkend="ST_ClusterDBSCAN"/>,
+              <xref linkend="ST_ClusterIntersecting" />,
+              <xref linkend="ST_ClusterWithin" />, <xref linkend="ST_Subdivide" />
+          </para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_ClusterWithin">
+      <refnamediv>
+        <refname>ST_ClusterWithin</refname>
+
+        <refpurpose>Aggregate function that clusters the input geometries by separation distance.</refpurpose>
+      </refnamediv>
+
+      <refsynopsisdiv>
+        <funcsynopsis>
+          <funcprototype>
+            <funcdef>geometry[] <function>ST_ClusterWithin</function></funcdef>
+            <paramdef><type>geometry set </type> <parameter>g</parameter></paramdef>
+            <paramdef><type>float8 </type> <parameter>distance</parameter></paramdef>
+          </funcprototype>
+        </funcsynopsis>
+      </refsynopsisdiv>
+
+      <refsection>
+        <title>Description</title>
+
+        <para>ST_ClusterWithin is an aggregate function that returns an array of GeometryCollections, where each GeometryCollection represents a set of geometries separated by no more than the specified distance.  (Distances are Cartesian distances in the units of the SRID.)</para>
+
+        <para>Availability: 2.2.0</para>
+      </refsection>
+
+      <refsection>
+        <title>Examples</title>
+        <programlisting>
+WITH testdata AS
+  (SELECT unnest(ARRAY['LINESTRING (0 0, 1 1)'::geometry,
+                      'LINESTRING (5 5, 4 4)'::geometry,
+                      'LINESTRING (6 6, 7 7)'::geometry,
+                      'LINESTRING (0 0, -1 -1)'::geometry,
+                      'POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))'::geometry]) AS geom)
+
+SELECT ST_AsText(unnest(ST_ClusterWithin(geom, 1.4))) FROM testdata;
+
+--result
+
+st_astext
+---------
+GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(5 5,4 4),LINESTRING(0 0,-1 -1),POLYGON((0 0,4 0,4 4,0 4,0 0)))
+GEOMETRYCOLLECTION(LINESTRING(6 6,7 7))
+        </programlisting>
+      </refsection>
+      <refsection>
+        <title>See Also</title>
+        <para>
+          <xref linkend="ST_ClusterDBSCAN" />,
+          <xref linkend="ST_ClusterKMeans" />,
+          <xref linkend="ST_ClusterIntersecting" />
+        </para>
+      </refsection>
+
+    </refentry>
+
+</sect1>
index 41aca97b4a52c1450308fe5cba19c5254c12d884..6d236bb65e57a1d3e0bf8cdcb9b34609e920b32b 100644 (file)
                  </refsection>
        </refentry>
 
-       <refentry id="ST_Affine">
-         <refnamediv>
-               <refname>ST_Affine</refname>
 
-               <refpurpose>Apply a 3d affine transformation to a geometry.</refpurpose>
-         </refnamediv>
+       <refentry id="ST_CollectionExtract">
+               <refnamediv>
+                       <refname>ST_CollectionExtract</refname>
 
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_Affine</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>a</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>b</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>c</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>d</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>e</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>f</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>g</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>h</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>i</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>xoff</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>yoff</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>zoff</parameter></paramdef>
-                 </funcprototype>
+                       <refpurpose>
+Given a (multi)geometry, return a (multi)geometry consisting only of elements of the specified type.
+                       </refpurpose>
+               </refnamediv>
 
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_Affine</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>a</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>b</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>d</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>e</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>xoff</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>yoff</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
+               <refsynopsisdiv>
+                       <funcsynopsis>
+                         <funcprototype>
+                               <funcdef>geometry <function>ST_CollectionExtract</function></funcdef>
+                               <paramdef><type>geometry </type> <parameter>collection</parameter></paramdef>
+                               <paramdef><type>integer </type> <parameter>type</parameter></paramdef>
+                         </funcprototype>
+                       </funcsynopsis>
+               </refsynopsisdiv>
 
-         <refsection>
-               <title>Description</title>
+               <refsection>
+                       <title>Description</title>
 
-               <para>Applies a 3d affine transformation to the geometry to do things like translate, rotate, scale in one step.</para>
-               <para>
-               Version 1: The
-                       call <programlisting>ST_Affine(geom, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff) </programlisting>
-                       represents the transformation matrix <programlisting>/ a  b  c  xoff \
-| d  e  f  yoff |
-| g  h  i  zoff |
-\ 0  0  0     1 /</programlisting> and the vertices are transformed as
-                       follows: <programlisting>x' = a*x + b*y + c*z + xoff
-y' = d*x + e*y + f*z + yoff
-z' = g*x + h*y + i*z + zoff</programlisting> All of the translate / scale
-                       functions below are expressed via such an affine
-                       transformation.</para>
-               <para>Version 2: Applies a 2d affine transformation to the geometry. The
-                       call <programlisting>ST_Affine(geom, a, b, d, e, xoff, yoff)</programlisting>
-                       represents the transformation matrix <programlisting>/  a  b  0  xoff  \       /  a  b  xoff  \
-|  d  e  0  yoff  | rsp.  |  d  e  yoff  |
-|  0  0  1     0  |       \  0  0     1  /
-\  0  0  0     1  /</programlisting> and the vertices are transformed as
-                       follows: <programlisting>x' = a*x + b*y + xoff
-y' = d*x + e*y + yoff
-z' = z </programlisting> This method is a subcase of the 3D method
-                       above.</para>
-
-               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
-               <para>Availability: 1.1.2. Name changed from Affine to ST_Affine in 1.2.2</para>
-               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
+                       <para>
+Given a (multi)geometry, returns a (multi)geometry consisting only of elements of the specified type.
+Sub-geometries that are not the specified type are ignored. If there are no sub-geometries of the right type, an EMPTY geometry will be returned.
+Only points, lines and polygons are supported. Type numbers are 1 == POINT, 2 == LINESTRING, 3 == POLYGON.
+                       </para>
 
-               <para>&P_support;</para>
-               <para>&T_support;</para>
-               <para>&Z_support;</para>
-               <para>&curve_support;</para>
-         </refsection>
+                       <para>Availability: 1.5.0</para>
+
+                       <note><para>
+Prior to 1.5.3 this function returned non-collection inputs untouched, no matter type.
+In 1.5.3 non-matching single geometries result in a NULL return.
+In of 2.0.0 every case of missing match results in a typed EMPTY return.
+                       </para></note>
 
+                       <warning><para>When specifying 3 == POLYGON a multipolygon is returned even when the edges are shared.  This results in an invalid multipolygon for many cases
+                       such as applying this function on an <xref linkend="ST_Split" /> result.</para></warning>
 
-         <refsection>
-               <title>Examples</title>
+               </refsection>
 
-               <programlisting>
---Rotate a 3d line 180 degrees about the z axis.  Note this is long-hand for doing ST_Rotate();
- SELECT ST_AsEWKT(ST_Affine(the_geom,  cos(pi()), -sin(pi()), 0,  sin(pi()), cos(pi()), 0,  0, 0, 1,  0, 0, 0)) As using_affine,
-        ST_AsEWKT(ST_Rotate(the_geom, pi())) As using_rotate
-       FROM (SELECT ST_GeomFromEWKT('LINESTRING(1 2 3, 1 4 3)') As the_geom) As foo;
-        using_affine         |        using_rotate
------------------------------+-----------------------------
- LINESTRING(-1 -2 3,-1 -4 3) | LINESTRING(-1 -2 3,-1 -4 3)
+               <refsection>
+                       <title>Examples</title>
+
+                       <programlisting>-- Constants: 1 == POINT, 2 == LINESTRING, 3 == POLYGON
+SELECT ST_AsText(ST_CollectionExtract(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))'),1));
+st_astext
+---------------
+MULTIPOINT(0 0)
 (1 row)
 
---Rotate a 3d line 180 degrees in both the x and z axis
-SELECT ST_AsEWKT(ST_Affine(the_geom, cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), 0, 0, 0))
-       FROM (SELECT ST_GeomFromEWKT('LINESTRING(1 2 3, 1 4 3)') As the_geom) As foo;
-           st_asewkt
--------------------------------
- LINESTRING(-1 -2 -3,-1 -4 -3)
+SELECT ST_AsText(ST_CollectionExtract(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1)),LINESTRING(2 2, 3 3))'),2));
+st_astext
+---------------
+MULTILINESTRING((0 0, 1 1), (2 2, 3 3))
 (1 row)
-               </programlisting>
-         </refsection>
+                       </programlisting>
+               </refsection>
+               <refsection>
+                       <title>See Also</title>
+                       <para><xref linkend="ST_Multi" />, <xref linkend="ST_Dump" />, <xref linkend="ST_CollectionHomogenize" /></para>
+               </refsection>
+       </refentry>
 
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
+               <refentry id="ST_CollectionHomogenize">
+                       <refnamediv>
+                               <refname>ST_CollectionHomogenize</refname>
 
-               <para><xref linkend="ST_Rotate" />, <xref linkend="ST_Scale" />, <xref linkend="ST_Translate" />, <xref linkend="ST_TransScale" /></para>
-         </refsection>
-       </refentry>
+                               <refpurpose>
+       Given a geometry collection, return the "simplest" representation of the contents.
+                               </refpurpose>
+                       </refnamediv>
+
+                       <refsynopsisdiv>
+                               <funcsynopsis>
+                                 <funcprototype>
+                                       <funcdef>geometry <function>ST_CollectionHomogenize</function></funcdef>
+                                       <paramdef><type>geometry </type> <parameter>collection</parameter></paramdef>
+                                 </funcprototype>
+                               </funcsynopsis>
+                       </refsynopsisdiv>
+
+                       <refsection>
+                               <title>Description</title>
+
+                               <para>
+                                       Given a geometry collection, returns the "simplest" representation of the contents.  Singletons will be returned as singletons.  Collections that are homogeneous will be returned as the appropriate multi-type.
+                               </para>
+
+                               <warning><para>When specifying 3 == POLYGON a multipolygon is returned even when the edges are shared.  This results in an invalid multipolygon for many cases
+                       such as applying this function on an <xref linkend="ST_Split" /> result.</para></warning>
+
+
+                               <para>Availability: 2.0.0</para>
+
+                       </refsection>
+
+                       <refsection>
+                               <title>Examples</title>
+
+                               <programlisting>
+  SELECT ST_AsText(ST_CollectionHomogenize('GEOMETRYCOLLECTION(POINT(0 0))'));
+
+       st_astext
+       ------------
+        POINT(0 0)
+       (1 row)
+
+  SELECT ST_AsText(ST_CollectionHomogenize('GEOMETRYCOLLECTION(POINT(0 0),POINT(1 1))'));
+
+       st_astext
+       ---------------------
+        MULTIPOINT(0 0,1 1)
+       (1 row)
+
+                               </programlisting>
+                       </refsection>
+                       <refsection>
+                               <title>See Also</title>
+                               <para><xref linkend="ST_Multi" />, <xref linkend="ST_CollectionExtract" /></para>
+                       </refsection>
+               </refentry>
 
        <refentry id="ST_Force2D">
          <refnamediv>
@@ -845,21 +861,18 @@ LINESTRING Z (-30 -29.7 5,-29 -27 11,-30 -29.7 10,-36 -31 5,-45 -33 1,-46 -32 11
                </refsection>
        </refentry>
 
-       <refentry id="ST_CollectionExtract">
+       <refentry id="ST_Multi">
                <refnamediv>
-                       <refname>ST_CollectionExtract</refname>
+                       <refname>ST_Multi</refname>
 
-                       <refpurpose>
-Given a (multi)geometry, return a (multi)geometry consisting only of elements of the specified type.
-                       </refpurpose>
+                       <refpurpose>Return the geometry as a MULTI* geometry.</refpurpose>
                </refnamediv>
 
                <refsynopsisdiv>
                        <funcsynopsis>
                          <funcprototype>
-                               <funcdef>geometry <function>ST_CollectionExtract</function></funcdef>
-                               <paramdef><type>geometry </type> <parameter>collection</parameter></paramdef>
-                               <paramdef><type>integer </type> <parameter>type</parameter></paramdef>
+                               <funcdef>geometry <function>ST_Multi</function></funcdef>
+                               <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
                          </funcprototype>
                        </funcsynopsis>
                </refsynopsisdiv>
@@ -867,185 +880,65 @@ Given a (multi)geometry, return a (multi)geometry consisting only of elements of
                <refsection>
                        <title>Description</title>
 
-                       <para>
-Given a (multi)geometry, returns a (multi)geometry consisting only of elements of the specified type.
-Sub-geometries that are not the specified type are ignored. If there are no sub-geometries of the right type, an EMPTY geometry will be returned.
-Only points, lines and polygons are supported. Type numbers are 1 == POINT, 2 == LINESTRING, 3 == POLYGON.
-                       </para>
-
-                       <para>Availability: 1.5.0</para>
-
-                       <note><para>
-Prior to 1.5.3 this function returned non-collection inputs untouched, no matter type.
-In 1.5.3 non-matching single geometries result in a NULL return.
-In of 2.0.0 every case of missing match results in a typed EMPTY return.
-                       </para></note>
-
-                       <warning><para>When specifying 3 == POLYGON a multipolygon is returned even when the edges are shared.  This results in an invalid multipolygon for many cases
-                       such as applying this function on an <xref linkend="ST_Split" /> result.</para></warning>
+                       <para>Returns the geometry as a MULTI* geometry. If the geometry
+                               is already a MULTI*, it is returned unchanged.</para>
 
                </refsection>
 
                <refsection>
                        <title>Examples</title>
 
-                       <programlisting>-- Constants: 1 == POINT, 2 == LINESTRING, 3 == POLYGON
-SELECT ST_AsText(ST_CollectionExtract(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(0 0)))'),1));
-st_astext
----------------
-MULTIPOINT(0 0)
-(1 row)
-
-SELECT ST_AsText(ST_CollectionExtract(ST_GeomFromText('GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1)),LINESTRING(2 2, 3 3))'),2));
-st_astext
----------------
-MULTILINESTRING((0 0, 1 1), (2 2, 3 3))
-(1 row)
+                       <programlisting>SELECT ST_AsText(ST_Multi(ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
+                       743265 2967450,743265.625 2967416,743238 2967416))')));
+                       st_astext
+                       --------------------------------------------------------------------------------------------------
+                       MULTIPOLYGON(((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,
+                       743238 2967416)))
+                       (1 row)
                        </programlisting>
                </refsection>
                <refsection>
                        <title>See Also</title>
-                       <para><xref linkend="ST_Multi" />, <xref linkend="ST_Dump" />, <xref linkend="ST_CollectionHomogenize" /></para>
+                       <para><xref linkend="ST_AsText" /></para>
                </refsection>
        </refentry>
 
-               <refentry id="ST_CollectionHomogenize">
-                       <refnamediv>
-                               <refname>ST_CollectionHomogenize</refname>
-
-                               <refpurpose>
-       Given a geometry collection, return the "simplest" representation of the contents.
-                               </refpurpose>
-                       </refnamediv>
-
-                       <refsynopsisdiv>
-                               <funcsynopsis>
-                                 <funcprototype>
-                                       <funcdef>geometry <function>ST_CollectionHomogenize</function></funcdef>
-                                       <paramdef><type>geometry </type> <parameter>collection</parameter></paramdef>
-                                 </funcprototype>
-                               </funcsynopsis>
-                       </refsynopsisdiv>
-
-                       <refsection>
-                               <title>Description</title>
-
-                               <para>
-                                       Given a geometry collection, returns the "simplest" representation of the contents.  Singletons will be returned as singletons.  Collections that are homogeneous will be returned as the appropriate multi-type.
-                               </para>
+       <refentry id="ST_Normalize">
+               <refnamediv>
+                       <refname>ST_Normalize</refname>
 
-                               <warning><para>When specifying 3 == POLYGON a multipolygon is returned even when the edges are shared.  This results in an invalid multipolygon for many cases
-                       such as applying this function on an <xref linkend="ST_Split" /> result.</para></warning>
+                       <refpurpose>Return the geometry in its canonical form.</refpurpose>
+               </refnamediv>
 
+               <refsynopsisdiv>
+                       <funcsynopsis>
+                         <funcprototype>
+                               <funcdef>geometry <function>ST_Normalize</function></funcdef>
+                               <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
+                         </funcprototype>
+                       </funcsynopsis>
+               </refsynopsisdiv>
 
-                               <para>Availability: 2.0.0</para>
+               <refsection>
+                       <title>Description</title>
 
-                       </refsection>
+                       <para>
+        Returns the geometry in its normalized/canonical form.
+        May reorder vertices in polygon rings, rings in a polygon,
+        elements in a multi-geometry complex.
+      </para>
 
-                       <refsection>
-                               <title>Examples</title>
+                       <para>
+        Mostly only useful for testing purposes (comparing expected
+        and obtained results).
+      </para>
 
-                               <programlisting>
-  SELECT ST_AsText(ST_CollectionHomogenize('GEOMETRYCOLLECTION(POINT(0 0))'));
+      <para>Availability: 2.3.0</para>
 
-       st_astext
-       ------------
-        POINT(0 0)
-       (1 row)
+               </refsection>
 
-  SELECT ST_AsText(ST_CollectionHomogenize('GEOMETRYCOLLECTION(POINT(0 0),POINT(1 1))'));
-
-       st_astext
-       ---------------------
-        MULTIPOINT(0 0,1 1)
-       (1 row)
-
-                               </programlisting>
-                       </refsection>
-                       <refsection>
-                               <title>See Also</title>
-                               <para><xref linkend="ST_Multi" />, <xref linkend="ST_CollectionExtract" /></para>
-                       </refsection>
-               </refentry>
-
-       <refentry id="ST_Multi">
-               <refnamediv>
-                       <refname>ST_Multi</refname>
-
-                       <refpurpose>Return the geometry as a MULTI* geometry.</refpurpose>
-               </refnamediv>
-
-               <refsynopsisdiv>
-                       <funcsynopsis>
-                         <funcprototype>
-                               <funcdef>geometry <function>ST_Multi</function></funcdef>
-                               <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
-                         </funcprototype>
-                       </funcsynopsis>
-               </refsynopsisdiv>
-
-               <refsection>
-                       <title>Description</title>
-
-                       <para>Returns the geometry as a MULTI* geometry. If the geometry
-                               is already a MULTI*, it is returned unchanged.</para>
-
-               </refsection>
-
-               <refsection>
-                       <title>Examples</title>
-
-                       <programlisting>SELECT ST_AsText(ST_Multi(ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
-                       743265 2967450,743265.625 2967416,743238 2967416))')));
-                       st_astext
-                       --------------------------------------------------------------------------------------------------
-                       MULTIPOLYGON(((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,
-                       743238 2967416)))
-                       (1 row)
-                       </programlisting>
-               </refsection>
-               <refsection>
-                       <title>See Also</title>
-                       <para><xref linkend="ST_AsText" /></para>
-               </refsection>
-       </refentry>
-
-       <refentry id="ST_Normalize">
-               <refnamediv>
-                       <refname>ST_Normalize</refname>
-
-                       <refpurpose>Return the geometry in its canonical form.</refpurpose>
-               </refnamediv>
-
-               <refsynopsisdiv>
-                       <funcsynopsis>
-                         <funcprototype>
-                               <funcdef>geometry <function>ST_Normalize</function></funcdef>
-                               <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
-                         </funcprototype>
-                       </funcsynopsis>
-               </refsynopsisdiv>
-
-               <refsection>
-                       <title>Description</title>
-
-                       <para>
-        Returns the geometry in its normalized/canonical form.
-        May reorder vertices in polygon rings, rings in a polygon,
-        elements in a multi-geometry complex.
-      </para>
-
-                       <para>
-        Mostly only useful for testing purposes (comparing expected
-        and obtained results).
-      </para>
-
-      <para>Availability: 2.3.0</para>
-
-               </refsection>
-
-               <refsection>
-                       <title>Examples</title>
+               <refsection>
+                       <title>Examples</title>
 
                        <programlisting>
 SELECT ST_AsText(ST_Normalize(ST_GeomFromText(
@@ -1327,379 +1220,6 @@ LINESTRING(1 2,1 10) | LINESTRING(1 10,1 2)
          </refsection>
        </refentry>
 
-       <refentry id="ST_Rotate">
-         <refnamediv>
-               <refname>ST_Rotate</refname>
-
-               <refpurpose>Rotate a geometry rotRadians counter-clockwise about an origin.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_Rotate</function></funcdef>
-                       <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
-                 </funcprototype>
-
-                 <funcprototype>
-                        <funcdef>geometry <function>ST_Rotate</function></funcdef>
-                        <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
-                        <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
-                        <paramdef><type>float</type> <parameter>x0</parameter></paramdef>
-                        <paramdef><type>float</type> <parameter>y0</parameter></paramdef>
-                  </funcprototype>
-
-                 <funcprototype>
-                        <funcdef>geometry <function>ST_Rotate</function></funcdef>
-                        <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
-                        <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
-                        <paramdef><type>geometry</type> <parameter>pointOrigin</parameter></paramdef>
-                  </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Rotates geometry rotRadians counter-clockwise about the origin. The rotation origin can be
-                       specified either as a POINT geometry, or as x and y coordinates. If the origin is not
-                       specified, the geometry is rotated about POINT(0 0).</para>
-
-               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
-               <para>Enhanced: 2.0.0 additional parameters for specifying the origin of rotation were added.</para>
-               <para>Availability: 1.1.2. Name changed from Rotate to ST_Rotate in 1.2.2</para>
-               <para>&Z_support;</para>
-               <para>&curve_support;</para>
-               <para>&P_support;</para>
-               <para>&T_support;</para>
-
-         </refsection>
-
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>
---Rotate 180 degrees
-SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi()));
-               st_asewkt
----------------------------------------
- LINESTRING(-50 -160,-50 -50,-100 -50)
-(1 row)
-
---Rotate 30 degrees counter-clockwise at x=50, y=160
-SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi()/6, 50, 160));
-                                 st_asewkt
----------------------------------------------------------------------------
- LINESTRING(50 160,105 64.7372055837117,148.301270189222 89.7372055837117)
-(1 row)
-
---Rotate 60 degrees clockwise from centroid
-SELECT ST_AsEWKT(ST_Rotate(geom, -pi()/3, ST_Centroid(geom)))
-FROM (SELECT 'LINESTRING (50 160, 50 50, 100 50)'::geometry AS geom) AS foo;
-                           st_asewkt
---------------------------------------------------------------
- LINESTRING(116.4225 130.6721,21.1597 75.6721,46.1597 32.3708)
-(1 row)
-               </programlisting>
-         </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_Affine" />, <xref linkend="ST_RotateX" />, <xref linkend="ST_RotateY" />, <xref linkend="ST_RotateZ" /></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_RotateX">
-         <refnamediv>
-               <refname>ST_RotateX</refname>
-
-               <refpurpose>Rotate a geometry rotRadians about the X axis.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_RotateX</function></funcdef>
-                       <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Rotate a geometry geomA - rotRadians about the X axis.</para>
-
-               <note><para><code>ST_RotateX(geomA,  rotRadians)</code>
-                       is short-hand for <code>ST_Affine(geomA, 1, 0, 0, 0, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 0, 0, 0)</code>.</para></note>
-
-               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
-               <para>Availability: 1.1.2. Name changed from RotateX to ST_RotateX in 1.2.2</para>
-               <para>&P_support;</para>
-               <para>&Z_support;</para>
-               <para>&T_support;</para>
-         </refsection>
-
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>
---Rotate a line 90 degrees along x-axis
-SELECT ST_AsEWKT(ST_RotateX(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
-                st_asewkt
----------------------------
- LINESTRING(1 -3 2,1 -1 1)
-</programlisting>
-         </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_Affine" />, <xref linkend="ST_RotateY" />, <xref linkend="ST_RotateZ" /></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_RotateY">
-         <refnamediv>
-               <refname>ST_RotateY</refname>
-
-               <refpurpose>Rotate a geometry rotRadians about the Y axis.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_RotateY</function></funcdef>
-                       <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Rotate a geometry geomA - rotRadians about the y axis.</para>
-
-               <note><para><code>ST_RotateY(geomA,  rotRadians)</code>
-                       is short-hand for <code>ST_Affine(geomA,  cos(rotRadians), 0, sin(rotRadians),  0, 1, 0,  -sin(rotRadians), 0, cos(rotRadians), 0,  0, 0)</code>.</para></note>
-
-               <para>Availability: 1.1.2. Name changed from RotateY to ST_RotateY in 1.2.2</para>
-               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
-
-               <para>&P_support;</para>
-               <para>&Z_support;</para>
-               <para>&T_support;</para>
-
-         </refsection>
-
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>
---Rotate a line 90 degrees along y-axis
- SELECT ST_AsEWKT(ST_RotateY(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
-                st_asewkt
----------------------------
- LINESTRING(3 2 -1,1 1 -1)
-</programlisting>
-         </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_Affine" />, <xref linkend="ST_RotateX" />, <xref linkend="ST_RotateZ" /></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_RotateZ">
-         <refnamediv>
-               <refname>ST_RotateZ</refname>
-
-               <refpurpose>Rotate a geometry rotRadians about the Z axis.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_RotateZ</function></funcdef>
-                       <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Rotate a geometry geomA - rotRadians about the Z axis.</para>
-
-               <note><para>This is a synonym for ST_Rotate</para></note>
-               <note><para><code>ST_RotateZ(geomA,  rotRadians)</code>
-                       is short-hand for <code>SELECT ST_Affine(geomA,  cos(rotRadians), -sin(rotRadians), 0,  sin(rotRadians), cos(rotRadians), 0,  0, 0, 1,  0, 0, 0)</code>.</para></note>
-
-               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
-
-               <para>Availability: 1.1.2. Name changed from RotateZ to ST_RotateZ in 1.2.2</para>
-               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
-
-               <para>&Z_support;</para>
-               <para>&curve_support;</para>
-               <para>&P_support;</para>
-               <para>&T_support;</para>
-         </refsection>
-
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>
---Rotate a line 90 degrees along z-axis
-SELECT ST_AsEWKT(ST_RotateZ(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
-                st_asewkt
----------------------------
- LINESTRING(-2 1 3,-1 1 1)
-
- --Rotate a curved circle around z-axis
-SELECT ST_AsEWKT(ST_RotateZ(the_geom, pi()/2))
-FROM (SELECT ST_LineToCurve(ST_Buffer(ST_GeomFromText('POINT(234 567)'), 3)) As the_geom) As foo;
-
-                                                                                                          st_asewkt
-----------------------------------------------------------------------------------------------------------------------------
- CURVEPOLYGON(CIRCULARSTRING(-567 237,-564.87867965644 236.12132034356,-564 234,-569.12132034356 231.87867965644,-567 237))
-
-</programlisting>
-         </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_Affine" />, <xref linkend="ST_RotateX" />, <xref linkend="ST_RotateY" /></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_Scale">
-         <refnamediv>
-               <refname>ST_Scale</refname>
-
-               <refpurpose>Scale a geometry by given factors.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_Scale</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>XFactor</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>YFactor</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>ZFactor</parameter></paramdef>
-                 </funcprototype>
-
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_Scale</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>XFactor</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>YFactor</parameter></paramdef>
-                 </funcprototype>
-
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_Scale</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
-                       <paramdef><type>geometry</type> <parameter>factor</parameter></paramdef>
-                 </funcprototype>
-
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_Scale</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
-                       <paramdef><type>geometry</type> <parameter>factor</parameter></paramdef>
-                       <paramdef><type>geometry</type> <parameter>origin</parameter></paramdef>
-                 </funcprototype>
-
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Scales the geometry to a new size by multiplying the
-                       ordinates with the corresponding factor parameters.
-               </para>
-
-               <para>
-The version taking a geometry as the <varname>factor</varname> parameter
-allows passing a 2d, 3dm, 3dz or 4d point to set scaling factor for all
-supported dimensions. Missing dimensions in the <varname>factor</varname>
-point are equivalent to no scaling the corresponding dimension.
-    </para>
-    <para>
-        The three-geometry variant allows a "false origin" for the scaling to be passed in. This allows "scaling in place", for example using the centroid of the geometry as the false origin. Without a false origin, scaling takes place relative to the actual origin, so all coordinates are just multipled by the scale factor.
-    </para>
-
-               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
-
-
-               <para>Availability: 1.1.0.</para>
-               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
-                <para>Enhanced: 2.2.0 support for scaling all dimension (<varname>factor</varname> parameter) was introduced.</para>
-                <para>Enhanced: 2.5.0 support for scaling relative to a local origin (<varname>origin</varname> parameter) was introduced.</para>
-               <para>&P_support;</para>
-               <para>&Z_support;</para>
-               <para>&curve_support;</para>
-               <para>&T_support;</para>
-               <para>&M_support;</para>
-         </refsection>
-
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>--Version 1: scale X, Y, Z
-SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 0.75, 0.8));
-                         st_asewkt
---------------------------------------
- LINESTRING(0.5 1.5 2.4,0.5 0.75 0.8)
-
---Version 2: Scale X Y
- SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 0.75));
-                       st_asewkt
-----------------------------------
- LINESTRING(0.5 1.5 3,0.5 0.75 1)
-
---Version 3: Scale X Y Z M
- SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3 4, 1 1 1 1)'),
-   ST_MakePoint(0.5, 0.75, 2, -1)));
-                              st_asewkt
-----------------------------------------
- LINESTRING(0.5 1.5 6 -4,0.5 0.75 2 -1)
-
---Version 4: Scale X Y using false origin
-SELECT ST_AsText(ST_Scale('LINESTRING(1 1, 2 2)', 'POINT(2 2)', 'POINT(1 1)'::geometry));
-      st_astext
----------------------
- LINESTRING(1 1,3 3)
-
-</programlisting>
-         </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_Affine" />, <xref linkend="ST_TransScale" /></para>
-         </refsection>
-       </refentry>
-
        <refentry id="ST_Segmentize">
                <refnamediv>
                        <refname>ST_Segmentize</refname>
@@ -1826,66 +1346,6 @@ LINESTRING(0 0,1 1,0 0,3 3,4 4)
                  </refsection>
        </refentry>
 
-       <refentry id="ST_SetSRID">
-         <refnamediv>
-               <refname>ST_SetSRID</refname>
-
-               <refpurpose>Set the SRID on a geometry to a particular integer
-               value.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_SetSRID</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>geom</parameter></paramdef>
-
-                       <paramdef><type>integer </type>
-                       <parameter>srid</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Sets the SRID on a geometry to a particular integer value.
-               Useful in constructing bounding boxes for queries.</para>
-
-               <note>
-                 <para>This function does not transform the geometry coordinates in any way -
-                 it simply sets the meta data defining the spatial reference system the geometry is assumed to be in.
-                 Use <xref linkend="ST_Transform"/> if you want to transform the
-                 geometry into a new projection.</para>
-               </note>
-               <para>&sfs_compliant;</para>
-               <para>&curve_support;</para>
-         </refsection>
-
-         <refsection>
-                       <title>Examples</title>
-                       <para>-- Mark a point as WGS 84 long lat --</para>
-                       <programlisting>SELECT ST_SetSRID(ST_Point(-123.365556, 48.428611),4326) As wgs84long_lat;
--- the ewkt representation (wrap with ST_AsEWKT) -
-SRID=4326;POINT(-123.365556 48.428611)
-                       </programlisting>
-                       <para>-- Mark a point as WGS 84 long lat and then transform to web mercator (Spherical Mercator) --</para>
-                       <programlisting>SELECT ST_Transform(ST_SetSRID(ST_Point(-123.365556, 48.428611),4326),3785) As spere_merc;
--- the ewkt representation (wrap with ST_AsEWKT) -
-SRID=3785;POINT(-13732990.8753491 6178458.96425423)
-                       </programlisting>
-               </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="spatial_ref_sys" />, <xref linkend="ST_AsEWKT"/>,  <xref linkend="ST_Point" />, <xref linkend="ST_SRID"/>, <xref linkend="ST_Transform"/>, <xref linkend="UpdateGeometrySRID"/></para>
-         </refsection>
-
-       </refentry>
-
        <refentry id="ST_SnapToGrid">
          <refnamediv>
                <refname>ST_SnapToGrid</refname>
@@ -2221,309 +1681,65 @@ LINESTRING(26 125,54 84,101 100)
          </refsection>
        </refentry>
 
-       <refentry id="ST_Transform">
+       <refentry id="ST_SwapOrdinates">
          <refnamediv>
-               <refname>ST_Transform</refname>
-
-               <refpurpose>Return a new geometry with its coordinates transformed to
-                       a different spatial reference.</refpurpose>
+               <refname>ST_SwapOrdinates</refname>
+               <refpurpose>Returns a version of the given geometry with
+                               given ordinate values swapped.
+    </refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
                <funcsynopsis>
                  <funcprototype>
-                       <funcdef>geometry <function>ST_Transform</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
-                       <paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
+                       <funcdef>geometry <function>ST_SwapOrdinates</function></funcdef>
+                       <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
+                       <paramdef><type>cstring</type> <parameter>ords</parameter></paramdef>
                  </funcprototype>
-
-          <funcprototype>
-              <funcdef>geometry <function>ST_Transform</function></funcdef>
-              <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
-              <paramdef><type>text </type> <parameter>to_proj</parameter></paramdef>
-          </funcprototype>
-
-          <funcprototype>
-              <funcdef>geometry <function>ST_Transform</function></funcdef>
-              <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
-              <paramdef><type>text </type> <parameter>from_proj</parameter></paramdef>
-              <paramdef><type>text </type> <parameter>to_proj</parameter></paramdef>
-          </funcprototype>
-
-          <funcprototype>
-              <funcdef>geometry <function>ST_Transform</function></funcdef>
-              <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
-              <paramdef><type>text </type> <parameter>from_proj</parameter></paramdef>
-              <paramdef><type>integer </type> <parameter>to_srid</parameter></paramdef>
-          </funcprototype>
-
                </funcsynopsis>
          </refsynopsisdiv>
 
          <refsection>
                <title>Description</title>
-
-        <para>Returns a new geometry with its coordinates transformed to
-            a different spatial reference system. The destination spatial
-                       reference <varname>to_srid</varname> may be identified by a valid
-                       SRID integer parameter (i.e. it must exist in the
-                       <varname>spatial_ref_sys</varname> table).
-                       Alternatively, a spatial reference defined as a PROJ.4 string
-                       can be used for <varname>to_proj</varname> and/or
-                       <varname>from_proj</varname>, however these methods are not
-                       optimized. If the destination spatial reference system is
-                       expressed with a PROJ.4 string instead of an SRID, the SRID of the
-                       output geometry will be set to zero. With the exception of functions with
-                       <varname>from_proj</varname>, input geometries must have a defined SRID.
-               </para>
-
-               <para>ST_Transform is often confused with ST_SetSRID().  ST_Transform actually changes the coordinates
-               of a geometry from one spatial reference system to another, while ST_SetSRID() simply changes the SRID identifier of
-               the geometry.</para>
-
-               <note>
-                 <para>Requires PostGIS be compiled with Proj support.  Use <xref linkend="PostGIS_Full_Version" /> to confirm you have proj support compiled in.</para>
-               </note>
-
-               <note>
-                 <para>If using more than one transformation, it is useful to have a functional index on the commonly used
-                       transformations to take advantage of index usage.</para>
-               </note>
-
-               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
-
-               <para>Enhanced: 2.0.0 support for Polyhedral surfaces was introduced.</para>
-               <para>Enhanced: 2.3.0 support for direct PROJ.4 text was introduced.</para>
-               <para>&sqlmm_compliant; SQL-MM 3: 5.1.6</para>
+               <para>
+Returns a version of the given geometry with given ordinates swapped.
+    </para>
+               <para>
+The <varname>ords</varname> parameter is a 2-characters string naming
+the ordinates to swap. Valid names are: x,y,z and m.
+    </para>
+               <para>Availability: 2.2.0</para>
                <para>&curve_support;</para>
-               <para>&P_support;</para>
-
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-               <para>Change Massachusetts state plane US feet geometry to WGS 84 long lat</para>
-               <programlisting>
-SELECT ST_AsText(ST_Transform(ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
-       743265 2967450,743265.625 2967416,743238 2967416))',2249),4326)) As wgs_geom;
-
- wgs_geom
----------------------------
- POLYGON((-71.1776848522251 42.3902896512902,-71.1776843766326 42.3903829478009,
--71.1775844305465 42.3903826677917,-71.1775825927231 42.3902893647987,-71.177684
-8522251 42.3902896512902));
-(1 row)
-
---3D Circular String example
-SELECT ST_AsEWKT(ST_Transform(ST_GeomFromEWKT('SRID=2249;CIRCULARSTRING(743238 2967416 1,743238 2967450 2,743265 2967450 3,743265.625 2967416 3,743238 2967416 4)'),4326));
-
-                                st_asewkt
---------------------------------------------------------------------------------------
- SRID=4326;CIRCULARSTRING(-71.1776848522251 42.3902896512902 1,-71.1776843766326 42.3903829478009 2,
- -71.1775844305465 42.3903826677917 3,
- -71.1775825927231 42.3902893647987 3,-71.1776848522251 42.3902896512902 4)
-
-               </programlisting>
-               <para>Example of creating a partial functional index.  For tables where you are not sure all the geometries
-                       will be filled in, its best to use a partial index that leaves out null geometries which will both conserve space and make your index smaller and more efficient.</para>
-               <programlisting>
-CREATE INDEX idx_the_geom_26986_parcels
-  ON parcels
-  USING gist
-  (ST_Transform(the_geom, 26986))
-  WHERE the_geom IS NOT NULL;
-               </programlisting>
-
-               <para>Examples of using PROJ.4 text to transform with custom spatial references.</para>
-               <programlisting>
--- Find intersection of two polygons near the North pole, using a custom Gnomic projection
--- See http://boundlessgeo.com/2012/02/flattening-the-peel/
- WITH data AS (
-   SELECT
-     ST_GeomFromText('POLYGON((170 50,170 72,-130 72,-130 50,170 50))', 4326) AS p1,
-     ST_GeomFromText('POLYGON((-170 68,-170 90,-141 90,-141 68,-170 68))', 4326) AS p2,
-     '+proj=gnom +ellps=WGS84 +lat_0=70 +lon_0=-160 +no_defs'::text AS gnom
- )
- SELECT ST_AsText(
-   ST_Transform(
-     ST_Intersection(ST_Transform(p1, gnom), ST_Transform(p2, gnom)),
-   gnom, 4326))
- FROM data;
-                                          st_astext
- --------------------------------------------------------------------------------
-  POLYGON((-170 74.053793645338,-141 73.4268621378904,-141 68,-170 68,-170 74.053793645338))
-               </programlisting>
-
-         </refsection>
-         <refsection>
-               <title>Configuring transformation behaviour</title>
-                       <para>Sometimes coordinate transformation involving a grid-shift
-                               can fail, for example if PROJ.4 has not been built with
-                               grid-shift files or the coordinate does not lie within the
-                               range for which the grid shift is defined. By default, PostGIS
-                               will throw an error if a grid shift file is not present, but
-                               this behaviour can be configured on a per-SRID basis either
-                               by testing different <varname>to_proj</varname> values of
-                               PROJ.4 text, or altering the <varname>proj4text</varname> value
-                               within the <varname>spatial_ref_sys</varname> table.
-                       </para>
-                               <para>For example, the proj4text parameter +datum=NAD87 is a shorthand form for the following +nadgrids parameter:</para>
-                               <programlisting>+nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat</programlisting>
-                               <para>The @ prefix means no error is reported if the files are not present, but if the end of the list is reached with no file having been appropriate (ie. found and overlapping) then an error is issued.</para>
-                               <para>If, conversely, you wanted to ensure that at least the standard files were present, but that if all files were scanned without a hit a null transformation is applied you could use:</para>
-                               <programlisting>+nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat,null</programlisting>
-                               <para>The null grid shift file is a valid grid shift file covering the whole world and applying no shift. So for a complete example, if you wanted to alter PostGIS so that transformations to SRID 4267 that didn't lie within the correct range did not throw an ERROR, you would use the following:</para>
-                               <programlisting>UPDATE spatial_ref_sys SET proj4text = '+proj=longlat +ellps=clrk66 +nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat,null +no_defs' WHERE srid = 4267;</programlisting>
-                 </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="PostGIS_Full_Version" />, <xref linkend="ST_AsText" />, <xref linkend="ST_SetSRID" />, <xref linkend="UpdateGeometrySRID"/></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_Translate">
-         <refnamediv>
-               <refname>ST_Translate</refname>
-
-               <refpurpose>Translate a geometry by given offsets.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_Translate</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>deltax</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>deltay</parameter></paramdef>
-                 </funcprototype>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_Translate</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>deltax</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>deltay</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>deltaz</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns a new geometry whose coordinates are translated delta x,delta y,delta z units. Units are
-               based on the units defined in spatial reference (SRID) for this geometry.</para>
-
-               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
-
-               <para>Availability: 1.2.2</para>
                <para>&Z_support;</para>
-               <para>&curve_support;</para>
+               <para>&M_support;</para>
+               <para>&P_support;</para>
+               <para>&T_support;</para>
          </refsection>
 
          <refsection>
-               <title>Examples</title>
-               <para>Move a point 1 degree longitude</para>
-               <programlisting>
-       SELECT ST_AsText(ST_Translate(ST_GeomFromText('POINT(-71.01 42.37)',4326),1,0)) As wgs_transgeomtxt;
-
-       wgs_transgeomtxt
-       ---------------------
-       POINT(-70.01 42.37)
-               </programlisting>
-               <para>Move a linestring 1 degree longitude and 1/2 degree latitude</para>
-               <programlisting>SELECT ST_AsText(ST_Translate(ST_GeomFromText('LINESTRING(-71.01 42.37,-71.11 42.38)',4326),1,0.5)) As wgs_transgeomtxt;
-                  wgs_transgeomtxt
-       ---------------------------------------
-       LINESTRING(-70.01 42.87,-70.11 42.88)
-               </programlisting>
-               <para>Move a 3d point</para>
-               <programlisting>SELECT ST_AsEWKT(ST_Translate(CAST('POINT(0 0 0)' As geometry), 5, 12,3));
-       st_asewkt
-       ---------
-       POINT(5 12 3)
-               </programlisting>
-               <para>Move a curve and a point</para>
-<programlisting>SELECT ST_AsText(ST_Translate(ST_Collect('CURVEPOLYGON(CIRCULARSTRING(4 3,3.12 0.878,1 0,-1.121 5.1213,6 7, 8 9,4 3))','POINT(1 3)'),1,2));
-                                                                                                                st_astext
-------------------------------------------------------------------------------------------------------------
- GEOMETRYCOLLECTION(CURVEPOLYGON(CIRCULARSTRING(5 5,4.12 2.878,2 2,-0.121 7.1213,7 9,9 11,5 5)),POINT(2 5))
-</programlisting>
+               <title>Example</title>
+               <programlisting><![CDATA[
+-- Scale M value by 2
+SELECT ST_AsText(
+  ST_SwapOrdinates(
+    ST_Scale(
+      ST_SwapOrdinates(g,'xm'),
+      2, 1
+    ),
+  'xm')
+) FROM ( SELECT 'POINT ZM (0 0 0 2)'::geometry g ) foo;
+     st_astext
+--------------------
+ POINT ZM (0 0 0 4)
+                ]]></programlisting>
          </refsection>
 
          <!-- Optionally add a "See Also" section -->
          <refsection>
                <title>See Also</title>
-               <para><xref linkend="ST_Affine" />, <xref linkend="ST_AsText" />, <xref linkend="ST_GeomFromText" /></para>
+               <para> <xref linkend="ST_FlipCoordinates" /> </para>
          </refsection>
-       </refentry>
-
-       <refentry id="ST_TransScale">
-         <refnamediv>
-               <refname>ST_TransScale</refname>
-
-               <refpurpose>Translate a geometry by given factors and offsets.</refpurpose>
-         </refnamediv>
 
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_TransScale</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>deltaX</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>deltaY</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>XFactor</parameter></paramdef>
-                       <paramdef><type>float</type> <parameter>YFactor</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Translates the geometry using the deltaX and deltaY args,
-                       then scales it using the XFactor, YFactor args, working in 2D only.</para>
-
-               <note><para><code>ST_TransScale(geomA, deltaX, deltaY, XFactor, YFactor)</code>
-                       is short-hand for <code>ST_Affine(geomA, XFactor, 0, 0, 0, YFactor, 0,
-                       0, 0, 1, deltaX*XFactor, deltaY*YFactor, 0)</code>.</para></note>
-
-               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
-
-
-               <para>Availability: 1.1.0.</para>
-               <para>&Z_support;</para>
-               <para>&curve_support;</para>
-         </refsection>
-
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>SELECT ST_AsEWKT(ST_TransScale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 1, 1, 2));
-                 st_asewkt
------------------------------
- LINESTRING(1.5 6 3,1.5 4 1)
-
-
---Buffer a point to get an approximation of a circle, convert to curve and then translate 1,2 and scale it 3,4
-  SELECT ST_AsText(ST_Transscale(ST_LineToCurve(ST_Buffer('POINT(234 567)', 3)),1,2,3,4));
-                                                                                                                 st_astext
-------------------------------------------------------------------------------------------------------------------------------
- CURVEPOLYGON(CIRCULARSTRING(714 2276,711.363961030679 2267.51471862576,705 2264,698.636038969321 2284.48528137424,714 2276))
-
-</programlisting>
-         </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_Affine" />, <xref linkend="ST_Translate" /></para>
-         </refsection>
        </refentry>
 
-
-
   </sect1>
index 415778d6e3f7d63cf5708de97d08702defce7eb7..7abc9529560744b1de83f980996b6b28ef12d20f 100644 (file)
 <?xml version="1.0" encoding="UTF-8"?>
-  <sect1 id="Spatial_Relationships_Measurements">
-       <title>Spatial Relationships and Measurements</title>
-       <refentry id="ST_3DClosestPoint">
-                 <refnamediv>
-                       <refname>ST_3DClosestPoint</refname>
-
-                       <refpurpose>Returns the 3-dimensional point on g1 that is closest to g2.  This is the first point of
-                               the 3D shortest line.  </refpurpose>
-                 </refnamediv>
-
-                 <refsynopsisdiv>
-                       <funcsynopsis>
-                         <funcprototype>
-                               <funcdef>geometry <function>ST_3DClosestPoint</function></funcdef>
-
-                               <paramdef><type>geometry </type>
-                               <parameter>g1</parameter></paramdef>
-
-                               <paramdef><type>geometry </type>
-                               <parameter>g2</parameter></paramdef>
-                         </funcprototype>
-                       </funcsynopsis>
-                 </refsynopsisdiv>
-
-                 <refsection>
-                       <title>Description</title>
-
-                       <para>Returns the 3-dimensional point on g1 that is closest to g2.  This is the first point of
-                               the 3D shortest line. The 3D length of the 3D shortest line is the 3D distance.
-                       </para>
-                       <para>&Z_support;</para>
-                       <!-- Optionally mention supports Polyhedral Surface  -->
-                       <para>&P_support;</para>
-                       <para>Availability: 2.0.0</para>
-                       <para>Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
-                 </refsection>
-
-                 <refsection>
-                       <title>Examples</title>
-                               <informaltable>
-                                         <tgroup cols="1">
-                                               <tbody>
-                                                 <row>
-                                                       <entry><para>linestring and point -- both 3d and 2d closest point
-                                       <programlisting>
-SELECT ST_AsEWKT(ST_3DClosestPoint(line,pt)) AS cp3d_line_pt,
-               ST_AsEWKT(ST_ClosestPoint(line,pt)) As cp2d_line_pt
-       FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
-                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
-               ) As foo;
-
-
- cp3d_line_pt                                          |               cp2d_line_pt
------------------------------------------------------------+------------------------------------------
- POINT(54.6993798867619 128.935022917228 11.5475869506606) | POINT(73.0769230769231 115.384615384615)
-                                       </programlisting>
-                                                         </para></entry>
-                                                   </row>
-                                                   <row>
-                                                       <entry><para>linestring and multipoint -- both 3d and 2d closest point
-                                       <programlisting>SELECT ST_AsEWKT(ST_3DClosestPoint(line,pt)) AS cp3d_line_pt,
-               ST_AsEWKT(ST_ClosestPoint(line,pt)) As cp2d_line_pt
-       FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
-                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
-               ) As foo;
-
-
-                       cp3d_line_pt                        | cp2d_line_pt
------------------------------------------------------------+--------------
- POINT(54.6993798867619 128.935022917228 11.5475869506606) | POINT(50 75)
-                                       </programlisting>
-                                                         </para></entry>
-                                                 </row>
-                                                 <row>
-                                                 <entry><para>Multilinestring and polygon both 3d and 2d closest point
-                                       <programlisting>SELECT ST_AsEWKT(ST_3DClosestPoint(poly, mline)) As cp3d,
-    ST_AsEWKT(ST_ClosestPoint(poly, mline)) As cp2d
-        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
-                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
-                (1 10 2, 5 20 1))') As mline ) As foo;
-                   cp3d                    |     cp2d
--------------------------------------------+--------------
- POINT(39.993580415989 54.1889925532825 5) | POINT(20 40)
-             </programlisting>
-                                                         </para></entry>
-                                                 </row>
-                       </tbody>
-               </tgroup>
-       </informaltable>
-
-                 </refsection>
-
-                 <refsection>
-                       <title>See Also</title>
-
-                       <para><xref linkend="ST_AsEWKT" />, <xref linkend="ST_ClosestPoint"/>, <xref linkend="ST_3DDistance"/>, <xref linkend="ST_3DShortestLine"/></para>
-                 </refsection>
-       </refentry>
-       <refentry id="ST_3DDistance">
-         <refnamediv>
-               <refname>ST_3DDistance</refname>
-
-               <refpurpose>For geometry type Returns the 3-dimensional cartesian minimum distance (based on spatial ref) between two geometries in
-               projected units. </refpurpose>
-         </refnamediv>
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>float <function>ST_3DDistance</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g2</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>For geometry type returns the 3-dimensional minimum cartesian distance between two geometries in
-               projected units (spatial ref units).</para>
-
-               <para>&Z_support;</para>
-               <!-- Optionally mention supports Polyhedral Surface  -->
-               <para>&P_support;</para>
-               <para>&sqlmm_compliant; SQL-MM ?</para>
-
-               <para>Availability: 2.0.0</para>
-               <para>Changed: 2.2.0 - In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
-               <para>Changed: 3.0.0 - SFCGAL version removed</para>
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>
--- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
--- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
-SELECT ST_3DDistance(
-                       ST_Transform('SRID=4326;POINT(-72.1235 42.3521 4)'::geometry,2163),
-                       ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'::geometry,2163)
-               ) As dist_3d,
-               ST_Distance(
-                       ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry,2163),
-                       ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry,2163)
-               ) As dist_2d;
-
-     dist_3d      |     dist_2d
-------------------+-----------------
- 127.295059324629 | 126.66425605671
-</programlisting>
-<programlisting>
--- Multilinestring and polygon both 3d and 2d distance
--- Same example as 3D closest point example
-SELECT ST_3DDistance(poly, mline) As dist3d,
-    ST_Distance(poly, mline) As dist2d
-        FROM (SELECT  'POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))'::geometry as poly,
-               'MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1), (1 10 2, 5 20 1))'::geometry as mline) as foo;
-      dist3d       | dist2d
--------------------+--------
- 0.716635696066337 |      0
-</programlisting>
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_Distance"/>, <xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_3DDWithin"/>, <xref linkend="ST_3DMaxDistance" />, <xref linkend="ST_3DShortestLine"/>, <xref linkend="ST_Transform" /></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_3DDWithin">
-         <refnamediv>
-               <refname>ST_3DDWithin</refname>
-
-               <refpurpose>For 3d (z) geometry type Returns true if two geometries 3d distance is within number of units. </refpurpose>
-         </refnamediv>
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_3DDWithin</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g2</parameter></paramdef>
-
-                       <paramdef><type>double precision </type>
-                       <parameter>distance_of_srid</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>For geometry type returns true if the 3d distance between two objects is within distance_of_srid specified
-               projected units (spatial ref units). </para>
-
-        <para>&Z_support;</para>
-        <!-- Optionally mention supports Polyhedral Surface  -->
-        <para>&P_support;</para>
-               <para>&sqlmm_compliant; SQL-MM ?</para>
-
-               <para>Availability: 2.0.0</para>
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>
--- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
--- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
-SELECT ST_3DDWithin(
-                       ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 4)'),2163),
-                       ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163),
-                       126.8
-               ) As within_dist_3d,
-ST_DWithin(
-                       ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 4)'),2163),
-                       ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163),
-                       126.8
-               ) As within_dist_2d;
-
- within_dist_3d | within_dist_2d
-----------------+----------------
- f              | t
-</programlisting>
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_3DDistance"/>, <xref linkend="ST_Distance"/>, <xref linkend="ST_DWithin"/>, <xref linkend="ST_3DMaxDistance" />, <xref linkend="ST_Transform" /></para>
-         </refsection>
-       </refentry>
-
-<refentry id="ST_3DDFullyWithin">
-         <refnamediv>
-               <refname>ST_3DDFullyWithin</refname>
-
-               <refpurpose>Returns true if all of the 3D geometries are within the specified
-               distance of one another. </refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_3DDFullyWithin</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g2</parameter></paramdef>
-
-                       <paramdef><type>double precision </type>
-                       <parameter>distance</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns true if the 3D geometries are fully within the specified distance
-               of one another. The distance is specified in units defined by the
-               spatial reference system of the geometries.  For this function to make
-               sense, the source geometries must both be of the same coordinate projection,
-               having the same SRID.</para>
-
-               <note>
-                 <para>This function call will automatically include a bounding box
-                 comparison that will make use of any indexes that are available on
-                 the geometries.</para>
-               </note>
-
-               <para>Availability: 2.0.0</para>
-        <para>&Z_support;</para>
-        <!-- Optionally mention supports Polyhedral Surface  -->
-        <para>&P_support;</para>
-
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-               <programlisting>
-               -- This compares the difference between fully within and distance within as well
-               -- as the distance fully within for the 2D footprint of the line/point vs. the 3d fully within
-               SELECT ST_3DDFullyWithin(geom_a, geom_b, 10) as D3DFullyWithin10, ST_3DDWithin(geom_a, geom_b, 10) as D3DWithin10,
-       ST_DFullyWithin(geom_a, geom_b, 20) as D2DFullyWithin20,
-       ST_3DDFullyWithin(geom_a, geom_b, 20) as D3DFullyWithin20 from
-               (select ST_GeomFromEWKT('POINT(1 1 2)') as geom_a,
-               ST_GeomFromEWKT('LINESTRING(1 5 2, 2 7 20, 1 9 100, 14 12 3)') as geom_b) t1;
- d3dfullywithin10 | d3dwithin10 | d2dfullywithin20 | d3dfullywithin20
-------------------+-------------+------------------+------------------
- f                | t           | t                | f </programlisting>
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_3DMaxDistance"/>, <xref linkend="ST_3DDWithin"/>, <xref linkend="ST_DWithin"/>, <xref linkend="ST_DFullyWithin"/></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_3DIntersects">
-               <refnamediv>
-                       <refname>ST_3DIntersects</refname>
-
-                       <refpurpose>Returns TRUE if the Geometries "spatially
-                       intersect" in 3D - only for points, linestrings, polygons, polyhedral surface (area).
-                       </refpurpose>
-               </refnamediv>
-               <refsynopsisdiv>
-                       <funcsynopsis>
-                               <funcprototype>
-                                       <funcdef>boolean <function>ST_3DIntersects</function></funcdef>
-                                       <paramdef>
-                                               <type>geometry</type>
-                                               <parameter>geomA</parameter>
-                                       </paramdef>
-                                       <paramdef>
-                                               <type>geometry</type>
-                                               <parameter>geomB</parameter>
-                                       </paramdef>
-                               </funcprototype>
-                       </funcsynopsis>
-               </refsynopsisdiv>
-               <refsection>
-                       <title>Description</title>
-                       <para>Overlaps, Touches, Within all imply spatial intersection.  If any of the aforementioned
-                               returns true, then the geometries also spatially intersect.
-                               Disjoint implies false for spatial intersection.</para>
-
-                       <para>Changed: 3.0.0 SFCGAL backend removed, GEOS backend supports TINs.</para>
-                       <para>Availability: 2.0.0</para>
-                       <note>
-                         <para>This function call will automatically include a bounding box
-                         comparison that will make use of any indexes that are available on the
-                         geometries.</para>
-                       </note>
-
-                       <para>&Z_support;</para>
-                       <!-- Optionally mention supports Polyhedral Surface  -->
-                       <para>&P_support;</para>
-                       <para>&T_support;</para>
-                       <para>&sfcgal_enhanced;</para>
-                       <para>&sqlmm_compliant; SQL-MM 3: ?</para>
-               </refsection>
-               <refsection>
-               <title>Geometry Examples</title>
-<programlisting>SELECT ST_3DIntersects(pt, line), ST_Intersects(pt, line)
-       FROM (SELECT 'POINT(0 0 2)'::geometry As pt, 'LINESTRING (0 0 1, 0 2 3)'::geometry As line) As foo;
- st_3dintersects | st_intersects
------------------+---------------
- f               | t
-(1 row)
-               </programlisting>
-               </refsection>
-
-               <refsection><title>TIN Examples</title>
-                   <programlisting>SELECT ST_3DIntersects('TIN(((0 0 0,1 0 0,0 1 0,0 0 0)))'::geometry, 'POINT(.1 .1 0)'::geometry);
- st_3dintersects
------------------
- t</programlisting></refsection>
-
-               <refsection>
-                       <title>See Also</title>
-                       <para><xref linkend="ST_Intersects"/></para>
-               </refsection>
-       </refentry>
-
-       <refentry id="ST_3DLongestLine">
-         <refnamediv>
-               <refname>ST_3DLongestLine</refname>
-
-               <refpurpose>Returns the 3-dimensional longest line between two geometries</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_3DLongestLine</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g2</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns the 3-dimensional longest line between two geometries. The function will
-               only return the first longest line if more than one.
-               The line returned will always start in g1 and end in g2.
-               The 3D length of the line this function returns will always be the same as <xref linkend="ST_3DMaxDistance" /> returns for g1 and g2.
-               </para>
-
-               <para>Availability: 2.0.0</para>
-               <para>Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
-               <para>&Z_support;</para>
-               <!-- Optionally mention supports Polyhedral Surface  -->
-               <para>&P_support;</para>
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-                               <informaltable>
-                                         <tgroup cols="1">
-                                               <tbody>
-                                                 <row>
-                                                       <entry><para>linestring and point -- both 3d and 2d longest line
-                                       <programlisting>
-SELECT ST_AsEWKT(ST_3DLongestLine(line,pt)) AS lol3d_line_pt,
-               ST_AsEWKT(ST_LongestLine(line,pt)) As lol2d_line_pt
-       FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
-                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
-               ) As foo;
-
-
-           lol3d_line_pt           |       lol2d_line_pt
------------------------------------+----------------------------
- LINESTRING(50 75 1000,100 100 30) | LINESTRING(98 190,100 100)
-                                       </programlisting>
-                                                         </para></entry>
-                                                   </row>
-                                                   <row>
-                                                       <entry><para>linestring and multipoint -- both 3d and 2d longest line
-                                       <programlisting>SELECT ST_AsEWKT(ST_3DLongestLine(line,pt)) AS lol3d_line_pt,
-               ST_AsEWKT(ST_LongestLine(line,pt)) As lol2d_line_pt
-       FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
-                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
-               ) As foo;
-
-
-          lol3d_line_pt          |      lol2d_line_pt
----------------------------------+--------------------------
- LINESTRING(98 190 1,50 74 1000) | LINESTRING(98 190,50 74)
-                                       </programlisting>
-                                                         </para></entry>
-                                                 </row>
-                                                 <row>
-                                                 <entry><para>Multilinestring and polygon both 3d and 2d longest line
-                                       <programlisting>SELECT ST_AsEWKT(ST_3DLongestLine(poly, mline)) As lol3d,
-    ST_AsEWKT(ST_LongestLine(poly, mline)) As lol2d
-        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
-                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
-                (1 10 2, 5 20 1))') As mline ) As foo;
-            lol3d             |          lol2d
-------------------------------+--------------------------
- LINESTRING(175 150 5,1 10 2) | LINESTRING(175 150,1 10)
-             </programlisting>
-                                                         </para></entry>
-                                                 </row>
-                       </tbody>
-               </tgroup>
-       </informaltable>
-
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_3DDistance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_3DShortestLine"/>, <xref linkend="ST_3DMaxDistance"/></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_3DMaxDistance">
-         <refnamediv>
-               <refname>ST_3DMaxDistance</refname>
-
-               <refpurpose>For geometry type Returns the 3-dimensional cartesian maximum distance (based on spatial ref) between two geometries in
-               projected units.  </refpurpose>
-         </refnamediv>
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>float <function>ST_3DMaxDistance</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g2</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>For geometry type returns the 3-dimensional maximum cartesian distance between two geometries in
-               projected units (spatial ref units). </para>
-
-        <para>&Z_support;</para>
-        <!-- Optionally mention supports Polyhedral Surface  -->
-        <para>&P_support;</para>
-
-               <para>Availability: 2.0.0</para>
-               <para>Changed: 2.2.0 - In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>
--- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
--- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
-SELECT ST_3DMaxDistance(
-                       ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 10000)'),2163),
-                       ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163)
-               ) As dist_3d,
-               ST_MaxDistance(
-                       ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 10000)'),2163),
-                       ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163)
-               ) As dist_2d;
-
-     dist_3d      |     dist_2d
-------------------+------------------
- 24383.7467488441 | 22247.8472107251
-</programlisting>
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_Distance"/>, <xref linkend="ST_3DDWithin"/>, <xref linkend="ST_3DMaxDistance" />, <xref linkend="ST_Transform" /></para>
-         </refsection>
-       </refentry>
-       <refentry id="ST_3DShortestLine">
-         <refnamediv>
-               <refname>ST_3DShortestLine</refname>
-
-               <refpurpose>Returns the 3-dimensional shortest line between two geometries</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_3DShortestLine</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g2</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns the 3-dimensional shortest line between two geometries. The function will
-               only return the first shortest line if more than one, that the function finds.
-               If g1 and g2 intersects in just one point the function will return a line with both start
-               and end in that intersection-point.
-               If g1 and g2 are intersecting with more than one point the function will return a line with start
-               and end in the same point but it can be any of the intersecting points.
-               The line returned will always start in g1 and end in g2.
-               The 3D length of the line this function returns will always be the same as <xref linkend="ST_3DDistance" /> returns for g1 and g2.
-               </para>
-
-               <para>Availability: 2.0.0</para>
-               <para>Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
-               <para>&Z_support;</para>
-               <!-- Optionally mention supports Polyhedral Surface  -->
-               <para>&P_support;</para>
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-                               <informaltable>
-                                         <tgroup cols="1">
-                                               <tbody>
-                                                 <row>
-                                                       <entry><para>linestring and point -- both 3d and 2d shortest line
-                                       <programlisting>
-SELECT ST_AsEWKT(ST_3DShortestLine(line,pt)) AS shl3d_line_pt,
-               ST_AsEWKT(ST_ShortestLine(line,pt)) As shl2d_line_pt
-       FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
-                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
-               ) As foo;
-
-
- shl3d_line_pt                                                          |               shl2d_line_pt
-----------------------------------------------------------------------------+------------------------------------------------------
- LINESTRING(54.6993798867619 128.935022917228 11.5475869506606,100 100 30)  | LINESTRING(73.0769230769231 115.384615384615,100 100)
-                                       </programlisting>
-                                                         </para></entry>
-                                                   </row>
-                                                   <row>
-                                                       <entry><para>linestring and multipoint -- both 3d and 2d shortest line
-                                       <programlisting>SELECT ST_AsEWKT(ST_3DShortestLine(line,pt)) AS shl3d_line_pt,
-               ST_AsEWKT(ST_ShortestLine(line,pt)) As shl2d_line_pt
-       FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
-                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
-               ) As foo;
-
-
-                       shl3d_line_pt                                       | shl2d_line_pt
----------------------------------------------------------------------------+------------------------
- LINESTRING(54.6993798867619 128.935022917228 11.5475869506606,100 100 30) | LINESTRING(50 75,50 74)
-                                       </programlisting>
-                                                         </para></entry>
-                                                 </row>
-                                                 <row>
-                                                 <entry><para>Multilinestring and polygon both 3d and 2d shortest line
-                                       <programlisting>SELECT ST_AsEWKT(ST_3DShortestLine(poly, mline)) As shl3d,
-    ST_AsEWKT(ST_ShortestLine(poly, mline)) As shl2d
-        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
-                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
-                (1 10 2, 5 20 1))') As mline ) As foo;
-                   shl3d                                                                           |     shl2d
----------------------------------------------------------------------------------------------------+------------------------
- LINESTRING(39.993580415989 54.1889925532825 5,40.4078575708294 53.6052383805529 5.03423778139177) | LINESTRING(20 40,20 40)
-             </programlisting>
-                                                         </para></entry>
-                                                 </row>
-                       </tbody>
-               </tgroup>
-       </informaltable>
-
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_3DDistance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_ShortestLine"/>, <xref linkend="ST_3DMaxDistance"/></para>
-         </refsection>
-       </refentry>
-       <refentry id="ST_Area">
-               <refnamediv>
-                 <refname>ST_Area</refname>
-
-                 <refpurpose>Returns the area of the surface if it is a Polygon or
-                               MultiPolygon. For geometry, a 2D Cartesian area is determined with units specified by the SRID.  For geography, area is determined on a curved surface with units in square meters.</refpurpose>
-               </refnamediv>
-               <refsynopsisdiv>
-                 <funcsynopsis>
-                       <funcprototype>
-                         <funcdef>float <function>ST_Area</function></funcdef>
-                               <paramdef><type>geometry </type><parameter>g1</parameter></paramdef>
-                       </funcprototype>
-
-                       <funcprototype>
-                         <funcdef>float <function>ST_Area</function></funcdef>
-                               <paramdef><type>geography </type><parameter>geog</parameter></paramdef>
-                               <paramdef choice="opt"><type>boolean </type><parameter>use_spheroid=true</parameter></paramdef>
-                       </funcprototype>
-                 </funcsynopsis>
-               </refsynopsisdiv>
-               <refsection>
-                       <title>Description</title>
-
-                       <para>Returns the area of the geometry if it is a Polygon or
-                               MultiPolygon. Return the area measurement of an ST_Surface or
-                 ST_MultiSurface value. For geometry, a 2D Cartesian area is determined with units specified by the SRID.  For geography, by default area is determined on a spheroid with units in square meters.
-                 To measure around the faster but less accurate sphere, use ST_Area(geog,false).
-                 </para>
-                       <para>Enhanced: 2.0.0 - support for 2D polyhedral surfaces was introduced.</para>
-                       <para>Enhanced: 2.2.0 - measurement on spheroid performed with GeographicLib for improved accuracy and robustness.  Requires Proj &gt;= 4.9.0 to take advantage of the new feature.</para>
-                       <para>Changed: 3.0.0 - does not depend on SFCGAL anymore.</para>
-                       <para>&sfs_compliant;</para>
-                       <para>&sqlmm_compliant; SQL-MM 3: 8.1.2, 9.5.3</para>
-                       <para>&P_support;</para>
-                       <note><para>For polyhedral surfaces, only supports 2D polyhedral surfaces (not 2.5D).  For 2.5D, may give a non-zero answer, but only for the faces that
-                       sit completely in XY plane.</para></note>
-               </refsection>
-
-                 <refsection>
-                       <title>Examples</title>
-                       <para>Return area in square feet for a plot of Massachusetts land and multiply by conversion to get square meters.
-                               Note this is in square feet because EPSG:2249 is
-                               Massachusetts State Plane Feet </para>
-                       <programlisting>
-select ST_Area(geom) sqft,
-    ST_Area(geom) * 0.3048 ^ 2 sqm
-from (
-         select 'SRID=2249;POLYGON((743238 2967416,743238 2967450,
-                                743265 2967450,743265.625 2967416,743238 2967416))' :: geometry geom
-     ) subquery;
-┌─────────┬─────────────┐
-│  sqft   │     sqm     │
-├─────────┼─────────────┤
-│ 928.625 │ 86.27208552 │
-└─────────┴─────────────┘
-</programlisting>
-<para>Return area square feet and transform to Massachusetts state plane meters (EPSG:26986) to get square meters.
-                               Note this is in square feet because 2249 is
-                               Massachusetts State Plane Feet and transformed area is in square meters since EPSG:26986 is state plane Massachusetts meters </para>
-<programlisting>select ST_Area(geom) sqft,
-    ST_Area(ST_Transform(geom, 26986)) As sqm
-from (
-         select
-             'SRID=2249;POLYGON((743238 2967416,743238 2967450,
-             743265 2967450,743265.625 2967416,743238 2967416))' :: geometry geom
-     ) subquery;
-┌─────────┬─────────────────┐
-│  sqft   │       sqm       │
-├─────────┼─────────────────┤
-│ 928.625 │ 86.272430607008 │
-└─────────┴─────────────────┘
-</programlisting>
-
-<para>Return area square feet and square meters using geography data type.  Note that we transform to our geometry to geography
-       (before you can do that make sure your geometry is in WGS 84 long lat 4326).  Geography always measures in meters.
-       This is just for demonstration to compare.  Normally your table will be stored in geography data type already.</para>
-<programlisting>
-
-select ST_Area(geog) / 0.3048 ^ 2 sqft_spheroid,
-    ST_Area(geog, false) / 0.3048 ^ 2 sqft_sphere,
-    ST_Area(geog) sqm_spheroid
-from (
-         select ST_Transform(
-                    'SRID=2249;POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))'::geometry,
-                    4326
-             ) :: geography geog
-     ) as subquery;
-┌──────────────────┬──────────────────┬──────────────────┐
-│  sqft_spheroid   │   sqft_sphere    │   sqm_spheroid   │
-├──────────────────┼──────────────────┼──────────────────┤
-│ 928.684405784452 │ 927.049336105925 │ 86.2776044979692 │
-└──────────────────┴──────────────────┴──────────────────┘
-</programlisting>
-
- <para>If your data is in geography already:</para>
- <programlisting>
-select ST_Area(geog) / 0.3048 ^ 2 sqft,
-    ST_Area(the_geog) sqm
-from somegeogtable;</programlisting>
-                 </refsection>
-               <refsection>
-                       <title>See Also</title>
-                       <para><xref linkend="ST_3DArea" />, <xref linkend="ST_GeomFromText" />, <xref linkend="ST_GeographyFromText" />, <xref linkend="ST_SetSRID" />, <xref linkend="ST_Transform" /></para>
-               </refsection>
-       </refentry>
-
-       <refentry id="ST_Azimuth">
-               <refnamediv>
-                 <refname>ST_Azimuth</refname>
-
-                 <refpurpose>Returns the north-based azimuth as the angle in radians measured clockwise from the vertical on pointA to pointB.</refpurpose>
-               </refnamediv>
-               <refsynopsisdiv>
-                 <funcsynopsis>
-                       <funcprototype>
-                         <funcdef>float <function>ST_Azimuth</function></funcdef>
-                         <paramdef><type>geometry </type><parameter>pointA</parameter></paramdef>
-                         <paramdef><type>geometry </type><parameter>pointB</parameter></paramdef>
-                       </funcprototype>
-                       <funcprototype>
-                         <funcdef>float <function>ST_Azimuth</function></funcdef>
-                         <paramdef><type>geography </type><parameter>pointA</parameter></paramdef>
-                         <paramdef><type>geography </type><parameter>pointB</parameter></paramdef>
-                       </funcprototype>
-                 </funcsynopsis>
-               </refsynopsisdiv>
-               <refsection>
-                       <title>Description</title>
-
-                       <para>Returns the azimuth in radians of the segment defined by the given
-                       point geometries, or NULL if the two points are coincident. The azimuth is angle is referenced from north, and is positive clockwise: North = 0; East = &#x03C0;/2; South = &#x03C0;; West = 3&#x03C0;/2.</para>
-                       <para>For the geography type, the forward azimuth is solved as part of the inverse geodesic problem.</para>
-                       <para>The azimuth is mathematical concept defined as the angle between a reference plane and a point, with angular units in radians.
-                       Units can be converted to degrees using a built-in PostgreSQL function degrees(), as shown in the example.</para>
-
-                       <para>Availability: 1.1.0</para>
-                       <para>Enhanced: 2.0.0 support for geography was introduced.</para>
-                       <para>Enhanced: 2.2.0 measurement on spheroid performed with GeographicLib for improved accuracy and robustness.  Requires Proj &gt;= 4.9.0 to take advantage of the new feature.</para>
-                       <para>Azimuth is especially useful in conjunction with ST_Translate for shifting an object along its perpendicular axis. See
-                                upgis_lineshift <ulink url="http://trac.osgeo.org/postgis/wiki/UsersWikiplpgsqlfunctions">Plpgsqlfunctions PostGIS wiki section</ulink> for example of this.</para>
-               </refsection>
-
-               <refsection>
-               <title>Examples</title>
-               <para>Geometry Azimuth in degrees </para>
-<programlisting>
-SELECT degrees(ST_Azimuth(ST_Point(25, 45), ST_Point(75, 100))) AS degA_B,
-           degrees(ST_Azimuth(ST_Point(75, 100), ST_Point(25, 45))) AS degB_A;
-
-      dega_b       |     degb_a
-------------------+------------------
- 42.2736890060937 | 222.273689006094
-</programlisting>
-               <informaltable>
-                 <tgroup cols="2">
-                       <tbody>
-                               <row>
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_azimuth01.png" />
-                                         </imageobject>
-                                         <caption><para>Green: the start Point(25,45) with its vertical. Yellow: degA_B as the path to travel (azimuth).</para></caption>
-                                       </mediaobject>
-                                 </informalfigure>
-                               </para></entry>
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_azimuth02.png" />
-                                         </imageobject>
-                                         <caption><para>Green: the start Point(75,100) with its vertical. Yellow: degB_A as the path to travel (azimuth).</para></caption>
-                                       </mediaobject>
-                                 </informalfigure>
-                               </para></entry>
-                               </row>
-                       </tbody>
-                       </tgroup>
-               </informaltable>
-               </refsection>
-               <refsection>
-                       <title>See Also</title>
-                       <para><xref linkend="ST_Point" />, <xref linkend="ST_Translate" />, <xref linkend="ST_Project" />, <ulink url="http://www.postgresql.org/docs/current/interactive/functions-math.html">PostgreSQL Math Functions</ulink></para>
-               </refsection>
-
-  </refentry>
-
-       <refentry id="ST_Angle">
-               <refnamediv>
-                 <refname>ST_Angle</refname>
-
-                 <refpurpose>Returns the angle between 3 points, or between 2 vectors (4 points or 2 lines).</refpurpose>
-               </refnamediv>
-               <refsynopsisdiv>
-                 <funcsynopsis>
-                       <funcprototype>
-                         <funcdef>float <function>ST_Angle</function></funcdef>
-                         <paramdef><type>geometry </type><parameter>point1</parameter></paramdef>
-                         <paramdef><type>geometry </type><parameter>point2</parameter></paramdef>
-                         <paramdef><type>geometry </type><parameter>point3</parameter></paramdef>
-                         <paramdef choice="opt"><type>geometry </type><parameter>point4</parameter></paramdef>
-                       </funcprototype>
-                       <funcprototype>
-                         <funcdef>float <function>ST_Angle</function></funcdef>
-                         <paramdef><type>geometry </type><parameter>line1</parameter></paramdef>
-                         <paramdef><type>geometry </type><parameter>line2</parameter></paramdef>
-                       </funcprototype>
-                 </funcsynopsis>
-               </refsynopsisdiv>
-               <refsection>
-                       <title>Description</title>
-
-                       <para> For 3 points, computes the angle measured clockwise of P1P2P3.
-                       If input are 2 lines, get first and last point of the lines as 4 points.
-                       For 4 points,compute the angle measured clockwise of P1P2,P3P4.
-                       Results are always positive, between 0 and 2*Pi radians.
+  <sect1 id="Measurement_Functions">
+    <sect1info>
+    <abstract>
+    <para>These functions compute measurements of distance, area and angles.
+               There are also functions to compute geometry values determined by measurements.</para>
+    </abstract>
+    </sect1info>
 
-                       Uses azimuth of pairs or points.
-                       </para>
-                       <para>ST_Angle(P1,P2,P3) = ST_Angle(P2,P1,P2,P3)</para>
-                       <para>Result is in radian and can be converted to degrees using a built-in PostgreSQL function degrees(), as shown in the example.</para>
-                       <para>Availability: 2.5.0</para>
-               </refsection>
-
-               <refsection>
-               <title>Examples</title>
-               <para>Geometry Azimuth in degrees </para>
-<programlisting>
-       WITH rand AS (
-               SELECT s, random() * 2 * PI() AS rad1
-                       , random() * 2 * PI() AS rad2
-               FROM  generate_series(1,2,2) AS s
-       )
-        , points AS (
-               SELECT s, rad1,rad2, ST_MakePoint(cos1+s,sin1+s) as p1, ST_MakePoint(s,s) AS p2, ST_MakePoint(cos2+s,sin2+s) as p3
-               FROM rand
-                       ,cos(rad1) cos1, sin(rad1) sin1
-                       ,cos(rad2) cos2, sin(rad2) sin2
-       )
-       SELECT s, ST_AsText(ST_SnapToGrid(ST_MakeLine(ARRAY[p1,p2,p3]),0.001)) AS line
-               , degrees(ST_Angle(p1,p2,p3)) as computed_angle
-               , round(degrees(2*PI()-rad2 -2*PI()+rad1+2*PI()))::int%360 AS reference
-               , round(degrees(2*PI()-rad2 -2*PI()+rad1+2*PI()))::int%360 AS reference
-       FROM points ;
-
-1 | line | computed_angle | reference
-------------------+------------------
-1 | LINESTRING(1.511 1.86,1 1,0.896 0.005) | 155.27033848688 | 155
-
-</programlisting>
-               </refsection>
-  </refentry>
-
-  <refentry id="ST_Centroid">
-       <refnamediv>
-         <refname>ST_Centroid</refname>
-
-         <refpurpose>Returns the geometric center of a geometry.</refpurpose>
-       </refnamediv>
-
-       <refsynopsisdiv>
-         <funcsynopsis>
-          <funcprototype>
-                 <funcdef>geometry <function>ST_Centroid</function></funcdef>
-
-                 <paramdef><type>geometry </type>
-                 <parameter>g1</parameter></paramdef>
-               </funcprototype>
-            <funcprototype>
-                <funcdef>geography <function>ST_Centroid</function></funcdef>
-
-                <paramdef><type>geography </type>
-                <parameter>g1</parameter></paramdef>
-                <paramdef choice="opt"><type>boolean </type>
-                <parameter>use_spheroid=true</parameter></paramdef>
-       </funcprototype>
-
-         </funcsynopsis>
-       </refsynopsisdiv>
-
-       <refsection>
-         <title>Description</title>
-
-         <para>Computes the geometric center of a geometry, or equivalently,
-         the center of mass of the geometry as a <varname>POINT</varname>. For
-         [<varname>MULTI</varname>]<varname>POINT</varname>s, this is computed
-         as the arithmetic mean of the input coordinates. For
-         [<varname>MULTI</varname>]<varname>LINESTRING</varname>s, this is
-         computed as the weighted length of each line segment. For
-         [<varname>MULTI</varname>]<varname>POLYGON</varname>s, "weight" is
-         thought in terms of area. If an empty geometry is supplied, an empty
-         <varname>GEOMETRYCOLLECTION</varname> is returned. If
-         <varname>NULL</varname> is supplied, <varname>NULL</varname> is
-         returned.
-         If <varname>CIRCULARSTRING</varname> or <varname>COMPOUNDCURVE</varname>
-         are supplied, they are converted to linestring wtih CurveToLine first,
-         then same than for  <varname>LINESTRING</varname>
-         </para>
-         <para>New in 2.3.0 : support <varname>CIRCULARSTRING</varname> and <varname>COMPOUNDCURVE</varname> (using CurveToLine)</para>
-
-      <para>Availability: 2.4.0 support for geography was introduced.</para>
-
-         <para>The centroid is equal to the centroid of the set of component
-         Geometries of highest dimension (since the lower-dimension geometries
-         contribute zero "weight" to the centroid).</para>
-
-         <para>&sfs_compliant;</para>
-         <para>&sqlmm_compliant; SQL-MM 3: 8.1.4, 9.5.5</para>
-       </refsection>
-
-       <refsection>
-         <title>Examples</title>
-
-         <para>In each of the following illustrations, the green dot represents
-         the centroid of the source geometry.</para>
-
-         <informaltable>
-               <tgroup cols="2">
-                 <tbody>
-                       <row>
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_centroid01.png" />
-                                       </imageobject>
-
-                                       <caption><para>Centroid of a
-                                       <varname>MULTIPOINT</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_centroid02.png" />
-                                       </imageobject>
-
-                                       <caption><para>Centroid of a
-                                       <varname>LINESTRING</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-                       </row>
-
-                       <row>
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_centroid03.png" />
-                                       </imageobject>
-
-                                       <caption><para>Centroid of a
-                                       <varname>POLYGON</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_centroid04.png" />
-                                       </imageobject>
-
-                                       <caption><para>Centroid of a
-                                       <varname>GEOMETRYCOLLECTION</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-                       </row>
-                 </tbody>
-               </tgroup>
-         </informaltable>
-
-         <programlisting>SELECT ST_AsText(ST_Centroid('MULTIPOINT ( -1 0, -1 2, -1 3, -1 4, -1 7, 0 1, 0 3, 1 1, 2 0, 6 0, 7 8, 9 8, 10 6 )'));
-                               st_astext
-------------------------------------------
- POINT(2.30769230769231 3.30769230769231)
-(1 row)
-
-SELECT ST_AsText(ST_centroid(g))
-FROM  ST_GeomFromText('CIRCULARSTRING(0 2, -1 1,0 0, 0.5 0, 1 0, 2 1, 1 2, 0.5 2, 0 2)')  AS g ;
-------------------------------------------
-POINT(0.5 1)
-
-
-SELECT ST_AsText(ST_centroid(g))
-FROM  ST_GeomFromText('COMPOUNDCURVE(CIRCULARSTRING(0 2, -1 1,0 0),(0 0, 0.5 0, 1 0),CIRCULARSTRING( 1 0, 2 1, 1 2),(1 2, 0.5 2, 0 2))' ) AS g;
-------------------------------------------
-POINT(0.5 1)
-
-</programlisting>
-       </refsection>
-
-       <refsection>
-         <title>See Also</title>
-
-         <para><xref linkend="ST_PointOnSurface" />, <xref linkend="ST_GeometricMedian" /></para>
-       </refsection>
-  </refentry>
-
-<refentry id="ST_ClosestPoint">
-         <refnamediv>
-               <refname>ST_ClosestPoint</refname>
-
-               <refpurpose>Returns the 2-dimensional point on g1 that is closest to g2.  This is the first point of
-                       the shortest line.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_ClosestPoint</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g2</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns the 2-dimensional point on g1 that is closest to g2.  This is the first point of
-                       the shortest line.
-               </para>
-               <note><para>If you have a 3D Geometry, you may prefer to use <xref linkend="ST_3DClosestPoint" />.</para></note>
-               <para>Availability: 1.5.0</para>
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-                       <informaltable>
-                                 <tgroup cols="2">
-                                       <tbody>
-                                         <row>
-                                               <entry><para><informalfigure>
-                                                       <mediaobject>
-                                                         <imageobject>
-                                                               <imagedata fileref="images/st_closestpoint01.png" />
-                                                         </imageobject>
-                                                         <caption><para>Closest between point and linestring is the point itself, but closest
-                                                                                       point between a linestring and point is the point on line string that is closest.</para></caption>
-                                                       </mediaobject>
-                                                 </informalfigure>
-                               <programlisting>
-SELECT ST_AsText(ST_ClosestPoint(pt,line)) AS cp_pt_line,
-       ST_AsText(ST_ClosestPoint(line,pt)) As cp_line_pt
-FROM (SELECT 'POINT(100 100)'::geometry As pt,
-               'LINESTRING (20 80, 98 190, 110 180, 50 75 )'::geometry As line
-       ) As foo;
-
-
-   cp_pt_line   |                cp_line_pt
-----------------+------------------------------------------
- POINT(100 100) | POINT(73.0769230769231 115.384615384615)
-                               </programlisting>
-                                                 </para></entry>
-
-                                               <entry><para><informalfigure>
-                                                       <mediaobject>
-                                                         <imageobject>
-                                                               <imagedata fileref="images/st_closestpoint02.png" />
-                                                         </imageobject>
-                                                         <caption><para>closest point on polygon A to polygon B</para></caption>
-                                                       </mediaobject>
-                                                 </informalfigure>
-                               <programlisting>
-SELECT ST_AsText(
-               ST_ClosestPoint(
-                       ST_GeomFromText('POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))'),
-                       ST_Buffer(ST_GeomFromText('POINT(110 170)'), 20)
-                       )
-               ) As ptwkt;
-
-                  ptwkt
-------------------------------------------
- POINT(140.752120669087 125.695053378061)
-                               </programlisting>
-                                               </para></entry>
-                                         </row>
-               </tbody>
-       </tgroup>
-</informaltable>
-
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_3DClosestPoint" />,<xref linkend="ST_Distance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_ShortestLine"/>, <xref linkend="ST_MaxDistance"/></para>
-         </refsection>
-</refentry>
-
-    <refentry id="ST_ClusterDBSCAN">
-         <refnamediv>
-               <refname>ST_ClusterDBSCAN</refname>
-
-        <refpurpose>Windowing function that returns integer id for the cluster each input geometry is in based on 2D implementation of Density-based spatial clustering of applications with noise (DBSCAN) algorithm.</refpurpose>
-    </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>integer <function>ST_ClusterDBSCAN</function></funcdef>
-
-                       <paramdef><type>geometry winset </type>
-                       <parameter>geom</parameter></paramdef>
-
-                       <paramdef><type>float8 </type>
-                       <parameter>eps</parameter></paramdef>
-
-                       <paramdef><type>integer </type>
-                       <parameter>minpoints</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-      <title>Description</title>
-
-         <para>
-                 Returns cluster number for each input geometry, based on a 2D implementation of the
-          <ulink url="https://en.wikipedia.org/wiki/DBSCAN">Density-based spatial clustering of applications with noise (DBSCAN)</ulink>
-                 algorithm.  Unlike <xref linkend="ST_ClusterKMeans" />, it does not require the number of clusters to be specified, but instead
-                 uses the desired <link linkend="ST_Distance">distance</link> (<varname>eps</varname>) and density (<varname>minpoints</varname>) parameters to construct each cluster.
-         </para>
-
-         <para>
-                 An input geometry will be added to a cluster if it is either:
-                 <itemizedlist>
-              <listitem>
-                  <para>
-                      A "core" geometry, that is within <varname>eps</varname> <link linkend="ST_Distance">distance</link> of at least <varname>minpoints</varname> input geometries (including itself) or
-                  </para>
-                         </listitem>
-                         <listitem>
-                  <para>
-                      A "border" geometry, that is within <varname>eps</varname> <link linkend="ST_Distance">distance</link> of a core geometry.
-                  </para>
-                         </listitem>
-                 </itemizedlist>
-               </para>
-
-               <para>
-                 Note that border geometries may be within <varname>eps</varname> distance of core geometries in more than one cluster; in this
-                 case, either assignment would be correct, and the border geometry will be arbitrarily asssigned to one of the available clusters.
-                 In these cases, it is possible for a correct cluster to be generated with fewer than <varname>minpoints</varname> geometries.
-                 When assignment of a border geometry is ambiguous, repeated calls to ST_ClusterDBSCAN will produce identical results if an ORDER BY
-                 clause is included in the window definition, but cluster assignments may differ from other implementations of the same algorithm.
-         </para>
-
-         <note><para>
-                 Input geometries that do not meet the criteria to join any other cluster will be assigned a cluster number of NULL.
-         </para></note>
-
-      <para>Availability: 2.3.0</para>
-    </refsection>
-
-    <refsection>
-      <title>Examples</title>
-      <para>
-          Assigning a cluster number to each polygon within 50 meters of each other.  Require at least 2 polygons per cluster
-      </para>
-       <informaltable>
-                                 <tgroup cols="2">
-                                       <tbody>
-                                 <row>
-                                               <entry><para><informalfigure>
-                                                       <mediaobject>
-                                                         <imageobject>
-                                                               <imagedata fileref="images/st_clusterdbscan01.png" />
-                                                         </imageobject>
-                                                         <caption><para>within 50 meters at least 2 per cluster. singletons have NULL for cid</para></caption>
-                                                       </mediaobject>
-                                                 </informalfigure>
-  <programlisting>SELECT name, ST_ClusterDBSCAN(geom, eps := 50, minpoints := 2) over () AS cid
-FROM boston_polys
-WHERE name > '' AND building > ''
-       AND ST_DWithin(geom,
-        ST_Transform(
-            ST_GeomFromText('POINT(-71.04054 42.35141)', 4326), 26986),
-           500);</programlisting>
-                                                 </para></entry>
-
-                                               <entry><para><screen><![CDATA[                name                 | bucket
--------------------------------------+--------
- Manulife Tower                      |      0
- Park Lane Seaport I                 |      0
- Park Lane Seaport II                |      0
- Renaissance Boston Waterfront Hotel |      0
- Seaport Boston Hotel                |      0
- Seaport Hotel & World Trade Center  |      0
- Waterside Place                     |      0
- World Trade Center East             |      0
- 100 Northern Avenue                 |      1
- 100 Pier 4                          |      1
- The Institute of Contemporary Art   |      1
- 101 Seaport                         |      2
- District Hall                       |      2
- One Marina Park Drive               |      2
- Twenty Two Liberty                  |      2
- Vertex                              |      2
- Vertex                              |      2
- Watermark Seaport                   |      2
- Blue Hills Bank Pavilion            |   NULL
- World Trade Center West             |   NULL
-(20 rows)]]></screen></para>
-                               </entry>
-                                         </row>
-                               </tbody>
-                               </tgroup>
-                       </informaltable>
-
-
-        <para>
-            Combining parcels with the same cluster number into a single geometry. This uses named argument calling
-        </para>
-                   <programlisting>
-SELECT cid, ST_Collect(geom) AS cluster_geom, array_agg(parcel_id) AS ids_in_cluster FROM (
-    SELECT parcel_id, ST_ClusterDBSCAN(geom, eps := 0.5, minpoints := 5) over () AS cid, geom
-    FROM parcels) sq
-GROUP BY cid;
-    </programlisting>
-    </refsection>
-
-    <refsection>
-                 <title>See Also</title>
-          <para><xref linkend="ST_DWithin"/>,
-              <xref linkend="ST_ClusterKMeans"/>,
-              <xref linkend="ST_ClusterIntersecting"/>,
-              <xref linkend="ST_ClusterWithin"/>
-          </para>
-         </refsection>
-
-    </refentry>
-
-    <refentry id="ST_ClusterIntersecting">
-      <refnamediv>
-        <refname>ST_ClusterIntersecting</refname>
-
-        <refpurpose>Aggregate.  Returns an array with the connected components of a set of geometries</refpurpose>
-      </refnamediv>
-
-      <refsynopsisdiv>
-        <funcsynopsis>
-          <funcprototype>
-            <funcdef>geometry[] <function>ST_ClusterIntersecting</function></funcdef>
-            <paramdef><type>geometry set</type> <parameter>g</parameter></paramdef>
-          </funcprototype>
-        </funcsynopsis>
-      </refsynopsisdiv>
-
-      <refsection>
-        <title>Description</title>
-
-        <para>ST_ClusterIntersecting is an aggregate function that returns an array of GeometryCollections, where each GeometryCollection represents an interconnected set of geometries.</para>
-
-        <para>Availability: 2.2.0</para>
-      </refsection>
-
-      <refsection>
-        <title>Examples</title>
-        <programlisting>
-WITH testdata AS
-  (SELECT unnest(ARRAY['LINESTRING (0 0, 1 1)'::geometry,
-                      'LINESTRING (5 5, 4 4)'::geometry,
-                      'LINESTRING (6 6, 7 7)'::geometry,
-                      'LINESTRING (0 0, -1 -1)'::geometry,
-                      'POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))'::geometry]) AS geom)
-
-SELECT ST_AsText(unnest(ST_ClusterIntersecting(geom))) FROM testdata;
-
---result
-
-st_astext
----------
-GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(5 5,4 4),LINESTRING(0 0,-1 -1),POLYGON((0 0,4 0,4 4,0 4,0 0)))
-GEOMETRYCOLLECTION(LINESTRING(6 6,7 7))
-        </programlisting>
-      </refsection>
-      <refsection>
-        <title>See Also</title>
-        <para>
-            <xref linkend="ST_ClusterDBSCAN" />,
-            <xref linkend="ST_ClusterKMeans" />,
-            <xref linkend="ST_ClusterWithin" />
-        </para>
-      </refsection>
-
-    </refentry>
-
-
-       <refentry id="ST_ClusterKMeans">
-         <refnamediv>
-               <refname>ST_ClusterKMeans</refname>
-
-               <refpurpose>Windowing function that returns integer id for the cluster each input geometry is in.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>integer <function>ST_ClusterKMeans</function></funcdef>
-
-                       <paramdef><type>geometry winset </type>
-                       <parameter>geom</parameter></paramdef>
-
-                       <paramdef><type>integer </type>
-                       <parameter>number_of_clusters</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-      <title>Description</title>
-
-      <para>Returns 2D distance based
-        <ulink url="https://en.wikipedia.org/wiki/K-means_clustering">k-means</ulink>
-        cluster number for each input geometry. The distance used for clustering is the
-        distance between the centroids of the geometries.
-      </para>
-      <para>Availability: 2.3.0</para>
-    </refsection>
-
-    <refsection>
-      <title>Examples</title>
-               <para>Generate dummy set of parcels for examples</para>
-               <programlisting>CREATE TABLE parcels AS
-SELECT lpad((row_number() over())::text,3,'0') As parcel_id, geom,
-('{residential, commercial}'::text[])[1 + mod(row_number()OVER(),2)] As type
-FROM
-    ST_Subdivide(ST_Buffer('LINESTRING(40 100, 98 100, 100 150, 60 90)'::geometry,
-    40, 'endcap=square'),12) As geom;
-</programlisting>
-
-       <informaltable>
-                         <tgroup cols="1">
-                               <tbody>
-                                 <row>
-                                       <entry>
-                                               <para><informalfigure>
-                                               <mediaobject>
-                                                 <imageobject>
-                                                       <imagedata fileref="images/st_clusterkmeans01.png" />
-                                                 </imageobject>
-                                                 <caption><para>Original Parcels</para></caption>
-                                               </mediaobject>
-                                               </informalfigure>
-                                               </para>
-                                       </entry>
-                                       <entry><para><informalfigure>
-                                               <mediaobject>
-                                                 <imageobject>
-                                                       <imagedata fileref="images/st_clusterkmeans02.png" />
-                                                 </imageobject>
-                                                 <caption><para>Parcels color-coded by cluster number (cid)</para></caption>
-                                               </mediaobject>
-                                         </informalfigure>
-                                               <programlisting>SELECT ST_ClusterKMeans(geom, 5) OVER() AS cid, parcel_id, geom
-FROM parcels;
--- result
- cid | parcel_id |   geom
------+-----------+---------------
-   0 | 001       | 0103000000...
-   0 | 002       | 0103000000...
-   1 | 003       | 0103000000...
-   0 | 004       | 0103000000...
-   1 | 005       | 0103000000...
-   2 | 006       | 0103000000...
-   2 | 007       | 0103000000...
-(7 rows)</programlisting>
-                                       </para></entry>
-                                 </row>
-                       </tbody>
-                       </tgroup>
-               </informaltable>
-
-                   <programlisting> -- Partitioning parcel clusters by type
-SELECT ST_ClusterKMeans(geom,3) over (PARTITION BY type) AS cid, parcel_id, type
-FROM parcels;
--- result
- cid | parcel_id |    type
------+-----------+-------------
-   1 | 005       | commercial
-   1 | 003       | commercial
-   2 | 007       | commercial
-   0 | 001       | commercial
-   1 | 004       | residential
-   0 | 002       | residential
-   2 | 006       | residential
-(7 rows)</programlisting>
-
-    </refsection>
-
-    <refsection>
-                 <title>See Also</title>
-          <para>
-              <xref linkend="ST_ClusterDBSCAN"/>,
-              <xref linkend="ST_ClusterIntersecting" />,
-              <xref linkend="ST_ClusterWithin" />, <xref linkend="ST_Subdivide" />
-          </para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_ClusterWithin">
-      <refnamediv>
-        <refname>ST_ClusterWithin</refname>
-
-        <refpurpose>Aggregate.  Returns an array of GeometryCollections, where each GeometryCollection represents a set of geometries separated by no more than the specified distance.</refpurpose>
-      </refnamediv>
-
-      <refsynopsisdiv>
-        <funcsynopsis>
-          <funcprototype>
-            <funcdef>geometry[] <function>ST_ClusterWithin</function></funcdef>
-            <paramdef><type>geometry set </type> <parameter>g</parameter></paramdef>
-            <paramdef><type>float8 </type> <parameter>distance</parameter></paramdef>
-          </funcprototype>
-        </funcsynopsis>
-      </refsynopsisdiv>
-
-      <refsection>
-        <title>Description</title>
-
-        <para>ST_ClusterWithin is an aggregate function that returns an array of GeometryCollections, where each GeometryCollection represents a set of geometries separated by no more than the specified distance.  (Distances are Cartesian distances in the units of the SRID.)</para>
-
-        <para>Availability: 2.2.0</para>
-      </refsection>
-
-      <refsection>
-        <title>Examples</title>
-        <programlisting>
-WITH testdata AS
-  (SELECT unnest(ARRAY['LINESTRING (0 0, 1 1)'::geometry,
-                      'LINESTRING (5 5, 4 4)'::geometry,
-                      'LINESTRING (6 6, 7 7)'::geometry,
-                      'LINESTRING (0 0, -1 -1)'::geometry,
-                      'POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))'::geometry]) AS geom)
-
-SELECT ST_AsText(unnest(ST_ClusterWithin(geom, 1.4))) FROM testdata;
-
---result
+       <title>Measurement Functions</title>
 
-st_astext
----------
-GEOMETRYCOLLECTION(LINESTRING(0 0,1 1),LINESTRING(5 5,4 4),LINESTRING(0 0,-1 -1),POLYGON((0 0,4 0,4 4,0 4,0 0)))
-GEOMETRYCOLLECTION(LINESTRING(6 6,7 7))
-        </programlisting>
-      </refsection>
-      <refsection>
-        <title>See Also</title>
-        <para>
-          <xref linkend="ST_ClusterDBSCAN" />,
-          <xref linkend="ST_ClusterKMeans" />,
-          <xref linkend="ST_ClusterIntersecting" />
-        </para>
-      </refsection>
-
-    </refentry>
-
-  <refentry id="ST_Contains">
-         <refnamediv>
-               <refname>ST_Contains</refname>
-
-               <refpurpose>Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A. </refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_Contains</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>geomA</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>geomB</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Geometry A contains Geometry B if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.
-               An important subtlety of this definition is that A does not contain its boundary, but A does contain itself. Contrast that to <xref linkend="ST_ContainsProperly" /> where geometry
-               A does not Contain Properly itself.</para>
-
-               <para>Returns TRUE if geometry B is completely inside geometry A. For this function to make
-               sense, the source geometries must both be of the same coordinate projection,
-               having the same SRID.  ST_Contains is the inverse of ST_Within.  So ST_Contains(A,B) implies ST_Within(B,A) except in the case of
-               invalid geometries where the result is always false regardless or not defined.</para>
-
-               <para>Performed by the GEOS module</para>
-               <para>Enhanced: 2.3.0 Enhancement to PIP short-circuit extended to support MultiPoints with few points. Prior versions only supported point in polygon.</para>
-
-               <important>
-                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
-               </important>
-
-               <important>
-                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
-               </important>
-
-               <para>This function call will automatically include a bounding box
-                       comparison that will make use of any indexes that are available on
-                       the geometries. To avoid index use, use the function
-                       _ST_Contains.</para>
-
-               <para>NOTE: this is the "allowable" version that returns a
-                       boolean, not an integer.</para>
+       <refentry id="ST_Area">
+               <refnamediv>
+                 <refname>ST_Area</refname>
 
-               <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3
-               - same as within(geometry B, geometry A)</para>
-               <para>&sqlmm_compliant; SQL-MM 3: 5.1.31</para>
+                 <refpurpose>Returns the area of a polygonal geometry.
+                       </refpurpose>
+               </refnamediv>
+               <refsynopsisdiv>
+                 <funcsynopsis>
+                       <funcprototype>
+                         <funcdef>float <function>ST_Area</function></funcdef>
+                               <paramdef><type>geometry </type><parameter>g1</parameter></paramdef>
+                       </funcprototype>
 
-               <para>There are certain subtleties to ST_Contains and ST_Within that are not intuitively obvious.
-                       For details check out <ulink url="http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html">Subtleties of OGC Covers, Contains, Within</ulink></para>
-         </refsection>
+                       <funcprototype>
+                         <funcdef>float <function>ST_Area</function></funcdef>
+                               <paramdef><type>geography </type><parameter>geog</parameter></paramdef>
+                               <paramdef choice="opt"><type>boolean </type><parameter>use_spheroid=true</parameter></paramdef>
+                       </funcprototype>
+                 </funcsynopsis>
+               </refsynopsisdiv>
+               <refsection>
+                       <title>Description</title>
 
-         <refsection>
-               <title>Examples</title>
+                       <para>Returns the area of a polygonal geometry.
+                       For geometry types a 2D Cartesian (planar) area is computed, with units specified by the SRID.
+                       For geography types by default area is determined on a spheroid with units in square meters.
+                 To compute the area using the faster but less accurate spherical model use <varname>ST_Area(geog,false)</varname>.
+                 </para>
+                       <para>Enhanced: 2.0.0 - support for 2D polyhedral surfaces was introduced.</para>
+                       <para>Enhanced: 2.2.0 - measurement on spheroid performed with GeographicLib for improved accuracy and robustness.  Requires Proj &gt;= 4.9.0 to take advantage of the new feature.</para>
+                       <para>Changed: 3.0.0 - does not depend on SFCGAL anymore.</para>
+                       <para>&sfs_compliant;</para>
+                       <para>&sqlmm_compliant; SQL-MM 3: 8.1.2, 9.5.3</para>
+                       <para>&P_support;</para>
+                       <note><para>For polyhedral surfaces, only supports 2D polyhedral surfaces (not 2.5D).  For 2.5D, may give a non-zero answer, but only for the faces that
+                       sit completely in XY plane.</para></note>
+               </refsection>
 
-               <para>The <function>ST_Contains</function> predicate returns <varname>TRUE</varname> in all the following illustrations.</para>
+                 <refsection>
+                       <title>Examples</title>
+                       <para>Return area in square feet for a plot of Massachusetts land and multiply by conversion to get square meters.
+                               Note this is in square feet because EPSG:2249 is
+                               Massachusetts State Plane Feet </para>
+                       <programlisting>
+select ST_Area(geom) sqft,
+    ST_Area(geom) * 0.3048 ^ 2 sqm
+from (
+         select 'SRID=2249;POLYGON((743238 2967416,743238 2967450,
+                                743265 2967450,743265.625 2967416,743238 2967416))' :: geometry geom
+     ) subquery;
+┌─────────┬─────────────┐
+│  sqft   │     sqm     │
+├─────────┼─────────────┤
+│ 928.625 │ 86.27208552 │
+└─────────┴─────────────┘
+</programlisting>
+<para>Return area square feet and transform to Massachusetts state plane meters (EPSG:26986) to get square meters.
+                               Note this is in square feet because 2249 is
+                               Massachusetts State Plane Feet and transformed area is in square meters since EPSG:26986 is state plane Massachusetts meters </para>
+<programlisting>select ST_Area(geom) sqft,
+    ST_Area(ST_Transform(geom, 26986)) As sqm
+from (
+         select
+             'SRID=2249;POLYGON((743238 2967416,743238 2967450,
+             743265 2967450,743265.625 2967416,743238 2967416))' :: geometry geom
+     ) subquery;
+┌─────────┬─────────────────┐
+│  sqft   │       sqm       │
+├─────────┼─────────────────┤
+│ 928.625 │ 86.272430607008 │
+└─────────┴─────────────────┘
+</programlisting>
 
-               <informaltable>
-                 <tgroup cols="2">
-                       <tbody>
-                         <row>
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_contains01.png" />
-                                         </imageobject>
+<para>Return area square feet and square meters using geography data type.  Note that we transform to our geometry to geography
+       (before you can do that make sure your geometry is in WGS 84 long lat 4326).  Geography always measures in meters.
+       This is just for demonstration to compare.  Normally your table will be stored in geography data type already.</para>
+<programlisting>
 
-                                         <caption><para><varname>LINESTRING</varname> / <varname>MULTIPOINT</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
+select ST_Area(geog) / 0.3048 ^ 2 sqft_spheroid,
+    ST_Area(geog, false) / 0.3048 ^ 2 sqft_sphere,
+    ST_Area(geog) sqm_spheroid
+from (
+         select ST_Transform(
+                    'SRID=2249;POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))'::geometry,
+                    4326
+             ) :: geography geog
+     ) as subquery;
+┌──────────────────┬──────────────────┬──────────────────┐
+│  sqft_spheroid   │   sqft_sphere    │   sqm_spheroid   │
+├──────────────────┼──────────────────┼──────────────────┤
+│ 928.684405784452 │ 927.049336105925 │ 86.2776044979692 │
+└──────────────────┴──────────────────┴──────────────────┘
+</programlisting>
 
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_contains02.png" />
-                                         </imageobject>
+ <para>If your data is in geography already:</para>
+ <programlisting>
+select ST_Area(geog) / 0.3048 ^ 2 sqft,
+    ST_Area(the_geog) sqm
+from somegeogtable;</programlisting>
+                 </refsection>
+               <refsection>
+                       <title>See Also</title>
+                       <para><xref linkend="ST_3DArea" />, <xref linkend="ST_GeomFromText" />, <xref linkend="ST_GeographyFromText" />, <xref linkend="ST_SetSRID" />, <xref linkend="ST_Transform" /></para>
+               </refsection>
+       </refentry>
 
-                                         <caption><para><varname>POLYGON</varname> / <varname>POINT</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
-                         </row>
-                         <row>
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_contains03.png" />
-                                         </imageobject>
+       <refentry id="ST_Azimuth">
+               <refnamediv>
+                 <refname>ST_Azimuth</refname>
 
-                                         <caption><para><varname>POLYGON</varname> / <varname>LINESTRING</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
+                 <refpurpose>Returns the north-based azimuth as the angle in radians measured clockwise from the vertical on pointA to pointB.</refpurpose>
+               </refnamediv>
+               <refsynopsisdiv>
+                 <funcsynopsis>
+                       <funcprototype>
+                         <funcdef>float <function>ST_Azimuth</function></funcdef>
+                         <paramdef><type>geometry </type><parameter>pointA</parameter></paramdef>
+                         <paramdef><type>geometry </type><parameter>pointB</parameter></paramdef>
+                       </funcprototype>
+                       <funcprototype>
+                         <funcdef>float <function>ST_Azimuth</function></funcdef>
+                         <paramdef><type>geography </type><parameter>pointA</parameter></paramdef>
+                         <paramdef><type>geography </type><parameter>pointB</parameter></paramdef>
+                       </funcprototype>
+                 </funcsynopsis>
+               </refsynopsisdiv>
+               <refsection>
+                       <title>Description</title>
 
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_contains04.png" />
-                                         </imageobject>
+                       <para>Returns the azimuth in radians of the segment defined by the given
+                       point geometries, or NULL if the two points are coincident. The azimuth is angle is referenced from north, and is positive clockwise: North = 0; East = &#x03C0;/2; South = &#x03C0;; West = 3&#x03C0;/2.</para>
+                       <para>For the geography type, the forward azimuth is solved as part of the inverse geodesic problem.</para>
+                       <para>The azimuth is mathematical concept defined as the angle between a reference plane and a point, with angular units in radians.
+                       Units can be converted to degrees using a built-in PostgreSQL function degrees(), as shown in the example.</para>
 
-                                         <caption><para><varname>POLYGON</varname> / <varname>POLYGON</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
-                         </row>
-                       </tbody>
-                 </tgroup>
-               </informaltable>
+                       <para>Availability: 1.1.0</para>
+                       <para>Enhanced: 2.0.0 support for geography was introduced.</para>
+                       <para>Enhanced: 2.2.0 measurement on spheroid performed with GeographicLib for improved accuracy and robustness.  Requires Proj &gt;= 4.9.0 to take advantage of the new feature.</para>
+                       <para>Azimuth is especially useful in conjunction with ST_Translate for shifting an object along its perpendicular axis. See
+                                upgis_lineshift <ulink url="http://trac.osgeo.org/postgis/wiki/UsersWikiplpgsqlfunctions">Plpgsqlfunctions PostGIS wiki section</ulink> for example of this.</para>
+               </refsection>
 
-               <para>The <function>ST_Contains</function> predicate returns <varname>FALSE</varname> in all the following illustrations.</para>
+               <refsection>
+               <title>Examples</title>
+               <para>Geometry Azimuth in degrees </para>
+<programlisting>
+SELECT degrees(ST_Azimuth(ST_Point(25, 45), ST_Point(75, 100))) AS degA_B,
+           degrees(ST_Azimuth(ST_Point(75, 100), ST_Point(25, 45))) AS degB_A;
 
+      dega_b       |     degb_a
+------------------+------------------
+ 42.2736890060937 | 222.273689006094
+</programlisting>
                <informaltable>
                  <tgroup cols="2">
                        <tbody>
-                         <row>
+                               <row>
                                <entry><para><informalfigure>
                                        <mediaobject>
                                          <imageobject>
-                                               <imagedata fileref="images/st_contains05.png" />
+                                               <imagedata fileref="images/st_azimuth01.png" />
                                          </imageobject>
-
-                                         <caption><para><varname>POLYGON</varname> / <varname>MULTIPOINT</varname></para></caption>
+                                         <caption><para>Green: the start Point(25,45) with its vertical. Yellow: degA_B as the path to travel (azimuth).</para></caption>
                                        </mediaobject>
-                                 </informalfigure></para></entry>
-
+                                 </informalfigure>
+                               </para></entry>
                                <entry><para><informalfigure>
                                        <mediaobject>
                                          <imageobject>
-                                               <imagedata fileref="images/st_contains06.png" />
+                                               <imagedata fileref="images/st_azimuth02.png" />
                                          </imageobject>
-
-                                         <caption><para><varname>POLYGON</varname> / <varname>LINESTRING</varname></para></caption>
+                                         <caption><para>Green: the start Point(75,100) with its vertical. Yellow: degB_A as the path to travel (azimuth).</para></caption>
                                        </mediaobject>
-                                 </informalfigure></para></entry>
-                         </row>
+                                 </informalfigure>
+                               </para></entry>
+                               </row>
                        </tbody>
-                 </tgroup>
+                       </tgroup>
                </informaltable>
+               </refsection>
+               <refsection>
+                       <title>See Also</title>
+                       <para><xref linkend="ST_Point" />, <xref linkend="ST_Translate" />, <xref linkend="ST_Project" />, <ulink url="http://www.postgresql.org/docs/current/interactive/functions-math.html">PostgreSQL Math Functions</ulink></para>
+               </refsection>
 
-                 <programlisting>
--- A circle within a circle
-SELECT ST_Contains(smallc, bigc) As smallcontainsbig,
-          ST_Contains(bigc,smallc) As bigcontainssmall,
-          ST_Contains(bigc, ST_Union(smallc, bigc)) as bigcontainsunion,
-          ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion,
-          ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
-          ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
-FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
-                        ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-
--- Result
-  smallcontainsbig | bigcontainssmall | bigcontainsunion | bigisunion | bigcoversexterior | bigcontainsexterior
-------------------+------------------+------------------+------------+-------------------+---------------------
- f                | t                | t                | t          | t        | f
-
--- Example demonstrating difference between contains and contains properly
-SELECT ST_GeometryType(geomA) As geomtype, ST_Contains(geomA,geomA) AS acontainsa, ST_ContainsProperly(geomA, geomA) AS acontainspropa,
-   ST_Contains(geomA, ST_Boundary(geomA)) As acontainsba, ST_ContainsProperly(geomA, ST_Boundary(geomA)) As acontainspropba
-FROM (VALUES ( ST_Buffer(ST_Point(1,1), 5,1) ),
-                        ( ST_MakeLine(ST_Point(1,1), ST_Point(-1,-1) ) ),
-                        ( ST_Point(1,1) )
-         ) As foo(geomA);
-
-  geomtype    | acontainsa | acontainspropa | acontainsba | acontainspropba
---------------+------------+----------------+-------------+-----------------
-ST_Polygon    | t          | f              | f           | f
-ST_LineString | t          | f              | f           | f
-ST_Point      | t          | t              | f           | f
-
- </programlisting>
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-               <para><xref linkend="ST_Boundary" />, <xref linkend="ST_ContainsProperly" />, <xref linkend="ST_Covers" />, <xref linkend="ST_CoveredBy" />, <xref linkend="ST_Equals"/>, <xref linkend="ST_Within"/></para>
-         </refsection>
- </refentry>
-
- <refentry id="ST_ContainsProperly">
-         <refnamediv>
-               <refname>ST_ContainsProperly</refname>
-
-               <refpurpose>Returns true if B intersects the interior of A but not the boundary (or exterior). A does not contain properly itself, but does contain itself.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>geomA</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>geomB</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns true if B intersects the interior of A but not the boundary (or exterior).</para>
-
-               <para>A does not contain properly itself, but does contain itself.</para>
-               <para>Every point of the other geometry is a point of this geometry's interior. The DE-9IM Intersection Matrix for the two geometries matches
-   [T**FF*FF*] used in <xref linkend="ST_Relate" /></para>
+  </refentry>
 
-               <note>
-                 <para>From JTS docs slightly reworded: The advantage to using this predicate over <xref linkend="ST_Contains" /> and <xref linkend="ST_Intersects" /> is that it can be computed
-         efficiently, with no need to compute topology at individual points.</para>
-               <para>
-                        An example use case for this predicate is computing the intersections of a set of geometries with a large polygonal geometry. Since intersection is a fairly slow operation, it can be more efficient to use containsProperly to filter out test geometries which lie
-       wholly inside the area.  In these cases the intersection is     known a priori to be exactly the original test geometry.
-        </para>
-               </note>
-               <para>Performed by the GEOS module.</para>
-               <para>Availability: 1.4.0</para>
+       <refentry id="ST_Angle">
+               <refnamediv>
+                 <refname>ST_Angle</refname>
 
-               <important>
-                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
-               </important>
+                 <refpurpose>Returns the angle between 3 points, or between 2 vectors (4 points or 2 lines).</refpurpose>
+               </refnamediv>
+               <refsynopsisdiv>
+                 <funcsynopsis>
+                       <funcprototype>
+                         <funcdef>float <function>ST_Angle</function></funcdef>
+                         <paramdef><type>geometry </type><parameter>point1</parameter></paramdef>
+                         <paramdef><type>geometry </type><parameter>point2</parameter></paramdef>
+                         <paramdef><type>geometry </type><parameter>point3</parameter></paramdef>
+                         <paramdef choice="opt"><type>geometry </type><parameter>point4</parameter></paramdef>
+                       </funcprototype>
+                       <funcprototype>
+                         <funcdef>float <function>ST_Angle</function></funcdef>
+                         <paramdef><type>geometry </type><parameter>line1</parameter></paramdef>
+                         <paramdef><type>geometry </type><parameter>line2</parameter></paramdef>
+                       </funcprototype>
+                 </funcsynopsis>
+               </refsynopsisdiv>
+               <refsection>
+                       <title>Description</title>
 
-               <important>
-                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
-               </important>
+                       <para> For 3 points, computes the angle measured clockwise of P1P2P3.
+                       If input are 2 lines, get first and last point of the lines as 4 points.
+                       For 4 points,compute the angle measured clockwise of P1P2,P3P4.
+                       Results are always positive, between 0 and 2*Pi radians.
 
-               <para>This function call will automatically include a bounding box
-                       comparison that will make use of any indexes that are available on
-                       the geometries. To avoid index use, use the function
-                       _ST_ContainsProperly.</para>
+                       Uses azimuth of pairs or points.
+                       </para>
+                       <para>ST_Angle(P1,P2,P3) = ST_Angle(P2,P1,P2,P3)</para>
+                       <para>Result is in radian and can be converted to degrees using a built-in PostgreSQL function degrees(), as shown in the example.</para>
+                       <para>Availability: 2.5.0</para>
+               </refsection>
 
-         </refsection>
+               <refsection>
+               <title>Examples</title>
+               <para>Geometry Azimuth in degrees </para>
+<programlisting>
+       WITH rand AS (
+               SELECT s, random() * 2 * PI() AS rad1
+                       , random() * 2 * PI() AS rad2
+               FROM  generate_series(1,2,2) AS s
+       )
+        , points AS (
+               SELECT s, rad1,rad2, ST_MakePoint(cos1+s,sin1+s) as p1, ST_MakePoint(s,s) AS p2, ST_MakePoint(cos2+s,sin2+s) as p3
+               FROM rand
+                       ,cos(rad1) cos1, sin(rad1) sin1
+                       ,cos(rad2) cos2, sin(rad2) sin2
+       )
+       SELECT s, ST_AsText(ST_SnapToGrid(ST_MakeLine(ARRAY[p1,p2,p3]),0.001)) AS line
+               , degrees(ST_Angle(p1,p2,p3)) as computed_angle
+               , round(degrees(2*PI()-rad2 -2*PI()+rad1+2*PI()))::int%360 AS reference
+               , round(degrees(2*PI()-rad2 -2*PI()+rad1+2*PI()))::int%360 AS reference
+       FROM points ;
 
-         <refsection>
-               <title>Examples</title>
-                 <programlisting>
-       --a circle within a circle
-       SELECT ST_ContainsProperly(smallc, bigc) As smallcontainspropbig,
-       ST_ContainsProperly(bigc,smallc) As bigcontainspropsmall,
-       ST_ContainsProperly(bigc, ST_Union(smallc, bigc)) as bigcontainspropunion,
-       ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion,
-       ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
-       ST_ContainsProperly(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
-       FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
-       ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-       --Result
-  smallcontainspropbig | bigcontainspropsmall | bigcontainspropunion | bigisunion | bigcoversexterior | bigcontainsexterior
-------------------+------------------+------------------+------------+-------------------+---------------------
- f                     | t                    | f                    | t          | t                 | f
-
- --example demonstrating difference between contains and contains properly
- SELECT ST_GeometryType(geomA) As geomtype, ST_Contains(geomA,geomA) AS acontainsa, ST_ContainsProperly(geomA, geomA) AS acontainspropa,
- ST_Contains(geomA, ST_Boundary(geomA)) As acontainsba, ST_ContainsProperly(geomA, ST_Boundary(geomA)) As acontainspropba
- FROM (VALUES ( ST_Buffer(ST_Point(1,1), 5,1) ),
-                 ( ST_MakeLine(ST_Point(1,1), ST_Point(-1,-1) ) ),
-                 ( ST_Point(1,1) )
-       ) As foo(geomA);
-
-  geomtype    | acontainsa | acontainspropa | acontainsba | acontainspropba
---------------+------------+----------------+-------------+-----------------
-ST_Polygon    | t          | f              | f           | f
-ST_LineString | t          | f              | f           | f
-ST_Point      | t          | t              | f           | f
- </programlisting>
-         </refsection>
+1 | line | computed_angle | reference
+------------------+------------------
+1 | LINESTRING(1.511 1.86,1 1,0.896 0.005) | 155.27033848688 | 155
 
-         <refsection>
-               <title>See Also</title>
-               <para><xref linkend="ST_GeometryType" />, <xref linkend="ST_Boundary" />, <xref linkend="ST_Contains" />, <xref linkend="ST_Covers" />, <xref linkend="ST_CoveredBy" />, <xref linkend="ST_Equals"/>, <xref linkend="ST_Relate" />, <xref linkend="ST_Within"/></para>
-         </refsection>
- </refentry>
+</programlisting>
+               </refsection>
+  </refentry>
 
-  <refentry id="ST_Covers">
+<refentry id="ST_ClosestPoint">
          <refnamediv>
-               <refname>ST_Covers</refname>
+               <refname>ST_ClosestPoint</refname>
 
-               <refpurpose>Returns 1 (TRUE) if no point in Geometry B is outside
-                       Geometry A</refpurpose>
+               <refpurpose>Returns the 2D point on g1 that is closest to g2.  This is the first point of
+                       the shortest line.</refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
                <funcsynopsis>
                  <funcprototype>
-                       <funcdef>boolean <function>ST_Covers</function></funcdef>
+                       <funcdef>geometry <function>ST_ClosestPoint</function></funcdef>
 
                        <paramdef><type>geometry </type>
-                       <parameter>geomA</parameter></paramdef>
+                       <parameter>g1</parameter></paramdef>
 
                        <paramdef><type>geometry </type>
-                       <parameter>geomB</parameter></paramdef>
-                 </funcprototype>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_Covers</function></funcdef>
-
-                       <paramdef><type>geography </type>
-                       <parameter>geogpolyA</parameter></paramdef>
-
-                       <paramdef><type>geography </type>
-                       <parameter>geogpointB</parameter></paramdef>
+                       <parameter>g2</parameter></paramdef>
                  </funcprototype>
                </funcsynopsis>
          </refsynopsisdiv>
@@ -1812,590 +288,179 @@ ST_Point      | t          | t              | f           | f
          <refsection>
                <title>Description</title>
 
-                 <para>Returns 1 (TRUE) if no point in Geometry/Geography B is outside
-                       Geometry/Geography A</para>
-
-               <important>
-                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
-               </important>
-
-               <important>
-                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
-               </important>
-
-               <para>This function call will automatically include a bounding box
-                       comparison that will make use of any indexes that are available on
-                       the geometries. To avoid index use, use the function
-                       _ST_Covers.</para>
-
-               <para>Performed by the GEOS module</para>
-    <para>Enhanced: 2.4.0 Support for polygon in polygon and line in polygon added for geography type</para>
-               <para>Enhanced: 2.3.0 Enhancement to PIP short-circuit for geometry extended to support MultiPoints with few points. Prior versions only supported point in polygon.</para>
-               <para>Availability: 1.5 - support for geography was introduced. </para>
-               <para>Availability: 1.2.2</para>
-
-               <para>NOTE: this is the "allowable" version that returns a
-                       boolean, not an integer.</para>
-
-               <para>Not an OGC standard, but Oracle has it too.</para>
-               <para>There are certain subtleties to ST_Contains and ST_Within that are not intuitively obvious.
-                       For details check out <ulink url="http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html">Subtleties of OGC Covers, Contains, Within</ulink></para>
+               <para>Returns the 2-dimensional point on g1 that is closest to g2.  This is the first point of
+                       the shortest line.
+               </para>
+               <note><para>If you have a 3D Geometry, you may prefer to use <xref linkend="ST_3DClosestPoint" />.</para></note>
+               <para>Availability: 1.5.0</para>
          </refsection>
 
          <refsection>
                <title>Examples</title>
-                       <para> Geometry example </para>
-                 <programlisting>
-       --a circle covering a circle
-SELECT ST_Covers(smallc,smallc) As smallinsmall,
-       ST_Covers(smallc, bigc) As smallcoversbig,
-       ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
-       ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
-FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
-       ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-       --Result
- smallinsmall | smallcoversbig | bigcoversexterior | bigcontainsexterior
---------------+----------------+-------------------+---------------------
- t            | f              | t                 | f
-(1 row)        </programlisting>
-               <para>Geeography Example</para>
-               <programlisting>
--- a point with a 300 meter buffer compared to a point, a point and its 10 meter buffer
-SELECT ST_Covers(geog_poly, geog_pt) As poly_covers_pt,
-       ST_Covers(ST_Buffer(geog_pt,10), geog_pt) As buff_10m_covers_cent
-       FROM (SELECT ST_Buffer(ST_GeogFromText('SRID=4326;POINT(-99.327 31.4821)'), 300) As geog_poly,
-                               ST_GeogFromText('SRID=4326;POINT(-99.33 31.483)') As geog_pt ) As foo;
-
- poly_covers_pt | buff_10m_covers_cent
-----------------+------------------
- f              | t
-               </programlisting>
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-               <para><xref linkend="ST_Contains"/>, <xref linkend="ST_CoveredBy" />, <xref linkend="ST_Within"/></para>
-         </refsection>
- </refentry>
-
-  <refentry id="ST_CoveredBy">
-         <refnamediv>
-               <refname>ST_CoveredBy</refname>
-
-               <refpurpose>Returns 1 (TRUE) if no point in Geometry/Geography A is outside
-                       Geometry/Geography B</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>geomA</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>geomB</parameter></paramdef>
-                 </funcprototype>
-
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
-
-                       <paramdef><type>geography </type>
-                       <parameter>geogA</parameter></paramdef>
-
-                       <paramdef><type>geography </type>
-                       <parameter>geogB</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-                 <para>Returns 1 (TRUE) if no point in Geometry/Geography A is outside
-                       Geometry/Geography B</para>
+                       <informaltable>
+                                 <tgroup cols="2">
+                                       <tbody>
+                                         <row>
+                                               <entry><para><informalfigure>
+                                                       <mediaobject>
+                                                         <imageobject>
+                                                               <imagedata fileref="images/st_closestpoint01.png" />
+                                                         </imageobject>
+                                                         <caption><para>Closest between point and linestring is the point itself, but closest
+                                                                                       point between a linestring and point is the point on line string that is closest.</para></caption>
+                                                       </mediaobject>
+                                                 </informalfigure>
+                               <programlisting>
+SELECT ST_AsText(ST_ClosestPoint(pt,line)) AS cp_pt_line,
+       ST_AsText(ST_ClosestPoint(line,pt)) As cp_line_pt
+FROM (SELECT 'POINT(100 100)'::geometry As pt,
+               'LINESTRING (20 80, 98 190, 110 180, 50 75 )'::geometry As line
+       ) As foo;
 
-               <important>
-                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
-               </important>
 
-               <important>
-                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
-               </important>
-               <para>Performed by the GEOS module</para>
-               <para>Availability: 1.2.2</para>
-               <para>This function call will automatically include a bounding box
-                       comparison that will make use of any indexes that are available on
-                       the geometries. To avoid index use, use the function
-                       _ST_CoveredBy.</para>
+   cp_pt_line   |                cp_line_pt
+----------------+------------------------------------------
+ POINT(100 100) | POINT(73.0769230769231 115.384615384615)
+                               </programlisting>
+                                                 </para></entry>
 
-               <para>NOTE: this is the "allowable" version that returns a
-                       boolean, not an integer.</para>
+                                               <entry><para><informalfigure>
+                                                       <mediaobject>
+                                                         <imageobject>
+                                                               <imagedata fileref="images/st_closestpoint02.png" />
+                                                         </imageobject>
+                                                         <caption><para>closest point on polygon A to polygon B</para></caption>
+                                                       </mediaobject>
+                                                 </informalfigure>
+                               <programlisting>
+SELECT ST_AsText(
+               ST_ClosestPoint(
+                       ST_GeomFromText('POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))'),
+                       ST_Buffer(ST_GeomFromText('POINT(110 170)'), 20)
+                       )
+               ) As ptwkt;
 
-               <para>Not an OGC standard, but Oracle has it too.</para>
-               <para>There are certain subtleties to ST_Contains and ST_Within that are not intuitively obvious.
-                       For details check out <ulink url="http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html">Subtleties of OGC Covers, Contains, Within</ulink></para>
-         </refsection>
+                  ptwkt
+------------------------------------------
+ POINT(140.752120669087 125.695053378061)
+                               </programlisting>
+                                               </para></entry>
+                                         </row>
+               </tbody>
+       </tgroup>
+</informaltable>
 
-         <refsection>
-               <title>Examples</title>
-                 <programlisting>
-       --a circle coveredby a circle
-SELECT ST_CoveredBy(smallc,smallc) As smallinsmall,
-       ST_CoveredBy(smallc, bigc) As smallcoveredbybig,
-       ST_CoveredBy(ST_ExteriorRing(bigc), bigc) As exteriorcoveredbybig,
-       ST_Within(ST_ExteriorRing(bigc),bigc) As exeriorwithinbig
-FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
-       ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
-       --Result
- smallinsmall | smallcoveredbybig | exteriorcoveredbybig | exeriorwithinbig
---------------+-------------------+----------------------+------------------
- t            | t                 | t                    | f
-(1 row)        </programlisting>
          </refsection>
 
          <refsection>
                <title>See Also</title>
-               <para><xref linkend="ST_Contains"/>, <xref linkend="ST_Covers" />, <xref linkend="ST_ExteriorRing"/>, <xref linkend="ST_Within"/></para>
-         </refsection>
- </refentry>
-
-  <refentry id="ST_Crosses">
-       <refnamediv>
-         <refname>ST_Crosses</refname>
-
-         <refpurpose>Returns <varname>TRUE</varname> if the supplied geometries have some, but not all,
-         interior points in common.</refpurpose>
-       </refnamediv>
-
-       <refsynopsisdiv>
-         <funcsynopsis>
-               <funcprototype>
-                 <funcdef>boolean <function>ST_Crosses</function></funcdef>
-
-                 <paramdef><type>geometry </type><parameter>g1</parameter></paramdef>
-
-                 <paramdef><type>geometry </type><parameter>g2</parameter></paramdef>
-               </funcprototype>
-         </funcsynopsis>
-       </refsynopsisdiv>
-
-       <refsection>
-         <title>Description</title>
-
-         <para><function>ST_Crosses</function> takes two geometry objects and
-         returns <varname>TRUE</varname> if their intersection "spatially cross", that is, the
-         geometries have some, but not all interior points in common. The
-         intersection of the interiors of the geometries must not be the empty
-         set and must have a dimensionality less than the maximum dimension
-         of the two input geometries. Additionally, the intersection of the two
-         geometries must not equal either of the source geometries. Otherwise, it
-         returns <varname>FALSE</varname>.</para>
-
-         <para>In mathematical terms, this is expressed as:</para>
-
-         <remark>TODO: Insert appropriate MathML markup here or use a gif.
-         Simple HTML markup does not work well in both IE and Firefox.</remark>
-
-         <informalfigure>
-               <mediaobject>
-                 <imageobject>
-                       <imagedata fileref="images/st_crosses-math.gif" />
-                 </imageobject>
-               </mediaobject>
-         </informalfigure>
-
-         <para>The DE-9IM Intersection Matrix for the two geometries is:</para>
-
-         <itemizedlist>
-               <listitem>
-                 <para><markup>T*T******</markup> (for Point/Line, Point/Area, and
-                 Line/Area situations)</para>
-               </listitem>
-
-               <listitem>
-                 <para><markup>T*****T**</markup> (for Line/Point, Area/Point, and
-                 Area/Line situations)</para>
-               </listitem>
-
-               <listitem>
-                 <para><markup>0********</markup> (for Line/Line situations)</para>
-               </listitem>
-         </itemizedlist>
-
-         <para>For any other combination of dimensions this predicate returns
-         false.</para>
-
-         <para>The OpenGIS Simple Features Specification defines this predicate
-               only for Point/Line, Point/Area, Line/Line, and Line/Area situations.
-               JTS / GEOS extends the definition to apply to Line/Point, Area/Point and
-               Area/Line situations as well. This makes the relation
-               symmetric.</para>
-
-         <important>
-               <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
-         </important>
-
-       <note>
-         <para>This function call will automatically include a bounding box
-         comparison that will make use of any indexes that are available on the
-         geometries.</para>
-       </note>
-
-       <para>&sfs_compliant; s2.1.13.3</para>
-       <para>&sqlmm_compliant; SQL-MM 3: 5.1.29</para>
-       </refsection>
 
-       <refsection>
-         <title>Examples</title>
-
-         <para>The following illustrations all return <varname>TRUE</varname>.</para>
-
-         <informaltable>
-               <tgroup cols="2">
-                 <tbody>
-                       <row>
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_crosses01.png" />
-                                       </imageobject>
-
-                                       <caption><para><varname>MULTIPOINT</varname> / <varname>LINESTRING</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_crosses02.png" />
-                                       </imageobject>
-
-                                       <caption><para><varname>MULTIPOINT</varname> / <varname>POLYGON</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-                       </row>
-
-                       <row>
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_crosses03.png" />
-                                       </imageobject>
-
-                                       <caption><para><varname>LINESTRING</varname> / <varname>POLYGON</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_crosses04.png" />
-                                       </imageobject>
-
-                                       <caption><para><varname>LINESTRING</varname> / <varname>LINESTRING</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-                       </row>
-                 </tbody>
-               </tgroup>
-         </informaltable>
-
-         <para>Consider a situation where a user has two tables: a table of roads
-         and a table of highways.</para>
-
-         <informaltable>
-               <tgroup cols="2">
-                 <tbody>
-                       <row>
-                         <entry><para> <informalexample>
-                                 <programlisting>CREATE TABLE roads (
-  id serial NOT NULL,
-  the_geom geometry,
-  CONSTRAINT roads_pkey PRIMARY KEY (road_id)
-);</programlisting>
-                               </informalexample> </para></entry>
-
-                         <entry><para> <informalexample>
-                                 <programlisting>CREATE TABLE highways (
-  id serial NOT NULL,
-  the_gem geometry,
-  CONSTRAINT roads_pkey PRIMARY KEY (road_id)
-);</programlisting>
-                               </informalexample> </para></entry>
-                       </row>
-                 </tbody>
-               </tgroup>
-         </informaltable>
-
-         <para>To determine a list of roads that cross a highway, use a query
-         similiar to:</para>
+               <para><xref linkend="ST_3DClosestPoint" />,<xref linkend="ST_Distance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_ShortestLine"/>, <xref linkend="ST_MaxDistance"/></para>
+         </refsection>
+</refentry>
 
-         <para><informalexample>
-                 <programlisting>SELECT roads.id
-FROM roads, highways
-WHERE ST_Crosses(roads.the_geom, highways.the_geom);</programlisting>
-               </informalexample></para>
-       </refsection>
-  </refentry>
+       <refentry id="ST_3DClosestPoint">
+                 <refnamediv>
+                       <refname>ST_3DClosestPoint</refname>
 
-  <refentry id="ST_LineCrossingDirection">
-       <refnamediv>
-         <refname>ST_LineCrossingDirection</refname>
-
-         <refpurpose>Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing.</refpurpose>
-       </refnamediv>
-
-       <refsynopsisdiv>
-         <funcsynopsis>
-               <funcprototype>
-                 <funcdef>integer <function>ST_LineCrossingDirection</function></funcdef>
-                 <paramdef><type>geometry </type> <parameter>linestringA</parameter></paramdef>
-                 <paramdef><type>geometry </type> <parameter>linestringB</parameter></paramdef>
-               </funcprototype>
-         </funcsynopsis>
-       </refsynopsisdiv>
-
-       <refsection>
-         <title>Description</title>
-
-         <para>Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing.  This is only supported for <varname>LINESTRING</varname></para>
-         <para>Definition of integer constants is as follows:
-                  <itemizedlist>
-                               <listitem>
-                                 <para> 0: LINE NO CROSS</para>
-                               </listitem>
-                               <listitem>
-                                 <para>-1: LINE CROSS LEFT</para>
-                               </listitem>
-                               <listitem>
-                                 <para> 1: LINE CROSS RIGHT</para>
-                               </listitem>
-                               <listitem>
-                                 <para>-2: LINE MULTICROSS END LEFT</para>
-                               </listitem>
-                               <listitem>
-                                       <para> 2: LINE MULTICROSS END RIGHT</para>
-                               </listitem>
-                               <listitem>
-                                 <para>-3: LINE MULTICROSS END SAME FIRST LEFT</para>
-                               </listitem>
-                               <listitem>
-                                 <para> 3: LINE MULTICROSS END SAME FIRST RIGHT</para>
-                               </listitem>
-                       </itemizedlist>
-         </para>
-         <para>Availability: 1.4</para>
-         <!-- optionally mention that this function uses indexes if appropriate -->
+                       <refpurpose>Returns the 3D point on g1 that is closest to g2.  This is the first point of
+                               the 3D shortest line.  </refpurpose>
+                 </refnamediv>
 
-       </refsection>
+                 <refsynopsisdiv>
+                       <funcsynopsis>
+                         <funcprototype>
+                               <funcdef>geometry <function>ST_3DClosestPoint</function></funcdef>
 
+                               <paramdef><type>geometry </type>
+                               <parameter>g1</parameter></paramdef>
 
-       <refsection>
-         <title>Examples</title>
-  <!-- TODO: We really badly need diagrams here and more examples -->
-               <informaltable>
-                 <tgroup cols="2">
-                       <tbody>
-                         <row>
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_linecrossingdirection01.png" />
-                                         </imageobject>
-                                         <caption><para>Line 1 (green), Line 2 ball is start point,
-                                       triangle are end points. Query below. </para></caption>
-                                       </mediaobject>
-                                 </informalfigure>
-                                 <programlisting>
-SELECT ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
-         ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
-FROM (
-SELECT
- ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
- ST_GeomFromText('LINESTRING(171 154,20 140,71 74,161 53)') As line2
-       ) As foo;
+                               <paramdef><type>geometry </type>
+                               <parameter>g2</parameter></paramdef>
+                         </funcprototype>
+                       </funcsynopsis>
+                 </refsynopsisdiv>
 
- l1_cross_l2 | l2_cross_l1
--------------+-------------
-           3 |          -3
-                               </programlisting>
-                       </para>
-               </entry>
-
-               <entry>
-                       <para><informalfigure>
-                               <mediaobject>
-                                 <imageobject>
-                                       <imagedata fileref="images/st_linecrossingdirection02.png" />
-                                 </imageobject>
-                                 <caption><para>Line 1 (green), Line 2 (blue) ball is start point,
-                                               triangle are end points. Query below.</para></caption>
-                               </mediaobject>
-                         </informalfigure>
-                         <programlisting>
-SELECT ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
-         ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
-FROM (
- SELECT
-  ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
-  ST_GeomFromText('LINESTRING (171 154, 20 140, 71 74, 2.99 90.16)') As line2
-) As foo;
-
- l1_cross_l2 | l2_cross_l1
--------------+-------------
-           2 |          -2
-                               </programlisting>
-                       </para>
-               </entry>
-         </row>
-         <row>
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_linecrossingdirection03.png" />
-                                         </imageobject>
-                                         <caption><para>Line 1 (green), Line 2 (blue) ball is start point,
-                                       triangle are end points. Query below. </para></caption>
-                                       </mediaobject>
-                                 </informalfigure>
-                                 <programlisting>
-SELECT
-       ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
-       ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
-FROM (
- SELECT
-  ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
-  ST_GeomFromText('LINESTRING (20 140, 71 74, 161 53)') As line2
-  ) As foo;
-
- l1_cross_l2 | l2_cross_l1
--------------+-------------
-          -1 |          1
-                               </programlisting>
-                       </para>
-               </entry>
-
-               <entry>
-                       <para><informalfigure>
-                               <mediaobject>
-                                 <imageobject>
-                                       <imagedata fileref="images/st_linecrossingdirection04.png" />
-                                 </imageobject>
-                                 <caption><para>Line 1 (green), Line 2 (blue) ball is start point,
-                                               triangle are end points. Query below.</para></caption>
-                               </mediaobject>
-                         </informalfigure>
-                         <programlisting>
-SELECT ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
-         ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
-FROM (SELECT
-       ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
-       ST_GeomFromText('LINESTRING(2.99 90.16,71 74,20 140,171 154)') As line2
-       ) As foo;
+                 <refsection>
+                       <title>Description</title>
 
- l1_cross_l2 | l2_cross_l1
--------------+-------------
-          -2 |          2
-                               </programlisting>
+                       <para>Returns the 3-dimensional point on g1 that is closest to g2.  This is the first point of
+                               the 3D shortest line. The 3D length of the 3D shortest line is the 3D distance.
                        </para>
-               </entry>
-         </row>
-         </tbody>
-       </tgroup>
-</informaltable>
-
-<programlisting>
-SELECT s1.gid, s2.gid, ST_LineCrossingDirection(s1.the_geom, s2.the_geom)
-       FROM streets s1 CROSS JOIN streets s2 ON (s1.gid != s2.gid AND s1.the_geom &amp;&amp; s2.the_geom )
-WHERE ST_CrossingDirection(s1.the_geom, s2.the_geom) > 0;
-</programlisting>
-       </refsection>
-
-       <!-- Optionally add a "See Also" section -->
-       <refsection>
-         <title>See Also</title>
+                       <para>&Z_support;</para>
+                       <!-- Optionally mention supports Polyhedral Surface  -->
+                       <para>&P_support;</para>
+                       <para>Availability: 2.0.0</para>
+                       <para>Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
+                 </refsection>
 
-         <para><xref linkend="ST_Crosses" /></para>
-       </refsection>
-  </refentry>
+                 <refsection>
+                       <title>Examples</title>
+                               <informaltable>
+                                         <tgroup cols="1">
+                                               <tbody>
+                                                 <row>
+                                                       <entry><para>linestring and point -- both 3d and 2d closest point
+                                       <programlisting>
+SELECT ST_AsEWKT(ST_3DClosestPoint(line,pt)) AS cp3d_line_pt,
+               ST_AsEWKT(ST_ClosestPoint(line,pt)) As cp2d_line_pt
+       FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
+                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
+               ) As foo;
 
-  <refentry id="ST_Disjoint">
-               <refnamediv>
-                       <refname>ST_Disjoint</refname>
 
-                       <refpurpose>Returns TRUE if the Geometries do not "spatially
-                       intersect" - if they do not share any space together.
-                       </refpurpose>
-               </refnamediv>
-               <refsynopsisdiv>
-                       <funcsynopsis>
-                               <funcprototype>
-                                       <funcdef>boolean <function>ST_Disjoint</function></funcdef>
-                                       <paramdef>
-                                               <type>geometry</type>
-                                               <parameter>A</parameter>
-                                       </paramdef>
-                                       <paramdef>
-                                               <type>geometry</type>
-                                               <parameter>B</parameter>
-                                       </paramdef>
-                               </funcprototype>
-                       </funcsynopsis>
-               </refsynopsisdiv>
-               <refsection>
-                       <title>Description</title>
-                       <para>Overlaps, Touches, Within all imply geometries are not spatially disjoint.  If any of the aforementioned
-                               returns true, then the geometries are not spatially disjoint.
-                               Disjoint implies false for spatial intersection.</para>
-
-                       <important>
-                               <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
-                       </important>
-
-                       <para>Performed by the GEOS module</para>
-                       <note>
-                         <para>This function call does not use indexes</para>
-
-                       </note>
-                       <note>
-                         <para>NOTE: this is the "allowable" version that returns a
-                       boolean, not an integer.</para>
-                       </note>
-                       <para>&sfs_compliant; s2.1.1.2 //s2.1.13.3
-                       - a.Relate(b, 'FF*FF****')</para>
-                       <para>&sqlmm_compliant; SQL-MM 3: 5.1.26</para>
-               </refsection>
-               <refsection>
-               <title>Examples</title>
+ cp3d_line_pt                                          |               cp2d_line_pt
+-----------------------------------------------------------+------------------------------------------
+ POINT(54.6993798867619 128.935022917228 11.5475869506606) | POINT(73.0769230769231 115.384615384615)
+                                       </programlisting>
+                                                         </para></entry>
+                                                   </row>
+                                                   <row>
+                                                       <entry><para>linestring and multipoint -- both 3d and 2d closest point
+                                       <programlisting>SELECT ST_AsEWKT(ST_3DClosestPoint(line,pt)) AS cp3d_line_pt,
+               ST_AsEWKT(ST_ClosestPoint(line,pt)) As cp2d_line_pt
+       FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
+                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
+               ) As foo;
 
-               <programlisting>SELECT ST_Disjoint('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
- st_disjoint
----------------
- t
-(1 row)
-SELECT ST_Disjoint('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry);
- st_disjoint
----------------
- f
-(1 row)
-               </programlisting>
-               </refsection>
 
-               <refsection>
+                       cp3d_line_pt                        | cp2d_line_pt
+-----------------------------------------------------------+--------------
+ POINT(54.6993798867619 128.935022917228 11.5475869506606) | POINT(50 75)
+                                       </programlisting>
+                                                         </para></entry>
+                                                 </row>
+                                                 <row>
+                                                 <entry><para>Multilinestring and polygon both 3d and 2d closest point
+                                       <programlisting>SELECT ST_AsEWKT(ST_3DClosestPoint(poly, mline)) As cp3d,
+    ST_AsEWKT(ST_ClosestPoint(poly, mline)) As cp2d
+        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
+                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
+                (1 10 2, 5 20 1))') As mline ) As foo;
+                   cp3d                    |     cp2d
+-------------------------------------------+--------------
+ POINT(39.993580415989 54.1889925532825 5) | POINT(20 40)
+             </programlisting>
+                                                         </para></entry>
+                                                 </row>
+                       </tbody>
+               </tgroup>
+       </informaltable>
+
+                 </refsection>
+
+                 <refsection>
                        <title>See Also</title>
-                       <para><xref linkend="ST_Intersects"/></para>
-               </refsection>
+
+                       <para><xref linkend="ST_AsEWKT" />, <xref linkend="ST_ClosestPoint"/>, <xref linkend="ST_3DDistance"/>, <xref linkend="ST_3DShortestLine"/></para>
+                 </refsection>
        </refentry>
 
        <refentry id="ST_Distance">
          <refnamediv>
                <refname>ST_Distance</refname>
 
-               <refpurpose>For geometry type returns the 2D Cartesian distance between two geometries in
-               projected units (based on spatial reference system).
-               For geography type defaults to return minimum geodesic distance between two geographies in meters.</refpurpose>
+               <refpurpose>Returns the distance between two geometry or geography values.</refpurpose>
          </refnamediv>
          <refsynopsisdiv>
                <funcsynopsis>
@@ -2429,9 +494,13 @@ SELECT ST_Disjoint('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry);
          <refsection>
                <title>Description</title>
 
-               <para>For <xref linkend="geometry"/> type returns the minimum 2D Cartesian distance between two geometries in
-               projected units (spatial ref units). For <xref linkend="geography"/> type defaults to return the minimum geodesic distance between two geographies in meters.  If use_spheroid is
-               false, a faster sphere calculation is used instead of a spheroid.</para>
+               <para>For <xref linkend="geometry"/> types returns the minimum 2D Cartesian (planar) distance between two geometries, in
+               projected units (spatial ref units).
+               </para>
+               <para>For <xref linkend="geography"/> types defaults to return the minimum geodesic distance between two geographies in meters,
+               compute on the spheroid determined by the SRID.
+               If <varname>use_spheroid</varname> is
+               false, a faster spherical calculation is used.</para>
 
                <para>&sfs_compliant;</para>
                <para>&sqlmm_compliant; SQL-MM 3: 5.1.23</para>
@@ -2516,244 +585,23 @@ FROM (SELECT
          </refsection>
        </refentry>
 
-       <refentry id="ST_MinimumClearance">
-               <refnamediv>
-                       <refname>ST_MinimumClearance</refname>
-                       <refpurpose>Returns the minimum clearance of a geometry, a measure of a geometry's robustness.</refpurpose>
-               </refnamediv>
-
-               <refsynopsisdiv>
-                       <funcsynopsis>
-                               <funcprototype>
-                                       <funcdef>float <function>ST_MinimumClearance</function></funcdef>
-                                       <paramdef><type>geometry </type><parameter>g</parameter></paramdef>
-                               </funcprototype>
-                       </funcsynopsis>
-               </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>
-                       It is not uncommon to have a geometry that, while meeting the criteria for validity according to ST_IsValid (polygons)
-                       or ST_IsSimple (lines), would become invalid if one of the vertices moved by a slight distance, as can happen during
-                       conversion to text-based formats (such as WKT, KML, GML GeoJSON), or binary formats that do not use double-precision
-                       floating point coordinates (MapInfo TAB).
-               </para>
-
-               <para>
-                       A geometry's "minimum clearance" is the smallest distance by which a vertex of the geometry could be moved to produce
-                       an invalid geometry.  It can be thought of as a quantitative measure of a geometry's robustness, where increasing values
-                       of minimum clearance indicate increasing robustness.
-               </para>
-
-               <para>
-                       If a geometry has a minimum clearance of <varname>e</varname>, it can be said that:
-                       <itemizedlist>
-                               <listitem>
-                                       <para>
-                                               No two distinct vertices in the geometry are separated by less than <varname>e</varname>.
-                                       </para>
-                               </listitem>
-                               <listitem>
-                                       <para>
-                                               No vertex is closer than <varname>e</varname> to a line segement of which it is not an endpoint.
-                                       </para>
-                               </listitem>
-                       </itemizedlist>
-               </para>
-
-               <para>
-                       If no minimum clearance exists for a geometry (for example, a single point, or a multipoint whose points are identical), then
-                       ST_MinimumClearance will return Infinity.
-               </para>
-
-               <para>Availability: 2.3.0</para>
-
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-               <programlisting>
-SELECT ST_MinimumClearance('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))');
- st_minimumclearance
----------------------
-             0.00032
-     </programlisting>
-
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para>
-                       <xref linkend="ST_MinimumClearanceLine" />
-               </para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_MinimumClearanceLine">
-               <refnamediv>
-                       <refname>ST_MinimumClearanceLine</refname>
-                       <refpurpose>Returns the two-point LineString spanning a geometry's minimum clearance.</refpurpose>
-               </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>Geometry <function>ST_MinimumClearanceLine</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g</parameter></paramdef>
-
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>
-                       Returns the two-point LineString spanning a geometry's minimum clearance.  If the geometry does not have a minimum
-                       clearance, <varname>LINESTRING EMPTY</varname> will be returned.
-               </para>
-               <para>Performed by the GEOS module.</para>
-               <para>Availability: 2.3.0 - requires GEOS &gt;= 3.6.0</para>
-
-         </refsection>
-
-         <refsection>
-                 <title>Examples</title>
-                 <programlisting>
-SELECT ST_AsText(ST_MinimumClearanceLine('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))'));
-st_astext
--------------------------------
-LINESTRING(0.5 0.00032,0.5 0)
-                 </programlisting>
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para>
-                       <xref linkend="ST_MinimumClearance" />
-               </para>
-         </refsection>
-
-       </refentry>
-
-
-       <refentry id="ST_HausdorffDistance">
-         <refnamediv>
-               <refname>ST_HausdorffDistance</refname>
-
-               <refpurpose>Returns the Hausdorff distance between two geometries.  Basically a measure of how similar or dissimilar 2 geometries are. Units are in the units of the spatial
-               reference system of the geometries.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>float <function>ST_HausdorffDistance</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g2</parameter></paramdef>
-                 </funcprototype>
-                 <funcprototype>
-                       <funcdef>float <function>ST_HausdorffDistance</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g2</parameter></paramdef>
-
-                       <paramdef><type>float</type>
-                       <parameter>densifyFrac</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Implements algorithm for computing a distance metric which can be thought of as the "Discrete Hausdorff Distance".
-This is the Hausdorff distance restricted to discrete points for one of the geometries. <ulink url="http://en.wikipedia.org/wiki/Hausdorff_distance">Wikipedia article on Hausdorff distance</ulink>
-       <ulink url="http://lin-ear-th-inking.blogspot.com/2009/01/computing-geometric-similarity.html">Martin Davis note on how Hausdorff Distance calculation was used to prove correctness of the CascadePolygonUnion approach.</ulink></para>
-               <para>
-When densifyFrac is specified, this function performs a segment densification before computing the discrete hausdorff distance. The densifyFrac parameter sets the fraction by which to densify each segment. Each segment will be split into a number of equal-length subsegments, whose fraction of the total length is closest to the given fraction.
-               </para>
-
-               <note>
-                       <para>
-The current implementation supports only vertices as the discrete locations. This could be extended to allow an arbitrary density of points to be used.
-                       </para>
-               </note>
-               <note>
-                       <para>
-                               This algorithm is NOT equivalent to the standard Hausdorff distance. However, it computes an approximation that is correct for a large subset of useful cases.
-                       One important part of this subset is Linestrings that are roughly parallel to each other, and roughly equal in length.  This is a useful metric for line matching.
-                       </para>
-               </note>
-               <para>Availability: 1.5.0</para>
-
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-                   <para>For each building, find the parcel that best represents it. First we require the parcel intersect with the geometry.
-       DISTINCT ON guarantees we get each building listed only once, the ORDER BY .. ST_HausdorffDistance gives us a preference of parcel that is most similar to the building.</para>
-               <programlisting>SELECT DISTINCT ON(buildings.gid) buildings.gid, parcels.parcel_id
-   FROM buildings INNER JOIN parcels ON ST_Intersects(buildings.geom,parcels.geom)
-     ORDER BY buildings.gid, ST_HausdorffDistance(buildings.geom, parcels.geom);</programlisting>
-
-                               <programlisting>postgis=# SELECT ST_HausdorffDistance(
-                               'LINESTRING (0 0, 2 0)'::geometry,
-                               'MULTIPOINT (0 1, 1 0, 2 1)'::geometry);
- st_hausdorffdistance
- ----------------------
-                                        1
-(1 row)
-                       </programlisting>
-                       <programlisting>postgis=# SELECT st_hausdorffdistance('LINESTRING (130 0, 0 0, 0 150)'::geometry, 'LINESTRING (10 10, 10 150, 130 10)'::geometry, 0.5);
- st_hausdorffdistance
- ----------------------
-                                       70
-(1 row)
-                       </programlisting>
-
-         </refsection>
-          <refsection>
-                <title>See Also</title>
-
-                <para><xref linkend="ST_FrechetDistance" /></para>
-          </refsection>
-       </refentry>
-
-       <refentry id="ST_FrechetDistance">
+       <refentry id="ST_3DDistance">
          <refnamediv>
-               <refname>ST_FrechetDistance</refname>
+               <refname>ST_3DDistance</refname>
 
-               <refpurpose>Returns the Fréchet distance between two geometries. This is a measure of similarity between curves that takes into account the location
-               and ordering of the points along the curves.  Units are in the units of the spatial reference system of the geometries.</refpurpose>
+               <refpurpose>Returns the 3D cartesian minimum distance (based on spatial ref) between two geometries in
+               projected units. </refpurpose>
          </refnamediv>
-
          <refsynopsisdiv>
                <funcsynopsis>
                  <funcprototype>
-                       <funcdef>float <function>ST_FrechetDistance</function></funcdef>
+                       <funcdef>float <function>ST_3DDistance</function></funcdef>
 
                        <paramdef><type>geometry </type>
                        <parameter>g1</parameter></paramdef>
 
                        <paramdef><type>geometry </type>
                        <parameter>g2</parameter></paramdef>
-
-                       <paramdef><type>float</type>
-                       <parameter>densifyFrac = -1</parameter></paramdef>
                  </funcprototype>
                </funcsynopsis>
          </refsynopsisdiv>
@@ -2761,113 +609,65 @@ The current implementation supports only vertices as the discrete locations. Thi
          <refsection>
                <title>Description</title>
 
-               <para>Implements algorithm for computing the Fréchet distance restricted to discrete points for both geometries, based on <ulink url="http://www.kr.tuwien.ac.at/staff/eiter/et-archive/cdtr9464.pdf">Computing Discrete Fréchet Distance</ulink>.
-               The Fréchet distance is a measure of similarity between curves that takes into account the location and ordering of the points along the curves. Therefore it is often better than the Hausdorff distance. </para>
-               <para>
-When the optional densifyFrac is specified, this function performs a segment densification before computing the discrete Fréchet distance. The densifyFrac parameter sets the fraction by which to densify each segment. Each segment will be split into a number of equal-length subsegments, whose fraction of the total length is closest to the given fraction.
-               </para>
+               <para>Returns the 3-dimensional minimum cartesian distance between two geometries in
+               projected units (spatial ref units).</para>
 
-               <note>
-                       <para>
-The current implementation supports only vertices as the discrete locations. This could be extended to allow an arbitrary density of points to be used.
-                       </para>
-               </note>
-               <note>
-                       <para>
-The smaller densifyFrac we specify, the more acurate Fréchet distance we get. But, the computation time and the memory usage increase with the square of the number of subsegments.
-                       </para>
-               </note>
-               <para>Performed by the GEOS module.</para>
-               <para>Availability: 2.4.0 - requires GEOS &gt;= 3.7.0</para>
+               <para>&Z_support;</para>
+               <!-- Optionally mention supports Polyhedral Surface  -->
+               <para>&P_support;</para>
+               <para>&sqlmm_compliant; SQL-MM ?</para>
 
+               <para>Availability: 2.0.0</para>
+               <para>Changed: 2.2.0 - In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
+               <para>Changed: 3.0.0 - SFCGAL version removed</para>
          </refsection>
 
          <refsection>
                <title>Examples</title>
-                       <programlisting>postgres=# SELECT st_frechetdistance('LINESTRING (0 0, 100 0)'::geometry, 'LINESTRING (0 0, 50 50, 100 0)'::geometry);
- st_frechetdistance
---------------------
-   70.7106781186548
-(1 row)
-                       </programlisting>
-                       <programlisting>SELECT st_frechetdistance('LINESTRING (0 0, 100 0)'::geometry, 'LINESTRING (0 0, 50 50, 100 0)'::geometry, 0.5);
- st_frechetdistance
---------------------
-                 50
-(1 row)
-                       </programlisting>
 
+               <programlisting>
+-- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
+-- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
+SELECT ST_3DDistance(
+                       ST_Transform('SRID=4326;POINT(-72.1235 42.3521 4)'::geometry,2163),
+                       ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'::geometry,2163)
+               ) As dist_3d,
+               ST_Distance(
+                       ST_Transform('SRID=4326;POINT(-72.1235 42.3521)'::geometry,2163),
+                       ST_Transform('SRID=4326;LINESTRING(-72.1260 42.45, -72.123 42.1546)'::geometry,2163)
+               ) As dist_2d;
+
+     dist_3d      |     dist_2d
+------------------+-----------------
+ 127.295059324629 | 126.66425605671
+</programlisting>
+<programlisting>
+-- Multilinestring and polygon both 3d and 2d distance
+-- Same example as 3D closest point example
+SELECT ST_3DDistance(poly, mline) As dist3d,
+    ST_Distance(poly, mline) As dist2d
+        FROM (SELECT  'POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))'::geometry as poly,
+               'MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1), (1 10 2, 5 20 1))'::geometry as mline) as foo;
+      dist3d       | dist2d
+-------------------+--------
+ 0.716635696066337 |      0
+</programlisting>
          </refsection>
+
          <refsection>
                <title>See Also</title>
 
-               <para><xref linkend="ST_HausdorffDistance" /></para>
+               <para><xref linkend="ST_Distance"/>, <xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_3DDWithin"/>, <xref linkend="ST_3DMaxDistance" />, <xref linkend="ST_3DShortestLine"/>, <xref linkend="ST_Transform" /></para>
          </refsection>
        </refentry>
 
-<refentry id="ST_MaxDistance">
-  <refnamediv>
-    <refname>ST_MaxDistance</refname>
-
-    <refpurpose>Returns the 2-dimensional largest distance between two geometries in
-               projected units.</refpurpose>
-  </refnamediv>
-
-  <refsynopsisdiv>
-    <funcsynopsis>
-      <funcprototype>
-        <funcdef>float <function>ST_MaxDistance</function></funcdef>
-        <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
-        <paramdef><type>geometry </type> <parameter>g2</parameter></paramdef>
-      </funcprototype>
-    </funcsynopsis>
-  </refsynopsisdiv>
-
-  <refsection>
-    <title>Description</title>
-
-    <!-- optionally mention that this function uses indexes if appropriate -->
-    <note>
-      <para>Returns the 2-dimensional maximum distance between two geometries in
-               projected units. If g1 and g2 is the same geometry the function will return the distance between
-               the two vertices most far from each other in that geometry.</para>
-    </note>
-
-       <para>Availability: 1.5.0</para>
-  </refsection>
-  <refsection>
-    <title>Examples</title>
-
-     <para>Basic furthest distance the point is to any part of the line</para>
-               <programlisting>postgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
-   st_maxdistance
------------------
- 2
-(1 row)
-
-postgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 2, 2 2 )'::geometry);
-  st_maxdistance
-------------------
- 2.82842712474619
-(1 row)</programlisting>
-  </refsection>
-
-  <!-- Optionally add a "See Also" section -->
-  <refsection>
-    <title>See Also</title>
-<para><xref linkend="ST_Distance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_DFullyWithin" /></para>
-  </refsection>
-</refentry>
-
 <refentry id="ST_DistanceSphere">
          <refnamediv>
                <refname>ST_DistanceSphere</refname>
 
                <refpurpose>Returns minimum distance in meters between two lon/lat
-                               geometries. Uses a spherical earth and radius derived from the spheroid
-        defined by the SRID.
-                               Faster than ST_DistanceSpheroid <xref linkend="ST_Distance_Spheroid" />, but less
-                               accurate. PostGIS versions prior to 1.5 only implemented for points.</refpurpose>
+                               geometries using a spherical earth model.
+                       </refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
@@ -2924,9 +724,8 @@ FROM
          <refnamediv>
                <refname>ST_DistanceSpheroid</refname>
 
-               <refpurpose>Returns the minimum distance between two lon/lat geometries given a
-                       particular spheroid.
-                       PostGIS  versions prior to 1.5 only support points.</refpurpose>
+               <refpurpose>Returns the minimum distance between two lon/lat geometries
+               using a spheroidal earth model.</refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
@@ -2945,13 +744,15 @@ FROM
 
                <para>Returns minimum distance in meters between two lon/lat
                                geometries given a particular spheroid. See the explanation of spheroids given for
-                       <xref linkend="ST_Length_Spheroid" />. PostGIS version prior to 1.5 only support points.</para>
+                       <xref linkend="ST_Length_Spheroid" />.</para>
                <note>
-                       <para>This function currently does not look at the SRID of a geometry and will always assume its represented in the coordinates of the passed in spheroid. Prior versions of this function only support points.</para>
+                       <para>This function does not look at the SRID of the geometry.
+                       It assumes the geometry coordinates are based on the provided spheroid.
+                       </para>
                </note>
 
                <para>Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points.</para>
-               <para>Changed: 2.2.0 In prior versions this used to be called ST_Distance_Spheroid</para>
+               <para>Changed: 2.2.0 In prior versions this was called ST_Distance_Spheroid</para>
          </refsection>
 
 
@@ -2981,18 +782,18 @@ FROM
          </refsection>
        </refentry>
 
-       <refentry id="ST_DFullyWithin">
+
+       <refentry id="ST_FrechetDistance">
          <refnamediv>
-               <refname>ST_DFullyWithin</refname>
+               <refname>ST_FrechetDistance</refname>
 
-               <refpurpose>Returns true if all of the geometries are within the specified
-               distance of one another</refpurpose>
+               <refpurpose>Returns the Fréchet distance between two geometries.</refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
                <funcsynopsis>
                  <funcprototype>
-                       <funcdef>boolean <function>ST_DFullyWithin</function></funcdef>
+                       <funcdef>float <function>ST_FrechetDistance</function></funcdef>
 
                        <paramdef><type>geometry </type>
                        <parameter>g1</parameter></paramdef>
@@ -3000,84 +801,8 @@ FROM
                        <paramdef><type>geometry </type>
                        <parameter>g2</parameter></paramdef>
 
-                       <paramdef><type>double precision </type>
-                       <parameter>distance</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns true if the geometries is fully within the specified distance
-               of one another. The distance is specified in units defined by the
-               spatial reference system of the geometries.  For this function to make
-               sense, the source geometries must both be of the same coordinate projection,
-               having the same SRID.</para>
-
-               <note>
-                 <para>This function call will automatically include a bounding box
-                 comparison that will make use of any indexes that are available on
-                 the geometries.</para>
-               </note>
-
-               <para>Availability: 1.5.0</para>
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-               <programlisting>postgis=# SELECT ST_DFullyWithin(geom_a, geom_b, 10) as DFullyWithin10, ST_DWithin(geom_a, geom_b, 10) as DWithin10, ST_DFullyWithin(geom_a, geom_b, 20) as DFullyWithin20 from
-               (select ST_GeomFromText('POINT(1 1)') as geom_a,ST_GeomFromText('LINESTRING(1 5, 2 7, 1 9, 14 12)') as geom_b) t1;
-
------------------
- DFullyWithin10 | DWithin10 | DFullyWithin20 |
----------------+----------+---------------+
- f             | t        | t             |  </programlisting>
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_MaxDistance"/>, <xref linkend="ST_DWithin"/></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_DWithin">
-         <refnamediv>
-               <refname>ST_DWithin</refname>
-
-               <refpurpose>Returns true if the geometries are within the specified
-               distance of one another. For geometry units are in those of spatial reference and for geography units are in meters and measurement is
-               defaulted to use_spheroid=true (measure around spheroid), for faster check, use_spheroid=false to measure along sphere.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                               <funcdef>boolean <function>ST_DWithin</function></funcdef>
-                               <paramdef><type>geometry </type>
-                               <parameter>g1</parameter></paramdef>
-
-                               <paramdef><type>geometry </type>
-                               <parameter>g2</parameter></paramdef>
-
-                               <paramdef><type>double precision </type>
-                               <parameter>distance_of_srid</parameter></paramdef>
-                 </funcprototype>
-
-                 <funcprototype>
-                               <funcdef>boolean <function>ST_DWithin</function></funcdef>
-                               <paramdef><type>geography </type>
-                               <parameter>gg1</parameter></paramdef>
-
-                               <paramdef><type>geography </type>
-                               <parameter>gg2</parameter></paramdef>
-
-                               <paramdef><type>double precision </type>
-                               <parameter>distance_meters</parameter></paramdef>
-
-                               <paramdef choice="opt"><type>boolean </type>
-                               <parameter>use_spheroid</parameter></paramdef>
+                       <paramdef><type>float</type>
+                       <parameter>densifyFrac = -1</parameter></paramdef>
                  </funcprototype>
                </funcsynopsis>
          </refsynopsisdiv>
@@ -3085,295 +810,81 @@ FROM
          <refsection>
                <title>Description</title>
 
-               <para>Returns true if the geometries are within the specified distance
-               of one another.</para>
-
-               <para>For <type>geometry</type>: The distance is specified in units defined by the
-               spatial reference system of the geometries.  For this function to make
-               sense, the source geometries must both be of the same coordinate projection,
-               having the same SRID.</para>
-
-               <para>For <type>geography</type> units are in meters and measurement is
-               defaulted to <varname>use_spheroid</varname>=true, for faster check, <varname>use_spheroid</varname>=false to measure along sphere.
+               <para>Implements algorithm for computing the Fréchet distance restricted to discrete points for both geometries, based on <ulink url="http://www.kr.tuwien.ac.at/staff/eiter/et-archive/cdtr9464.pdf">Computing Discrete Fréchet Distance</ulink>.
+               The Fréchet distance is a measure of similarity between curves that takes into account the location and ordering of the points along the curves. Therefore it is often better than the Hausdorff distance. </para>
+               <para>
+When the optional densifyFrac is specified, this function performs a segment densification before computing the discrete Fréchet distance. The densifyFrac parameter sets the fraction by which to densify each segment. Each segment will be split into a number of equal-length subsegments, whose fraction of the total length is closest to the given fraction.
+               </para>
+               <para>Units are in the units of the spatial reference system of the geometries.
                </para>
 
                <note>
-                 <para>This function call will automatically include a bounding box
-                 comparison that will make use of any indexes that are available on
-                 the geometries.</para>
+                       <para>
+The current implementation supports only vertices as the discrete locations. This could be extended to allow an arbitrary density of points to be used.
+                       </para>
                </note>
-
                <note>
-                 <para>Prior to 1.3, ST_Expand was commonly used in conjunction with &amp;&amp; and ST_Distance to
-                 achieve the same effect and in pre-1.3.4 this function was basically short-hand for that construct.
-                 From 1.3.4, ST_DWithin uses a more short-circuit distance function which should make it more efficient
-                 than prior versions for larger buffer regions.</para>
+                       <para>
+The smaller densifyFrac we specify, the more acurate Fréchet distance we get. But, the computation time and the memory usage increase with the square of the number of subsegments.
+                       </para>
                </note>
+               <para>Performed by the GEOS module.</para>
+               <para>Availability: 2.4.0 - requires GEOS &gt;= 3.7.0</para>
 
-               <note><para>Use ST_3DDWithin if you have 3D geometries.</para></note>
-
-               <para>&sfs_compliant;</para>
-               <para>Availability: 1.5.0 support for geography was introduced</para>
-               <para>Enhanced: 2.1.0 improved speed for geography. See <ulink url="http://blog.opengeo.org/2012/07/12/making-geography-faster/">Making Geography faster</ulink> for details.</para>
-               <para>Enhanced: 2.1.0 support for curved geometries was introduced.</para>
          </refsection>
 
          <refsection>
                <title>Examples</title>
-                 <programlisting>
--- Find the nearest hospital to each school
--- that is within 3000 units of the school.
---  We do an ST_DWithin search to utilize indexes to limit our search list
---  that the non-indexable ST_Distance needs to process
--- If the units of the spatial reference is meters then units would be meters
-SELECT DISTINCT ON (s.gid) s.gid, s.school_name, s.geom, h.hospital_name
-       FROM schools s
-               LEFT JOIN hospitals h ON ST_DWithin(s.the_geom, h.geom, 3000)
-       ORDER BY s.gid, ST_Distance(s.geom, h.geom);
-
--- The schools with no close hospitals
--- Find all schools with no hospital within 3000 units
--- away from the school.  Units is in units of spatial ref (e.g. meters, feet, degrees)
-SELECT s.gid, s.school_name
-       FROM schools s
-               LEFT JOIN hospitals h ON ST_DWithin(s.geom, h.geom, 3000)
-       WHERE h.gid IS NULL;
-
--- Find broadcasting towers that receiver with limited range can receive.
--- Data is geometry in Spherical Mercator (SRID=3857), ranges are approximate.
-
--- Create geometry index that will check proximity limit of user to tower
-CREATE INDEX ON broadcasting_towers using gist (geom);
-
--- Create geometry index that will check proximity limit of tower to user
-CREATE INDEX ON broadcasting_towers using gist (ST_Expand(geom, sending_range));
-
--- Query towers that 4-kilometer receiver in Minsk Hackerspace can get
--- Note: two conditions, because shorter LEAST(b.sending_range, 4000) will not use index.
-SELECT b.tower_id, b.geom
-  FROM broadcasting_towers b
-  WHERE ST_DWithin(b.geom, 'SRID=3857;POINT(3072163.4 7159374.1)', 4000)
-         AND ST_DWithin(b.geom, 'SRID=3857;POINT(3072163.4 7159374.1)', b.sending_range);
-
-                         </programlisting>
-         </refsection>
+                       <programlisting>postgres=# SELECT st_frechetdistance('LINESTRING (0 0, 100 0)'::geometry, 'LINESTRING (0 0, 50 50, 100 0)'::geometry);
+ st_frechetdistance
+--------------------
+   70.7106781186548
+(1 row)
+                       </programlisting>
+                       <programlisting>SELECT st_frechetdistance('LINESTRING (0 0, 100 0)'::geometry, 'LINESTRING (0 0, 50 50, 100 0)'::geometry, 0.5);
+ st_frechetdistance
+--------------------
+                 50
+(1 row)
+                       </programlisting>
 
+         </refsection>
          <refsection>
                <title>See Also</title>
 
-               <para><xref linkend="ST_Distance"/>, <xref linkend="ST_Expand"/>, <xref linkend="ST_3DDWithin"/></para>
+               <para><xref linkend="ST_HausdorffDistance" /></para>
          </refsection>
        </refentry>
 
-       <refentry id="ST_Equals">
+       <refentry id="ST_HausdorffDistance">
          <refnamediv>
-               <refname>ST_Equals</refname>
+               <refname>ST_HausdorffDistance</refname>
 
-               <refpurpose>Returns true if the given geometries represent the same geometry. Directionality
-                       is ignored.</refpurpose>
+               <refpurpose>Returns the Hausdorff distance between two geometries. </refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
                <funcsynopsis>
                  <funcprototype>
-                       <funcdef>boolean <function>ST_Equals</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>A</parameter></paramdef>
-                       <paramdef><type>geometry </type> <parameter>B</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns TRUE if the given Geometries are "spatially
-                       equal". Use this for a 'better' answer than '='.
-                       Note by spatially equal we mean ST_Within(A,B) = true and ST_Within(B,A) = true and
-                       also mean ordering of points can be different but
-                       represent the same geometry structure.  To verify the order of points is consistent, use
-                       ST_OrderingEquals (it must be noted ST_OrderingEquals is a little more stringent than simply verifying order of
-                       points are the same).</para>
-
-               <important>
-                 <para>This function will return false if either geometry is invalid except in the case where they are binary equal.</para>
-               </important>
-
-        <important>
-            <para>Do not call with a GEOMETRYCOLLECTION as an argument.</para>
-               </important>
-
-               <para>&sfs_compliant; s2.1.1.2</para>
-               <para>&sqlmm_compliant; SQL-MM 3: 5.1.24</para>
-        <para>Changed: 2.2.0 Returns true even for invalid geometries if they are binary equal</para>
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>SELECT ST_Equals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
-               ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
- st_equals
------------
- t
-(1 row)
-
-SELECT ST_Equals(ST_Reverse(ST_GeomFromText('LINESTRING(0 0, 10 10)')),
-               ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
- st_equals
------------
- t
-(1 row)
-</programlisting>
-         </refsection>
-
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_IsValid"/>, <xref linkend="ST_OrderingEquals"/>, <xref linkend="ST_Reverse"/>, <xref linkend="ST_Within" /></para>
-         </refsection>
-
-       </refentry>
-
-       <refentry id="ST_GeometricMedian">
-         <refnamediv>
-                 <refname>
-                         ST_GeometricMedian
-                 </refname>
-
-               <refpurpose>
-                       Returns the geometric median of a MultiPoint.
-               </refpurpose>
-         </refnamediv>
-
-       <refsynopsisdiv>
-         <funcsynopsis>
-               <funcprototype>
-                       <funcdef>geometry
-                               <function>
-                                       ST_GeometricMedian
-                               </function>
-                       </funcdef>
-
-                       <paramdef>
-                               <type>
-                                       geometry
-                               </type>
-                               <parameter>
-                                       g
-                               </parameter>
-                       </paramdef>
-
-                       <paramdef>
-                               <type>
-                                       float8
-                               </type>
-                               <parameter>
-                                       tolerance
-                               </parameter>
-                       </paramdef>
-
-                       <paramdef>
-                               <type>
-                                       int
-                               </type>
-                               <parameter>
-                                       max_iter
-                               </parameter>
-                       </paramdef>
-
-                       <paramdef>
-                               <type>
-                                       boolean
-                               </type>
-                               <parameter>
-                                       fail_if_not_converged
-                               </parameter>
-                       </paramdef>
-
-               </funcprototype>
-         </funcsynopsis>
-       </refsynopsisdiv>
-
-       <refsection>
-         <title>Description</title>
-
-       <para>
-                 Computes the approximate geometric median of a MultiPoint geometry
-                 using the Weiszfeld algorithm.  The geometric median provides a
-                 centrality measure that is less sensitive to outlier points than
-                 the centroid.
-       </para>
-       <para>
-                 The algorithm will iterate until the distance change between
-                 successive iterations is less than the supplied <varname>tolerance</varname>
-                 parameter.  If this condition has not been met after <varname>max_iterations</varname>
-                 iterations, the function will produce an error and exit, unless <varname>fail_if_not_converged</varname>
-                 is set to false.
-       </para>
-       <para>
-                 If a <varname>tolerance</varname> value is not provided, a default tolerance value
-                 will be calculated based on the extent of the input geometry.
-       </para>
-       <para>
-                 M value of points, if present, is interpreted as their relative weight.
-       </para>
-       <para>Availability: 2.3.0</para>
-       <para>Enhanced: 2.5.0 Added support for M as weight of points.</para>
-       <para>&Z_support;</para>
-       <para>&M_support;</para>
-    </refsection>
-    <refsection>
-      <title>Examples</title>
-         <para>
-                 <informalfigure>
-                         <mediaobject>
-                                       <imageobject>
-                                               <imagedata fileref="images/st_geometricmedian01.png" />
-                                       </imageobject>
-
-                                       <caption>
-                                               <para>
-                                               Comparison of the centroid (turquoise point) and geometric
-                                               median (red point) of a four-point MultiPoint (yellow points).
-                                               </para>
-                                       </caption>
-                         </mediaobject>
-               </informalfigure>
-         </para>
-         <programlisting>
-WITH test AS (
-SELECT 'MULTIPOINT((0 0), (1 1), (2 2), (200 200))'::geometry geom)
-SELECT
-  ST_AsText(ST_Centroid(geom)) centroid,
-  ST_AsText(ST_GeometricMedian(geom)) median
-FROM test;
-      centroid      |                 median
---------------------+----------------------------------------
- POINT(50.75 50.75) | POINT(1.9761550281255 1.9761550281255)
-(1 row)
-         </programlisting>
-       </refsection>
-
-       <refsection>
-         <title>See Also</title>
+                       <funcdef>float <function>ST_HausdorffDistance</function></funcdef>
 
-         <para><xref linkend="ST_Centroid"/></para>
-       </refsection>
+                       <paramdef><type>geometry </type>
+                       <parameter>g1</parameter></paramdef>
 
-       </refentry>
+                       <paramdef><type>geometry </type>
+                       <parameter>g2</parameter></paramdef>
+                 </funcprototype>
+                 <funcprototype>
+                       <funcdef>float <function>ST_HausdorffDistance</function></funcdef>
 
-       <refentry id="ST_HasArc">
-         <refnamediv>
-               <refname>ST_HasArc</refname>
+                       <paramdef><type>geometry </type>
+                       <parameter>g1</parameter></paramdef>
 
-               <refpurpose>Returns true if a geometry or geometry collection contains a circular string</refpurpose>
-         </refnamediv>
+                       <paramdef><type>geometry </type>
+                       <parameter>g2</parameter></paramdef>
 
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_HasArc</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float</type>
+                       <parameter>densifyFrac</parameter></paramdef>
                  </funcprototype>
                </funcsynopsis>
          </refsynopsisdiv>
@@ -3381,136 +892,68 @@ FROM test;
          <refsection>
                <title>Description</title>
 
-               <para>Returns true if a geometry or geometry collection contains a circular string</para>
-
-               <para>Availability: 1.2.3?</para>
-               <para>&Z_support;</para>
-               <para>&curve_support;</para>
-         </refsection>
-
+               <para>Returns the Hausdorff distance between two geometries, a measure of how similar or dissimilar 2 geometries are.
+               </para>
+               <para>Implements algorithm for computing a distance metric which can be thought of as the "Discrete Hausdorff Distance".
+This is the Hausdorff distance restricted to discrete points for one of the geometries. <ulink url="http://en.wikipedia.org/wiki/Hausdorff_distance">Wikipedia article on Hausdorff distance</ulink>
+       <ulink url="http://lin-ear-th-inking.blogspot.com/2009/01/computing-geometric-similarity.html">Martin Davis note on how Hausdorff Distance calculation was used to prove correctness of the CascadePolygonUnion approach.</ulink></para>
+               <para>
+When densifyFrac is specified, this function performs a segment densification before computing the discrete hausdorff distance. The densifyFrac parameter sets the fraction by which to densify each segment. Each segment will be split into a number of equal-length subsegments, whose fraction of the total length is closest to the given fraction.
+               </para>
+               <para>Units are in the units of the spatial reference system of the geometries.
+               </para>
 
-         <refsection>
-               <title>Examples</title>
+               <note>
+                       <para>
+The current implementation supports only vertices as the discrete locations. This could be extended to allow an arbitrary density of points to be used.
+                       </para>
+               </note>
+               <note>
+                       <para>
+                               This algorithm is NOT equivalent to the standard Hausdorff distance. However, it computes an approximation that is correct for a large subset of useful cases.
+                       One important part of this subset is Linestrings that are roughly parallel to each other, and roughly equal in length.  This is a useful metric for line matching.
+                       </para>
+               </note>
+               <para>Availability: 1.5.0</para>
 
-               <programlisting>SELECT ST_HasArc(ST_Collect('LINESTRING(1 2, 3 4, 5 6)', 'CIRCULARSTRING(1 1, 2 3, 4 5, 6 7, 5 6)'));
-               st_hasarc
-               --------
-               t
-               </programlisting>
          </refsection>
 
-         <!-- Optionally add a "See Also" section -->
          <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_CurveToLine" />, <xref linkend="ST_LineToCurve" /></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_Intersects">
-               <refnamediv>
-                       <refname>ST_Intersects</refname>
+               <title>Examples</title>
+                   <para>For each building, find the parcel that best represents it. First we require the parcel intersect with the geometry.
+       DISTINCT ON guarantees we get each building listed only once, the ORDER BY .. ST_HausdorffDistance gives us a preference of parcel that is most similar to the building.</para>
+               <programlisting>SELECT DISTINCT ON(buildings.gid) buildings.gid, parcels.parcel_id
+   FROM buildings INNER JOIN parcels ON ST_Intersects(buildings.geom,parcels.geom)
+     ORDER BY buildings.gid, ST_HausdorffDistance(buildings.geom, parcels.geom);</programlisting>
 
-                       <refpurpose>Returns TRUE if the Geometries/Geography "spatially
-                       intersect in 2D" - (share any portion of space) and FALSE if they don't (they are Disjoint).
-                       For geography tolerance is 0.00001 meters (so any points that close are considered to intersect)
-                       </refpurpose>
-               </refnamediv>
-               <refsynopsisdiv>
-                       <funcsynopsis>
-                               <funcprototype>
-                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
-                                       <paramdef>
-                                               <type>geometry</type>
-                                               <parameter>geomA</parameter>
-                                       </paramdef>
-                                       <paramdef>
-                                               <type>geometry</type>
-                                               <parameter>geomB</parameter>
-                                       </paramdef>
-                               </funcprototype>
-                               <funcprototype>
-                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
-                                       <paramdef>
-                                               <type>geography</type>
-                                               <parameter>geogA</parameter>
-                                       </paramdef>
-                                       <paramdef>
-                                               <type>geography</type>
-                                               <parameter>geogB</parameter>
-                                       </paramdef>
-                               </funcprototype>
-                       </funcsynopsis>
-               </refsynopsisdiv>
-               <refsection>
-                       <title>Description</title>
-                       <para>If a geometry or geography shares any portion of space then they intersect.
-                       For geography -- tolerance is 0.00001 meters (so any points that are close are considered to intersect)</para>
-                       <para>ST_Overlaps, ST_Touches, ST_Within all imply spatial intersection.
-                         If any of the aforementioned
-                               returns true, then the geometries also spatially intersect.
-                               Disjoint implies false for spatial intersection.</para>
-
-                       <para>Changed: 3.0.0 SFCGAL version removed.</para>
-                       <para>Enhanced: 2.5.0 Supports GEOMETRYCOLLECTION.</para>
-                       <para>Enhanced: 2.3.0 Enhancement to PIP short-circuit extended to support MultiPoints with few points. Prior versions only supported point in polygon.</para>
-                       <para>Performed by the GEOS module (for geometry), geography is native</para>
-                       <para>Availability: 1.5 support for geography was introduced.</para>
-                       <note>
-                         <para>This function call will automatically include a bounding box
-                         comparison that will make use of any indexes that are available on the
-                         geometries.</para>
-                       </note>
-                       <note>
-                         <para>For geography, this function has a distance tolerance of about 0.00001 meters and uses the sphere rather
-                               than spheroid calculation.</para>
-                       </note>
-                       <note>
-                         <para>NOTE: this is the "allowable" version that returns a
-                       boolean, not an integer.</para>
-                       </note>
-                       <para>&sfs_compliant; s2.1.1.2 //s2.1.13.3
-                         - ST_Intersects(g1, g2 ) --&gt; Not (ST_Disjoint(g1, g2 ))
-                       </para>
-                       <para>&sqlmm_compliant; SQL-MM 3: 5.1.27</para>
-                        <para>&sfcgal_enhanced;</para>
-               </refsection>
-               <refsection>
-               <title>Geometry Examples</title>
-<programlisting>SELECT ST_Intersects('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
- st_intersects
----------------
- f
+                               <programlisting>postgis=# SELECT ST_HausdorffDistance(
+                               'LINESTRING (0 0, 2 0)'::geometry,
+                               'MULTIPOINT (0 1, 1 0, 2 1)'::geometry);
+ st_hausdorffdistance
+ ----------------------
+                                        1
 (1 row)
-SELECT ST_Intersects('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry);
- st_intersects
----------------
- t
+                       </programlisting>
+                       <programlisting>postgis=# SELECT st_hausdorffdistance('LINESTRING (130 0, 0 0, 0 150)'::geometry, 'LINESTRING (10 10, 10 150, 130 10)'::geometry, 0.5);
+ st_hausdorffdistance
+ ----------------------
+                                       70
 (1 row)
-               </programlisting>
-               </refsection>
-               <refsection>
-               <title>Geography Examples</title>
-<programlisting>SELECT ST_Intersects(
-               'SRID=4326;LINESTRING(-43.23456 72.4567,-43.23456 72.4568)'::geography,
-               'SRID=4326;POINT(-43.23456 72.4567772)'::geography
-               );
+                       </programlisting>
 
- st_intersects
----------------
-t
-</programlisting>
-               </refsection>
-               <refsection>
-                       <title>See Also</title>
-                       <para> <xref linkend="ST_3DIntersects" />, <xref linkend="ST_Disjoint"/></para>
-               </refsection>
+         </refsection>
+          <refsection>
+                <title>See Also</title>
+
+                <para><xref linkend="ST_FrechetDistance" /></para>
+          </refsection>
        </refentry>
+
        <refentry id="ST_Length">
                <refnamediv>
                  <refname>ST_Length</refname>
 
-                 <refpurpose>Returns the 2D length of the geometry if it is a LineString or MultiLineString. geometry are in units of spatial reference and geography are in meters (default spheroid)</refpurpose>
+                 <refpurpose>Returns the 2D length of a linear geometry.</refpurpose>
                </refnamediv>
                <refsynopsisdiv>
                  <funcsynopsis>
@@ -3528,17 +971,21 @@ t
                <refsection>
                        <title>Description</title>
 
-                       <para>For geometry: Returns the 2D Cartesian length of the geometry if it is a LineString, MultiLineString, ST_Curve, ST_MultiCurve.  0 is returned for
-                               areal geometries.  For areal geometries use <xref linkend="ST_Perimeter" />. For geometry types, units for length measures are specified by the
+                       <para>For geometry types: returns the 2D Cartesian length of the geometry if it is a LineString, MultiLineString, ST_Curve, ST_MultiCurve.
+                               For areal geometries 0 is returned; use <xref linkend="ST_Perimeter" /> instead.
+                               The units of length is determined by the
                                spatial reference system of the geometry.</para>
-                       <para>For geography types, the calculations are performed using the inverse geodesic problem, where length units are in meters.
+                       <para>For geography types: computation is performed using the inverse geodesic calculation. Units of length are in meters.
                                If PostGIS is compiled with PROJ version 4.8.0 or later, the spheroid is specified by the SRID, otherwise it is exclusive to WGS84.
-                               If <varname>use_spheroid=false</varname>, then calculations will approximate a sphere instead of a spheroid.</para>
+                               If <varname>use_spheroid=false</varname>, then the calculation is based on a sphere instead of a spheroid.
+                               </para>
 
                        <para>Currently for geometry this is an alias for ST_Length2D, but this may change to support higher dimensions.</para>
+
                        <warning><para>Changed: 2.0.0 Breaking change -- in prior versions applying this to a MULTI/POLYGON of type geography would give you the perimeter of the POLYGON/MULTIPOLYGON.  In 2.0.0
                        this was changed to return 0 to be in line with geometry behavior.  Please use ST_Perimeter if you want the perimeter of a polygon</para></warning>
-                       <note><para>For geography measurement defaults spheroid measurement.  To use the faster less accurate sphere use ST_Length(gg,false);</para></note>
+
+                       <note><para>For geography the calculation defaults to using a spheroidal model.  To use the faster but less accurate spherical calculation use ST_Length(gg,false);</para></note>
                        <para>&sfs_compliant; s2.1.5.1</para>
                        <para>&sqlmm_compliant; SQL-MM 3: 7.1.2, 9.3.4</para>
                        <para>Availability: 1.5.0 geography support was introduced in 1.5.</para>
@@ -3552,6 +999,7 @@ t
                        <programlisting>
 SELECT ST_Length(ST_GeomFromText('LINESTRING(743238 2967416,743238 2967450,743265 2967450,
 743265.625 2967416,743238 2967416)',2249));
+
 st_length
 ---------
  122.630744000095
@@ -3564,6 +1012,7 @@ SELECT ST_Length(
                26986
        )
 );
+
 st_length
 ---------
 34309.4563576191
@@ -3573,11 +1022,12 @@ st_length
                        <title>Geography Examples</title>
                        <para>Return length of WGS 84 geography line</para>
                        <programlisting>
-                       -- default calculation is using a sphere rather than spheroid
+-- the default calculation uses a spheroid
 SELECT ST_Length(the_geog) As length_spheroid,  ST_Length(the_geog,false) As length_sphere
 FROM (SELECT ST_GeographyFromText(
 'SRID=4326;LINESTRING(-72.1260 42.45, -72.1240 42.45666, -72.123 42.1546)') As the_geog)
  As foo;
+
  length_spheroid  |  length_sphere
 ------------------+------------------
  34310.5703627288 | 34346.2060960742
@@ -3593,8 +1043,7 @@ FROM (SELECT ST_GeographyFromText(
          <refnamediv>
                <refname>ST_Length2D</refname>
 
-               <refpurpose>Returns the 2-dimensional length of the geometry if it is a
-                               linestring or multi-linestring. This is an alias for <varname>ST_Length</varname></refpurpose>
+               <refpurpose>Returns the 2D length of a linear geometry. Alias for <varname>ST_Length</varname></refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
@@ -3609,7 +1058,7 @@ FROM (SELECT ST_GeographyFromText(
          <refsection>
                <title>Description</title>
 
-               <para>Returns the 2-dimensional length of the geometry if it is a
+               <para>Returns the 2D length of the geometry if it is a
                                linestring or multi-linestring. This is an alias for <varname>ST_Length</varname></para>
 
          </refsection>
@@ -3626,8 +1075,7 @@ FROM (SELECT ST_GeographyFromText(
          <refnamediv>
                <refname>ST_3DLength</refname>
 
-               <refpurpose>Returns the 3-dimensional or 2-dimensional length of the geometry if it is a
-                       linestring or multi-linestring. </refpurpose>
+               <refpurpose>Returns the 3D length of a linear geometry.</refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
@@ -3675,9 +1123,7 @@ ST_3DLength
          <refnamediv>
                <refname>ST_LengthSpheroid</refname>
 
-        <refpurpose>Calculates the 2D or 3D length/perimeter of a geometry on an ellipsoid. This
-                       is useful if the coordinates of the geometry are in
-                       longitude/latitude and a length is desired without reprojection.</refpurpose>
+        <refpurpose>Returns the 2D or 3D length/perimeter of a lon/lat geometry on a spheroid.</refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
@@ -3693,18 +1139,17 @@ ST_3DLength
          <refsection>
                <title>Description</title>
 
-        <para>Calculates the length/perimeter of a geometry on an ellipsoid. This
+      <para>Calculates the length or perimeter of a geometry on an ellipsoid. This
                        is useful if the coordinates of the geometry are in
                        longitude/latitude and a length is desired without reprojection.
-                       The ellipsoid is a separate database type and can be constructed
-                       as follows:</para>
+                       The spheroid is specified by a text value       as follows:</para>
 
                <literallayout>SPHEROID[&lt;NAME&gt;,&lt;SEMI-MAJOR AXIS&gt;,&lt;INVERSE FLATTENING&gt;]</literallayout>
-
+               <para>For example:</para>
                <literallayout>SPHEROID["GRS_1980",6378137,298.257222101]</literallayout>
 
                <para>Availability: 1.2.2</para>
-               <para>Changed: 2.2.0 In prior versions this used to be called ST_Length_Spheroid and used to have a ST_3DLength_Spheroid alias</para>
+               <para>Changed: 2.2.0 In prior versions this was called ST_Length_Spheroid and had the alias ST_3DLength_Spheroid</para>
                <para>&Z_support;</para>
          </refsection>
 
@@ -3753,10 +1198,8 @@ CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m)  as foo
          <refnamediv>
                <refname>ST_LongestLine</refname>
 
-               <refpurpose>Returns the 2-dimensional longest line points of two geometries.
-               The function will only return the first longest line if more than one, that the function finds.
-               The line returned will always start in g1 and end in g2.
-               The length of the line this function returns will always be the same as st_maxdistance returns for g1 and g2.</refpurpose>
+               <refpurpose>Returns the 2D longest line between two geometries.
+               </refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
@@ -3776,9 +1219,12 @@ CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m)  as foo
          <refsection>
                <title>Description</title>
 
-               <para>Returns the 2-dimensional longest line between the points of two geometries.
+               <para>Returns the 2-D longest line between the points of two geometries.
+               </para>
+               <para>The function returns the first longest line if more than one is found.
+               The line returned starts on g1 and ends on g2.
+               The length of the line is equal to the distance returned by <xref linkend="ST_MaxDistance"/>.
                </para>
-
                <para>Availability: 1.5.0</para>
 
          </refsection>
@@ -3874,24 +1320,180 @@ FROM (SELECT ST_BuildArea(ST_Collect(the_geom)) As the_geom
          <refsection>
                <title>See Also</title>
 
-               <para><xref linkend="ST_MaxDistance"/>, <xref linkend="ST_ShortestLine"/>, <xref linkend="ST_LongestLine"/></para>
-         </refsection>
-       </refentry>
+               <para><xref linkend="ST_MaxDistance"/>, <xref linkend="ST_ShortestLine"/>, <xref linkend="ST_3DLongestLine"/></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_3DLongestLine">
+         <refnamediv>
+               <refname>ST_3DLongestLine</refname>
+
+               <refpurpose>Returns the 3D longest line between two geometries</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_3DLongestLine</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g1</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g2</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns the 3-dimensional longest line between two geometries. The function will
+               only return the first longest line if more than one.
+               The line returned will always start in g1 and end in g2.
+               The 3D length of the line this function returns will always be the same as <xref linkend="ST_3DMaxDistance" /> returns for g1 and g2.
+               </para>
+
+               <para>Availability: 2.0.0</para>
+               <para>Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
+               <para>&Z_support;</para>
+               <!-- Optionally mention supports Polyhedral Surface  -->
+               <para>&P_support;</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+                               <informaltable>
+                                         <tgroup cols="1">
+                                               <tbody>
+                                                 <row>
+                                                       <entry><para>linestring and point -- both 3d and 2d longest line
+                                       <programlisting>
+SELECT ST_AsEWKT(ST_3DLongestLine(line,pt)) AS lol3d_line_pt,
+               ST_AsEWKT(ST_LongestLine(line,pt)) As lol2d_line_pt
+       FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
+                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
+               ) As foo;
+
+
+           lol3d_line_pt           |       lol2d_line_pt
+-----------------------------------+----------------------------
+ LINESTRING(50 75 1000,100 100 30) | LINESTRING(98 190,100 100)
+                                       </programlisting>
+                                                         </para></entry>
+                                                   </row>
+                                                   <row>
+                                                       <entry><para>linestring and multipoint -- both 3d and 2d longest line
+                                       <programlisting>SELECT ST_AsEWKT(ST_3DLongestLine(line,pt)) AS lol3d_line_pt,
+               ST_AsEWKT(ST_LongestLine(line,pt)) As lol2d_line_pt
+       FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
+                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
+               ) As foo;
+
+
+          lol3d_line_pt          |      lol2d_line_pt
+---------------------------------+--------------------------
+ LINESTRING(98 190 1,50 74 1000) | LINESTRING(98 190,50 74)
+                                       </programlisting>
+                                                         </para></entry>
+                                                 </row>
+                                                 <row>
+                                                 <entry><para>Multilinestring and polygon both 3d and 2d longest line
+                                       <programlisting>SELECT ST_AsEWKT(ST_3DLongestLine(poly, mline)) As lol3d,
+    ST_AsEWKT(ST_LongestLine(poly, mline)) As lol2d
+        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
+                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
+                (1 10 2, 5 20 1))') As mline ) As foo;
+            lol3d             |          lol2d
+------------------------------+--------------------------
+ LINESTRING(175 150 5,1 10 2) | LINESTRING(175 150,1 10)
+             </programlisting>
+                                                         </para></entry>
+                                                 </row>
+                       </tbody>
+               </tgroup>
+       </informaltable>
+
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_3DDistance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_3DShortestLine"/>, <xref linkend="ST_3DMaxDistance"/></para>
+         </refsection>
+       </refentry>
+
+<refentry id="ST_MaxDistance">
+  <refnamediv>
+    <refname>ST_MaxDistance</refname>
+
+    <refpurpose>Returns the 2D largest distance between two geometries in
+               projected units.</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcprototype>
+        <funcdef>float <function>ST_MaxDistance</function></funcdef>
+        <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
+        <paramdef><type>geometry </type> <parameter>g2</parameter></paramdef>
+      </funcprototype>
+    </funcsynopsis>
+  </refsynopsisdiv>
+
+  <refsection>
+    <title>Description</title>
+
+    <!-- optionally mention that this function uses indexes if appropriate -->
+    <note>
+      <para>Returns the 2-dimensional maximum distance between two geometries in
+               projected units. If g1 and g2 is the same geometry the function will return the distance between
+               the two vertices most far from each other in that geometry.</para>
+    </note>
+
+       <para>Availability: 1.5.0</para>
+  </refsection>
+  <refsection>
+    <title>Examples</title>
+
+     <para>Basic furthest distance the point is to any part of the line</para>
+               <programlisting>postgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
+   st_maxdistance
+-----------------
+ 2
+(1 row)
+
+postgis=# SELECT ST_MaxDistance('POINT(0 0)'::geometry, 'LINESTRING ( 2 2, 2 2 )'::geometry);
+  st_maxdistance
+------------------
+ 2.82842712474619
+(1 row)</programlisting>
+  </refsection>
+
+  <!-- Optionally add a "See Also" section -->
+  <refsection>
+    <title>See Also</title>
+<para><xref linkend="ST_Distance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_DFullyWithin" /></para>
+  </refsection>
+</refentry>
 
-       <refentry id="ST_OrderingEquals">
+       <refentry id="ST_3DMaxDistance">
          <refnamediv>
-               <refname>ST_OrderingEquals</refname>
+               <refname>ST_3DMaxDistance</refname>
 
-               <refpurpose>Returns true if the given geometries represent the same geometry
-               and points are in the same directional order.</refpurpose>
+               <refpurpose>Returns the 3D cartesian maximum distance (based on spatial ref) between two geometries in
+               projected units.  </refpurpose>
          </refnamediv>
-
          <refsynopsisdiv>
                <funcsynopsis>
                  <funcprototype>
-                       <funcdef>boolean <function>ST_OrderingEquals</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>A</parameter></paramdef>
-                       <paramdef><type>geometry </type> <parameter>B</parameter></paramdef>
+                       <funcdef>float <function>ST_3DMaxDistance</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g1</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g2</parameter></paramdef>
                  </funcprototype>
                </funcsynopsis>
          </refsynopsisdiv>
@@ -3899,182 +1501,176 @@ FROM (SELECT ST_BuildArea(ST_Collect(the_geom)) As the_geom
          <refsection>
                <title>Description</title>
 
-               <para>ST_OrderingEquals compares two geometries and returns t (TRUE) if the
-                 geometries are equal and the coordinates are in the same order;
-                 otherwise it returns f (FALSE).</para>
+               <para>Returns the 3-dimensional maximum cartesian distance between two geometries in
+               projected units (spatial ref units). </para>
 
-               <note>
-                       <para>This function is implemented as per the ArcSDE SQL
-               specification rather than SQL-MM.
-               http://edndoc.esri.com/arcsde/9.1/sql_api/sqlapi3.htm#ST_OrderingEquals</para>
-               </note>
-               <para>&sqlmm_compliant; SQL-MM 3: 5.1.43</para>
+        <para>&Z_support;</para>
+        <!-- Optionally mention supports Polyhedral Surface  -->
+        <para>&P_support;</para>
+
+               <para>Availability: 2.0.0</para>
+               <para>Changed: 2.2.0 - In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
          </refsection>
 
          <refsection>
                <title>Examples</title>
 
-               <programlisting>SELECT ST_OrderingEquals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
-               ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
- st_orderingequals
------------
- f
-(1 row)
-
-SELECT ST_OrderingEquals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
-               ST_GeomFromText('LINESTRING(0 0, 0 0, 10 10)'));
- st_orderingequals
------------
- t
-(1 row)
+               <programlisting>
+-- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
+-- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
+SELECT ST_3DMaxDistance(
+                       ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 10000)'),2163),
+                       ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163)
+               ) As dist_3d,
+               ST_MaxDistance(
+                       ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 10000)'),2163),
+                       ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163)
+               ) As dist_2d;
 
-SELECT ST_OrderingEquals(ST_Reverse(ST_GeomFromText('LINESTRING(0 0, 10 10)')),
-               ST_GeomFromText('LINESTRING(0 0, 0 0, 10 10)'));
- st_orderingequals
------------
- f
-(1 row)
+     dist_3d      |     dist_2d
+------------------+------------------
+ 24383.7467488441 | 22247.8472107251
 </programlisting>
-                 </refsection>
-                 <refsection>
-                       <title>See Also</title>
-                       <para><xref linkend="ST_Equals"/>, <xref linkend="ST_Reverse"/></para>
-                 </refsection>
-       </refentry>
+         </refsection>
 
-       <refentry id="ST_Overlaps">
-         <refnamediv>
-               <refname>ST_Overlaps</refname>
+         <refsection>
+               <title>See Also</title>
 
-               <refpurpose>Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other.</refpurpose>
-         </refnamediv>
+               <para><xref linkend="ST_Distance"/>, <xref linkend="ST_3DDWithin"/>, <xref linkend="ST_3DMaxDistance" />, <xref linkend="ST_Transform" /></para>
+         </refsection>
+       </refentry>
 
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_Overlaps</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>A</parameter></paramdef>
-                       <paramdef><type>geometry </type> <parameter>B</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
+<refentry id="ST_MinimumClearance">
+               <refnamediv>
+                       <refname>ST_MinimumClearance</refname>
+                       <refpurpose>Returns the minimum clearance of a geometry, a measure of a geometry's robustness.</refpurpose>
+               </refnamediv>
+
+               <refsynopsisdiv>
+                       <funcsynopsis>
+                               <funcprototype>
+                                       <funcdef>float <function>ST_MinimumClearance</function></funcdef>
+                                       <paramdef><type>geometry </type><parameter>g</parameter></paramdef>
+                               </funcprototype>
+                       </funcsynopsis>
+               </refsynopsisdiv>
 
          <refsection>
                <title>Description</title>
 
-               <para>Returns TRUE if the Geometries "spatially
-                       overlap".  By that we mean they intersect, but one does not completely contain another. </para>
+               <para>
+                       It is not uncommon to have a geometry that, while meeting the criteria for validity according to ST_IsValid (polygons)
+                       or ST_IsSimple (lines), would become invalid if one of the vertices moved by a slight distance, as can happen during
+                       conversion to text-based formats (such as WKT, KML, GML GeoJSON), or binary formats that do not use double-precision
+                       floating point coordinates (MapInfo TAB).
+               </para>
 
-                <para>Performed by the GEOS module</para>
+               <para>
+                       A geometry's "minimum clearance" is the smallest distance by which a vertex of the geometry could be moved to produce
+                       an invalid geometry.  It can be thought of as a quantitative measure of a geometry's robustness, where increasing values
+                       of minimum clearance indicate increasing robustness.
+               </para>
 
-               <note><para>Do not call with a GeometryCollection as an argument</para></note>
+               <para>
+                       If a geometry has a minimum clearance of <varname>e</varname>, it can be said that:
+                       <itemizedlist>
+                               <listitem>
+                                       <para>
+                                               No two distinct vertices in the geometry are separated by less than <varname>e</varname>.
+                                       </para>
+                               </listitem>
+                               <listitem>
+                                       <para>
+                                               No vertex is closer than <varname>e</varname> to a line segement of which it is not an endpoint.
+                                       </para>
+                               </listitem>
+                       </itemizedlist>
+               </para>
 
-               <para>This function call will automatically include a bounding box
-               comparison that will make use of any indexes that are available on
-               the geometries. To avoid index use, use the function
-               _ST_Overlaps.</para>
+               <para>
+                       If no minimum clearance exists for a geometry (for example, a single point, or a multipoint whose points are identical), then
+                       ST_MinimumClearance will return Infinity.
+               </para>
 
-               <para>NOTE: this is the "allowable" version that returns a
-                       boolean, not an integer.</para>
+               <para>Availability: 2.3.0</para>
 
-               <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3</para>
-               <para>&sqlmm_compliant; SQL-MM 3: 5.1.32</para>
          </refsection>
 
          <refsection>
                <title>Examples</title>
-          <para>The following illustrations all return <varname>TRUE</varname>.</para>
-
-         <informaltable>
-               <tgroup cols="3">
-                 <tbody>
-                       <row>
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_overlaps01.png" />
-                                       </imageobject>
-                                       <caption><para><varname>MULTIPOINT</varname> / <varname>MULTIPOINT</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_overlaps02.png" />
-                                       </imageobject>
-                                       <caption><para><varname>LINESTRING</varname> / <varname>LINESTRING</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-                         <entry><para><informalfigure>
-                                 <mediaobject>
-                                       <imageobject>
-                                         <imagedata fileref="images/st_overlaps03.png" />
-                                       </imageobject>
-                                       <caption><para><varname>POLYGON</varname> / <varname>POLYGON</varname></para></caption>
-                                 </mediaobject>
-                               </informalfigure></para></entry>
-                       </row>
-                 </tbody>
-               </tgroup>
-         </informaltable>
-               <programlisting>--a point on a line is contained by the line and is of a lower dimension, and therefore does not overlap the line
-                       nor crosses
-
-SELECT ST_Overlaps(a,b) As a_overlap_b,
-       ST_Crosses(a,b) As a_crosses_b,
-               ST_Intersects(a, b) As a_intersects_b, ST_Contains(b,a) As b_contains_a
-FROM (SELECT ST_GeomFromText('POINT(1 0.5)') As a, ST_GeomFromText('LINESTRING(1 0, 1 1, 3 5)')  As b)
-       As foo
-
-a_overlap_b | a_crosses_b | a_intersects_b | b_contains_a
-------------+-------------+----------------+--------------
-f           | f           | t              | t
-
---a line that is partly contained by circle, but not fully is defined as intersecting and crossing,
--- but since of different dimension it does not overlap
-SELECT ST_Overlaps(a,b) As a_overlap_b, ST_Crosses(a,b) As a_crosses_b,
-       ST_Intersects(a, b) As a_intersects_b,
-       ST_Contains(a,b) As a_contains_b
-FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 0.5)'), 3)  As a, ST_GeomFromText('LINESTRING(1 0, 1 1, 3 5)')  As b)
-       As foo;
-
- a_overlap_b | a_crosses_b | a_intersects_b | a_contains_b
--------------+-------------+----------------+--------------
- f           | t           | t              | f
-
- -- a 2-dimensional bent hot dog (aka buffered line string) that intersects a circle,
- --    but is not fully contained by the circle is defined as overlapping since they are of the same dimension,
---     but it does not cross, because the intersection of the 2 is of the same dimension
---     as the maximum dimension of the 2
-
-SELECT ST_Overlaps(a,b) As a_overlap_b, ST_Crosses(a,b) As a_crosses_b, ST_Intersects(a, b) As a_intersects_b,
-ST_Contains(b,a) As b_contains_a,
-ST_Dimension(a) As dim_a, ST_Dimension(b) as dim_b, ST_Dimension(ST_Intersection(a,b)) As dima_intersection_b
-FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 0.5)'), 3)  As a,
-       ST_Buffer(ST_GeomFromText('LINESTRING(1 0, 1 1, 3 5)'),0.5)  As b)
-       As foo;
-
- a_overlap_b | a_crosses_b | a_intersects_b | b_contains_a | dim_a | dim_b | dima_intersection_b
--------------+-------------+----------------+--------------+-------+-------+---------------------
- t           | f           | t              | f            |     2 |     2 |              2
-</programlisting>
+               <programlisting>
+SELECT ST_MinimumClearance('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))');
+ st_minimumclearance
+---------------------
+             0.00032
+     </programlisting>
+
+         </refsection>
 
+         <refsection>
+               <title>See Also</title>
+
+               <para>
+                       <xref linkend="ST_MinimumClearanceLine" />
+               </para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_MinimumClearanceLine">
+               <refnamediv>
+                       <refname>ST_MinimumClearanceLine</refname>
+                       <refpurpose>Returns the two-point LineString spanning a geometry's minimum clearance.</refpurpose>
+               </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>Geometry <function>ST_MinimumClearanceLine</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g</parameter></paramdef>
+
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>
+                       Returns the two-point LineString spanning a geometry's minimum clearance.  If the geometry does not have a minimum
+                       clearance, <varname>LINESTRING EMPTY</varname> will be returned.
+               </para>
+               <para>Performed by the GEOS module.</para>
+               <para>Availability: 2.3.0 - requires GEOS &gt;= 3.6.0</para>
 
          </refsection>
 
+         <refsection>
+                 <title>Examples</title>
+                 <programlisting>
+SELECT ST_AsText(ST_MinimumClearanceLine('POLYGON ((0 0, 1 0, 1 1, 0.5 3.2e-4, 0 0))'));
+st_astext
+-------------------------------
+LINESTRING(0.5 0.00032,0.5 0)
+                 </programlisting>
+         </refsection>
+
          <refsection>
                <title>See Also</title>
 
-               <para><xref linkend="ST_Contains"/>, <xref linkend="ST_Crosses"/>, <xref linkend="ST_Dimension"/>, <xref linkend="ST_Intersects"/></para>
+               <para>
+                       <xref linkend="ST_MinimumClearance" />
+               </para>
          </refsection>
+
        </refentry>
+
        <refentry id="ST_Perimeter">
                <refnamediv>
                  <refname>ST_Perimeter</refname>
 
-                 <refpurpose>Return the length measurement of the boundary of an ST_Surface
-                 or ST_MultiSurface geometry or geography. (Polygon, MultiPolygon).  geometry measurement is in units of spatial reference and geography is in meters.</refpurpose>
+                 <refpurpose>Returns the length of the boundary of a polygonal geometry or geography.</refpurpose>
                </refnamediv>
                <refsynopsisdiv>
                  <funcsynopsis>
@@ -4175,8 +1771,8 @@ FROM ST_GeogFromText('MULTIPOLYGON(((-71.1044543107478 42.340674480411,-71.10445
          <refnamediv>
                <refname>ST_Perimeter2D</refname>
 
-               <refpurpose>Returns the 2-dimensional perimeter of the geometry, if it
-                       is a polygon or multi-polygon.  This is currently an alias for ST_Perimeter.</refpurpose>
+               <refpurpose>Returns the 2D perimeter of a polygonal geometry.
+               Alias for <varname>ST_Perimeter</varname>.</refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
@@ -4191,8 +1787,7 @@ FROM ST_GeogFromText('MULTIPOLYGON(((-71.1044543107478 42.340674480411,-71.10445
          <refsection>
                <title>Description</title>
 
-               <para>Returns the 2-dimensional perimeter of the geometry, if it
-                       is a polygon or multi-polygon. </para>
+               <para>Returns the 2-dimensional perimeter of a polygonal geometry. </para>
 
                <!-- optionally mention that this function uses indexes if appropriate -->
                <note>
@@ -4210,118 +1805,16 @@ FROM ST_GeogFromText('MULTIPOLYGON(((-71.1044543107478 42.340674480411,-71.10445
 
        <refentry id="ST_3DPerimeter">
          <refnamediv>
-               <refname>ST_3DPerimeter</refname>
-
-               <refpurpose>Returns the 3-dimensional perimeter of the geometry, if it
-                       is a polygon or multi-polygon.</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>float <function>ST_3DPerimeter</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns the 3-dimensional perimeter of the geometry, if it
-                       is a polygon or multi-polygon. If the geometry is 2-dimensional, then the 2-dimensional perimeter is returned.  </para>
-               <para>&Z_support;</para>
-               <para>Changed: 2.0.0 In prior versions this used to be called ST_Perimeter3D</para>
-         </refsection>
-
-
-         <refsection>
-               <title>Examples</title>
-               <para>Perimeter of a slightly elevated polygon in the air in Massachusetts state plane feet</para>
-               <programlisting>SELECT ST_3DPerimeter(the_geom), ST_Perimeter2d(the_geom), ST_Perimeter(the_geom) FROM
-                       (SELECT ST_GeomFromEWKT('SRID=2249;POLYGON((743238 2967416 2,743238 2967450 1,
-743265.625 2967416 1,743238 2967416 2))') As the_geom) As foo;
-
-  ST_3DPerimeter  |  st_perimeter2d  |   st_perimeter
-------------------+------------------+------------------
- 105.465793597674 | 105.432997272188 | 105.432997272188
-
-</programlisting>
-         </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_GeomFromEWKT" />, <xref linkend="ST_Perimeter" />, <xref linkend="ST_Perimeter2D" /></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_PointInsideCircle">
-         <refnamediv>
-               <refname>ST_PointInsideCircle</refname>
-
-               <refpurpose>Is the point geometry inside the circle defined by center_x, center_y, radius</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_PointInsideCircle</function></funcdef>
-                       <paramdef><type>geometry </type> <parameter>a_point</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>center_x</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>center_y</parameter></paramdef>
-                       <paramdef><type>float </type> <parameter>radius</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>The syntax for this functions is
-                       ST_PointInsideCircle(&lt;geometry&gt;,&lt;circle_center_x&gt;,&lt;circle_center_y&gt;,&lt;radius&gt;).
-                       Returns the true if the geometry is a point and is inside the
-                       circle. Returns false otherwise.</para>
-               <note><para>This only works for points as the name suggests</para></note>
-
-               <para>Availability: 1.2</para>
-               <para>Changed: 2.2.0 In prior versions this used to be called ST_Point_Inside_Circle</para>
-         </refsection>
-
-
-         <refsection>
-               <title>Examples</title>
-
-               <programlisting>SELECT ST_PointInsideCircle(ST_Point(1,2), 0.5, 2, 3);
- st_pointinsidecircle
-------------------------
- t
-</programlisting>
-         </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_DWithin" /></para>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_PointOnSurface">
-         <refnamediv>
-               <refname>ST_PointOnSurface</refname>
+               <refname>ST_3DPerimeter</refname>
 
-               <refpurpose>Returns a <varname>POINT</varname> guaranteed to lie on the surface.</refpurpose>
+               <refpurpose>Returns the 3D perimeter of a polygonal geometry.</refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
                <funcsynopsis>
                  <funcprototype>
-                       <funcdef>geometry <function>ST_PointOnSurface</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>g1</parameter></paramdef>
+                       <funcdef>float <function>ST_3DPerimeter</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
                  </funcprototype>
                </funcsynopsis>
          </refsynopsisdiv>
@@ -4329,48 +1822,32 @@ FROM ST_GeogFromText('MULTIPOLYGON(((-71.1044543107478 42.340674480411,-71.10445
          <refsection>
                <title>Description</title>
 
-               <para>Returns a <varname>POINT</varname> guaranteed to intersect a surface.</para>
-
-               <para>&sfs_compliant; s3.2.14.2 // s3.2.18.2</para>
-               <para>&sqlmm_compliant; SQL-MM 3: 8.1.5, 9.5.6.
-                According to the specs, ST_PointOnSurface works for surface geometries (POLYGONs, MULTIPOLYGONS, CURVED POLYGONS).  So PostGIS seems to be extending what
-                the spec allows here.  Most databases Oracle,DB II, ESRI SDE seem to only support this function for surfaces.  SQL Server 2008 like PostGIS supports for all common geometries.</para>
+               <para>Returns the 3-dimensional perimeter of the geometry, if it
+                       is a polygon or multi-polygon. If the geometry is 2-dimensional, then the 2-dimensional perimeter is returned.  </para>
                <para>&Z_support;</para>
+               <para>Changed: 2.0.0 In prior versions this used to be called ST_Perimeter3D</para>
          </refsection>
 
+
          <refsection>
                <title>Examples</title>
+               <para>Perimeter of a slightly elevated polygon in the air in Massachusetts state plane feet</para>
+               <programlisting>SELECT ST_3DPerimeter(the_geom), ST_Perimeter2d(the_geom), ST_Perimeter(the_geom) FROM
+                       (SELECT ST_GeomFromEWKT('SRID=2249;POLYGON((743238 2967416 2,743238 2967450 1,
+743265.625 2967416 1,743238 2967416 2))') As the_geom) As foo;
 
-               <programlisting>SELECT ST_AsText(ST_PointOnSurface('POINT(0 5)'::geometry));
- st_astext
-------------
- POINT(0 5)
-(1 row)
-
-SELECT ST_AsText(ST_PointOnSurface('LINESTRING(0 5, 0 10)'::geometry));
- st_astext
-------------
- POINT(0 5)
-(1 row)
-
-SELECT ST_AsText(ST_PointOnSurface('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'::geometry));
-   st_astext
-----------------
- POINT(2.5 2.5)
-(1 row)
+  ST_3DPerimeter  |  st_perimeter2d  |   st_perimeter
+------------------+------------------+------------------
+ 105.465793597674 | 105.432997272188 | 105.432997272188
 
-SELECT ST_AsEWKT(ST_PointOnSurface(ST_GeomFromEWKT('LINESTRING(0 5 1, 0 0 1, 0 10 2)')));
-   st_asewkt
-----------------
- POINT(0 0 1)
-(1 row)
 </programlisting>
          </refsection>
 
+         <!-- Optionally add a "See Also" section -->
          <refsection>
                <title>See Also</title>
 
-               <para><xref linkend="ST_Centroid" />, <xref linkend="ST_PointInsideCircle" /></para>
+               <para><xref linkend="ST_GeomFromEWKT" />, <xref linkend="ST_Perimeter" />, <xref linkend="ST_Perimeter2D" /></para>
          </refsection>
        </refentry>
 
@@ -4378,7 +1855,7 @@ SELECT ST_AsEWKT(ST_PointOnSurface(ST_GeomFromEWKT('LINESTRING(0 5 1, 0 0 1, 0 1
                  <refnamediv>
                        <refname>ST_Project</refname>
 
-                       <refpurpose>Returns a <varname>POINT</varname> projected from a start point using a distance in meters and bearing (azimuth) in radians.</refpurpose>
+                       <refpurpose>Returns a point projected from a start point by a distance and bearing (azimuth).</refpurpose>
                  </refnamediv>
 
                  <refsynopsisdiv>
@@ -4399,9 +1876,18 @@ SELECT ST_AsEWKT(ST_PointOnSurface(ST_GeomFromEWKT('LINESTRING(0 5 1, 0 0 1, 0 1
                  <refsection>
                        <title>Description</title>
 
-                       <para>Returns a <varname>POINT</varname> projected along a geodesic from a start point using an azimuth (bearing) measured in radians and distance measured in meters. This is also called a direct geodesic problem.</para>
-                       <para>The azimuth is sometimes called the heading or the bearing in navigation. It is measured relative to true north (azimuth zero). East is azimuth 90 (&#x03C0;/2), south is azimuth 180 (&#x03C0;), west is azimuth 270 (3&#x03C0;/2).</para>
-                       <para>The distance is given in meters.</para>
+                       <para>Returns a point projected from a start point along a geodesic using
+                       a given distance and azimuth (bearing).
+                       This is known as the direct geodesic problem.</para>
+                       <para>The distance is given in meters.  Negative values are supported.</para>
+                       <para>The azimuth (also known as heading or bearing) is given in radians.
+                       It is measured clockwise from true north (azimuth zero).
+                       East is azimuth &#x03C0;/2 (90 degrees);
+                       south is azimuth &#x03C0; (180 degrees);
+                       west is azimuth 3&#x03C0;/2 (270 degrees).
+                       Negative azimuth values and values greater than 2&#x03C0; (360 degrees) are supported.
+                       </para>
+
 
                        <para>Availability: 2.0.0</para>
                        <para>Enhanced: 2.4.0 Allow negative distance and non-normalized azimuth.</para>
@@ -4409,7 +1895,7 @@ SELECT ST_AsEWKT(ST_PointOnSurface(ST_GeomFromEWKT('LINESTRING(0 5 1, 0 0 1, 0 1
                  </refsection>
 
                  <refsection>
-                       <title>Example: Using degrees - projected point 100,000 meters and bearing 45 degrees </title>
+                       <title>Example: Projected point at 100,000 meters and bearing 45 degrees </title>
 
                        <programlisting>SELECT ST_AsText(ST_Project('POINT(0 0)'::geography, 100000, radians(45.0)));
 
@@ -4423,181 +1909,16 @@ SELECT ST_AsEWKT(ST_PointOnSurface(ST_GeomFromEWKT('LINESTRING(0 5 1, 0 0 1, 0 1
                  <refsection>
                        <title>See Also</title>
 
-                       <para><xref linkend="ST_Azimuth" />, <xref linkend="ST_Distance" />, <ulink url="http://www.postgresql.org/docs/current/interactive/functions-math.html">PostgreSQL Math Functions</ulink></para>
+                       <para><xref linkend="ST_Azimuth" />, <xref linkend="ST_Distance" />, <ulink url="http://www.postgresql.org/docs/current/interactive/functions-math.html">PostgreSQL function radians()</ulink></para>
                  </refsection>
        </refentry>
 
-       <refentry id="ST_Relate">
-               <refnamediv>
-                       <refname>ST_Relate</refname>
-
-                       <refpurpose>Returns true if this Geometry is spatially related to
-                                       anotherGeometry, by testing for intersections between the
-                                       Interior, Boundary and Exterior of the two geometries as specified
-                                       by the values in the intersectionMatrixPattern.  If no intersectionMatrixPattern
-                                       is passed in, then returns the maximum intersectionMatrixPattern that relates the 2 geometries.</refpurpose>
-               </refnamediv>
-
-               <refsynopsisdiv>
-                       <funcsynopsis>
-                         <funcprototype>
-                               <funcdef>boolean <function>ST_Relate</function></funcdef>
-                               <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
-                               <paramdef><type>geometry </type> <parameter>geomB</parameter></paramdef>
-                               <paramdef><type>text </type> <parameter>intersectionMatrixPattern</parameter></paramdef>
-                         </funcprototype>
-
-                         <funcprototype>
-                               <funcdef>text <function>ST_Relate</function></funcdef>
-                               <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
-                               <paramdef><type>geometry </type> <parameter>geomB</parameter></paramdef>
-                         </funcprototype>
-
-                         <funcprototype>
-                               <funcdef>text <function>ST_Relate</function></funcdef>
-                               <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
-                               <paramdef><type>geometry </type> <parameter>geomB</parameter></paramdef>
-                               <paramdef><type>integer </type> <parameter>BoundaryNodeRule</parameter></paramdef>
-                         </funcprototype>
-                       </funcsynopsis>
-               </refsynopsisdiv>
-
-               <refsection>
-                       <title>Description</title>
-
-                       <para>Version 1: Takes geomA, geomB, intersectionMatrix and Returns 1 (TRUE) if this Geometry is spatially related to
-                                       anotherGeometry, by testing for intersections between the
-                                       Interior, Boundary and Exterior of the two geometries as specified
-                                       by the values in the <ulink url="http://en.wikipedia.org/wiki/DE-9IM">DE-9IM matrix pattern</ulink>.</para>
-
-                       <para>This is especially useful for testing compound checks of intersection, crosses, etc in one step.</para>
-                       <para>Do not call with a GeometryCollection as an argument</para>
-
-                       <note><para>This is the "allowable" version that returns a
-                       boolean, not an integer.  This is defined in OGC spec</para></note>
-
-                       <note><para>This DOES NOT automagically include an index call.  The reason for that
-                               is some relationships are anti e.g. Disjoint.  If you are
-                               using a relationship pattern that requires intersection, then include the &amp;&amp;
-                               index call.</para></note>
-
-                       <para>Version 2: Takes geomA and geomB and returns the <xref linkend="DE-9IM" /></para>
-
-                       <para>Version 3: same as version 2, but allows to specify a boundary node rule (1:OGC/MOD2, 2:Endpoint, 3:MultivalentEndpoint, 4:MonovalentEndpoint)</para>
-
-                       <note><para>Do not call with a GeometryCollection as an argument</para></note>
-
-                       <para>not in OGC spec, but implied. see s2.1.13.2</para>
-                       <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3</para>
-                       <para>&sqlmm_compliant; SQL-MM 3: 5.1.25</para>
-                       <para>Performed by the GEOS module</para>
-                       <para>Enhanced: 2.0.0 - added support for specifying boundary node rule.</para>
-               </refsection>
-
-
-               <refsection>
-               <title>Examples</title>
-               <programlisting>
---Find all compounds that intersect and not touch a poly (interior intersects)
-SELECT l.* , b.name As poly_name
-       FROM polys As b
-INNER JOIN compounds As l
-ON (p.the_geom &amp;&amp; b.the_geom
-AND ST_Relate(l.the_geom, b.the_geom,'T********'));
-
-SELECT ST_Relate(ST_GeometryFromText('POINT(1 2)'), ST_Buffer(ST_GeometryFromText('POINT(1 2)'),2));
-st_relate
------------
-0FFFFF212
-
-SELECT ST_Relate(ST_GeometryFromText('LINESTRING(1 2, 3 4)'), ST_GeometryFromText('LINESTRING(5 6, 7 8)'));
-st_relate
------------
-FF1FF0102
-
-
-SELECT ST_Relate(ST_GeometryFromText('POINT(1 2)'), ST_Buffer(ST_GeometryFromText('POINT(1 2)'),2), '0FFFFF212');
-st_relate
------------
-t
-
-SELECT ST_Relate(ST_GeometryFromText('POINT(1 2)'), ST_Buffer(ST_GeometryFromText('POINT(1 2)'),2), '*FF*FF212');
-st_relate
------------
-t
-               </programlisting>
-       </refsection>
-
-       <!-- Optionally add a "See Also" section -->
-       <refsection>
-               <title>See Also</title>
-
-               <para><xref linkend="ST_Crosses" />, <xref linkend="DE-9IM" />, <xref linkend="ST_Disjoint" />, <xref linkend="ST_Intersects" />, <xref linkend="ST_Touches" /></para>
-       </refsection>
-</refentry>
-
-<refentry id="ST_RelateMatch">
-       <refnamediv>
-               <refname>ST_RelateMatch</refname>
-
-               <refpurpose>Returns true if intersectionMattrixPattern1 implies intersectionMatrixPattern2</refpurpose>
-       </refnamediv>
-
-       <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_RelateMatch</function></funcdef>
-                       <paramdef><type>text </type> <parameter>intersectionMatrix</parameter></paramdef>
-                       <paramdef><type>text </type> <parameter>intersectionMatrixPattern</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-       </refsynopsisdiv>
-
-       <refsection>
-               <title>Description</title>
-
-               <para> Takes intersectionMatrix and intersectionMatrixPattern and Returns true if the intersectionMatrix satisfies
-               the intersectionMatrixPattern. For more information refer to <xref linkend="DE-9IM" />. </para>
-               <para>Performed by the GEOS module</para>
-               <para>Availability: 2.0.0</para>
-       </refsection>
-
-
-       <refsection>
-               <title>Examples</title>
-               <programlisting>
-SELECT ST_RelateMatch('101202FFF', 'TTTTTTFFF') ;
--- result --
-t
---example of common intersection matrix patterns and example matrices
--- comparing relationships of involving one invalid geometry and ( a line and polygon that intersect at interior and boundary)
-SELECT mat.name, pat.name, ST_RelateMatch(mat.val, pat.val) As satisfied
-    FROM
-        ( VALUES ('Equality', 'T1FF1FFF1'),
-                ('Overlaps', 'T*T***T**'),
-                ('Within', 'T*F**F***'),
-                ('Disjoint', 'FF*FF****') As pat(name,val)
-        CROSS JOIN
-            (  VALUES ('Self intersections (invalid)', '111111111'),
-                    ('IE2_BI1_BB0_BE1_EI1_EE2', 'FF2101102'),
-                    ('IB1_IE1_BB0_BE0_EI2_EI1_EE2', 'F11F00212')
-            ) As mat(name,val);
-
-               </programlisting>
-       </refsection>
-
-       <!-- Optionally add a "See Also" section -->
-       <refsection>
-               <title>See Also</title>
-               <para><xref linkend="DE-9IM" />, <xref linkend="ST_Relate" /></para>
-       </refsection>
-</refentry>
 
 <refentry id="ST_ShortestLine">
          <refnamediv>
                <refname>ST_ShortestLine</refname>
 
-               <refpurpose>Returns the 2-dimensional shortest line between two geometries</refpurpose>
+               <refpurpose>Returns the 2D shortest line between two geometries</refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
@@ -4689,19 +2010,17 @@ SELECT ST_AsText(
                <para><xref linkend="ST_ClosestPoint"/>, <xref linkend="ST_Distance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_MaxDistance"/></para>
          </refsection>
        </refentry>
-
-       <refentry id="ST_Touches">
+       <refentry id="ST_3DShortestLine">
          <refnamediv>
-               <refname>ST_Touches</refname>
+               <refname>ST_3DShortestLine</refname>
 
-               <refpurpose>Returns <varname>TRUE</varname> if the geometries have at least one point in common,
-               but their interiors do not intersect.</refpurpose>
+               <refpurpose>Returns the 3D shortest line between two geometries</refpurpose>
          </refnamediv>
 
          <refsynopsisdiv>
                <funcsynopsis>
                  <funcprototype>
-                       <funcdef>boolean <function>ST_Touches</function></funcdef>
+                       <funcdef>geometry <function>ST_3DShortestLine</function></funcdef>
 
                        <paramdef><type>geometry </type>
                        <parameter>g1</parameter></paramdef>
@@ -4715,228 +2034,85 @@ SELECT ST_AsText(
          <refsection>
                <title>Description</title>
 
-               <para>Returns <varname>TRUE</varname> if the only points in common between
-               <parameter>g1</parameter> and <parameter>g2</parameter> lie in the union of the
-               boundaries of <parameter>g1</parameter> and <parameter>g2</parameter>.
-               The <function>ST_Touches</function> relation applies
-               to all Area/Area, Line/Line, Line/Area, Point/Area and Point/Line pairs of relationships,
-               but <emphasis>not</emphasis> to the Point/Point pair.</para>
-
-               <para>In mathematical terms, this predicate is expressed as:</para>
-
-               <informalfigure>
-                 <mediaobject>
-                       <imageobject>
-                         <imagedata fileref="images/st_touches-math.gif" />
-                       </imageobject>
-                 </mediaobject>
-               </informalfigure>
-
-               <para>The allowable DE-9IM Intersection Matrices for the two geometries are:</para>
-
-               <itemizedlist>
-                 <listitem>
-                       <para><markup>FT*******</markup></para>
-                 </listitem>
-
-                 <listitem>
-                       <para><markup>F**T*****</markup></para>
-                 </listitem>
-
-                 <listitem>
-                       <para><markup>F***T****</markup></para>
-                 </listitem>
-               </itemizedlist>
-
-               <important>
-                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
-               </important>
-
-               <note>
-                 <para>This function call will automatically include a bounding box
-                 comparison that will make use of any indexes that are available on
-                 the geometries.  To avoid using an index, use <function>_ST_Touches</function> instead.</para>
-               </note>
+               <para>Returns the 3-dimensional shortest line between two geometries. The function will
+               only return the first shortest line if more than one, that the function finds.
+               If g1 and g2 intersects in just one point the function will return a line with both start
+               and end in that intersection-point.
+               If g1 and g2 are intersecting with more than one point the function will return a line with start
+               and end in the same point but it can be any of the intersecting points.
+               The line returned will always start in g1 and end in g2.
+               The 3D length of the line this function returns will always be the same as <xref linkend="ST_3DDistance" /> returns for g1 and g2.
+               </para>
 
-               <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3</para>
-               <para>&sqlmm_compliant; SQL-MM 3: 5.1.28</para>
+               <para>Availability: 2.0.0</para>
+               <para>Changed: 2.2.0 - if 2 2D geometries are input, a 2D point is returned (instead of old behavior assuming 0 for missing Z). In case of 2D and 3D, Z is no longer assumed to be 0 for missing Z.</para>
+               <para>&Z_support;</para>
+               <!-- Optionally mention supports Polyhedral Surface  -->
+               <para>&P_support;</para>
          </refsection>
 
          <refsection>
                <title>Examples</title>
+                               <informaltable>
+                                         <tgroup cols="1">
+                                               <tbody>
+                                                 <row>
+                                                       <entry><para>linestring and point -- both 3d and 2d shortest line
+                                       <programlisting>
+SELECT ST_AsEWKT(ST_3DShortestLine(line,pt)) AS shl3d_line_pt,
+               ST_AsEWKT(ST_ShortestLine(line,pt)) As shl2d_line_pt
+       FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
+                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
+               ) As foo;
 
-               <para>The <function>ST_Touches</function> predicate returns <varname>TRUE</varname> in all the following illustrations.</para>
-               <informaltable>
-                 <tgroup cols="3">
-                       <tbody>
-                         <row>
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_touches01.png" />
-                                         </imageobject>
-
-                                         <caption><para><varname>POLYGON</varname> / <varname>POLYGON</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
-
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_touches02.png" />
-                                         </imageobject>
-
-                                         <caption><para><varname>POLYGON</varname> / <varname>POLYGON</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
-
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_touches03.png" />
-                                         </imageobject>
-
-                                         <caption><para><varname>POLYGON</varname> / <varname>LINESTRING</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
-                         </row>
-                         <row>
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_touches04.png" />
-                                         </imageobject>
-
-                                         <caption><para><varname>LINESTRING</varname> / <varname>LINESTRING</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
-
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_touches05.png" />
-                                         </imageobject>
 
-                                         <caption><para><varname>LINESTRING</varname> / <varname>LINESTRING</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
+ shl3d_line_pt                                                          |               shl2d_line_pt
+----------------------------------------------------------------------------+------------------------------------------------------
+ LINESTRING(54.6993798867619 128.935022917228 11.5475869506606,100 100 30)  | LINESTRING(73.0769230769231 115.384615384615,100 100)
+                                       </programlisting>
+                                                         </para></entry>
+                                                   </row>
+                                                   <row>
+                                                       <entry><para>linestring and multipoint -- both 3d and 2d shortest line
+                                       <programlisting>SELECT ST_AsEWKT(ST_3DShortestLine(line,pt)) AS shl3d_line_pt,
+               ST_AsEWKT(ST_ShortestLine(line,pt)) As shl2d_line_pt
+       FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
+                       'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
+               ) As foo;
 
-                               <entry><para><informalfigure>
-                                       <mediaobject>
-                                         <imageobject>
-                                               <imagedata fileref="images/st_touches06.png" />
-                                         </imageobject>
 
-                                         <caption><para><varname>POLYGON</varname> / <varname>POINT</varname></para></caption>
-                                       </mediaobject>
-                                 </informalfigure></para></entry>
-                         </row>
+                       shl3d_line_pt                                       | shl2d_line_pt
+---------------------------------------------------------------------------+------------------------
+ LINESTRING(54.6993798867619 128.935022917228 11.5475869506606,100 100 30) | LINESTRING(50 75,50 74)
+                                       </programlisting>
+                                                         </para></entry>
+                                                 </row>
+                                                 <row>
+                                                 <entry><para>Multilinestring and polygon both 3d and 2d shortest line
+                                       <programlisting>SELECT ST_AsEWKT(ST_3DShortestLine(poly, mline)) As shl3d,
+    ST_AsEWKT(ST_ShortestLine(poly, mline)) As shl2d
+        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
+                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
+                (1 10 2, 5 20 1))') As mline ) As foo;
+                   shl3d                                                                           |     shl2d
+---------------------------------------------------------------------------------------------------+------------------------
+ LINESTRING(39.993580415989 54.1889925532825 5,40.4078575708294 53.6052383805529 5.03423778139177) | LINESTRING(20 40,20 40)
+             </programlisting>
+                                                         </para></entry>
+                                                 </row>
                        </tbody>
-                 </tgroup>
-               </informaltable>
-
-               <programlisting>SELECT ST_Touches('LINESTRING(0 0, 1 1, 0 2)'::geometry, 'POINT(1 1)'::geometry);
- st_touches
-------------
- f
-(1 row)
-
-SELECT ST_Touches('LINESTRING(0 0, 1 1, 0 2)'::geometry, 'POINT(0 2)'::geometry);
- st_touches
-------------
- t
-(1 row)</programlisting>
-         </refsection>
-       </refentry>
-
-       <refentry id="ST_Within">
-         <refnamediv>
-               <refname>ST_Within</refname>
-
-               <refpurpose>Returns true if the geometry A is completely inside geometry B</refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>boolean <function>ST_Within</function></funcdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>A</parameter></paramdef>
-
-                       <paramdef><type>geometry </type>
-                       <parameter>B</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-
-               <para>Returns TRUE if geometry A is completely inside geometry B. For this function to make
-               sense, the source geometries must both be of the same coordinate projection,
-               having the same SRID.  It is a given that if ST_Within(A,B) is true and ST_Within(B,A) is true, then
-               the two geometries are considered spatially equal.</para>
-
-               <para>Performed by the GEOS module</para>
-
-               <para>Enhanced: 2.3.0 Enhancement to PIP short-circuit for geometry extended to support MultiPoints with few points. Prior versions only supported point in polygon.</para>
-
-               <important>
-                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
-               </important>
-
-               <important>
-                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
-               </important>
-
-               <para>This function call will automatically include a bounding box
-                       comparison that will make use of any indexes that are available on
-                       the geometries. To avoid index use, use the function
-                       _ST_Within.</para>
-
-               <para>NOTE: this is the "allowable" version that returns a
-                       boolean, not an integer.</para>
-
-               <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3
-                 - a.Relate(b, 'T*F**F***')
-               </para>
-               <para>&sqlmm_compliant; SQL-MM 3: 5.1.30</para>
-         </refsection>
-
-         <refsection>
-               <title>Examples</title>
-                 <programlisting>
---a circle within a circle
-SELECT ST_Within(smallc,smallc) As smallinsmall,
-       ST_Within(smallc, bigc) As smallinbig,
-       ST_Within(bigc,smallc) As biginsmall,
-       ST_Within(ST_Union(smallc, bigc), bigc) as unioninbig,
-       ST_Within(bigc, ST_Union(smallc, bigc)) as biginunion,
-       ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion
-FROM
-(
-SELECT ST_Buffer(ST_GeomFromText('POINT(50 50)'), 20) As smallc,
-       ST_Buffer(ST_GeomFromText('POINT(50 50)'), 40) As bigc) As foo;
---Result
- smallinsmall | smallinbig | biginsmall | unioninbig | biginunion | bigisunion
---------------+------------+------------+------------+------------+------------
- t            | t          | f          | t          | t          | t
-(1 row)
-               </programlisting>
+               </tgroup>
+       </informaltable>
 
-               <para><inlinemediaobject>
-               <imageobject>
-                 <imagedata fileref="images/st_within01.png" />
-               </imageobject>
-         </inlinemediaobject> </para>
          </refsection>
 
          <refsection>
                <title>See Also</title>
-               <para><xref linkend="ST_Contains"/>, <xref linkend="ST_Equals"/>, <xref linkend="ST_IsValid"/></para>
+
+               <para><xref linkend="ST_3DClosestPoint"/>, <xref linkend="ST_3DDistance"/>, <xref linkend="ST_LongestLine"/>, <xref linkend="ST_ShortestLine"/>, <xref linkend="ST_3DMaxDistance"/></para>
          </refsection>
        </refentry>
 
 
+
 </sect1>
index faa7451d4dd93cf1eda42b109e2efe0ad4b48b6d..ea7a4e0d835e96c64a24863a04fdfc2b1596f367 100644 (file)
@@ -520,6 +520,150 @@ FROM (SELECT ST_Buffer(
                  </refsection>
        </refentry>
 
+  <refentry id="ST_Centroid">
+       <refnamediv>
+         <refname>ST_Centroid</refname>
+
+         <refpurpose>Returns the geometric center of a geometry.</refpurpose>
+       </refnamediv>
+
+       <refsynopsisdiv>
+         <funcsynopsis>
+          <funcprototype>
+                 <funcdef>geometry <function>ST_Centroid</function></funcdef>
+
+                 <paramdef><type>geometry </type>
+                 <parameter>g1</parameter></paramdef>
+               </funcprototype>
+            <funcprototype>
+                <funcdef>geography <function>ST_Centroid</function></funcdef>
+
+                <paramdef><type>geography </type>
+                <parameter>g1</parameter></paramdef>
+                <paramdef choice="opt"><type>boolean </type>
+                <parameter>use_spheroid=true</parameter></paramdef>
+       </funcprototype>
+
+         </funcsynopsis>
+       </refsynopsisdiv>
+
+       <refsection>
+         <title>Description</title>
+
+         <para>Computes the geometric center of a geometry, or equivalently,
+         the center of mass of the geometry as a <varname>POINT</varname>. For
+         [<varname>MULTI</varname>]<varname>POINT</varname>s, this is computed
+         as the arithmetic mean of the input coordinates. For
+         [<varname>MULTI</varname>]<varname>LINESTRING</varname>s, this is
+         computed as the weighted length of each line segment. For
+         [<varname>MULTI</varname>]<varname>POLYGON</varname>s, "weight" is
+         thought in terms of area. If an empty geometry is supplied, an empty
+         <varname>GEOMETRYCOLLECTION</varname> is returned. If
+         <varname>NULL</varname> is supplied, <varname>NULL</varname> is
+         returned.
+         If <varname>CIRCULARSTRING</varname> or <varname>COMPOUNDCURVE</varname>
+         are supplied, they are converted to linestring wtih CurveToLine first,
+         then same than for  <varname>LINESTRING</varname>
+         </para>
+         <para>New in 2.3.0 : support <varname>CIRCULARSTRING</varname> and <varname>COMPOUNDCURVE</varname> (using CurveToLine)</para>
+
+      <para>Availability: 2.4.0 support for geography was introduced.</para>
+
+         <para>The centroid is equal to the centroid of the set of component
+         Geometries of highest dimension (since the lower-dimension geometries
+         contribute zero "weight" to the centroid).</para>
+
+         <para>&sfs_compliant;</para>
+         <para>&sqlmm_compliant; SQL-MM 3: 8.1.4, 9.5.5</para>
+       </refsection>
+
+       <refsection>
+         <title>Examples</title>
+
+         <para>In each of the following illustrations, the green dot represents
+         the centroid of the source geometry.</para>
+
+         <informaltable>
+               <tgroup cols="2">
+                 <tbody>
+                       <row>
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_centroid01.png" />
+                                       </imageobject>
+
+                                       <caption><para>Centroid of a
+                                       <varname>MULTIPOINT</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_centroid02.png" />
+                                       </imageobject>
+
+                                       <caption><para>Centroid of a
+                                       <varname>LINESTRING</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+                       </row>
+
+                       <row>
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_centroid03.png" />
+                                       </imageobject>
+
+                                       <caption><para>Centroid of a
+                                       <varname>POLYGON</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_centroid04.png" />
+                                       </imageobject>
+
+                                       <caption><para>Centroid of a
+                                       <varname>GEOMETRYCOLLECTION</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+                       </row>
+                 </tbody>
+               </tgroup>
+         </informaltable>
+
+         <programlisting>SELECT ST_AsText(ST_Centroid('MULTIPOINT ( -1 0, -1 2, -1 3, -1 4, -1 7, 0 1, 0 3, 1 1, 2 0, 6 0, 7 8, 9 8, 10 6 )'));
+                               st_astext
+------------------------------------------
+ POINT(2.30769230769231 3.30769230769231)
+(1 row)
+
+SELECT ST_AsText(ST_centroid(g))
+FROM  ST_GeomFromText('CIRCULARSTRING(0 2, -1 1,0 0, 0.5 0, 1 0, 2 1, 1 2, 0.5 2, 0 2)')  AS g ;
+------------------------------------------
+POINT(0.5 1)
+
+
+SELECT ST_AsText(ST_centroid(g))
+FROM  ST_GeomFromText('COMPOUNDCURVE(CIRCULARSTRING(0 2, -1 1,0 0),(0 0, 0.5 0, 1 0),CIRCULARSTRING( 1 0, 2 1, 1 2),(1 2, 0.5 2, 0 2))' ) AS g;
+------------------------------------------
+POINT(0.5 1)
+
+</programlisting>
+       </refsection>
+
+       <refsection>
+         <title>See Also</title>
+
+         <para><xref linkend="ST_PointOnSurface" />, <xref linkend="ST_GeometricMedian" /></para>
+       </refsection>
+  </refentry>
+
        <refentry id="ST_ClipByBox2D">
          <refnamediv>
                <refname>ST_ClipByBox2D</refname>
@@ -1902,6 +2046,133 @@ FROM (
                </refsection>
        </refentry>
 
+       <refentry id="ST_GeometricMedian">
+         <refnamediv>
+                 <refname>
+                         ST_GeometricMedian
+                 </refname>
+
+               <refpurpose>
+                       Returns the geometric median of a MultiPoint.
+               </refpurpose>
+         </refnamediv>
+
+       <refsynopsisdiv>
+         <funcsynopsis>
+               <funcprototype>
+                       <funcdef>geometry
+                               <function>
+                                       ST_GeometricMedian
+                               </function>
+                       </funcdef>
+
+                       <paramdef>
+                               <type>
+                                       geometry
+                               </type>
+                               <parameter>
+                                       g
+                               </parameter>
+                       </paramdef>
+
+                       <paramdef>
+                               <type>
+                                       float8
+                               </type>
+                               <parameter>
+                                       tolerance
+                               </parameter>
+                       </paramdef>
+
+                       <paramdef>
+                               <type>
+                                       int
+                               </type>
+                               <parameter>
+                                       max_iter
+                               </parameter>
+                       </paramdef>
+
+                       <paramdef>
+                               <type>
+                                       boolean
+                               </type>
+                               <parameter>
+                                       fail_if_not_converged
+                               </parameter>
+                       </paramdef>
+
+               </funcprototype>
+         </funcsynopsis>
+       </refsynopsisdiv>
+
+       <refsection>
+         <title>Description</title>
+
+       <para>
+                 Computes the approximate geometric median of a MultiPoint geometry
+                 using the Weiszfeld algorithm.  The geometric median provides a
+                 centrality measure that is less sensitive to outlier points than
+                 the centroid.
+       </para>
+       <para>
+                 The algorithm will iterate until the distance change between
+                 successive iterations is less than the supplied <varname>tolerance</varname>
+                 parameter.  If this condition has not been met after <varname>max_iterations</varname>
+                 iterations, the function will produce an error and exit, unless <varname>fail_if_not_converged</varname>
+                 is set to false.
+       </para>
+       <para>
+                 If a <varname>tolerance</varname> value is not provided, a default tolerance value
+                 will be calculated based on the extent of the input geometry.
+       </para>
+       <para>
+                 M value of points, if present, is interpreted as their relative weight.
+       </para>
+       <para>Availability: 2.3.0</para>
+       <para>Enhanced: 2.5.0 Added support for M as weight of points.</para>
+       <para>&Z_support;</para>
+       <para>&M_support;</para>
+    </refsection>
+    <refsection>
+      <title>Examples</title>
+         <para>
+                 <informalfigure>
+                         <mediaobject>
+                                       <imageobject>
+                                               <imagedata fileref="images/st_geometricmedian01.png" />
+                                       </imageobject>
+
+                                       <caption>
+                                               <para>
+                                               Comparison of the centroid (turquoise point) and geometric
+                                               median (red point) of a four-point MultiPoint (yellow points).
+                                               </para>
+                                       </caption>
+                         </mediaobject>
+               </informalfigure>
+         </para>
+         <programlisting>
+WITH test AS (
+SELECT 'MULTIPOINT((0 0), (1 1), (2 2), (200 200))'::geometry geom)
+SELECT
+  ST_AsText(ST_Centroid(geom)) centroid,
+  ST_AsText(ST_GeometricMedian(geom)) median
+FROM test;
+      centroid      |                 median
+--------------------+----------------------------------------
+ POINT(50.75 50.75) | POINT(1.9761550281255 1.9761550281255)
+(1 row)
+         </programlisting>
+       </refsection>
+
+       <refsection>
+         <title>See Also</title>
+
+         <para><xref linkend="ST_Centroid"/></para>
+       </refsection>
+
+       </refentry>
 
        <refentry id="ST_Intersection">
                <refnamediv>
@@ -2756,6 +3027,72 @@ MULTILINESTRING((164 1,11.7867965644036 1,1 11.7867965644036,1 195),
                          </refsection>
        </refentry>
 
+       <refentry id="ST_PointOnSurface">
+         <refnamediv>
+               <refname>ST_PointOnSurface</refname>
+
+               <refpurpose>Returns a <varname>POINT</varname> guaranteed to lie on the surface.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_PointOnSurface</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g1</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns a <varname>POINT</varname> guaranteed to intersect a surface.</para>
+
+               <para>&sfs_compliant; s3.2.14.2 // s3.2.18.2</para>
+               <para>&sqlmm_compliant; SQL-MM 3: 8.1.5, 9.5.6.
+                According to the specs, ST_PointOnSurface works for surface geometries (POLYGONs, MULTIPOLYGONS, CURVED POLYGONS).  So PostGIS seems to be extending what
+                the spec allows here.  Most databases Oracle,DB II, ESRI SDE seem to only support this function for surfaces.  SQL Server 2008 like PostGIS supports for all common geometries.</para>
+               <para>&Z_support;</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>SELECT ST_AsText(ST_PointOnSurface('POINT(0 5)'::geometry));
+ st_astext
+------------
+ POINT(0 5)
+(1 row)
+
+SELECT ST_AsText(ST_PointOnSurface('LINESTRING(0 5, 0 10)'::geometry));
+ st_astext
+------------
+ POINT(0 5)
+(1 row)
+
+SELECT ST_AsText(ST_PointOnSurface('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'::geometry));
+   st_astext
+----------------
+ POINT(2.5 2.5)
+(1 row)
+
+SELECT ST_AsEWKT(ST_PointOnSurface(ST_GeomFromEWKT('LINESTRING(0 5 1, 0 0 1, 0 10 2)')));
+   st_asewkt
+----------------
+ POINT(0 0 1)
+(1 row)
+</programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Centroid" />, <xref linkend="ST_PointInsideCircle" /></para>
+         </refsection>
+       </refentry>
+
        <refentry id="ST_RemoveRepeatedPoints">
          <refnamediv>
                <refname>ST_RemoveRepeatedPoints</refname>
@@ -3747,67 +4084,6 @@ LINESTRING(44.7994523421035 82.5156766227011,85 85)</screen>
          </refsection>
        </refentry>
 
-       <refentry id="ST_SwapOrdinates">
-         <refnamediv>
-               <refname>ST_SwapOrdinates</refname>
-               <refpurpose>Returns a version of the given geometry with
-                               given ordinate values swapped.
-    </refpurpose>
-         </refnamediv>
-
-         <refsynopsisdiv>
-               <funcsynopsis>
-                 <funcprototype>
-                       <funcdef>geometry <function>ST_SwapOrdinates</function></funcdef>
-                       <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
-                       <paramdef><type>cstring</type> <parameter>ords</parameter></paramdef>
-                 </funcprototype>
-               </funcsynopsis>
-         </refsynopsisdiv>
-
-         <refsection>
-               <title>Description</title>
-               <para>
-Returns a version of the given geometry with given ordinates swapped.
-    </para>
-               <para>
-The <varname>ords</varname> parameter is a 2-characters string naming
-the ordinates to swap. Valid names are: x,y,z and m.
-    </para>
-               <para>Availability: 2.2.0</para>
-               <para>&curve_support;</para>
-               <para>&Z_support;</para>
-               <para>&M_support;</para>
-               <para>&P_support;</para>
-               <para>&T_support;</para>
-         </refsection>
-
-         <refsection>
-               <title>Example</title>
-               <programlisting><![CDATA[
--- Scale M value by 2
-SELECT ST_AsText(
-  ST_SwapOrdinates(
-    ST_Scale(
-      ST_SwapOrdinates(g,'xm'),
-      2, 1
-    ),
-  'xm')
-) FROM ( SELECT 'POINT ZM (0 0 0 2)'::geometry g ) foo;
-     st_astext
---------------------
- POINT ZM (0 0 0 4)
-                ]]></programlisting>
-         </refsection>
-
-         <!-- Optionally add a "See Also" section -->
-         <refsection>
-               <title>See Also</title>
-               <para> <xref linkend="ST_FlipCoordinates" /> </para>
-         </refsection>
-
-       </refentry>
-
 <refentry id="ST_Union">
   <refnamediv>
        <refname>ST_Union</refname>
diff --git a/doc/reference_relationship.xml b/doc/reference_relationship.xml
new file mode 100644 (file)
index 0000000..759a441
--- /dev/null
@@ -0,0 +1,2114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <sect1 id="Spatial_Relationships">
+    <sect1info>
+    <abstract>
+    <para>These functions determine spatial relationships between geometries.</para>
+    </abstract>
+    </sect1info>
+       <title>Spatial Relationships</title>
+
+       <refentry id="ST_3DDWithin">
+         <refnamediv>
+               <refname>ST_3DDWithin</refname>
+
+               <refpurpose>For 3d (z) geometry type Returns true if two geometries 3d distance is within number of units. </refpurpose>
+         </refnamediv>
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_3DDWithin</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g1</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g2</parameter></paramdef>
+
+                       <paramdef><type>double precision </type>
+                       <parameter>distance_of_srid</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>For geometry type returns true if the 3d distance between two objects is within distance_of_srid specified
+               projected units (spatial ref units). </para>
+
+        <para>&Z_support;</para>
+        <!-- Optionally mention supports Polyhedral Surface  -->
+        <para>&P_support;</para>
+               <para>&sqlmm_compliant; SQL-MM ?</para>
+
+               <para>Availability: 2.0.0</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>
+-- Geometry example - units in meters (SRID: 2163 US National Atlas Equal area) (3D point and line compared 2D point and line)
+-- Note: currently no vertical datum support so Z is not transformed and assumed to be same units as final.
+SELECT ST_3DDWithin(
+                       ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 4)'),2163),
+                       ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163),
+                       126.8
+               ) As within_dist_3d,
+ST_DWithin(
+                       ST_Transform(ST_GeomFromEWKT('SRID=4326;POINT(-72.1235 42.3521 4)'),2163),
+                       ST_Transform(ST_GeomFromEWKT('SRID=4326;LINESTRING(-72.1260 42.45 15, -72.123 42.1546 20)'),2163),
+                       126.8
+               ) As within_dist_2d;
+
+ within_dist_3d | within_dist_2d
+----------------+----------------
+ f              | t
+</programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_3DDistance"/>, <xref linkend="ST_Distance"/>, <xref linkend="ST_DWithin"/>, <xref linkend="ST_3DMaxDistance" />, <xref linkend="ST_Transform" /></para>
+         </refsection>
+       </refentry>
+
+<refentry id="ST_3DDFullyWithin">
+         <refnamediv>
+               <refname>ST_3DDFullyWithin</refname>
+
+               <refpurpose>Returns true if all of the 3D geometries are within the specified
+               distance of one another. </refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_3DDFullyWithin</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g1</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g2</parameter></paramdef>
+
+                       <paramdef><type>double precision </type>
+                       <parameter>distance</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns true if the 3D geometries are fully within the specified distance
+               of one another. The distance is specified in units defined by the
+               spatial reference system of the geometries.  For this function to make
+               sense, the source geometries must both be of the same coordinate projection,
+               having the same SRID.</para>
+
+               <note>
+                 <para>This function call will automatically include a bounding box
+                 comparison that will make use of any indexes that are available on
+                 the geometries.</para>
+               </note>
+
+               <para>Availability: 2.0.0</para>
+        <para>&Z_support;</para>
+        <!-- Optionally mention supports Polyhedral Surface  -->
+        <para>&P_support;</para>
+
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+               <programlisting>
+               -- This compares the difference between fully within and distance within as well
+               -- as the distance fully within for the 2D footprint of the line/point vs. the 3d fully within
+               SELECT ST_3DDFullyWithin(geom_a, geom_b, 10) as D3DFullyWithin10, ST_3DDWithin(geom_a, geom_b, 10) as D3DWithin10,
+       ST_DFullyWithin(geom_a, geom_b, 20) as D2DFullyWithin20,
+       ST_3DDFullyWithin(geom_a, geom_b, 20) as D3DFullyWithin20 from
+               (select ST_GeomFromEWKT('POINT(1 1 2)') as geom_a,
+               ST_GeomFromEWKT('LINESTRING(1 5 2, 2 7 20, 1 9 100, 14 12 3)') as geom_b) t1;
+ d3dfullywithin10 | d3dwithin10 | d2dfullywithin20 | d3dfullywithin20
+------------------+-------------+------------------+------------------
+ f                | t           | t                | f </programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_3DMaxDistance"/>, <xref linkend="ST_3DDWithin"/>, <xref linkend="ST_DWithin"/>, <xref linkend="ST_DFullyWithin"/></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_3DIntersects">
+               <refnamediv>
+                       <refname>ST_3DIntersects</refname>
+
+                       <refpurpose>Returns TRUE if the Geometries "spatially
+                       intersect" in 3D - only for points, linestrings, polygons, polyhedral surface (area).
+                       </refpurpose>
+               </refnamediv>
+               <refsynopsisdiv>
+                       <funcsynopsis>
+                               <funcprototype>
+                                       <funcdef>boolean <function>ST_3DIntersects</function></funcdef>
+                                       <paramdef>
+                                               <type>geometry</type>
+                                               <parameter>geomA</parameter>
+                                       </paramdef>
+                                       <paramdef>
+                                               <type>geometry</type>
+                                               <parameter>geomB</parameter>
+                                       </paramdef>
+                               </funcprototype>
+                       </funcsynopsis>
+               </refsynopsisdiv>
+               <refsection>
+                       <title>Description</title>
+                       <para>Overlaps, Touches, Within all imply spatial intersection.  If any of the aforementioned
+                               returns true, then the geometries also spatially intersect.
+                               Disjoint implies false for spatial intersection.</para>
+
+                       <para>Changed: 3.0.0 SFCGAL backend removed, GEOS backend supports TINs.</para>
+                       <para>Availability: 2.0.0</para>
+                       <note>
+                         <para>This function call will automatically include a bounding box
+                         comparison that will make use of any indexes that are available on the
+                         geometries.</para>
+                       </note>
+
+                       <para>&Z_support;</para>
+                       <!-- Optionally mention supports Polyhedral Surface  -->
+                       <para>&P_support;</para>
+                       <para>&T_support;</para>
+                       <para>&sfcgal_enhanced;</para>
+                       <para>&sqlmm_compliant; SQL-MM 3: ?</para>
+               </refsection>
+               <refsection>
+               <title>Geometry Examples</title>
+<programlisting>SELECT ST_3DIntersects(pt, line), ST_Intersects(pt, line)
+       FROM (SELECT 'POINT(0 0 2)'::geometry As pt, 'LINESTRING (0 0 1, 0 2 3)'::geometry As line) As foo;
+ st_3dintersects | st_intersects
+-----------------+---------------
+ f               | t
+(1 row)
+               </programlisting>
+               </refsection>
+
+               <refsection><title>TIN Examples</title>
+                   <programlisting>SELECT ST_3DIntersects('TIN(((0 0 0,1 0 0,0 1 0,0 0 0)))'::geometry, 'POINT(.1 .1 0)'::geometry);
+ st_3dintersects
+-----------------
+ t</programlisting></refsection>
+
+               <refsection>
+                       <title>See Also</title>
+                       <para><xref linkend="ST_Intersects"/></para>
+               </refsection>
+       </refentry>
+
+  <refentry id="ST_Contains">
+         <refnamediv>
+               <refname>ST_Contains</refname>
+
+               <refpurpose>Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A. </refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_Contains</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>geomA</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>geomB</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Geometry A contains Geometry B if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.
+               An important subtlety of this definition is that A does not contain its boundary, but A does contain itself. Contrast that to <xref linkend="ST_ContainsProperly" /> where geometry
+               A does not Contain Properly itself.</para>
+
+               <para>Returns TRUE if geometry B is completely inside geometry A. For this function to make
+               sense, the source geometries must both be of the same coordinate projection,
+               having the same SRID.  ST_Contains is the inverse of ST_Within.  So ST_Contains(A,B) implies ST_Within(B,A) except in the case of
+               invalid geometries where the result is always false regardless or not defined.</para>
+
+               <para>Performed by the GEOS module</para>
+               <para>Enhanced: 2.3.0 Enhancement to PIP short-circuit extended to support MultiPoints with few points. Prior versions only supported point in polygon.</para>
+
+               <important>
+                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
+               </important>
+
+               <important>
+                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
+               </important>
+
+               <para>This function call will automatically include a bounding box
+                       comparison that will make use of any indexes that are available on
+                       the geometries. To avoid index use, use the function
+                       _ST_Contains.</para>
+
+               <para>NOTE: this is the "allowable" version that returns a
+                       boolean, not an integer.</para>
+
+               <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3
+               - same as within(geometry B, geometry A)</para>
+               <para>&sqlmm_compliant; SQL-MM 3: 5.1.31</para>
+
+               <para>There are certain subtleties to ST_Contains and ST_Within that are not intuitively obvious.
+                       For details check out <ulink url="http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html">Subtleties of OGC Covers, Contains, Within</ulink></para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+
+               <para>The <function>ST_Contains</function> predicate returns <varname>TRUE</varname> in all the following illustrations.</para>
+
+               <informaltable>
+                 <tgroup cols="2">
+                       <tbody>
+                         <row>
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_contains01.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>LINESTRING</varname> / <varname>MULTIPOINT</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_contains02.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>POLYGON</varname> / <varname>POINT</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+                         </row>
+                         <row>
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_contains03.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>POLYGON</varname> / <varname>LINESTRING</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_contains04.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>POLYGON</varname> / <varname>POLYGON</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+                         </row>
+                       </tbody>
+                 </tgroup>
+               </informaltable>
+
+               <para>The <function>ST_Contains</function> predicate returns <varname>FALSE</varname> in all the following illustrations.</para>
+
+               <informaltable>
+                 <tgroup cols="2">
+                       <tbody>
+                         <row>
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_contains05.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>POLYGON</varname> / <varname>MULTIPOINT</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_contains06.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>POLYGON</varname> / <varname>LINESTRING</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+                         </row>
+                       </tbody>
+                 </tgroup>
+               </informaltable>
+
+                 <programlisting>
+-- A circle within a circle
+SELECT ST_Contains(smallc, bigc) As smallcontainsbig,
+          ST_Contains(bigc,smallc) As bigcontainssmall,
+          ST_Contains(bigc, ST_Union(smallc, bigc)) as bigcontainsunion,
+          ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion,
+          ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
+          ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
+FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
+                        ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+
+-- Result
+  smallcontainsbig | bigcontainssmall | bigcontainsunion | bigisunion | bigcoversexterior | bigcontainsexterior
+------------------+------------------+------------------+------------+-------------------+---------------------
+ f                | t                | t                | t          | t        | f
+
+-- Example demonstrating difference between contains and contains properly
+SELECT ST_GeometryType(geomA) As geomtype, ST_Contains(geomA,geomA) AS acontainsa, ST_ContainsProperly(geomA, geomA) AS acontainspropa,
+   ST_Contains(geomA, ST_Boundary(geomA)) As acontainsba, ST_ContainsProperly(geomA, ST_Boundary(geomA)) As acontainspropba
+FROM (VALUES ( ST_Buffer(ST_Point(1,1), 5,1) ),
+                        ( ST_MakeLine(ST_Point(1,1), ST_Point(-1,-1) ) ),
+                        ( ST_Point(1,1) )
+         ) As foo(geomA);
+
+  geomtype    | acontainsa | acontainspropa | acontainsba | acontainspropba
+--------------+------------+----------------+-------------+-----------------
+ST_Polygon    | t          | f              | f           | f
+ST_LineString | t          | f              | f           | f
+ST_Point      | t          | t              | f           | f
+
+ </programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+               <para><xref linkend="ST_Boundary" />, <xref linkend="ST_ContainsProperly" />, <xref linkend="ST_Covers" />, <xref linkend="ST_CoveredBy" />, <xref linkend="ST_Equals"/>, <xref linkend="ST_Within"/></para>
+         </refsection>
+ </refentry>
+
+ <refentry id="ST_ContainsProperly">
+         <refnamediv>
+               <refname>ST_ContainsProperly</refname>
+
+               <refpurpose>Returns true if B intersects the interior of A but not the boundary (or exterior). A does not contain properly itself, but does contain itself.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_ContainsProperly</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>geomA</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>geomB</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns true if B intersects the interior of A but not the boundary (or exterior).</para>
+
+               <para>A does not contain properly itself, but does contain itself.</para>
+               <para>Every point of the other geometry is a point of this geometry's interior. The DE-9IM Intersection Matrix for the two geometries matches
+   [T**FF*FF*] used in <xref linkend="ST_Relate" /></para>
+
+               <note>
+                 <para>From JTS docs slightly reworded: The advantage to using this predicate over <xref linkend="ST_Contains" /> and <xref linkend="ST_Intersects" /> is that it can be computed
+         efficiently, with no need to compute topology at individual points.</para>
+               <para>
+                        An example use case for this predicate is computing the intersections of a set of geometries with a large polygonal geometry. Since intersection is a fairly slow operation, it can be more efficient to use containsProperly to filter out test geometries which lie
+       wholly inside the area.  In these cases the intersection is     known a priori to be exactly the original test geometry.
+        </para>
+               </note>
+               <para>Performed by the GEOS module.</para>
+               <para>Availability: 1.4.0</para>
+
+               <important>
+                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
+               </important>
+
+               <important>
+                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
+               </important>
+
+               <para>This function call will automatically include a bounding box
+                       comparison that will make use of any indexes that are available on
+                       the geometries. To avoid index use, use the function
+                       _ST_ContainsProperly.</para>
+
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+                 <programlisting>
+       --a circle within a circle
+       SELECT ST_ContainsProperly(smallc, bigc) As smallcontainspropbig,
+       ST_ContainsProperly(bigc,smallc) As bigcontainspropsmall,
+       ST_ContainsProperly(bigc, ST_Union(smallc, bigc)) as bigcontainspropunion,
+       ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion,
+       ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
+       ST_ContainsProperly(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
+       FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
+       ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+       --Result
+  smallcontainspropbig | bigcontainspropsmall | bigcontainspropunion | bigisunion | bigcoversexterior | bigcontainsexterior
+------------------+------------------+------------------+------------+-------------------+---------------------
+ f                     | t                    | f                    | t          | t                 | f
+
+ --example demonstrating difference between contains and contains properly
+ SELECT ST_GeometryType(geomA) As geomtype, ST_Contains(geomA,geomA) AS acontainsa, ST_ContainsProperly(geomA, geomA) AS acontainspropa,
+ ST_Contains(geomA, ST_Boundary(geomA)) As acontainsba, ST_ContainsProperly(geomA, ST_Boundary(geomA)) As acontainspropba
+ FROM (VALUES ( ST_Buffer(ST_Point(1,1), 5,1) ),
+                 ( ST_MakeLine(ST_Point(1,1), ST_Point(-1,-1) ) ),
+                 ( ST_Point(1,1) )
+       ) As foo(geomA);
+
+  geomtype    | acontainsa | acontainspropa | acontainsba | acontainspropba
+--------------+------------+----------------+-------------+-----------------
+ST_Polygon    | t          | f              | f           | f
+ST_LineString | t          | f              | f           | f
+ST_Point      | t          | t              | f           | f
+ </programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+               <para><xref linkend="ST_GeometryType" />, <xref linkend="ST_Boundary" />, <xref linkend="ST_Contains" />, <xref linkend="ST_Covers" />, <xref linkend="ST_CoveredBy" />, <xref linkend="ST_Equals"/>, <xref linkend="ST_Relate" />, <xref linkend="ST_Within"/></para>
+         </refsection>
+ </refentry>
+
+  <refentry id="ST_Covers">
+         <refnamediv>
+               <refname>ST_Covers</refname>
+
+               <refpurpose>Returns 1 (TRUE) if no point in Geometry B is outside
+                       Geometry A</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_Covers</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>geomA</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>geomB</parameter></paramdef>
+                 </funcprototype>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_Covers</function></funcdef>
+
+                       <paramdef><type>geography </type>
+                       <parameter>geogpolyA</parameter></paramdef>
+
+                       <paramdef><type>geography </type>
+                       <parameter>geogpointB</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+                 <para>Returns 1 (TRUE) if no point in Geometry/Geography B is outside
+                       Geometry/Geography A</para>
+
+               <important>
+                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
+               </important>
+
+               <important>
+                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
+               </important>
+
+               <para>This function call will automatically include a bounding box
+                       comparison that will make use of any indexes that are available on
+                       the geometries. To avoid index use, use the function
+                       _ST_Covers.</para>
+
+               <para>Performed by the GEOS module</para>
+    <para>Enhanced: 2.4.0 Support for polygon in polygon and line in polygon added for geography type</para>
+               <para>Enhanced: 2.3.0 Enhancement to PIP short-circuit for geometry extended to support MultiPoints with few points. Prior versions only supported point in polygon.</para>
+               <para>Availability: 1.5 - support for geography was introduced. </para>
+               <para>Availability: 1.2.2</para>
+
+               <para>NOTE: this is the "allowable" version that returns a
+                       boolean, not an integer.</para>
+
+               <para>Not an OGC standard, but Oracle has it too.</para>
+               <para>There are certain subtleties to ST_Contains and ST_Within that are not intuitively obvious.
+                       For details check out <ulink url="http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html">Subtleties of OGC Covers, Contains, Within</ulink></para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+                       <para> Geometry example </para>
+                 <programlisting>
+       --a circle covering a circle
+SELECT ST_Covers(smallc,smallc) As smallinsmall,
+       ST_Covers(smallc, bigc) As smallcoversbig,
+       ST_Covers(bigc, ST_ExteriorRing(bigc)) As bigcoversexterior,
+       ST_Contains(bigc, ST_ExteriorRing(bigc)) As bigcontainsexterior
+FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
+       ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+       --Result
+ smallinsmall | smallcoversbig | bigcoversexterior | bigcontainsexterior
+--------------+----------------+-------------------+---------------------
+ t            | f              | t                 | f
+(1 row)        </programlisting>
+               <para>Geeography Example</para>
+               <programlisting>
+-- a point with a 300 meter buffer compared to a point, a point and its 10 meter buffer
+SELECT ST_Covers(geog_poly, geog_pt) As poly_covers_pt,
+       ST_Covers(ST_Buffer(geog_pt,10), geog_pt) As buff_10m_covers_cent
+       FROM (SELECT ST_Buffer(ST_GeogFromText('SRID=4326;POINT(-99.327 31.4821)'), 300) As geog_poly,
+                               ST_GeogFromText('SRID=4326;POINT(-99.33 31.483)') As geog_pt ) As foo;
+
+ poly_covers_pt | buff_10m_covers_cent
+----------------+------------------
+ f              | t
+               </programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+               <para><xref linkend="ST_Contains"/>, <xref linkend="ST_CoveredBy" />, <xref linkend="ST_Within"/></para>
+         </refsection>
+ </refentry>
+
+  <refentry id="ST_CoveredBy">
+         <refnamediv>
+               <refname>ST_CoveredBy</refname>
+
+               <refpurpose>Returns 1 (TRUE) if no point in Geometry/Geography A is outside
+                       Geometry/Geography B</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>geomA</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>geomB</parameter></paramdef>
+                 </funcprototype>
+
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_CoveredBy</function></funcdef>
+
+                       <paramdef><type>geography </type>
+                       <parameter>geogA</parameter></paramdef>
+
+                       <paramdef><type>geography </type>
+                       <parameter>geogB</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+                 <para>Returns 1 (TRUE) if no point in Geometry/Geography A is outside
+                       Geometry/Geography B</para>
+
+               <important>
+                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
+               </important>
+
+               <important>
+                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
+               </important>
+               <para>Performed by the GEOS module</para>
+               <para>Availability: 1.2.2</para>
+               <para>This function call will automatically include a bounding box
+                       comparison that will make use of any indexes that are available on
+                       the geometries. To avoid index use, use the function
+                       _ST_CoveredBy.</para>
+
+               <para>NOTE: this is the "allowable" version that returns a
+                       boolean, not an integer.</para>
+
+               <para>Not an OGC standard, but Oracle has it too.</para>
+               <para>There are certain subtleties to ST_Contains and ST_Within that are not intuitively obvious.
+                       For details check out <ulink url="http://lin-ear-th-inking.blogspot.com/2007/06/subtleties-of-ogc-covers-spatial.html">Subtleties of OGC Covers, Contains, Within</ulink></para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+                 <programlisting>
+       --a circle coveredby a circle
+SELECT ST_CoveredBy(smallc,smallc) As smallinsmall,
+       ST_CoveredBy(smallc, bigc) As smallcoveredbybig,
+       ST_CoveredBy(ST_ExteriorRing(bigc), bigc) As exteriorcoveredbybig,
+       ST_Within(ST_ExteriorRing(bigc),bigc) As exeriorwithinbig
+FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 2)'), 10) As smallc,
+       ST_Buffer(ST_GeomFromText('POINT(1 2)'), 20) As bigc) As foo;
+       --Result
+ smallinsmall | smallcoveredbybig | exteriorcoveredbybig | exeriorwithinbig
+--------------+-------------------+----------------------+------------------
+ t            | t                 | t                    | f
+(1 row)        </programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+               <para><xref linkend="ST_Contains"/>, <xref linkend="ST_Covers" />, <xref linkend="ST_ExteriorRing"/>, <xref linkend="ST_Within"/></para>
+         </refsection>
+ </refentry>
+
+  <refentry id="ST_Crosses">
+       <refnamediv>
+         <refname>ST_Crosses</refname>
+
+         <refpurpose>Returns <varname>TRUE</varname> if the supplied geometries have some, but not all,
+         interior points in common.</refpurpose>
+       </refnamediv>
+
+       <refsynopsisdiv>
+         <funcsynopsis>
+               <funcprototype>
+                 <funcdef>boolean <function>ST_Crosses</function></funcdef>
+
+                 <paramdef><type>geometry </type><parameter>g1</parameter></paramdef>
+
+                 <paramdef><type>geometry </type><parameter>g2</parameter></paramdef>
+               </funcprototype>
+         </funcsynopsis>
+       </refsynopsisdiv>
+
+       <refsection>
+         <title>Description</title>
+
+         <para><function>ST_Crosses</function> takes two geometry objects and
+         returns <varname>TRUE</varname> if their intersection "spatially cross", that is, the
+         geometries have some, but not all interior points in common. The
+         intersection of the interiors of the geometries must not be the empty
+         set and must have a dimensionality less than the maximum dimension
+         of the two input geometries. Additionally, the intersection of the two
+         geometries must not equal either of the source geometries. Otherwise, it
+         returns <varname>FALSE</varname>.</para>
+
+         <para>In mathematical terms, this is expressed as:</para>
+
+         <remark>TODO: Insert appropriate MathML markup here or use a gif.
+         Simple HTML markup does not work well in both IE and Firefox.</remark>
+
+         <informalfigure>
+               <mediaobject>
+                 <imageobject>
+                       <imagedata fileref="images/st_crosses-math.gif" />
+                 </imageobject>
+               </mediaobject>
+         </informalfigure>
+
+         <para>The DE-9IM Intersection Matrix for the two geometries is:</para>
+
+         <itemizedlist>
+               <listitem>
+                 <para><markup>T*T******</markup> (for Point/Line, Point/Area, and
+                 Line/Area situations)</para>
+               </listitem>
+
+               <listitem>
+                 <para><markup>T*****T**</markup> (for Line/Point, Area/Point, and
+                 Area/Line situations)</para>
+               </listitem>
+
+               <listitem>
+                 <para><markup>0********</markup> (for Line/Line situations)</para>
+               </listitem>
+         </itemizedlist>
+
+         <para>For any other combination of dimensions this predicate returns
+         false.</para>
+
+         <para>The OpenGIS Simple Features Specification defines this predicate
+               only for Point/Line, Point/Area, Line/Line, and Line/Area situations.
+               JTS / GEOS extends the definition to apply to Line/Point, Area/Point and
+               Area/Line situations as well. This makes the relation
+               symmetric.</para>
+
+         <important>
+               <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
+         </important>
+
+       <note>
+         <para>This function call will automatically include a bounding box
+         comparison that will make use of any indexes that are available on the
+         geometries.</para>
+       </note>
+
+       <para>&sfs_compliant; s2.1.13.3</para>
+       <para>&sqlmm_compliant; SQL-MM 3: 5.1.29</para>
+       </refsection>
+
+       <refsection>
+         <title>Examples</title>
+
+         <para>The following illustrations all return <varname>TRUE</varname>.</para>
+
+         <informaltable>
+               <tgroup cols="2">
+                 <tbody>
+                       <row>
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_crosses01.png" />
+                                       </imageobject>
+
+                                       <caption><para><varname>MULTIPOINT</varname> / <varname>LINESTRING</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_crosses02.png" />
+                                       </imageobject>
+
+                                       <caption><para><varname>MULTIPOINT</varname> / <varname>POLYGON</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+                       </row>
+
+                       <row>
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_crosses03.png" />
+                                       </imageobject>
+
+                                       <caption><para><varname>LINESTRING</varname> / <varname>POLYGON</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_crosses04.png" />
+                                       </imageobject>
+
+                                       <caption><para><varname>LINESTRING</varname> / <varname>LINESTRING</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+                       </row>
+                 </tbody>
+               </tgroup>
+         </informaltable>
+
+         <para>Consider a situation where a user has two tables: a table of roads
+         and a table of highways.</para>
+
+         <informaltable>
+               <tgroup cols="2">
+                 <tbody>
+                       <row>
+                         <entry><para> <informalexample>
+                                 <programlisting>CREATE TABLE roads (
+  id serial NOT NULL,
+  the_geom geometry,
+  CONSTRAINT roads_pkey PRIMARY KEY (road_id)
+);</programlisting>
+                               </informalexample> </para></entry>
+
+                         <entry><para> <informalexample>
+                                 <programlisting>CREATE TABLE highways (
+  id serial NOT NULL,
+  the_gem geometry,
+  CONSTRAINT roads_pkey PRIMARY KEY (road_id)
+);</programlisting>
+                               </informalexample> </para></entry>
+                       </row>
+                 </tbody>
+               </tgroup>
+         </informaltable>
+
+         <para>To determine a list of roads that cross a highway, use a query
+         similiar to:</para>
+
+         <para><informalexample>
+                 <programlisting>SELECT roads.id
+FROM roads, highways
+WHERE ST_Crosses(roads.the_geom, highways.the_geom);</programlisting>
+               </informalexample></para>
+       </refsection>
+  </refentry>
+
+  <refentry id="ST_LineCrossingDirection">
+       <refnamediv>
+         <refname>ST_LineCrossingDirection</refname>
+
+         <refpurpose>Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing.</refpurpose>
+       </refnamediv>
+
+       <refsynopsisdiv>
+         <funcsynopsis>
+               <funcprototype>
+                 <funcdef>integer <function>ST_LineCrossingDirection</function></funcdef>
+                 <paramdef><type>geometry </type> <parameter>linestringA</parameter></paramdef>
+                 <paramdef><type>geometry </type> <parameter>linestringB</parameter></paramdef>
+               </funcprototype>
+         </funcsynopsis>
+       </refsynopsisdiv>
+
+       <refsection>
+         <title>Description</title>
+
+         <para>Given 2 linestrings, returns a number between -3 and 3 denoting what kind of crossing behavior. 0 is no crossing.  This is only supported for <varname>LINESTRING</varname></para>
+         <para>Definition of integer constants is as follows:
+                  <itemizedlist>
+                               <listitem>
+                                 <para> 0: LINE NO CROSS</para>
+                               </listitem>
+                               <listitem>
+                                 <para>-1: LINE CROSS LEFT</para>
+                               </listitem>
+                               <listitem>
+                                 <para> 1: LINE CROSS RIGHT</para>
+                               </listitem>
+                               <listitem>
+                                 <para>-2: LINE MULTICROSS END LEFT</para>
+                               </listitem>
+                               <listitem>
+                                       <para> 2: LINE MULTICROSS END RIGHT</para>
+                               </listitem>
+                               <listitem>
+                                 <para>-3: LINE MULTICROSS END SAME FIRST LEFT</para>
+                               </listitem>
+                               <listitem>
+                                 <para> 3: LINE MULTICROSS END SAME FIRST RIGHT</para>
+                               </listitem>
+                       </itemizedlist>
+         </para>
+         <para>Availability: 1.4</para>
+         <!-- optionally mention that this function uses indexes if appropriate -->
+
+       </refsection>
+
+
+       <refsection>
+         <title>Examples</title>
+  <!-- TODO: We really badly need diagrams here and more examples -->
+               <informaltable>
+                 <tgroup cols="2">
+                       <tbody>
+                         <row>
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_linecrossingdirection01.png" />
+                                         </imageobject>
+                                         <caption><para>Line 1 (green), Line 2 ball is start point,
+                                       triangle are end points. Query below. </para></caption>
+                                       </mediaobject>
+                                 </informalfigure>
+                                 <programlisting>
+SELECT ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
+         ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
+FROM (
+SELECT
+ ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
+ ST_GeomFromText('LINESTRING(171 154,20 140,71 74,161 53)') As line2
+       ) As foo;
+
+ l1_cross_l2 | l2_cross_l1
+-------------+-------------
+           3 |          -3
+                               </programlisting>
+                       </para>
+               </entry>
+
+               <entry>
+                       <para><informalfigure>
+                               <mediaobject>
+                                 <imageobject>
+                                       <imagedata fileref="images/st_linecrossingdirection02.png" />
+                                 </imageobject>
+                                 <caption><para>Line 1 (green), Line 2 (blue) ball is start point,
+                                               triangle are end points. Query below.</para></caption>
+                               </mediaobject>
+                         </informalfigure>
+                         <programlisting>
+SELECT ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
+         ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
+FROM (
+ SELECT
+  ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
+  ST_GeomFromText('LINESTRING (171 154, 20 140, 71 74, 2.99 90.16)') As line2
+) As foo;
+
+ l1_cross_l2 | l2_cross_l1
+-------------+-------------
+           2 |          -2
+                               </programlisting>
+                       </para>
+               </entry>
+         </row>
+         <row>
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_linecrossingdirection03.png" />
+                                         </imageobject>
+                                         <caption><para>Line 1 (green), Line 2 (blue) ball is start point,
+                                       triangle are end points. Query below. </para></caption>
+                                       </mediaobject>
+                                 </informalfigure>
+                                 <programlisting>
+SELECT
+       ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
+       ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
+FROM (
+ SELECT
+  ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
+  ST_GeomFromText('LINESTRING (20 140, 71 74, 161 53)') As line2
+  ) As foo;
+
+ l1_cross_l2 | l2_cross_l1
+-------------+-------------
+          -1 |          1
+                               </programlisting>
+                       </para>
+               </entry>
+
+               <entry>
+                       <para><informalfigure>
+                               <mediaobject>
+                                 <imageobject>
+                                       <imagedata fileref="images/st_linecrossingdirection04.png" />
+                                 </imageobject>
+                                 <caption><para>Line 1 (green), Line 2 (blue) ball is start point,
+                                               triangle are end points. Query below.</para></caption>
+                               </mediaobject>
+                         </informalfigure>
+                         <programlisting>
+SELECT ST_LineCrossingDirection(foo.line1, foo.line2) As l1_cross_l2 ,
+         ST_LineCrossingDirection(foo.line2, foo.line1) As l2_cross_l1
+FROM (SELECT
+       ST_GeomFromText('LINESTRING(25 169,89 114,40 70,86 43)') As line1,
+       ST_GeomFromText('LINESTRING(2.99 90.16,71 74,20 140,171 154)') As line2
+       ) As foo;
+
+ l1_cross_l2 | l2_cross_l1
+-------------+-------------
+          -2 |          2
+                               </programlisting>
+                       </para>
+               </entry>
+         </row>
+         </tbody>
+       </tgroup>
+</informaltable>
+
+<programlisting>
+SELECT s1.gid, s2.gid, ST_LineCrossingDirection(s1.the_geom, s2.the_geom)
+       FROM streets s1 CROSS JOIN streets s2 ON (s1.gid != s2.gid AND s1.the_geom &amp;&amp; s2.the_geom )
+WHERE ST_CrossingDirection(s1.the_geom, s2.the_geom) > 0;
+</programlisting>
+       </refsection>
+
+       <!-- Optionally add a "See Also" section -->
+       <refsection>
+         <title>See Also</title>
+
+         <para><xref linkend="ST_Crosses" /></para>
+       </refsection>
+  </refentry>
+
+  <refentry id="ST_Disjoint">
+               <refnamediv>
+                       <refname>ST_Disjoint</refname>
+
+                       <refpurpose>Returns TRUE if the Geometries do not "spatially
+                       intersect" - if they do not share any space together.
+                       </refpurpose>
+               </refnamediv>
+               <refsynopsisdiv>
+                       <funcsynopsis>
+                               <funcprototype>
+                                       <funcdef>boolean <function>ST_Disjoint</function></funcdef>
+                                       <paramdef>
+                                               <type>geometry</type>
+                                               <parameter>A</parameter>
+                                       </paramdef>
+                                       <paramdef>
+                                               <type>geometry</type>
+                                               <parameter>B</parameter>
+                                       </paramdef>
+                               </funcprototype>
+                       </funcsynopsis>
+               </refsynopsisdiv>
+               <refsection>
+                       <title>Description</title>
+                       <para>Overlaps, Touches, Within all imply geometries are not spatially disjoint.  If any of the aforementioned
+                               returns true, then the geometries are not spatially disjoint.
+                               Disjoint implies false for spatial intersection.</para>
+
+                       <important>
+                               <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
+                       </important>
+
+                       <para>Performed by the GEOS module</para>
+                       <note>
+                         <para>This function call does not use indexes</para>
+
+                       </note>
+                       <note>
+                         <para>NOTE: this is the "allowable" version that returns a
+                       boolean, not an integer.</para>
+                       </note>
+                       <para>&sfs_compliant; s2.1.1.2 //s2.1.13.3
+                       - a.Relate(b, 'FF*FF****')</para>
+                       <para>&sqlmm_compliant; SQL-MM 3: 5.1.26</para>
+               </refsection>
+               <refsection>
+               <title>Examples</title>
+
+               <programlisting>SELECT ST_Disjoint('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
+ st_disjoint
+---------------
+ t
+(1 row)
+SELECT ST_Disjoint('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry);
+ st_disjoint
+---------------
+ f
+(1 row)
+               </programlisting>
+               </refsection>
+
+               <refsection>
+                       <title>See Also</title>
+                       <para><xref linkend="ST_Intersects"/></para>
+               </refsection>
+       </refentry>
+
+       <refentry id="ST_DFullyWithin">
+         <refnamediv>
+               <refname>ST_DFullyWithin</refname>
+
+               <refpurpose>Returns true if all of the geometries are within the specified
+               distance of one another</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_DFullyWithin</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g1</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g2</parameter></paramdef>
+
+                       <paramdef><type>double precision </type>
+                       <parameter>distance</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns true if the geometries is fully within the specified distance
+               of one another. The distance is specified in units defined by the
+               spatial reference system of the geometries.  For this function to make
+               sense, the source geometries must both be of the same coordinate projection,
+               having the same SRID.</para>
+
+               <note>
+                 <para>This function call will automatically include a bounding box
+                 comparison that will make use of any indexes that are available on
+                 the geometries.</para>
+               </note>
+
+               <para>Availability: 1.5.0</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+               <programlisting>postgis=# SELECT ST_DFullyWithin(geom_a, geom_b, 10) as DFullyWithin10, ST_DWithin(geom_a, geom_b, 10) as DWithin10, ST_DFullyWithin(geom_a, geom_b, 20) as DFullyWithin20 from
+               (select ST_GeomFromText('POINT(1 1)') as geom_a,ST_GeomFromText('LINESTRING(1 5, 2 7, 1 9, 14 12)') as geom_b) t1;
+
+-----------------
+ DFullyWithin10 | DWithin10 | DFullyWithin20 |
+---------------+----------+---------------+
+ f             | t        | t             |  </programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_MaxDistance"/>, <xref linkend="ST_DWithin"/></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_DWithin">
+         <refnamediv>
+               <refname>ST_DWithin</refname>
+
+               <refpurpose>Returns true if the geometries are within the specified
+               distance of one another. For geometry units are in those of spatial reference and for geography units are in meters and measurement is
+               defaulted to use_spheroid=true (measure around spheroid), for faster check, use_spheroid=false to measure along sphere.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                               <funcdef>boolean <function>ST_DWithin</function></funcdef>
+                               <paramdef><type>geometry </type>
+                               <parameter>g1</parameter></paramdef>
+
+                               <paramdef><type>geometry </type>
+                               <parameter>g2</parameter></paramdef>
+
+                               <paramdef><type>double precision </type>
+                               <parameter>distance_of_srid</parameter></paramdef>
+                 </funcprototype>
+
+                 <funcprototype>
+                               <funcdef>boolean <function>ST_DWithin</function></funcdef>
+                               <paramdef><type>geography </type>
+                               <parameter>gg1</parameter></paramdef>
+
+                               <paramdef><type>geography </type>
+                               <parameter>gg2</parameter></paramdef>
+
+                               <paramdef><type>double precision </type>
+                               <parameter>distance_meters</parameter></paramdef>
+
+                               <paramdef choice="opt"><type>boolean </type>
+                               <parameter>use_spheroid</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns true if the geometries are within the specified distance
+               of one another.</para>
+
+               <para>For <type>geometry</type>: The distance is specified in units defined by the
+               spatial reference system of the geometries.  For this function to make
+               sense, the source geometries must both be of the same coordinate projection,
+               having the same SRID.</para>
+
+               <para>For <type>geography</type> units are in meters and measurement is
+               defaulted to <varname>use_spheroid</varname>=true, for faster check, <varname>use_spheroid</varname>=false to measure along sphere.
+               </para>
+
+               <note>
+                 <para>This function call will automatically include a bounding box
+                 comparison that will make use of any indexes that are available on
+                 the geometries.</para>
+               </note>
+
+               <note>
+                 <para>Prior to 1.3, ST_Expand was commonly used in conjunction with &amp;&amp; and ST_Distance to
+                 achieve the same effect and in pre-1.3.4 this function was basically short-hand for that construct.
+                 From 1.3.4, ST_DWithin uses a more short-circuit distance function which should make it more efficient
+                 than prior versions for larger buffer regions.</para>
+               </note>
+
+               <note><para>Use ST_3DDWithin if you have 3D geometries.</para></note>
+
+               <para>&sfs_compliant;</para>
+               <para>Availability: 1.5.0 support for geography was introduced</para>
+               <para>Enhanced: 2.1.0 improved speed for geography. See <ulink url="http://blog.opengeo.org/2012/07/12/making-geography-faster/">Making Geography faster</ulink> for details.</para>
+               <para>Enhanced: 2.1.0 support for curved geometries was introduced.</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+                 <programlisting>
+-- Find the nearest hospital to each school
+-- that is within 3000 units of the school.
+--  We do an ST_DWithin search to utilize indexes to limit our search list
+--  that the non-indexable ST_Distance needs to process
+-- If the units of the spatial reference is meters then units would be meters
+SELECT DISTINCT ON (s.gid) s.gid, s.school_name, s.geom, h.hospital_name
+       FROM schools s
+               LEFT JOIN hospitals h ON ST_DWithin(s.the_geom, h.geom, 3000)
+       ORDER BY s.gid, ST_Distance(s.geom, h.geom);
+
+-- The schools with no close hospitals
+-- Find all schools with no hospital within 3000 units
+-- away from the school.  Units is in units of spatial ref (e.g. meters, feet, degrees)
+SELECT s.gid, s.school_name
+       FROM schools s
+               LEFT JOIN hospitals h ON ST_DWithin(s.geom, h.geom, 3000)
+       WHERE h.gid IS NULL;
+
+-- Find broadcasting towers that receiver with limited range can receive.
+-- Data is geometry in Spherical Mercator (SRID=3857), ranges are approximate.
+
+-- Create geometry index that will check proximity limit of user to tower
+CREATE INDEX ON broadcasting_towers using gist (geom);
+
+-- Create geometry index that will check proximity limit of tower to user
+CREATE INDEX ON broadcasting_towers using gist (ST_Expand(geom, sending_range));
+
+-- Query towers that 4-kilometer receiver in Minsk Hackerspace can get
+-- Note: two conditions, because shorter LEAST(b.sending_range, 4000) will not use index.
+SELECT b.tower_id, b.geom
+  FROM broadcasting_towers b
+  WHERE ST_DWithin(b.geom, 'SRID=3857;POINT(3072163.4 7159374.1)', 4000)
+         AND ST_DWithin(b.geom, 'SRID=3857;POINT(3072163.4 7159374.1)', b.sending_range);
+
+                         </programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Distance"/>, <xref linkend="ST_Expand"/>, <xref linkend="ST_3DDWithin"/></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_Equals">
+         <refnamediv>
+               <refname>ST_Equals</refname>
+
+               <refpurpose>Returns true if the given geometries represent the same geometry. Directionality
+                       is ignored.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_Equals</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>A</parameter></paramdef>
+                       <paramdef><type>geometry </type> <parameter>B</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns TRUE if the given Geometries are "spatially
+                       equal". Use this for a 'better' answer than '='.
+                       Note by spatially equal we mean ST_Within(A,B) = true and ST_Within(B,A) = true and
+                       also mean ordering of points can be different but
+                       represent the same geometry structure.  To verify the order of points is consistent, use
+                       ST_OrderingEquals (it must be noted ST_OrderingEquals is a little more stringent than simply verifying order of
+                       points are the same).</para>
+
+               <important>
+                 <para>This function will return false if either geometry is invalid except in the case where they are binary equal.</para>
+               </important>
+
+        <important>
+            <para>Do not call with a GEOMETRYCOLLECTION as an argument.</para>
+               </important>
+
+               <para>&sfs_compliant; s2.1.1.2</para>
+               <para>&sqlmm_compliant; SQL-MM 3: 5.1.24</para>
+        <para>Changed: 2.2.0 Returns true even for invalid geometries if they are binary equal</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>SELECT ST_Equals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
+               ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
+ st_equals
+-----------
+ t
+(1 row)
+
+SELECT ST_Equals(ST_Reverse(ST_GeomFromText('LINESTRING(0 0, 10 10)')),
+               ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
+ st_equals
+-----------
+ t
+(1 row)
+</programlisting>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_IsValid"/>, <xref linkend="ST_OrderingEquals"/>, <xref linkend="ST_Reverse"/>, <xref linkend="ST_Within" /></para>
+         </refsection>
+
+       </refentry>
+
+
+       <refentry id="ST_Intersects">
+               <refnamediv>
+                       <refname>ST_Intersects</refname>
+
+                       <refpurpose>Returns TRUE if the Geometries/Geography "spatially
+                       intersect in 2D" - (share any portion of space) and FALSE if they don't (they are Disjoint).
+                       For geography tolerance is 0.00001 meters (so any points that close are considered to intersect)
+                       </refpurpose>
+               </refnamediv>
+               <refsynopsisdiv>
+                       <funcsynopsis>
+                               <funcprototype>
+                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
+                                       <paramdef>
+                                               <type>geometry</type>
+                                               <parameter>geomA</parameter>
+                                       </paramdef>
+                                       <paramdef>
+                                               <type>geometry</type>
+                                               <parameter>geomB</parameter>
+                                       </paramdef>
+                               </funcprototype>
+                               <funcprototype>
+                                       <funcdef>boolean <function>ST_Intersects</function></funcdef>
+                                       <paramdef>
+                                               <type>geography</type>
+                                               <parameter>geogA</parameter>
+                                       </paramdef>
+                                       <paramdef>
+                                               <type>geography</type>
+                                               <parameter>geogB</parameter>
+                                       </paramdef>
+                               </funcprototype>
+                       </funcsynopsis>
+               </refsynopsisdiv>
+               <refsection>
+                       <title>Description</title>
+                       <para>If a geometry or geography shares any portion of space then they intersect.
+                       For geography -- tolerance is 0.00001 meters (so any points that are close are considered to intersect)</para>
+                       <para>ST_Overlaps, ST_Touches, ST_Within all imply spatial intersection.
+                         If any of the aforementioned
+                               returns true, then the geometries also spatially intersect.
+                               Disjoint implies false for spatial intersection.</para>
+
+                       <para>Changed: 3.0.0 SFCGAL version removed.</para>
+                       <para>Enhanced: 2.5.0 Supports GEOMETRYCOLLECTION.</para>
+                       <para>Enhanced: 2.3.0 Enhancement to PIP short-circuit extended to support MultiPoints with few points. Prior versions only supported point in polygon.</para>
+                       <para>Performed by the GEOS module (for geometry), geography is native</para>
+                       <para>Availability: 1.5 support for geography was introduced.</para>
+                       <note>
+                         <para>This function call will automatically include a bounding box
+                         comparison that will make use of any indexes that are available on the
+                         geometries.</para>
+                       </note>
+                       <note>
+                         <para>For geography, this function has a distance tolerance of about 0.00001 meters and uses the sphere rather
+                               than spheroid calculation.</para>
+                       </note>
+                       <note>
+                         <para>NOTE: this is the "allowable" version that returns a
+                       boolean, not an integer.</para>
+                       </note>
+                       <para>&sfs_compliant; s2.1.1.2 //s2.1.13.3
+                         - ST_Intersects(g1, g2 ) --&gt; Not (ST_Disjoint(g1, g2 ))
+                       </para>
+                       <para>&sqlmm_compliant; SQL-MM 3: 5.1.27</para>
+                        <para>&sfcgal_enhanced;</para>
+               </refsection>
+               <refsection>
+               <title>Geometry Examples</title>
+<programlisting>SELECT ST_Intersects('POINT(0 0)'::geometry, 'LINESTRING ( 2 0, 0 2 )'::geometry);
+ st_intersects
+---------------
+ f
+(1 row)
+SELECT ST_Intersects('POINT(0 0)'::geometry, 'LINESTRING ( 0 0, 0 2 )'::geometry);
+ st_intersects
+---------------
+ t
+(1 row)
+               </programlisting>
+               </refsection>
+               <refsection>
+               <title>Geography Examples</title>
+<programlisting>SELECT ST_Intersects(
+               'SRID=4326;LINESTRING(-43.23456 72.4567,-43.23456 72.4568)'::geography,
+               'SRID=4326;POINT(-43.23456 72.4567772)'::geography
+               );
+
+ st_intersects
+---------------
+t
+</programlisting>
+               </refsection>
+               <refsection>
+                       <title>See Also</title>
+                       <para> <xref linkend="ST_3DIntersects" />, <xref linkend="ST_Disjoint"/></para>
+               </refsection>
+       </refentry>
+
+       <refentry id="ST_OrderingEquals">
+         <refnamediv>
+               <refname>ST_OrderingEquals</refname>
+
+               <refpurpose>Returns true if the given geometries represent the same geometry
+               and points are in the same directional order.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_OrderingEquals</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>A</parameter></paramdef>
+                       <paramdef><type>geometry </type> <parameter>B</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>ST_OrderingEquals compares two geometries and returns t (TRUE) if the
+                 geometries are equal and the coordinates are in the same order;
+                 otherwise it returns f (FALSE).</para>
+
+               <note>
+                       <para>This function is implemented as per the ArcSDE SQL
+               specification rather than SQL-MM.
+               http://edndoc.esri.com/arcsde/9.1/sql_api/sqlapi3.htm#ST_OrderingEquals</para>
+               </note>
+               <para>&sqlmm_compliant; SQL-MM 3: 5.1.43</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>SELECT ST_OrderingEquals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
+               ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
+ st_orderingequals
+-----------
+ f
+(1 row)
+
+SELECT ST_OrderingEquals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
+               ST_GeomFromText('LINESTRING(0 0, 0 0, 10 10)'));
+ st_orderingequals
+-----------
+ t
+(1 row)
+
+SELECT ST_OrderingEquals(ST_Reverse(ST_GeomFromText('LINESTRING(0 0, 10 10)')),
+               ST_GeomFromText('LINESTRING(0 0, 0 0, 10 10)'));
+ st_orderingequals
+-----------
+ f
+(1 row)
+</programlisting>
+                 </refsection>
+                 <refsection>
+                       <title>See Also</title>
+                       <para><xref linkend="ST_Equals"/>, <xref linkend="ST_Reverse"/></para>
+                 </refsection>
+       </refentry>
+
+       <refentry id="ST_Overlaps">
+         <refnamediv>
+               <refname>ST_Overlaps</refname>
+
+               <refpurpose>Returns TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_Overlaps</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>A</parameter></paramdef>
+                       <paramdef><type>geometry </type> <parameter>B</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns TRUE if the Geometries "spatially
+                       overlap".  By that we mean they intersect, but one does not completely contain another. </para>
+
+                <para>Performed by the GEOS module</para>
+
+               <note><para>Do not call with a GeometryCollection as an argument</para></note>
+
+               <para>This function call will automatically include a bounding box
+               comparison that will make use of any indexes that are available on
+               the geometries. To avoid index use, use the function
+               _ST_Overlaps.</para>
+
+               <para>NOTE: this is the "allowable" version that returns a
+                       boolean, not an integer.</para>
+
+               <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3</para>
+               <para>&sqlmm_compliant; SQL-MM 3: 5.1.32</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+          <para>The following illustrations all return <varname>TRUE</varname>.</para>
+
+         <informaltable>
+               <tgroup cols="3">
+                 <tbody>
+                       <row>
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_overlaps01.png" />
+                                       </imageobject>
+                                       <caption><para><varname>MULTIPOINT</varname> / <varname>MULTIPOINT</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_overlaps02.png" />
+                                       </imageobject>
+                                       <caption><para><varname>LINESTRING</varname> / <varname>LINESTRING</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+                         <entry><para><informalfigure>
+                                 <mediaobject>
+                                       <imageobject>
+                                         <imagedata fileref="images/st_overlaps03.png" />
+                                       </imageobject>
+                                       <caption><para><varname>POLYGON</varname> / <varname>POLYGON</varname></para></caption>
+                                 </mediaobject>
+                               </informalfigure></para></entry>
+                       </row>
+                 </tbody>
+               </tgroup>
+         </informaltable>
+               <programlisting>--a point on a line is contained by the line and is of a lower dimension, and therefore does not overlap the line
+                       nor crosses
+
+SELECT ST_Overlaps(a,b) As a_overlap_b,
+       ST_Crosses(a,b) As a_crosses_b,
+               ST_Intersects(a, b) As a_intersects_b, ST_Contains(b,a) As b_contains_a
+FROM (SELECT ST_GeomFromText('POINT(1 0.5)') As a, ST_GeomFromText('LINESTRING(1 0, 1 1, 3 5)')  As b)
+       As foo
+
+a_overlap_b | a_crosses_b | a_intersects_b | b_contains_a
+------------+-------------+----------------+--------------
+f           | f           | t              | t
+
+--a line that is partly contained by circle, but not fully is defined as intersecting and crossing,
+-- but since of different dimension it does not overlap
+SELECT ST_Overlaps(a,b) As a_overlap_b, ST_Crosses(a,b) As a_crosses_b,
+       ST_Intersects(a, b) As a_intersects_b,
+       ST_Contains(a,b) As a_contains_b
+FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 0.5)'), 3)  As a, ST_GeomFromText('LINESTRING(1 0, 1 1, 3 5)')  As b)
+       As foo;
+
+ a_overlap_b | a_crosses_b | a_intersects_b | a_contains_b
+-------------+-------------+----------------+--------------
+ f           | t           | t              | f
+
+ -- a 2-dimensional bent hot dog (aka buffered line string) that intersects a circle,
+ --    but is not fully contained by the circle is defined as overlapping since they are of the same dimension,
+--     but it does not cross, because the intersection of the 2 is of the same dimension
+--     as the maximum dimension of the 2
+
+SELECT ST_Overlaps(a,b) As a_overlap_b, ST_Crosses(a,b) As a_crosses_b, ST_Intersects(a, b) As a_intersects_b,
+ST_Contains(b,a) As b_contains_a,
+ST_Dimension(a) As dim_a, ST_Dimension(b) as dim_b, ST_Dimension(ST_Intersection(a,b)) As dima_intersection_b
+FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(1 0.5)'), 3)  As a,
+       ST_Buffer(ST_GeomFromText('LINESTRING(1 0, 1 1, 3 5)'),0.5)  As b)
+       As foo;
+
+ a_overlap_b | a_crosses_b | a_intersects_b | b_contains_a | dim_a | dim_b | dima_intersection_b
+-------------+-------------+----------------+--------------+-------+-------+---------------------
+ t           | f           | t              | f            |     2 |     2 |              2
+</programlisting>
+
+
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Contains"/>, <xref linkend="ST_Crosses"/>, <xref linkend="ST_Dimension"/>, <xref linkend="ST_Intersects"/></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_PointInsideCircle">
+         <refnamediv>
+               <refname>ST_PointInsideCircle</refname>
+
+               <refpurpose>Is the point geometry inside the circle defined by center_x, center_y, radius</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_PointInsideCircle</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>a_point</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>center_x</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>center_y</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>radius</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>The syntax for this functions is
+                       ST_PointInsideCircle(&lt;geometry&gt;,&lt;circle_center_x&gt;,&lt;circle_center_y&gt;,&lt;radius&gt;).
+                       Returns the true if the geometry is a point and is inside the
+                       circle. Returns false otherwise.</para>
+               <note><para>This only works for points as the name suggests</para></note>
+
+               <para>Availability: 1.2</para>
+               <para>Changed: 2.2.0 In prior versions this used to be called ST_Point_Inside_Circle</para>
+         </refsection>
+
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>SELECT ST_PointInsideCircle(ST_Point(1,2), 0.5, 2, 3);
+ st_pointinsidecircle
+------------------------
+ t
+</programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_DWithin" /></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_Relate">
+               <refnamediv>
+                       <refname>ST_Relate</refname>
+
+                       <refpurpose>Returns true if this Geometry is spatially related to
+                                       anotherGeometry, by testing for intersections between the
+                                       Interior, Boundary and Exterior of the two geometries as specified
+                                       by the values in the intersectionMatrixPattern.  If no intersectionMatrixPattern
+                                       is passed in, then returns the maximum intersectionMatrixPattern that relates the 2 geometries.</refpurpose>
+               </refnamediv>
+
+               <refsynopsisdiv>
+                       <funcsynopsis>
+                         <funcprototype>
+                               <funcdef>boolean <function>ST_Relate</function></funcdef>
+                               <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                               <paramdef><type>geometry </type> <parameter>geomB</parameter></paramdef>
+                               <paramdef><type>text </type> <parameter>intersectionMatrixPattern</parameter></paramdef>
+                         </funcprototype>
+
+                         <funcprototype>
+                               <funcdef>text <function>ST_Relate</function></funcdef>
+                               <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                               <paramdef><type>geometry </type> <parameter>geomB</parameter></paramdef>
+                         </funcprototype>
+
+                         <funcprototype>
+                               <funcdef>text <function>ST_Relate</function></funcdef>
+                               <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                               <paramdef><type>geometry </type> <parameter>geomB</parameter></paramdef>
+                               <paramdef><type>integer </type> <parameter>BoundaryNodeRule</parameter></paramdef>
+                         </funcprototype>
+                       </funcsynopsis>
+               </refsynopsisdiv>
+
+               <refsection>
+                       <title>Description</title>
+
+                       <para>Version 1: Takes geomA, geomB, intersectionMatrix and Returns 1 (TRUE) if this Geometry is spatially related to
+                                       anotherGeometry, by testing for intersections between the
+                                       Interior, Boundary and Exterior of the two geometries as specified
+                                       by the values in the <ulink url="http://en.wikipedia.org/wiki/DE-9IM">DE-9IM matrix pattern</ulink>.</para>
+
+                       <para>This is especially useful for testing compound checks of intersection, crosses, etc in one step.</para>
+                       <para>Do not call with a GeometryCollection as an argument</para>
+
+                       <note><para>This is the "allowable" version that returns a
+                       boolean, not an integer.  This is defined in OGC spec</para></note>
+
+                       <note><para>This DOES NOT automagically include an index call.  The reason for that
+                               is some relationships are anti e.g. Disjoint.  If you are
+                               using a relationship pattern that requires intersection, then include the &amp;&amp;
+                               index call.</para></note>
+
+                       <para>Version 2: Takes geomA and geomB and returns the <xref linkend="DE-9IM" /></para>
+
+                       <para>Version 3: same as version 2, but allows to specify a boundary node rule (1:OGC/MOD2, 2:Endpoint, 3:MultivalentEndpoint, 4:MonovalentEndpoint)</para>
+
+                       <note><para>Do not call with a GeometryCollection as an argument</para></note>
+
+                       <para>not in OGC spec, but implied. see s2.1.13.2</para>
+                       <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3</para>
+                       <para>&sqlmm_compliant; SQL-MM 3: 5.1.25</para>
+                       <para>Performed by the GEOS module</para>
+                       <para>Enhanced: 2.0.0 - added support for specifying boundary node rule.</para>
+               </refsection>
+
+
+               <refsection>
+               <title>Examples</title>
+               <programlisting>
+--Find all compounds that intersect and not touch a poly (interior intersects)
+SELECT l.* , b.name As poly_name
+       FROM polys As b
+INNER JOIN compounds As l
+ON (p.the_geom &amp;&amp; b.the_geom
+AND ST_Relate(l.the_geom, b.the_geom,'T********'));
+
+SELECT ST_Relate(ST_GeometryFromText('POINT(1 2)'), ST_Buffer(ST_GeometryFromText('POINT(1 2)'),2));
+st_relate
+-----------
+0FFFFF212
+
+SELECT ST_Relate(ST_GeometryFromText('LINESTRING(1 2, 3 4)'), ST_GeometryFromText('LINESTRING(5 6, 7 8)'));
+st_relate
+-----------
+FF1FF0102
+
+
+SELECT ST_Relate(ST_GeometryFromText('POINT(1 2)'), ST_Buffer(ST_GeometryFromText('POINT(1 2)'),2), '0FFFFF212');
+st_relate
+-----------
+t
+
+SELECT ST_Relate(ST_GeometryFromText('POINT(1 2)'), ST_Buffer(ST_GeometryFromText('POINT(1 2)'),2), '*FF*FF212');
+st_relate
+-----------
+t
+               </programlisting>
+       </refsection>
+
+       <!-- Optionally add a "See Also" section -->
+       <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Crosses" />, <xref linkend="DE-9IM" />, <xref linkend="ST_Disjoint" />, <xref linkend="ST_Intersects" />, <xref linkend="ST_Touches" /></para>
+       </refsection>
+</refentry>
+
+<refentry id="ST_RelateMatch">
+       <refnamediv>
+               <refname>ST_RelateMatch</refname>
+
+               <refpurpose>Returns true if intersectionMattrixPattern1 implies intersectionMatrixPattern2</refpurpose>
+       </refnamediv>
+
+       <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_RelateMatch</function></funcdef>
+                       <paramdef><type>text </type> <parameter>intersectionMatrix</parameter></paramdef>
+                       <paramdef><type>text </type> <parameter>intersectionMatrixPattern</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+       </refsynopsisdiv>
+
+       <refsection>
+               <title>Description</title>
+
+               <para> Takes intersectionMatrix and intersectionMatrixPattern and Returns true if the intersectionMatrix satisfies
+               the intersectionMatrixPattern. For more information refer to <xref linkend="DE-9IM" />. </para>
+               <para>Performed by the GEOS module</para>
+               <para>Availability: 2.0.0</para>
+       </refsection>
+
+
+       <refsection>
+               <title>Examples</title>
+               <programlisting>
+SELECT ST_RelateMatch('101202FFF', 'TTTTTTFFF') ;
+-- result --
+t
+--example of common intersection matrix patterns and example matrices
+-- comparing relationships of involving one invalid geometry and ( a line and polygon that intersect at interior and boundary)
+SELECT mat.name, pat.name, ST_RelateMatch(mat.val, pat.val) As satisfied
+    FROM
+        ( VALUES ('Equality', 'T1FF1FFF1'),
+                ('Overlaps', 'T*T***T**'),
+                ('Within', 'T*F**F***'),
+                ('Disjoint', 'FF*FF****') As pat(name,val)
+        CROSS JOIN
+            (  VALUES ('Self intersections (invalid)', '111111111'),
+                    ('IE2_BI1_BB0_BE1_EI1_EE2', 'FF2101102'),
+                    ('IB1_IE1_BB0_BE0_EI2_EI1_EE2', 'F11F00212')
+            ) As mat(name,val);
+
+               </programlisting>
+       </refsection>
+
+       <!-- Optionally add a "See Also" section -->
+       <refsection>
+               <title>See Also</title>
+               <para><xref linkend="DE-9IM" />, <xref linkend="ST_Relate" /></para>
+       </refsection>
+</refentry>
+
+       <refentry id="ST_Touches">
+         <refnamediv>
+               <refname>ST_Touches</refname>
+
+               <refpurpose>Returns <varname>TRUE</varname> if the geometries have at least one point in common,
+               but their interiors do not intersect.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_Touches</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g1</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>g2</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns <varname>TRUE</varname> if the only points in common between
+               <parameter>g1</parameter> and <parameter>g2</parameter> lie in the union of the
+               boundaries of <parameter>g1</parameter> and <parameter>g2</parameter>.
+               The <function>ST_Touches</function> relation applies
+               to all Area/Area, Line/Line, Line/Area, Point/Area and Point/Line pairs of relationships,
+               but <emphasis>not</emphasis> to the Point/Point pair.</para>
+
+               <para>In mathematical terms, this predicate is expressed as:</para>
+
+               <informalfigure>
+                 <mediaobject>
+                       <imageobject>
+                         <imagedata fileref="images/st_touches-math.gif" />
+                       </imageobject>
+                 </mediaobject>
+               </informalfigure>
+
+               <para>The allowable DE-9IM Intersection Matrices for the two geometries are:</para>
+
+               <itemizedlist>
+                 <listitem>
+                       <para><markup>FT*******</markup></para>
+                 </listitem>
+
+                 <listitem>
+                       <para><markup>F**T*****</markup></para>
+                 </listitem>
+
+                 <listitem>
+                       <para><markup>F***T****</markup></para>
+                 </listitem>
+               </itemizedlist>
+
+               <important>
+                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
+               </important>
+
+               <note>
+                 <para>This function call will automatically include a bounding box
+                 comparison that will make use of any indexes that are available on
+                 the geometries.  To avoid using an index, use <function>_ST_Touches</function> instead.</para>
+               </note>
+
+               <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3</para>
+               <para>&sqlmm_compliant; SQL-MM 3: 5.1.28</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+
+               <para>The <function>ST_Touches</function> predicate returns <varname>TRUE</varname> in all the following illustrations.</para>
+               <informaltable>
+                 <tgroup cols="3">
+                       <tbody>
+                         <row>
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_touches01.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>POLYGON</varname> / <varname>POLYGON</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_touches02.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>POLYGON</varname> / <varname>POLYGON</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_touches03.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>POLYGON</varname> / <varname>LINESTRING</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+                         </row>
+                         <row>
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_touches04.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>LINESTRING</varname> / <varname>LINESTRING</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_touches05.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>LINESTRING</varname> / <varname>LINESTRING</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+
+                               <entry><para><informalfigure>
+                                       <mediaobject>
+                                         <imageobject>
+                                               <imagedata fileref="images/st_touches06.png" />
+                                         </imageobject>
+
+                                         <caption><para><varname>POLYGON</varname> / <varname>POINT</varname></para></caption>
+                                       </mediaobject>
+                                 </informalfigure></para></entry>
+                         </row>
+                       </tbody>
+                 </tgroup>
+               </informaltable>
+
+               <programlisting>SELECT ST_Touches('LINESTRING(0 0, 1 1, 0 2)'::geometry, 'POINT(1 1)'::geometry);
+ st_touches
+------------
+ f
+(1 row)
+
+SELECT ST_Touches('LINESTRING(0 0, 1 1, 0 2)'::geometry, 'POINT(0 2)'::geometry);
+ st_touches
+------------
+ t
+(1 row)</programlisting>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_Within">
+         <refnamediv>
+               <refname>ST_Within</refname>
+
+               <refpurpose>Returns true if the geometry A is completely inside geometry B</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>boolean <function>ST_Within</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>A</parameter></paramdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>B</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns TRUE if geometry A is completely inside geometry B. For this function to make
+               sense, the source geometries must both be of the same coordinate projection,
+               having the same SRID.  It is a given that if ST_Within(A,B) is true and ST_Within(B,A) is true, then
+               the two geometries are considered spatially equal.</para>
+
+               <para>Performed by the GEOS module</para>
+
+               <para>Enhanced: 2.3.0 Enhancement to PIP short-circuit for geometry extended to support MultiPoints with few points. Prior versions only supported point in polygon.</para>
+
+               <important>
+                 <para>Do not call with a <varname>GEOMETRYCOLLECTION</varname> as an argument</para>
+               </important>
+
+               <important>
+                 <para>Do not use this function with invalid geometries. You will get unexpected results.</para>
+               </important>
+
+               <para>This function call will automatically include a bounding box
+                       comparison that will make use of any indexes that are available on
+                       the geometries. To avoid index use, use the function
+                       _ST_Within.</para>
+
+               <para>NOTE: this is the "allowable" version that returns a
+                       boolean, not an integer.</para>
+
+               <para>&sfs_compliant; s2.1.1.2 // s2.1.13.3
+                 - a.Relate(b, 'T*F**F***')
+               </para>
+               <para>&sqlmm_compliant; SQL-MM 3: 5.1.30</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+                 <programlisting>
+--a circle within a circle
+SELECT ST_Within(smallc,smallc) As smallinsmall,
+       ST_Within(smallc, bigc) As smallinbig,
+       ST_Within(bigc,smallc) As biginsmall,
+       ST_Within(ST_Union(smallc, bigc), bigc) as unioninbig,
+       ST_Within(bigc, ST_Union(smallc, bigc)) as biginunion,
+       ST_Equals(bigc, ST_Union(smallc, bigc)) as bigisunion
+FROM
+(
+SELECT ST_Buffer(ST_GeomFromText('POINT(50 50)'), 20) As smallc,
+       ST_Buffer(ST_GeomFromText('POINT(50 50)'), 40) As bigc) As foo;
+--Result
+ smallinsmall | smallinbig | biginsmall | unioninbig | biginunion | bigisunion
+--------------+------------+------------+------------+------------+------------
+ t            | t          | f          | t          | t          | t
+(1 row)
+               </programlisting>
+
+               <para><inlinemediaobject>
+               <imageobject>
+                 <imagedata fileref="images/st_within01.png" />
+               </imageobject>
+         </inlinemediaobject> </para>
+         </refsection>
+
+         <refsection>
+               <title>See Also</title>
+               <para><xref linkend="ST_Contains"/>, <xref linkend="ST_Equals"/>, <xref linkend="ST_IsValid"/></para>
+         </refsection>
+       </refentry>
+
+
+</sect1>
diff --git a/doc/reference_srs.xml b/doc/reference_srs.xml
new file mode 100644 (file)
index 0000000..91b0dec
--- /dev/null
@@ -0,0 +1,277 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <sect1 id="SRS_Functions">
+    <sect1info>
+    <abstract>
+       <para>These functions work with the Spatial Reference System of geometries.</para>
+   </abstract>
+    </sect1info>
+
+         <title>Spatial Reference System Functions</title>
+
+       <refentry id="ST_SetSRID">
+         <refnamediv>
+               <refname>ST_SetSRID</refname>
+
+               <refpurpose>Set the SRID on a geometry to a particular integer
+               value.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_SetSRID</function></funcdef>
+
+                       <paramdef><type>geometry </type>
+                       <parameter>geom</parameter></paramdef>
+
+                       <paramdef><type>integer </type>
+                       <parameter>srid</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Sets the SRID on a geometry to a particular integer value.
+               Useful in constructing bounding boxes for queries.</para>
+
+               <note>
+                 <para>This function does not transform the geometry coordinates in any way -
+                 it simply sets the meta data defining the spatial reference system the geometry is assumed to be in.
+                 Use <xref linkend="ST_Transform"/> if you want to transform the
+                 geometry into a new projection.</para>
+               </note>
+               <para>&sfs_compliant;</para>
+               <para>&curve_support;</para>
+         </refsection>
+
+         <refsection>
+                       <title>Examples</title>
+                       <para>-- Mark a point as WGS 84 long lat --</para>
+                       <programlisting>SELECT ST_SetSRID(ST_Point(-123.365556, 48.428611),4326) As wgs84long_lat;
+-- the ewkt representation (wrap with ST_AsEWKT) -
+SRID=4326;POINT(-123.365556 48.428611)
+                       </programlisting>
+                       <para>-- Mark a point as WGS 84 long lat and then transform to web mercator (Spherical Mercator) --</para>
+                       <programlisting>SELECT ST_Transform(ST_SetSRID(ST_Point(-123.365556, 48.428611),4326),3785) As spere_merc;
+-- the ewkt representation (wrap with ST_AsEWKT) -
+SRID=3785;POINT(-13732990.8753491 6178458.96425423)
+                       </programlisting>
+               </refsection>
+
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="spatial_ref_sys" />, <xref linkend="ST_AsEWKT"/>,  <xref linkend="ST_SRID"/>, <xref linkend="ST_Transform"/>, <xref linkend="UpdateGeometrySRID"/></para>
+         </refsection>
+
+       </refentry>
+
+       <refentry id="ST_SRID">
+         <refnamediv>
+               <refname>ST_SRID</refname>
+               <refpurpose>Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>integer <function>ST_SRID</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns the spatial reference identifier for the ST_Geometry as defined in spatial_ref_sys table. <xref linkend="spatial_ref_sys" /></para>
+               <para><note><para>spatial_ref_sys
+               table is a table that catalogs all spatial reference systems known to PostGIS and is used for transformations from one spatial
+                       reference system to another.  So verifying you have the right spatial reference system identifier is important if you plan to ever transform your geometries.</para></note></para>
+               <para>&sfs_compliant; s2.1.1.1</para>
+               <para>&sqlmm_compliant; SQL-MM 3: 5.1.5</para>
+               <para>&curve_support;</para>
+
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>SELECT ST_SRID(ST_GeomFromText('POINT(-71.1043 42.315)',4326));
+               --result
+               4326
+               </programlisting>
+         </refsection>
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="spatial_ref_sys" />, <xref linkend="ST_GeomFromText" />, <xref linkend="ST_SetSRID" />, <xref linkend="ST_Transform" /></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_Transform">
+         <refnamediv>
+               <refname>ST_Transform</refname>
+
+               <refpurpose>Return a new geometry with its coordinates transformed to
+                       a different spatial reference system.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Transform</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
+                       <paramdef><type>integer </type> <parameter>srid</parameter></paramdef>
+                 </funcprototype>
+
+          <funcprototype>
+              <funcdef>geometry <function>ST_Transform</function></funcdef>
+              <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
+              <paramdef><type>text </type> <parameter>to_proj</parameter></paramdef>
+          </funcprototype>
+
+          <funcprototype>
+              <funcdef>geometry <function>ST_Transform</function></funcdef>
+              <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
+              <paramdef><type>text </type> <parameter>from_proj</parameter></paramdef>
+              <paramdef><type>text </type> <parameter>to_proj</parameter></paramdef>
+          </funcprototype>
+
+          <funcprototype>
+              <funcdef>geometry <function>ST_Transform</function></funcdef>
+              <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
+              <paramdef><type>text </type> <parameter>from_proj</parameter></paramdef>
+              <paramdef><type>integer </type> <parameter>to_srid</parameter></paramdef>
+          </funcprototype>
+
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+        <para>Returns a new geometry with its coordinates transformed to
+            a different spatial reference system. The destination spatial
+                       reference <varname>to_srid</varname> may be identified by a valid
+                       SRID integer parameter (i.e. it must exist in the
+                       <varname>spatial_ref_sys</varname> table).
+                       Alternatively, a spatial reference defined as a PROJ.4 string
+                       can be used for <varname>to_proj</varname> and/or
+                       <varname>from_proj</varname>, however these methods are not
+                       optimized. If the destination spatial reference system is
+                       expressed with a PROJ.4 string instead of an SRID, the SRID of the
+                       output geometry will be set to zero. With the exception of functions with
+                       <varname>from_proj</varname>, input geometries must have a defined SRID.
+               </para>
+
+               <para>ST_Transform is often confused with <xref linkend="ST_SetSRID" />.  ST_Transform actually changes the coordinates
+               of a geometry from one spatial reference system to another, while ST_SetSRID() simply changes the SRID identifier of
+               the geometry.</para>
+
+               <note>
+                 <para>Requires PostGIS be compiled with Proj support.  Use <xref linkend="PostGIS_Full_Version" /> to confirm you have proj support compiled in.</para>
+               </note>
+
+               <note>
+                 <para>If using more than one transformation, it is useful to have a functional index on the commonly used
+                       transformations to take advantage of index usage.</para>
+               </note>
+
+               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
+
+               <para>Enhanced: 2.0.0 support for Polyhedral surfaces was introduced.</para>
+               <para>Enhanced: 2.3.0 support for direct PROJ.4 text was introduced.</para>
+               <para>&sqlmm_compliant; SQL-MM 3: 5.1.6</para>
+               <para>&curve_support;</para>
+               <para>&P_support;</para>
+
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+               <para>Change Massachusetts state plane US feet geometry to WGS 84 long lat</para>
+               <programlisting>
+SELECT ST_AsText(ST_Transform(ST_GeomFromText('POLYGON((743238 2967416,743238 2967450,
+       743265 2967450,743265.625 2967416,743238 2967416))',2249),4326)) As wgs_geom;
+
+ wgs_geom
+---------------------------
+ POLYGON((-71.1776848522251 42.3902896512902,-71.1776843766326 42.3903829478009,
+-71.1775844305465 42.3903826677917,-71.1775825927231 42.3902893647987,-71.177684
+8522251 42.3902896512902));
+(1 row)
+
+--3D Circular String example
+SELECT ST_AsEWKT(ST_Transform(ST_GeomFromEWKT('SRID=2249;CIRCULARSTRING(743238 2967416 1,743238 2967450 2,743265 2967450 3,743265.625 2967416 3,743238 2967416 4)'),4326));
+
+                                st_asewkt
+--------------------------------------------------------------------------------------
+ SRID=4326;CIRCULARSTRING(-71.1776848522251 42.3902896512902 1,-71.1776843766326 42.3903829478009 2,
+ -71.1775844305465 42.3903826677917 3,
+ -71.1775825927231 42.3902893647987 3,-71.1776848522251 42.3902896512902 4)
+
+               </programlisting>
+               <para>Example of creating a partial functional index.  For tables where you are not sure all the geometries
+                       will be filled in, its best to use a partial index that leaves out null geometries which will both conserve space and make your index smaller and more efficient.</para>
+               <programlisting>
+CREATE INDEX idx_the_geom_26986_parcels
+  ON parcels
+  USING gist
+  (ST_Transform(the_geom, 26986))
+  WHERE the_geom IS NOT NULL;
+               </programlisting>
+
+               <para>Examples of using PROJ.4 text to transform with custom spatial references.</para>
+               <programlisting>
+-- Find intersection of two polygons near the North pole, using a custom Gnomic projection
+-- See http://boundlessgeo.com/2012/02/flattening-the-peel/
+ WITH data AS (
+   SELECT
+     ST_GeomFromText('POLYGON((170 50,170 72,-130 72,-130 50,170 50))', 4326) AS p1,
+     ST_GeomFromText('POLYGON((-170 68,-170 90,-141 90,-141 68,-170 68))', 4326) AS p2,
+     '+proj=gnom +ellps=WGS84 +lat_0=70 +lon_0=-160 +no_defs'::text AS gnom
+ )
+ SELECT ST_AsText(
+   ST_Transform(
+     ST_Intersection(ST_Transform(p1, gnom), ST_Transform(p2, gnom)),
+   gnom, 4326))
+ FROM data;
+                                          st_astext
+ --------------------------------------------------------------------------------
+  POLYGON((-170 74.053793645338,-141 73.4268621378904,-141 68,-170 68,-170 74.053793645338))
+               </programlisting>
+
+         </refsection>
+         <refsection>
+               <title>Configuring transformation behaviour</title>
+                       <para>Sometimes coordinate transformation involving a grid-shift
+                               can fail, for example if PROJ.4 has not been built with
+                               grid-shift files or the coordinate does not lie within the
+                               range for which the grid shift is defined. By default, PostGIS
+                               will throw an error if a grid shift file is not present, but
+                               this behaviour can be configured on a per-SRID basis either
+                               by testing different <varname>to_proj</varname> values of
+                               PROJ.4 text, or altering the <varname>proj4text</varname> value
+                               within the <varname>spatial_ref_sys</varname> table.
+                       </para>
+                               <para>For example, the proj4text parameter +datum=NAD87 is a shorthand form for the following +nadgrids parameter:</para>
+                               <programlisting>+nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat</programlisting>
+                               <para>The @ prefix means no error is reported if the files are not present, but if the end of the list is reached with no file having been appropriate (ie. found and overlapping) then an error is issued.</para>
+                               <para>If, conversely, you wanted to ensure that at least the standard files were present, but that if all files were scanned without a hit a null transformation is applied you could use:</para>
+                               <programlisting>+nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat,null</programlisting>
+                               <para>The null grid shift file is a valid grid shift file covering the whole world and applying no shift. So for a complete example, if you wanted to alter PostGIS so that transformations to SRID 4267 that didn't lie within the correct range did not throw an ERROR, you would use the following:</para>
+                               <programlisting>UPDATE spatial_ref_sys SET proj4text = '+proj=longlat +ellps=clrk66 +nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat,null +no_defs' WHERE srid = 4267;</programlisting>
+                 </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="PostGIS_Full_Version" />, <xref linkend="ST_AsText" />, <xref linkend="ST_SetSRID" />, <xref linkend="UpdateGeometrySRID"/></para>
+         </refsection>
+       </refentry>
+
+  </sect1>
index 76f1f6ff41bad4a59a8cd06f2c4a72c0313cfef4..c5f1d5016ddf02bf9b865fd65fd56b04896b4bed 100644 (file)
@@ -3,7 +3,8 @@
     <sect1info>
     <abstract>
 
-         <para>These functions implement locking to support long transactions.  This mechanism is required by the
+         <para>These functions implement a row locking mechanism to support long transactions.
+               They are provided primarily for implementors of the
                <ulink url="http://www.opengeospatial.org/standards/wfs">Web Feature Service</ulink> specification.</para>
 
     </abstract>
diff --git a/doc/reference_transformation.xml b/doc/reference_transformation.xml
new file mode 100644 (file)
index 0000000..887eb2f
--- /dev/null
@@ -0,0 +1,636 @@
+<?xml version="1.0" encoding="UTF-8"?>
+  <sect1 id="Affine_Transformation">
+    <sect1info>
+    <abstract>
+       <para>These functions change the position and shape of geometries using
+       <ulink url="https://en.wikipedia.org/wiki/Affine_transformation">affine transformations</ulink>.</para>
+   </abstract>
+    </sect1info>
+
+         <title>Affine Transformations</title>
+
+       <refentry id="ST_Affine">
+         <refnamediv>
+               <refname>ST_Affine</refname>
+
+               <refpurpose>Apply a 3D affine transformation to a geometry.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Affine</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>a</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>b</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>c</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>d</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>e</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>f</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>g</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>h</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>i</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>xoff</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>yoff</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>zoff</parameter></paramdef>
+                 </funcprototype>
+
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Affine</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>a</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>b</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>d</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>e</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>xoff</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>yoff</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Applies a 3D affine transformation to the geometry to do things like translate, rotate, scale in one step.</para>
+               <para>
+               Version 1: The
+                       call <programlisting>ST_Affine(geom, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff) </programlisting>
+                       represents the transformation matrix <programlisting>/ a  b  c  xoff \
+| d  e  f  yoff |
+| g  h  i  zoff |
+\ 0  0  0     1 /</programlisting> and the vertices are transformed as
+                       follows: <programlisting>x' = a*x + b*y + c*z + xoff
+y' = d*x + e*y + f*z + yoff
+z' = g*x + h*y + i*z + zoff</programlisting> All of the translate / scale
+                       functions below are expressed via such an affine
+                       transformation.</para>
+               <para>Version 2: Applies a 2d affine transformation to the geometry. The
+                       call <programlisting>ST_Affine(geom, a, b, d, e, xoff, yoff)</programlisting>
+                       represents the transformation matrix <programlisting>/  a  b  0  xoff  \       /  a  b  xoff  \
+|  d  e  0  yoff  | rsp.  |  d  e  yoff  |
+|  0  0  1     0  |       \  0  0     1  /
+\  0  0  0     1  /</programlisting> and the vertices are transformed as
+                       follows: <programlisting>x' = a*x + b*y + xoff
+y' = d*x + e*y + yoff
+z' = z </programlisting> This method is a subcase of the 3D method
+                       above.</para>
+
+               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
+               <para>Availability: 1.1.2. Name changed from Affine to ST_Affine in 1.2.2</para>
+               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
+
+               <para>&P_support;</para>
+               <para>&T_support;</para>
+               <para>&Z_support;</para>
+               <para>&curve_support;</para>
+         </refsection>
+
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>
+--Rotate a 3d line 180 degrees about the z axis.  Note this is long-hand for doing ST_Rotate();
+ SELECT ST_AsEWKT(ST_Affine(the_geom,  cos(pi()), -sin(pi()), 0,  sin(pi()), cos(pi()), 0,  0, 0, 1,  0, 0, 0)) As using_affine,
+        ST_AsEWKT(ST_Rotate(the_geom, pi())) As using_rotate
+       FROM (SELECT ST_GeomFromEWKT('LINESTRING(1 2 3, 1 4 3)') As the_geom) As foo;
+        using_affine         |        using_rotate
+-----------------------------+-----------------------------
+ LINESTRING(-1 -2 3,-1 -4 3) | LINESTRING(-1 -2 3,-1 -4 3)
+(1 row)
+
+--Rotate a 3d line 180 degrees in both the x and z axis
+SELECT ST_AsEWKT(ST_Affine(the_geom, cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), -sin(pi()), 0, sin(pi()), cos(pi()), 0, 0, 0))
+       FROM (SELECT ST_GeomFromEWKT('LINESTRING(1 2 3, 1 4 3)') As the_geom) As foo;
+           st_asewkt
+-------------------------------
+ LINESTRING(-1 -2 -3,-1 -4 -3)
+(1 row)
+               </programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Rotate" />, <xref linkend="ST_Scale" />, <xref linkend="ST_Translate" />, <xref linkend="ST_TransScale" /></para>
+         </refsection>
+       </refentry>
+
+
+       <refentry id="ST_Rotate">
+         <refnamediv>
+               <refname>ST_Rotate</refname>
+
+               <refpurpose>Rotates a geometry about an origin point.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Rotate</function></funcdef>
+                       <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
+                 </funcprototype>
+
+                 <funcprototype>
+                        <funcdef>geometry <function>ST_Rotate</function></funcdef>
+                        <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
+                        <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
+                        <paramdef><type>float</type> <parameter>x0</parameter></paramdef>
+                        <paramdef><type>float</type> <parameter>y0</parameter></paramdef>
+                  </funcprototype>
+
+                 <funcprototype>
+                        <funcdef>geometry <function>ST_Rotate</function></funcdef>
+                        <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
+                        <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
+                        <paramdef><type>geometry</type> <parameter>pointOrigin</parameter></paramdef>
+                  </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Rotates geometry rotRadians counter-clockwise about the origin point. The rotation origin can be
+                       specified either as a POINT geometry, or as x and y coordinates. If the origin is not
+                       specified, the geometry is rotated about POINT(0 0).</para>
+
+               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
+               <para>Enhanced: 2.0.0 additional parameters for specifying the origin of rotation were added.</para>
+               <para>Availability: 1.1.2. Name changed from Rotate to ST_Rotate in 1.2.2</para>
+               <para>&Z_support;</para>
+               <para>&curve_support;</para>
+               <para>&P_support;</para>
+               <para>&T_support;</para>
+
+         </refsection>
+
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>
+--Rotate 180 degrees
+SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi()));
+               st_asewkt
+---------------------------------------
+ LINESTRING(-50 -160,-50 -50,-100 -50)
+(1 row)
+
+--Rotate 30 degrees counter-clockwise at x=50, y=160
+SELECT ST_AsEWKT(ST_Rotate('LINESTRING (50 160, 50 50, 100 50)', pi()/6, 50, 160));
+                                 st_asewkt
+---------------------------------------------------------------------------
+ LINESTRING(50 160,105 64.7372055837117,148.301270189222 89.7372055837117)
+(1 row)
+
+--Rotate 60 degrees clockwise from centroid
+SELECT ST_AsEWKT(ST_Rotate(geom, -pi()/3, ST_Centroid(geom)))
+FROM (SELECT 'LINESTRING (50 160, 50 50, 100 50)'::geometry AS geom) AS foo;
+                           st_asewkt
+--------------------------------------------------------------
+ LINESTRING(116.4225 130.6721,21.1597 75.6721,46.1597 32.3708)
+(1 row)
+               </programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Affine" />, <xref linkend="ST_RotateX" />, <xref linkend="ST_RotateY" />, <xref linkend="ST_RotateZ" /></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_RotateX">
+         <refnamediv>
+               <refname>ST_RotateX</refname>
+
+               <refpurpose>Rotates a geometry about the X axis.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_RotateX</function></funcdef>
+                       <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Rotates a geometry geomA - rotRadians about the X axis.</para>
+
+               <note><para><code>ST_RotateX(geomA,  rotRadians)</code>
+                       is short-hand for <code>ST_Affine(geomA, 1, 0, 0, 0, cos(rotRadians), -sin(rotRadians), 0, sin(rotRadians), cos(rotRadians), 0, 0, 0)</code>.</para></note>
+
+               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
+               <para>Availability: 1.1.2. Name changed from RotateX to ST_RotateX in 1.2.2</para>
+               <para>&P_support;</para>
+               <para>&Z_support;</para>
+               <para>&T_support;</para>
+         </refsection>
+
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>
+--Rotate a line 90 degrees along x-axis
+SELECT ST_AsEWKT(ST_RotateX(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
+                st_asewkt
+---------------------------
+ LINESTRING(1 -3 2,1 -1 1)
+</programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Affine" />, <xref linkend="ST_RotateY" />, <xref linkend="ST_RotateZ" /></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_RotateY">
+         <refnamediv>
+               <refname>ST_RotateY</refname>
+
+               <refpurpose>Rotates a geometry about the Y axis.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_RotateY</function></funcdef>
+                       <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Rotates a geometry geomA - rotRadians about the y axis.</para>
+
+               <note><para><code>ST_RotateY(geomA,  rotRadians)</code>
+                       is short-hand for <code>ST_Affine(geomA,  cos(rotRadians), 0, sin(rotRadians),  0, 1, 0,  -sin(rotRadians), 0, cos(rotRadians), 0,  0, 0)</code>.</para></note>
+
+               <para>Availability: 1.1.2. Name changed from RotateY to ST_RotateY in 1.2.2</para>
+               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
+
+               <para>&P_support;</para>
+               <para>&Z_support;</para>
+               <para>&T_support;</para>
+
+         </refsection>
+
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>
+--Rotate a line 90 degrees along y-axis
+ SELECT ST_AsEWKT(ST_RotateY(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
+                st_asewkt
+---------------------------
+ LINESTRING(3 2 -1,1 1 -1)
+</programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Affine" />, <xref linkend="ST_RotateX" />, <xref linkend="ST_RotateZ" /></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_RotateZ">
+         <refnamediv>
+               <refname>ST_RotateZ</refname>
+
+               <refpurpose>Rotates a geometry about the Z axis.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_RotateZ</function></funcdef>
+                       <paramdef><type>geometry</type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>rotRadians</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Rotates a geometry geomA - rotRadians about the Z axis.</para>
+
+               <note><para>This is a synonym for ST_Rotate</para></note>
+               <note><para><code>ST_RotateZ(geomA,  rotRadians)</code>
+                       is short-hand for <code>SELECT ST_Affine(geomA,  cos(rotRadians), -sin(rotRadians), 0,  sin(rotRadians), cos(rotRadians), 0,  0, 0, 1,  0, 0, 0)</code>.</para></note>
+
+               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
+
+               <para>Availability: 1.1.2. Name changed from RotateZ to ST_RotateZ in 1.2.2</para>
+               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
+
+               <para>&Z_support;</para>
+               <para>&curve_support;</para>
+               <para>&P_support;</para>
+               <para>&T_support;</para>
+         </refsection>
+
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>
+--Rotate a line 90 degrees along z-axis
+SELECT ST_AsEWKT(ST_RotateZ(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), pi()/2));
+                st_asewkt
+---------------------------
+ LINESTRING(-2 1 3,-1 1 1)
+
+ --Rotate a curved circle around z-axis
+SELECT ST_AsEWKT(ST_RotateZ(the_geom, pi()/2))
+FROM (SELECT ST_LineToCurve(ST_Buffer(ST_GeomFromText('POINT(234 567)'), 3)) As the_geom) As foo;
+
+                                                                                                          st_asewkt
+----------------------------------------------------------------------------------------------------------------------------
+ CURVEPOLYGON(CIRCULARSTRING(-567 237,-564.87867965644 236.12132034356,-564 234,-569.12132034356 231.87867965644,-567 237))
+
+</programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Affine" />, <xref linkend="ST_RotateX" />, <xref linkend="ST_RotateY" /></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_Scale">
+         <refnamediv>
+               <refname>ST_Scale</refname>
+
+               <refpurpose>Scales a geometry by given factors.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Scale</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>XFactor</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>YFactor</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>ZFactor</parameter></paramdef>
+                 </funcprototype>
+
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Scale</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>XFactor</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>YFactor</parameter></paramdef>
+                 </funcprototype>
+
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Scale</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
+                       <paramdef><type>geometry</type> <parameter>factor</parameter></paramdef>
+                 </funcprototype>
+
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Scale</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
+                       <paramdef><type>geometry</type> <parameter>factor</parameter></paramdef>
+                       <paramdef><type>geometry</type> <parameter>origin</parameter></paramdef>
+                 </funcprototype>
+
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Scales the geometry to a new size by multiplying the
+                       ordinates with the corresponding factor parameters.
+               </para>
+
+               <para>
+The version taking a geometry as the <varname>factor</varname> parameter
+allows passing a 2d, 3dm, 3dz or 4d point to set scaling factor for all
+supported dimensions. Missing dimensions in the <varname>factor</varname>
+point are equivalent to no scaling the corresponding dimension.
+    </para>
+    <para>
+        The three-geometry variant allows a "false origin" for the scaling to be passed in. This allows "scaling in place", for example using the centroid of the geometry as the false origin. Without a false origin, scaling takes place relative to the actual origin, so all coordinates are just multipled by the scale factor.
+    </para>
+
+               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
+
+
+               <para>Availability: 1.1.0.</para>
+               <para>Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
+                <para>Enhanced: 2.2.0 support for scaling all dimension (<varname>factor</varname> parameter) was introduced.</para>
+                <para>Enhanced: 2.5.0 support for scaling relative to a local origin (<varname>origin</varname> parameter) was introduced.</para>
+               <para>&P_support;</para>
+               <para>&Z_support;</para>
+               <para>&curve_support;</para>
+               <para>&T_support;</para>
+               <para>&M_support;</para>
+         </refsection>
+
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>--Version 1: scale X, Y, Z
+SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 0.75, 0.8));
+                         st_asewkt
+--------------------------------------
+ LINESTRING(0.5 1.5 2.4,0.5 0.75 0.8)
+
+--Version 2: Scale X Y
+ SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 0.75));
+                       st_asewkt
+----------------------------------
+ LINESTRING(0.5 1.5 3,0.5 0.75 1)
+
+--Version 3: Scale X Y Z M
+ SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3 4, 1 1 1 1)'),
+   ST_MakePoint(0.5, 0.75, 2, -1)));
+                              st_asewkt
+----------------------------------------
+ LINESTRING(0.5 1.5 6 -4,0.5 0.75 2 -1)
+
+--Version 4: Scale X Y using false origin
+SELECT ST_AsText(ST_Scale('LINESTRING(1 1, 2 2)', 'POINT(2 2)', 'POINT(1 1)'::geometry));
+      st_astext
+---------------------
+ LINESTRING(1 1,3 3)
+
+</programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Affine" />, <xref linkend="ST_TransScale" /></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_Translate">
+         <refnamediv>
+               <refname>ST_Translate</refname>
+
+               <refpurpose>Translates a geometry by given offsets.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Translate</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>deltax</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>deltay</parameter></paramdef>
+                 </funcprototype>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_Translate</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>deltax</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>deltay</parameter></paramdef>
+                       <paramdef><type>float </type> <parameter>deltaz</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Returns a new geometry whose coordinates are translated delta x,delta y,delta z units. Units are
+               based on the units defined in spatial reference (SRID) for this geometry.</para>
+
+               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
+
+               <para>Availability: 1.2.2</para>
+               <para>&Z_support;</para>
+               <para>&curve_support;</para>
+         </refsection>
+
+         <refsection>
+               <title>Examples</title>
+               <para>Move a point 1 degree longitude</para>
+               <programlisting>
+       SELECT ST_AsText(ST_Translate(ST_GeomFromText('POINT(-71.01 42.37)',4326),1,0)) As wgs_transgeomtxt;
+
+       wgs_transgeomtxt
+       ---------------------
+       POINT(-70.01 42.37)
+               </programlisting>
+               <para>Move a linestring 1 degree longitude and 1/2 degree latitude</para>
+               <programlisting>SELECT ST_AsText(ST_Translate(ST_GeomFromText('LINESTRING(-71.01 42.37,-71.11 42.38)',4326),1,0.5)) As wgs_transgeomtxt;
+                  wgs_transgeomtxt
+       ---------------------------------------
+       LINESTRING(-70.01 42.87,-70.11 42.88)
+               </programlisting>
+               <para>Move a 3d point</para>
+               <programlisting>SELECT ST_AsEWKT(ST_Translate(CAST('POINT(0 0 0)' As geometry), 5, 12,3));
+       st_asewkt
+       ---------
+       POINT(5 12 3)
+               </programlisting>
+               <para>Move a curve and a point</para>
+<programlisting>SELECT ST_AsText(ST_Translate(ST_Collect('CURVEPOLYGON(CIRCULARSTRING(4 3,3.12 0.878,1 0,-1.121 5.1213,6 7, 8 9,4 3))','POINT(1 3)'),1,2));
+                                                                                                                st_astext
+------------------------------------------------------------------------------------------------------------
+ GEOMETRYCOLLECTION(CURVEPOLYGON(CIRCULARSTRING(5 5,4.12 2.878,2 2,-0.121 7.1213,7 9,9 11,5 5)),POINT(2 5))
+</programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+               <para><xref linkend="ST_Affine" />, <xref linkend="ST_AsText" />, <xref linkend="ST_GeomFromText" /></para>
+         </refsection>
+       </refentry>
+
+       <refentry id="ST_TransScale">
+         <refnamediv>
+               <refname>ST_TransScale</refname>
+
+               <refpurpose>Translates and scales a geometry by given offsets and factors.</refpurpose>
+         </refnamediv>
+
+         <refsynopsisdiv>
+               <funcsynopsis>
+                 <funcprototype>
+                       <funcdef>geometry <function>ST_TransScale</function></funcdef>
+                       <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>deltaX</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>deltaY</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>XFactor</parameter></paramdef>
+                       <paramdef><type>float</type> <parameter>YFactor</parameter></paramdef>
+                 </funcprototype>
+               </funcsynopsis>
+         </refsynopsisdiv>
+
+         <refsection>
+               <title>Description</title>
+
+               <para>Translates the geometry using the deltaX and deltaY args,
+                       then scales it using the XFactor, YFactor args, working in 2D only.</para>
+
+               <note><para><code>ST_TransScale(geomA, deltaX, deltaY, XFactor, YFactor)</code>
+                       is short-hand for <code>ST_Affine(geomA, XFactor, 0, 0, 0, YFactor, 0,
+                       0, 0, 1, deltaX*XFactor, deltaY*YFactor, 0)</code>.</para></note>
+
+               <note><para>Prior to 1.3.4, this function crashes if used with geometries that contain CURVES.  This is fixed in 1.3.4+</para></note>
+
+
+               <para>Availability: 1.1.0.</para>
+               <para>&Z_support;</para>
+               <para>&curve_support;</para>
+         </refsection>
+
+
+         <refsection>
+               <title>Examples</title>
+
+               <programlisting>SELECT ST_AsEWKT(ST_TransScale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 0.5, 1, 1, 2));
+                 st_asewkt
+-----------------------------
+ LINESTRING(1.5 6 3,1.5 4 1)
+
+
+--Buffer a point to get an approximation of a circle, convert to curve and then translate 1,2 and scale it 3,4
+  SELECT ST_AsText(ST_Transscale(ST_LineToCurve(ST_Buffer('POINT(234 567)', 3)),1,2,3,4));
+                                                                                                                 st_astext
+------------------------------------------------------------------------------------------------------------------------------
+ CURVEPOLYGON(CIRCULARSTRING(714 2276,711.363961030679 2267.51471862576,705 2264,698.636038969321 2284.48528137424,714 2276))
+
+</programlisting>
+         </refsection>
+
+         <!-- Optionally add a "See Also" section -->
+         <refsection>
+               <title>See Also</title>
+
+               <para><xref linkend="ST_Affine" />, <xref linkend="ST_Translate" /></para>
+         </refsection>
+       </refentry>
+
+
+
+  </sect1>