<?xml version="1.0" encoding="UTF-8"?>
<sect1 id="PostGIS_Types">
<title>PostgreSQL PostGIS Types</title>
-
+ <para>This section lists the PostgreSQL data types installed by PostGIS. Note we describe the casting behavior of these which is very
+ important especially when designing your own functions.
+ </para>
+ <para>A Cast is when one type is coerced into another type. PostgreSQL
+ is unique from most databases in that it allows you to define casting behavior for custom types and the functions used for casting.
+ A cast can be specified as automatic in which case, you do not have to do a CAST(myfoo As otherfootype) or myfoo::otherfootype
+ if you are feeding it to a function that only works with otherfootype and there is an automatic cast in place for it.
+ </para>
+ <para>The danger of relying on automatic cast behavior is when you have an overloaded function say one that takes a box2d and one that takes a box3d
+ but no geometry. What happens is that both functions are equally good to use with geometry since geometry has an autocast for both
+ -- so you end up with an ambiguous function error. To force PostgreSQL to choose, you do a CAST(mygeom As box3d) or mygeom::box3d.</para>
+
<refentry id="box2d">
<refnamediv>
<refname>box2d</refname>
<title>Description</title>
<para>box3d is a postgis spatial data type used to represent the enclosing box of a geometry or set of geometries. ST_Extent3D returns a box3d object.</para>
</refsection>
+
+ <refsection>
+ <title>Casting Behavor</title>
+ <para>This section lists the automatic as well as explicit casts allowed for this data type</para>
+ <informaltable rowsep="1" frame="all">
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>Cast To</entry>
+ <entry>Behavior</entry>
+ </row>
+ <row>
+ <entry>box</entry>
+ <entry>automatic</entry>
+ </row>
+ <row>
+ <entry>box2d</entry>
+ <entry>automatic</entry>
+ </row>
+ <row>
+ <entry>geometry</entry>
+ <entry>automatic</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsection>
</refentry>
<refentry id="box3d_extent">
<title>Description</title>
<para>box3d_extent is a data type returned by ST_Extent. In versions prior to PostGIS 1.4, ST_Extent would return a box2d.</para>
</refsection>
+
<refsection>
- <title>Casting Behavor</title>
+ <title>Casting Behavor</title>
<para>This section lists the automatic as well as explicit casts allowed for this data type</para>
<informaltable rowsep="1" frame="all">
- <tgroup cols="2">
- <tbody>
- <row>
- <entry>Cast To</entry>
- <entry>Behavior</entry>
- </row>
- <row>
- <entry>box2d</entry>
- <entry>automatic</entry>
- </row>
- <row>
- <entry>box3d</entry>
- <entry>automatic</entry>
- </row>
- <row>
- <entry>geometry</entry>
- <entry>automatic</entry>
- </row>
- </tbody>
- </tgroup>
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>Cast To</entry>
+ <entry>Behavior</entry>
+ </row>
+ <row>
+ <entry>box2d</entry>
+ <entry>automatic</entry>
+ </row>
+ <row>
+ <entry>box3d</entry>
+ <entry>automatic</entry>
+ </row>
+ <row>
+ <entry>geometry</entry>
+ <entry>automatic</entry>
+ </row>
+ </tbody>
+ </tgroup>
</informaltable>
- </refsection>
+ </refsection>
+
+ <refsection>
+ <title>See Also</title>
+ <para><xref linkend="PostGIS_BoxFunctions" /> </para>
+ </refsection>
</refentry>
<refentry id="geometry">
<para>geometry is a fundamental postgis spatial data type used to represent a feature in the Euclidean coordinate system.</para>
</refsection>
+ <refsection>
+ <title>Casting Behavor</title>
+ <para>This section lists the automatic as well as explicit casts allowed for this data type</para>
+ <informaltable rowsep="1" frame="all">
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>Cast To</entry>
+ <entry>Behavior</entry>
+ </row>
+ <row>
+ <entry>box</entry>
+ <entry>automatic</entry>
+ </row>
+ <row>
+ <entry>box2d</entry>
+ <entry>automatic</entry>
+ </row>
+ <row>
+ <entry>box3d</entry>
+ <entry>automatic</entry>
+ </row>
+ <row>
+ <entry>bytea</entry>
+ <entry>automatic</entry>
+ </row>
+ <row>
+ <entry>geography</entry>
+ <entry>automatic</entry>
+ </row>
+ <row>
+ <entry>text</entry>
+ <entry>automatic</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </refsection>
+
<refsection>
<title>See Also</title>
<para><xref linkend="RefObject" /></para>
<refsection>
<title>Description</title>
- <para>GEOGRAPHY is a spatial data type used to represent a feature in the round-earth coordinate system.</para>
+ <para>geography is a spatial data type used to represent a feature in the round-earth coordinate system.</para>
+ </refsection>
+
+ <refsection>
+ <title>Casting Behavor</title>
+ <para>This section lists the automatic as well as explicit casts allowed for this data type</para>
+ <informaltable rowsep="1" frame="all">
+ <tgroup cols="2">
+ <tbody>
+ <row>
+ <entry>Cast To</entry>
+ <entry>Behavior</entry>
+ </row>
+ <row>
+ <entry>geometry</entry>
+ <entry>explicit</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
</refsection>
<refsection>
</xsl:for-each>\r
</itemizedlist>\r
</sect1>\r
+ \r
+ <sect1 id="PostGIS_BoxFunctions">\r
+ <title>PostGIS Box Functions</title>\r
+ <para>The functions given below are PostGIS functions that take as input or return as output the box* family of PostGIS spatial types.\r
+ The box family of types consists of <link linkend="box2d">box2d</link>, <link linkend="box3d">box3d</link>, <link linkend="box3d_extent">box3d_extent</link> </para>\r
+ <itemizedlist>\r
+ <!-- Pull out the purpose section for each ref entry and strip whitespace and put in a variable to be tagged unto each function comment -->\r
+ <xsl:for-each select='sect1/refentry'>\r
+ <xsl:sort select="@id"/>\r
+ <xsl:variable name='comment'>\r
+ <xsl:value-of select="normalize-space(translate(translate(refnamediv/refpurpose,'
', ' '), '	', ' '))"/>\r
+ </xsl:variable>\r
+ <xsl:variable name="refid">\r
+ <xsl:value-of select="@id" />\r
+ </xsl:variable>\r
+ <xsl:variable name="refname">\r
+ <xsl:value-of select="refnamediv/refname" />\r
+ </xsl:variable>\r
+\r
+ <!-- If at least one proto function accepts or returns a geography -->\r
+ <xsl:choose>\r
+ <xsl:when test="contains(refsynopsisdiv/funcsynopsis,'box') or contains(refsynopsisdiv/funcsynopsis/funcprototype/funcdef,'box')">\r
+ <listitem><link linkend="{$refid}"><xsl:value-of select="$refname" /></link> - <xsl:value-of select="$comment" /></listitem>\r
+ </xsl:when>\r
+ </xsl:choose>\r
+ </xsl:for-each>\r
+ </itemizedlist>\r
+ </sect1>\r
\r
<sect1 id="PostGIS_3D_Functions">\r
<title>PostGIS Functions that support 3D</title>\r