<?xml version="1.0" encoding="UTF-8"?>
  <sect1 id="PostGIS_Types">
    <sect1info>
    <abstract>
    <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>

    <para><emphasis>At least as of PostgreSQL 8.3</emphasis> - Everything can be CAST to text (presumably because of the magical unknown type), so no defined CASTS for that need to be present for you to CAST an object to text.</para>
    </abstract>
    </sect1info>
    <title>PostgreSQL PostGIS Geometry/Geography/Box Types</title>

	<refentry id="box2d_type">
      <refnamediv>
        <refname>box2d</refname>
        <refpurpose>A box composed of x min, ymin,  xmax, ymax.  Often used to return the 2d enclosing box of a geometry. </refpurpose>
      </refnamediv>

      <refsection>
        <title>Description</title>
        <para>box2d is a spatial data type used to represent the enclosing box of a geometry or set of geometries. ST_Extent in earlier versions prior to PostGIS 1.4 would return a box2d.</para>
      </refsection>
    </refentry>
	<refentry id="box3d_type">
      <refnamediv>
        <refname>box3d</refname>
        <refpurpose>A box composed of x min, ymin, zmin, xmax, ymax, zmax.  Often used to return the 3d extent of a geometry or collection of geometries. </refpurpose>
      </refnamediv>

      <refsection>
        <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_3DExtent returns a box3d object.</para>
      </refsection>

      <refsection>
		<title>Casting Behavior</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="geometry">
		<refnamediv>
			<refname>geometry</refname>
			<refpurpose>Planar spatial data type.</refpurpose>
		</refnamediv>

		<refsection>
			<title>Description</title>
			<para>geometry is a fundamental postgis spatial data type used to represent a feature in the Euclidean coordinate system.</para>
		</refsection>

		<refsection>
		<title>Casting Behavior</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>
	</refentry>

	<refentry id="geometry_dump">
		<refnamediv>
			<refname>geometry_dump</refname>
			<refpurpose>A spatial datatype with two fields - geom (holding a geometry object)
				and path[] (a 1-d array holding the position of the geometry within the dumped object.)</refpurpose>
		</refnamediv>

		<refsection>
		<title>Description</title>
		<para>geometry_dump is a compound data type consisting of a geometry object referenced by the .geom field
			and path[] a 1-dimensional integer array (starting at 1 e.g. path[1] to get first element) array that defines the navigation path within the dumped geometry to find this element.
			It is used by the ST_Dump* family of functions as an output type to explode a more complex geometry into its
				constituent parts and location of parts.</para>
		</refsection>
		<refsection>
			<title>See Also</title>
			<para><xref linkend="PostGIS_Geometry_DumpFunctions" /> </para>
		</refsection>
	</refentry>

	<refentry id="geography">
		<refnamediv>
			<refname>geography</refname>
			<refpurpose>Ellipsoidal spatial data type.</refpurpose>
		</refnamediv>

		<refsection>
		<title>Description</title>
		<para>geography is a spatial data type used to represent a feature in the round-earth coordinate system.</para>
		</refsection>

		<refsection>
		<title>Casting Behavior</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>
			<title>See Also</title>
			<para><xref linkend="PostGIS_GeographyFunctions" />, <xref linkend="PostGIS_Geography" /></para>
		</refsection>
	</refentry>
  </sect1>
