<!-- Converted by db4-upgrade version 1.1 -->
<section xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="Geometry_Accessors">
        <title>Geometry Accessors</title><info>
        <abstract>
        <para>These functions expose structural information about an existing geometry
        without changing it. They provide access to metadata such as geometry
        type, dimensionality, or coordinate components so that spatial
        expressions can interrogate complex objects in a controlled way.</para>
        </abstract>
        </info>

	<refentry xml:id="GeometryType">
	  <refnamediv>
		<refname>GeometryType</refname>

		<refpurpose>Returns the type of a geometry as text.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>text <function>GeometryType</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the type of the geometry as a string. Eg:
		'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.</para>

		<para>OGC SPEC s2.1.1.1 - Returns the name of the instantiable
		subtype of Geometry of which this Geometry instance is a member.
		The name of the instantiable subtype of Geometry is returned as a
		string.</para>

		<note>
		  <para>This function also indicates if the geometry is measured,
		  by returning a string of the form 'POINTM'.</para>
		</note>
		<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
		<para>&sfs_compliant;</para>
		<para>&curve_support;</para>
		<para>&Z_support;</para>
		<para>&P_support;</para>
		<para>&T_support;</para>

	  </refsection>


	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT GeometryType('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'::geometry);</programlisting>
<screen role="visual-primary text-primary">LINESTRING</screen>
		<programlisting>SELECT ST_GeometryType('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)) )');
    POLYHEDRALSURFACE
            </programlisting>
<programlisting>SELECT GeometryType(geom) as result
FROM
  (SELECT
     'TIN (((
              0 0 0,
              0 0 1,
              0 1 0,
              0 0 0
          )),((
              0 0 0,
              0 1 0,
              1 1 0,
              0 0 0
          ))
          )'::geometry  AS geom
  ) AS g;</programlisting>
<screen role="visual-primary text-primary">TIN</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>
		<para><xref linkend="ST_GeometryType"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_Boundary">
	  <refnamediv>
		<refname>ST_Boundary</refname>

		<refpurpose>Returns the boundary of a geometry.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_Boundary</function></funcdef>

			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the closure of the combinatorial boundary of this
			Geometry. The combinatorial boundary is defined as described in
			section 3.12.3.2 of the OGC SPEC. Because the result of this
			function is a closure, and hence topologically closed, the
			resulting boundary can be represented using representational
			geometry primitives as discussed in the OGC SPEC, section
			3.12.2.</para>
		<para>Performed by the GEOS module</para>

		<note> <para>Prior to 2.0.0, this function throws an exception if used with <varname>GEOMETRYCOLLECTION</varname>. From 2.0.0 up it will return NULL instead (unsupported input).</para></note>

		<para>&sfs_compliant; OGC SPEC s2.1.1.1</para>
        <para>&sqlmm_compliant; SQL-MM IEC 13249-3: 5.1.17</para>
		<para>&Z_support;</para>
		<para role="enhanced" conformance="2.1.0">Enhanced: 2.1.0 support for Triangle was introduced</para>
		<para role="changed" conformance="3.2.0">Changed: 3.2.0 support for TIN, does not use geos, does not linearize curves</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

		<para>LineString with boundary points overlaid.</para>
				<programlisting language="sql">SELECT ST_Boundary(geom)
FROM (SELECT 'LINESTRING(100 150,50 60,70 80,160 170)'::geometry As geom) As f;
                </programlisting>
<screen role="visual-primary text-primary">
MULTIPOINT((100 150),(160 170))
</screen>

		<para>Polygon holes with the boundary MultiLineString overlaid.</para>
				<programlisting language="sql">SELECT ST_Boundary(geom)
FROM (SELECT
'POLYGON (( 10 130,50 190,110 190,140 150,150 80,100 10,20 40,10 130 ),
    ( 70 40,100 50,120 80,80 110,50 90,70 40 ))'::geometry As geom) As f;
                </programlisting>
<screen role="visual-primary text-primary">
MULTILINESTRING((10 130,50 190,110 190,140 150,150 80,100 10,20 40,10 130),
        (70 40,100 50,120 80,80 110,50 90,70 40))
</screen>

		 <programlisting>SELECT ST_Boundary('LINESTRING(1 1,0 0,-1 1)');</programlisting>
<screen role="visual-primary text-primary">MULTIPOINT((1 1),(-1 1))</screen>
<programlisting>SELECT ST_Boundary('POLYGON((1 1,0 0,-1 1,1 1))');</programlisting>
<screen role="visual-primary text-primary">LINESTRING(1 1,0 0,-1 1,1 1)</screen>
<para>This example uses a 3D polygon.</para>
<programlisting>SELECT ST_Boundary('POLYGON((1 1 1,0 0 1,-1 1 1,1 1 1))');</programlisting>
<screen role="visual-primary text-primary">LINESTRING(1 1 1,0 0 1,-1 1 1,1 1 1)</screen>
<para>This example uses a 3D MultiLineString.</para>
<programlisting>SELECT ST_Boundary('MULTILINESTRING((1 1 1,0 0 0.5,-1 1 1),(1 1 0.5,0 0 0.5,-1 1 0.5,1 1 0.5) )');</programlisting>
<screen role="visual-primary text-primary">MULTIPOINT(1 1 1,-1 1 1)</screen>
		</refsection>
		<refsection>
			<title>See Also</title>

			<para><xref linkend="ST_AsText"/>, <xref linkend="ST_ExteriorRing"/>, <xref linkend="ST_MakePolygon"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_BoundingDiagonal">
		  <refnamediv>
			<refname>ST_BoundingDiagonal</refname>

			<refpurpose>Returns the diagonal of a geometry's bounding box.</refpurpose>
		  </refnamediv>

		  <refsynopsisdiv>
			<funcsynopsis>
			  <funcprototype>
				<funcdef>geometry <function>ST_BoundingDiagonal</function></funcdef>

				<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
				<paramdef choice="opt"><type>boolean </type> <parameter>fits=false</parameter></paramdef>
			  </funcprototype>
			</funcsynopsis>
		  </refsynopsisdiv>

		  <refsection>
			<title>Description</title>

			<para>
Returns the diagonal of the supplied geometry's bounding box as a LineString.
The diagonal is a 2-point LineString with the minimum values of each dimension in its
start point and the maximum values in its end point.
If the input geometry is empty, the diagonal line is a LINESTRING EMPTY.
			</para>

			<para>
The optional <varname>fits</varname> parameter specifies if the best fit is needed.
If false, the diagonal of a somewhat larger bounding box can be accepted
(which is faster to compute for geometries with many vertices). In either case,
the bounding box of the returned diagonal line always covers the input
geometry.
			</para>

			<para>
The returned geometry retains the SRID and dimensionality
(Z and M presence) of the input geometry.
			</para>

			<note><para>
In degenerate cases (i.e. a single vertex in input) the returned linestring
will be formally invalid (no interior).
The result is still topologically valid.
			</para></note>

			<para role="availability" conformance="2.2.0">Availability: 2.2.0</para>
			<para>&Z_support;</para>
			<para>&M_support;</para>
		</refsection>

	  <refsection>
		<title>Examples</title>

		<para>This example shows a polygon together with the diagonal of its bounding box.</para>
		<programlisting>WITH input AS (
  SELECT 'POLYGON((10 20,30 60,70 40,90 10,50 -10,10 20))'::geometry AS geom
)
SELECT geom AS input_polygon,
       ST_BoundingDiagonal(geom) AS diagonal
FROM input;</programlisting>
<screen role="visual-overlay visual-primary text-primary">POLYGON((10 20,30 60,70 40,90 10,50 -10,10 20)) | LINESTRING(10 -10,90 60)</screen>

		<para>This example returns the minimum X coordinate of a buffer around a point.</para>
		<programlisting>
SELECT ST_X(ST_StartPoint(ST_BoundingDiagonal(
  ST_Buffer(ST_Point(0, 0), 10)
)));</programlisting>
<screen>-10</screen>
		</refsection>
	  <refsection>
		<title>See Also</title>
		<para>
<xref linkend="ST_StartPoint"/>,
<xref linkend="ST_EndPoint"/>,
<xref linkend="ST_X"/>,
<xref linkend="ST_Y"/>,
<xref linkend="ST_Z"/>,
<xref linkend="ST_M"/>,
<xref linkend="ST_Envelope"/>
		</para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_CoordDim">
	  <refnamediv>
		<refname>ST_CoordDim</refname>

		<refpurpose>Return the coordinate dimension of a geometry.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_CoordDim</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Return the coordinate dimension of the ST_Geometry value.</para>

		<para>This is the MM compliant alias name for <xref linkend="ST_NDims"/></para>

		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant; SQL-MM 3: 5.1.3</para>
		<para>&curve_support;</para>
		<para>&Z_support;</para>
		<para>&P_support;</para>
		<para>&T_support;</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_CoordDim('CIRCULARSTRING(1 2 3,1 3 4,5 6 7,8 9 10,11 12 13)');</programlisting>
<screen>3</screen>
		<programlisting>SELECT ST_CoordDim(ST_Point(1, 2));</programlisting>
<screen>2</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_NDims"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_Dimension">
	  <refnamediv>
		<refname>ST_Dimension</refname>

		<refpurpose>Returns the topological dimension of a geometry. </refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_Dimension</function></funcdef>

			<paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Return the topological dimension of this Geometry object, which must
			be less than or equal to the coordinate dimension. OGC SPEC
			s2.1.1.1 - returns 0 for <varname>POINT</varname>, 1 for <varname>LINESTRING</varname>, 2 for <varname>POLYGON</varname>, and
			the largest dimension of the components of a
			<varname>GEOMETRYCOLLECTION</varname>.
			If the dimension is unknown (e.g. for an empty <varname>GEOMETRYCOLLECTION</varname>) 0 is returned.
		</para>

		<para>&sqlmm_compliant; SQL-MM 3: 5.1.2</para>
		<note>
		  <para>
			A <varname>TIN</varname>, including a closed TIN surface, is a
			surface geometry and has dimension 2.  Use
			<xref linkend="CG_MakeSolid"/> to make the solid representation
			explicit; the resulting 3D solid has dimension 3.  Solid geometry
			semantics, such as volume, are handled separately by the SQL/MM 3D
			solid functions (SQL-MM IEC 13249-3: 9.1).
		  </para>
		</note>
		<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces and TINs was introduced. No longer throws an exception if given empty geometry.</para>
		<note> <para>Prior to 2.0.0, this function throws an exception if used with empty geometry. </para></note>
		<para>&P_support;</para>
		<para>&T_support;</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

		 <programlisting>SELECT ST_Dimension('GEOMETRYCOLLECTION(LINESTRING(1 1,0 0), POINT(0 0))');</programlisting>
<screen>1</screen>
		 <programlisting>SELECT ST_Dimension('TIN Z (((0 0 0,0 0 1,0 1 0,0 0 0)),((0 0 0,0 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,0 0 1,0 0 0)),((1 0 0,0 1 0,0 0 1,1 0 0)))');</programlisting>
<screen>2</screen>
		</refsection>
		<refsection>
			<title>See Also</title>

			<para><xref linkend="ST_NDims"/>, <xref linkend="CG_MakeSolid"/>, <xref linkend="CG_Volume"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_Dump">
	  <refnamediv>
		<refname>ST_Dump</refname>
		<refpurpose>Returns a set of <varname>geometry_dump</varname> rows for the components of a geometry.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry_dump[] <function>ST_Dump</function></funcdef>
			<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>
			<para>A set-returning function (SRF) that extracts the components of a geometry.
            It returns a set of
			<xref linkend="geometry_dump"/> rows,
            each containing a geometry (<parameter>geom</parameter> field)
            and an array of integers (<parameter>path</parameter> field).
            </para>

            <para>For an atomic geometry type
			(POINT,LINESTRING,POLYGON) a single record is returned with
			an empty <parameter>path</parameter> array and the input geometry as <parameter>geom</parameter>.
            For a collection or multi-geometry a record is returned for each
			of the collection components, and the <parameter>path</parameter> denotes the
			position of the component inside the collection.</para>

			<para>ST_Dump is useful for expanding geometries. It is the
			inverse of a <xref linkend="ST_Collect"/> / GROUP BY, in that it creates new rows.
            For example it can be use to expand MULTIPOLYGONS into POLYGONS.</para>

			<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
			<para role="availability" conformance="1.0.0">Availability: PostGIS 1.0.0RC1. Requires PostgreSQL 7.3 or higher.</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>&curve_support;</para>
            <para>&P_support;</para>
            <para>&T_support;</para>
            <para>&Z_support;</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>
	<para>Dump the components of geometries stored in a table.</para>
	<programlisting>SELECT sometable.field1,
       (ST_Dump(sometable.geom)).geom AS geom
FROM sometable;</programlisting>

	<para>Break a CompoundCurve into its constituent LineStrings and CircularStrings.</para>
	<programlisting>
SELECT a.geom, ST_HasArc(a.geom)
  FROM ( SELECT (ST_Dump(p_geom)).geom AS geom
         FROM (SELECT 'COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))'::geometry AS p_geom) AS b
        ) AS a;</programlisting>
<screen>          st_asewkt          | st_hasarc
-----------------------------+----------
 CIRCULARSTRING(0 0,1 1,1 0) | t
 LINESTRING(1 0,0 1)         | f
(2 rows)</screen>

<para>This example breaks a PolyhedralSurface into its faces.</para>
<programlisting>
SELECT (a.p_geom).path[1] As path,(a.p_geom).geom As geom_ewkt
  FROM (SELECT ST_Dump('POLYHEDRALSURFACE(
((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1))
)' ) AS p_geom )  AS a;</programlisting>
<screen> path |                geom_ewkt
------+------------------------------------------
    1 | POLYGON((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0))
    2 | POLYGON((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0))
    3 | POLYGON((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0))
    4 | POLYGON((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0))
    5 | POLYGON((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0))
    6 | POLYGON((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1))</screen>

<para>This example uses a TIN geometry.</para>
<programlisting language="sql">
SELECT (g.gdump).path,(g.gdump).geom as wkt
  FROM
    (SELECT
       ST_Dump('TIN (((
                0 0 0,
                0 0 1,
                0 1 0,
                0 0 0
            )),((
                0 0 0,
                0 1 0,
                1 1 0,
                0 0 0
            ))
            )' ) AS gdump
    ) AS g;</programlisting>
<screen> path |                 wkt
------+-------------------------------------
 {1}  | TRIANGLE((0 0 0,0 0 1,0 1 0,0 0 0))
 {2}  | TRIANGLE((0 0 0,0 1 0,1 1 0,0 0 0))
</screen>
	  </refsection>
	  <refsection>
		<title>See Also</title>
		<para><xref linkend="geometry_dump"/>, <xref linkend="PostGIS_Geometry_DumpFunctions"/>, <xref linkend="ST_Collect"/>, <xref linkend="ST_GeometryN"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_DumpPoints">
		<refnamediv>
			<refname>ST_DumpPoints</refname>
			<refpurpose>Returns a set of <varname>geometry_dump</varname> rows for the coordinates in a geometry.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
				<funcdef>geometry_dump[] <function>ST_DumpPoints</function></funcdef>
				<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
			</funcprototype>
		</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>A set-returning function (SRF) that extracts the coordinates (vertices) of a geometry.
            It returns a set of
			    <xref linkend="geometry_dump"/> rows,
                each containing a geometry (<parameter>geom</parameter> field)
                and an array of integers (<parameter>path</parameter> field).
            </para>

            <itemizedlist>
            <listitem>
                <para>the <parameter>geom</parameter> field
                    <varname>POINT</varname>s represent the coordinates of the supplied geometry.
                </para>
            </listitem>
            <listitem>
                <para>the <parameter>path</parameter> field (an <varname>integer[]</varname>)
                    is an index enumerating the coordinate positions in the elements of the supplied geometry.
                    The indices are 1-based.
                    For example, for a <varname>LINESTRING</varname> the paths are <varname>{i}</varname>
                    where <varname>i</varname> is the <varname>nth</varname>
                    coordinate in the <varname>LINESTRING</varname>.
                    For a <varname>POLYGON</varname> the paths are <varname>{i,j}</varname> where
                    <varname>i</varname> is the ring number (1 is outer; inner rings follow)
                    and <varname>j</varname> is the coordinate position in the ring.
                </para>
            </listitem>
            </itemizedlist>

            <para>
            To obtain a single geometry containing the coordinates use <xref linkend="ST_Points"/>.
            </para>

            <para role="enhanced" conformance="2.1.0">Enhanced: 2.1.0 Faster speed. Reimplemented as native-C.</para>
            <para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
            <para role="availability" conformance="1.5.0">Availability: 1.5.0</para>
            <para>&curve_support;</para>
            <para>&P_support;</para>
            <para>&T_support;</para>
            <para>&Z_support;</para>
		</refsection>

		<refsection>
			<title>Examples</title>
			<para>Explode a table of LineStrings into their vertices.</para>
			<programlisting>SELECT edge_id, (dp).path[1] As index,(dp).geom As wktnode
FROM (SELECT 1 As edge_id,
    ST_DumpPoints(ST_GeomFromText('LINESTRING(1 2,3 4,10 10)')) AS dp
     UNION ALL
     SELECT 2 As edge_id,
    ST_DumpPoints(ST_GeomFromText('LINESTRING(3 5,5 6,9 10)')) AS dp
   ) As foo;</programlisting>
<screen> edge_id | index |    wktnode
---------+-------+--------------
       1 |     1 | POINT(1 2)
       1 |     2 | POINT(3 4)
       1 |     3 | POINT(10 10)
       2 |     1 | POINT(3 5)
       2 |     2 | POINT(5 6)
       2 |     3 | POINT(9 10)</screen>

			<para>Dump every vertex from a mixed GeometryCollection.</para>
			<programlisting>SELECT path,geom
FROM (
  SELECT (ST_DumpPoints(g.geom)).*
  FROM
    (SELECT
       'GEOMETRYCOLLECTION(
          POINT ( 0 1 ),
          LINESTRING ( 0 3,3 4 ),
          POLYGON (( 2 0,2 3,0 2,2 0 )),
          POLYGON (( 3 0,3 3,6 3,6 0,3 0 ),
                   ( 5 1,4 2,5 2,5 1 )),
          MULTIPOLYGON (
                  (( 0 5,0 8,4 8,4 5,0 5 ),
                   ( 1 6,3 6,2 7,1 6 )),
                  (( 5 4,5 8,6 7,5 4 ))
          )
        )'::geometry AS geom
    ) AS g
  ) j;</programlisting>
<screen>   path    | st_astext
-----------+------------
 {1,1}     | POINT(0 1)
 {2,1}     | POINT(0 3)
 {2,2}     | POINT(3 4)
 {3,1,1}   | POINT(2 0)
 {3,1,2}   | POINT(2 3)
 {3,1,3}   | POINT(0 2)
 {3,1,4}   | POINT(2 0)
 {4,1,1}   | POINT(3 0)
 {4,1,2}   | POINT(3 3)
 {4,1,3}   | POINT(6 3)
 {4,1,4}   | POINT(6 0)
 {4,1,5}   | POINT(3 0)
 {4,2,1}   | POINT(5 1)
 {4,2,2}   | POINT(4 2)
 {4,2,3}   | POINT(5 2)
 {4,2,4}   | POINT(5 1)
 {5,1,1,1} | POINT(0 5)
 {5,1,1,2} | POINT(0 8)
 {5,1,1,3} | POINT(4 8)
 {5,1,1,4} | POINT(4 5)
 {5,1,1,5} | POINT(0 5)
 {5,1,2,1} | POINT(1 6)
 {5,1,2,2} | POINT(3 6)
 {5,1,2,3} | POINT(2 7)
 {5,1,2,4} | POINT(1 6)
 {5,2,1,1} | POINT(5 4)
 {5,2,1,2} | POINT(5 8)
 {5,2,1,3} | POINT(6 7)
 {5,2,1,4} | POINT(5 4)
(29 rows)</screen>

			<para>Collect the dumped vertices to visualize them over the source geometry.</para>
			<programlisting>WITH source(geom) AS (VALUES (
  'GEOMETRYCOLLECTION(
     POINT (0 1),
     LINESTRING (0 3,3 4),
     POLYGON ((2 0,2 3,0 2,2 0)),
     POLYGON ((3 0,3 3,6 3,6 0,3 0),(5 1,4 2,5 2,5 1)),
     MULTIPOLYGON (((0 5,0 8,4 8,4 5,0 5),(1 6,3 6,2 7,1 6)),
                   ((5 4,5 8,6 7,5 4))))'::geometry
))
SELECT ST_Collect((dp).geom ORDER BY (dp).path) AS vertices
FROM source
CROSS JOIN LATERAL ST_DumpPoints(source.geom) AS dp;</programlisting>
<screen role="visual-primary text-primary">MULTIPOINT((0 1),(0 3),(3 4),(2 0),(2 3),(0 2),(2 0),(3 0),(3 3),(6 3),(6 0),(3 0),(5 1),(4 2),(5 2),(5 1),(0 5),(0 8),(4 8),(4 5),(0 5),(1 6),(3 6),(2 7),(1 6),(5 4),(5 8),(6 7),(5 4))</screen>

			<para>This example uses a cube represented as a PolyhedralSurface.</para>
			<programlisting>
SELECT (g.gdump).path,(g.gdump).geom as wkt
  FROM
    (SELECT
       ST_DumpPoints('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)) )' ) AS gdump
    ) AS g;</programlisting>
<screen>  path   |     wkt
---------+--------------
 {1,1,1} | POINT(0 0 0)
 {1,1,2} | POINT(0 0 1)
 {1,1,3} | POINT(0 1 1)
 {1,1,4} | POINT(0 1 0)
 {1,1,5} | POINT(0 0 0)
 {2,1,1} | POINT(0 0 0)
 {2,1,2} | POINT(0 1 0)
 {2,1,3} | POINT(1 1 0)
 {2,1,4} | POINT(1 0 0)
 {2,1,5} | POINT(0 0 0)
 {3,1,1} | POINT(0 0 0)
 {3,1,2} | POINT(1 0 0)
 {3,1,3} | POINT(1 0 1)
 {3,1,4} | POINT(0 0 1)
 {3,1,5} | POINT(0 0 0)
 {4,1,1} | POINT(1 1 0)
 {4,1,2} | POINT(1 1 1)
 {4,1,3} | POINT(1 0 1)
 {4,1,4} | POINT(1 0 0)
 {4,1,5} | POINT(1 1 0)
 {5,1,1} | POINT(0 1 0)
 {5,1,2} | POINT(0 1 1)
 {5,1,3} | POINT(1 1 1)
 {5,1,4} | POINT(1 1 0)
 {5,1,5} | POINT(0 1 0)
 {6,1,1} | POINT(0 0 1)
 {6,1,2} | POINT(1 0 1)
 {6,1,3} | POINT(1 1 1)
 {6,1,4} | POINT(0 1 1)
 {6,1,5} | POINT(0 0 1)
(30 rows)</screen>
<para>This example uses a Triangle geometry.</para>
<programlisting>
SELECT (g.gdump).path,(g.gdump).geom as wkt
  FROM
    (SELECT
       ST_DumpPoints('TRIANGLE ((
                0 0,
                0 9,
                9 0,
                0 0
            ))' ) AS gdump
    ) AS g;</programlisting>
<screen> path |    wkt
------+------------
 {1,1} | POINT(0 0)
 {1,2} | POINT(0 9)
 {1,3} | POINT(9 0)
 {1,4} | POINT(0 0)</screen>
<para>This example uses a TIN geometry.</para>
<programlisting>
SELECT (g.gdump).path,(g.gdump).geom as wkt
  FROM
    (SELECT
       ST_DumpPoints('TIN (((
                0 0 0,
                0 0 1,
                0 1 0,
                0 0 0
            )),((
                0 0 0,
                0 1 0,
                1 1 0,
                0 0 0
            ))
            )' ) AS gdump
    ) AS g;</programlisting>
<screen>  path   |     wkt
---------+--------------
 {1,1,1} | POINT(0 0 0)
 {1,1,2} | POINT(0 0 1)
 {1,1,3} | POINT(0 1 0)
 {1,1,4} | POINT(0 0 0)
 {2,1,1} | POINT(0 0 0)
 {2,1,2} | POINT(0 1 0)
 {2,1,3} | POINT(1 1 0)
 {2,1,4} | POINT(0 0 0)
(8 rows)</screen>
		</refsection>
			<refsection>
			<title>See Also</title>
			<para><xref linkend="geometry_dump"/>, <xref linkend="PostGIS_Geometry_DumpFunctions"/>,
            <xref linkend="ST_Dump"/>, <xref linkend="ST_DumpRings"/>, <xref linkend="ST_Points"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_DumpSegments">
		<refnamediv>
			<refname>ST_DumpSegments</refname>
			<refpurpose>Returns a set of <varname>geometry_dump</varname> rows for the segments in a geometry.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
				<funcdef>geometry_dump[] <function>ST_DumpSegments</function></funcdef>
				<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
			</funcprototype>
		</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>A set-returning function (SRF) that extracts the segments of a geometry.
            It returns a set of
			    <xref linkend="geometry_dump"/> rows,
                each containing a geometry (<parameter>geom</parameter> field)
                and an array of integers (<parameter>path</parameter> field).
            </para>

            <itemizedlist>
            <listitem>
                <para>the <parameter>geom</parameter> field
                    <varname>LINESTRING</varname>s represent the linear segments of the supplied geometry, while the <varname>CIRCULARSTRING</varname>s represent the arc segments.
                </para>
            </listitem>
            <listitem>
                <para>the <parameter>path</parameter> field (an <varname>integer[]</varname>)
                    is an index enumerating the segment start point positions in the elements of the supplied geometry.
                    The indices are 1-based.
                    For example, for a <varname>LINESTRING</varname> the paths are <varname>{i}</varname>
                    where <varname>i</varname> is the <varname>nth</varname>
                    segment start point in the <varname>LINESTRING</varname>.
                    For a <varname>POLYGON</varname> the paths are <varname>{i,j}</varname> where
                    <varname>i</varname> is the ring number (1 is outer; inner rings follow)
                    and <varname>j</varname> is the segment start point position in the ring.
                </para>
            </listitem>
            </itemizedlist>

            <para role="availability" conformance="3.2.0">Availability: 3.2.0</para>
            <para>&T_support;</para>
            <para>&Z_support;</para>
		</refsection>

		<refsection>
			<title>Standard Geometry Examples</title>

			<programlisting>SELECT path,geom
FROM (
    SELECT (ST_DumpSegments(g.geom)).*
    FROM (SELECT 'GEOMETRYCOLLECTION(
    LINESTRING(1 1,3 3,4 4),
    POLYGON((5 5,6 6,7 7,5 5))
)'::geometry AS geom
        ) AS g
) j;</programlisting>
<screen>  path   │      st_astext
---------------------------------
 {1,1}   │ LINESTRING(1 1,3 3)
 {1,2}   │ LINESTRING(3 3,4 4)
 {2,1,1} │ LINESTRING(5 5,6 6)
 {2,1,2} │ LINESTRING(6 6,7 7)
 {2,1,3} │ LINESTRING(7 7,5 5)
(5 rows)</screen>
		</refsection>
	<refsection>
			<title>TIN and Triangle Examples</title>
<para>This example uses a Triangle geometry.</para>
<programlisting>
SELECT path,geom
FROM (
    SELECT (ST_DumpSegments(g.geom)).*
    FROM (SELECT 'TRIANGLE((
        0 0,
        0 9,
        9 0,
        0 0
    ))'::geometry AS geom
        ) AS g
) j;</programlisting>
<screen> path  │      st_astext
 ---------------------------------
 {1,1} │ LINESTRING(0 0,0 9)
 {1,2} │ LINESTRING(0 9,9 0)
 {1,3} │ LINESTRING(9 0,0 0)
(3 rows)</screen>
<para>This example uses a TIN geometry.</para>
<programlisting>
SELECT path,geom
FROM (
    SELECT (ST_DumpSegments(g.geom)).*
    FROM (SELECT 'TIN(((
        0 0 0,
        0 0 1,
        0 1 0,
        0 0 0
    )),((
        0 0 0,
        0 1 0,
        1 1 0,
        0 0 0
    ))
    )'::geometry AS geom
        ) AS g
) j;</programlisting>
<screen>  path   │        st_asewkt
  ---------------------------------
 {1,1,1} │ LINESTRING(0 0 0,0 0 1)
 {1,1,2} │ LINESTRING(0 0 1,0 1 0)
 {1,1,3} │ LINESTRING(0 1 0,0 0 0)
 {2,1,1} │ LINESTRING(0 0 0,0 1 0)
 {2,1,2} │ LINESTRING(0 1 0,1 1 0)
 {2,1,3} │ LINESTRING(1 1 0,0 0 0)
(6 rows)</screen>
		</refsection>
			<refsection>
			<title>See Also</title>
			<para><xref linkend="geometry_dump"/>, <xref linkend="PostGIS_Geometry_DumpFunctions"/>,
            <xref linkend="ST_Dump"/>, <xref linkend="ST_DumpRings"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_DumpRings">
	  <refnamediv>
		<refname>ST_DumpRings</refname>

		<refpurpose>Returns a set of <varname>geometry_dump</varname> rows for
			the exterior and interior rings of a Polygon.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry_dump[] <function>ST_DumpRings</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_polygon</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

        <para>A set-returning function (SRF) that extracts the rings of a polygon.
            It returns a set of <xref linkend="geometry_dump"/> rows,
            each containing a geometry (<parameter>geom</parameter> field)
            and an array of integers (<parameter>path</parameter> field).
        </para>
        <para>
		The <parameter>geom</parameter> field contains each ring as a POLYGON.
	    The <parameter>path</parameter> field is an integer array of length 1 containing the polygon ring index.
        The exterior ring (shell) has index 0.  The interior rings (holes) have indices of 1 and higher.
        </para>

		<note><para>This only works for POLYGON geometries, not MULTIPOLYGONs.
		Use <xref linkend="ST_Dump"/> to extract polygon elements from polygonal geometries:
		<code>ST_DumpRings((ST_Dump(geom)).geom )</code>
		</para></note>

		<para role="availability" conformance="1.1.3.">Availability: PostGIS 1.1.3. Requires PostgreSQL 7.3 or higher.</para>
		<para>&Z_support;</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>
        <para>Extracting all rings as polygons.</para>
		<programlisting>SELECT polyTable.field1, polyTable.field1,
      (ST_DumpRings(polyTable.geom)).geom As geom
FROM polyTable
</programlisting>
        <para>Extracting shell and holes from a polygon.</para>
<programlisting>SELECT path,geom As geom
FROM ST_DumpRings('POLYGON ((1 9,9 9,9 1,1 1,1 9),(2 2,2 3,3 3,3 2,2 2),(4 2,4 4,6 4,6 2,4 2))');</programlisting>
<screen> path |              geom
------+--------------------------------
 {0}  | POLYGON((1 9,9 9,9 1,1 1,1 9))
 {1}  | POLYGON((2 2,2 3,3 3,3 2,2 2))
 {2}  | POLYGON((4 2,4 4,6 4,6 2,4 2))</screen>

        <para>Finding interior rings which lie close to the exterior ring.</para>
<programlisting>WITH poly AS (
  SELECT 'POLYGON ((
      0 0, 10 0, 10 10, 0 10, 0 0
    ), (
      1 1, 1 2, 2 2, 2 1, 1 1
    ), (
      8.5 1, 8.5 2, 9.5 2, 9.5 1, 8.5 1
    ))'::geometry AS geom
),
rings AS (
  SELECT d.path[1] AS ring_no,
         ST_Boundary(d.geom) AS ring_geom
  FROM poly
  CROSS JOIN LATERAL ST_DumpRings(poly.geom) AS d
),
shell AS (
  SELECT ring_geom
  FROM rings
  WHERE ring_no = 0
),
holes AS (
  SELECT ring_no, ring_geom
  FROM rings
  WHERE ring_no &gt; 0
)
SELECT h.ring_no,
       ST_Normalize(ST_Multi(ST_LineMerge(
         ST_Intersection(ST_Buffer(s.ring_geom, 1.0), h.ring_geom)
       ))) AS close_part
FROM shell AS s
JOIN holes AS h
  ON ST_DWithin(s.ring_geom, h.ring_geom, 1.0);
</programlisting>
<screen> ring_no |                   close_part
---------+-------------------------------------------------
       1 | MULTILINESTRING((1 2,1 1,2 1))
       2 | MULTILINESTRING((8.5 1,9 1,9.5 1,9.5 2,9 2))
</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="geometry_dump"/>, <xref linkend="PostGIS_Geometry_DumpFunctions"/>, <xref linkend="ST_Boundary"/>, <xref linkend="ST_Buffer"/>, <xref linkend="ST_Dump"/>, <xref linkend="ST_DWithin"/>, <xref linkend="ST_ExteriorRing"/>, <xref linkend="ST_InteriorRingN"/>, <xref linkend="ST_Intersection"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_EndPoint">
	  <refnamediv>
		<refname>ST_EndPoint</refname>

		<refpurpose>Returns the last point of a LineString, CircularLineString, or NURBSCurve.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_EndPoint</function></funcdef>

			<paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

	  <para>Returns the last point of a <varname>LINESTRING</varname>,
      <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname> geometry
	  as a <varname>POINT</varname>.
      Returns <varname>NULL</varname> if the input
	  is not a <varname>LINESTRING</varname>, <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname>.</para>

		<para>&sqlmm_compliant; SQL-MM 3: 7.1.4</para>
		<para>&Z_support;</para>
	  <para>&curve_support;</para>

		<para role="changed" conformance="2.0.0">Changed: 2.0.0 no longer works with single geometry MultiLineStrings.  In older
	  versions of PostGIS a single-line MultiLineString would work with this
	  function and return the end point.  In 2.0.0 it returns NULL like any other MultiLineString.
	  The old behavior was an undocumented feature, but people who assumed they had their data stored as LINESTRING
	  may experience these returning NULL in 2.0.0.</para>

	  </refsection>

	  <refsection>
		<title>Examples</title>

<para>End point of a LineString</para>
		<programlisting>SELECT ST_EndPoint('LINESTRING(1 1,2 2,3 3)'::geometry);</programlisting>
<screen role="visual-primary text-primary">POINT(3 3)</screen>

<para>End point of a non-LineString is NULL</para>
<programlisting>SELECT ST_EndPoint('POINT(1 1)'::geometry) IS NULL AS is_null;</programlisting>
<screen>t</screen>

<para>End point of a 3D LineString</para>
<para>3D endpoint.</para>
<programlisting>SELECT ST_EndPoint('LINESTRING(1 1 2,1 2 3,0 0 5)');</programlisting>
<screen role="visual-primary text-primary">POINT(0 0 5)</screen>

<para>End point of a CircularString</para>
<programlisting>SELECT ST_EndPoint('CIRCULARSTRING(5 2,-3 2,-2 1,-4 2,6 3)'::geometry);</programlisting>
<screen role="visual-primary text-primary">POINT(6 3)</screen>

<para>End point of a NURBSCurve</para>
<programlisting>SELECT ST_EndPoint('NURBSCURVE(2, (0 0, 1 1, 2 0))'::geometry);</programlisting>
<screen role="visual-primary text-primary">POINT(2 0)</screen>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_PointN"/>, <xref linkend="ST_StartPoint"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_Envelope">
		  <refnamediv>
			<refname>ST_Envelope</refname>

			<refpurpose>Returns a geometry representing the bounding box of a geometry.</refpurpose>
		  </refnamediv>

		  <refsynopsisdiv>
			<funcsynopsis>
			  <funcprototype>
				<funcdef>geometry <function>ST_Envelope</function></funcdef>

				<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
			  </funcprototype>
			</funcsynopsis>
		  </refsynopsisdiv>

		  <refsection>
			<title>Description</title>

			<para>Returns the double-precision (float8) minimum bounding box for the supplied geometry, as a geometry.
			The polygon is defined by the corner points of the bounding box
			((<varname>MINX</varname>, <varname>MINY</varname>),
			(<varname>MINX</varname>, <varname>MAXY</varname>),
			(<varname>MAXX</varname>, <varname>MAXY</varname>),
			(<varname>MAXX</varname>, <varname>MINY</varname>),
			(<varname>MINX</varname>, <varname>MINY</varname>)). (PostGIS will add a
			<varname>ZMIN</varname>/<varname>ZMAX</varname> coordinate as
			well).</para>

			<para>Degenerate cases (vertical lines, points) will return a geometry of
			lower dimension than <varname>POLYGON</varname>, ie.
			<varname>POINT</varname> or <varname>LINESTRING</varname>.</para>

			<para role="availability" conformance="1.5.0">Availability: 1.5.0 behavior changed to output double precision instead of float4</para>
			<para>&sfs_compliant; s2.1.1.1</para>
			<para>&sqlmm_compliant; SQL-MM 3: 5.1.19</para>
		</refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_Envelope('POINT(1 3)'::geometry);</programlisting>
<screen role="visual-primary text-primary">POINT(1 3)</screen>
<programlisting>SELECT ST_Envelope('LINESTRING(0 0,1 3)'::geometry);</programlisting>
<screen role="visual-primary text-primary">POLYGON((0 0,0 3,1 3,1 0,0 0))</screen>
<programlisting>SELECT ST_Envelope('POLYGON((0 0,0 1,1.0000001 1,1.0000001 0,0 0))'::geometry);</programlisting>
<screen role="visual-primary text-primary">POLYGON((0 0,0 1,1.0000001 1,1.0000001 0,0 0))</screen>
<programlisting>SELECT ST_Envelope('POLYGON((0 0,0 1,1.0000000001 1,1.0000000001 0,0 0))'::geometry);</programlisting>
<screen role="visual-primary text-primary">POLYGON((0 0,0 1,1.0000000001 1,1.0000000001 0,0 0))</screen>
<programlisting>SELECT Box3D(geom), Box2D(geom), ST_Envelope(geom) As envelopewkt
    FROM (SELECT 'POLYGON((0 0,0 1000012333334.34545678,1.0000001 1,1.0000001 0,0 0))'::geometry As geom) As foo;

<!-- TODO: Fix examples to reflect new behavior --></programlisting>
	<para>Envelope of a point and LineString.</para>
<programlisting>
SELECT ST_Envelope(ST_Collect(
            'LINESTRING(55 75,125 150)',
            ST_Point(20, 80)
            )) As wktenv;</programlisting>
<screen role="visual-primary text-primary">POLYGON((20 75,20 150,125 150,125 75,20 75))</screen>
	  </refsection>
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="Box2D"/>, <xref linkend="Box3D"/>, <xref linkend="ST_OrientedEnvelope"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_ExteriorRing">
	  <refnamediv>
		<refname>ST_ExteriorRing</refname>

		<refpurpose>Returns a LineString representing the exterior ring of a Polygon. </refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_ExteriorRing</function></funcdef>

			<paramdef><type>geometry </type> <parameter>a_polygon</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns a LINESTRING representing the exterior ring (shell) of a POLYGON.
        Returns	NULL if the geometry is not a polygon.</para>

		<note>
		  <para>This function does not support MULTIPOLYGONs.
          For MULTIPOLYGONs use in conjunction with <xref linkend="ST_GeometryN"/> or <xref linkend="ST_Dump"/> </para>
        </note>

		<para>&sfs_compliant; 2.1.5.1</para>
		<para>&sqlmm_compliant; SQL-MM 3: 8.2.3, 8.3.3</para>
                <para>&Z_support;</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>

<para>Extract the exterior ring from a Polygon with a hole.</para>
<programlisting>WITH input(geom) AS (VALUES (
  'POLYGON((0 0,2 9,9 11,14 6,12 0,0 0),(4 3,9 3,10 7,5 8,4 3))'::geometry
))
SELECT geom AS input_polygon,
       ST_ExteriorRing(geom) AS exterior_ring
FROM input;</programlisting>
<screen role="visual-overlay visual-primary text-primary">POLYGON((0 0,2 9,9 11,14 6,12 0,0 0),(4 3,9 3,10 7,5 8,4 3)) | LINESTRING(0 0,2 9,9 11,14 6,12 0,0 0)</screen>

<para>For a MultiPolygon, dump the component Polygons before extracting their exterior rings. Both component Polygons in this example have holes.</para>
<programlisting>WITH input(geom) AS (VALUES (
  'MULTIPOLYGON(
    ((0 0,2 9,9 11,14 6,12 0,0 0),(4 3,9 3,10 7,5 8,4 3)),
    ((18 1,18 10,29 10,31 4,25 0,18 1),(21 3,25 2,28 5,25 8,21 7,21 3))
  )'::geometry
))
SELECT part.geom AS input_polygon,
       ST_ExteriorRing(part.geom) AS exterior_ring
FROM input
CROSS JOIN LATERAL ST_Dump(geom) AS part
ORDER BY part.path;</programlisting>
<screen role="visual-overlay visual-primary text-primary">POLYGON((0 0,2 9,9 11,14 6,12 0,0 0),(4 3,9 3,10 7,5 8,4 3)) | LINESTRING(0 0,2 9,9 11,14 6,12 0,0 0)
POLYGON((18 1,18 10,29 10,31 4,25 0,18 1),(21 3,25 2,28 5,25 8,21 7,21 3)) | LINESTRING(18 1,18 10,29 10,31 4,25 0,18 1)</screen>

<para>Extract exterior rings from a table of Polygons.</para>
<programlisting>
SELECT gid, ST_ExteriorRing(geom) AS ering
FROM sometable;</programlisting>

<para>For a table of MultiPolygons, dump the component Polygons and collect their exterior rings into a MultiLineString.</para>
<programlisting language="sql">SELECT gid, ST_Collect(ST_ExteriorRing(geom)) AS erings
FROM (
  SELECT gid, (ST_Dump(geom)).geom AS geom
  FROM sometable
) AS foo
GROUP BY gid;</programlisting>

<para>This example returns the 3D exterior ring of a Polygon.</para>
<programlisting>SELECT ST_ExteriorRing(
    'POLYGON Z ((0 0 5,4 0 5,4 3 5,0 3 5,0 0 5))'
    );</programlisting>
<screen role="visual-primary text-primary">LINESTRING(0 0 5,4 0 5,4 3 5,0 3 5,0 0 5)</screen>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para>
<xref linkend="ST_InteriorRingN"/>,
<xref linkend="ST_Boundary"/>,
<xref linkend="ST_NumInteriorRings"/>
		</para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_GeometryN">
	  <refnamediv>
		<refname>ST_GeometryN</refname>

		<refpurpose>Return an element of a geometry collection.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_GeometryN</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
			<paramdef><type>integer </type> <parameter>n</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 1-based Nth element of a GEOMETRYCOLLECTION,
			MULTIPOINT, MULTILINESTRING, MULTICURVE, or MULTIPOLYGON.
			For a unitary geometry, including a TIN or PolyhedralSurface,
			an index of 1 returns the input geometry and any other index returns NULL.
			Use <xref linkend="ST_PatchN"/> and <xref linkend="ST_NumPatches"/> to
			access and count the faces of a TIN or PolyhedralSurface.</para>

		<note>
		  <para>Index is 1-based as for OGC specs since version 0.8.0.
		  Previous versions implemented this as 0-based instead.</para>
		</note>

		<note>
		  <para>To extract all elements of a geometry, <xref linkend="ST_Dump"/> is more efficient and works for atomic geometries.</para>
		</note>
		<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
		<para role="changed" conformance="2.0.0">Changed: 2.0.0 Prior versions would return NULL for singular geometries.  This was changed to return the geometry for ST_GeometryN(..,1) case.</para>
		<para role="changed" conformance="3.6.0">Changed: 3.6.0 TIN and PolyhedralSurface are treated as unitary geometries and are not decomposed into patches; use ST_PatchN to access faces.</para>
		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant; SQL-MM 3: 9.1.5</para>
		<para>&Z_support;</para>
		<para>&curve_support;</para>
		<para>&P_support;</para>
		<para>&T_support;</para>

	  </refsection>


	  <refsection>
		<title>Standard Examples</title>

		<para>Extracting a subset of points from a 3D multipoint.</para>
		<programlisting>
<![CDATA[
SELECT n, ST_GeometryN(geom, n) As geomewkt
FROM (
VALUES
    (1, 'MULTIPOINT((1 2 7), (3 4 7), (5 6 7), (8 9 10))'::geometry ),
    (2, 'MULTICURVE(CIRCULARSTRING(2.5 2.5,4.5 2.5, 3.5 3.5), (10 11, 12 11))'::geometry )
    ) As foo(id, geom)
    CROSS JOIN generate_series(1,100) n
WHERE n <= ST_NumGeometries(geom)
ORDER BY id, n;
]]></programlisting>
<screen><![CDATA[ n |               geomewkt
---+-----------------------------------------
 1 | POINT(1 2 7)
 2 | POINT(3 4 7)
 3 | POINT(5 6 7)
 4 | POINT(8 9 10)
 1 | CIRCULARSTRING(2.5 2.5,4.5 2.5,3.5 3.5)
 2 | LINESTRING(10 11,12 11)]]></screen>

<para>Extracting all geometries (useful when you want to assign an id).</para>
<programlisting><![CDATA[SELECT gid, n, ST_GeometryN(geom, n)
FROM sometable CROSS JOIN generate_series(1,100) n
WHERE n <= ST_NumGeometries(geom);]]></programlisting>
	  </refsection>

<refsection><title>Polyhedral Surfaces, TIN and Triangle Examples</title>
<para>A PolyhedralSurface or TIN is treated as a single geometry, not as a
collection of faces.  <function>ST_GeometryN</function> does not decompose the
surface into patches, so an index greater than 1 returns <varname>NULL</varname>.
Use <xref linkend="ST_PatchN"/> and <xref linkend="ST_NumPatches"/> to access
individual faces.</para>
<para>This example requests the third element of a PolyhedralSurface.</para>
<programlisting language="sql">
SELECT ST_GeometryN(p_geom, 3) As geom_ewkt
  FROM (SELECT 'POLYHEDRALSURFACE(
((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),
((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),
((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1))
)'::geometry  AS p_geom )  AS a;</programlisting>
<screen>NULL</screen>

<para>This example requests the second element of a TIN.</para>
<programlisting language="sql">
SELECT ST_GeometryN(geom, 2) as wkt
  FROM
    (SELECT
       'TIN (((
                0 0 0,
                0 0 1,
                0 1 0,
                0 0 0
            )),((
                0 0 0,
                0 1 0,
                1 1 0,
                0 0 0
            ))
            )'::geometry  AS geom
    ) AS g;</programlisting>
<screen>NULL</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Dump"/>, <xref linkend="ST_NumGeometries"/>, <xref linkend="ST_PatchN"/>, <xref linkend="ST_NumPatches"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_GeometryType">
		<refnamediv>
			<refname>ST_GeometryType</refname>
			<refpurpose>Returns the SQL-MM type of a geometry as text.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>text <function>ST_GeometryType</function></funcdef>
			<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
		</refsynopsisdiv>
		<refsection>
			<title>Description</title>

			<para>Returns the type of the geometry as a string. EG: 'ST_LineString', 'ST_Polygon','ST_MultiPolygon' etc. This function differs from GeometryType(geometry) in the case of the string and ST in front that is returned, as well as the fact that it will not indicate whether the geometry is measured.</para>

			<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces was introduced.</para>
			<para>&sqlmm_compliant;	SQL-MM 3: 5.1.4</para>
			<para>&Z_support;</para>
			<para>&P_support;</para>

		</refsection>

		<refsection>
			<title>Examples</title>

			<programlisting language="sql">SELECT ST_GeometryType('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'::geometry);</programlisting>
<screen role="text-primary">ST_LineString</screen>

			<programlisting language="sql">SELECT ST_GeometryType('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)) )'::geometry);</programlisting>
<screen role="text-primary">ST_PolyhedralSurface</screen>

		<programlisting language="sql">SELECT ST_GeometryType(geom) AS result
FROM
  (SELECT
     'TIN (((
              0 0 0,
              0 0 1,
              0 1 0,
              0 0 0
          )),((
              0 0 0,
              0 1 0,
              1 1 0,
              0 0 0
          ))
          )'::geometry AS geom
  ) AS g;</programlisting>
<screen role="text-primary">ST_Tin</screen>
		</refsection>
		<refsection>
			<title>See Also</title>

			<para><xref linkend="GeometryType"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_HasArc">
	  <refnamediv>
		<refname>ST_HasArc</refname>

		<refpurpose>Tests if a geometry contains a circular arc</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 role="availability" conformance="1.2.3">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)'));</programlisting>
<screen>t</screen>
	  </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 xml:id="ST_InteriorRingN">
	  <refnamediv>
		<refname>ST_InteriorRingN</refname>

		<refpurpose>Returns the Nth interior ring (hole) of a Polygon.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_InteriorRingN</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_polygon</parameter></paramdef>
			<paramdef><type>integer </type> <parameter>n</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the Nth interior ring (hole) of a POLYGON geometry as a LINESTRING. The index starts at 1. Returns NULL if the geometry is not a polygon or the index is out of range.</para>

		<!-- optionally mention that this function uses indexes if appropriate -->
		<note>
		  <para>This function does not support MULTIPOLYGONs.
          For MULTIPOLYGONs use in conjunction with <xref linkend="ST_GeometryN"/> or <xref linkend="ST_Dump"/> </para>
		</note>

		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant; SQL-MM 3: 8.2.6, 8.3.5</para>
		<para>&Z_support;</para>

	  </refsection>


	  <refsection>
		<title>Examples</title>

		<programlisting language="sql">WITH data AS (
  SELECT ST_BuildArea(ST_Collect(
    ST_Buffer(ST_Point(1, 2), 20, 3),
    ST_Buffer(ST_Point(1, 2), 10, 3)
  )) AS geom
)
SELECT geom AS input_polygon,
       ST_InteriorRingN(geom, 1) AS ring
FROM data;</programlisting>
        <screen role="visual-primary docbook-qa-ignore-wide-lines">POLYGON((21 2,18.320508075688775 -7.999999999999998,11.000000000000002 -15.320508075688771,1 -18,-8.999999999999996 -15.320508075688775,-16.32050807568877 -8.000000000000007,-19 2,-16.320508075688778 11.999999999999995,-9.000000000000009 19.320508075688767,1 22,10.999999999999986 19.32050807568878,18.320508075688767 12.000000000000009,21 2),(11 2,9.660254037844384 7.000000000000004,5.999999999999993 10.66025403784439,1 12,-4.000000000000004 10.660254037844384,-7.660254037844389 6.999999999999997,-9 2,-7.660254037844386 -3.000000000000004,-3.999999999999998 -6.660254037844387,1 -8,6.000000000000001 -6.660254037844386,9.660254037844387 -2.999999999999999,11 2)) | LINESTRING(11 2,9.660254037844384 7.000000000000004,5.999999999999993 10.66025403784439,1 12,-4.000000000000004 10.660254037844384,-7.660254037844389 6.999999999999997,-9 2,-7.660254037844386 -3.000000000000004,-3.999999999999998 -6.660254037844387,1 -8,6.000000000000001 -6.660254037844386,9.660254037844387 -2.999999999999999,11 2)</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para>
            <xref linkend="ST_ExteriorRing"/>,
            <xref linkend="ST_BuildArea"/>,
            <xref linkend="ST_Collect"/>,
            <xref linkend="ST_Dump"/>,
            <xref linkend="ST_NumInteriorRing"/>,
            <xref linkend="ST_NumInteriorRings"/>
		</para>
	  </refsection>
	</refentry>

    <refentry xml:id="ST_NumCurves">
      <refnamediv>
        <refname>ST_NumCurves</refname>
        <refpurpose>Return the number of component curves in a CompoundCurve.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>integer <function>ST_NumCurves</function></funcdef>
            <paramdef><type>geometry </type> <parameter>a_compoundcurve</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Return the number of component curves in a CompoundCurve, zero for an empty CompoundCurve, or NULL for a non-CompoundCurve input. </para>
        <para>&sqlmm_compliant; SQL-MM 3: 8.2.6, 8.3.5</para>
        <para>&Z_support;</para>
      </refsection>

      <refsection>
        <title>Examples</title>

        <para>This CompoundCurve contains three component curves.</para>
        <programlisting language="sql">SELECT ST_NumCurves('COMPOUNDCURVE(
    (2 2,2.5 2.5),
    CIRCULARSTRING(2.5 2.5,4.5 2.5,3.5 3.5),
    (3.5 3.5,2.5 4.5,3 5,2 2)
  )');</programlisting>
<screen role="text-primary">3</screen>

        <para>An empty CompoundCurve has no component curves.</para>
        <programlisting language="sql">SELECT ST_NumCurves('COMPOUNDCURVE EMPTY');</programlisting>
<screen role="text-primary">0</screen>
      </refsection>

      <refsection>
        <title>See Also</title>
        <para>
            <xref linkend="ST_CurveN"/>,
            <xref linkend="ST_Dump"/>,
            <xref linkend="ST_ExteriorRing"/>,
            <xref linkend="ST_NumInteriorRings"/>,
            <xref linkend="ST_NumGeometries"/>
        </para>
      </refsection>
    </refentry>

    <refentry xml:id="ST_CurveN">
      <refnamediv>
        <refname>ST_CurveN</refname>
        <refpurpose>Returns the Nth component curve geometry of a CompoundCurve.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_CurveN</function></funcdef>
            <paramdef><type>geometry </type> <parameter>a_compoundcurve</parameter></paramdef>
            <paramdef><type>integer </type> <parameter>index</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Returns the Nth component curve geometry of a CompoundCurve. The index starts at 1. Returns NULL if the geometry is not a CompoundCurve or the index is out of range.</para>
        <para>&sqlmm_compliant; SQL-MM 3: 8.2.6, 8.3.5</para>
        <para>&Z_support;</para>
      </refsection>

      <refsection>
        <title>Examples</title>

        <para>This example extracts the second component curve, a CircularString, from a CompoundCurve.</para>
        <programlisting language="sql">SELECT ST_CurveN(
  'COMPOUNDCURVE(
    (0 0,2 0),
    CIRCULARSTRING(2 0,3 1,4 0),
    (4 0,6 1)
  )',
  2) AS curve;</programlisting>
<screen role="visual-primary visual-overlay text-primary">CIRCULARSTRING(2 0,3 1,4 0)</screen>
      </refsection>

      <refsection>
        <title>See Also</title>
        <para>
            <xref linkend="ST_NumCurves"/>,
            <xref linkend="ST_Dump"/>,
            <xref linkend="ST_ExteriorRing"/>,
            <xref linkend="ST_NumInteriorRings"/>,
            <xref linkend="ST_NumGeometries"/>
        </para>
      </refsection>
    </refentry>

	<refentry xml:id="ST_IsClosed">
	  <refnamediv>
		<refname>ST_IsClosed</refname>

		<refpurpose>Tests if a LineStrings's start and end points are coincident. For a PolyhedralSurface tests if it is closed (volumetric).
		</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>boolean <function>ST_IsClosed</function></funcdef>

			<paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns <varname>TRUE</varname> if the <varname>LINESTRING</varname>'s
		start and end points are coincident.
		For Polyhedral Surfaces, reports if the surface is areal (open) or volumetric (closed).</para>

		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant; SQL-MM 3: 7.1.5, 9.3.3</para>
		<note>
		  <para>SQL-MM defines the result of
		  <code>ST_IsClosed(NULL)</code> to be 0, while
		  PostGIS returns <varname>NULL</varname>.</para>
		</note>

		<para>&Z_support;</para>
		<para>&curve_support;</para>
		<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces was introduced.</para>

		<para>&P_support;</para>

	  </refsection>

	  <refsection>
		<title>Line String and Point Examples</title>

		<programlisting>SELECT ST_IsClosed('LINESTRING(0 0,1 1)'::geometry);</programlisting>
<screen>f</screen>
<programlisting>SELECT ST_IsClosed('LINESTRING(0 0,0 1,1 1,0 0)'::geometry);</programlisting>
<screen>t</screen>
<programlisting>SELECT ST_IsClosed('MULTILINESTRING((0 0,0 1,1 1,0 0),(0 0,1 1))'::geometry);</programlisting>
<screen>f</screen>
<programlisting>SELECT ST_IsClosed('POINT(0 0)'::geometry);</programlisting>
<screen>t</screen>
<programlisting>SELECT ST_IsClosed('MULTIPOINT((0 0),(1 1))'::geometry);</programlisting>
<screen>t</screen>
	  </refsection>

		  <refsection>
		<title>Polyhedral Surface Examples</title>

		<para>This example uses a cube.</para>
		<programlisting>
SELECT ST_IsClosed('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)) )');</programlisting>
<screen>t</screen>
<para>This example uses the same cube with one side missing.</para>
<programlisting>
SELECT ST_IsClosed('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
       ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
       ((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
       ((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)) )');</programlisting>
<screen>f</screen>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_IsRing"/></para>
	  </refsection>
        </refentry>

	<refentry xml:id="ST_IsCollection">
	  <refnamediv>
		<refname>ST_IsCollection</refname>
      <refpurpose>Tests if a geometry is a geometry collection type.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>boolean <function>ST_IsCollection</function></funcdef>
			<paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

                <para>Returns <varname>TRUE</varname> if the geometry type of
                  the argument a geometry collection type.  Collection types are the following:
                  <itemizedlist>
                    <listitem><para>GEOMETRYCOLLECTION</para></listitem>
                    <listitem><para>MULTI{POINT,POLYGON,LINESTRING,CURVE,SURFACE}</para></listitem>
                    <listitem><para>COMPOUNDCURVE</para></listitem>
                  </itemizedlist>
                </para>

                <note>
                  <para>
                    This function analyzes the type of the geometry. This means
                    that it will return <varname>TRUE</varname> on collections
                    that are empty or that contain a single element.
                  </para>
                </note>

		<para>&Z_support;</para>
		<para>&curve_support;</para>

	  </refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_IsCollection('LINESTRING(0 0,1 1)'::geometry);</programlisting>
<screen>f</screen>
<programlisting>SELECT ST_IsCollection('MULTIPOINT EMPTY'::geometry);</programlisting>
<screen>t</screen>
<programlisting>SELECT ST_IsCollection('MULTIPOINT((0 0))'::geometry);</programlisting>
<screen>t</screen>
<programlisting>SELECT ST_IsCollection('MULTIPOINT((0 0),(42 42))'::geometry);</programlisting>
<screen>t</screen>
<programlisting>SELECT ST_IsCollection('GEOMETRYCOLLECTION(POINT(0 0))'::geometry);</programlisting>
<screen>t</screen>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_NumGeometries"/></para>
	  </refsection>
        </refentry>

	<refentry xml:id="ST_IsEmpty">
	  <refnamediv>
		<refname>ST_IsEmpty</refname>

		<refpurpose>Tests if a geometry is empty.</refpurpose>

	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>boolean <function>ST_IsEmpty</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns true if this Geometry is an empty geometry. If
				true, then this Geometry represents an empty geometry collection, polygon, point etc.</para>
		<note>
			<para>SQL-MM defines the result of ST_IsEmpty(NULL) to be 0, while
			PostGIS returns NULL.</para>
		</note>

		<para>&sfs_compliant; s2.1.1.1</para>
		<para>&sqlmm_compliant; SQL-MM 3: 5.1.7</para>
		<para>&curve_support;</para>
		<para role="changed" conformance="2.0.0">Changed: 2.0.0 In prior versions of PostGIS ST_GeomFromText('GEOMETRYCOLLECTION(EMPTY)') was allowed.  This is now illegal in PostGIS 2.0.0 to better conform with SQL/MM standards</para>

	  </refsection>


	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_IsEmpty('GEOMETRYCOLLECTION EMPTY'::geometry);</programlisting>
<screen>t</screen>
<programlisting>SELECT ST_IsEmpty('POLYGON EMPTY'::geometry);</programlisting>
<screen>t</screen>
<programlisting>SELECT ST_IsEmpty('POLYGON((1 2,3 4,5 6,1 2))'::geometry);</programlisting>
<screen>f</screen>
<programlisting>SELECT ST_IsEmpty('POLYGON((1 2,3 4,5 6,1 2))'::geometry) = false;</programlisting>
<screen> t
(1 row)</screen>
<programlisting>SELECT ST_IsEmpty('CIRCULARSTRING EMPTY'::geometry);</programlisting>
<screen>t</screen>
	  </refsection>

	</refentry>

	<refentry xml:id="ST_IsPolygonCCW">
		<refnamediv>
			<refname>ST_IsPolygonCCW</refname>
			<refpurpose>Tests if Polygons have exterior rings oriented counter-clockwise and interior rings oriented clockwise.
			</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>boolean <function>ST_IsPolygonCCW</function></funcdef>
					<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>

			<para>
				Returns true if all polygonal components of the input geometry use a counter-clockwise
				orientation for their exterior ring, and a clockwise direction
				for all interior rings.
			</para>

			<para>
				Returns true if the geometry has no polygonal components.
			</para>

			<note>
				<para>
					Closed linestrings are not considered polygonal components,
					so you would still get a true return by passing
          a single closed linestring no matter its orientation.
				</para>
			</note>

			<note>
				<para>
					If a polygonal geometry does not use reversed orientation
					for interior rings (i.e., if one or more interior rings
					are oriented in the same direction as an exterior ring)
					then both ST_IsPolygonCW and ST_IsPolygonCCW will return false.
				</para>
			</note>

			<para role="availability" conformance="2.4.0">Availability: 2.4.0</para>
			<para>&Z_support;</para>
			<para>&M_support;</para>

		</refsection>

		<refsection>
			<title>See Also</title>
			<para>
				<xref linkend="ST_ForcePolygonCW"/>,
				<xref linkend="ST_ForcePolygonCCW"/>,
				<xref linkend="ST_IsPolygonCW"/>
			</para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_IsPolygonCW">
		<refnamediv>
			<refname>ST_IsPolygonCW</refname>
			<refpurpose>Tests if Polygons have exterior rings oriented clockwise and interior rings oriented counter-clockwise.
			</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>boolean <function>ST_IsPolygonCW</function></funcdef>
					<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>

			<para>
				Returns true if all polygonal components of the input geometry use a clockwise
				orientation for their exterior ring, and a counter-clockwise direction
				for all interior rings.
			</para>

			<para>
				Returns true if the geometry has no polygonal components.
			</para>

			<note>
				<para>
					Closed linestrings are not considered polygonal components,
					so you would still get a true return by passing
          a single closed linestring no matter its orientation.
				</para>
			</note>

			<note>
				<para>
					If a polygonal geometry does not use reversed orientation
					for interior rings (i.e., if one or more interior rings
					are oriented in the same direction as an exterior ring)
					then both ST_IsPolygonCW and ST_IsPolygonCCW will return false.
				</para>
			</note>

			<para role="availability" conformance="2.4.0">Availability: 2.4.0</para>
			<para>&Z_support;</para>
			<para>&M_support;</para>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para>
				<xref linkend="ST_ForcePolygonCW"/>,
				<xref linkend="ST_ForcePolygonCCW"/>,
				<xref linkend="ST_IsPolygonCW"/>
			</para>
		</refsection>
	</refentry>

  <refentry xml:id="ST_IsRing">
	<refnamediv>
	  <refname>ST_IsRing</refname>

	  <refpurpose>Tests if a LineString is closed and simple.</refpurpose>
	</refnamediv>

	<refsynopsisdiv>
	  <funcsynopsis>
		<funcprototype>
		  <funcdef>boolean <function>ST_IsRing</function></funcdef>

		  <paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
		</funcprototype>
	  </funcsynopsis>
	</refsynopsisdiv>

	<refsection>
	  <title>Description</title>

	  <para>Returns <varname>TRUE</varname> if this
	  <varname>LINESTRING</varname> is both <xref linkend="ST_IsClosed" />
	  (<code>ST_StartPoint(g) ~= ST_EndPoint(g)</code>) and <xref
	  linkend="ST_IsSimple" /> (does not self intersect).</para>

	  <para>&sfs_compliant; 2.1.5.1</para>
	  <para>&sqlmm_compliant; SQL-MM 3: 7.1.6</para>
	  <note>
		<para>SQL-MM defines the result of
		<code>ST_IsRing(NULL)</code> to be 0, while
		PostGIS returns <varname>NULL</varname>.</para>
	  </note>
	</refsection>

	<refsection>
	  <title>Examples</title>

	  <programlisting>SELECT ST_IsRing(geom), ST_IsClosed(geom), ST_IsSimple(geom)
FROM (SELECT 'LINESTRING(0 0,0 1,1 1,1 0,0 0)'::geometry AS geom) AS foo;</programlisting>
<screen> st_isring | st_isclosed | st_issimple
-----------+-------------+-------------
 t         | t           | t
(1 row)</screen>
<programlisting>SELECT ST_IsRing(geom), ST_IsClosed(geom), ST_IsSimple(geom)
FROM (SELECT 'LINESTRING(0 0,0 1,1 0,1 1,0 0)'::geometry AS geom) AS foo;</programlisting>
<screen> st_isring | st_isclosed | st_issimple
-----------+-------------+-------------
 f         | t           | f
(1 row)</screen>
	</refsection>

	<refsection>
	  <title>See Also</title>

	  <para><xref linkend="ST_IsClosed"/>, <xref linkend="ST_IsSimple"/>, <xref linkend="ST_StartPoint"/>,
	  <xref linkend="ST_EndPoint"/></para>
	</refsection>
  </refentry>


  <refentry xml:id="ST_IsSimple">
	  <refnamediv>
		<refname>ST_IsSimple</refname>

		<refpurpose>Tests if a geometry has no points of self-intersection or self-tangency.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>boolean <function>ST_IsSimple</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns true if this Geometry has no anomalous geometric
				points, such as self-intersection or self-tangency. For more
			information on the OGC's definition of geometry simplicity and validity, refer
			to <link linkend="OGC_Validity">"Ensuring OpenGIS compliance of geometries"</link></para>

		<note>
			<para>SQL-MM defines the result of ST_IsSimple(NULL) to be 0,
			while PostGIS returns NULL.</para>
		</note>

		<para>&sfs_compliant; s2.1.1.1</para>
		<para>&sqlmm_compliant; SQL-MM 3: 5.1.8</para>
		<para>&Z_support;</para>

	  </refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_IsSimple('POLYGON((1 2,3 4,5 6,1 2))');</programlisting>
<screen>f</screen>
<programlisting>SELECT ST_IsSimple('LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 1)');</programlisting>
<screen>f</screen>
		</refsection>

		<refsection>
			<title>See Also</title>

			<para><xref linkend="ST_IsValid"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_M">
	  <refnamediv>
		<refname>ST_M</refname>

		<refpurpose>Returns the M coordinate of a Point.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_M</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_point</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Return the M coordinate of a Point, or NULL if not
			available. Input must be a Point.</para>

		<note>
			  <para>This is not (yet) part of the OGC spec, but is listed here
			  to complete the point coordinate extractor function list.</para>
		</note>
		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant;</para>
		<para>&Z_support;</para>

	  </refsection>


	  <refsection>
		<title>Examples</title>
		<programlisting>SELECT ST_M('POINT(1 2 3 4)');</programlisting>
<screen>4</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_GeomFromEWKT"/>, <xref linkend="ST_X"/>, <xref linkend="ST_Y"/>, <xref linkend="ST_Z"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_MemSize">
	  <refnamediv>
		<refname>ST_MemSize</refname>

		<refpurpose>Returns the amount of memory space a geometry takes.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_MemSize</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the amount of memory space (in bytes) the geometry takes. </para>
		<para>This complements the PostgreSQL built-in <link xlink:href="https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADMIN-DBOBJECT">database object functions</link>
		 pg_column_size, pg_size_pretty, pg_relation_size, pg_total_relation_size.</para>
		<note><para>pg_relation_size which gives the byte size of a table may return byte size lower than ST_MemSize. This is because
		pg_relation_size does not add toasted table contribution and large geometries are stored in TOAST tables.</para>
		<para>pg_total_relation_size - includes, the table, the toasted tables, and the indexes.</para>
		<para>pg_column_size returns how much space a geometry would take in a column considering compression, so may be lower than ST_MemSize</para>
		</note>

		<para>&Z_support;</para>
		<para>&curve_support;</para>
		<para>&P_support;</para>
		<para>&T_support;</para>
		<para role="changed" conformance="2.2.0">Changed: 2.2.0 name changed to ST_MemSize to follow naming convention.</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>

		<para>Compare the memory used by all geometries in a Massachusetts town dataset with the subset for Boston.</para>
		<programlisting role="requires-external-state">SELECT pg_size_pretty(sum(ST_MemSize(geom))) AS totgeomsum,
       pg_size_pretty(sum(CASE WHEN town = 'BOSTON' THEN ST_MemSize(geom) ELSE 0 END)) AS bossum,
       cast(
           sum(CASE WHEN town = 'BOSTON' THEN ST_MemSize(geom) ELSE 0 END) * 100.0
           / sum(ST_MemSize(geom)) AS numeric(10, 2)
       ) AS perbos
FROM towns;</programlisting>
<screen> totgeomsum | bossum | perbos
------------+--------+--------
 1522 kB    | 30 kB  |   1.99
(1 row)</screen>

		<para>Return the memory size of a CircularString in bytes.</para>
<programlisting>SELECT ST_MemSize('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)'::geometry);</programlisting>
<screen> st_memsize
------------
         80
(1 row)</screen>

		<para>Calculate the percentage of a table's total size used by geometry data.</para>
		<programlisting role="requires-external-state">SELECT pg_total_relation_size('public.neighborhoods') AS fulltable_size,
       sum(ST_MemSize(geom)) AS geomsize,
       sum(ST_MemSize(geom)) * 100.0
           / pg_total_relation_size('public.neighborhoods') AS pergeom
FROM neighborhoods;</programlisting>
<screen> fulltable_size | geomsize |         pergeom
----------------+----------+--------------------------
         262144 |    96238 | 36.71188354492187500000
(1 row)</screen>
	  </refsection>

	</refentry>

	<refentry xml:id="ST_NDims">
		<refnamediv>
			<refname>ST_NDims</refname>
			<refpurpose>Returns the coordinate dimension of a geometry.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_NDims</function></funcdef>
			<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>

			<para>Returns the coordinate dimension of the geometry.  PostGIS supports 2 -  (x,y) ,
			3 -  (x,y,z) or 2D with measure - x,y,m, and 4 - 3D with measure space x,y,z,m</para>

			<para>&Z_support;</para>
		</refsection>

		<refsection>
			<title>Examples</title>

			<programlisting>SELECT ST_NDims('POINT(1 1)') As d2point,
ST_NDims('POINT(1 1 2)') As d3point,
ST_NDims('POINTM(1 1 0.5)') As d2pointm;</programlisting>
<screen> d2point | d3point | d2pointm
---------+---------+----------
       2 |       3 |        3</screen>
		</refsection>
		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_CoordDim"/>, <xref linkend="ST_Dimension"/>, <xref linkend="ST_GeomFromEWKT"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_NPoints">
		<refnamediv>
			<refname>ST_NPoints</refname>
			<refpurpose>Returns the number of points (vertices) in a geometry.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_NPoints</function></funcdef>
			<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>

			<para>Return the number of points in a geometry.  Works for all geometries.</para>
			<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces was introduced.</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>

		</refsection>

		<refsection>
			<title>Examples</title>

			<para>Count the points in a 2D LineString.</para>
<programlisting>SELECT ST_NPoints('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)');</programlisting>
<screen> st_npoints
------------
          4
(1 row)</screen>

			<para>Count the points in a 3D LineString.</para>
<programlisting>SELECT ST_NPoints('LINESTRING(77.29 29.07 1,77.42 29.26 0,77.27 29.31 -1,77.29 29.07 3)');</programlisting>
<screen> st_npoints
------------
          4
(1 row)</screen>
		</refsection>
		<refsection>
			<title>See Also</title>

			<para><xref linkend="ST_NumPoints"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_NRings">
	  <refnamediv>
		<refname>ST_NRings</refname>
		<refpurpose>Returns the number of rings in a polygonal geometry.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_NRings</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>If the geometry is a polygon or multi-polygon returns the number of rings.  Unlike NumInteriorRings, it counts
		the outer rings as well.</para>
		<para>&Z_support;</para>
		<para>&curve_support;</para>

	  </refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_NRings(geom) As Nrings, ST_NumInteriorRings(geom) As ninterrings
FROM (SELECT 'POLYGON((1 2,3 4,5 6,1 2))'::geometry As geom) As foo;</programlisting>
<screen> nrings | ninterrings
--------+-------------
      1 |           0
(1 row)</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_NumInteriorRings"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_NumGeometries">
		<refnamediv>
			<refname>ST_NumGeometries</refname>
			<refpurpose>Returns the number of elements in a geometry collection.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_NumGeometries</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>

			<para>Returns the number of elements in a geometry collection (GEOMETRYCOLLECTION or MULTI*).
			For non-empty atomic geometries returns 1.  For empty geometries returns 0.
			</para>

			<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 support for Polyhedral surfaces, Triangles and TIN was introduced.</para>
			<para role="changed" conformance="2.0.0">Changed: 2.0.0 In prior versions this would return NULL if the geometry was not a collection/MULTI type.
				2.0.0+ now returns 1 for single geometries e.g POLYGON, LINESTRING, POINT.</para>
			<para role="changed" conformance="3.6.0">Changed: 3.6.0 TIN and PolyhedralSurface are treated as unitary geometries and return 1; use ST_NumPatches to count faces.</para>
			<para>&sqlmm_compliant; SQL-MM 3: 9.1.4</para>
			<para>&Z_support;</para>
			<para>&P_support;</para>
			<para>&T_support;</para>

		</refsection>

		<refsection>
			<title>Examples</title>

<para>This example returns 1; prior versions would have returned NULL.</para>
<programlisting language="sql">
SELECT ST_NumGeometries('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)');</programlisting>
<screen role="text-primary"> st_numgeometries
------------------
                1
(1 row)</screen>

			<para>A MultiPoint counts as one geometry within a GeometryCollection.</para>
<programlisting language="sql">SELECT ST_NumGeometries('GEOMETRYCOLLECTION(MULTIPOINT((-2 3),(-2 2)),
LINESTRING(5 5,10 10),
POLYGON((-7 4.2,-7.1 5,-7.1 4.3,-7 4.2)))');</programlisting>
<screen role="text-primary"> st_numgeometries
------------------
                3
(1 row)</screen>
		</refsection>
		<refsection>
			<title>See Also</title>

			<para><xref linkend="ST_GeometryN"/>, <xref linkend="ST_Multi"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_NumInteriorRings">
	  <refnamediv>
		<refname>ST_NumInteriorRings</refname>
		<refpurpose>Returns the number of interior rings (holes) of a Polygon.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_NumInteriorRings</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_polygon</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>
      Return the number of interior rings of a polygon geometry.
			Return NULL if the geometry is not a polygon.
    </para>

		<para>&sqlmm_compliant; SQL-MM 3: 8.2.5</para>
		<para role="changed" conformance="2.0.0">Changed: 2.0.0 - in prior versions it would allow passing a MULTIPOLYGON, returning the number of interior rings of first POLYGON.</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

			<para>Count the interior rings of a Polygon.</para>
			<programlisting language="sql" role="requires-external-state">SELECT gid, field1, field2, ST_NumInteriorRings(geom) AS numholes
FROM sometable;</programlisting>

			<para>For a MultiPolygon, dump its component Polygons and sum their interior ring counts.</para>
			<programlisting language="sql" role="requires-external-state">SELECT gid, field1, field2, SUM(ST_NumInteriorRings(geom)) AS numholes
FROM (
    SELECT gid, field1, field2, (ST_Dump(geom)).geom AS geom
    FROM sometable
) AS foo
GROUP BY gid, field1, field2;
            </programlisting>
	  </refsection>
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_NumInteriorRing"/>, <xref linkend="ST_InteriorRingN"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_NumInteriorRing">
	  <refnamediv>
		<refname>ST_NumInteriorRing</refname>
		<refpurpose>Returns the number of interior rings (holes) of a Polygon. Alias for ST_NumInteriorRings.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_NumInteriorRing</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_polygon</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>This function is an alias for <xref linkend="ST_NumInteriorRings"/>.</para>
		<para role="availability" conformance="1.2.2">Availability: 1.2.2</para>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_NumInteriorRings"/>, <xref linkend="ST_InteriorRingN"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_NumPatches">
	  <refnamediv>
		<refname>ST_NumPatches</refname>
		<refpurpose>Returns the number of faces in a PolyhedralSurface or TIN.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_NumPatches</function></funcdef>
			<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the number of faces in a PolyhedralSurface or TIN.
		Returns NULL for other geometries. Unlike <xref linkend="ST_NumGeometries"/>,
		this function counts individual faces.</para>

		<para role="availability" conformance="2.0.0">Availability: 2.0.0</para>
		<para>&Z_support;</para>
		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant; SQL-MM ISO/IEC 13249-3: 8.5</para>
		<para>&P_support;</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_NumPatches('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)) )');</programlisting>
<screen> st_numpatches
---------------
             6
(1 row)</screen>
	  </refsection>
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_GeomFromEWKT"/>, <xref linkend="ST_NumGeometries"/>, <xref linkend="ST_PatchN"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_NumPoints">
	  <refnamediv>
		<refname>ST_NumPoints</refname>
		<refpurpose>Returns the number of points in a LineString or CircularString.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>integer <function>ST_NumPoints</function></funcdef>
			<paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Return the number of points in an ST_LineString or
		  ST_CircularString value. Prior to 1.4 only works with linestrings as the specs state.  From 1.4 forward this is an alias for ST_NPoints which returns number of vertices for
		  not just linestrings.
		  Consider using ST_NPoints instead which is multi-purpose
		  and works with many geometry types.</para>

		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant; SQL-MM 3: 7.2.4</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting language="sql">SELECT ST_NumPoints('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)');</programlisting>
<screen role="text-primary"> st_numpoints
--------------
            4
(1 row)</screen>
	  </refsection>
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_NPoints"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_PatchN">
	  <refnamediv>
		<refname>ST_PatchN</refname>

		<refpurpose>Returns the Nth face of a PolyhedralSurface or TIN.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_PatchN</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
			<paramdef><type>integer </type> <parameter>n</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns the 1-based Nth face of a PolyhedralSurface or TIN.
			Returns NULL for other geometries or an out-of-range index.
			Use this function to access faces, because <xref linkend="ST_GeometryN"/>
			treats PolyhedralSurface and TIN as unitary geometries.</para>

		<note>
		  <para>Index is 1-based.</para>
		</note>

		<note>
		  <para>If you want to extract all elements of a geometry <xref linkend="ST_Dump"/> is more efficient.</para>
		</note>

		<para role="availability" conformance="2.0.0">Availability: 2.0.0</para>
		<para>&sqlmm_compliant; SQL-MM ISO/IEC 13249-3: 8.5</para>
		<para>&Z_support;</para>
		<para>&P_support;</para>
		<para>&T_support;</para>

	  </refsection>


	  <refsection>
		<title>Examples</title>

		<para>Extract the 2nd face of the polyhedral surface.</para>
		<programlisting>
SELECT ST_PatchN(geom, 2) As geomewkt
FROM (
VALUES ('POLYHEDRALSURFACE( ((0 0 0,0 0 1,0 1 1,0 1 0,0 0 0)),
    ((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0)),((0 0 0,1 0 0,1 0 1,0 0 1,0 0 0)),
    ((1 1 0,1 1 1,1 0 1,1 0 0,1 1 0)),
    ((0 1 0,0 1 1,1 1 1,1 1 0,0 1 0)),((0 0 1,1 0 1,1 1 1,0 1 1,0 0 1)) )'::geometry) ) As foo(geom);</programlisting>
<screen role="visual-primary text-primary">POLYGON((0 0 0,0 1 0,1 1 0,1 0 0,0 0 0))</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_AsEWKT"/>, <xref linkend="ST_GeomFromEWKT"/>, <xref linkend="ST_Dump"/>, <xref linkend="ST_GeometryN"/>, <xref linkend="ST_NumGeometries"/>, <xref linkend="ST_NumPatches"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_PointN">
	  <refnamediv>
		<refname>ST_PointN</refname>

		<refpurpose>Returns the Nth point in the first LineString or circular LineString in a
			geometry. </refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>geometry <function>ST_PointN</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_linestring</parameter></paramdef>
			<paramdef><type>integer </type> <parameter>n</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Return the Nth point in a single linestring or circular linestring in the
			geometry. Negative values are counted backwards from the end of the LineString, so that -1 is the last point. Returns NULL if there is no linestring in the
			geometry.</para>

		<note>
			  <para>Index is 1-based as for OGC specs since version 0.8.0.
              Backward indexing (negative index) is not in OGC.
			  Previous versions implemented this as 0-based instead.</para>
		</note>

		<note>
			  <para>If you want to get the Nth point of each LineString in a MultiLineString, use in conjunction
			  with ST_Dump</para>
		</note>

		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant; SQL-MM 3: 7.2.5, 7.3.5</para>
		<para>&Z_support;</para>
		<para>&curve_support;</para>
		<para role="changed" conformance="2.0.0">Changed: 2.0.0 no longer works with single geometry multilinestrings.  In older
	  versions of PostGIS -- a single line multilinestring would work happily with this
	  function and return the start point.  In 2.0.0 it just returns NULL like any other multilinestring.</para>
		<para role="changed" conformance="2.3.0"> Changed: 2.3.0 : negative indexing available (-1 is last point)
    </para>

	  </refsection>


	  <refsection>
		<title>Examples</title>

		<para>This example extracts all POINT geometries from a LineString.</para>
		<programlisting>
SELECT ST_PointN(
      column1,
      generate_series(1, ST_NPoints(column1))
   )
FROM ( VALUES ('LINESTRING(0 0,1 1,2 2)'::geometry) ) AS foo;</programlisting>
<screen role="visual-primary text-primary"> POINT(0 0)
 POINT(1 1)
 POINT(2 2)
(3 rows)</screen>
	<para>This example uses a CircularString.</para>
	<programlisting>SELECT ST_PointN('CIRCULARSTRING(1 2,3 2,1 2)', 2);</programlisting>
	<screen role="visual-primary text-primary">POINT(3 2)</screen>
	<para>The index is 1-based. A negative index counts backward from the end of the LineString.</para>
	<programlisting>SELECT f
FROM ST_GeomFromText('LINESTRING(0 0 0,1 1 1,2 2 2)') AS g
  CROSS JOIN ST_PointN(g, -2) AS f;</programlisting>
	<screen role="visual-primary text-primary">POINT Z (1 1 1)</screen>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_NPoints"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_Points">
		<refnamediv>
			<refname>ST_Points</refname>
			<refpurpose>Returns a MultiPoint containing the coordinates of a geometry.
			</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>geometry <function>ST_Points</function></funcdef>
					<paramdef>
						<type>geometry</type>
						<parameter>geom</parameter>
					</paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>

			<para>
				Returns a MultiPoint containing all the coordinates of a geometry.
                Duplicate points are preserved,
				including the start and end points of ring geometries.
				(If desired, duplicate points can be removed by calling
				<xref linkend="ST_RemoveRepeatedPoints"/> on the result).
			</para>

            <para>
            To obtain information about the position of each coordinate in the parent geometry
            use <xref linkend="ST_DumpPoints"/>.
            </para>

			<para>
				M and Z coordinates are preserved if present.
			</para>

			<para>&curve_support;</para>
			<para>&Z_support;</para>

			<para role="availability" conformance="2.3.0">Availability: 2.3.0</para>

		</refsection>

		<refsection>
			<title>Examples</title>

			<programlisting language="sql">SELECT ST_Points('POLYGON Z ((30 10 4,10 30 5,40 40 6,30 10 4))');</programlisting>
			<screen role="visual-primary text-primary">MULTIPOINT Z ((30 10 4),(10 30 5),(40 40 6),(30 10 4))</screen>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_RemoveRepeatedPoints"/>, <xref linkend="ST_DumpPoints"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_StartPoint">
	<refnamediv>
	  <refname>ST_StartPoint</refname>

	  <refpurpose>Returns the first point of a LineString, CircularLineString, or NURBSCurve.</refpurpose>
	</refnamediv>

	<refsynopsisdiv>
	  <funcsynopsis>
		<funcprototype>
		  <funcdef>geometry <function>ST_StartPoint</function></funcdef>

		  <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		</funcprototype>
	  </funcsynopsis>
	</refsynopsisdiv>

	<refsection>
	  <title>Description</title>

	  <para>Returns the first point of a <varname>LINESTRING</varname>,
      <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname> geometry
	  as a <varname>POINT</varname>.
	  For other geometries, returns the first point in coordinate order.</para>

	  <para>&sqlmm_compliant; SQL-MM 3: 7.1.3</para>
	  <para>&Z_support;</para>
	  <para>&curve_support;</para>

	  <para role="enhanced" conformance="3.2.0">Enhanced: 3.2.0 returns a point for all geometries. Prior behavior returns NULLs if input was not a LineString.</para>
	  <para role="changed" conformance="2.0.0">Changed: 2.0.0 no longer works with single geometry MultiLineStrings.  In older
	  versions of PostGIS a single-line MultiLineString would work happily with this
	  function and return the start point.  In 2.0.0 it just returns NULL like any other MultiLineString.
	  The old behavior was an undocumented feature, but people who assumed they had their data stored as LINESTRING
	  may experience these returning NULL in 2.0.0.</para>

	</refsection>

	<refsection>
	  <title>Examples</title>
<para>Start point of a LineString</para>
	  <programlisting>SELECT ST_StartPoint('LINESTRING(0 1,0 2)'::geometry);</programlisting>
<screen role="visual-primary text-primary">POINT(0 1)</screen>

<para>Start point of a Point is the Point itself</para>
<programlisting>SELECT ST_StartPoint('POINT(0 1)'::geometry);</programlisting>
<screen role="visual-primary text-primary">POINT(0 1)</screen>

<para>Start point of a 3D LineString</para>
<programlisting>SELECT ST_StartPoint('LINESTRING(0 1 1,0 2 2)'::geometry);</programlisting>
<screen role="visual-primary text-primary">POINT(0 1 1)</screen>

<para>Start point of a CircularString</para>
<programlisting>SELECT ST_StartPoint('CIRCULARSTRING(5 2,-3 2,-2 1,-4 2,6 3)'::geometry);</programlisting>
<screen role="visual-primary text-primary">POINT(5 2)</screen>

<para>Start point of a NURBSCurve</para>
<programlisting language="sql">SELECT ST_StartPoint('NURBSCURVE(2, (0 0, 1 1, 2 0))'::geometry);</programlisting>
<screen role="visual-primary text-primary">POINT(0 0)</screen>

<para>Build edge node references from the start and end points of a LineString
table. The example uses exact endpoint equality, so linework with nearly
coincident endpoints should be snapped or otherwise cleaned first.</para>
<programlisting>WITH roads(road_id, geom) AS (
  VALUES
    (1, 'LINESTRING(0 0, 1 0)'::geometry),
    (2, 'LINESTRING(1 0, 1 1)'::geometry),
    (3, 'LINESTRING(1 0, 2 0)'::geometry)
),
endpoints AS (
  SELECT road_id, 'from' AS end_name, ST_StartPoint(geom) AS geom,
         ST_AsEWKB(ST_StartPoint(geom)) AS endpoint_key
  FROM roads
  UNION ALL
  SELECT road_id, 'to' AS end_name, ST_EndPoint(geom) AS geom,
         ST_AsEWKB(ST_EndPoint(geom)) AS endpoint_key
  FROM roads
),
nodes AS (
  SELECT dense_rank() OVER (ORDER BY ST_X(geom), ST_Y(geom), endpoint_key) AS node_id,
         endpoint_key
  FROM (
    SELECT DISTINCT ON (endpoint_key) endpoint_key, geom
    FROM endpoints
    ORDER BY endpoint_key
  ) AS distinct_endpoints
)
SELECT e.road_id,
       max(n.node_id) FILTER (WHERE e.end_name = 'from') AS from_node,
       max(n.node_id) FILTER (WHERE e.end_name = 'to') AS to_node
FROM endpoints AS e
JOIN nodes AS n USING (endpoint_key)
GROUP BY e.road_id
ORDER BY e.road_id;</programlisting>
<screen> road_id | from_node | to_node
---------+-----------+---------
     1 |         1 |       2
     2 |         2 |       3
     3 |         2 |       4</screen>
		</refsection>

	<refsection>
	  <title>See Also</title>

	  <para><xref linkend="ST_EndPoint"/>, <xref linkend="ST_PointN"/></para>
	</refsection>
  </refentry>

	<refentry xml:id="ST_StartM">
	<refnamediv>
	  <refname>ST_StartM</refname>

	  <refpurpose>Returns the M coordinate of the first point of a LineString, CircularLineString, or NURBSCurve.</refpurpose>
	</refnamediv>

	<refsynopsisdiv>
	  <funcsynopsis>
		<funcprototype>
		  <funcdef>float8 <function>ST_StartM</function></funcdef>

		  <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
		</funcprototype>
	  </funcsynopsis>
	</refsynopsisdiv>

	<refsection>
	  <title>Description</title>

	  <para>Returns the M coordinate of the first point of a <varname>LINESTRING</varname>,
      <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname> geometry.
      Returns <varname>NULL</varname> if the input geometry does not have an M dimension or
	  is not a <varname>LINESTRING</varname>, <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname>.</para>

	  <para>&curve_support;</para>
	</refsection>

	<refsection>
	  <title>Examples</title>
<para>Start M value of a LineString</para>
	  <programlisting>SELECT ST_StartM('LINESTRING M(0 0 10,1 1 20,2 0 30)'::geometry);</programlisting>
<screen>10</screen>

<para>Start M value of a CircularString</para>
<programlisting>SELECT ST_StartM('CIRCULARSTRING M(0 0 5,1 1 10,2 0 15)'::geometry);</programlisting>
<screen>5</screen>

<para>Start M value of a NURBSCurve</para>
<programlisting>SELECT ST_StartM('NURBSCURVE M(2, (0 0 100, 1 1 200, 2 0 300))'::geometry);</programlisting>
<screen>100</screen>

<para>Geometry without M dimension returns NULL</para>
<programlisting>SELECT ST_StartM('LINESTRING(0 0,1 1)'::geometry) IS NULL AS is_null;</programlisting>
<screen>t</screen>
	</refsection>

	<refsection>
	  <title>See Also</title>

	  <para><xref linkend="ST_EndM"/>, <xref linkend="ST_SetStartM"/>, <xref linkend="ST_StartPoint"/></para>
	</refsection>
  </refentry>

	<refentry xml:id="ST_EndM">
	<refnamediv>
	  <refname>ST_EndM</refname>

	  <refpurpose>Returns the M coordinate of the last point of a LineString, CircularLineString, or NURBSCurve.</refpurpose>
	</refnamediv>

	<refsynopsisdiv>
	  <funcsynopsis>
		<funcprototype>
		  <funcdef>float8 <function>ST_EndM</function></funcdef>

		  <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
		</funcprototype>
	  </funcsynopsis>
	</refsynopsisdiv>

	<refsection>
	  <title>Description</title>

	  <para>Returns the M coordinate of the last point of a <varname>LINESTRING</varname>,
      <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname> geometry.
      Returns <varname>NULL</varname> if the input geometry does not have an M dimension or
	  is not a <varname>LINESTRING</varname>, <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname>.</para>

	  <para>&curve_support;</para>
	</refsection>

	<refsection>
	  <title>Examples</title>
<para>End M value of a LineString</para>
	  <programlisting>SELECT ST_EndM('LINESTRING M(0 0 10,1 1 20,2 0 30)'::geometry);</programlisting>
<screen>30</screen>

<para>End M value of a CircularString</para>
<programlisting>SELECT ST_EndM('CIRCULARSTRING M(0 0 5,1 1 10,2 0 15)'::geometry);</programlisting>
<screen>15</screen>

<para>End M value of a NURBSCurve</para>
<programlisting>SELECT ST_EndM('NURBSCURVE M(2, (0 0 100, 1 1 200, 2 0 300))'::geometry);</programlisting>
<screen>300</screen>

<para>Geometry without M dimension returns NULL</para>
<programlisting>SELECT ST_EndM('LINESTRING(0 0,1 1)'::geometry) IS NULL AS is_null;</programlisting>
<screen>t</screen>
	</refsection>

	<refsection>
	  <title>See Also</title>

	  <para><xref linkend="ST_StartM"/>, <xref linkend="ST_SetEndM"/>, <xref linkend="ST_EndPoint"/></para>
	</refsection>
  </refentry>

	<refentry xml:id="ST_SetStartM">
	<refnamediv>
	  <refname>ST_SetStartM</refname>

	  <refpurpose>Sets the M coordinate of the first point of a LineString, CircularLineString, or NURBSCurve.</refpurpose>
	</refnamediv>

	<refsynopsisdiv>
	  <funcsynopsis>
		<funcprototype>
		  <funcdef>geometry <function>ST_SetStartM</function></funcdef>

		  <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
		  <paramdef><type>float8 </type> <parameter>m</parameter></paramdef>
		</funcprototype>
	  </funcsynopsis>
	</refsynopsisdiv>

	<refsection>
	  <title>Description</title>

	  <para>Returns a copy of the input <varname>LINESTRING</varname>,
      <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname> geometry
      with the M coordinate of the first point set to the specified value.
      If the input geometry does not have an M dimension, it will be added.
      Returns <varname>NULL</varname> if the input
	  is not a <varname>LINESTRING</varname>, <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname>.</para>

	  <para>&curve_support;</para>
	</refsection>

	<refsection>
	  <title>Examples</title>
<para>Set start M value of a LineString</para>
	  <programlisting>SELECT ST_SetStartM('LINESTRING M(0 0 10,1 1 20,2 0 30)'::geometry, 100);</programlisting>
<screen role="visual-primary text-primary">LINESTRING M (0 0 100,1 1 20,2 0 30)</screen>

<para>Add M dimension and set start M value</para>
<programlisting>SELECT ST_SetStartM('LINESTRING(0 0,1 1,2 0)'::geometry, 50);</programlisting>
<screen role="visual-primary text-primary">LINESTRING M (0 0 50,1 1 0,2 0 0)</screen>

<para>Set start M value of a CircularString</para>
<programlisting>SELECT ST_SetStartM('CIRCULARSTRING M(0 0 5,1 1 10,2 0 15)'::geometry, 99);</programlisting>
<screen role="visual-primary text-primary">CIRCULARSTRING M (0 0 99,1 1 10,2 0 15)</screen>

<para>Set start M value of a NURBSCurve</para>
<programlisting language="sql">SELECT ST_SetStartM('NURBSCURVE M(2, (0 0 100, 1 1 200, 2 0 300))'::geometry, 500);</programlisting>
<screen role="visual-primary text-primary">NURBSCURVE M (DEGREE 2,CONTROLPOINTS M (NURBSPOINT(WEIGHTEDPOINT M (0 0 500),WEIGHT 1), NURBSPOINT(WEIGHTEDPOINT M (1 1 200),WEIGHT 1), NURBSPOINT(WEIGHTEDPOINT M (2 0 300),WEIGHT 1)),KNOTS (KNOT(0,3), KNOT(1,3)))</screen>
	</refsection>

	<refsection>
	  <title>See Also</title>

	  <para><xref linkend="ST_SetEndM"/>, <xref linkend="ST_StartM"/>, <xref linkend="ST_StartPoint"/></para>
	</refsection>
  </refentry>

	<refentry xml:id="ST_SetEndM">
	<refnamediv>
	  <refname>ST_SetEndM</refname>

	  <refpurpose>Sets the M coordinate of the last point of a LineString, CircularLineString, or NURBSCurve.</refpurpose>
	</refnamediv>

	<refsynopsisdiv>
	  <funcsynopsis>
		<funcprototype>
		  <funcdef>geometry <function>ST_SetEndM</function></funcdef>

		  <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
		  <paramdef><type>float8 </type> <parameter>m</parameter></paramdef>
		</funcprototype>
	  </funcsynopsis>
	</refsynopsisdiv>

	<refsection>
	  <title>Description</title>

	  <para>Returns a copy of the input <varname>LINESTRING</varname>,
      <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname> geometry
      with the M coordinate of the last point set to the specified value.
      If the input geometry does not have an M dimension, it will be added.
      Returns <varname>NULL</varname> if the input
	  is not a <varname>LINESTRING</varname>, <varname>CIRCULARLINESTRING</varname>, or <varname>NURBSCURVE</varname>.</para>

	  <para>&curve_support;</para>
	</refsection>

	<refsection>
	  <title>Examples</title>
<para>Set end M value of a LineString</para>
	  <programlisting>SELECT ST_SetEndM('LINESTRING M(0 0 10,1 1 20,2 0 30)'::geometry, 999);</programlisting>
<screen role="visual-primary text-primary">LINESTRING M (0 0 10,1 1 20,2 0 999)</screen>

<para>Add M dimension and set end M value</para>
<programlisting>SELECT ST_SetEndM('LINESTRING(0 0,1 1,2 0)'::geometry, 75);</programlisting>
<screen role="visual-primary text-primary">LINESTRING M (0 0 0,1 1 0,2 0 75)</screen>

<para>Set end M value of a CircularString</para>
<programlisting>SELECT ST_SetEndM('CIRCULARSTRING M(0 0 5,1 1 10,2 0 15)'::geometry, 88);</programlisting>
<screen role="visual-primary text-primary">CIRCULARSTRING M (0 0 5,1 1 10,2 0 88)</screen>

<para>Set end M value of a NURBSCurve</para>
<programlisting language="sql">SELECT ST_SetEndM('NURBSCURVE M(2, (0 0 100, 1 1 200, 2 0 300))'::geometry, 999);</programlisting>
<screen role="visual-primary text-primary">NURBSCURVE M (DEGREE 2,CONTROLPOINTS M (NURBSPOINT(WEIGHTEDPOINT M (0 0 100),WEIGHT 1), NURBSPOINT(WEIGHTEDPOINT M (1 1 200),WEIGHT 1), NURBSPOINT(WEIGHTEDPOINT M (2 0 999),WEIGHT 1)),KNOTS (KNOT(0,3), KNOT(1,3)))</screen>
	</refsection>

	<refsection>
	  <title>See Also</title>

	  <para><xref linkend="ST_SetStartM"/>, <xref linkend="ST_EndM"/>, <xref linkend="ST_EndPoint"/></para>
	</refsection>
  </refentry>

	<refentry xml:id="ST_Summary">
	  <refnamediv>
		<refname>ST_Summary</refname>

		<refpurpose>Returns a text summary of the contents of a geometry.
		</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>text <function>ST_Summary</function></funcdef>
			<paramdef><type>geometry </type> <parameter>g</parameter></paramdef>
		  </funcprototype>
		  <funcprototype>
			<funcdef>text <function>ST_Summary</function></funcdef>
			<paramdef><type>geography </type> <parameter>g</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns a text summary of the contents of the geometry.</para>

		<para>
                  Flags shown square brackets after the geometry type
                  have the following meaning:
                  <itemizedlist>
                    <listitem><para>M: has M coordinate</para></listitem>
                    <listitem><para>Z: has Z coordinate</para></listitem>
                    <listitem><para>B: has a cached bounding box</para></listitem>
                    <listitem><para>G: is geodetic (geography)</para></listitem>
                    <listitem><para>S: has spatial reference system</para></listitem>
                  </itemizedlist>
                </para>
	<!-- Optionally mention Circular String Support -->
	<para>&curve_support;</para>

	<!-- Optionally mention supports Polyhedral Surface  -->
	<para>&P_support;</para>

	<!-- Optionally mention support for Triangles and TINS  -->
	<para>&T_support;</para>
		<para role="availability" conformance="1.2.2">Availability: 1.2.2</para>
		<para role="enhanced" conformance="2.0.0">Enhanced: 2.0.0 added support for geography</para>
		<para role="enhanced" conformance="2.1.0">Enhanced: 2.1.0 S flag to denote if has a known spatial reference system</para>
		<para role="enhanced" conformance="2.2.0">Enhanced: 2.2.0 Added support for TIN and Curves</para>
	  </refsection>

	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_Summary('LINESTRING(0 0,1 1)'::geometry) as geom,
ST_Summary('POLYGON((0 0,1 1,1 2,1 1,0 0))'::geography) geog;</programlisting>
<screen>            geom             |          geog
-----------------------------+--------------------------
 LineString[B] with 2 points | Polygon[BGS] with 1 rings
                             | ring 0 has 5 points
                             :
(1 row)</screen>
<programlisting>SELECT ST_Summary('LINESTRING(0 0 1,1 1 1)'::geography) As geog_line,
ST_Summary('SRID=4326;POLYGON((0 0 1,1 1 2,1 2 3,1 1 1,0 0 1))'::geometry) As geom_poly;</programlisting>
<screen>          geog_line             |        geom_poly
-------------------------------- +--------------------------
 LineString[ZBGS] with 2 points | Polygon[ZBS] with 1 rings
                                :    ring 0 has 5 points
                                :
(1 row)</screen>
	  </refsection>

	  <refsection>
		<title>See Also</title>

		<para>
<xref linkend="PostGIS_DropBBox"/>,
<xref linkend="PostGIS_AddBBox"/>,
<xref linkend="ST_Force_3DM"/>,
<xref linkend="ST_Force_3DZ"/>,
<xref linkend="ST_Force2D"/>,
<xref linkend="geography"/>
		</para>

		<para>
<xref linkend="ST_IsValid"/>,
<xref linkend="ST_IsValid"/>,
<xref linkend="ST_IsValidReason"/>,
<xref linkend="ST_IsValidDetail"/>
		</para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_X">
	  <refnamediv>
		<refname>ST_X</refname>

		<refpurpose>Returns the X coordinate of a Point.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_X</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_point</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Return the X coordinate of the point, or NULL if not
			available. Input must be a point.</para>

		<note><para>To get the minimum and maximum X value of geometry coordinates use the functions
		<xref linkend="ST_XMin"/> and <xref linkend="ST_XMax"/>.</para></note>

		<para>&sqlmm_compliant; SQL-MM 3: 6.1.3</para>
		<para>&Z_support;</para>

	  </refsection>


	  <refsection>
		<title>Examples</title>
		<programlisting>SELECT ST_X('POINT(1 2 3 4)');</programlisting>
<screen>1</screen>
<programlisting>SELECT ST_Y(ST_Centroid('LINESTRING(1 2 3 4,1 1 1 1)'::geometry));</programlisting>
<screen>1.5</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Centroid"/>, <xref linkend="ST_GeomFromEWKT"/>, <xref linkend="ST_M"/>, <xref linkend="ST_XMax"/>, <xref linkend="ST_XMin"/>, <xref linkend="ST_Y"/>, <xref linkend="ST_Z"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_Y">
	  <refnamediv>
		<refname>ST_Y</refname>

		<refpurpose>Returns the Y coordinate of a Point.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_Y</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_point</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Return the Y coordinate of the point, or NULL if not
			available. Input must be a point.</para>

		<note><para>To get the minimum and maximum Y value of geometry coordinates use the functions
		<xref linkend="ST_YMin"/> and <xref linkend="ST_YMax"/>.</para></note>

		<para>&sfs_compliant;</para>
		<para>&sqlmm_compliant; SQL-MM 3: 6.1.4</para>
		<para>&Z_support;</para>

	  </refsection>


	  <refsection>
		<title>Examples</title>
		<programlisting>SELECT ST_Y('POINT(1 2 3 4)');</programlisting>
<screen>2</screen>
<programlisting>SELECT ST_Y(ST_Centroid('LINESTRING(1 2 3 4,1 1 1 1)'::geometry));</programlisting>
<screen>1.5</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_Centroid"/>, <xref linkend="ST_GeomFromEWKT"/>, <xref linkend="ST_M"/>, <xref linkend="ST_X"/>, <xref linkend="ST_YMax"/>, <xref linkend="ST_YMin"/>, <xref linkend="ST_Z"/></para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_Z">
	  <refnamediv>
		<refname>ST_Z</refname>

		<refpurpose>Returns the Z coordinate of a Point.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>float <function>ST_Z</function></funcdef>
			<paramdef><type>geometry </type> <parameter>a_point</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Return the Z coordinate of the point, or NULL if not
			available. Input must be a point.</para>

		<note><para>To get the minimum and maximum Z value of geometry coordinates use the functions
		<xref linkend="ST_ZMin"/> and <xref linkend="ST_ZMax"/>.</para></note>


		<para>&sqlmm_compliant;</para>
		<para>&Z_support;</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>
		<programlisting>SELECT ST_Z('POINT(1 2 3 4)');</programlisting>
<screen>3</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_GeomFromEWKT"/>, <xref linkend="ST_M"/>, <xref linkend="ST_X"/>, <xref linkend="ST_Y"/>, <xref linkend="ST_ZMax"/>, <xref linkend="ST_ZMin"/> </para>
	  </refsection>
	</refentry>

	<refentry xml:id="ST_ZMFlag">
	  <refnamediv>
		<refname>ST_ZMFlag</refname>

		<refpurpose>Returns a code indicating the ZM coordinate dimension of a geometry.</refpurpose>
	  </refnamediv>

	  <refsynopsisdiv>
		<funcsynopsis>
		  <funcprototype>
			<funcdef>smallint <function>ST_ZMFlag</function></funcdef>
			<paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
		  </funcprototype>
		</funcsynopsis>
	  </refsynopsisdiv>

	  <refsection>
		<title>Description</title>

		<para>Returns a code indicating the ZM coordinate dimension of a geometry. </para>

		<para>Values are: 0 = 2D, 1 = 3D-M, 2 = 3D-Z, 3 = 4D.</para>

		<para>&Z_support;</para>
		<para>&curve_support;</para>
	  </refsection>


	  <refsection>
		<title>Examples</title>

		<programlisting>SELECT ST_ZMFlag('LINESTRING(1 2,3 4)');</programlisting>
<screen>0</screen>
<programlisting>SELECT ST_ZMFlag('LINESTRINGM(1 2 3, 3 4 3)');</programlisting>
<screen>1</screen>
<programlisting>SELECT ST_ZMFlag('CIRCULARSTRING(1 2 3,3 4 3,5 6 3)');</programlisting>
<screen>2</screen>
<programlisting>SELECT ST_ZMFlag('POINT(1 2 3 4)');</programlisting>
<screen>3</screen>
	  </refsection>

	  <!-- Optionally add a "See Also" section -->
	  <refsection>
		<title>See Also</title>

		<para><xref linkend="ST_CoordDim"/>, <xref linkend="ST_NDims"/>, <xref linkend="ST_Dimension"/></para>
	  </refsection>
	</refentry>

    <refentry xml:id="ST_HasZ">
  <refnamediv>
    <refname>ST_HasZ</refname>
    <refpurpose>Checks if a geometry has a Z dimension.</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcprototype>
        <funcdef>boolean <function>ST_HasZ</function></funcdef>
        <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>

  <refsection>
    <title>Description</title>

    <para>Checks if the input geometry has a Z dimension and returns a boolean value. If the geometry has a Z dimension, it returns true; otherwise, it returns false.</para>

    <para>Geometry objects with a Z dimension typically represent three-dimensional (3D) geometries, while those without it are two-dimensional (2D) geometries.</para>

    <para>This function is useful for determining if a geometry has elevation or height information.</para>

    <para role="availability" conformance="3.5.0">Availability: 3.5.0</para>
    <para>&Z_support;</para>
    <para>&M_support;</para>
  </refsection>

  <refsection>
    <title>Examples</title>

    <programlisting language="sql">SELECT ST_HasZ('POINT(1 2 3)');</programlisting>
    <screen role="text-primary">t</screen>
    <programlisting language="sql">SELECT ST_HasZ('LINESTRING(0 0,1 1)');</programlisting>
    <screen role="text-primary">f</screen>
  </refsection>

  <refsection>
    <title>See Also</title>
    <para><xref linkend="ST_ZMFlag"/></para>
    <para><xref linkend="ST_HasM"/></para>
  </refsection>
</refentry>

<refentry xml:id="ST_HasM">
  <refnamediv>
    <refname>ST_HasM</refname>
    <refpurpose>Checks if a geometry has an M (measure) dimension.</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <funcsynopsis>
      <funcprototype>
        <funcdef>boolean <function>ST_HasM</function></funcdef>
        <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
      </funcprototype>
    </funcsynopsis>
  </refsynopsisdiv>

  <refsection>
    <title>Description</title>

    <para>Checks if the input geometry has an M (measure) dimension and returns a boolean value. If the geometry has an M dimension, it returns true; otherwise, it returns false.</para>

    <para>Geometry objects with an M dimension typically represent measurements or additional data associated with spatial features.</para>

    <para>This function is useful for determining if a geometry includes measure information.</para>

    <para role="availability" conformance="3.5.0">Availability: 3.5.0</para>
    <para>&Z_support;</para>
    <para>&M_support;</para>
  </refsection>

  <refsection>
    <title>Examples</title>

    <programlisting language="sql">SELECT ST_HasM('POINTM(1 2 3)');</programlisting>
    <screen role="text-primary">t</screen>
    <programlisting language="sql">SELECT ST_HasM('LINESTRING(0 0,1 1)');</programlisting>
    <screen role="text-primary">f</screen>
  </refsection>

  <refsection>
    <title>See Also</title>
    <para><xref linkend="ST_ZMFlag"/></para>
    <para><xref linkend="ST_HasZ"/></para>
  </refsection>
</refentry>

	<refentry xml:id="ST_ControlPoints">
		<refnamediv>
			<refname>ST_ControlPoints</refname>
			<refpurpose>Returns the control points of a NURBS curve as a MULTIPOINT geometry.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>geometry <function>ST_ControlPoints</function></funcdef>
					<paramdef><type>geometry</type> <parameter>nurbscurve</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>Extracts the control points from a NURBS curve and returns them as a MULTIPOINT geometry. Control points define the control polygon that influences the shape of the NURBS curve.</para>

			<para>The function raises an error if the input is not a NURBS curve. Returns NULL if the input is NULL.</para>

			<para role="availability" conformance="3.7.0">Availability: 3.7.0</para>
		</refsection>

		<refsection>
				<title>Examples</title>
				<para>This example extracts control points from a NURBS curve.</para>
				<programlisting>SELECT ST_ControlPoints('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry);</programlisting>
<screen role="visual-primary text-primary">MULTIPOINT((0 0),(5 10),(10 0))</screen>
				<para>This example counts the control points.</para>
<programlisting>SELECT ST_NPoints(ST_ControlPoints('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry));</programlisting>
<screen>3</screen>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_MakeNurbsCurve"/>, <xref linkend="ST_NumControlPoints"/>, <xref linkend="ST_Weights"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_Degree">
		<refnamediv>
			<refname>ST_Degree</refname>
			<refpurpose>Returns the polynomial degree of a NURBS curve.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>integer <function>ST_Degree</function></funcdef>
					<paramdef><type>geometry</type> <parameter>nurbscurve</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>Returns the polynomial degree of a NURBS curve as an integer. The degree determines the curve's smoothness and flexibility. Higher degrees produce smoother curves but require more control points.</para>

			<para>The function raises an error if the input is not a NURBS curve. Returns NULL if the input is NULL.</para>

			<para role="availability" conformance="3.7.0">Availability: 3.7.0</para>
		</refsection>

		<refsection>
				<title>Examples</title>
				<para>This example returns the degree of a NURBS curve.</para>
				<programlisting>SELECT ST_Degree('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry);</programlisting>
<screen>2</screen>
				<para>This example checks whether a NURBS curve is cubic.</para>
<programlisting>SELECT ST_Degree('NURBSCURVE(3, (0 0, 2 5, 5 8, 10 0))'::geometry) = 3;</programlisting>
<screen>t</screen>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_MakeNurbsCurve"/>, <xref linkend="ST_NumControlPoints"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_Weights">
		<refnamediv>
			<refname>ST_Weights</refname>
			<refpurpose>Returns the weight array of a rational NURBS curve.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>float8[] <function>ST_Weights</function></funcdef>
					<paramdef><type>geometry</type> <parameter>nurbscurve</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>Returns the weight values of a rational NURBS curve as an array of double precision values. Weights control the influence of each control point on the curve shape. Higher weights pull the curve closer to the corresponding control point.</para>

			<para>Returns NULL if the curve has no weights (non-rational B-spline) or if the input is NULL. Raises an error if the input is not a NURBS curve.</para>

			<para role="availability" conformance="3.7.0">Availability: 3.7.0</para>
		</refsection>

		<refsection>
				<title>Examples</title>
				<para>This example returns weights from a rational NURBS curve.</para>
				<programlisting>SELECT ST_Weights(ST_MakeNurbsCurve(2, 'LINESTRING(0 0,5 10,10 0)'::geometry, ARRAY[1.0, 2.0, 1.0]));</programlisting>
<screen>{1,2,1}</screen>
				<para>This example checks the weights of a non-rational curve.</para>
<programlisting>SELECT ST_Weights('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry);</programlisting>
<screen>null</screen>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_MakeNurbsCurve"/>, <xref linkend="ST_NurbsCurveIsRational"/>, <xref linkend="ST_ControlPoints"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_Knots">
		<refnamediv>
			<refname>ST_Knots</refname>
			<refpurpose>Returns the knot vector of a NURBS curve.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>float8[] <function>ST_Knots</function></funcdef>
					<paramdef><type>geometry</type> <parameter>nurbscurve</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>Returns the knot vector of a NURBS curve as an array of double precision values. The knot vector defines the parameter space and controls where and how the control points affect the curve. It must be a non-decreasing sequence with length equal to (number of control points + degree + 1).</para>

			<para>Returns NULL if the curve uses the default uniform clamped knot vector or if the input is NULL. Raises an error if the input is not a NURBS curve.</para>

			<para role="availability" conformance="3.7.0">Availability: 3.7.0</para>
		</refsection>

		<refsection>
				<title>Examples</title>
				<para>This example returns knots from a NURBS curve with a custom knot vector.</para>
				<programlisting>
SELECT ST_Knots(ST_MakeNurbsCurve(
        2,
        'LINESTRING(0 0,5 10,10 0)'::geometry,
        ARRAY[1.0, 2.0, 1.0],
        ARRAY[0, 0, 0, 1, 1, 1]));</programlisting>
<screen>{0,0,0,1,1,1}</screen>
				<para>This example checks the knots of a curve using the default knot vector.</para>
<programlisting>SELECT ST_Knots('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry);</programlisting>
<screen>null</screen>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_MakeNurbsCurve"/>, <xref linkend="ST_Degree"/>, <xref linkend="ST_NumControlPoints"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_NumControlPoints">
		<refnamediv>
			<refname>ST_NumControlPoints</refname>
			<refpurpose>Returns the number of control points in a NURBS curve.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>integer <function>ST_NumControlPoints</function></funcdef>
					<paramdef><type>geometry</type> <parameter>nurbscurve</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>Returns the number of control points in a NURBS curve. The number of control points must be at least (degree + 1) for a valid NURBS curve.</para>

			<para>Raises an error if the input is not a NURBS curve. Returns NULL if the input is NULL.</para>

			<para role="availability" conformance="3.7.0">Availability: 3.7.0</para>
		</refsection>

		<refsection>
				<title>Examples</title>
				<para>This example returns the number of control points.</para>
				<programlisting>SELECT ST_NumControlPoints('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry);</programlisting>
<screen>3</screen>
				<para>This example verifies that a curve has enough control points for its degree.</para>
<programlisting>SELECT ST_NumControlPoints(curve) >= ST_Degree(curve) + 1 AS valid
FROM (SELECT 'NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry AS curve) AS t;</programlisting>
<screen>t</screen>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_MakeNurbsCurve"/>, <xref linkend="ST_ControlPoints"/>, <xref linkend="ST_Degree"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_NurbsCurveIsRational">
		<refnamediv>
			<refname>ST_NurbsCurveIsRational</refname>
			<refpurpose>Checks if a NURBS curve is rational (has weights).</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>boolean <function>ST_NurbsCurveIsRational</function></funcdef>
					<paramdef><type>geometry</type> <parameter>nurbscurve</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>Returns TRUE if the NURBS curve has weights assigned to its control points (rational NURBS), FALSE if it uses uniform weights (non-rational B-spline).</para>

			<para>Rational NURBS curves provide more flexibility in curve shape control through variable weights. Non-rational B-splines use uniform weights and are a special case of NURBS curves.</para>

			<para>Raises an error if the input is not a NURBS curve. Returns NULL if the input is NULL.</para>

			<para role="availability" conformance="3.7.0">Availability: 3.7.0</para>
		</refsection>

		<refsection>
				<title>Examples</title>
				<para>This example checks whether a curve is rational.</para>
				<programlisting>
SELECT ST_NurbsCurveIsRational(ST_MakeNurbsCurve(
        2,
        'LINESTRING(0 0,5 10,10 0)'::geometry,
        ARRAY[1.0, 2.0, 1.0]));</programlisting>
<screen>t</screen>
				<para>This example checks a non-rational curve.</para>
<programlisting>SELECT ST_NurbsCurveIsRational('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry);</programlisting>
<screen>f</screen>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_MakeNurbsCurve"/>, <xref linkend="ST_Weights"/>, <xref linkend="ST_IsNurbsCurve"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_IsNurbsCurve">
		<refnamediv>
			<refname>ST_IsNurbsCurve</refname>
			<refpurpose>Checks if a geometry is a NURBS curve.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>boolean <function>ST_IsNurbsCurve</function></funcdef>
					<paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>Returns TRUE if the geometry is a NURBS curve, FALSE otherwise. This function can be used to test geometry types before applying NURBS-specific functions.</para>

			<para>Returns NULL if the input is NULL.</para>

			<para role="availability" conformance="3.7.0">Availability: 3.7.0</para>
		</refsection>

		<refsection>
				<title>Examples</title>
				<para>This example checks whether a geometry is a NURBS curve.</para>
				<programlisting>SELECT ST_IsNurbsCurve('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry);</programlisting>
<screen>t</screen>
				<para>This example tests a regular LineString.</para>
<programlisting>SELECT ST_IsNurbsCurve('LINESTRING(0 0,10 10)'::geometry);</programlisting>
<screen>f</screen>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_MakeNurbsCurve"/>, <xref linkend="ST_GeometryType"/>, <xref linkend="ST_NurbsCurveIsRational"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_Evaluate">
		<refnamediv>
			<refname>ST_Evaluate</refname>
			<refpurpose>Evaluates a NURBS curve at a specific parameter value and returns the resulting point.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>geometry <function>ST_Evaluate</function></funcdef>
					<paramdef><type>geometry</type> <parameter>nurbscurve</parameter></paramdef>
					<paramdef><type>float8</type> <parameter>parameter</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>Evaluates a NURBS curve at the specified parameter value and returns a POINT geometry representing the position on the curve. The parameter typically ranges from 0.0 (start of curve) to 1.0 (end of curve), though the actual range depends on the knot vector.</para>

			<para>Raises an error if the input is not a NURBS curve or if evaluation fails. Returns NULL if either input is NULL.</para>

			<para role="availability" conformance="3.7.0">Availability: 3.7.0</para>
		</refsection>

		<refsection>
				<title>Examples</title>
				<para>This example returns the midpoint of a NURBS curve.</para>
				<programlisting>SELECT ST_Evaluate('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry, 0.5);</programlisting>
				<para>This example samples multiple points along a curve.</para>
<programlisting>SELECT t, ST_Evaluate(curve, t) AS point
FROM (SELECT 'NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry AS curve) AS c,
         generate_series(0, 1, 0.25) AS t;</programlisting>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_MakeNurbsCurve"/>, <xref linkend="ST_NurbsToLineString"/></para>
		</refsection>
	</refentry>

	<refentry xml:id="ST_NurbsToLineString">
		<refnamediv>
			<refname>ST_NurbsToLineString</refname>
			<refpurpose>Converts a NURBS curve to a LINESTRING by uniform sampling.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
				<funcprototype>
					<funcdef>geometry <function>ST_NurbsToLineString</function></funcdef>
					<paramdef><type>geometry</type> <parameter>nurbscurve</parameter></paramdef>
					<paramdef choice="opt"><type>integer</type> <parameter>num_segments=32</parameter></paramdef>
				</funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>
			<para>Converts a NURBS curve to a LINESTRING geometry by creating a piecewise linear approximation. The curve is sampled at uniformly distributed parameter values and the resulting points are connected with straight line segments.</para>

			<para>The optional <varname>num_segments</varname> parameter specifies the number of line segments in the output (default: 32, range: 2-10000). Higher values produce smoother approximations but increase geometry complexity.</para>

			<para>Raises an error if the input is not a NURBS curve. Returns NULL if the input is NULL.</para>

			<para role="availability" conformance="3.7.0">Availability: 3.7.0</para>
		</refsection>

		<refsection>
				<title>Examples</title>
				<para>This example converts a NURBS curve to a LineString using the default quality.</para>
				<programlisting language="sql">SELECT ST_NurbsToLineString('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry);</programlisting>
<screen role="visual-primary text-primary docbook-qa-ignore-wide-lines">LINESTRING(0 0,0.3125 0.60546875,0.625 1.171875,0.9375 1.69921875,1.25 2.1875,1.5625 2.63671875,1.875 3.046875,2.1875 3.41796875,2.5 3.75,2.8125 4.04296875,3.125 4.296875,3.4375 4.51171875,3.75 4.6875,4.0625 4.82421875,4.375 4.921875,4.6875 4.98046875,5 5,5.3125 4.98046875,5.625 4.921875,5.9375 4.82421875,6.25 4.6875,6.5625 4.51171875,6.875 4.296875,7.1875 4.04296875,7.5 3.75,7.8125 3.41796875,8.125 3.046875,8.4375 2.63671875,8.75 2.1875,9.0625 1.69921875,9.375 1.171875,9.6875 0.60546875,10 0)</screen>
				<para>This example creates a high-quality approximation with 64 segments.</para>
<programlisting language="sql">SELECT ST_NurbsToLineString('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry, 64);</programlisting>
<screen role="visual-primary docbook-qa-ignore-wide-lines">LINESTRING(0 0,0.15625 0.3076171875,0.3125 0.60546875,0.46875 0.8935546875,0.625 1.171875,0.78125 1.4404296875,0.9375 1.69921875,1.09375 1.9482421875,1.25 2.1875,1.40625 2.4169921875,1.5625 2.63671875,1.71875 2.8466796875,1.875 3.046875,2.03125 3.2373046875,2.1875 3.41796875,2.34375 3.5888671875,2.5 3.75,2.65625 3.9013671875,2.8125 4.04296875,2.96875 4.1748046875,3.125 4.296875,3.28125 4.4091796875,3.4375 4.51171875,3.59375 4.6044921875,3.75 4.6875,3.90625 4.7607421875,4.0625 4.82421875,4.21875 4.8779296875,4.375 4.921875,4.53125 4.9560546875,4.6875 4.98046875,4.84375 4.9951171875,5 5,5.15625 4.9951171875,5.3125 4.98046875,5.46875 4.9560546875,5.625 4.921875,5.78125 4.8779296875,5.9375 4.82421875,6.09375 4.7607421875,6.25 4.6875,6.40625 4.6044921875,6.5625 4.51171875,6.71875 4.4091796875,6.875 4.296875,7.03125 4.1748046875,7.1875 4.04296875,7.34375 3.9013671875,7.5 3.75,7.65625 3.5888671875,7.8125 3.41796875,7.96875 3.2373046875,8.125 3.046875,8.28125 2.8466796875,8.4375 2.63671875,8.59375 2.4169921875,8.75 2.1875,8.90625 1.9482421875,9.0625 1.69921875,9.21875 1.4404296875,9.375 1.171875,9.53125 0.8935546875,9.6875 0.60546875,9.84375 0.3076171875,10 0)</screen>
				<para>This example creates a lower-quality, faster approximation with 16 segments.</para>
<programlisting language="sql">SELECT ST_NurbsToLineString('NURBSCURVE(2, (0 0, 5 10, 10 0))'::geometry, 16);</programlisting>
<screen role="visual-primary text-primary docbook-qa-ignore-wide-lines">LINESTRING(0 0,0.625 1.171875,1.25 2.1875,1.875 3.046875,2.5 3.75,3.125 4.296875,3.75 4.6875,4.375 4.921875,5 5,5.625 4.921875,6.25 4.6875,6.875 4.296875,7.5 3.75,8.125 3.046875,8.75 2.1875,9.375 1.171875,10 0)</screen>
		</refsection>

		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_MakeNurbsCurve"/>, <xref linkend="ST_Evaluate"/>, <xref linkend="ST_Segmentize"/></para>
		</refsection>
	</refentry>

  </section>
