[DebianGIS-dev] r563 - in packages/postgis/trunk: . doc doc/html extras/WFS_locks extras/ogc_test_suite extras/wkb_reader loader lwgeom regress regress/loader topology topology/ER topology/test utils

Fabio Tranchitella kobold at costa.debian.org
Fri Oct 6 08:50:15 UTC 2006


Author: kobold
Date: 2006-10-06 08:50:14 +0000 (Fri, 06 Oct 2006)
New Revision: 563

Added:
   packages/postgis/trunk/doc/html/postgis.html
   packages/postgis/trunk/java/
   packages/postgis/trunk/regress/ctors.sql
   packages/postgis/trunk/regress/ctors_expected
Removed:
   packages/postgis/trunk/.cvsignore
   packages/postgis/trunk/HOWTO_RELEASE
   packages/postgis/trunk/autom4te.cache/
   packages/postgis/trunk/doc/.cvsignore
   packages/postgis/trunk/doc/html/.cvsignore
   packages/postgis/trunk/doc/html/apa.html
   packages/postgis/trunk/doc/html/ch01.html
   packages/postgis/trunk/doc/html/ch02.html
   packages/postgis/trunk/doc/html/ch03.html
   packages/postgis/trunk/doc/html/ch04.html
   packages/postgis/trunk/doc/html/ch05.html
   packages/postgis/trunk/doc/html/ch06.html
   packages/postgis/trunk/doc/html/ch07.html
   packages/postgis/trunk/doc/html/index.html
   packages/postgis/trunk/extras/ogc_test_suite/.cvsignore
   packages/postgis/trunk/extras/wkb_reader/.cvsignore
   packages/postgis/trunk/jdbc2/
   packages/postgis/trunk/loader/.cvsignore
   packages/postgis/trunk/lwgeom/.cvsignore
   packages/postgis/trunk/make_dist.sh
   packages/postgis/trunk/topology/.cvsignore
   packages/postgis/trunk/topology/ER/.cvsignore
   packages/postgis/trunk/topology/test/.cvsignore
Modified:
   packages/postgis/trunk/CHANGES
   packages/postgis/trunk/Version.config
   packages/postgis/trunk/doc/postgis.xml
   packages/postgis/trunk/extras/WFS_locks/WFS_locks.sql.in
   packages/postgis/trunk/extras/ogc_test_suite/1_schema.sql
   packages/postgis/trunk/extras/ogc_test_suite/2_queries.sql
   packages/postgis/trunk/loader/dbfopen.c
   packages/postgis/trunk/loader/pgsql2shp.c
   packages/postgis/trunk/loader/shapefil.h
   packages/postgis/trunk/loader/shp2pgsql.c
   packages/postgis/trunk/loader/shpopen.c
   packages/postgis/trunk/lwgeom/lex.yy.c
   packages/postgis/trunk/lwgeom/long_xact.sql
   packages/postgis/trunk/lwgeom/lwcollection.c
   packages/postgis/trunk/lwgeom/lwgeom.c
   packages/postgis/trunk/lwgeom/lwgeom_box2dfloat4.c
   packages/postgis/trunk/lwgeom/lwgeom_box3d.c
   packages/postgis/trunk/lwgeom/lwgeom_btree.c
   packages/postgis/trunk/lwgeom/lwgeom_chip.c
   packages/postgis/trunk/lwgeom/lwgeom_dump.c
   packages/postgis/trunk/lwgeom/lwgeom_estimate.c
   packages/postgis/trunk/lwgeom/lwgeom_functions_analytic.c
   packages/postgis/trunk/lwgeom/lwgeom_functions_basic.c
   packages/postgis/trunk/lwgeom/lwgeom_functions_lrs.c
   packages/postgis/trunk/lwgeom/lwgeom_gist.c
   packages/postgis/trunk/lwgeom/lwgeom_gml.c
   packages/postgis/trunk/lwgeom/lwgeom_ogc.c
   packages/postgis/trunk/lwgeom/lwgeom_spheroid.c
   packages/postgis/trunk/lwgeom/lwgeom_svg.c
   packages/postgis/trunk/lwgeom/lwgeom_transform.c
   packages/postgis/trunk/lwgeom/lwline.c
   packages/postgis/trunk/lwgeom/lwmline.c
   packages/postgis/trunk/lwgeom/lwmpoint.c
   packages/postgis/trunk/lwgeom/lwmpoly.c
   packages/postgis/trunk/lwgeom/lwpoint.c
   packages/postgis/trunk/lwgeom/lwpoly.c
   packages/postgis/trunk/lwgeom/lwpostgis.sql.in
   packages/postgis/trunk/lwgeom/measures.c
   packages/postgis/trunk/lwgeom/ptarray.c
   packages/postgis/trunk/lwgeom/stringBuffer.h
   packages/postgis/trunk/lwgeom/wktparse.h
   packages/postgis/trunk/lwgeom/wktunparse.c
   packages/postgis/trunk/regress/Makefile
   packages/postgis/trunk/regress/loader/Arc.dbf
   packages/postgis/trunk/regress/loader/ArcM.dbf
   packages/postgis/trunk/regress/loader/MultiPoint.dbf
   packages/postgis/trunk/regress/loader/MultiPointM.dbf
   packages/postgis/trunk/regress/loader/MultiPointZ.dbf
   packages/postgis/trunk/regress/loader/Point.dbf
   packages/postgis/trunk/regress/loader/PointM.dbf
   packages/postgis/trunk/regress/loader/PointZ.dbf
   packages/postgis/trunk/regress/loader/Polygon.dbf
   packages/postgis/trunk/regress/loader/PolygonM.dbf
   packages/postgis/trunk/regress/loader/PolygonZ.dbf
   packages/postgis/trunk/regress/regress_index.sql
   packages/postgis/trunk/regress/regress_ogc.sql
   packages/postgis/trunk/regress/regress_ogc_expected
   packages/postgis/trunk/topology/topology.sql.in
   packages/postgis/trunk/utils/profile_intersects.pl
   packages/postgis/trunk/utils/test_estimation.pl
   packages/postgis/trunk/utils/test_joinestimation.pl
Log:
Merged trunk with upstream (postgis-1.1.4).


Deleted: packages/postgis/trunk/.cvsignore
===================================================================
--- packages/postgis/trunk/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,15 +0,0 @@
-Makefile.config
-libpostgis.so.0.8
-postgis.sql
-postgis_undef.sql
-postgis_old.sql
-lwpostgis.sql
-lwpostgis_upgrade.sql
-.classpath
-.project
-config.log
-config.status
-configure
-autom4te.cache
-config.h
-eclipsebin

Modified: packages/postgis/trunk/CHANGES
===================================================================
--- packages/postgis/trunk/CHANGES	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/CHANGES	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,3 +1,21 @@
+PostGIS 1.1.4
+
+	- Fixed support for PostgreSQL 8.2
+	- Fixed bug in collect() function discarding SRID of
+	  input
+	- Added SRID match check in MakeBox2d and MakeBox3d
+	- Fixed regress tests to pass with GEOS-3.0.0
+	- Improved pgsql2shp run concurrency.
+	- Java:
+		- reworked JTS support to reflect new upstream
+		  JTS developers' attitude to SRID handling.
+		  Simplifies code and drops build depend on GNU trove.
+		- Added EJB2 support generously donated by the
+		  "Geodetix s.r.l. Company" http://www.geodetix.it/
+		- Added EJB3 tutorial / examples donated by
+		  Norman Barker <nbarker at ittvis.com>
+		- Reorganized java directory layout a little.
+
 PostGIS 1.1.3
 2006/06/30
 

Deleted: packages/postgis/trunk/HOWTO_RELEASE
===================================================================
--- packages/postgis/trunk/HOWTO_RELEASE	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/HOWTO_RELEASE	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,31 +0,0 @@
-How to release
-~~~~~~~~~~~~~~
-  Date: 2005-12-15
-
-Versioning Scheme
------------------
-
-Release version is composed by REL_MAJOR_VERSION, REL_MINOR_VERSION
-and REL_MICRO_VERSION components.
-
-By default only [REL_MICRO_VERSION] increments between releases.
-
-[REL_MINOR_VERSION] is incremented (and MICRO set to 0) when minor
-additions have been introduced (one or two functions can be considered
-*micro* additions)
-
-[REL_MAJOR_VERSION] is incremented (and MICRO and MINOR set to 0) when
-a dump/reload of existing spatial databases is *REQUIRED* for things
-to work or rather *HIGHLY RECOMMENDED* to get new functionalities.
-
-Release procedure
------------------
-
-1) Update Version.config as specified in Versioning Scheme above.
-2) Edit CHANGES: set release date and check all notable changes are
-   been reported.
-3) Add release notes in doc/postgis.xml
-4) Tag pgis_MAJ_MIN_MIC
-5) Run: sh make_dist.sh MAJ.MIN.MIC
-6) Publish
-7) Announce 

Modified: packages/postgis/trunk/Version.config
===================================================================
--- packages/postgis/trunk/Version.config	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/Version.config	2006-10-06 08:50:14 UTC (rev 563)
@@ -4,7 +4,7 @@
 # shared library / release version
 SO_MAJOR_VERSION=1
 SO_MINOR_VERSION=1
-SO_MICRO_VERSION=3
+SO_MICRO_VERSION=4
 
 # JDBC code version
 JDBC_MAJOR_VERSION=1

Deleted: packages/postgis/trunk/doc/.cvsignore
===================================================================
--- packages/postgis/trunk/doc/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,3 +0,0 @@
-postgis-out.xml
-postgis.fo
-postgis.pdf

Deleted: packages/postgis/trunk/doc/html/.cvsignore
===================================================================
--- packages/postgis/trunk/doc/html/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1 +0,0 @@
-*.html

Deleted: packages/postgis/trunk/doc/html/apa.html
===================================================================
--- packages/postgis/trunk/doc/html/apa.html	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/apa.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,239 +0,0 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Appendix A. Appendix</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PostGIS Manual"><link rel="up" href="index.html" title="PostGIS Manual"><link rel="previous" href="ch07.html" title="Chapter 7. Reporting Bugs"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Appendix A. Appendix</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch07.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> </td></tr></table><hr></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="release_notes"></a>Appendix A. Appendix</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="apa.html#id2530726">A.1. Release Notes</a></span></dt><dd><dl><dt><span class="sect2"><a href="apa.html#id2530732">A.1.1. Release 1.1.3</a></span></dt><dt><span class="sect2"><a href="apa.html#id2530900">A.1.2. Release 1.1.2</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531032">A.1.3. Release 1.1.1</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531325">A.1.4. Release 1.1.0</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531650">A.1.5. Release 1.0.6</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531758">A.1.6. Release 1.0.5</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531890">A.1.7. Release 1.0.4</a></span></dt><dt><span class="sect2"><a href="apa.html#rel_1.0.3_upgrading">A.1.8. Release 1.0.3</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532137">A.1.9. Release 1.0.2</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532216">A.1.10. Release 1.0.1</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532315">A.1.11. Release 1.0.0</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532414">A.1.12. Release 1.0.0RC6</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532488">A.1.13. Release 1.0.0RC5</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532560">A.1.14. Release 1.0.0RC4</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532685">A.1.15. Release 1.0.0RC3</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532857">A.1.16. Release 1.0.0RC2</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532955">A.1.17. Release 1.0.0RC1</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2530726"></a>A.1. Release Notes</h2></div></div><div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2530732"></a>A.1.1. Release 1.1.3</h3></div></div><div></div></div><p>Release date: 2006/06/30</p><p>
-This is an bugfix release including also some new functionalities (most notably long transaction support) and portability enhancements.
-Upgrade is <span class="emphasis"><em>encouraged</em></span>.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2530751"></a>A.1.1.1. Upgrading</h4></div></div><div></div></div><p>
-If you are upgrading from release 1.0.3 or later follow the
-<a href="ch02.html#soft_upgrade" title="2.2.1.1. Soft upgrade">soft upgrade</a> procedure.
-				</p><p>
-If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6 and
-1.0.2</em></span> (inclusive) and really want a live upgrade read the
-<a href="apa.html#rel_1.0.3_upgrading" title="A.1.8. Release 1.0.3">upgrade section</a> of the 1.0.3
-release notes chapter.
-				</p><p>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<a href="ch02.html#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2530800"></a>A.1.1.2. Bug fixes / correctness</h4></div></div><div></div></div><p> BUGFIX in distance(poly,poly) giving wrong results. </p><p> BUGFIX in pgsql2shp successful return code. </p><p> BUGFIX in shp2pgsql handling of MultiLine WKT. </p><p> BUGFIX in affine() failing to update bounding box. </p><p> WKT parser: forbidden construction of multigeometries with 
-	  EMPTY elements (still supported for GEOMETRYCOLLECTION). </p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2530829"></a>A.1.1.3. New functionalities</h4></div></div><div></div></div><p> NEW Long Transactions support. </p><p> NEW DumpRings() function. </p><p> NEW AsHEXEWKB(geom, XDR|NDR) function. </p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2530847"></a>A.1.1.4. JDBC changes</h4></div></div><div></div></div><p> Improved regression tests: MultiPoint and scientific ordinates </p><p> Fixed some minor bugs in jdbc code </p><p>
-Added proper accessor functions for all fields in preparation of 
-making those fields private later
-</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2530868"></a>A.1.1.5. Other changes</h4></div></div><div></div></div><p> NEW regress test support for loader/dumper. </p><p> Added --with-proj-libdir and --with-geos-libdir configure switches. </p><p> Support for build Tru64 build. </p><p> Use Jade for generating documentation. </p><p> Don't link pgsql2shp to more libs then required. </p><p> Initial support for PostgreSQL 8.2. </p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2530900"></a>A.1.2. Release 1.1.2</h3></div></div><div></div></div><p>Release date: 2006/03/30</p><p>
-This is an bugfix release including some new functions and portability enhancements.
-Upgrade is <span class="emphasis"><em>encouraged</em></span>.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2530918"></a>A.1.2.1. Upgrading</h4></div></div><div></div></div><p>
-If you are upgrading from release 1.0.3 or later follow the
-<a href="ch02.html#soft_upgrade" title="2.2.1.1. Soft upgrade">soft upgrade</a> procedure.
-				</p><p>
-If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6 and
-1.0.2</em></span> (inclusive) and really want a live upgrade read the
-<a href="apa.html#rel_1.0.3_upgrading" title="A.1.8. Release 1.0.3">upgrade section</a> of the 1.0.3
-release notes chapter.
-				</p><p>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<a href="ch02.html#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2530965"></a>A.1.2.2. Bug fixes</h4></div></div><div></div></div><p>BUGFIX in SnapToGrid() computation of output bounding box</p><p>BUGFIX in EnforceRHR() </p><p>jdbc2 SRID handling fixes in JTS code</p><p>Fixed support for 64bit archs</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2530988"></a>A.1.2.3. New functionalities</h4></div></div><div></div></div><p>Regress tests can now be run *before* postgis intallation</p><p>New affine() matrix transformation functions</p><p>New rotate{,X,Y,Z}() function </p><p>Old translating and scaling functions now use affine() internally</p><p>Embedded access control in estimated_extent() for builds against pgsql &gt;= 8.0.0</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531016"></a>A.1.2.4. Other changes</h4></div></div><div></div></div><p>More portable ./configure script</p><p>Changed ./run_test script to have more sane default behaviour</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2531032"></a>A.1.3. Release 1.1.1</h3></div></div><div></div></div><p>Release date: 2006/01/23</p><p>
-This is an important Bugfix release, upgrade is <span class="emphasis"><em>highly
-recommended</em></span>.
-Previous version contained a bug in postgis_restore.pl preventing
-<a href="ch02.html#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a> procedure to complete
-and a bug in GEOS-2.2+ connector preventing GeometryCollection objects
-to be used in topological operations.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531060"></a>A.1.3.1. Upgrading</h4></div></div><div></div></div><p>
-If you are upgrading from release 1.0.3 or later follow the
-<a href="ch02.html#soft_upgrade" title="2.2.1.1. Soft upgrade">soft upgrade</a> procedure.
-				</p><p>
-If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6 and
-1.0.2</em></span> (inclusive) and really want a live upgrade read the
-<a href="apa.html#rel_1.0.3_upgrading" title="A.1.8. Release 1.0.3">upgrade section</a> of the 1.0.3
-release notes chapter.
-				</p><p>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<a href="ch02.html#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531269"></a>A.1.3.2. Bug fixes</h4></div></div><div></div></div><p>Fixed a premature exit in postgis_restore.pl </p><p>BUGFIX in geometrycollection handling of GEOS-CAPI connector</p><p>Solaris 2.7 and MingW support improvements</p><p>BUGFIX in line_locate_point()</p><p>Fixed handling of postgresql paths</p><p>BUGFIX in line_substring()</p><p>Added support for localized cluster in regress tester</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531304"></a>A.1.3.3. New functionalities</h4></div></div><div></div></div><p>New Z and M interpolation in line_substring()</p><p>New Z and M interpolation in line_interpolate_point()</p><p>added NumInteriorRing() alias due to OpenGIS ambiguity</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2531325"></a>A.1.4. Release 1.1.0</h3></div></div><div></div></div><p>Release date: 2005/12/21</p><p>
-This is a Minor release, containing many improvements and new things.
-Most notably: build procedure greatly simplified; transform() performance
-drastically improved; more stable GEOS connectivity (CAPI support);
-lots of new functions; draft topology support.
-			</p><p>
-It is <span class="emphasis"><em>highly recommended</em></span> that you upgrade to GEOS-2.2.x
-before installing PostGIS, this will ensure future GEOS upgrades won't
-require a rebuild of the PostGIS library.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531352"></a>A.1.4.1. Credits</h4></div></div><div></div></div><p>
-This release includes code from Mark Cave Ayland for caching of proj4
-objects. Markus Schaber added many improvements in his JDBC2 code.
-Alex Bodnaru helped with PostgreSQL source dependency relief and
-provided Debian specfiles.  Michael Fuhr tested new things on Solaris arch.
-David Techer and Gerald Fenoy helped testing GEOS C-API connector.
-Hartmut Tschauner provided code for the azimuth() function. 
-Devrim GUNDUZ provided RPM specfiles. Carl Anderson helped with
-the new area building functions.
-See the <a href="ch01.html#credits" title="1.1. Credits">credits</a> section for more names.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531378"></a>A.1.4.2. Upgrading</h4></div></div><div></div></div><p>
-If you are upgrading from release 1.0.3 or later you <span class="emphasis"><em>DO
-NOT</em></span> need a dump/reload.
-Simply sourcing the new lwpostgis_upgrade.sql script in all your
-existing databases will work.
-See the <a href="ch02.html#soft_upgrade" title="2.2.1.1. Soft upgrade">soft upgrade</a> chapter
-for more informations.
-				</p><p>
-If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6 and
-1.0.2</em></span> (inclusive) and really want a live upgrade read the
-<a href="apa.html#rel_1.0.3_upgrading" title="A.1.8. Release 1.0.3">upgrade section</a> of the 1.0.3
-release notes chapter.
-				</p><p>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<a href="ch02.html#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531431"></a>A.1.4.3. New functions</h4></div></div><div></div></div><p>scale() and transscale() companion methods to translate()</p><p>line_substring() </p><p>line_locate_point()</p><p>M(point) </p><p>LineMerge(geometry) </p><p>shift_longitude(geometry) </p><p>azimuth(geometry) </p><p>locate_along_measure(geometry, float8) </p><p>locate_between_measures(geometry, float8, float8) </p><p>SnapToGrid by point offset (up to 4d support)</p><p>BuildArea(any_geometry) </p><p>OGC BdPolyFromText(linestring_wkt, srid) </p><p>OGC BdMPolyFromText(linestring_wkt, srid)</p><p>RemovePoint(linestring, offset)</p><p>ReplacePoint(linestring, offset, point)</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531496"></a>A.1.4.4. Bug fixes</h4></div></div><div></div></div><p>Fixed memory leak in polygonize()</p><p>Fixed bug in lwgeom_as_anytype cast funcions</p><p>
-Fixed USE_GEOS, USE_PROJ and USE_STATS elements of postgis_version()
-output to always reflect library state.
-</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531516"></a>A.1.4.5. Function semantic changes</h4></div></div><div></div></div><p>SnapToGrid doesn't discard higher dimensions</p><p>Changed Z() function to return NULL if requested dimension is not available</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531531"></a>A.1.4.6. Performance improvements</h4></div></div><div></div></div><p>
-Much faster transform() function, caching proj4 objects
-</p><p>
-Removed automatic call to fix_geometry_columns() in
-AddGeometryColumns() and update_geometry_stats()
-</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531548"></a>A.1.4.7. JDBC2 works</h4></div></div><div></div></div><p>Makefile improvements</p><p>JTS support improvements</p><p>Improved regression test system</p><p>Basic consistency check method for geometry collections</p><p>Support for (Hex)(E)wkb</p><p>Autoprobing DriverWrapper for HexWKB / EWKT switching</p><p>fix compile problems in ValueSetter for ancient jdk releases.</p><p>fix EWKT constructors to accept SRID=4711; representation</p><p>added preliminary read-only support for java2d geometries</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531591"></a>A.1.4.8. Other new things</h4></div></div><div></div></div><p>
-Full autoconf-based configuration, with PostgreSQL source dependency relief
-</p><p>GEOS C-API support (2.2.0 and higher)</p><p>Initial support for topology modelling</p><p>Debian and RPM specfiles</p><p>New lwpostgis_upgrade.sql script</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531618"></a>A.1.4.9. Other changes</h4></div></div><div></div></div><p>JTS support improvements</p><p>Stricter mapping between DBF and SQL integer and string attributes</p><p>Wider and cleaner regression test suite</p><p>old jdbc code removed from release</p><p>obsoleted direct use of postgis_proc_upgrade.pl</p><p>scripts version unified with release version</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2531650"></a>A.1.5. Release 1.0.6</h3></div></div><div></div></div><p>Release date: 2005/12/06</p><p>
-Contains a few bug fixes and improvements.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531664"></a>A.1.5.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
-				release 1.0.3 or later you <span class="emphasis"><em>DO
-				NOT</em></span> need a dump/reload.
-				</p><p>If you are upgrading from
-				a release <span class="emphasis"><em>between 1.0.0RC6 and
-				1.0.2</em></span> (inclusive) and really want
-				a live upgrade read the <a href="apa.html#rel_1.0.3_upgrading" title="A.1.8. Release 1.0.3">upgrade
-				section</a> of the 1.0.3 release notes
-				chapter.
-				</p><p>
-				Upgrade from any release prior to 1.0.0RC6
-				requires an <a href="ch02.html#hard_upgrade" title="2.2.1.2. Hard upgrade">hard
-				upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531707"></a>A.1.5.2. Bug fixes</h4></div></div><div></div></div><p>Fixed palloc(0) call in collection deserializer (only gives problem with --enable-cassert)</p><p>Fixed bbox cache handling bugs</p><p>Fixed geom_accum(NULL, NULL) segfault</p><p>Fixed segfault in addPoint()</p><p>Fixed short-allocation in lwcollection_clone()</p><p>Fixed bug in segmentize()</p><p>Fixed bbox computation of SnapToGrid output</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531742"></a>A.1.5.3. Improvements</h4></div></div><div></div></div><p>Initial support for postgresql 8.2</p><p>Added missing SRID mismatch checks in GEOS ops</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2531758"></a>A.1.6. Release 1.0.5</h3></div></div><div></div></div><p>Release date: 2005/11/25</p><p>
-Contains memory-alignment fixes in the library, a segfault fix in loader's
-handling of UTF8 attributes and a few improvements and cleanups.
-			</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-Return code of shp2pgsl changed from previous releases to conform to unix
-standards (return 0 on success).
-			</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531780"></a>A.1.6.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
-				release 1.0.3 or later you <span class="emphasis"><em>DO
-				NOT</em></span> need a dump/reload.
-				</p><p>If you are upgrading from
-				a release <span class="emphasis"><em>between 1.0.0RC6 and
-				1.0.2</em></span> (inclusive) and really want
-				a live upgrade read the <a href="apa.html#rel_1.0.3_upgrading" title="A.1.8. Release 1.0.3">upgrade
-				section</a> of the 1.0.3 release notes
-				chapter.
-				</p><p>
-				Upgrade from any release prior to 1.0.0RC6
-				requires an <a href="ch02.html#hard_upgrade" title="2.2.1.2. Hard upgrade">hard
-				upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531823"></a>A.1.6.2. Library changes</h4></div></div><div></div></div><p>Fixed memory alignment problems</p><p>Fixed computation of null values fraction in analyzer</p><p>Fixed a small bug in the getPoint4d_p() low-level function</p><p>Speedup of serializer functions</p><p>Fixed a bug in force_3dm(), force_3dz() and force_4d()</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531850"></a>A.1.6.3. Loader changes</h4></div></div><div></div></div><p>Fixed return code of shp2pgsql</p><p>Fixed back-compatibility issue in loader (load of null shapefiles)</p><p>Fixed handling of trailing dots in dbf numerical attributes</p><p>Segfault fix in shp2pgsql (utf8 encoding)</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531874"></a>A.1.6.4. Other changes</h4></div></div><div></div></div><p>Schema aware postgis_proc_upgrade.pl, support for pgsql 7.2+</p><p>New "Reporting Bugs" chapter in manual</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2531890"></a>A.1.7. Release 1.0.4</h3></div></div><div></div></div><p>Release date: 2005/09/09</p><p>
-Contains important bug fixes and a few improvements. In particular, it
-fixes a memory leak preventing successful build of GiST indexes
-for large spatial tables.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531906"></a>A.1.7.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
-				release 1.0.3 you <span class="emphasis"><em>DO
-				NOT</em></span> need a dump/reload.
-				</p><p>If you are upgrading from
-				a release <span class="emphasis"><em>between 1.0.0RC6 and
-				1.0.2</em></span> (inclusive) and really want
-				a live upgrade read the <a href="apa.html#rel_1.0.3_upgrading" title="A.1.8. Release 1.0.3">upgrade
-				section</a> of the 1.0.3 release notes
-				chapter.
-				</p><p>
-				Upgrade from any release prior to 1.0.0RC6
-				requires an <a href="ch02.html#hard_upgrade" title="2.2.1.2. Hard upgrade">hard
-				upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531949"></a>A.1.7.2. Bug fixes</h4></div></div><div></div></div><p>Memory leak plugged in GiST indexing</p><p>Segfault fix in transform() handling of proj4 errors</p><p>Fixed some proj4 texts in spatial_ref_sys (missing +proj)</p><p>Loader: fixed string functions usage, reworked NULL objects check, fixed segfault on MULTILINESTRING input.</p><p>Fixed bug in MakeLine dimension handling</p><p>Fixed bug in translate() corrupting output bounding box</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2531982"></a>A.1.7.3. Improvements</h4></div></div><div></div></div><p>Documentation improvements</p><p>More robust selectivity estimator </p><p>Minor speedup in distance()</p><p>Minor cleanups </p><p>GiST indexing cleanup</p><p>Looser syntax acceptance in box3d parser</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="rel_1.0.3_upgrading"></a>A.1.8. Release 1.0.3</h3></div></div><div></div></div><p>Release date: 2005/08/08</p><p>
-Contains some bug fixes - <span class="emphasis"><em>including a severe one affecting
-correctness of stored geometries</em></span> - and a few improvements.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532034"></a>A.1.8.1. Upgrading</h4></div></div><div></div></div><p>
-Due to a bug in a bounding box computation routine, the upgrade procedure
-requires special attention, as bounding boxes cached in the database could
-be incorrect.
-				</p><p>
-An <a href="ch02.html#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a> procedure (dump/reload)
-will force recomputation of all bounding boxes (not included in dumps).
-This is <span class="emphasis"><em>required</em></span> if upgrading from releases prior
-to 1.0.0RC6.
-				</p><p>
-If you are upgrading from versions 1.0.0RC6 or up, this release includes a
-perl script (utils/rebuild_bbox_caches.pl) to force recomputation of
-geometries' bounding boxes and invoke all operations required to propagate
-eventual changes in them (geometry statistics update, reindexing).
-Invoke the script after a make install (run with no args for syntax help).
-Optionally run utils/postgis_proc_upgrade.pl to refresh postgis procedures
-and functions signatures (see <a href="ch02.html#soft_upgrade" title="2.2.1.1. Soft upgrade">Soft upgrade</a>).
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532082"></a>A.1.8.2. Bug fixes</h4></div></div><div></div></div><p>Severe bugfix in lwgeom's 2d bounding box computation</p><p>Bugfix in WKT (-w) POINT handling in loader</p><p>Bugfix in dumper on 64bit machines</p><p>Bugfix in dumper handling of user-defined queries </p><p>Bugfix in create_undef.pl script</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532109"></a>A.1.8.3. Improvements</h4></div></div><div></div></div><p>Small performance improvement in canonical input function</p><p>Minor cleanups in loader</p><p>Support for multibyte field names in loader</p><p>Improvement in the postgis_restore.pl script</p><p>New rebuild_bbox_caches.pl util script</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2532137"></a>A.1.9. Release 1.0.2</h3></div></div><div></div></div><p>Release date: 2005/07/04</p><p>
-			Contains a few bug fixes and improvements.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532151"></a>A.1.9.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
-				release 1.0.0RC6 or up you <span class="emphasis"><em>DO
-				NOT</em></span> need a dump/reload.</p><p>Upgrading from older releases
-				requires a dump/reload. 
-				See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532177"></a>A.1.9.2. Bug fixes</h4></div></div><div></div></div><p>Fault tolerant btree ops</p><p>Memory leak plugged in pg_error</p><p>Rtree index fix</p><p>Cleaner build scripts (avoided mix of CFLAGS and CXXFLAGS)</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532200"></a>A.1.9.3. Improvements</h4></div></div><div></div></div><p>New index creation capabilities in loader (-I switch)</p><p>Initial support for postgresql 8.1dev</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2532216"></a>A.1.10. Release 1.0.1</h3></div></div><div></div></div><p>Release date: 2005/05/24</p><p>
-			Contains a few bug fixes and some improvements.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532229"></a>A.1.10.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
-				release 1.0.0RC6 or up you <span class="emphasis"><em>DO
-				NOT</em></span> need a dump/reload.</p><p>Upgrading from older releases
-				requires a dump/reload. 
-				See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532256"></a>A.1.10.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in 3d computation of lenght_spheroid()</p><p>BUGFIX in join selectivity estimator</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532271"></a>A.1.10.3. Other changes/additions</h4></div></div><div></div></div><p>BUGFIX in shp2pgql escape functions</p><p>better support for concurrent postgis in multiple schemas</p><p>documentation fixes</p><p>jdbc2: compile with "-target 1.2 -source 1.2" by default</p><p>NEW -k switch for pgsql2shp</p><p>NEW support for custom createdb options in postgis_restore.pl</p><p>BUGFIX in pgsql2shp attribute names unicity enforcement</p><p>BUGFIX in Paris projections definitions</p><p>postgis_restore.pl cleanups</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2532315"></a>A.1.11. Release 1.0.0</h3></div></div><div></div></div><p>Release date: 2005/04/19</p><p>Final 1.0.0 release.
-			Contains a few bug fixes, some improvements
-			in the loader (most notably support for older
-			postgis versions), and more docs.
-			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532331"></a>A.1.11.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
-				release 1.0.0RC6 you <span class="emphasis"><em>DO
-				NOT</em></span> need a dump/reload.</p><p>Upgrading from any other precedent
-				release requires a dump/reload. 
-				See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532358"></a>A.1.11.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in transform() releasing random memory address</p><p>BUGFIX in force_3dm() allocating less memory then required</p><p>BUGFIX in join selectivity estimator (defaults, leaks, tuplecount, sd)</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532378"></a>A.1.11.3. Other changes/additions</h4></div></div><div></div></div><p>BUGFIX in shp2pgsql escape of values starting with tab or single-quote</p><p>NEW manual pages for loader/dumper</p><p>NEW shp2pgsql support for old (HWGEOM) postgis versions</p><p>NEW -p (prepare) flag for shp2pgsql</p><p>NEW manual chapter about OGC compliancy enforcement</p><p>NEW autoconf support for JTS lib</p><p>BUGFIX in estimator testers (support for LWGEOM and schema parsing)</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2532414"></a>A.1.12. Release 1.0.0RC6</h3></div></div><div></div></div><p>Release date: 2005/03/30</p><p>Sixth release candidate for 1.0.0.
-			Contains a few bug fixes and cleanups.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532429"></a>A.1.12.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
-				from precedent releases. See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532447"></a>A.1.12.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in multi()</p><p>early return [when noop] from multi()</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532462"></a>A.1.12.3. Scripts changes</h4></div></div><div></div></div><p>dropped {x,y}{min,max}(box2d) functions</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532472"></a>A.1.12.4. Other changes</h4></div></div><div></div></div><p>BUGFIX in postgis_restore.pl scrip</p><p>BUGFIX in dumper's 64bit support</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2532488"></a>A.1.13. Release 1.0.0RC5</h3></div></div><div></div></div><p>Release date: 2005/03/25</p><p>Fifth release candidate for 1.0.0.
-			Contains a few bug fixes and a improvements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532502"></a>A.1.13.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
-				release 1.0.0RC4 you <span class="emphasis"><em>DO
-				NOT</em></span> need a dump/reload.</p><p>Upgrading from any other precedent
-				release requires a dump/reload. 
-				See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532529"></a>A.1.13.2. Library changes</h4></div></div><div></div></div><p>BUGFIX (segfaulting) in box3d computation (yes, another!).</p><p>BUGFIX (segfaulting) in estimated_extent().</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532544"></a>A.1.13.3. Other changes</h4></div></div><div></div></div><p>Small build scripts and utilities refinements.</p><p>Additional performance tips documented.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2532560"></a>A.1.14. Release 1.0.0RC4</h3></div></div><div></div></div><p>Release date: 2005/03/18</p><p>Fourth release candidate for 1.0.0.
-			Contains bug fixes and a few improvements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532574"></a>A.1.14.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
-				from precedent releases. See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532593"></a>A.1.14.2. Library changes</h4></div></div><div></div></div><p>BUGFIX (segfaulting) in geom_accum().</p><p>BUGFIX in 64bit architectures support.</p><p>BUGFIX in box3d computation function with collections.</p><p>NEW subselects support in selectivity estimator.</p><p>Early return from force_collection.</p><p>Consistency check fix in SnapToGrid().</p><p>Box2d output changed back to 15 significant digits.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532628"></a>A.1.14.3. Scripts changes</h4></div></div><div></div></div><p>NEW distance_sphere() function.</p><p>Changed get_proj4_from_srid implementation to use PL/PGSQL instead of SQL.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532643"></a>A.1.14.4. Other changes</h4></div></div><div></div></div><p>BUGFIX in loader and dumper handling of MultiLine shapes</p><p>BUGFIX in loader, skipping all but first hole of polygons.</p><p>jdbc2: code cleanups, Makefile improvements</p><p>FLEX and YACC variables set *after* pgsql Makefile.global is included and only if the pgsql *stripped* version evaulates to the empty string</p><p>Added already generated parser in release</p><p>Build scripts refinements</p><p>improved version handling, central Version.config</p><p>improvements in postgis_restore.pl</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2532685"></a>A.1.15. Release 1.0.0RC3</h3></div></div><div></div></div><p>Release date: 2005/02/24</p><p>Third release candidate for 1.0.0.
-			Contains many bug fixes and improvements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532699"></a>A.1.15.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
-				from precedent releases. See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532718"></a>A.1.15.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in transform(): missing SRID, better error handling.</p><p>BUGFIX in memory alignment handling</p><p>BUGFIX in force_collection() causing mapserver connector failures on simple (single) geometry types.</p><p>BUGFIX in GeometryFromText() missing to add a bbox cache.</p><p>reduced precision of box2d output.</p><p>prefixed DEBUG macros with PGIS_ to avoid clash with pgsql one</p><p>plugged a leak in GEOS2POSTGIS converter</p><p>Reduced memory usage by early releasing query-context palloced one.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532759"></a>A.1.15.3. Scripts changes</h4></div></div><div></div></div><p>BUGFIX in 72 index bindings.</p><p>BUGFIX in probe_geometry_columns() to work with PG72 and support multiple geometry columns in a single table</p><p>NEW bool::text cast</p><p>Some functions made IMMUTABLE from STABLE, for performance
-	improvement.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532783"></a>A.1.15.4. JDBC changes</h4></div></div><div></div></div><p>jdbc2: small patches, box2d/3d tests, revised docs and license.</p><p>jdbc2: bug fix and testcase in for pgjdbc 8.0 type autoregistration</p><p>jdbc2: Removed use of jdk1.4 only features to enable build with older jdk releases.</p><p>jdbc2: Added support for building against pg72jdbc2.jar</p><p>jdbc2: updated and cleaned makefile</p><p>jdbc2: added BETA support for jts geometry classes</p><p>jdbc2: Skip known-to-fail tests against older PostGIS servers.</p><p>jdbc2: Fixed handling of measured geometries in EWKT.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532824"></a>A.1.15.5. Other changes</h4></div></div><div></div></div><p>new performance tips chapter in manual</p><p>documentation updates: pgsql72 requirement, lwpostgis.sql</p><p>few changes in autoconf </p><p>BUILDDATE extraction made more portable</p><p>fixed spatial_ref_sys.sql to avoid vacuuming the whole
-	database.</p><p>spatial_ref_sys: changed Paris entries to match the ones
-	distributed with 0.x.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2532857"></a>A.1.16. Release 1.0.0RC2</h3></div></div><div></div></div><p>Release date: 2005/01/26</p><p>Second release candidate for 1.0.0
-			containing bug fixes and a few improvements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532871"></a>A.1.16.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
-				from precedent releases. See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532889"></a>A.1.16.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in pointarray box3d computation</p><p>BUGFIX in distance_spheroid definition</p><p>BUGFIX in transform() missing to update bbox cache</p><p>NEW jdbc driver (jdbc2)</p><p>GEOMETRYCOLLECTION(EMPTY) syntax support for backward compatibility</p><p>Faster binary outputs</p><p>Stricter OGC WKB/WKT constructors</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532924"></a>A.1.16.3. Scripts changes</h4></div></div><div></div></div><p>More correct STABLE, IMMUTABLE, STRICT uses in lwpostgis.sql</p><p>stricter OGC WKB/WKT constructors</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532939"></a>A.1.16.4. Other changes</h4></div></div><div></div></div><p>Faster and more robust loader (both i18n and not)</p><p>Initial autoconf script</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2532955"></a>A.1.17. Release 1.0.0RC1</h3></div></div><div></div></div><p>Release date: 2005/01/13</p><p>This is the first candidate of a
-			major postgis release, with internal
-			storage of postgis types redesigned to be smaller
-			and faster on indexed queries.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532970"></a>A.1.17.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
-				from precedent releases. See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2532989"></a>A.1.17.2. Changes</h4></div></div><div></div></div><p>
-				Faster canonical input parsing.
-				</p><p>
-				Lossless canonical output.
-				</p><p>
-				EWKB Canonical binary IO with PG&gt;73.
-				</p><p>
-				Support for up to 4d coordinates, providing
-				lossless shapefile-&gt;postgis-&gt;shapefile
-				conversion.
-				</p><p>
-				New function: UpdateGeometrySRID(), AsGML(),
-				SnapToGrid(), ForceRHR(), estimated_extent(),
-				accum().
-				</p><p>
-				Vertical positioning indexed operators.
-				</p><p>
-				JOIN selectivity function.
-				</p><p>
-				More geometry constructors / editors.
-				</p><p>
-				Postgis extension API.
-				</p><p>
-				UTF8 support in loader.
-				</p></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch07.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top">Chapter 7. Reporting Bugs </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>

Deleted: packages/postgis/trunk/doc/html/ch01.html
===================================================================
--- packages/postgis/trunk/doc/html/ch01.html	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/ch01.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,37 +0,0 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 1. Introduction</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PostGIS Manual"><link rel="up" href="index.html" title="PostGIS Manual"><link rel="previous" href="index.html" title="PostGIS Manual"><link rel="next" href="ch02.html" title="Chapter 2. Installation"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 1. Introduction</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="index.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch02.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2454821"></a>Chapter 1. Introduction</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch01.html#credits">1.1. Credits</a></span></dt><dt><span class="sect1"><a href="ch01.html#id2454630">1.2. More Information</a></span></dt></dl></div><p>PostGIS is developed by Refractions Research Inc, as a spatial
-    database technology research project. Refractions is a GIS and database
-    consulting company in Victoria, British Columbia, Canada, specializing in
-    data integration and custom software development. We plan on supporting
-    and developing PostGIS to support a range of important GIS functionality,
-    including full OpenGIS support, advanced topological constructs
-    (coverages, surfaces, networks), desktop user interface tools for viewing
-    and editing GIS data, and web-based access tools.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="credits"></a>1.1. Credits</h2></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">Sandro Santilli &lt;strk at refractions.net&gt;</span></dt><dd><p>Coordinates all bug fixing and maintainance effort,
-            integration of new GEOS functionality, and new function
-            enhancements.</p></dd><dt><span class="term">Chris Hodgson &lt;chodgson at refractions.net&gt;</span></dt><dd><p>Maintains new functions and the 7.2 index bindings.</p></dd><dt><span class="term">Paul Ramsey &lt;pramsey at refractions.net&gt;</span></dt><dd><p>Keeps track of the
-            documentation and packaging.</p></dd><dt><span class="term">Jeff Lounsbury &lt;jeffloun at refractions.net&gt;</span></dt><dd><p>Original development of the Shape file loader/dumper.</p></dd><dt><span class="term">Dave Blasby &lt;dblasby at gmail.com&gt;</span></dt><dd><p>The original developer of PostGIS. Dave wrote the server
-            side objects, index bindings, and many of the server side
-            analytical functions.</p></dd><dt><span class="term">Other contributors</span></dt><dd><p>
-		In alphabetical order: 
-		Alex Bodnaru, Alex Mayrhofer, Bruce Rindahl,
-		Bernhard Reiter, 
-		Bruno Wolff III, Carl Anderson, Charlie Savage,
-		David Skea, David Techer, 
-		IIDA Tetsushi, Geographic Data BC, Gerald Fenoy,
-		Gino Lucrezi, Klaus Foerster, Kris Jurka, Mark Cave-Ayland,
-		Mark Sondheim, Markus Schaber, Michael Fuhr, Nikita Shulga,
-		Norman Vine, Olivier Courtin, Ralph Mason, Steffen Macke.
-            </p></dd><dt><span class="term">Important Support Libraries</span></dt><dd><p>The <a href="http://geos.refractions.net" target="_top">GEOS</a>
-            geometry operations library, and the algorithmic work of 
-            Martin Davis &lt;mbdavis at vividsolutions.com&gt; of Vivid Solutions
-            in making it all work.</p><p>The <a href="http://proj4.maptools.org" target="_top">Proj4</a>
-            cartographic projection library, and the work of Gerald Evenden
-            and Frank Warmerdam in creating and maintaining it.</p></dd></dl></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2454630"></a>1.2. More Information</h2></div></div><div></div></div><div class="itemizedlist"><ul type="disc"><li><p>The latest software, documentation and news items are
-          available at the PostGIS web site, <a href="http://postgis.refractions.net" target="_top">http://postgis.refractions.net</a>.</p></li><li><p>More information about the GEOS geometry operations library is
-          available at<a href="http://geos.refractions.net" target="_top">
-          http://geos.refractions.net</a>.</p></li><li><p>More information about the Proj4 reprojection library is
-          available at <a href="http://www.remotesensing.org/proj" target="_top">http://www.remotesensing.org/proj</a>.</p></li><li><p>More information about the PostgreSQL database server is
-          available at the PostgreSQL main site <a href="http://www.postgresql.org" target="_top">http://www.postgresql.org</a>.</p></li><li><p>More information about GiST indexing is available at the
-          PostgreSQL GiST development site, <a href="http://www.sai.msu.su/~megera/postgres/gist" target="_top">http://www.sai.msu.su/~megera/postgres/gist</a>.</p></li><li><p>More information about Mapserver internet map server is
-          available at <a href="http://mapserver.gis.umn.edu/" target="_top">http://mapserver.gis.umn.edu</a>.</p></li><li><p>The "<a href="http://www.opengis.org/docs/99-049.pdf" target="_top">Simple Features
-          for Specification for SQL</a>" is available at the OpenGIS
-          Consortium web site: <a href="http://www.opengis.org" target="_top">http://www.opengis.org</a>.</p></li></ul></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="index.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">PostGIS Manual </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 2. Installation</td></tr></table></div></body></html>

Deleted: packages/postgis/trunk/doc/html/ch02.html
===================================================================
--- packages/postgis/trunk/doc/html/ch02.html	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/ch02.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,171 +0,0 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 2. Installation</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PostGIS Manual"><link rel="up" href="index.html" title="PostGIS Manual"><link rel="previous" href="ch01.html" title="Chapter 1. Introduction"><link rel="next" href="ch03.html" title="Chapter 3. Frequently Asked Questions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 2. Installation</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch01.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch03.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2481874"></a>Chapter 2. Installation</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch02.html#id2481880">2.1. Requirements</a></span></dt><dt><span class="sect1"><a href="ch02.html#PGInstall">2.2. PostGIS</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch02.html#upgrading">2.2.1. Upgrading</a></span></dt><dt><span class="sect2"><a href="ch02.html#id2453863">2.2.2. Common Problems</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch02.html#id2522143">2.3. JDBC</a></span></dt><dt><span class="sect1"><a href="ch02.html#id2522219">2.4. Loader/Dumper</a></span></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2481880"></a>2.1. Requirements</h2></div></div><div></div></div><p>PostGIS has the following requirements for building and
-      usage:</p><div class="itemizedlist"><ul type="disc"><li><p>
-	  A complete installation of PostgreSQL (including server headers).
-          PostgreSQL is available from <a href="http://www.postgresql.org" target="_top">http://www.postgresql.org</a>.
-	  Version 7.2 or higher is required.
-	  </p></li><li><p>GNU C compiler (<tt class="filename">gcc</tt>). Some other ANSI C
-          compilers can be used to compile PostGIS, but we find far fewer
-          problems when compiling with <tt class="filename">gcc</tt>.</p></li><li><p>GNU Make (<tt class="filename">gmake</tt> or
-          <tt class="filename">make</tt>). For many systems, GNU
-          <tt class="filename">make</tt> is the default version of make. Check the
-          version by invoking <tt class="filename">make -v</tt>. Other versions of
-          <tt class="filename">make</tt> may not process the PostGIS
-          <tt class="filename">Makefile</tt> properly.</p></li><li><p>(Recommended) Proj4 reprojection library. The Proj4 library is
-          used to provide coordinate reprojection support within PostGIS.
-          Proj4 is available for download from <a href="http://www.remotesensing.org/proj" target="_top">http://www.remotesensing.org/proj</a>.</p></li><li><p>(Recommended) GEOS geometry library. The GEOS library is used
-          to provide geometry tests (Touches(), Contains(), Intersects()) and
-          operations (Buffer(), GeomUnion(), Difference()) within PostGIS.
-          GEOS is available for download from <a href="http://geos.refractions.net" target="_top">http://geos.refractions.net</a>.</p></li></ul></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PGInstall"></a>2.2. PostGIS</h2></div></div><div></div></div><p>The PostGIS module is a extension to the PostgreSQL backend
-      server. As such, PostGIS 1.1.3
-      <span class="emphasis"><em>requires</em></span> full PostgreSQL server headers access
-      in order to compile. The PostgreSQL source code is available at <a href="http://www.postgresql.org" target="_top">http://www.postgresql.org</a>.</p><p>PostGIS 1.1.3 can be built against PostgreSQL
-      versions 7.2.0 or higher. Earlier versions of PostgreSQL are
-      <span class="emphasis"><em>not</em></span> supported.</p><div class="orderedlist"><ol type="1"><li><p>Before you can compile the PostGIS server modules, you must
-          compile and install the PostgreSQL package.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>If you plan to use GEOS functionality you might need to
-            explicitly link PostgreSQL against the standard C++
-            library:</p><pre class="programlisting">LDFLAGS=-lstdc++ ./configure [YOUR OPTIONS HERE]</pre><p>This is a workaround for bogus C++ exceptions interaction
-            with older development tools. If you experience weird problems
-            (backend unexpectedly closed or similar things) try this trick.
-            This will require recompiling your PostgreSQL from scratch, of
-            course.</p></div></li><li><p>Retrieve the PostGIS source archive from <a href="http://postgis.refractions.net/postgis-1.1.3.tar.gz" target="_top">http://postgis.refractions.net/postgis-1.1.3.tar.gz</a>.
-          Uncompress and untar the archive.
-	  </p><pre class="programlisting"># gzip -d -c postgis-1.1.3.tar.gz | tar xvf -</pre></li><li><p>Enter the postgis-1.1.3 directory, and run:
-</p><pre class="programlisting"># ./configure</pre><p>
-	  </p><div class="itemizedlist"><ul type="disc"><li><p>
-		If you want support for coordinate reprojection, you must have
-		the Proj4 library installed. If ./configure didn't find
-		it, try using <tt class="code">--with-proj=PATH</tt>
-		switch specify a specific Proj4 installation directory.
-		</p></li><li><p>
-		If you want to use GEOS functionality, you must have the GEOS
-		library installed. If ./configure didn't find it, try
-		using <tt class="code">--with-geos=PATH</tt> to specify the full 
-                path to the geos-config program full path.
-		</p></li></ul></div></li><li><p>Run the compile and install commands.</p><pre class="programlisting"># make 
-# make install</pre><p>All files are installed using information provided
-	  by <tt class="filename">pg_config</tt></p><div class="itemizedlist"><ul type="disc"><li><p>Libraries are installed
-              <tt class="filename">[pkglibdir]/lib/contrib</tt>.</p></li><li><p>Important support files such as
-              <tt class="filename">lwpostgis.sql</tt> are installed in
-              <tt class="filename">[prefix]/share/contrib</tt>.</p></li><li><p>Loader and dumper binaries are installed in
-              <tt class="filename">[bindir]/</tt>.</p></li></ul></div></li><li><p>PostGIS requires the PL/pgSQL procedural language extension.
-          Before loading the <tt class="filename">lwpostgis.sql</tt> file, you must
-          first enable PL/pgSQL. You should use the
-          <tt class="filename">createlang</tt> command. The PostgreSQL 
-          Programmer's Guide has the details if you want to this manually for
-          some reason.</p><pre class="programlisting"># createlang plpgsql [yourdatabase]</pre></li><li><p>Now load the PostGIS object and function definitions into your
-          database by loading the <tt class="filename">lwpostgis.sql</tt> definitions
-          file.</p><pre class="programlisting"># psql -d [yourdatabase] -f lwpostgis.sql</pre><p>The PostGIS server extensions are now loaded and ready to
-          use.</p></li><li><p>For a complete set of EPSG coordinate system definition
-          identifiers, you can also load the
-          <tt class="filename">spatial_ref_sys.sql</tt> definitions file and
-          populate the <tt class="varname">SPATIAL_REF_SYS</tt> table.</p><pre class="programlisting"># psql -d [yourdatabase] -f spatial_ref_sys.sql</pre></li></ol></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="upgrading"></a>2.2.1. Upgrading</h3></div></div><div></div></div><p>
-Upgrading existing spatial databases can be tricky as it requires
-replacement or introduction of new PostGIS object definitions.
-</p><p>
-Unfortunately not all definitions can be easily replaced in 
-a live database, so sometimes your best bet is a dump/reload
-process. 
-</p><p>
-PostGIS provides a SOFT UPGRADE procedure for minor or bugfix
-releases, and an HARD UPGRADE procedure for major releases.
-</p><p>
-Before attempting to upgrade postgis, it is always worth to backup
-your data. If you use the -Fc flag to pg_dump you will always be able
-to restore the dump with an HARD UPGRADE.
-	</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="soft_upgrade"></a>2.2.1.1. Soft upgrade</h4></div></div><div></div></div><p>
-Soft upgrade consists of sourcing the lwpostgis_upgrade.sql
-script in your spatial database:
-</p><pre class="programlisting">psql -f lwpostgis_upgrade.sql -d your_spatial_database</pre><p>
-If a soft upgrade is not possible the script will abort and 
-you will be warned about HARD UPGRADE being required,
-so do not hesitate to try a soft upgrade first.
-</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-If you can't find the <tt class="filename">lwpostgis_upgrade.sql</tt> file
-you are probably using a version prior to 1.1 and must generate that
-file by yourself. This is done with the following command:
-</p><pre class="programlisting">utils/postgis_proc_upgrade.pl lwpostgis.sql &gt; lwpostgis_upgrade.sql</pre></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="hard_upgrade"></a>2.2.1.2. Hard upgrade</h4></div></div><div></div></div><p>
-By HARD UPGRADE we intend full dump/reload of postgis-enabled databases.
-You need an HARD UPGRADE when postgis objects' internal storage
-changes or when SOFT UPGRADE is not possible.
-The <a href="apa.html" title="Appendix A. Appendix">Release Notes</a> appendix reports for each version wheter you need a
-dump/reload (HARD UPGRADE) to upgrade.
-	</p><p>
-PostGIS provides an utility script to restore a dump
-produced with the pg_dump -Fc command. It is experimental so redirecting
-its output to a file will help in case of problems. The procedure is
-as follow:
-	</p><pre class="programlisting">
-	# Create a "custom-format" dump of the database you want
-	# to upgrade (let's call it "olddb")
-	$ pg_dump -Fc olddb &gt; olddb.dump
-
-	# Restore the dump contextually upgrading postgis into
-	# a new database. The new database doesn't have to exist.
-	# Let's call it "newdb"
-	$ sh utils/postgis_restore.pl lwpostgis.sql newdb olddb.dump &gt; restore.log
-
-	# Check that all restored dump objects really had to be restored from dump
-	# and do not conflict with the ones defined in lwpostgis.sql
-	$ grep ^KEEPING restore.log | less
-
-	# If upgrading from PostgreSQL &lt; 8.0 to &gt;= 8.0 you might want to 
-	# drop the attrelid, varattnum and stats columns in the geometry_columns
-	# table, which are no-more needed. Keeping them won't hurt.
-	# !!! DROPPING THEM WHEN REALLY NEEDED WILL DO HURT !!!!
-	$ psql newdb -c "ALTER TABLE geometry_columns DROP attrelid"
-	$ psql newdb -c "ALTER TABLE geometry_columns DROP varattnum"
-	$ psql newdb -c "ALTER TABLE geometry_columns DROP stats"
-
-	# spatial_ref_sys table is restore from the dump, to ensure your custom
-	# additions are kept, but the distributed one might contain modification
-	# so you should backup your entries, drop the table and source the new one.
-	# If you did make additions we assume you know how to backup them before
-	# upgrading the table. Replace of it with the new one is done like this:
-	$ psql newdb
-	newdb=&gt; delete from spatial_ref_sys; 
-	DROP
-	newdb=&gt; \i spatial_ref_sys.sql
-	</pre></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2453863"></a>2.2.2. Common Problems</h3></div></div><div></div></div><p>There are several things to check when your installation or
-        upgrade doesn't go as you expected.</p><div class="orderedlist"><ol type="1"><li><p>It is easiest if you untar the PostGIS distribution into the
-            contrib directory under the PostgreSQL source tree. However, if
-            this is not possible for some reason, you can set the
-            <tt class="varname">PGSQL_SRC</tt> environment variable to the path to
-            the PostgreSQL source directory. This will allow you to compile
-            PostGIS, but the <span><b class="command">make install</b></span> may not work, so
-            be prepared to copy the PostGIS library and executable files to
-            the appropriate locations yourself.</p></li><li><p>Check that you you have installed PostgreSQL 7.2 or newer,
-            and that you are compiling against the same version of the
-            PostgreSQL source as the version of PostgreSQL that is running.
-            Mix-ups can occur when your (Linux) distrubution has already
-            installed PostgreSQL, or you have otherwise installed PostgreSQL
-            before and forgotten about it. PostGIS will only work with
-            PostgreSQL 7.2 or newer, and strange, unexpected error messages
-            will result if you use an older version. To check the version of
-            PostgreSQL which is running, connect to the database using psql
-            and run this query:</p><pre class="programlisting">SELECT version();</pre><p>If you are running an RPM based distribution, you can check
-            for the existence of pre-installed packages using the
-            <span><b class="command">rpm</b></span> command as follows: <span><b class="command">rpm -qa | grep
-            postgresql</b></span></p></li></ol></div><p>Also check that you have made any necessary changes to the top
-        of the Makefile.config. This includes:</p><div class="orderedlist"><ol type="1"><li><p>If you want to be able to do coordinate reprojections, you
-            must install the Proj4 library on your system, set the
-            <tt class="varname">USE_PROJ</tt> variable to 1 and the
-            <tt class="varname">PROJ_DIR</tt> to your installation prefix in the
-            Makefile.config.</p></li><li><p>If you want to be able to use GEOS functions you must
-            install the GEOS library on your system, and set the
-            <tt class="varname">USE_GEOS</tt> to 1 and the
-            <tt class="varname">GEOS_DIR</tt> to your installation prefix in the
-            Makefile.config</p></li></ol></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2522143"></a>2.3. JDBC</h2></div></div><div></div></div><p>The JDBC extensions provide Java objects corresponding to the
-      internal PostGIS types. These objects can be used to write Java clients
-      which query the PostGIS database and draw or do calculations on the GIS
-      data in PostGIS.</p><div class="orderedlist"><ol type="1"><li><p>Enter the <tt class="filename">jdbc</tt> sub-directory of the
-          PostGIS distribution.</p></li><li><p>Edit the <tt class="filename">Makefile</tt> to provide the correct
-          paths of your java compiler (<tt class="varname">JAVAC</tt>) and
-          interpreter (<tt class="varname">JAVA</tt>).</p></li><li><p>Run the <tt class="filename">make</tt> command. Copy the
-          <tt class="filename">postgis.jar</tt> file to wherever you keep your java
-          libraries.</p></li></ol></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2522219"></a>2.4. Loader/Dumper</h2></div></div><div></div></div><p>The data loader and dumper are built and installed automatically
-      as part of the PostGIS build. To build and install them manually:</p><pre class="programlisting"># cd postgis-1.1.3/loader 
-# make
-# make install</pre><p>The loader is called <tt class="filename">shp2pgsql</tt> and converts
-      ESRI Shape files into SQL suitable for loading in PostGIS/PostgreSQL.
-      The dumper is called <tt class="filename">pgsql2shp</tt> and converts PostGIS
-      tables (or queries) into ESRI Shape files.</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch01.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 1. Introduction </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 3. Frequently Asked Questions</td></tr></table></div></body></html>

Deleted: packages/postgis/trunk/doc/html/ch03.html
===================================================================
--- packages/postgis/trunk/doc/html/ch03.html	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/ch03.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,92 +0,0 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 3. Frequently Asked Questions</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PostGIS Manual"><link rel="up" href="index.html" title="PostGIS Manual"><link rel="previous" href="ch02.html" title="Chapter 2. Installation"><link rel="next" href="ch04.html" title="Chapter 4. Using PostGIS"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 3. Frequently Asked Questions</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch04.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2522258"></a>Chapter 3. Frequently Asked Questions</h2></div></div><div></div></div><div class="qandaset"><dl><dt>3.1. <a href="ch03.html#id2522266">What kind of geometric objects can I store?</a></dt><dt>3.2. <a href="ch03.html#id2522286">How do I insert a GIS object into the database?</a></dt><dt>3.3. <a href="ch03.html#id2522382">How do I construct a spatial query?</a></dt><dt>3.4. <a href="ch03.html#id2522447">How do I speed up spatial queries on large tables?</a></dt><dt>3.5. <a href="ch03.html#id2522529">Why aren't PostgreSQL R-Tree indexes supported?</a></dt><dt>3.6. <a href="ch03.html#id2522581">Why should I use the AddGeometryColumn()
-          function and all the other OpenGIS stuff?</a></dt><dt>3.7. <a href="ch03.html#id2522629">What is the best way to find all objects within a radius of
-          another object?</a></dt><dt>3.8. <a href="ch03.html#id2522681">How do I perform a coordinate reprojection as part of a
-          query?</a></dt></dl><table border="0" summary="Q and A Set"><col align="left" width="1%"><tbody><tr class="question"><td align="left" valign="top"><a name="id2522266"></a><a name="id2522268"></a><b>3.1.</b></td><td align="left" valign="top"><p>What kind of geometric objects can I store?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>You can store point, line, polygon, multipoint, multiline,
-          multipolygon, and geometrycollections. These are specified in the
-          Open GIS Well Known Text Format (with XYZ,XYM,XYZM extentions).</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2522286"></a><a name="id2522288"></a><b>3.2.</b></td><td align="left" valign="top"><p>How do I insert a GIS object into the database?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>First, you need to create a table with a column of type
-          "geometry" to hold your GIS data. Connect to your database with
-          <tt class="filename">psql</tt> and try the following SQL:</p><pre class="programlisting">CREATE TABLE gtest ( ID int4, NAME varchar(20) );
-SELECT AddGeometryColumn('', 'gtest','geom',-1,'LINESTRING',2);</pre><p>If the geometry column addition fails, you probably have not
-          loaded the PostGIS functions and objects into this database. See the
-          <a href="ch02.html#PGInstall" title="2.2. PostGIS">installation instructions</a>.</p><p>Then, you can insert a geometry into the table using a SQL
-          insert statement. The GIS object itself is formatted using the
-          OpenGIS Consortium "well-known text" format:</p><pre class="programlisting">INSERT INTO gtest (ID, NAME, GEOM) VALUES (1, 'First Geometry', GeomFromText('LINESTRING(2 3,4 5,6 5,7 8)', -1));</pre><p>For more information about other GIS objects, see the <a href="ch04.html#RefObject" title="4.1. GIS Objects">object reference</a>.</p><p>To view your GIS data in the table:</p><pre class="programlisting">SELECT id, name, AsText(geom) AS geom FROM gtest;</pre><p>The return value should look something like this:</p><pre class="programlisting"> id | name           | geom
-----+----------------+-----------------------------
-  1 | First Geometry | LINESTRING(2 3,4 5,6 5,7 8) 
-(1 row)</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2522382"></a><a name="id2522384"></a><b>3.3.</b></td><td align="left" valign="top"><p>How do I construct a spatial query?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>The same way you construct any other database query, as an SQL
-          combination of return values, functions, and boolean tests.</p><p>For spatial queries, there are two issues that are important
-          to keep in mind while constructing your query: is there a spatial
-          index you can make use of; and, are you doing expensive calculations
-          on a large number of geometries.</p><p>In general, you will want to use the "intersects operator"
-          (&amp;&amp;) which tests whether the bounding boxes of features
-          intersect. The reason the &amp;&amp; operator is useful is because
-          if a spatial index is available to speed up the test, the &amp;&amp;
-          operator will make use of this. This can make queries much much
-          faster.</p><p>You will also make use of spatial functions, such as
-          Distance(), Intersects(), Contains() and Within(), among others, to
-          narrow down the results of your search. Most spatial queries include
-          both an indexed test and a spatial function test. The index test
-          serves to limit the number of return tuples to only tuples that
-          <span class="emphasis"><em>might</em></span> meet the condition of interest. The
-          spatial functions are then use to test the condition exactly.</p><pre class="programlisting">SELECT id, the_geom FROM thetable
-WHERE
-  the_geom &amp;&amp; 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'
-AND
-  Contains(the_geom,'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))';</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2522447"></a><a name="id2522449"></a><b>3.4.</b></td><td align="left" valign="top"><p>How do I speed up spatial queries on large tables?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>Fast queries on large tables is the <span class="emphasis"><em>raison
-          d'etre</em></span> of spatial databases (along with transaction
-          support) so having a good index is important.</p><p>To build a spatial index on a table with a
-          <tt class="varname">geometry</tt> column, use the "CREATE INDEX" function
-          as follows:</p><pre class="programlisting">CREATE INDEX [indexname] ON [tablename]  
-  USING GIST ( [geometrycolumn] );</pre><p>The "USING GIST" option tells the server to use a GiST
-          (Generalized Search Tree) index.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-            GiST indexes are assumed to be lossy.
-	    Lossy indexes uses a proxy object (in the spatial case,
-	    a bounding box) for building the index.</p></div><p>You should also ensure that the PostgreSQL query planner has
-          enough information about your index to make rational decisions about
-          when to use it. To do this, you have to "gather statistics" on your
-          geometry tables.</p><p>For PostgreSQL 8.0.x and greater, just run the <span><b class="command">VACUUM
-          ANALYZE</b></span> command.</p><p>For PostgreSQL 7.4.x and below, run the <span><b class="command">SELECT
-          UPDATE_GEOMETRY_STATS()</b></span> command.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2522529"></a><a name="id2522531"></a><b>3.5.</b></td><td align="left" valign="top"><p>Why aren't PostgreSQL R-Tree indexes supported?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>Early versions of PostGIS used the PostgreSQL R-Tree indexes.
-          However, PostgreSQL R-Trees have been completely discarded since
-          version 0.6, and spatial indexing is provided with an
-          R-Tree-over-GiST scheme.</p><p>Our tests have shown search speed for native R-Tree and GiST
-          to be comparable. Native PostgreSQL R-Trees have two limitations
-          which make them undesirable for use with GIS features (note that
-          these limitations are due to the current PostgreSQL native R-Tree
-          implementation, not the R-Tree concept in general):</p><div class="itemizedlist"><ul type="disc"><li><p>R-Tree indexes in PostgreSQL cannot handle features which
-              are larger than 8K in size. GiST indexes can, using the "lossy"
-              trick of substituting the bounding box for the feature
-              itself.</p></li><li><p>R-Tree indexes in PostgreSQL are not "null safe", so
-              building an index on a geometry column which contains null
-              geometries will fail.</p></li></ul></div></td></tr><tr class="question"><td align="left" valign="top"><a name="id2522581"></a><a name="id2522584"></a><b>3.6.</b></td><td align="left" valign="top"><p>Why should I use the <tt class="varname">AddGeometryColumn()</tt>
-          function and all the other OpenGIS stuff?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>If you do not want to use the OpenGIS support functions, you
-          do not have to. Simply create tables as in older versions, defining
-          your geometry columns in the CREATE statement. All your geometries
-          will have SRIDs of -1, and the OpenGIS meta-data tables will
-          <span class="emphasis"><em>not</em></span> be filled in properly. However, this will
-          cause most applications based on PostGIS to fail, and it is
-          generally suggested that you do use
-          <tt class="varname">AddGeometryColumn()</tt> to create geometry
-          tables.</p><p>Mapserver is one application which makes use of the
-          <tt class="varname">geometry_columns</tt> meta-data. Specifically,
-          Mapserver can use the SRID of the geometry column to do on-the-fly
-          reprojection of features into the correct map projection.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2522629"></a><a name="id2522631"></a><b>3.7.</b></td><td align="left" valign="top"><p>What is the best way to find all objects within a radius of
-          another object?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>To use the database most efficiently, it is best to do radius
-          queries which combine the radius test with a bounding box test: the
-          bounding box test uses the spatial index, giving fast access to a
-          subset of data which the radius test is then applied to.</p><p>The <tt class="varname">Expand()</tt> function is a handy way of
-          enlarging a bounding box to allow an index search of a region of
-          interest. The combination of a fast access index clause and a slower
-          accurate distance test provides the best combination of speed and
-          precision for this query.</p><p>For example, to find all objects with 100 meters of POINT(1000
-          1000) the following query would work well:</p><pre class="programlisting">SELECT * 
-FROM GEOTABLE 
-WHERE 
-  GEOCOLUMN &amp;&amp; Expand(GeomFromText('POINT(1000 1000)',-1),100)
-AND
-  Distance(GeomFromText('POINT(1000 1000)',-1),GEOCOLUMN) &lt; 100;</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2522681"></a><a name="id2522683"></a><b>3.8.</b></td><td align="left" valign="top"><p>How do I perform a coordinate reprojection as part of a
-          query?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>To perform a reprojection, both the source and destination
-          coordinate systems must be defined in the SPATIAL_REF_SYS table, and
-          the geometries being reprojected must already have an SRID set on
-          them. Once that is done, a reprojection is as simple as referring to
-          the desired destination SRID.</p><pre class="programlisting">SELECT Transform(GEOM,4269) FROM GEOTABLE;</pre></td></tr></tbody></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch04.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 2. Installation </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 4. Using PostGIS</td></tr></table></div></body></html>

Deleted: packages/postgis/trunk/doc/html/ch04.html
===================================================================
--- packages/postgis/trunk/doc/html/ch04.html	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/ch04.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,782 +0,0 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 4. Using PostGIS</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PostGIS Manual"><link rel="up" href="index.html" title="PostGIS Manual"><link rel="previous" href="ch03.html" title="Chapter 3. Frequently Asked Questions"><link rel="next" href="ch05.html" title="Chapter 5. Performance tips"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 4. Using PostGIS</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch03.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch05.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2522713"></a>Chapter 4. Using PostGIS</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch04.html#RefObject">4.1. GIS Objects</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2522740">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2522847">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2523004">4.2. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2523037">4.2.1. The SPATIAL_REF_SYS Table</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2523246">4.2.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2523380">4.2.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2523486">4.2.4. Ensuring OpenGIS compliancy of geometries</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2523576">4.3. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2523590">4.3.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2523645">4.3.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2523875">4.4. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2523888">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2524054">4.4.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2524232">4.5. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2524285">4.5.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2524354">4.5.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2524472">4.6. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2524491">4.6.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2524587">4.6.2. Examples of Spatial SQL</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2524902">4.7. Using Mapserver</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2524945">4.7.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2525193">4.7.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2525360">4.7.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2453149">4.7.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2453247">4.8. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="ch04.html#id2525835">4.9. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2525844">4.9.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2525854">4.9.2. Binary Cursors</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="RefObject"></a>4.1. GIS Objects</h2></div></div><div></div></div><p>The GIS objects supported by PostGIS are a superset of
-      the "Simple Features" defined by the OpenGIS Consortium (OGC).
-      As of version 0.9, PostGIS supports all the objects and functions
-      specified in the OGC "Simple Features for SQL" specification.</p><p>PostGIS extends the standard with support for 3DZ,3DM and 4D
-      coordinates.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2522740"></a>4.1.1. OpenGIS WKB and WKT</h3></div></div><div></div></div><p>The OpenGIS specification defines two standard ways of
-        expressing spatial objects: the Well-Known Text (WKT) form and
-	the Well-Known Binary (WKB) form. Both WKT and WKB include
-	information about the type of the object and the
-        coordinates which form the object.</p><p>Examples of the text representations (WKT) of the spatial
-      objects of the features are as follows:</p><div class="itemizedlist"><ul type="disc"><li><p>POINT(0 0)</p></li><li><p>LINESTRING(0 0,1 1,1 2)</p></li><li><p>POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))</p></li><li><p>MULTIPOINT(0 0,1 2)</p></li><li><p>MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))</p></li><li><p>MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)),
-	  ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))</p></li><li><p>GEOMETRYCOLLECTION(POINT(2 3),LINESTRING((2 3,3 4)))</p></li></ul></div><p>The OpenGIS specification also requires that the
-        internal storage format of spatial objects include a spatial
-        referencing system identifier (SRID). The SRID is required when
-        creating spatial objects for insertion into the database.</p><p>
-Input/Output of these formats are available using the following
-interfaces:
-</p><pre class="programlisting">
-	bytea WKB = asBinary(geometry);
-	text WKT = asText(geometry);
-	geometry = GeomFromWKB(bytea WKB, SRID); 
-	geometry = GeometryFromText(text WKT, SRID);
-	</pre><p> For example, a valid insert statement to create and insert an OGC spatial object would be:</p><pre class="programlisting">
-	INSERT INTO SPATIALTABLE ( 
-		  THE_GEOM, 
-		  THE_NAME 
-	) 
-	VALUES ( 
-		  GeomFromText('POINT(-126.4 45.32)', 312), 
-		  'A Place' 
-	)</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2522847"></a>4.1.2. PostGIS EWKB, EWKT and Canonical Forms</h3></div></div><div></div></div><p>
-OGC formats only support 2d geometries, and the associated SRID
-is *never* embedded in the input/output representations.
-</p><p>
-Postgis extended formats are currently superset of OGC one (every
-valid WKB/WKT is a valid EWKB/EWKT) but this might vary in the
-future, specifically if OGC comes out with a new format conflicting
-with our extensions. Thus you SHOULD NOT rely on this feature!
-</p><p>
-Postgis EWKB/EWKT add 3dm,3dz,4d coordinates support and embedded
-SRID information.
-</p><p>Examples of the text representations (EWKT) of the
-      extended spatial objects of the features are as follows:</p><div class="itemizedlist"><ul type="disc"><li><p>POINT(0 0 0) -- XYZ</p></li><li><p>SRID=32632;POINT(0 0) -- XY with SRID</p></li><li><p>POINTM(0 0 0) -- XYM</p></li><li><p>POINT(0 0 0 0) -- XYZM</p></li><li><p>SRID=4326;MULTIPOINTM(0 0 0,1 2 1) -- XYM with SRID</p></li><li><p>MULTILINESTRING((0 0 0,1 1 0,1 2 1),(2 3 1,3 2 1,5 4
-          1))</p></li><li><p>POLYGON((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2
-          0,1 1 0))</p></li><li><p>MULTIPOLYGON(((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2
-          0,1 2 0,1 1 0)),((-1 -1 0,-1 -2 0,-2 -2 0,-2 -1 0,-1 -1 0)))</p></li><li><p>GEOMETRYCOLLECTIONM(POINTM(2 3 9),LINESTRINGM((2 3 4,3 4
-          5)))</p></li></ul></div><p>
-Input/Output of these formats are available using the following
-interfaces:
-</p><pre class="programlisting">
-	bytea EWKB = asEWKB(geometry);
-	text EWKT = asEWKT(geometry);
-	geometry = GeomFromEWKB(bytea EWKB);
-	geometry = GeomFromEWKT(text EWKT);
-	</pre><p>
-For example, a valid insert statement to create and insert a PostGIS spatial object would be:
-</p><pre class="programlisting">
-	INSERT INTO SPATIALTABLE ( 
-		  THE_GEOM, 
-		  THE_NAME 
-	) 
-	VALUES ( 
-		  GeomFromEWKT('SRID=312;POINTM(-126.4 45.32 15)'), 
-		  'A Place' 
-	)</pre><p>
-The "canonical forms" of a PostgreSQL type are the representations
-you get with a simple query (without any function call) and the one
-which is guaranteed to be accepted with a simple insert, update or
-copy. For the postgis 'geometry' type these are:
-
-	</p><pre class="programlisting">
-	- Output -
-	binary: EWKB
-	 ascii: HEXEWKB (EWKB in hex form)
-
-	- Input -
-	binary: EWKB
-	 ascii: HEXEWKB|EWKT
-	</pre><p>
-</p><p>
-For example this statement reads EWKT and returns HEXEWKB in the
-process of canonical ascii input/output:
-</p><pre class="programlisting">
-	=# SELECT 'SRID=4;POINT(0 0)'::geometry;
-			      geometry
-	----------------------------------------------------
-	 01010000200400000000000000000000000000000000000000
-	(1 row)
-	</pre></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2523004"></a>4.2. Using OpenGIS Standards</h2></div></div><div></div></div><p>The OpenGIS "Simple Features Specification for SQL" defines
-      standard GIS object types, the functions required to manipulate them,
-      and a set of meta-data tables. In order to ensure that meta-data remain
-      consistent, operations such as creating and removing a spatial column
-      are carried out through special procedures defined by OpenGIS.</p><p>There are two OpenGIS meta-data tables:
-      <tt class="varname">SPATIAL_REF_SYS</tt> and
-      <tt class="varname">GEOMETRY_COLUMNS</tt>. The
-      <tt class="varname">SPATIAL_REF_SYS</tt> table holds the numeric IDs and
-      textual descriptions of coordinate systems used in the spatial
-      database.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2523037"></a>4.2.1. The SPATIAL_REF_SYS Table</h3></div></div><div></div></div><p>The <tt class="varname">SPATIAL_REF_SYS</tt> table definition is as
-        follows:</p><pre class="programlisting">CREATE TABLE SPATIAL_REF_SYS ( 
-  SRID INTEGER NOT NULL PRIMARY KEY, 
-  AUTH_NAME VARCHAR(256), 
-  AUTH_SRID INTEGER, 
-  SRTEXT VARCHAR(2048), 
-  PROJ4TEXT VARCHAR(2048)
-)</pre><p>The <tt class="varname">SPATIAL_REF_SYS</tt> columns are as
-        follows:</p><div class="variablelist"><dl><dt><span class="term">SRID</span></dt><dd><p>An integer value that uniquely identifies the Spatial
-              Referencing System (SRS) within the database.</p></dd><dt><span class="term">AUTH_NAME</span></dt><dd><p>The name of the standard or standards body that is being
-              cited for this reference system. For example, "EPSG" would be a
-              valid <tt class="varname">AUTH_NAME</tt>.</p></dd><dt><span class="term">AUTH_SRID</span></dt><dd><p>The ID of the Spatial Reference System as defined by the
-              Authority cited in the <tt class="varname">AUTH_NAME</tt>. In the case
-              of EPSG, this is where the EPSG projection code would go.</p></dd><dt><span class="term">SRTEXT</span></dt><dd><p>The Well-Known Text representation of the Spatial
-              Reference System. An example of a WKT SRS representation
-              is:</p><pre class="programlisting">PROJCS["NAD83 / UTM Zone 10N", 
-  GEOGCS["NAD83",
-    DATUM["North_American_Datum_1983", 
-      SPHEROID["GRS 1980",6378137,298.257222101]
-    ], 
-    PRIMEM["Greenwich",0], 
-    UNIT["degree",0.0174532925199433] 
-  ],
-  PROJECTION["Transverse_Mercator"], 
-  PARAMETER["latitude_of_origin",0],
-  PARAMETER["central_meridian",-123], 
-  PARAMETER["scale_factor",0.9996],
-  PARAMETER["false_easting",500000], 
-  PARAMETER["false_northing",0],
-  UNIT["metre",1] 
-]</pre><p>For a listing of EPSG projection codes and their
-              corresponding WKT representations, see <a href="http://www.opengis.org/techno/interop/EPSG2WKT.TXT" target="_top">http://www.opengis.org/techno/interop/EPSG2WKT.TXT</a>.
-              For a discussion of WKT in general, see the OpenGIS "Coordinate
-              Transformation Services Implementation Specification" at <a href="http://www.opengis.org/techno/specs.htm" target="_top">http://www.opengis.org/techno/specs.htm</a>.
-              For information on the European Petroleum Survey Group (EPSG)
-              and their database of spatial reference systems, see <a href="http://epsg.org" target="_top">http://epsg.org</a>.</p></dd><dt><span class="term">PROJ4TEXT</span></dt><dd><p>PostGIS uses the Proj4 library to provide coordinate
-              transformation capabilities. The <tt class="varname">PROJ4TEXT</tt>
-              column contains the Proj4 coordinate definition string for a
-              particular SRID. For example:</p><pre class="programlisting">+proj=utm +zone=10 +ellps=clrk66 +datum=NAD27 +units=m</pre><p>For more information about, see the Proj4 web site at
-              <a href="http://www.remotesensing.org/proj" target="_top">http://www.remotesensing.org/proj</a>.
-              The <tt class="filename">spatial_ref_sys.sql</tt> file contains both
-              <tt class="varname">SRTEXT</tt> and <tt class="varname">PROJ4TEXT</tt>
-              definitions for all EPSG projections.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2523246"></a>4.2.2. The GEOMETRY_COLUMNS Table</h3></div></div><div></div></div><p>The <tt class="varname">GEOMETRY_COLUMNS</tt> table definition is as
-        follows:</p><pre class="programlisting">CREATE TABLE GEOMETRY_COLUMNS ( 
-  F_TABLE_CATALOG VARCHAR(256) NOT NULL, 
-  F_TABLE_SCHEMA VARCHAR(256) NOT NULL, 
-  F_TABLE_NAME VARCHAR(256) NOT NULL, 
-  F_GEOMETRY_COLUMN VARCHAR(256) NOT NULL,
-  COORD_DIMENSION INTEGER NOT NULL, 
-  SRID INTEGER NOT NULL, 
-  TYPE VARCHAR(30) NOT NULL 
-)</pre><p>The columns are as follows:</p><div class="variablelist"><dl><dt><span class="term">F_TABLE_CATALOG, F_TABLE_SCHEMA, F_TABLE_NAME</span></dt><dd><p>The fully qualified name of the feature table containing
-              the geometry column. Note that the terms "catalog" and "schema"
-              are Oracle-ish. There is not PostgreSQL analogue of "catalog" so
-              that column is left blank -- for "schema" the PostgreSQL schema
-              name is used (<tt class="varname">public</tt> is the default).</p></dd><dt><span class="term">F_GEOMETRY_COLUMN</span></dt><dd><p>The name of the geometry column in the feature
-              table.</p></dd><dt><span class="term">COORD_DIMENSION</span></dt><dd><p>The spatial dimension (2, 3 or 4 dimensional) of the
-              column.</p></dd><dt><span class="term">SRID</span></dt><dd><p>The ID of the spatial reference system used for the
-              coordinate geometry in this table. It is a foreign key reference
-              to the <tt class="varname">SPATIAL_REF_SYS</tt>.</p></dd><dt><span class="term">TYPE</span></dt><dd><p>The type of the spatial object. To restrict the spatial
-              column to a single type, use one of: POINT, LINESTRING, POLYGON,
-              MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION or
-	      corresponding XYM versions POINTM, LINESTRINGM, POLYGONM,
-	      MULTIPOINTM, MULTILINESTRINGM, MULTIPOLYGONM, GEOMETRYCOLLECTIONM.
-              For heterogeneous (mixed-type) collections, you can use
-              "GEOMETRY" as the type.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This attribute is (probably) not part of the OpenGIS
-                specification, but is required for ensuring type
-                homogeneity.</p></div></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2523380"></a>4.2.3. Creating a Spatial Table</h3></div></div><div></div></div><p>Creating a table with spatial data is done in two stages:</p><div class="itemizedlist"><ul type="disc"><li><p>Create a normal non-spatial table.</p><p>For example: <span><b class="command">CREATE TABLE ROADS_GEOM ( ID int4,
-            NAME varchar(25) )</b></span></p></li><li><p>Add a spatial column to the table using the OpenGIS
-            "AddGeometryColumn" function.</p><p>The syntax is:
-            </p><pre class="programlisting">AddGeometryColumn(&lt;schema_name&gt;, &lt;table_name&gt;,
-            &lt;column_name&gt;, &lt;srid&gt;, &lt;type&gt;,
-            &lt;dimension&gt;)</pre><p>
-
-	    Or, using current schema:
-            </p><pre class="programlisting">AddGeometryColumn(&lt;table_name&gt;,
-            &lt;column_name&gt;, &lt;srid&gt;, &lt;type&gt;,
-            &lt;dimension&gt;)</pre><p>
-	    </p><p>Example1: <span><b class="command">SELECT AddGeometryColumn('public',
-            'roads_geom', 'geom', 423, 'LINESTRING', 2)</b></span></p><p>Example2: <span><b class="command">SELECT AddGeometryColumn(
-            'roads_geom', 'geom', 423, 'LINESTRING', 2)</b></span></p></li></ul></div><p>Here is an example of SQL used to create a table and add a
-        spatial column (assuming that an SRID of 128
-        exists already):</p><pre class="programlisting">CREATE TABLE parks ( PARK_ID int4, PARK_NAME varchar(128), PARK_DATE date, PARK_TYPE varchar(2) );
-SELECT AddGeometryColumn('parks', 'park_geom', 128, 'MULTIPOLYGON', 2 );</pre><p>Here is another example, using the generic "geometry" type and
-        the undefined SRID value of -1:</p><pre class="programlisting">CREATE TABLE roads ( ROAD_ID int4, ROAD_NAME varchar(128) ); 
-SELECT AddGeometryColumn( 'roads', 'roads_geom', -1, 'GEOMETRY', 3 );</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2523486"></a>4.2.4. Ensuring OpenGIS compliancy of geometries</h3></div></div><div></div></div><p>Most of the functions implemented by the GEOS library
-	rely on the assumption that your geometries are valid
-        as specified by the OpenGIS Simple Feature Specification.
-	To check validity of geometries you can use the
-	<a href="ch06.html#IsValid">IsValid()</a> function:</p><pre class="programlisting">gisdb=# select isvalid('LINESTRING(0 0, 1 1)'), isvalid('LINESTRING(0 0,0 0)');
- isvalid | isvalid
----------+---------
- t       | f</pre><p>By default, PostGIS does not apply this validity check on geometry input, because
-        testing for validity needs lots of CPU time for complex geometries, especially polygons.
-        If you do not trust your data sources, you can manually enforce such a check to your tables
-        by adding a check constraint:</p><pre class="programlisting">ALTER TABLE mytable ADD CONSTRAINT geometry_valid_check CHECK (isvalid(the_geom));</pre><p>If you encounter any strange error messages such as "GEOS Intersection() threw an 
-        error!" or "JTS Intersection() threw an error!" when calling PostGIS functions with valid
-        input geometries, you likely found an error in either PostGIS or one of the libraries it
-        uses, and you should contact the PostGIS developers. The same is true if a PostGIS function returns
-        an invalid geometry for valid input.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-	Strictly compliant OGC geometries cannot have Z or M values.
-	The <a href="ch06.html#IsValid">IsValid()</a> function won't
-	consider higher dimensioned geometries invalid! Invocations
-	of <a href="ch06.html#AddGeometryColumn">AddGeometryColumn()</a>
-        will add a constraint checking geometry dimensions, so it is
-        enough to specify 2 there.
-	</p></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2523576"></a>4.3. Loading GIS Data</h2></div></div><div></div></div><p>Once you have created a spatial table, you are ready to upload GIS
-      data to the database. Currently, there are two ways to get data into a
-      PostGIS/PostgreSQL database: using formatted SQL statements or using the
-      Shape file loader/dumper.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2523590"></a>4.3.1. Using SQL</h3></div></div><div></div></div><p>If you can convert your data to a text representation, then
-        using formatted SQL might be the easiest way to get your data into
-        PostGIS. As with Oracle and other SQL databases, data can be bulk
-        loaded by piping a large text file full of SQL "INSERT" statements
-        into the SQL terminal monitor.</p><p>A data upload file (<tt class="filename">roads.sql</tt> for example)
-        might look like this:</p><pre class="programlisting">BEGIN;
-INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (1,GeomFromText('LINESTRING(191232 243118,191108 243242)',-1),'Jeff Rd'); 
-INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (2,GeomFromText('LINESTRING(189141 244158,189265 244817)',-1),'Geordie Rd'); 
-INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (3,GeomFromText('LINESTRING(192783 228138,192612 229814)',-1),'Paul St'); 
-INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (4,GeomFromText('LINESTRING(189412 252431,189631 259122)',-1),'Graeme Ave'); 
-INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (5,GeomFromText('LINESTRING(190131 224148,190871 228134)',-1),'Phil Tce'); 
-INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (6,GeomFromText('LINESTRING(198231 263418,198213 268322)',-1),'Dave Cres');
-COMMIT;</pre><p>The data file can be piped into PostgreSQL very easily using the
-        "psql" SQL terminal monitor:</p><pre class="programlisting">psql -d [database] -f roads.sql</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2523645"></a>4.3.2. Using the Loader</h3></div></div><div></div></div><p>The <tt class="filename">shp2pgsql</tt> data loader converts ESRI
-        Shape files into SQL suitable for insertion into a PostGIS/PostgreSQL
-        database. The loader has several operating modes distinguished by
-        command line flags:</p><div class="variablelist"><dl><dt><span class="term">-d</span></dt><dd><p>Drops the database table before creating a new table with
-              the data in the Shape file.</p></dd><dt><span class="term">-a</span></dt><dd><p>Appends data from the Shape file into the database table.
-              Note that to use this option to load multiple files, the files
-              must have the same attributes and same data types.</p></dd><dt><span class="term">-c</span></dt><dd><p>Creates a new table and populates it from the Shape file.
-              <span class="emphasis"><em>This is the default mode.</em></span></p></dd><dt><span class="term">-p</span></dt><dd><p>Only produces the table creation SQL code, without adding 
-              any actual data. This can be used if you need to completely
-              separate the table creation and data loading steps.</p></dd><dt><span class="term">-D</span></dt><dd><p>Use the PostgreSQL "dump" format for the output data. This 
-              can be combined with -a, -c and -d. It is much faster to load
-              than the default "insert" SQL format. Use this for very large data
-              sets.</p></dd><dt><span class="term">-s &lt;SRID&gt;</span></dt><dd><p>Creates and populates the geometry tables with the
-              specified SRID.</p></dd><dt><span class="term">-k</span></dt><dd><p>Keep idendifiers case (column, schema and attributes). Note that attributes in Shapefile are all UPPERCASE.</p></dd><dt><span class="term">-i</span></dt><dd><p>Coerce all integers to standard 32-bit integers, do not
-              create 64-bit bigints, even if the DBF header signature appears
-              to warrant it.</p></dd><dt><span class="term">-I</span></dt><dd><p>Create a GiST index on the geometry column.</p></dd><dt><span class="term">-w</span></dt><dd><p>
-       	      Output WKT format, for use with older (0.x) versions of PostGIS.
-              Note  that this will introduce coordinate drifts and will drop M
-              values from shapefiles.
-              </p></dd><dt><span class="term">-W &lt;encoding&gt;</span></dt><dd><p>
-Specify encoding of the input data (dbf file).
-When used, all attributes of the dbf are converted from the specified
-encoding to UTF8. The resulting SQL output will contain a <tt class="code">SET
-CLIENT_ENCODING to UTF8</tt> command, so that the backend will be able
-to reconvert from UTF8 to whatever encoding the database is configured
-to use internally.
-		</p></dd></dl></div><p>Note that -a, -c, -d and -p are mutually exclusive.</p><p>An example session using the loader to create an input file and
-        uploading it might look like this:</p><pre class="programlisting"># shp2pgsql shaperoads myschema.roadstable &gt; roads.sql 
-# psql -d roadsdb -f roads.sql</pre><p>A conversion and upload can be done all in one step using UNIX
-        pipes:</p><pre class="programlisting"># shp2pgsql shaperoads myschema.roadstable | psql -d roadsdb</pre></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2523875"></a>4.4. Retrieving GIS Data</h2></div></div><div></div></div><p>Data can be extracted from the database using either SQL or the
-      Shape file loader/dumper. In the section on SQL we will discuss some of
-      the operators available to do comparisons and queries on spatial
-      tables.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2523888"></a>4.4.1. Using SQL</h3></div></div><div></div></div><p>The most straightforward means of pulling data out of the
-        database is to use a SQL select query and dump the resulting columns
-        into a parsable text file:</p><pre class="programlisting">db=# SELECT id, AsText(geom) AS geom, name FROM ROADS_GEOM; 
-id | geom                                    | name 
----+-----------------------------------------+-----------
- 1 | LINESTRING(191232 243118,191108 243242) | Jeff Rd  
- 2 | LINESTRING(189141 244158,189265 244817) | Geordie Rd 
- 3 | LINESTRING(192783 228138,192612 229814) | Paul St 
- 4 | LINESTRING(189412 252431,189631 259122) | Graeme Ave 
- 5 | LINESTRING(190131 224148,190871 228134) | Phil Tce 
- 6 | LINESTRING(198231 263418,198213 268322) | Dave Cres 
- 7 | LINESTRING(218421 284121,224123 241231) | Chris Way 
-(6 rows)</pre><p>However, there will be times when some kind of restriction is
-        necessary to cut down the number of fields returned. In the case of
-        attribute-based restrictions, just use the same SQL syntax as normal
-        with a non-spatial table. In the case of spatial restrictions, the
-        following operators are available/useful:</p><div class="variablelist"><dl><dt><span class="term">&amp;&amp;</span></dt><dd><p>This operator tells whether the bounding box of one
-              geometry intersects the bounding box of another.</p></dd><dt><span class="term">~=</span></dt><dd><p>This operators tests whether two geometries are
-              geometrically identical. For example, if 'POLYGON((0 0,1 1,1 0,0
-              0))' is the same as 'POLYGON((0 0,1 1,1 0,0 0))' (it is).</p></dd><dt><span class="term">=</span></dt><dd><p>This operator is a little more naive, it only tests
-              whether the bounding boxes of to geometries are the same.</p></dd></dl></div><p>Next, you can use these operators in queries. Note that when
-        specifying geometries and boxes on the SQL command line, you must
-        explicitly turn the string representations into geometries by using
-        the "GeomFromText()" function. So, for example:</p><pre class="programlisting">SELECT 
-  ID, NAME 
-FROM ROADS_GEOM 
-WHERE 
-  GEOM ~= GeomFromText('LINESTRING(191232 243118,191108 243242)',-1);</pre><p>The above query would return the single record from the
-        "ROADS_GEOM" table in which the geometry was equal to that
-        value.</p><p>When using the "&amp;&amp;" operator, you can specify either a
-        BOX3D as the comparison feature or a GEOMETRY. When you specify a
-        GEOMETRY, however, its bounding box will be used for the
-        comparison.</p><pre class="programlisting">SELECT 
-  ID, NAME 
-FROM ROADS_GEOM 
-WHERE 
-  GEOM &amp;&amp; GeomFromText('POLYGON((191232 243117,191232 243119,191234 243117,191232 243117))',-1);</pre><p>The above query will use the bounding box of the polygon for
-        comparison purposes.</p><p>The most common spatial query will probably be a "frame-based"
-        query, used by client software, like data browsers and web mappers, to
-        grab a "map frame" worth of data for display. Using a "BOX3D" object
-        for the frame, such a query looks like this:</p><pre class="programlisting">SELECT 
-  AsText(GEOM) AS GEOM 
-FROM ROADS_GEOM 
-WHERE 
-  GEOM &amp;&amp; SetSRID('BOX3D(191232 243117,191232 243119)'::box3d,-1);</pre><p>Note the use of the SRID, to specify the projection of the
-        BOX3D. The value -1 is used to indicate no specified SRID.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2524054"></a>4.4.2. Using the Dumper</h3></div></div><div></div></div><p>The <tt class="filename">pgsql2shp</tt> table dumper connects
-        directly to the database and converts a table (possibly defined by
-	a query) into a shape file. The
-        basic syntax is:</p><pre class="programlisting">pgsql2shp [&lt;options&gt;] &lt;database&gt; [&lt;schema&gt;.]&lt;table&gt;</pre><pre class="programlisting">pgsql2shp [&lt;options&gt;] &lt;database&gt; &lt;query&gt;</pre><p>The commandline options are:</p><div class="variablelist"><dl><dt><span class="term">-f &lt;filename&gt;</span></dt><dd><p>Write the output to a particular filename.</p></dd><dt><span class="term">-h &lt;host&gt;</span></dt><dd><p>The database host to connect to.</p></dd><dt><span class="term">-p &lt;port&gt;</span></dt><dd><p>The port to connect to on the database host.</p></dd><dt><span class="term">-P &lt;password&gt;</span></dt><dd><p>The password to use when connecting to the
-              database.</p></dd><dt><span class="term">-u &lt;user&gt;</span></dt><dd><p>The username to use when connecting to the
-              database.</p></dd><dt><span class="term">-g &lt;geometry column&gt;</span></dt><dd><p>In the case of tables with multiple geometry columns, the
-              geometry column to use when writing the shape file.</p></dd><dt><span class="term">-b</span></dt><dd><p>Use a binary cursor. This will make the operation faster,
-	      but will not work if any NON-geometry attribute in the table
-	      lacks a cast to text.</p></dd><dt><span class="term">-r</span></dt><dd><p>Raw mode. Do not drop the <tt class="varname">gid</tt> field, or
-              escape column names.</p></dd><dt><span class="term">-d</span></dt><dd><p>For backward compatibility: write a 3-dimensional shape
-	      file when dumping from old (pre-1.0.0) postgis databases (the
-	      default is to write a 2-dimensional shape file in that case).
-	      Starting from postgis-1.0.0+, dimensions are fully encoded.
-	      </p></dd></dl></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2524232"></a>4.5. Building Indexes</h2></div></div><div></div></div><p>Indexes are what make using a spatial database for large data sets
-      possible. Without indexing, any search for a feature would require a
-      "sequential scan" of every record in the database. Indexing speeds up
-      searching by organizing the data into a search tree which can be quickly
-      traversed to find a particular record. PostgreSQL supports three kinds
-      of indexes by default: B-Tree indexes, R-Tree indexes, and GiST
-      indexes.</p><div class="itemizedlist"><ul type="disc"><li><p>B-Trees are used for data which can be sorted along one axis;
-          for example, numbers, letters, dates. GIS data cannot be rationally
-          sorted along one axis (which is greater, (0,0) or (0,1) or (1,0)?)
-          so B-Tree indexing is of no use for us.</p></li><li><p>R-Trees break up data into rectangles, and sub-rectangles, and
-          sub-sub rectangles, etc. R-Trees are used by some spatial databases
-          to index GIS data, but the PostgreSQL R-Tree implementation is not
-          as robust as the GiST implementation.</p></li><li><p>GiST (Generalized Search Trees) indexes break up data into
-          "things to one side", "things which overlap", "things which are
-          inside" and can be used on a wide range of data-types, including GIS
-          data. PostGIS uses an R-Tree index implemented on top of GiST to
-          index GIS data.</p></li></ul></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2524285"></a>4.5.1. GiST Indexes</h3></div></div><div></div></div><p>GiST stands for "Generalized Search Tree" and is a generic form
-        of indexing. In addition to GIS indexing, GiST is used to speed up
-        searches on all kinds of irregular data structures (integer arrays,
-        spectral data, etc) which are not amenable to normal B-Tree
-        indexing.</p><p>Once a GIS data table exceeds a few thousand rows, you will want
-        to build an index to speed up spatial searches of the data (unless all
-        your searches are based on attributes, in which case you'll want to
-        build a normal index on the attribute fields).</p><p>The syntax for building a GiST index on a "geometry" column is
-        as follows:</p><pre class="programlisting">CREATE INDEX [indexname] ON [tablename] 
-  USING GIST ( [geometryfield] GIST_GEOMETRY_OPS ); </pre><p>Building a spatial index is a computationally intensive
-        exercise: on tables of around 1 million rows, on a 300MHz Solaris
-        machine, we have found building a GiST index takes about 1 hour. After
-        building an index, it is important to force PostgreSQL to collect
-        table statistics, which are used to optimize query plans:</p><pre class="programlisting">VACUUM ANALYZE [table_name] [column_name];
-
--- This is only needed for PostgreSQL 7.4 installations and below
-SELECT UPDATE_GEOMETRY_STATS([table_name], [column_name]);</pre><p>GiST indexes have two advantages over R-Tree indexes in
-        PostgreSQL. Firstly, GiST indexes are "null safe", meaning they can
-        index columns which include null values. Secondly, GiST indexes
-        support the concept of "lossiness" which is important when dealing
-        with GIS objects larger than the PostgreSQL 8K page size. Lossiness
-        allows PostgreSQL to store only the "important" part of an object in
-        an index -- in the case of GIS objects, just the bounding box. GIS
-        objects larger than 8K will cause R-Tree indexes to fail in the
-        process of being built.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2524354"></a>4.5.2. Using Indexes</h3></div></div><div></div></div><p>Ordinarily, indexes invisibly speed up data access: once the
-        index is built, the query planner transparently decides when to use
-        index information to speed up a query plan. Unfortunately, the
-        PostgreSQL query planner does not optimize the use of GiST indexes
-        well, so sometimes searches which should use a spatial index instead
-        default to a sequence scan of the whole table.</p><p>If you find your spatial indexes are not being used (or your
-        attribute indexes, for that matter) there are a couple things you can
-        do:</p><div class="itemizedlist"><ul type="disc"><li><p>Firstly, make sure statistics are gathered about the number
-            and distributions of values in a table, to provide the query
-            planner with better information to make decisions around index
-            usage. For PostgreSQL 7.4 installations and below this is done by
-            running <span><b class="command">update_geometry_stats([table_name,
-            column_name])</b></span> (compute distribution) and <span><b class="command">VACUUM
-            ANALYZE [table_name] [column_name]</b></span> (compute number of
-            values). Starting with PostgreSQL 8.0 running <span><b class="command">VACUUM
-            ANALYZE</b></span> will do both operations. You should regularly
-            vacuum your databases anyways -- many PostgreSQL DBAs have
-            <span><b class="command">VACUUM</b></span> run as an off-peak cron job on a regular
-            basis.</p></li><li><p>If vacuuming does not work, you can force the planner to use
-            the index information by using the <span><b class="command">SET
-            ENABLE_SEQSCAN=OFF</b></span> command. You should only use this
-            command sparingly, and only on spatially indexed queries:
-            generally speaking, the planner knows better than you do about
-            when to use normal B-Tree indexes. Once you have run your query,
-            you should consider setting <tt class="varname">ENABLE_SEQSCAN</tt> back
-            on, so that other queries will utilize the planner as
-            normal.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>As of version 0.6, it should not be necessary to force the
-              planner to use the index with
-              <tt class="varname">ENABLE_SEQSCAN</tt>.</p></div></li><li><p>If you find the planner wrong about the cost of sequencial
-            vs index scans try reducing the value of random_page_cost in
-            postgresql.conf or using SET random_page_cost=#. Default value for
-            the parameter is 4, try setting it to 1 or 2. Decrementing the
-            value makes the planner more inclined of using Index scans.</p></li></ul></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2524472"></a>4.6. Complex Queries</h2></div></div><div></div></div><p>The <span class="emphasis"><em>raison d'etre</em></span> of spatial database
-      functionality is performing queries inside the database which would
-      ordinarily require desktop GIS functionality. Using PostGIS effectively
-      requires knowing what spatial functions are available, and ensuring that
-      appropriate indexes are in place to provide good performance.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2524491"></a>4.6.1. Taking Advantage of Indexes</h3></div></div><div></div></div><p>When constructing a query it is important to remember that only
-        the bounding-box-based operators such as &amp;&amp; can take advatage
-        of the GiST spatial index. Functions such as
-        <tt class="varname">distance()</tt> cannot use the index to optimize their
-        operation. For example, the following query would be quite slow on a
-        large table:</p><pre class="programlisting">SELECT the_geom FROM geom_table
-WHERE distance( the_geom, GeomFromText( 'POINT(100000 200000)', -1 ) ) &lt; 100</pre><p>This query is selecting all the geometries in geom_table which
-        are within 100 units of the point (100000, 200000). It will be slow
-        because it is calculating the distance between each point in the table
-        and our specified point, ie. one <tt class="varname">distance()</tt>
-        calculation for each row in the table. We can avoid this by using the
-        &amp;&amp; operator to reduce the number of distance calculations
-        required:</p><pre class="programlisting">SELECT the_geom FROM geom_table
-WHERE the_geom &amp;&amp; 'BOX3D(90900 190900, 100100 200100)'::box3d
-  AND distance( the_geom, GeomFromText( 'POINT(100000 200000)', -1 ) ) &lt; 100</pre><p>This query selects the same geometries, but it does it in a more
-        efficient way. Assuming there is a GiST index on the_geom, the query
-        planner will recognize that it can use the index to reduce the number
-        of rows before calculating the result of the
-        <tt class="varname">distance()</tt> function. Notice that the
-        <tt class="varname">BOX3D</tt> geometry which is used in the &amp;&amp;
-        operation is a 200 unit square box centered on the original point -
-        this is our "query box". The &amp;&amp; operator uses the index to
-        quickly reduce the result set down to only those geometries which have
-        bounding boxes that overlap the "query box". Assuming that our query
-        box is much smaller than the extents of the entire geometry table,
-        this will drastically reduce the number of distance calculations that
-        need to be done.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2524587"></a>4.6.2. Examples of Spatial SQL</h3></div></div><div></div></div><p>The examples in this section will make use of two tables, a
-        table of linear roads, and a table of polygonal municipality
-        boundaries. The table definitions for the <tt class="varname">bc_roads</tt>
-        table is:</p><pre class="programlisting">  Column    |       Type        |   Description
-------------+-------------------+-------------------
- gid        | integer           | Unique ID
- name       | character varying | Road Name
- the_geom   | geometry          | Location Geometry (Linestring)</pre><p>The table definition for the <tt class="varname">bc_municipality</tt>
-        table is:</p><pre class="programlisting">  Column   |       Type        |   Description
------------+-------------------+-------------------
- gid       | integer           | Unique ID
- code      | integer           | Unique ID
- name      | character varying | City / Town Name
- the_geom  | geometry          | Location Geometry (Polygon)</pre><div class="qandaset"><dl><dt>4.6.2.1. <a href="ch04.html#id2524633">What is the total length of all roads, expressed in
-                kilometers?</a></dt><dt>4.6.2.2. <a href="ch04.html#id2524660">How large is the city of Prince George, in
-                hectares?</a></dt><dt>4.6.2.3. <a href="ch04.html#id2524689">What is the largest municipality in the province, by
-                area?</a></dt><dt>4.6.2.4. <a href="ch04.html#id2524731">What is the length of roads fully contained within each
-                municipality?</a></dt><dt>4.6.2.5. <a href="ch04.html#id2524793">Create a new table with all the roads within the city of
-                Prince George.</a></dt><dt>4.6.2.6. <a href="ch04.html#id2524832">What is the length in kilometers of "Douglas St" in
-                Victoria?</a></dt><dt>4.6.2.7. <a href="ch04.html#id2524866">What is the largest municipality polygon that has a
-                hole?</a></dt></dl><table border="0" summary="Q and A Set"><col align="left" width="1%"><tbody><tr class="question"><td align="left" valign="top"><a name="id2524633"></a><a name="id2524635"></a><b>4.6.2.1.</b></td><td align="left" valign="top"><p>What is the total length of all roads, expressed in
-                kilometers?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>You can answer this question with a very simple piece of
-                SQL:</p><pre class="programlisting">postgis=# SELECT sum(length(the_geom))/1000 AS km_roads FROM bc_roads;
-     km_roads
-------------------
- 70842.1243039643
-(1 row)</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2524660"></a><a name="id2524663"></a><b>4.6.2.2.</b></td><td align="left" valign="top"><p>How large is the city of Prince George, in
-                hectares?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>This query combines an attribute condition (on the
-                municipality name) with a spatial calculation (of the
-                area):</p><pre class="programlisting">postgis=# SELECT area(the_geom)/10000 AS hectares FROM bc_municipality 
-          WHERE name = 'PRINCE GEORGE';
-     hectares
-------------------
- 32657.9103824927
-(1 row) </pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2524689"></a><a name="id2524691"></a><b>4.6.2.3.</b></td><td align="left" valign="top"><p>What is the largest municipality in the province, by
-                area?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>This query brings a spatial measurement into the query
-                condition. There are several ways of approaching this problem,
-                but the most efficient is below:</p><pre class="programlisting">postgis=# SELECT name, area(the_geom)/10000 AS hectares 
-          FROM bc_municipality 
-          ORDER BY hectares DESC 
-          LIMIT 1;
-     name      |    hectares
----------------+-----------------
- TUMBLER RIDGE | 155020.02556131
-(1 row)</pre><p>Note that in order to answer this query we have to
-                calculate the area of every polygon. If we were doing this a
-                lot it would make sense to add an area column to the table
-                that we could separately index for performance. By ordering
-                the results in a descending direction, and them using the
-                PostgreSQL "LIMIT" command we can easily pick off the largest
-                value without using an aggregate function like max().</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2524731"></a><a name="id2524733"></a><b>4.6.2.4.</b></td><td align="left" valign="top"><p>What is the length of roads fully contained within each
-                municipality?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>This is an example of a "spatial join", because we are
-                bringing together data from two tables (doing a join) but
-                using a spatial interaction condition ("contained") as the
-                join condition rather than the usual relational approach of
-                joining on a common key:</p><pre class="programlisting">postgis=# SELECT m.name, sum(length(r.the_geom))/1000 as roads_km 
-          FROM bc_roads AS r,bc_municipality AS m 
-          WHERE r.the_geom &amp;&amp; m.the_geom 
-          AND contains(m.the_geom,r.the_geom) 
-          GROUP BY m.name 
-          ORDER BY roads_km;
-
-            name            |     roads_km
-----------------------------+------------------
- SURREY                     | 1539.47553551242
- VANCOUVER                  | 1450.33093486576
- LANGLEY DISTRICT           | 833.793392535662
- BURNABY                    | 773.769091404338
- PRINCE GEORGE              |  694.37554369147
- ...</pre><p>This query takes a while, because every road in the
-                table is summarized into the final result (about 250K roads
-                for our particular example table). For smaller overlays
-                (several thousand records on several hundred) the response can
-                be very fast.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2524793"></a><a name="id2524795"></a><b>4.6.2.5.</b></td><td align="left" valign="top"><p>Create a new table with all the roads within the city of
-                Prince George.</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>This is an example of an "overlay", which takes in two
-                tables and outputs a new table that consists of spatially
-                clipped or cut resultants. Unlike the "spatial join"
-                demonstrated above, this query actually creates new
-                geometries. An overlay is like a turbo-charged spatial join,
-                and is useful for more exact analysis work:</p><pre class="programlisting">postgis=# CREATE TABLE pg_roads as
-          SELECT intersection(r.the_geom, m.the_geom) AS intersection_geom, 
-                 length(r.the_geom) AS rd_orig_length, 
-                 r.* 
-          FROM bc_roads AS r, bc_municipality AS m 
-          WHERE r.the_geom &amp;&amp; m.the_geom 
-          AND intersects(r.the_geom, m.the_geom) 
-          AND m.name = 'PRINCE GEORGE';</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2524832"></a><a name="id2524834"></a><b>4.6.2.6.</b></td><td align="left" valign="top"><p>What is the length in kilometers of "Douglas St" in
-                Victoria?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><pre class="programlisting">postgis=# SELECT sum(length(r.the_geom))/1000 AS kilometers 
-          FROM bc_roads r, bc_municipality m 
-          WHERE r.the_geom &amp;&amp; m.the_geom 
-          AND r.name = 'Douglas St' 
-          AND m.name = 'VICTORIA';
-    kilometers
-------------------
- 4.89151904172838
-(1 row)</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2524866"></a><a name="id2524868"></a><b>4.6.2.7.</b></td><td align="left" valign="top"><p>What is the largest municipality polygon that has a
-                hole?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><pre class="programlisting">postgis=# SELECT gid, name, area(the_geom) AS area 
-          FROM bc_municipality 
-          WHERE nrings(the_geom) &gt; 1 
-          ORDER BY area DESC LIMIT 1;
- gid |     name     |       area
------+--------------+------------------
-  12 | SPALLUMCHEEN | 257374619.430216
-(1 row)</pre></td></tr></tbody></table></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2524902"></a>4.7. Using Mapserver</h2></div></div><div></div></div><p>The Minnesota Mapserver is an internet web-mapping server which
-      conforms to the OpenGIS Web Mapping Server specification.</p><div class="itemizedlist"><ul type="disc"><li><p>The Mapserver homepage is at <a href="http://mapserver.gis.umn.edu" target="_top">http://mapserver.gis.umn.edu</a>.</p></li><li><p>The OpenGIS Web Map Specification is at <a href="http://www.opengis.org/techno/specs/01-047r2.pdf" target="_top">http://www.opengis.org/techno/specs/01-047r2.pdf</a>.</p></li></ul></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2524945"></a>4.7.1. Basic Usage</h3></div></div><div></div></div><p>To use PostGIS with Mapserver, you will need to know about how
-        to configure Mapserver, which is beyond the scope of this
-        documentation. This section will cover specific PostGIS issues and
-        configuration details.</p><p>To use PostGIS with Mapserver, you will need:</p><div class="itemizedlist"><ul type="disc"><li><p>Version 0.6 or newer of PostGIS.</p></li><li><p>Version 3.5 or newer of Mapserver.</p></li></ul></div><p>Mapserver accesses PostGIS/PostgreSQL data like any other
-        PostgreSQL client -- using <tt class="filename">libpq</tt>. This means that
-        Mapserver can be installed on any machine with network access to the
-        PostGIS server, as long as the system has the
-        <tt class="filename">libpq</tt> PostgreSQL client libraries.</p><div class="orderedlist"><ol type="1"><li><p>Compile and install Mapserver, with whatever options you
-            desire, including the "--with-postgis" configuration
-            option.</p></li><li><p>In your Mapserver map file, add a PostGIS layer. For
-            example:</p><pre class="programlisting">LAYER
-  CONNECTIONTYPE postgis
-  NAME "widehighways"
-  # Connect to a remote spatial database
-  CONNECTION "user=dbuser dbname=gisdatabase host=bigserver"
-  # Get the lines from the 'geom' column of the 'roads' table
-  DATA "geom from roads"
-  STATUS ON
-  TYPE LINE
-  # Of the lines in the extents, only render the wide highways
-  FILTER "type = 'highway' and numlanes &gt;= 4"
-  CLASS
-    # Make the superhighways brighter and 2 pixels wide
-    EXPRESSION ([numlanes] &gt;= 6)
-    COLOR 255 22 22      
-    SYMBOL "solid"
-    SIZE 2
-  END
-  CLASS
-    # All the rest are darker and only 1 pixel wide
-    EXPRESSION ([numlanes] &lt; 6)
-    COLOR 205 92 82      
-  END
-END</pre><p>In the example above, the PostGIS-specific directives are as
-            follows:</p><div class="variablelist"><dl><dt><span class="term">CONNECTIONTYPE</span></dt><dd><p>For PostGIS layers, this is always "postgis".</p></dd><dt><span class="term">CONNECTION</span></dt><dd><p>The database connection is governed by the a
-                  'connection string' which is a standard set of keys and
-                  values like this (with the default values in
-                  &lt;&gt;):</p><p>user=&lt;username&gt; password=&lt;password&gt;
-                  dbname=&lt;username&gt; hostname=&lt;server&gt;
-                  port=&lt;5432&gt;</p><p>An empty connection string is still valid, and any of
-                  the key/value pairs can be omitted. At a minimum you will
-                  generally supply the database name and username to connect
-                  with.</p></dd><dt><span class="term">DATA</span></dt><dd><p>The form of this parameter is "&lt;column&gt; from
-                  &lt;tablename&gt;" where the column is the spatial column to
-                  be rendered to the map.</p></dd><dt><span class="term">FILTER</span></dt><dd><p>The filter must be a valid SQL string corresponding to
-                  the logic normally following the "WHERE" keyword in a SQL
-                  query. So, for example, to render only roads with 6 or more
-                  lanes, use a filter of "num_lanes &gt;= 6".</p></dd></dl></div></li><li><p>In your spatial database, ensure you have spatial (GiST)
-            indexes built for any the layers you will be drawing.</p><pre class="programlisting">CREATE INDEX [indexname]
-  ON [tablename] 
-  USING GIST ( [geometrycolumn] GIST_GEOMETRY_OPS );</pre></li><li><p>If you will be querying your layers using Mapserver you will
-            also need an "oid index".</p><p>Mapserver requires unique identifiers for each spatial
-            record when doing queries, and the PostGIS module of Mapserver
-            uses the PostgreSQL <tt class="varname">oid</tt> value to provide these
-            unique identifiers. A side-effect of this is that in order to do
-            fast random access of records during queries, an index on the
-            <tt class="varname">oid</tt> is needed.</p><p>To build an "oid index", use the following SQL:</p><pre class="programlisting">CREATE INDEX [indexname] ON [tablename] ( oid );</pre></li></ol></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2525193"></a>4.7.2. Frequently Asked Questions</h3></div></div><div></div></div><div class="qandaset"><dl><dt>4.7.2.1. <a href="ch04.html#id2525201">When I use an EXPRESSION in my map
-                file, the condition never returns as true, even though I know
-                the values exist in my table.</a></dt><dt>4.7.2.2. <a href="ch04.html#id2525235">The FILTER I use for my Shape files is not working for
-                my PostGIS table of the same data.</a></dt><dt>4.7.2.3. <a href="ch04.html#id2525264">My PostGIS layer draws much slower than my Shape file
-                layer, is this normal?</a></dt><dt>4.7.2.4. <a href="ch04.html#id2525302">My PostGIS layer draws fine, but queries are really
-                slow. What is wrong?</a></dt></dl><table border="0" summary="Q and A Set"><col align="left" width="1%"><tbody><tr class="question"><td align="left" valign="top"><a name="id2525201"></a><a name="id2525203"></a><b>4.7.2.1.</b></td><td align="left" valign="top"><p>When I use an <tt class="varname">EXPRESSION</tt> in my map
-                file, the condition never returns as true, even though I know
-                the values exist in my table.</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>Unlike shape files, PostGIS field names have to be
-                referenced in EXPRESSIONS using <span class="emphasis"><em>lower
-                case</em></span>.</p><pre class="programlisting">EXPRESSION ([numlanes] &gt;= 6)</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2525235"></a><a name="id2525237"></a><b>4.7.2.2.</b></td><td align="left" valign="top"><p>The FILTER I use for my Shape files is not working for
-                my PostGIS table of the same data.</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>Unlike shape files, filters for PostGIS layers use SQL
-                syntax (they are appended to the SQL statement the PostGIS
-                connector generates for drawing layers in Mapserver).</p><pre class="programlisting">FILTER "type = 'highway' and numlanes &gt;= 4"</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2525264"></a><a name="id2525266"></a><b>4.7.2.3.</b></td><td align="left" valign="top"><p>My PostGIS layer draws much slower than my Shape file
-                layer, is this normal?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>In general, expect PostGIS layers to be 10% slower than
-                equivalent Shape files layers, due to the extra overhead
-                involved in database connections, data transformations and
-                data transit between the database and Mapserver.</p><p>If you are finding substantial draw performance
-                problems, it is likely that you have not build a spatial index
-                on your table.</p><pre class="programlisting">postgis# CREATE INDEX geotable_gix ON geotable USING GIST ( geocolumn );
-postgis# SELECT update_geometry_stats();  -- For PGSQL &lt; 8.0
-postgis# VACUUM ANALYZE;                  -- For PGSQL &gt;= 8.0</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2525302"></a><a name="id2525304"></a><b>4.7.2.4.</b></td><td align="left" valign="top"><p>My PostGIS layer draws fine, but queries are really
-                slow. What is wrong?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>For queries to be fast, you must have a unique key for
-                your spatial table and you must have an index on that unique
-                key.</p><p>You can specify what unique key for mapserver to use
-                with the <tt class="varname">USING UNIQUE</tt> clause in your
-                <tt class="varname">DATA</tt> line:</p><pre class="programlisting">DATA "the_geom FROM geotable USING UNIQUE gid"</pre><p>If your table does not have an explicit unique column,
-                you can "fake" a unique column by using the PostgreSQL row
-                "oid" for your unique column. "oid" is the default unique
-                column if you do not declare one, so enhancing your query
-                speed is a matter of building an index on your spatial table
-                oid value.</p><pre class="programlisting">postgis# CREATE INDEX geotable_oid_idx ON geotable (oid);</pre></td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2525360"></a>4.7.3. Advanced Usage</h3></div></div><div></div></div><p>The <tt class="varname">USING</tt> pseudo-SQL clause is used to add
-        some information to help mapserver understand the results of more
-        complex queries. More specifically, when either a view or a subselect
-        is used as the source table (the thing to the right of "FROM" in a
-        <tt class="varname">DATA</tt> definition) it is more difficult for mapserver
-        to automatically determine a unique identifier for each row and also
-        the SRID for the table. The <tt class="varname">USING</tt> clause can
-        provide mapserver with these two pieces of information as
-        follows:</p><pre class="programlisting">DATA "the_geom FROM (SELECT table1.the_geom AS the_geom, table1.oid AS oid, table2.data AS data
- FROM table1 LEFT JOIN table2 ON table1.id = table2.id) AS new_table USING UNIQUE oid USING SRID=-1"</pre><div class="variablelist"><dl><dt><span class="term">USING UNIQUE &lt;uniqueid&gt;</span></dt><dd><p>Mapserver requires a unique id for each row in order to
-              identify the row when doing map queries. Normally, it would use
-              the oid as the unique identifier, but views and subselects don't
-              automatically have an oid column. If you want to use Mapserver's
-              query functionality, you need to add a unique column to your
-              view or subselect, and declare it with <tt class="varname">USING
-              UNIQUE</tt>. For example, you could explicitly select one
-              of the table's oid values for this purpose, or any other column
-              which is guaranteed to be unique for the result set.</p><p>The <tt class="varname">USING</tt> statement can also be useful
-              even for simple <tt class="varname">DATA</tt> statements, if you are
-              doing map queries. It was previously recommended to add an index
-              on the oid column of tables used in query-able layers, in order
-              to speed up the performance of map queries. However, with the
-              <tt class="varname">USING</tt> clause, it is possible to tell
-              mapserver to use your table's primary key as the identifier for
-              map queries, and then it is no longer necessary to have an
-              additional index.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>"Querying a Map" is the action of clicking on a map to
-                ask for information about the map features in that location.
-                Don't confuse "map queries" with the SQL query in a
-                <tt class="varname">DATA</tt> definition.</p></div></dd><dt><span class="term">USING SRID=&lt;srid&gt;</span></dt><dd><p>PostGIS needs to know which spatial referencing system is
-              being used by the geometries in order to return the correct data
-              back to mapserver. Normally it is possible to find this
-              information in the "geometry_columns" table in the PostGIS
-              database, however, this is not possible for tables which are
-              created on the fly such as subselects and views. So the
-              <tt class="varname">USING SRID=</tt> option allows the correct SRID to
-              be specified in the <tt class="varname">DATA</tt> definition.</p></dd></dl></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>The parser for Mapserver PostGIS layers is fairly primitive,
-          and is case sensitive in a few areas. Be careful to ensure that all
-          SQL keywords and all your <tt class="varname">USING</tt> clauses are in
-          upper case, and that your <tt class="varname">USING UNIQUE</tt> clause
-          precedes your <tt class="varname">USING SRID</tt> clause.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2453149"></a>4.7.4. Examples</h3></div></div><div></div></div><p>Lets start with a simple example and work our way up. Consider
-        the following Mapserver layer definition:</p><pre class="programlisting">LAYER
- CONNECTIONTYPE postgis
- NAME "roads"
- CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
- DATA "the_geom FROM roads"
- STATUS ON
- TYPE LINE
- CLASS
-  COLOR 0 0 0
- END
-END</pre><p>This layer will display all the road geometries in the roads
-        table as black lines.</p><p>Now lets say we want to show only the highways until we get
-        zoomed in to at least a 1:100000 scale - the next two layers will
-        acheive this effect:</p><pre class="programlisting">LAYER
- CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
- DATA "the_geom FROM roads"
- MINSCALE 100000
- STATUS ON
- TYPE LINE
- FILTER "road_type = 'highway'"
- CLASS
-  COLOR 0 0 0
- END
-END
-
-LAYER
- CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
- DATA "the_geom FROM roads"
- MAXSCALE 100000
- STATUS ON
- TYPE LINE
- CLASSITEM road_type
- CLASS
-  EXPRESSION "highway"
-  SIZE 2
-  COLOR 255 0 0
- END
- CLASS
-  COLOR 0 0 0
- END
-END</pre><p>The first layer is used when the scale is greater than 1:100000,
-        and displays only the roads of type "highway" as black lines. The
-        <tt class="varname">FILTER</tt> option causes only roads of type "highway"
-        to be displayed.</p><p>The second layer is used when the scale is less than 1:100000,
-        and will display highways as double-thick red lines, and other roads
-        as regular black lines.</p><p>So, we have done a couple of interesting things using only
-        mapserver functionality, but our <tt class="varname">DATA</tt> SQL statement
-        has remained simple. Suppose that the name of the road is stored in
-        another table (for whatever reason) and we need to do a join to get it
-        and label our roads.</p><pre class="programlisting">LAYER
- CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
- DATA "the_geom FROM (SELECT roads.oid AS oid, roads.the_geom AS the_geom, road_names.name as name
-   FROM roads LEFT JOIN road_names ON roads.road_name_id = road_names.road_name_id) AS named_roads
-   USING UNIQUE oid USING SRID=-1"
- MAXSCALE 20000
- STATUS ON
- TYPE ANNOTATION
- LABELITEM name
- CLASS
-  LABEL
-   ANGLE auto
-   SIZE 8
-   COLOR 0 192 0
-   TYPE truetype
-   FONT arial
-  END
- END
-END</pre><p>This annotation layer adds green labels to all the roads when
-        the scale gets down to 1:20000 or less. It also demonstrates how to
-        use an SQL join in a <tt class="varname">DATA</tt> definition.</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2453247"></a>4.8. Java Clients (JDBC)</h2></div></div><div></div></div><p>Java clients can access PostGIS "geometry" objects in the
-      PostgreSQL database either directly as text representations or using the
-      JDBC extension objects bundled with PostGIS. In order to use the
-      extension objects, the "postgis.jar" file must be in your CLASSPATH
-      along with the "postgresql.jar" JDBC driver package.</p><pre class="programlisting">import java.sql.*; 
-import java.util.*; 
-import java.lang.*; 
-import org.postgis.*; 
-
-public class JavaGIS { 
-  public static void main(String[] args) 
-  { 
-    java.sql.Connection conn; 
-    try 
-    { 
-      /* 
-      * Load the JDBC driver and establish a connection. 
-      */  
-      Class.forName("org.postgresql.Driver"); 
-      String url = "jdbc:postgresql://localhost:5432/database"; 
-      conn = DriverManager.getConnection(url, "postgres", ""); 
-    
-      /* 
-      * Add the geometry types to the connection. Note that you 
-      * must cast the connection to the pgsql-specific connection * implementation before calling the addDataType() method. 
-      */
-      ((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
-      ((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PGbox3d");
-
-      /* 
-      * Create a statement and execute a select query. 
-      */ 
-      Statement s = conn.createStatement(); 
-      ResultSet r = s.executeQuery("select AsText(geom) as geom,id from geomtable"); 
-      while( r.next() ) 
-      { 
-        /* 
-        * Retrieve the geometry as an object then cast it to the geometry type. 
-        * Print things out. 
-        */ 
-        PGgeometry geom = (PGgeometry)r.getObject(1); 
-        int id = r.getInt(2);
-        System.out.println("Row " + id + ":"); 
-        System.out.println(geom.toString()); 
-      }
-      s.close(); 
-      conn.close(); 
-    } 
-    catch( Exception e ) 
-    { 
-      e.printStackTrace(); 
-    }  
-  }
-}</pre><p>The "PGgeometry" object is a wrapper object which contains a
-      specific topological geometry object (subclasses of the abstract class
-      "Geometry") depending on the type: Point, LineString, Polygon,
-      MultiPoint, MultiLineString, MultiPolygon.</p><pre class="programlisting">PGgeometry geom = (PGgeometry)r.getObject(1); 
-if( geom.getType() = Geometry.POLYGON ) 
-{ 
-  Polygon pl = (Polygon)geom.getGeometry();
-  for( int r = 0; r &lt; pl.numRings(); r++ ) 
-  { 
-    LinearRing rng = pl.getRing(r);
-    System.out.println("Ring: " + r); 
-    for( int p = 0; p &lt; rng.numPoints(); p++ ) 
-    { 
-      Point pt = rng.getPoint(p); 
-      System.out.println("Point: " + p);
-      System.out.println(pt.toString()); 
-    } 
-  } 
-}</pre><p>The JavaDoc for the extension objects provides a reference for the
-      various data accessor functions in the geometric objects.</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2525835"></a>4.9. C Clients (libpq)</h2></div></div><div></div></div><p>...</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2525844"></a>4.9.1. Text Cursors</h3></div></div><div></div></div><p>...</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2525854"></a>4.9.2. Binary Cursors</h3></div></div><div></div></div><p>...</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch03.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch05.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 3. Frequently Asked Questions </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 5. Performance tips</td></tr></table></div></body></html>

Deleted: packages/postgis/trunk/doc/html/ch05.html
===================================================================
--- packages/postgis/trunk/doc/html/ch05.html	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/ch05.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,111 +0,0 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 5. Performance tips</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PostGIS Manual"><link rel="up" href="index.html" title="PostGIS Manual"><link rel="previous" href="ch04.html" title="Chapter 4. Using PostGIS"><link rel="next" href="ch06.html" title="Chapter 6. PostGIS Reference"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Performance tips</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch04.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch06.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2525866"></a>Chapter 5. Performance tips</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch05.html#id2525872">5.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05.html#id2525878">5.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="ch05.html#id2525930">5.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch05.html#id2525990">5.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="ch05.html#id2526046">5.3. Avoiding dimension conversion</a></span></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2525872"></a>5.1. Small tables of large geometries</h2></div></div><div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2525878"></a>5.1.1. Problem description</h3></div></div><div></div></div><p>
-Current PostgreSQL versions (including 8.0) suffer from a query
-optimizer weakness regarding TOAST tables. TOAST tables are a kind of
-"extension room" used to store large (in the sense of data size) values
-that do not fit into normal data pages (like long texts, images or
-complex geometries with lots of vertices), see
-http://www.postgresql.org/docs/8.0/static/storage-toast.html for more
-information).
-</p><p>
-The problem appears if you happen to have a table with rather large
-geometries, but not too much rows of them (like a table containing the
-boundaries of all european countries in high resolution). Then the table
-itsself is small, but it uses lots of TOAST space. In our example case,
-the table itsself had about 80 rows and used only 3 data pages, but the
-TOAST table used 8225 pages.
-</p><p>
-Now issue a query where you use the geometry operator &amp;&amp; to search for a
-bounding box that matches only very few of those rows. Now the query
-optimizer sees that the table has only 3 pages and 80 rows. He estimates
-that a sequential scan on such a small table is much faster than using
-an index. And so he decides to ignore the GIST index. Usually, this
-estimation is correct. But in our case, the &amp;&amp; operator has to fetch
-every geometry from disk to compare the bounding boxes, thus reading all
-TOAST pages, too.
-</p><p>
-To see whether your suffer from this bug, use the "EXPLAIN ANALYZE"
-postgresql command. For more information and the technical details, you
-can read the thread on the postgres performance mailing list:
-http://archives.postgresql.org/pgsql-performance/2005-02/msg00030.php
-</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2525930"></a>5.1.2. Workarounds</h3></div></div><div></div></div><p>
-The PostgreSQL people are trying to solve this issue by making the query
-estimation TOAST-aware. For now, here are two workarounds:
-</p><p>
-The first workaround is to force the query planner to use the index.
-Send "SET enable_seqscan TO off;" to the server before issuing the
-query. This basically forces the query planner to avoid sequential scans
-whenever possible. So it uses the GIST index as usual. But this flag has
-to be set on every connection, and it causes the query planner to make
-misestimations in other cases, so you should "SET enable_seqscan TO on;"
-after the query.
-</p><p>
-The second workaround is to make the sequential scan as fast as the
-query planner thinks. This can be achieved by creating an additional
-column that "caches" the bbox, and matching against this. In our
-example, the commands are like:
-</p><pre class="programlisting">
-SELECT addGeometryColumn('myschema','mytable','bbox','4326','GEOMETRY','2');
-
-UPDATE mytable set bbox = Envelope(Force_2d(the_geom));
-</pre><p>
-Now change your query to use the &amp;&amp; operator against bbox instead of
-geom_column, like:
-</p><pre class="programlisting">
-SELECT geom_column FROM mytable WHERE bbox &amp;&amp; SetSrid('BOX3D(0 0,1 1)'::box3d,4326);
-</pre><p>
-Of yourse, if you change or add rows to mytable, you have to keep the
-bbox "in sync". The most transparent way to do this would be triggers,
-but you also can modify your application to keep the bbox column current
-or run the UPDATE query above after every modification.
-</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2525990"></a>5.2. CLUSTERing on geometry indices</h2></div></div><div></div></div><p>
-For tables that are mostly read-only, and where a single index is used for the
-majority of queries, PostgreSQL offers the CLUSTER command. This command 
-physically reorders all the data rows in the same order as the index criteria,
-yielding two performance advantages: First, for index range scans, the number of 
-seeks on the data table is drastically reduced. Second, if your working set
-concentrates to some small intervals on the indices, you have a more efficient
-caching because the data rows are spread along fewer data pages. (Feel invited
-to read the CLUSTER command documentation from the PostgreSQL manual at this
-point.)
-</p><p>
-However, currently PostgreSQL does not allow clustering on PostGIS GIST indices
-because GIST indices simply ignores NULL values, you get an error message like:
-</p><pre class="programlisting">
-lwgeom=# CLUSTER my_geom_index ON my_table;
-ERROR:  cannot cluster when index access method does not handle null values
-HINT:  You may be able to work around this by marking column "the_geom" NOT NULL.
-</pre><p>
-As the HINT message tells you, one can work around this deficiency by adding a
-"not null" constraint to the table:
-</p><pre class="programlisting">
-lwgeom=# ALTER TABLE my_table ALTER COLUMN the_geom SET not null;
-ALTER TABLE
-</pre><p>
-Of course, this will not work if you in fact need NULL values in your geometry
-column. Additionally, you must use the above method to add the constraint, using
-a CHECK constraint like "ALTER TABLE blubb ADD CHECK (geometry is not null);" will
-not work.
-</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2526046"></a>5.3. Avoiding dimension conversion</h2></div></div><div></div></div><p>
-Sometimes, you happen to have 3D or 4D data in your table, but always access
-it using OpenGIS compliant asText() or asBinary() functions that only output
-2D geometries. They do this by internally calling the force_2d() function,
-which introduces a significant overhead for large geometries. To avoid this
-overhead, it may be feasible to pre-drop those additional dimensions once and
-forever:
-</p><pre class="programlisting">
-UPDATE mytable SET the_geom = force_2d(the_geom);
-VACUUM FULL ANALYZE mytable;
-</pre><p>
-Note that if you added your geometry column using AddGeometryColumn()
-there'll be a constraint on geometry dimension.
-To bypass it you will need to drop the constraint.
-Remember to update the entry in the geometry_columns table and
-recreate the constraint afterwards.
-</p><p>
-In case of large tables, it may be wise to divide this UPDATE into smaller portions
-by constraining the UPDATE to a part of the table via a WHERE clause and your
-primary key or another feasible criteria, and running a simple "VACUUM;" between
-your UPDATEs. This drastically reduces the need for temporary disk space.
-Additionally, if you have mixed dimension geometries, restricting the UPDATE by "WHERE 
-dimension(the_geom)&gt;2" skips re-writing of geometries that already are in 2D. 
-</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch04.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch06.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 4. Using PostGIS </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 6. PostGIS Reference</td></tr></table></div></body></html>

Deleted: packages/postgis/trunk/doc/html/ch06.html
===================================================================
--- packages/postgis/trunk/doc/html/ch06.html	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/ch06.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,599 +0,0 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 6. PostGIS Reference</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PostGIS Manual"><link rel="up" href="index.html" title="PostGIS Manual"><link rel="previous" href="ch05.html" title="Chapter 5. Performance tips"><link rel="next" href="ch07.html" title="Chapter 7. Reporting Bugs"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 6. PostGIS Reference</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch05.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch07.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2526096"></a>Chapter 6. PostGIS Reference</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="ch06.html#id2526109">6.1. OpenGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch06.html#id2526115">6.1.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2526205">6.1.2. Geometry Relationship Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2526581">6.1.3. Geometry Processing Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2526907">6.1.4. Geometry Accessors</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2527394">6.1.5. Geometry Constructors</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch06.html#id2527996">6.2. Postgis Extensions</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch06.html#id2528002">6.2.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2528326">6.2.2. Operators</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2528534">6.2.3. Measurement Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2528817">6.2.4. Geometry Outputs</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2528926">6.2.5. Geometry Constructors</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2529258">6.2.6. Geometry Editors</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2529854">6.2.7. Linear Referencing</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2530074">6.2.8. Misc</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2531072">6.2.9. Long Transactions support</a></span></dt></dl></dd></dl></div><p>The functions given below are the ones which a user of PostGIS is
-    likely to need. There are other functions which are required support
-    functions to the PostGIS objects which are not of use to a general
-    user.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2526109"></a>6.1. OpenGIS Functions</h2></div></div><div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2526115"></a>6.1.1. Management Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><a name="AddGeometryColumn"></a><span class="term">AddGeometryColumn(varchar, varchar, varchar, integer,
-            varchar, integer)</span></dt><dd><p>Syntax: AddGeometryColumn(&lt;schema_name&gt;,
-              &lt;table_name&gt;, &lt;column_name&gt;, &lt;srid&gt;,
-              &lt;type&gt;, &lt;dimension&gt;). Adds a geometry column to an
-              existing table of attributes. The <tt class="varname">schema_name</tt>
-              is the name of the table schema (unused for pre-schema
-              PostgreSQL installations). The <tt class="varname">srid</tt> must be
-              an integer value reference to an entry in the SPATIAL_REF_SYS
-              table. The <tt class="varname">type</tt> must be an uppercase string
-              corresponding to the geometry type, eg, 'POLYGON' or
-              'MULTILINESTRING'.</p></dd><dt><span class="term">DropGeometryColumn(varchar, varchar, varchar)</span></dt><dd><p>Syntax: DropGeometryColumn(&lt;schema_name&gt;,
-              &lt;table_name&gt;, &lt;column_name&gt;). Remove a geometry
-              column from a spatial table. Note that schema_name will need to
-              match the f_schema_name field of the table's row in the
-              geometry_columns table.</p></dd><dt><span class="term">SetSRID(geometry, integer)</span></dt><dd><p>Set the SRID on a geometry to a particular integer value.
-              Useful in constructing bounding boxes for queries.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2526205"></a>6.1.2. Geometry Relationship Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">Distance(geometry, geometry)</span></dt><dd><p>Return the cartesian distance between two geometries in
-              projected units.</p></dd><dt><span class="term">Equals(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the given Geometries are
-	      "spatially equal". Use this for a 'better' answer than '='.
-	      equals('LINESTRING(0 0, 10 10)','LINESTRING(0 0, 5 5, 10 10)')
-	      is true.</p><p>Performed by the GEOS module</p><p>OGC SPEC s2.1.1.2</p></dd><dt><span class="term">Disjoint(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries are "spatially disjoint".
-	      </p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 //s2.1.13.3 - a.Relate(b,
-              'FF*FF****')</p></dd><dt><span class="term">Intersects(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially intersect".
-              </p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 //s2.1.13.3 - Intersects(g1, g2 ) --&gt;
-              Not (Disjoint(g1, g2 ))</p></dd><dt><span class="term">Touches(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially touch".
-              </p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3- a.Touches(b) -&gt; (I(a)
-              intersection I(b) = {empty set} ) and (a intersection b) not
-              empty</p></dd><dt><span class="term">Crosses(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially cross".
-              </p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3 - a.Relate(b,
-              'T*T******')</p></dd><dt><span class="term">Within(geometry A, geometry B)</span></dt><dd><p>Returns 1 (TRUE) if Geometry A is "spatially within"
-              Geometry B.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3 - a.Relate(b,
-              'T*F**F***')</p></dd><dt><span class="term">Overlaps(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially
-              overlap".</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3</p></dd><dt><span class="term">Contains(geometry A, geometry B)</span></dt><dd><p>Returns 1 (TRUE) if Geometry A "spatially contains"
-              Geometry B.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3 - same as
-              within(geometry B, geometry A)</p></dd><dt><span class="term">Intersects(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially
-              intersect".</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3 - NOT
-              disjoint(geometry, geometry)</p></dd><dt><span class="term">Relate(geometry, geometry, intersectionPatternMatrix)</span></dt><dd><p>Returns 1 (TRUE) if this Geometry is spatially related to
-              anotherGeometry, by testing for intersections between the
-              Interior, Boundary and Exterior of the two geometries as
-              specified by the values in the intersectionPatternMatrix.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3</p></dd><dt><span class="term">Relate(geometry, geometry)</span></dt><dd><p>returns the DE-9IM (dimensionally extended
-              nine-intersection matrix)</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>not in OGC spec, but implied. see s2.1.13.2</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2526581"></a>6.1.3. Geometry Processing Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">Centroid(geometry)</span></dt><dd><p>Returns the centroid of the geometry as a point.</p><p>Computation will be more accurate if performed by the GEOS
-              module (enabled at compile time).</p></dd><dt><span class="term">Area(geometry)</span></dt><dd><p>Returns the area of the geometry if it is a polygon or
-              multi-polygon. </p></dd><dt><span class="term">Length(geometry)</span></dt><dd><p>The length of this Curve in its associated spatial
-              reference.</p><p>synonym for length2d()</p><p>OGC SPEC 2.1.5.1</p></dd><dt><span class="term">PointOnSurface(geometry)</span></dt><dd><p>Return a Point guaranteed to lie on the surface</p><p>Implemented using GEOS</p><p>OGC SPEC 3.2.14.2 and 3.2.18.2 -</p></dd><dt><span class="term">Boundary(geometry)</span></dt><dd><p>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.</p><p>Performed by the GEOS module</p><p>OGC SPEC s2.1.1.1</p></dd><dt><span class="term">Buffer(geometry, double, [integer])</span></dt><dd><p>Returns a geometry that represents all points whose
-              distance from this Geometry is less than or equal to distance.
-              Calculations are in the Spatial Reference System of this
-              Geometry. The optional third parameter sets the
-	      number of segment used to approximate a quarter circle
-	      (defaults to 8).</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">ConvexHull(geometry)</span></dt><dd><p>Returns a geometry that represents the convex hull of this
-              Geometry.</p><p>Performed by the GEOS module</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">Intersection(geometry, geometry)</span></dt><dd><p>Returns a geometry that represents the point set
-              intersection of the Geometies.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">SymDifference(geometry A, geometry B)</span></dt><dd><p>Returns a geometry that represents the point set symmetric
-              difference of Geometry A with Geometry B.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">Difference(geometry A, geometry B)</span></dt><dd><p>Returns a geometry that represents the point set symmetric
-              difference of Geometry A with Geometry B.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">GeomUnion(geometry, geometry)</span></dt><dd><p>Returns a geometry that represents the point set union of
-              the Geometries.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
-              argument</p><p>NOTE: this is renamed from "union" because union is an SQL
-              reserved word</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">GeomUnion(geometry set)</span></dt><dd><p>Returns a geometry that represents the point set union of
-              this all Geometries in given set.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection in the argument
-              set</p><p>Not explicitly defined in OGC SPEC</p></dd><dt><span class="term">MemGeomUnion(geometry set)</span></dt><dd><p>Same as the above, only memory-friendly (uses less memory
-              and more processor time).</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2526907"></a>6.1.4. Geometry Accessors</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">AsText(geometry)</span></dt><dd><p>Return the Well-Known Text representation of the geometry.
-              For example: POLYGON(0 0,0 1,1 1,1 0,0 0)</p><p>OGC SPEC s2.1.1.1</p></dd><dt><span class="term">AsBinary(geometry)</span></dt><dd><p>Returns the geometry in the OGC "well-known-binary"
-              format, using the endian encoding of the server on which the
-              database is running. This is useful in binary cursors to pull
-              data out of the database without converting it to a string
-              representation.</p><p>OGC SPEC s2.1.1.1 - also see
-              asBinary(&lt;geometry&gt;,'XDR') and
-              asBinary(&lt;geometry&gt;,'NDR')</p></dd><dt><span class="term">SRID(geometry)</span></dt><dd><p>Returns the integer SRID number of the spatial reference
-              system of the geometry.</p><p>OGC SPEC s2.1.1.1</p></dd><dt><span class="term">Dimension(geometry)</span></dt><dd><p>The inherent 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 points, 1 for lines, 2 for polygons,
-              and the largest dimension of the components of a
-              GEOMETRYCOLLECTION.</p><pre class="programlisting">select dimension('GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0 0)'); 
-dimension 
------------
-1</pre></dd><dt><span class="term">Envelope(geometry)</span></dt><dd><p>Returns a POLYGON representing the bounding box of the
-              geometry.</p><p>OGC SPEC s2.1.1.1 - The minimum bounding box for this
-              Geometry, returned as a Geometry. The polygon is defined by the
-              corner points of the bounding box ((MINX, MINY), (MAXX, MINY),
-              (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)).</p><p>NOTE:PostGIS will add a Zmin/Zmax coordinate as
-              well.</p></dd><dt><span class="term">IsEmpty(geometry)</span></dt><dd><p>Returns 1 (TRUE) if this Geometry is the empty geometry .
-              If true, then this Geometry represents the empty point set -
-              i.e. GEOMETRYCOLLECTION(EMPTY).</p><p>OGC SPEC s2.1.1.1</p></dd><dt><a name="IsSimple"></a><span class="term">IsSimple(geometry)</span></dt><dd><p>Returns 1 (TRUE) if this Geometry has no anomalous
-              geometric points, such as self intersection or self
-              tangency.</p><p>Performed by the GEOS module</p><p>OGC SPEC s2.1.1.1</p></dd><dt><a name="IsClosed"></a><span class="term">IsClosed(geometry)</span></dt><dd><p>Returns true of the geometry start and end points are
-              coincident.</p></dd><dt><span class="term">IsRing(geometry)</span></dt><dd><p>Returns 1 (TRUE) if this Curve is closed (StartPoint ( ) =
-              EndPoint ( )) and this Curve is simple (does not pass through
-              the same point more than once).</p><p>performed by GEOS</p><p>OGC spec 2.1.5.1</p></dd><dt><span class="term">NumGeometries(geometry)</span></dt><dd><p>If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the
-              number of geometries, otherwise return NULL.</p></dd><dt><span class="term">GeometryN(geometry,int)</span></dt><dd><p>Return the N'th geometry if the geometry is a
-              GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING or MULTIPOLYGON.
-              Otherwise, return NULL.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-		Index is 1-based as for OGC specs since version 0.8.0.
-		Previous versions implemented this as 0-based instead.
-		</p></div></dd><dt><span class="term">NumPoints(geometry)</span></dt><dd><p>Find and return the number of points in the first
-              linestring in the geometry. Return NULL if there is no
-              linestring in the geometry.</p></dd><dt><span class="term">PointN(geometry,integer)</span></dt><dd><p>Return the N'th point in the first linestring in the
-              geometry. Return NULL if there is no linestring in the
-              geometry.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-		Index is 1-based as for OGC specs since version 0.8.0.
-		Previous versions implemented this as 0-based instead.
-		</p></div></dd><dt><span class="term">ExteriorRing(geometry)</span></dt><dd><p>Return the exterior ring of the polygon geometry.
-	      Return NULL if the geometry is not a polygon.</p></dd><dt><span class="term">NumInteriorRings(geometry)</span></dt><dd><p>Return the number of interior rings of the first polygon
-              in the geometry. Return NULL if there is no polygon in the
-              geometry.</p></dd><dt><span class="term">NumInteriorRing(geometry)</span></dt><dd><p>Synonym to NumInteriorRings(geometry). The OpenGIS specs
-	      are ambigous about the exact function naming, so we provide
-	      both spellings.</p></dd><dt><span class="term">InteriorRingN(geometry,integer)</span></dt><dd><p>Return the N'th interior ring of the polygon geometry.
-	      Return NULL if the geometry is not a polygon or the given
-	      N is out of range.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-		Index is 1-based as for OGC specs since version 0.8.0.
-		Previous versions implemented this as 0-based instead.
-		</p></div></dd><dt><span class="term">EndPoint(geometry)</span></dt><dd><p>Returns the last point of the LineString geometry as a point.</p></dd><dt><a name="StartPoint"></a><span class="term">StartPoint(geometry)</span></dt><dd><p>Returns the first point of the LineString geometry as a point.</p></dd><dt><a name="GeometryType"></a><span class="term">GeometryType(geometry)</span></dt><dd><p>Returns the type of the geometry as a string. Eg:
-              'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.</p><p>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.</p></dd><dt><span class="term">X(geometry)</span></dt><dd><p>Return the X coordinate of the point.
-	      Input must be a point.</p></dd><dt><span class="term">Y(geometry)</span></dt><dd><p>Return the Y coordinate of the point.
-	      Input must be a point.</p></dd><dt><span class="term">Z(geometry)</span></dt><dd><p>Return the Z coordinate of the point,
-	      or NULL if not available.
-	      Input must be a point.</p></dd><dt><span class="term">M(geometry)</span></dt><dd><p>Return the M coordinate of the point, 
-	      or NULL if not available.
-	      Input must be a point.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This is not (yet) part of the OGC spec,
-		but is listed here to complete the point coordinate
-	        extractor function list.</p></div></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2527394"></a>6.1.5. Geometry Constructors</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">GeomFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
-              suite</p></dd><dt><span class="term">PointFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
-              suite</p><p>Throws an error if the WKT is not a Point</p></dd><dt><span class="term">LineFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
-              suite</p><p>Throws an error if the WKT is not a Line</p></dd><dt><span class="term">LinestringFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>from the conformance suite</p><p>Throws an error if the WKT is not a Line</p></dd><dt><span class="term">PolyFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
-              suite</p><p>Throws an error if the WKT is not a Polygon</p></dd><dt><span class="term">PolygonFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>from the conformance suite</p><p>Throws an error if the WKT is not a Polygon</p></dd><dt><span class="term">MPointFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
-              suite</p><p>Throws an error if the WKT is not a MULTIPOINT</p></dd><dt><span class="term">MLineFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
-              suite</p><p>Throws an error if the WKT is not a MULTILINESTRING</p></dd><dt><span class="term">MPolyFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
-              suite</p><p>Throws an error if the WKT is not a MULTIPOLYGON</p></dd><dt><span class="term">GeomCollFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
-              suite</p><p>Throws an error if the WKT is not a
-              GEOMETRYCOLLECTION</p></dd><dt><span class="term">GeomFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
-              suite</p></dd><dt><span class="term">GeomFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
-              suite</p></dd><dt><span class="term">PointFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
-              suite</p><p>throws an error if WKB is not a POINT</p></dd><dt><span class="term">LineFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
-              suite</p><p>throws an error if WKB is not a LINESTRING</p></dd><dt><span class="term">LinestringFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>from the conformance suite</p><p>throws an error if WKB is not a LINESTRING</p></dd><dt><span class="term">PolyFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
-              suite</p><p>throws an error if WKB is not a POLYGON</p></dd><dt><span class="term">PolygonFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>from the conformance suite</p><p>throws an error if WKB is not a POLYGON</p></dd><dt><span class="term">MPointFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
-              suite</p><p>throws an error if WKB is not a MULTIPOINT</p></dd><dt><span class="term">MLineFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
-              suite</p><p>throws an error if WKB is not a MULTILINESTRING</p></dd><dt><span class="term">MPolyFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
-              suite</p><p>throws an error if WKB is not a MULTIPOLYGON</p></dd><dt><span class="term">GeomCollFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
-              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
-              suite</p><p>throws an error if WKB is not a GEOMETRYCOLLECTION</p></dd><dt><a name="BdPolyFromText"></a><span class="term">BdPolyFromText(text WKT, integer SRID)</span></dt><dd><p>
-		Construct a Polygon given an arbitrary
-		collection of closed linestrings as a
-		MultiLineString text representation.
-		</p><p>
-	      Throws an error if WKT is not a MULTILINESTRING.
-	      Throws an error if output is a MULTIPOLYGON; use <a href="ch06.html#BdMPolyFromText">BdMPolyFromText</a> in
-	      that case, or see 
-		<a href="ch06.html#BuildArea">BuildArea()</a>
-		for a postgis-specific approach.
-		</p><p>OGC SFSQL 1.1 - 3.2.6.2</p><p>
-		    Availability: 1.1.0 - requires GEOS &gt;= 2.1.0.
-		</p></dd><dt><a name="BdMPolyFromText"></a><span class="term">BdMPolyFromText(text WKT, integer SRID)</span></dt><dd><p>
-		Construct a MultiPolygon given an arbitrary
-		collection of closed linestrings as a
-		MultiLineString text representation.
-		</p><p>
-                Throws an error if WKT is not a MULTILINESTRING.
-		Forces MULTIPOLYGON output even when result is really
-		only composed by a single POLYGON; use <a href="ch06.html#BdPolyFromText">BdPolyFromText</a> if you're sure
-		a single POLYGON will result from
-		operation, or see
-		<a href="ch06.html#BuildArea">BuildArea()</a>
-		for a postgis-specific approach.
-		</p><p>OGC SFSQL 1.1 - 3.2.6.2</p><p>
-		    Availability: 1.1.0 - requires GEOS &gt;= 2.1.0.
-		</p></dd></dl></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2527996"></a>6.2. Postgis Extensions</h2></div></div><div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2528002"></a>6.2.1. Management Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">DropGeometryTable([&lt;schema_name&gt;],
-		  &lt;table_name&gt;)</span></dt><dd><p>Drops a table and all its references in geometry_columns.
-		    Note: uses current_schema() on schema-aware pgsql installations if
-		    schema is not provided.</p></dd><dt><span class="term">UpdateGeometrySRID([&lt;schema_name&gt;],
-		  &lt;table_name&gt;, &lt;column_name&gt;, &lt;srid&gt;)</span></dt><dd><p>Update the SRID of all features in a geometry column updating constraints and reference in geometry_columns.
-		    Note: uses current_schema() on schema-aware pgsql installations if schema is not provided.</p></dd><dt><span class="term">update_geometry_stats([&lt;table_name&gt;,
-		  &lt;column_name&gt;])</span></dt><dd><p>Update statistics about spatial tables for use by the query
-		    planner. You will also need to run "VACUUM ANALYZE [table_name]
-		    [column_name]" for the statistics gathering process to be
-		    complete. NOTE: starting with PostgreSQL 8.0 statistics gathering
-		    is automatically performed running "VACUUM ANALYZE".</p></dd><dt><span class="term">postgis_version()</span></dt><dd><p>Returns PostGIS version number and compile-time options</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-		Prior to version 1.1.0 this was a procedural function, thus possibly
-		returning inaccurate information (in case of incomplete database upgrades).
-		</p></div></dd><dt><a name="postgis_lib_version"></a><span class="term">postgis_lib_version()</span></dt><dd><p>Returns the version number of the PostGIS library.</p><p>
-	Availability: 0.9.0
-		</p></dd><dt><span class="term">postgis_lib_build_date()</span></dt><dd><p>Returns build date of the PostGIS library.</p><p>
-	Availability: 1.0.0RC1
-		</p></dd><dt><span class="term">postgis_script_build_date()</span></dt><dd><p>Returns build date of the PostGIS scripts.</p><p>
-	Availability: 1.0.0RC1
-		</p></dd><dt><span class="term">postgis_scripts_installed()</span></dt><dd><p>
-		Returns version of the postgis scripts
-		installed in this database.
-		</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-		If the output of this function doesn't match the output of
-		<a href="ch06.html#postgis_scripts_released">postgis_scripts_released()</a>
-		you probably missed to properly upgrade an existing database.
-		See the <a href="ch02.html#upgrading" title="2.2.1. Upgrading">Upgrading</a> section for more info.
-		</p></div><p>
-	Availability: 0.9.0
-		</p></dd><dt><a name="postgis_scripts_released"></a><span class="term">postgis_scripts_released()</span></dt><dd><p>Returns the version number of the lwpostgis.sql script
-            released with the installed postgis lib.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-		Starting with version 1.1.0 this function returns the same
-		value of <a href="ch06.html#postgis_lib_version">postgis_lib_version()</a>.
-		Kept for backward compatibility.
-		</p></div><p>
-	Availability: 0.9.0 
-		</p></dd><dt><span class="term">postgis_geos_version()</span></dt><dd><p>Returns the version number of the GEOS library, or NULL if
-            GEOS support is not enabled.</p><p>
-	Availability: 0.9.0
-		</p></dd><dt><span class="term">postgis_jts_version()</span></dt><dd><p>Returns the version number of the JTS library, or NULL if
-            JTS support is not enabled.</p><p>
-	Availability: 1.1.0
-		</p></dd><dt><span class="term">postgis_proj_version()</span></dt><dd><p>Returns the version number of the PROJ4 library, or NULL if
-            PROJ4 support is not enabled.</p><p>
-	Availability: 0.9.0
-		</p></dd><dt><span class="term">postgis_uses_stats()</span></dt><dd><p>Returns true if STATS usage has been enabled, false
-            otherwise.</p><p>
-	Availability: 0.9.0
-		</p></dd><dt><a name="postgis_full_version"></a><span class="term">postgis_full_version()</span></dt><dd><p>Reports full postgis version and build configuration
-            infos.</p><p>Availability: 0.9.0</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2528326"></a>6.2.2. Operators</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">A &amp;&lt; B</span></dt><dd><p>The "&amp;&lt;" operator returns true if A's bounding box
-		    overlaps or is to the left of B's bounding box.</p></dd><dt><span class="term">A &amp;&gt; B</span></dt><dd><p>The "&amp;&gt;" operator returns true if A's bounding box
-		    overlaps or is to the right of B's bounding box.</p></dd><dt><span class="term">A &lt;&lt; B</span></dt><dd><p>The "&lt;&lt;" operator returns true if A's bounding box is
-		    strictly to the left of B's bounding box.</p></dd><dt><span class="term">A &gt;&gt; B</span></dt><dd><p>The "&gt;&gt;" operator returns true if A's bounding box is
-		    strictly to the right of B's bounding box.</p></dd><dt><span class="term">A &amp;&lt;| B</span></dt><dd><p>The "&amp;&lt;|" operator returns true if A's bounding box
-		    overlaps or is below B's bounding box.</p></dd><dt><span class="term">A |&amp;&gt; B</span></dt><dd><p>The "|&amp;&gt;" operator returns true if A's bounding box
-		    overlaps or is above B's bounding box.</p></dd><dt><span class="term">A &lt;&lt;| B</span></dt><dd><p>The "&lt;&lt;|" operator returns true if A's bounding box is
-		    strictly below B's bounding box.</p></dd><dt><span class="term">A |&gt;&gt; B</span></dt><dd><p>The "|&gt;&gt;" operator returns true if A's bounding box is
-		    strictly above B's bounding box.</p></dd><dt><span class="term">A ~= B</span></dt><dd><p>The "~=" operator is the "same as" operator. It tests actual
-		    geometric equality of two features. So if A and B are the same
-		    feature, vertex-by-vertex, the operator returns true.</p></dd><dt><span class="term">A @ B</span></dt><dd><p>The "@" operator returns true if A's bounding box is
-		    completely contained by B's bounding box.</p></dd><dt><span class="term">A ~ B</span></dt><dd><p>The "~" operator returns true if A's bounding box completely
-		    contains B's bounding box.</p></dd><dt><span class="term">A &amp;&amp; B</span></dt><dd><p>The "&amp;&amp;" operator is the "overlaps" operator. If A's
-		    bounding boux overlaps B's bounding box the operator returns
-		    true.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2528534"></a>6.2.3. Measurement Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">area2d(geometry)</span></dt><dd><p>Returns the area of the geometry if it is a polygon or
-		    multi-polygon.</p></dd><dt><span class="term">distance_sphere(point, point)</span></dt><dd><p>Returns linear distance in meters between two lat/lon
-            points. Uses a spherical earth and radius of 6370986 meters.
-            Faster than <a href="ch06.html#distance_spheroid">distance_spheroid()</a>, but
-            less accurate.
-			Only implemented for points.</p></dd><dt><a name="distance_spheroid"></a><span class="term">distance_spheroid(point, point, spheroid)</span></dt><dd><p>Returns linear distance between two lat/lon points given a
-            particular spheroid. See the explanation of spheroids given for
-            <a href="ch06.html#length_spheroid">length_spheroid()</a>.
-            Currently only implemented for points.</p></dd><dt><a name="length2d"></a><span class="term">length2d(geometry)</span></dt><dd><p>Returns the 2-dimensional length of the geometry if it is a
-            linestring or multi-linestring.</p></dd><dt><span class="term">length3d(geometry)</span></dt><dd><p>Returns the 3-dimensional length of the geometry if it is a
-            linestring or multi-linestring.</p></dd><dt><a name="length_spheroid"></a><span class="term">length_spheroid(geometry,spheroid)</span></dt><dd><p>Calculates the length of of a geometry on an elipsoid. This
-            is useful if the coordinates of the geometry are in
-            latitude/longitude and a length is desired without reprojection.
-            The elipsoid is a separate database type and can be constructed as
-            follows:</p><div class="literallayout"><p>SPHEROID[&lt;NAME&gt;,&lt;SEMI-MAJOR AXIS&gt;,&lt;INVERSE FLATTENING&gt;]</p></div><p>Eg:</p><div class="literallayout"><p>SPHEROID["GRS_1980",6378137,298.257222101]</p></div><p>An example calculation might look like this:</p><div class="literallayout"><p>SELECT<br>
- length_spheroid(<br>
-  geometry_column,<br>
-  'SPHEROID["GRS_1980",6378137,298.257222101]'<br>
- )<br>
-FROM geometry_table;</p></div></dd><dt><span class="term">length3d_spheroid(geometry,spheroid)</span></dt><dd><p>Calculates the length of of a geometry on an elipsoid,
-            taking the elevation into account. This is just like
-            length_spheroid except vertical coordinates (expressed in the same
-            units as the spheroid axes) are used to calculate the extra
-            distance vertical displacement adds.</p></dd><dt><span class="term">distance(geometry, geometry)</span></dt><dd><p>Returns the smaller distance between two geometries.</p></dd><dt><span class="term">max_distance(linestring,linestring)</span></dt><dd><p>Returns the largest distance between two line
-            strings.</p></dd><dt><span class="term">perimeter(geometry)</span></dt><dd><p>Returns the 2-dimensional perimeter of the geometry, if it
-            is a polygon or multi-polygon.</p></dd><dt><span class="term">perimeter2d(geometry)</span></dt><dd><p>Returns the 2-dimensional perimeter of the geometry, if it
-            is a polygon or multi-polygon.</p></dd><dt><span class="term">perimeter3d(geometry)</span></dt><dd><p>Returns the 3-dimensional perimeter of the geometry, if it
-            is a polygon or multi-polygon.</p></dd><dt><span class="term">azimuth(geometry, geometry)</span></dt><dd><p>
-	Returns the azimuth of the segment defined by the given Point
-	geometries, or NULL if the two points are coincident.
-	Return value is in radians.
-            </p><p>
-			Availability: 1.1.0
-		</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2528817"></a>6.2.4. Geometry Outputs</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">AsBinary(geometry,{'NDR'|'XDR'})</span></dt><dd><p>Returns the geometry in the OGC "well-known-binary" format as a bytea, using little-endian (NDR) or big-endian (XDR) encoding. This is useful in binary cursors to pull data out of the database without converting it to a string representation.</p></dd><dt><span class="term">AsEWKT(geometry)</span></dt><dd><p>Returns a Geometry in EWKT format (as text).</p></dd><dt><span class="term">AsEWKB(geometry, {'NDR'|'XDR'})</span></dt><dd><p>Returns a Geometry in EWKB format (as bytea) using either little-endian (NDR) or big-endian (XDR) encoding.</p></dd><dt><span class="term">AsHEXEWKB(geometry, {'NDR'|'XDR'})</span></dt><dd><p>Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding.</p></dd><dt><span class="term">AsSVG(geometry, [rel], [precision])</span></dt><dd><p>Return the geometry as an SVG path data. Use 1 as second argument to have the path data implemented in terms of relative moves, the default (or 0) uses absolute moves. Third argument may be used to reduce the maximum number of decimal digits used in output (defaults to 15). Point geometries will be rendered as cx/cy when 'rel' arg is 0, x/y when 'rel' is 1.</p></dd><dt><span class="term">AsGML(geometry, [precision])</span></dt><dd><p>Return the geometry as a GML element.  Second argument may be used to reduce the maximum number of significant digits used in output (defaults to 15).</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2528926"></a>6.2.5. Geometry Constructors</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">GeomFromEWKT(text)</span></dt><dd><p>Makes a Geometry from EWKT.</p></dd><dt><span class="term">GeomFromEWKB(bytea)</span></dt><dd><p>Makes a Geometry from EWKB.</p></dd><dt><span class="term">MakePoint(&lt;x&gt;, &lt;y&gt;, [&lt;z&gt;], [&lt;m&gt;])</span></dt><dd><p>Creates a 2d,3dz or 4d point geometry.</p></dd><dt><span class="term">MakePointM(&lt;x&gt;, &lt;y&gt;, &lt;m&gt;)</span></dt><dd><p>Creates a 3dm point geometry.</p></dd><dt><span class="term">MakeBox2D(&lt;LL&gt;, &lt;UR&gt;)</span></dt><dd><p>Creates a BOX2D defined by the given point geometries.</p></dd><dt><span class="term">MakeBox3D(&lt;LLB&gt;, &lt;URT&gt;)</span></dt><dd><p>Creates a BOX3D defined by the given point geometries.</p></dd><dt><span class="term">MakeLine(geometry set)</span></dt><dd><p>Creates a Linestring from a set of point geometries.
-		    You might want to use a subselect to order points before
-		    feeding them to this aggregate.</p></dd><dt><span class="term">MakeLine(geometry, geometry)</span></dt><dd><p>Creates a Linestring from the two given point
-		    geometries.</p></dd><dt><span class="term">LineFromMultiPoint(multipoint)</span></dt><dd><p>Creates a LineString from a MultiPoint geometry.</p></dd><dt><span class="term">MakePolygon(linestring, [linestring[]])</span></dt><dd><p>Creates a Polygon formed by the given 
-		    shell and array of holes. You can construct
-		    a geometry array using <a href="ch06.html#Accum">Accum</a>.
-		    Input geometries must be closed LINESTRINGS (see <a href="ch06.html#IsClosed">IsClosed</a> and <a href="ch06.html#GeometryType">GeometryType</a>).
-		    </p></dd><dt><a name="BuildArea"></a><span class="term">BuildArea(geometry)</span></dt><dd><p>Creates an areal geometry formed by the costituent
-		    linework of given geometry. The return type can
-		    be a Polygon or MultiPolygon, depending on input.
-		    If the input lineworks do not form polygons NULL is
-		    returned.
-		    </p><p>
-		    See also <a href="ch06.html#BdPolyFromText">BdPolyFromText</a> and <a href="ch06.html#BdMPolyFromText">BdMPolyFromText</a> - wrappers to this function with standard OGC interface.
-		    </p><p>
-		    Availability: 1.1.0 - requires GEOS &gt;= 2.1.0.
-		</p></dd><dt><span class="term">Polygonize(geometry set)</span></dt><dd><p>
-			Aggregate. Creates a GeometryCollection containing
-			possible polygons formed from the costituent linework
-			of a set of geometries.
-		</p><p>
-		    Availability: 1.0.0RC1 - requires GEOS &gt;= 2.1.0.
-		</p></dd><dt><span class="term">Collect(geometry set)</span></dt><dd><p>This function returns a GEOMETRYCOLLECTION or a MULTI object from a set
-		    of geometries. The collect() function is an "aggregate" function
-		    in the terminology of PostgreSQL. That means that it operators on
-		    lists of data, in the same way the sum() and mean() functions do.
-		    For example, "SELECT COLLECT(GEOM) FROM GEOMTABLE GROUP BY
-		    ATTRCOLUMN" will return a separate GEOMETRYCOLLECTION for each
-		    distinct value of ATTRCOLUMN.</p></dd><dt><span class="term">Collect(geometry, geometry)</span></dt><dd><p>This function returns a geometry being a collection
-		    of two input geometries. Output type can be a MULTI* or 
-		    a GEOMETRYCOLLECTION.</p></dd><dt><span class="term">Dump(geometry)</span></dt><dd><p>This is a set-returning function (SRF).
-		    It returns a set of geometry_dump rows, formed
-		    by a geometry (geom) and an array of integers (path).
-		    When the input geometry is a simple type
-		    (POINT,LINESTRING,POLYGON)
-		    a single record will be returned with an empty
-		    path array and the input geometry as geom.
-		    When the input geometry is a collection or multi
-		    it will return a record for each of the collection
-		    components, and the path will express the position
-		    of the component inside the collection.
-		    </p><p>
-		    Availability: PostGIS 1.0.0RC1.
-		    Requires PostgreSQL 7.3 or higher.
-		</p></dd><dt><span class="term">DumpRings(geometry)</span></dt><dd><p>This is a set-returning function (SRF).
-		    It returns a set of geometry_dump rows, formed
-		    by a geometry (geom) and an array of integers (path).
-		    The 'path' field holds the polygon ring index, contains
-		    a single element: 0 for the shell, hole number for holes.
-		    The 'geom' field contains the corresponding ring
-		    as a polygon.
-		    </p><p>
-		    Availability: PostGIS 1.1.3.
-		    Requires PostgreSQL 7.3 or higher.
-		</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2529258"></a>6.2.6. Geometry Editors</h3></div></div><div></div></div><div class="variablelist"><dl><dt><a name="addbbox"></a><span class="term">AddBBOX(geometry)</span></dt><dd><p>Add bounding box to the geometry. This would make bounding
-	    box based queries faster, but will increase the size of the
-	    geometry.</p></dd><dt><a name="dropbbox"></a><span class="term">DropBBOX(geometry)</span></dt><dd><p>Drop the bounding box cache from the geometry.
-	    This reduces geometry size, but makes bounding-box based
-	    queries slower.</p></dd><dt><span class="term">AddPoint(linestring, point, [&lt;position&gt;])</span></dt><dd><p>Adds a point to a LineString before point &lt;pos&gt;
-	    (0-based index).
-	    Third parameter can be omitted or set to -1 for appending.
-	    </p></dd><dt><span class="term">RemovePoint(linestring, offset)</span></dt><dd><p>
-			Removes point from a linestring. Offset is 0-based.
-		</p><p>
-			Availability: 1.1.0
-		</p></dd><dt><span class="term">SetPoint(linestring, N, point)</span></dt><dd><p>
-			Replace point N of linestring with given point.
-			Index is 0-based.
-		</p><p>
-			Availability: 1.1.0
-		</p></dd><dt><span class="term">Force_collection(geometry)</span></dt><dd><p>Converts the geometry into a GEOMETRYCOLLECTION. This is
-            useful for simplifying the WKB representation.</p></dd><dt><a name="force_2d"></a><span class="term">Force_2d(geometry)</span></dt><dd><p>Forces the geometries into a "2-dimensional mode" so that
-            all output representations will only have the X and Y coordinates.
-            This is useful for force OGC-compliant output (since OGC only
-            specifies 2-D geometries).</p></dd><dt><a name="force_3dz"></a><span class="term">Force_3dz(geometry), </span><span class="term">Force_3d(geometry), </span></dt><dd><p>Forces the geometries into XYZ mode.</p></dd><dt><a name="force_3dm"></a><span class="term">Force_3dm(geometry)</span></dt><dd><p>Forces the geometries into XYM mode.</p></dd><dt><a name="force_4d"></a><span class="term">Force_4d(geometry)</span></dt><dd><p>Forces the geometries into XYZM mode.</p></dd><dt><span class="term">Multi(geometry)</span></dt><dd><p>Returns the geometry as a MULTI* geometry. If the geometry
-            is already a MULTI*, it is returned unchanged.</p></dd><dt><span class="term">Transform(geometry,integer)</span></dt><dd><p>Returns a new geometry with its coordinates transformed to
-            the SRID referenced by the integer parameter. The destination SRID
-            must exist in the <tt class="varname">SPATIAL_REF_SYS</tt> table.</p></dd><dt><span class="term">Affine(geometry,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8)</span></dt><dd><p>Applies an 3d affine transformation to the geometry. The call 
-                </p><pre class="programlisting">
-                    Affine(geom, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff)
-                </pre><p>
-                represents the transformation matrix
-                </p><pre class="programlisting">
-                    /  a  b  c  xoff  \
-                    |  d  e  f  yoff  |
-                    |  g  h  i  zoff  |
-                    \  0  0  0  1     /
-                </pre><p>
-                and the vertices are transformed as follows:
-                </p><pre class="programlisting">
-                    x' = a*x + b*y + c*z + xoff
-                    y' = d*x + e*y + f*z + yoff
-                    z' = g*x + h*y + i*z + zoff   
-                </pre><p>
-                All of the translate / scale functions below are expressed via such an affine transformation.
-            </p><p>
-                Availability: 1.1.2.
-            </p></dd><dt><span class="term">Affine(geometry,float8,float8,float8,float8,float8,float8)</span></dt><dd><p>Applies an 2d affine transformation to the geometry. The call 
-                </p><pre class="programlisting">
-                    Affine(geom, a, b, d, e, xoff, yoff)
-                </pre><p>
-                represents the transformation matrix
-                </p><pre class="programlisting">
-                    /  a  b  0  xoff  \        /  a  b  xoff  \
-                    |  d  e  0  yoff  |  rsp.  |  d  e  yoff  |
-                    |  0  0  1  0     |        \  0  0  1     /
-                    \  0  0  0  1     /
-                </pre><p>
-                and the vertices are transformed as follows:
-                </p><pre class="programlisting">
-                    x' = a*x + b*y + xoff
-                    y' = d*x + e*y + yoff
-                    z' = z   
-                </pre><p>
-                This method is a subcase of the 3D method above.
-            </p><p>
-		Availability: 1.1.2.
-            </p></dd><dt><span class="term">Translate(geometry,float8,float8,float8)</span></dt><dd><p>Translates the geometry to a new location using the numeric
-            parameters as offsets. Ie: translate(geom, X, Y, Z).</p></dd><dt><span class="term">Scale(geometry,float8,float8,float8)</span></dt><dd><p>scales the geometry to a new size by multiplying the
-            ordinates with the parameters. Ie: scale(geom, Xfactor, Yfactor, Zfactor).</p><p>
-			Availability: 1.1.0
-		</p></dd><dt><a name="Rotate"></a><span class="term">RotateZ(geometry,float8), </span><span class="term">RotateX(geometry,float8), </span><span class="term">RotateY(geometry,float8), </span></dt><dd><p>
-			Rotate the geometry around the Z, X or Y axis by
-			the given angle given in radians. Follows the
-			right-hand rule. This is the same in
-			PostScript but opposite of SVG.
-		</p><p>
-			Availability: 1.1.2.
-		</p></dd><dt><span class="term">TransScale(geometry,float8,float8,float8,float8)</span></dt><dd><p>First, translates the geometry using the first two floats, then scales it
-                    using the second two floats, working in 2D only. Using
-                    <tt class="code">transscale(geom, X, Y, XFactor, YFactor)</tt> internally calls
-                    <tt class="code">affine(geom, XFactor, 0, 0,  0, YFactor, 0,  0, 0, 1,  X*XFactor, Y*YFactor, 0)</tt>.                
-                </p><p>
-                        Availability: 1.1.0.
-                </p></dd><dt><span class="term">Reverse(geometry)</span></dt><dd><p>Returns the geometry with vertex order reversed.</p></dd><dt><span class="term">ForceRHR(geometry)</span></dt><dd><p>Force polygons of the collection to obey Right-Hand-Rule.</p></dd><dt><span class="term">Simplify(geometry, tolerance)</span></dt><dd><p>Returns a "simplified" version of the given geometry using
-            the Douglas-Peuker algorithm. Will actually do something only with
-            (multi)lines and (multi)polygons but you can safely call it with
-            any kind of geometry. Since simplification occurs on a
-            object-by-object basis you can also feed a GeometryCollection to
-            this function. Note that returned geometry might loose its
-            simplicity (see <a href="ch06.html#IsSimple">IsSimple</a>)</p></dd><dt><span class="term">SnapToGrid(geometry, originX, originY, sizeX, sizeY), </span><span class="term">SnapToGrid(geometry, sizeX, sizeY), </span><span class="term">SnapToGrid(geometry, size), </span></dt><dd><p>Snap all points of the input geometry to the grid
-	    defined by its origin and cell size.
-            Remove consecutive points falling on the same cell,
-	    eventually returning NULL if output points are not
-	    enough to define a geometry of the given type.
-	    Collapsed geometries in a collection are stripped
-	    from it.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-            The returned geometry might loose its
-            simplicity (see <a href="ch06.html#IsSimple">IsSimple</a>).
-	</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-            Before release 1.1.0 this function always returned
-	    a 2d geometry. Starting at 1.1.0 the returned geometry
-	    will have same dimensionality as the input one with higher
-	    dimension values untouched. Use the version taking a second
-	    geometry argument to define all grid dimensions.
-	</p></div><p>
-			Availability: 1.0.0RC1
-		</p></dd><dt><span class="term">SnapToGrid(geometry, geometry, sizeX, sizeY, sizeZ, sizeM)</span></dt><dd><p>
-	    Snap all points of the input geometry to the grid
-	    defined by its origin (the second argument, must be a point)
-	    and cell sizes. Specify 0 as size for any dimension you don't
-	    want to snap to a grid.
-	    </p><p>
-			Availability: 1.1.0
-		</p></dd><dt><span class="term">Segmentize(geometry, maxlength)</span></dt><dd><p>Return a modified geometry having no segment
-            longer then the given distance. Interpolated points will have Z
-            and M values (if needed) set to 0. Distance computation is
-            performed in 2d only.</p></dd><dt><span class="term">LineMerge(geometry)</span></dt><dd><p>
-			Returns a (set of) LineString(s) formed by sewing
-			togheter costituent linework of input.
-		</p><p>
-			Availability: 1.1.0 - requires GEOS &gt;= 2.1.0
-		</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2529854"></a>6.2.7. Linear Referencing</h3></div></div><div></div></div><div class="variablelist"><dl><dt><a name="line_interpolate_point"></a><span class="term">line_interpolate_point(linestring, location)</span></dt><dd><p>
-		Returns a poin interpolated along a line.
-		First argument must be a LINESTRING.
-		Second argument is a float8 between 0 and 1
-		representing fraction of total
-		<a href="ch06.html#length2d">2d length</a> the point has
-		to be located.
-		</p><p>
-		See <a href="ch06.html#line_locate_point">line_locate_point()</a>
-		for computing the line location nearest to a Point.
-		</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-            Since release 1.1.1 this function also interpolates
-	    M and Z values (when present), while prior releases
-	    set them to 0.0.
-	</p></div><p>
-			Availability: 0.8.2
-		</p></dd><dt><a name="line_substring"></a><span class="term">line_substring(linestring, start, end)</span></dt><dd><p>
-		Return a linestring being a substring of the input one starting
-		and ending at the given fractions of total 2d length. Second
-		and third arguments are float8 values between 0 and 1.
-		</p><p>
-		If 'start' and 'end' have the same value this is equivalent 
-		to <a href="ch06.html#line_interpolate_point">line_interpolate_point()</a>.
-		</p><p>
-		See <a href="ch06.html#line_locate_point">line_locate_point()</a>
-		for computing the line location nearest to a Point.
-		</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-            Since release 1.1.1 this function also interpolates
-	    M and Z values (when present), while prior releases
-	    set them to unspecified values.
-	</p></div><p>
-			Availability: 1.1.0
-		</p></dd><dt><a name="line_locate_point"></a><span class="term">line_locate_point(LineString, Point)</span></dt><dd><p>
-		Returns a float between 0 and 1 representing 
-		the location of the closest point on LineString
-		to the given Point, as a fraction of
-		total <a href="ch06.html#length2d">2d line</a> length.
-		</p><p>
-	You can use the returned location to extract a Point (<a href="ch06.html#line_interpolate_point">line_interpolate_point</a>) or a substring (<a href="ch06.html#line_substring">line_substring</a>).
-		</p><p>
-			Availability: 1.1.0
-		</p></dd><dt><span class="term">locate_along_measure(geometry, float8)</span></dt><dd><p>
-		Return a derived geometry collection value with elements that
-		match the specified measure.
-		Polygonal elements are not supported.
-		</p><p>
-		Semantic is specified by: ISO/IEC CD 13249-3:200x(E) -
-		Text for Continuation CD Editing Meeting
-		</p><p>
-			Availability: 1.1.0
-		</p></dd><dt><span class="term">locate_between_measures(geometry, float8, float8)</span></dt><dd><p>
-		Return a derived geometry collection value with elements that
-		match the specified range of measures inclusively.
-		Polygonal elements are not supported. 
-		</p><p>
-		Semantic is specified by: ISO/IEC CD 13249-3:200x(E) -
-		Text for Continuation CD Editing Meeting
-		</p><p>
-			Availability: 1.1.0
-		</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2530074"></a>6.2.8. Misc</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">Summary(geometry)</span></dt><dd><p>Returns a text summary of the contents of the geometry.</p></dd><dt><span class="term">box2d(geometry)</span></dt><dd><p>Returns a BOX2D representing the maximum extents of the geometry.</p></dd><dt><span class="term">box3d(geometry)</span></dt><dd><p>Returns a BOX3D representing the maximum extents of the geometry.</p></dd><dt><span class="term">extent(geometry set)</span></dt><dd><p>The extent() function is an "aggregate" function in the terminology of PostgreSQL. That means that it operators on lists of data, in the same way the sum() and mean() functions do. For example, "SELECT EXTENT(GEOM) FROM GEOMTABLE" will return a BOX3D giving the maximum extend of all features in the table. Similarly, "SELECT EXTENT(GEOM) FROM GEOMTABLE GROUP BY CATEGORY" will return one extent result for each category.</p></dd><dt><a name="zmflag"></a><span class="term">zmflag(geometry)</span></dt><dd><p>Returns ZM (dimension semantic) flag of the geometries as a small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.  </p></dd><dt><a name="hasbbox"></a><span class="term">HasBBOX(geometry)</span></dt><dd><p>Returns TRUE if the bbox of this geometry is cached, FALSE otherwise. Use <a href="ch06.html#addbbox">addBBOX()</a> and <a href="ch06.html#dropbbox">dropBBOX()</a> to control caching.</p></dd><dt><a name="ndims"></a><span class="term">ndims(geometry)</span></dt><dd><p>Returns number of dimensions of the geometry as a small int. Values are: 2,3 or 4.</p></dd><dt><span class="term">nrings(geometry)</span></dt><dd><p>If the geometry is a polygon or multi-polygon returns the number of rings.</p></dd><dt><span class="term">npoints(geometry)</span></dt><dd><p>Returns the number of points in the geometry.</p></dd><dt><a name="IsValid"></a><span class="term">isvalid(geometry)</span></dt><dd><p>returns true if this geometry is valid.</p></dd><dt><span class="term">expand(geometry, float)</span></dt><dd><p>This function returns a bounding box expanded in all
-		    directions from the bounding box of the input geometry, by an
-		    amount specified in the second argument. Very useful for
-		    distance() queries, to add an index filter to the query.</p></dd><dt><span class="term">estimated_extent([schema], table, geocolumn)</span></dt><dd><p> Return the 'estimated' extent of the given spatial table.  The estimated is taken from the geometry column's statistics. The current schema will be used if not specified.</p><p>For PostgreSQL&gt;=8.0.0 statistics are gathered by VACUUM ANALYZE and resulting extent will be about 95% of the real one.</p><p>For PostgreSQL&lt;8.0.0 statistics are gathered by update_geometry_stats() and resulting extent will be exact.</p></dd><dt><span class="term">find_srid(varchar,varchar,varchar)</span></dt><dd><p>The syntax is find_srid(&lt;db/schema&gt;, &lt;table&gt;,
-            &lt;column&gt;) and the function returns the integer SRID of the
-            specified column by searching through the GEOMETRY_COLUMNS table.
-            If the geometry column has not been properly added with the
-            AddGeometryColumns() function, this function will not work
-            either.</p></dd><dt><span class="term">mem_size(geometry)</span></dt><dd><p>Returns the amount of space (in bytes) the geometry
-            takes.</p></dd><dt><span class="term">numb_sub_objects(geometry)</span></dt><dd><p>Returns the number of objects stored in the geometry. This
-            is useful for MULTI-geometries and GEOMETRYCOLLECTIONs.</p></dd><dt><span class="term">point_inside_circle(geometry,float,float,float)</span></dt><dd><p>The syntax for this functions is
-            point_inside_circle(&lt;geometry&gt;,&lt;circle_center_x&gt;,&lt;circle_center_y&gt;,&lt;radius&gt;).
-            Returns the true if the geometry is a point and is inside the
-            circle. Returns false otherwise.</p></dd><dt><span class="term">xmin(box3d) ymin(box3d) zmin(box3d)</span></dt><dd><p>Returns the requested minima of a bounding box.</p></dd><dt><span class="term">xmax(box3d) ymax(box3d) zmax(box3d)</span></dt><dd><p>Returns the requested maxima of a bounding box.</p></dd><dt><a name="Accum"></a><span class="term">Accum(geometry set)</span></dt><dd><p>Aggregate. Constructs an array of geometries.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2531072"></a>6.2.9. Long Transactions support</h3></div></div><div></div></div><p>
-This module and associated pl/pgsql functions have been implemented
-to provide long locking support required by
-<a href="https://portal.opengeospatial.org/files/?artifact_id=7176" target="_top">Web Feature Service</a> specification.
-	</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
-  Users must use <a href="http://www.postgresql.org/docs/7.4/static/transaction-iso.html" target="_top">serializable transaction level</a> otherwise locking mechanism would break.
-	  </p></div><div class="variablelist"><dl><dt><a name="EnableLongTransactions"></a><span class="term">EnableLongTransactions()</span></dt><dd><p>
-		Enable long transaction support. This function creates the
-		required metadata tables, needs to be called once before
-		using the other functions in this section. Calling it twice
-		is harmless.
-	    </p><p>
-		    Availability: 1.1.3
-		</p></dd><dt><a name="DisableLongTransactions"></a><span class="term">DisableLongTransactions()</span></dt><dd><p>
-		Disable long transaction support. This function removes the
-		long transaction support metadata tables, and drops all
-		triggers attached to lock-checked tables.
-	    </p><p>
-		    Availability: 1.1.3
-		</p></dd><dt><a name="CheckAuth"></a><span class="term">CheckAuth([&lt;schema&gt;], &lt;table&gt;, &lt;rowid_col&gt;)</span></dt><dd><p>
-		Check updates and deletes of rows in
-		given table for being authorized.
-		Identify rows using &lt;rowid_col&gt; column.
-	    </p><p>
-		    Availability: 1.1.3
-		</p></dd><dt><a name="LockRow"></a><span class="term">LockRow([&lt;schema&gt;], &lt;table&gt;, &lt;rowid&gt;, &lt;authid&gt;, [&lt;expires&gt;])</span></dt><dd><p>
-	Set lock/authorization for specific row in table
-	&lt;authid&gt; is a text value, &lt;expires&gt; is a timestamp
-	defaulting to now()+1hour.
-	Returns 1 if lock has been assigned, 0 otherwise
-	(already locked by other auth)
-	    </p><p>
-		    Availability: 1.1.3
-		</p></dd><dt><a name="UnlockRows"></a><span class="term">UnlockRows(&lt;authid&gt;)</span></dt><dd><p>
-	Remove all locks held by specified authorization id.
-	Returns the number of locks released.
-	    </p><p>
-		    Availability: 1.1.3
-		</p></dd><dt><a name="AddAuth"></a><span class="term">AddAuth(&lt;authid&gt;)</span></dt><dd><p>
-	Add an authorization token to be used in current
-	transaction. 
-	    </p><p>
-		    Availability: 1.1.3
-		</p></dd></dl></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch05.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch07.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 5. Performance tips </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 7. Reporting Bugs</td></tr></table></div></body></html>

Deleted: packages/postgis/trunk/doc/html/ch07.html
===================================================================
--- packages/postgis/trunk/doc/html/ch07.html	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/ch07.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,23 +0,0 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 7. Reporting Bugs</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="PostGIS Manual"><link rel="up" href="index.html" title="PostGIS Manual"><link rel="previous" href="ch06.html" title="Chapter 6. PostGIS Reference"><link rel="next" href="apa.html" title="Appendix A. Appendix"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 7. Reporting Bugs</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch06.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="apa.html">Next</a></td></tr></table><hr></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2530656"></a>Chapter 7. Reporting Bugs</h2></div></div><div></div></div><p>
-	Reporting bugs effectively is a fundamental way to help PostGIS
-	development. The most effective bug report is that enabling 
-	PostGIS developers to reproduce it, so it would ideally contain
-	a script triggering it and every information reguarding the
-	environment in which it was detected. Good enough info can
-	be extracted running <tt class="code">SELECT postgis_full_version()</tt>
-	[for postgis] and <tt class="code">SELECT version()</tt> [for postgresql].
-		</p><p>
-	If you aren't using latest release, it's worth taking a look
-	at its <a href="http://postgis.refractions.net/CHANGES.txt" target="_top">release
-	changelog</a> first, to find out if your bug has already been
-	fixed.
-		</p><p>
-	Using the <a href="http://postgis.refractions.net/bugs/" target="_top">PostGIS
-	bug tracker</a> will ensure your reports are not discarded, and
-	will keep you informed on it's handling process. Before reporting
-	a new bug please query the database to see if it is a known one, and
-	if it is please add any new information you have about it.
-		</p><p>
-	You might want to read Simon Tatham's paper about <a href="http://www.chiark.greenend.org.uk/~sgtatham/bugs.html" target="_top">How
-	to Report Bugs Effectively</a> before filing a new report.
-		</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch06.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="apa.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 6. PostGIS Reference </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix A. Appendix</td></tr></table></div></body></html>

Deleted: packages/postgis/trunk/doc/html/index.html
===================================================================
--- packages/postgis/trunk/doc/html/index.html	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/html/index.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,9 +0,0 @@
-<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>PostGIS Manual</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><meta name="description" content="PostGIS is an extension to the PostgreSQL object-relational
-      database system which allows GIS (Geographic Information Systems)
-      objects to be stored in the database. PostGIS includes support for
-      GiST-based R-Tree spatial indexes, and functions for analysis and
-      processing of GIS objects. This is the manual for version 1.1.3"><link rel="home" href="index.html" title="PostGIS Manual"><link rel="next" href="ch01.html" title="Chapter 1. Introduction"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">PostGIS Manual</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch01.html">Next</a></td></tr></table><hr></div><div class="book" lang="en"><div class="titlepage"><div><div><h1 class="title"><a name="id2398070"></a>PostGIS Manual</h1></div><div><div class="abstract"><p class="title"><b>Abstract</b></p><p>PostGIS is an extension to the PostgreSQL object-relational
-      database system which allows GIS (Geographic Information Systems)
-      objects to be stored in the database. PostGIS includes support for
-      GiST-based R-Tree spatial indexes, and functions for analysis and
-      processing of GIS objects.</p><p>This is the manual for version 1.1.3</p></div></div></div><div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="chapter"><a href="ch01.html">1. Introduction</a></span></dt><dd><dl><dt><span class="sect1"><a href="ch01.html#credits">1.1. Credits</a></span></dt><dt><span class="sect1"><a href="ch01.html#id2454630">1.2. More Information</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch02.html">2. Installation</a></span></dt><dd><dl><dt><span class="sect1"><a href="ch02.html#id2481880">2.1. Requirements</a></span></dt><dt><span class="sect1"><a href="ch02.html#PGInstall">2.2. PostGIS</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch02.html#upgrading">2.2.1. Upgrading</a></span></dt><dt><span class="sect2"><a href="ch02.html#id2453863">2.2.2. Common Problems</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch02.html#id2522143">2.3. JDBC</a></span></dt><dt><span class="sect1"><a href="ch02.html#id2522219">2.4. Loader/Dumper</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch03.html">3. Frequently Asked Questions</a></span></dt><dt><span class="chapter"><a href="ch04.html">4. Using PostGIS</a></span></dt><dd><dl><dt><span class="sect1"><a href="ch04.html#RefObject">4.1. GIS Objects</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2522740">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2522847">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2523004">4.2. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2523037">4.2.1. The SPATIAL_REF_SYS Table</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2523246">4.2.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2523380">4.2.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2523486">4.2.4. Ensuring OpenGIS compliancy of geometries</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2523576">4.3. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2523590">4.3.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2523645">4.3.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2523875">4.4. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2523888">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2524054">4.4.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2524232">4.5. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2524285">4.5.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2524354">4.5.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2524472">4.6. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2524491">4.6.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2524587">4.6.2. Examples of Spatial SQL</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2524902">4.7. Using Mapserver</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2524945">4.7.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2525193">4.7.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2525360">4.7.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2453149">4.7.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch04.html#id2453247">4.8. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="ch04.html#id2525835">4.9. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch04.html#id2525844">4.9.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="ch04.html#id2525854">4.9.2. Binary Cursors</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="ch05.html">5. Performance tips</a></span></dt><dd><dl><dt><span class="sect1"><a href="ch05.html#id2525872">5.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch05.html#id2525878">5.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="ch05.html#id2525930">5.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch05.html#id2525990">5.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="ch05.html#id2526046">5.3. Avoiding dimension conversion</a></span></dt></dl></dd><dt><span class="chapter"><a href="ch06.html">6. PostGIS Reference</a></span></dt><dd><dl><dt><span class="sect1"><a href="ch06.html#id2526109">6.1. OpenGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch06.html#id2526115">6.1.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2526205">6.1.2. Geometry Relationship Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2526581">6.1.3. Geometry Processing Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2526907">6.1.4. Geometry Accessors</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2527394">6.1.5. Geometry Constructors</a></span></dt></dl></dd><dt><span class="sect1"><a href="ch06.html#id2527996">6.2. Postgis Extensions</a></span></dt><dd><dl><dt><span class="sect2"><a href="ch06.html#id2528002">6.2.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2528326">6.2.2. Operators</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2528534">6.2.3. Measurement Functions</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2528817">6.2.4. Geometry Outputs</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2528926">6.2.5. Geometry Constructors</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2529258">6.2.6. Geometry Editors</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2529854">6.2.7. Linear Referencing</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2530074">6.2.8. Misc</a></span></dt><dt><span class="sect2"><a href="ch06.html#id2531072">6.2.9. Long Transactions support</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="ch07.html">7. Reporting Bugs</a></span></dt><dt><span class="appendix"><a href="apa.html">A. Appendix</a></span></dt><dd><dl><dt><span class="sect1"><a href="apa.html#id2530726">A.1. Release Notes</a></span></dt><dd><dl><dt><span class="sect2"><a href="apa.html#id2530732">A.1.1. Release 1.1.3</a></span></dt><dt><span class="sect2"><a href="apa.html#id2530900">A.1.2. Release 1.1.2</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531032">A.1.3. Release 1.1.1</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531325">A.1.4. Release 1.1.0</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531650">A.1.5. Release 1.0.6</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531758">A.1.6. Release 1.0.5</a></span></dt><dt><span class="sect2"><a href="apa.html#id2531890">A.1.7. Release 1.0.4</a></span></dt><dt><span class="sect2"><a href="apa.html#rel_1.0.3_upgrading">A.1.8. Release 1.0.3</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532137">A.1.9. Release 1.0.2</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532216">A.1.10. Release 1.0.1</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532315">A.1.11. Release 1.0.0</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532414">A.1.12. Release 1.0.0RC6</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532488">A.1.13. Release 1.0.0RC5</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532560">A.1.14. Release 1.0.0RC4</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532685">A.1.15. Release 1.0.0RC3</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532857">A.1.16. Release 1.0.0RC2</a></span></dt><dt><span class="sect2"><a href="apa.html#id2532955">A.1.17. Release 1.0.0RC1</a></span></dt></dl></dd></dl></dd></dl></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch01.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"> </td><td width="40%" align="right" valign="top"> Chapter 1. Introduction</td></tr></table></div></body></html>

Copied: packages/postgis/trunk/doc/html/postgis.html (from rev 562, packages/postgis/upstream/doc/html/postgis.html)
===================================================================
--- packages/postgis/trunk/doc/html/postgis.html	                        (rev 0)
+++ packages/postgis/trunk/doc/html/postgis.html	2006-10-06 08:50:14 UTC (rev 563)
@@ -0,0 +1,2092 @@
+<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>PostGIS Manual</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><meta name="description" content="PostGIS is an extension to the PostgreSQL object-relational
+      database system which allows GIS (Geographic Information Systems)
+      objects to be stored in the database. PostGIS includes support for
+      GiST-based R-Tree spatial indexes, and functions for analysis and
+      processing of GIS objects. This is the manual for version 1.1.4"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="book" lang="en"><div class="titlepage"><div><div><h1 class="title"><a name="id2580166"></a>PostGIS Manual</h1></div><div><div class="abstract"><p class="title"><b>Abstract</b></p><p>PostGIS is an extension to the PostgreSQL object-relational
+      database system which allows GIS (Geographic Information Systems)
+      objects to be stored in the database. PostGIS includes support for
+      GiST-based R-Tree spatial indexes, and functions for analysis and
+      processing of GIS objects.</p><p>This is the manual for version 1.1.4</p></div></div></div><div></div><hr></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="chapter"><a href="#id2582151">1. Introduction</a></span></dt><dd><dl><dt><span class="sect1"><a href="#credits">1.1. Credits</a></span></dt><dt><span class="sect1"><a href="#id2581981">1.2. More Information</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2609268">2. Installation</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2609274">2.1. Requirements</a></span></dt><dt><span class="sect1"><a href="#PGInstall">2.2. PostGIS</a></span></dt><dd><dl><dt><span class="sect2"><a href="#upgrading">2.2.1. Upgrading</a></span></dt><dt><span class="sect2"><a href="#id2581192">2.2.2. Common Problems</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2649517">2.3. JDBC</a></span></dt><dt><span class="sect1"><a href="#id2649594">2.4. Loader/Dumper</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2649632">3. Frequently Asked Questions</a></span></dt><dt><span class="chapter"><a href="#id2650088">4. Using PostGIS</a></span></dt><dd><dl><dt><span class="sect1"><a href="#RefObject">4.1. GIS Objects</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2650115">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="#id2650222">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2650378">4.2. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2650411">4.2.1. The SPATIAL_REF_SYS Table</a></span></dt><dt><span class="sect2"><a href="#id2650620">4.2.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="#id2650754">4.2.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="#id2650861">4.2.4. Ensuring OpenGIS compliancy of geometries</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2650951">4.3. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2650964">4.3.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2651020">4.3.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2651250">4.4. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2651263">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2651429">4.4.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2651607">4.5. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2651660">4.5.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="#id2651729">4.5.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2651847">4.6. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2651866">4.6.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="#id2651962">4.6.2. Examples of Spatial SQL</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2652277">4.7. Using Mapserver</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2652320">4.7.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="#id2652568">4.7.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="#id2652735">4.7.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="#id2580495">4.7.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2580593">4.8. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="#id2653210">4.9. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2653219">4.9.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="#id2653229">4.9.2. Binary Cursors</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id2653241">5. Performance tips</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2653247">5.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2653253">5.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="#id2653305">5.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2653365">5.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="#id2653421">5.3. Avoiding dimension conversion</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2653471">6. PostGIS Reference</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2653484">6.1. OpenGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2653490">6.1.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2653580">6.1.2. Geometry Relationship Functions</a></span></dt><dt><span class="sect2"><a href="#id2653956">6.1.3. Geometry Processing Functions</a></span></dt><dt><span class="sect2"><a href="#id2654282">6.1.4. Geometry Accessors</a></span></dt><dt><span class="sect2"><a href="#id2654768">6.1.5. Geometry Constructors</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2655371">6.2. Postgis Extensions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2655376">6.2.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2655701">6.2.2. Operators</a></span></dt><dt><span class="sect2"><a href="#id2655909">6.2.3. Measurement Functions</a></span></dt><dt><span class="sect2"><a href="#id2656192">6.2.4. Geometry Outputs</a></span></dt><dt><span class="sect2"><a href="#id2656300">6.2.5. Geometry Constructors</a></span></dt><dt><span class="sect2"><a href="#id2656633">6.2.6. Geometry Editors</a></span></dt><dt><span class="sect2"><a href="#id2657229">6.2.7. Linear Referencing</a></span></dt><dt><span class="sect2"><a href="#id2657449">6.2.8. Misc</a></span></dt><dt><span class="sect2"><a href="#id2658447">6.2.9. Long Transactions support</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id2658031">7. Reporting Bugs</a></span></dt><dt><span class="appendix"><a href="#release_notes">A. Appendix</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2658101">A.1. Release Notes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2658106">A.1.1. Release 1.1.4</a></span></dt><dt><span class="sect2"><a href="#id2658230">A.1.2. Release 1.1.3</a></span></dt><dt><span class="sect2"><a href="#id2658396">A.1.3. Release 1.1.2</a></span></dt><dt><span class="sect2"><a href="#id2658690">A.1.4. Release 1.1.1</a></span></dt><dt><span class="sect2"><a href="#id2658820">A.1.5. Release 1.1.0</a></span></dt><dt><span class="sect2"><a href="#id2659145">A.1.6. Release 1.0.6</a></span></dt><dt><span class="sect2"><a href="#id2659254">A.1.7. Release 1.0.5</a></span></dt><dt><span class="sect2"><a href="#id2659386">A.1.8. Release 1.0.4</a></span></dt><dt><span class="sect2"><a href="#rel_1.0.3_upgrading">A.1.9. Release 1.0.3</a></span></dt><dt><span class="sect2"><a href="#id2659632">A.1.10. Release 1.0.2</a></span></dt><dt><span class="sect2"><a href="#id2659711">A.1.11. Release 1.0.1</a></span></dt><dt><span class="sect2"><a href="#id2659811">A.1.12. Release 1.0.0</a></span></dt><dt><span class="sect2"><a href="#id2659910">A.1.13. Release 1.0.0RC6</a></span></dt><dt><span class="sect2"><a href="#id2659984">A.1.14. Release 1.0.0RC5</a></span></dt><dt><span class="sect2"><a href="#id2660056">A.1.15. Release 1.0.0RC4</a></span></dt><dt><span class="sect2"><a href="#id2660181">A.1.16. Release 1.0.0RC3</a></span></dt><dt><span class="sect2"><a href="#id2660352">A.1.17. Release 1.0.0RC2</a></span></dt><dt><span class="sect2"><a href="#id2660450">A.1.18. Release 1.0.0RC1</a></span></dt></dl></dd></dl></dd></dl></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2582151"></a>Chapter 1. Introduction</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#credits">1.1. Credits</a></span></dt><dt><span class="sect1"><a href="#id2581981">1.2. More Information</a></span></dt></dl></div><p>PostGIS is developed by Refractions Research Inc, as a spatial
+    database technology research project. Refractions is a GIS and database
+    consulting company in Victoria, British Columbia, Canada, specializing in
+    data integration and custom software development. We plan on supporting
+    and developing PostGIS to support a range of important GIS functionality,
+    including full OpenGIS support, advanced topological constructs
+    (coverages, surfaces, networks), desktop user interface tools for viewing
+    and editing GIS data, and web-based access tools.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="credits"></a>1.1. Credits</h2></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">Sandro Santilli &lt;strk at refractions.net&gt;</span></dt><dd><p>Coordinates all bug fixing and maintenance effort,
+            integration of new GEOS functionality, and new function
+            enhancements.</p></dd><dt><span class="term">Chris Hodgson &lt;chodgson at refractions.net&gt;</span></dt><dd><p>Maintains new functions and the 7.2 index bindings.</p></dd><dt><span class="term">Paul Ramsey &lt;pramsey at refractions.net&gt;</span></dt><dd><p>Keeps track of the
+            documentation and packaging.</p></dd><dt><span class="term">Jeff Lounsbury &lt;jeffloun at refractions.net&gt;</span></dt><dd><p>Original development of the Shape file loader/dumper.</p></dd><dt><span class="term">Dave Blasby &lt;dblasby at gmail.com&gt;</span></dt><dd><p>The original developer of PostGIS. Dave wrote the server
+            side objects, index bindings, and many of the server side
+            analytical functions.</p></dd><dt><span class="term">Other contributors</span></dt><dd><p>
+		In alphabetical order: 
+		Alex Bodnaru, Alex Mayrhofer, Bruce Rindahl,
+		Bernhard Reiter, 
+		Bruno Wolff III, Carl Anderson, Charlie Savage,
+		David Skea, David Techer, 
+		IIDA Tetsushi, Geographic Data BC, Gerald Fenoy,
+		Gino Lucrezi, Klaus Foerster, Kris Jurka, Mark Cave-Ayland,
+		Mark Sondheim, Markus Schaber, Michael Fuhr, Nikita Shulga,
+		Norman Vine, Olivier Courtin, Ralph Mason, Steffen Macke.
+            </p></dd><dt><span class="term">Important Support Libraries</span></dt><dd><p>The <a href="http://geos.refractions.net" target="_top">GEOS</a>
+            geometry operations library, and the algorithmic work of 
+            Martin Davis &lt;mbdavis at vividsolutions.com&gt; of Vivid Solutions
+            in making it all work.</p><p>The <a href="http://proj4.maptools.org" target="_top">Proj4</a>
+            cartographic projection library, and the work of Gerald Evenden
+            and Frank Warmerdam in creating and maintaining it.</p></dd></dl></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2581981"></a>1.2. More Information</h2></div></div><div></div></div><div class="itemizedlist"><ul type="disc"><li><p>The latest software, documentation and news items are
+          available at the PostGIS web site, <a href="http://postgis.refractions.net" target="_top">http://postgis.refractions.net</a>.</p></li><li><p>More information about the GEOS geometry operations library is
+          available at<a href="http://geos.refractions.net" target="_top">
+          http://geos.refractions.net</a>.</p></li><li><p>More information about the Proj4 reprojection library is
+          available at <a href="http://www.remotesensing.org/proj" target="_top">http://www.remotesensing.org/proj</a>.</p></li><li><p>More information about the PostgreSQL database server is
+          available at the PostgreSQL main site <a href="http://www.postgresql.org" target="_top">http://www.postgresql.org</a>.</p></li><li><p>More information about GiST indexing is available at the
+          PostgreSQL GiST development site, <a href="http://www.sai.msu.su/~megera/postgres/gist" target="_top">http://www.sai.msu.su/~megera/postgres/gist</a>.</p></li><li><p>More information about Mapserver internet map server is
+          available at <a href="http://mapserver.gis.umn.edu/" target="_top">http://mapserver.gis.umn.edu</a>.</p></li><li><p>The "<a href="http://www.opengis.org/docs/99-049.pdf" target="_top">Simple Features
+          for Specification for SQL</a>" is available at the OpenGIS
+          Consortium web site: <a href="http://www.opengis.org" target="_top">http://www.opengis.org</a>.</p></li></ul></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2609268"></a>Chapter 2. Installation</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id2609274">2.1. Requirements</a></span></dt><dt><span class="sect1"><a href="#PGInstall">2.2. PostGIS</a></span></dt><dd><dl><dt><span class="sect2"><a href="#upgrading">2.2.1. Upgrading</a></span></dt><dt><span class="sect2"><a href="#id2581192">2.2.2. Common Problems</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2649517">2.3. JDBC</a></span></dt><dt><span class="sect1"><a href="#id2649594">2.4. Loader/Dumper</a></span></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2609274"></a>2.1. Requirements</h2></div></div><div></div></div><p>PostGIS has the following requirements for building and
+      usage:</p><div class="itemizedlist"><ul type="disc"><li><p>
+	  A complete installation of PostgreSQL (including server headers).
+          PostgreSQL is available from <a href="http://www.postgresql.org" target="_top">http://www.postgresql.org</a>.
+	  Version 7.2 or higher is required.
+	  </p></li><li><p>GNU C compiler (<tt class="filename">gcc</tt>). Some other ANSI C
+          compilers can be used to compile PostGIS, but we find far fewer
+          problems when compiling with <tt class="filename">gcc</tt>.</p></li><li><p>GNU Make (<tt class="filename">gmake</tt> or
+          <tt class="filename">make</tt>). For many systems, GNU
+          <tt class="filename">make</tt> is the default version of make. Check the
+          version by invoking <tt class="filename">make -v</tt>. Other versions of
+          <tt class="filename">make</tt> may not process the PostGIS
+          <tt class="filename">Makefile</tt> properly.</p></li><li><p>(Recommended) Proj4 reprojection library. The Proj4 library is
+          used to provide coordinate reprojection support within PostGIS.
+          Proj4 is available for download from <a href="http://www.remotesensing.org/proj" target="_top">http://www.remotesensing.org/proj</a>.</p></li><li><p>(Recommended) GEOS geometry library. The GEOS library is used
+          to provide geometry tests (Touches(), Contains(), Intersects()) and
+          operations (Buffer(), GeomUnion(), Difference()) within PostGIS.
+          GEOS is available for download from <a href="http://geos.refractions.net" target="_top">http://geos.refractions.net</a>.</p></li></ul></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="PGInstall"></a>2.2. PostGIS</h2></div></div><div></div></div><p>The PostGIS module is a extension to the PostgreSQL backend
+      server. As such, PostGIS 1.1.4
+      <span class="emphasis"><em>requires</em></span> full PostgreSQL server headers access
+      in order to compile. The PostgreSQL source code is available at <a href="http://www.postgresql.org" target="_top">http://www.postgresql.org</a>.</p><p>PostGIS 1.1.4 can be built against PostgreSQL
+      versions 7.2.0 or higher. Earlier versions of PostgreSQL are
+      <span class="emphasis"><em>not</em></span> supported.</p><div class="orderedlist"><ol type="1"><li><p>Before you can compile the PostGIS server modules, you must
+          compile and install the PostgreSQL package.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>If you plan to use GEOS functionality you might need to
+            explicitly link PostgreSQL against the standard C++
+            library:</p><pre class="programlisting">LDFLAGS=-lstdc++ ./configure [YOUR OPTIONS HERE]</pre><p>This is a workaround for bogus C++ exceptions interaction
+            with older development tools. If you experience weird problems
+            (backend unexpectedly closed or similar things) try this trick.
+            This will require recompiling your PostgreSQL from scratch, of
+            course.</p></div></li><li><p>Retrieve the PostGIS source archive from <a href="http://postgis.refractions.net/postgis-1.1.4.tar.gz" target="_top">http://postgis.refractions.net/postgis-1.1.4.tar.gz</a>.
+          Uncompress and untar the archive.
+	  </p><pre class="programlisting"># gzip -d -c postgis-1.1.4.tar.gz | tar xvf -</pre></li><li><p>Enter the postgis-1.1.4 directory, and run:
+</p><pre class="programlisting"># ./configure</pre><p>
+	  </p><div class="itemizedlist"><ul type="disc"><li><p>
+		If you want support for coordinate reprojection, you must have
+		the Proj4 library installed. If ./configure didn't find
+		it, try using <tt class="code">--with-proj=PATH</tt>
+		switch specify a specific Proj4 installation directory.
+		</p></li><li><p>
+		If you want to use GEOS functionality, you must have the GEOS
+		library installed. If ./configure didn't find it, try
+		using <tt class="code">--with-geos=PATH</tt> to specify the full 
+                path to the geos-config program full path.
+		</p></li></ul></div></li><li><p>Run the compile and install commands.</p><pre class="programlisting"># make 
+# make install</pre><p>All files are installed using information provided
+	  by <tt class="filename">pg_config</tt></p><div class="itemizedlist"><ul type="disc"><li><p>Libraries are installed
+              <tt class="filename">[pkglibdir]/lib/contrib</tt>.</p></li><li><p>Important support files such as
+              <tt class="filename">lwpostgis.sql</tt> are installed in
+              <tt class="filename">[prefix]/share/contrib</tt>.</p></li><li><p>Loader and dumper binaries are installed in
+              <tt class="filename">[bindir]/</tt>.</p></li></ul></div></li><li><p>PostGIS requires the PL/pgSQL procedural language extension.
+          Before loading the <tt class="filename">lwpostgis.sql</tt> file, you must
+          first enable PL/pgSQL. You should use the
+          <tt class="filename">createlang</tt> command. The PostgreSQL 
+          Programmer's Guide has the details if you want to this manually for
+          some reason.</p><pre class="programlisting"># createlang plpgsql [yourdatabase]</pre></li><li><p>Now load the PostGIS object and function definitions into your
+          database by loading the <tt class="filename">lwpostgis.sql</tt> definitions
+          file.</p><pre class="programlisting"># psql -d [yourdatabase] -f lwpostgis.sql</pre><p>The PostGIS server extensions are now loaded and ready to
+          use.</p></li><li><p>For a complete set of EPSG coordinate system definition
+          identifiers, you can also load the
+          <tt class="filename">spatial_ref_sys.sql</tt> definitions file and
+          populate the <tt class="varname">SPATIAL_REF_SYS</tt> table.</p><pre class="programlisting"># psql -d [yourdatabase] -f spatial_ref_sys.sql</pre></li></ol></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="upgrading"></a>2.2.1. Upgrading</h3></div></div><div></div></div><p>
+Upgrading existing spatial databases can be tricky as it requires
+replacement or introduction of new PostGIS object definitions.
+</p><p>
+Unfortunately not all definitions can be easily replaced in 
+a live database, so sometimes your best bet is a dump/reload
+process. 
+</p><p>
+PostGIS provides a SOFT UPGRADE procedure for minor or bugfix
+releases, and an HARD UPGRADE procedure for major releases.
+</p><p>
+Before attempting to upgrade postgis, it is always worth to backup
+your data. If you use the -Fc flag to pg_dump you will always be able
+to restore the dump with an HARD UPGRADE.
+	</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="soft_upgrade"></a>2.2.1.1. Soft upgrade</h4></div></div><div></div></div><p>
+Soft upgrade consists of sourcing the lwpostgis_upgrade.sql
+script in your spatial database:
+</p><pre class="programlisting">psql -f lwpostgis_upgrade.sql -d your_spatial_database</pre><p>
+If a soft upgrade is not possible the script will abort and 
+you will be warned about HARD UPGRADE being required,
+so do not hesitate to try a soft upgrade first.
+</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+If you can't find the <tt class="filename">lwpostgis_upgrade.sql</tt> file
+you are probably using a version prior to 1.1 and must generate that
+file by yourself. This is done with the following command:
+</p><pre class="programlisting">utils/postgis_proc_upgrade.pl lwpostgis.sql &gt; lwpostgis_upgrade.sql</pre></div></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="hard_upgrade"></a>2.2.1.2. Hard upgrade</h4></div></div><div></div></div><p>
+By HARD UPGRADE we intend full dump/reload of postgis-enabled databases.
+You need an HARD UPGRADE when postgis objects' internal storage
+changes or when SOFT UPGRADE is not possible.
+The <a href="#release_notes" title="Appendix A. Appendix">Release Notes</a> appendix reports for each version whether you need a
+dump/reload (HARD UPGRADE) to upgrade.
+	</p><p>
+PostGIS provides an utility script to restore a dump
+produced with the pg_dump -Fc command. It is experimental so redirecting
+its output to a file will help in case of problems. The procedure is
+as follow:
+	</p><pre class="programlisting">
+	# Create a "custom-format" dump of the database you want
+	# to upgrade (let's call it "olddb")
+	$ pg_dump -Fc olddb &gt; olddb.dump
+
+	# Restore the dump contextually upgrading postgis into
+	# a new database. The new database doesn't have to exist.
+	# Let's call it "newdb"
+	$ sh utils/postgis_restore.pl lwpostgis.sql newdb olddb.dump &gt; restore.log
+
+	# Check that all restored dump objects really had to be restored from dump
+	# and do not conflict with the ones defined in lwpostgis.sql
+	$ grep ^KEEPING restore.log | less
+
+	# If upgrading from PostgreSQL &lt; 8.0 to &gt;= 8.0 you might want to 
+	# drop the attrelid, varattnum and stats columns in the geometry_columns
+	# table, which are no-more needed. Keeping them won't hurt.
+	# !!! DROPPING THEM WHEN REALLY NEEDED WILL DO HURT !!!!
+	$ psql newdb -c "ALTER TABLE geometry_columns DROP attrelid"
+	$ psql newdb -c "ALTER TABLE geometry_columns DROP varattnum"
+	$ psql newdb -c "ALTER TABLE geometry_columns DROP stats"
+
+	# spatial_ref_sys table is restore from the dump, to ensure your custom
+	# additions are kept, but the distributed one might contain modification
+	# so you should backup your entries, drop the table and source the new one.
+	# If you did make additions we assume you know how to backup them before
+	# upgrading the table. Replace of it with the new one is done like this:
+	$ psql newdb
+	newdb=&gt; delete from spatial_ref_sys; 
+	DROP
+	newdb=&gt; \i spatial_ref_sys.sql
+	</pre></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2581192"></a>2.2.2. Common Problems</h3></div></div><div></div></div><p>There are several things to check when your installation or
+        upgrade doesn't go as you expected.</p><div class="orderedlist"><ol type="1"><li><p>It is easiest if you untar the PostGIS distribution into the
+            contrib directory under the PostgreSQL source tree. However, if
+            this is not possible for some reason, you can set the
+            <tt class="varname">PGSQL_SRC</tt> environment variable to the path to
+            the PostgreSQL source directory. This will allow you to compile
+            PostGIS, but the <span><b class="command">make install</b></span> may not work, so
+            be prepared to copy the PostGIS library and executable files to
+            the appropriate locations yourself.</p></li><li><p>Check that you you have installed PostgreSQL 7.2 or newer,
+            and that you are compiling against the same version of the
+            PostgreSQL source as the version of PostgreSQL that is running.
+            Mix-ups can occur when your (Linux) distribution has already
+            installed PostgreSQL, or you have otherwise installed PostgreSQL
+            before and forgotten about it. PostGIS will only work with
+            PostgreSQL 7.2 or newer, and strange, unexpected error messages
+            will result if you use an older version. To check the version of
+            PostgreSQL which is running, connect to the database using psql
+            and run this query:</p><pre class="programlisting">SELECT version();</pre><p>If you are running an RPM based distribution, you can check
+            for the existence of pre-installed packages using the
+            <span><b class="command">rpm</b></span> command as follows: <span><b class="command">rpm -qa | grep
+            postgresql</b></span></p></li></ol></div><p>Also check that you have made any necessary changes to the top
+        of the Makefile.config. This includes:</p><div class="orderedlist"><ol type="1"><li><p>If you want to be able to do coordinate reprojections, you
+            must install the Proj4 library on your system, set the
+            <tt class="varname">USE_PROJ</tt> variable to 1 and the
+            <tt class="varname">PROJ_DIR</tt> to your installation prefix in the
+            Makefile.config.</p></li><li><p>If you want to be able to use GEOS functions you must
+            install the GEOS library on your system, and set the
+            <tt class="varname">USE_GEOS</tt> to 1 and the
+            <tt class="varname">GEOS_DIR</tt> to your installation prefix in the
+            Makefile.config</p></li></ol></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2649517"></a>2.3. JDBC</h2></div></div><div></div></div><p>The JDBC extensions provide Java objects corresponding to the
+      internal PostGIS types. These objects can be used to write Java clients
+      which query the PostGIS database and draw or do calculations on the GIS
+      data in PostGIS.</p><div class="orderedlist"><ol type="1"><li><p>Enter the <tt class="filename">jdbc</tt> sub-directory of the
+          PostGIS distribution.</p></li><li><p>Edit the <tt class="filename">Makefile</tt> to provide the correct
+          paths of your java compiler (<tt class="varname">JAVAC</tt>) and
+          interpreter (<tt class="varname">JAVA</tt>).</p></li><li><p>Run the <tt class="filename">make</tt> command. Copy the
+          <tt class="filename">postgis.jar</tt> file to wherever you keep your java
+          libraries.</p></li></ol></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2649594"></a>2.4. Loader/Dumper</h2></div></div><div></div></div><p>The data loader and dumper are built and installed automatically
+      as part of the PostGIS build. To build and install them manually:</p><pre class="programlisting"># cd postgis-1.1.4/loader 
+# make
+# make install</pre><p>The loader is called <tt class="filename">shp2pgsql</tt> and converts
+      ESRI Shape files into SQL suitable for loading in PostGIS/PostgreSQL.
+      The dumper is called <tt class="filename">pgsql2shp</tt> and converts PostGIS
+      tables (or queries) into ESRI Shape files.</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2649632"></a>Chapter 3. Frequently Asked Questions</h2></div></div><div></div></div><div class="qandaset"><dl><dt>3.1. <a href="#id2649640">What kind of geometric objects can I store?</a></dt><dt>3.2. <a href="#id2649661">How do I insert a GIS object into the database?</a></dt><dt>3.3. <a href="#id2649756">How do I construct a spatial query?</a></dt><dt>3.4. <a href="#id2649822">How do I speed up spatial queries on large tables?</a></dt><dt>3.5. <a href="#id2649903">Why aren't PostgreSQL R-Tree indexes supported?</a></dt><dt>3.6. <a href="#id2649956">Why should I use the AddGeometryColumn()
+          function and all the other OpenGIS stuff?</a></dt><dt>3.7. <a href="#id2650004">What is the best way to find all objects within a radius of
+          another object?</a></dt><dt>3.8. <a href="#id2650056">How do I perform a coordinate reprojection as part of a
+          query?</a></dt></dl><table border="0" summary="Q and A Set"><col align="left" width="1%"><tbody><tr class="question"><td align="left" valign="top"><a name="id2649640"></a><a name="id2649642"></a><b>3.1.</b></td><td align="left" valign="top"><p>What kind of geometric objects can I store?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>You can store point, line, polygon, multipoint, multiline,
+          multipolygon, and geometrycollections. These are specified in the
+          Open GIS Well Known Text Format (with XYZ,XYM,XYZM extentions).</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2649661"></a><a name="id2649663"></a><b>3.2.</b></td><td align="left" valign="top"><p>How do I insert a GIS object into the database?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>First, you need to create a table with a column of type
+          "geometry" to hold your GIS data. Connect to your database with
+          <tt class="filename">psql</tt> and try the following SQL:</p><pre class="programlisting">CREATE TABLE gtest ( ID int4, NAME varchar(20) );
+SELECT AddGeometryColumn('', 'gtest','geom',-1,'LINESTRING',2);</pre><p>If the geometry column addition fails, you probably have not
+          loaded the PostGIS functions and objects into this database. See the
+          <a href="#PGInstall" title="2.2. PostGIS">installation instructions</a>.</p><p>Then, you can insert a geometry into the table using a SQL
+          insert statement. The GIS object itself is formatted using the
+          OpenGIS Consortium "well-known text" format:</p><pre class="programlisting">INSERT INTO gtest (ID, NAME, GEOM) VALUES (1, 'First Geometry', GeomFromText('LINESTRING(2 3,4 5,6 5,7 8)', -1));</pre><p>For more information about other GIS objects, see the <a href="#RefObject" title="4.1. GIS Objects">object reference</a>.</p><p>To view your GIS data in the table:</p><pre class="programlisting">SELECT id, name, AsText(geom) AS geom FROM gtest;</pre><p>The return value should look something like this:</p><pre class="programlisting"> id | name           | geom
+----+----------------+-----------------------------
+  1 | First Geometry | LINESTRING(2 3,4 5,6 5,7 8) 
+(1 row)</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2649756"></a><a name="id2649758"></a><b>3.3.</b></td><td align="left" valign="top"><p>How do I construct a spatial query?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>The same way you construct any other database query, as an SQL
+          combination of return values, functions, and boolean tests.</p><p>For spatial queries, there are two issues that are important
+          to keep in mind while constructing your query: is there a spatial
+          index you can make use of; and, are you doing expensive calculations
+          on a large number of geometries.</p><p>In general, you will want to use the "intersects operator"
+          (&amp;&amp;) which tests whether the bounding boxes of features
+          intersect. The reason the &amp;&amp; operator is useful is because
+          if a spatial index is available to speed up the test, the &amp;&amp;
+          operator will make use of this. This can make queries much much
+          faster.</p><p>You will also make use of spatial functions, such as
+          Distance(), Intersects(), Contains() and Within(), among others, to
+          narrow down the results of your search. Most spatial queries include
+          both an indexed test and a spatial function test. The index test
+          serves to limit the number of return tuples to only tuples that
+          <span class="emphasis"><em>might</em></span> meet the condition of interest. The
+          spatial functions are then use to test the condition exactly.</p><pre class="programlisting">SELECT id, the_geom FROM thetable
+WHERE
+  the_geom &amp;&amp; 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'
+AND
+  Contains(the_geom,'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))';</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2649822"></a><a name="id2649824"></a><b>3.4.</b></td><td align="left" valign="top"><p>How do I speed up spatial queries on large tables?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>Fast queries on large tables is the <span class="emphasis"><em>raison
+          d'etre</em></span> of spatial databases (along with transaction
+          support) so having a good index is important.</p><p>To build a spatial index on a table with a
+          <tt class="varname">geometry</tt> column, use the "CREATE INDEX" function
+          as follows:</p><pre class="programlisting">CREATE INDEX [indexname] ON [tablename]  
+  USING GIST ( [geometrycolumn] );</pre><p>The "USING GIST" option tells the server to use a GiST
+          (Generalized Search Tree) index.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+            GiST indexes are assumed to be lossy.
+	    Lossy indexes uses a proxy object (in the spatial case,
+	    a bounding box) for building the index.</p></div><p>You should also ensure that the PostgreSQL query planner has
+          enough information about your index to make rational decisions about
+          when to use it. To do this, you have to "gather statistics" on your
+          geometry tables.</p><p>For PostgreSQL 8.0.x and greater, just run the <span><b class="command">VACUUM
+          ANALYZE</b></span> command.</p><p>For PostgreSQL 7.4.x and below, run the <span><b class="command">SELECT
+          UPDATE_GEOMETRY_STATS()</b></span> command.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2649903"></a><a name="id2649906"></a><b>3.5.</b></td><td align="left" valign="top"><p>Why aren't PostgreSQL R-Tree indexes supported?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>Early versions of PostGIS used the PostgreSQL R-Tree indexes.
+          However, PostgreSQL R-Trees have been completely discarded since
+          version 0.6, and spatial indexing is provided with an
+          R-Tree-over-GiST scheme.</p><p>Our tests have shown search speed for native R-Tree and GiST
+          to be comparable. Native PostgreSQL R-Trees have two limitations
+          which make them undesirable for use with GIS features (note that
+          these limitations are due to the current PostgreSQL native R-Tree
+          implementation, not the R-Tree concept in general):</p><div class="itemizedlist"><ul type="disc"><li><p>R-Tree indexes in PostgreSQL cannot handle features which
+              are larger than 8K in size. GiST indexes can, using the "lossy"
+              trick of substituting the bounding box for the feature
+              itself.</p></li><li><p>R-Tree indexes in PostgreSQL are not "null safe", so
+              building an index on a geometry column which contains null
+              geometries will fail.</p></li></ul></div></td></tr><tr class="question"><td align="left" valign="top"><a name="id2649956"></a><a name="id2649958"></a><b>3.6.</b></td><td align="left" valign="top"><p>Why should I use the <tt class="varname">AddGeometryColumn()</tt>
+          function and all the other OpenGIS stuff?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>If you do not want to use the OpenGIS support functions, you
+          do not have to. Simply create tables as in older versions, defining
+          your geometry columns in the CREATE statement. All your geometries
+          will have SRIDs of -1, and the OpenGIS meta-data tables will
+          <span class="emphasis"><em>not</em></span> be filled in properly. However, this will
+          cause most applications based on PostGIS to fail, and it is
+          generally suggested that you do use
+          <tt class="varname">AddGeometryColumn()</tt> to create geometry
+          tables.</p><p>Mapserver is one application which makes use of the
+          <tt class="varname">geometry_columns</tt> meta-data. Specifically,
+          Mapserver can use the SRID of the geometry column to do on-the-fly
+          reprojection of features into the correct map projection.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2650004"></a><a name="id2650006"></a><b>3.7.</b></td><td align="left" valign="top"><p>What is the best way to find all objects within a radius of
+          another object?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>To use the database most efficiently, it is best to do radius
+          queries which combine the radius test with a bounding box test: the
+          bounding box test uses the spatial index, giving fast access to a
+          subset of data which the radius test is then applied to.</p><p>The <tt class="varname">Expand()</tt> function is a handy way of
+          enlarging a bounding box to allow an index search of a region of
+          interest. The combination of a fast access index clause and a slower
+          accurate distance test provides the best combination of speed and
+          precision for this query.</p><p>For example, to find all objects with 100 meters of POINT(1000
+          1000) the following query would work well:</p><pre class="programlisting">SELECT * 
+FROM GEOTABLE 
+WHERE 
+  GEOCOLUMN &amp;&amp; Expand(GeomFromText('POINT(1000 1000)',-1),100)
+AND
+  Distance(GeomFromText('POINT(1000 1000)',-1),GEOCOLUMN) &lt; 100;</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2650056"></a><a name="id2650058"></a><b>3.8.</b></td><td align="left" valign="top"><p>How do I perform a coordinate reprojection as part of a
+          query?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>To perform a reprojection, both the source and destination
+          coordinate systems must be defined in the SPATIAL_REF_SYS table, and
+          the geometries being reprojected must already have an SRID set on
+          them. Once that is done, a reprojection is as simple as referring to
+          the desired destination SRID.</p><pre class="programlisting">SELECT Transform(GEOM,4269) FROM GEOTABLE;</pre></td></tr></tbody></table></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2650088"></a>Chapter 4. Using PostGIS</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#RefObject">4.1. GIS Objects</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2650115">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="#id2650222">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2650378">4.2. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2650411">4.2.1. The SPATIAL_REF_SYS Table</a></span></dt><dt><span class="sect2"><a href="#id2650620">4.2.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="#id2650754">4.2.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="#id2650861">4.2.4. Ensuring OpenGIS compliancy of geometries</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2650951">4.3. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2650964">4.3.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2651020">4.3.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2651250">4.4. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2651263">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2651429">4.4.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2651607">4.5. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2651660">4.5.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="#id2651729">4.5.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2651847">4.6. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2651866">4.6.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="#id2651962">4.6.2. Examples of Spatial SQL</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2652277">4.7. Using Mapserver</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2652320">4.7.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="#id2652568">4.7.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="#id2652735">4.7.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="#id2580495">4.7.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2580593">4.8. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="#id2653210">4.9. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2653219">4.9.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="#id2653229">4.9.2. Binary Cursors</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="RefObject"></a>4.1. GIS Objects</h2></div></div><div></div></div><p>The GIS objects supported by PostGIS are a superset of
+      the "Simple Features" defined by the OpenGIS Consortium (OGC).
+      As of version 0.9, PostGIS supports all the objects and functions
+      specified in the OGC "Simple Features for SQL" specification.</p><p>PostGIS extends the standard with support for 3DZ,3DM and 4D
+      coordinates.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2650115"></a>4.1.1. OpenGIS WKB and WKT</h3></div></div><div></div></div><p>The OpenGIS specification defines two standard ways of
+        expressing spatial objects: the Well-Known Text (WKT) form and
+	the Well-Known Binary (WKB) form. Both WKT and WKB include
+	information about the type of the object and the
+        coordinates which form the object.</p><p>Examples of the text representations (WKT) of the spatial
+      objects of the features are as follows:</p><div class="itemizedlist"><ul type="disc"><li><p>POINT(0 0)</p></li><li><p>LINESTRING(0 0,1 1,1 2)</p></li><li><p>POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))</p></li><li><p>MULTIPOINT(0 0,1 2)</p></li><li><p>MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))</p></li><li><p>MULTIPOLYGON(((0 0,4 0,4 4,0 4,0 0),(1 1,2 1,2 2,1 2,1 1)),
+	  ((-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))</p></li><li><p>GEOMETRYCOLLECTION(POINT(2 3),LINESTRING((2 3,3 4)))</p></li></ul></div><p>The OpenGIS specification also requires that the
+        internal storage format of spatial objects include a spatial
+        referencing system identifier (SRID). The SRID is required when
+        creating spatial objects for insertion into the database.</p><p>
+Input/Output of these formats are available using the following
+interfaces:
+</p><pre class="programlisting">
+	bytea WKB = asBinary(geometry);
+	text WKT = asText(geometry);
+	geometry = GeomFromWKB(bytea WKB, SRID); 
+	geometry = GeometryFromText(text WKT, SRID);
+	</pre><p> For example, a valid insert statement to create and insert an OGC spatial object would be:</p><pre class="programlisting">
+	INSERT INTO SPATIALTABLE ( 
+		  THE_GEOM, 
+		  THE_NAME 
+	) 
+	VALUES ( 
+		  GeomFromText('POINT(-126.4 45.32)', 312), 
+		  'A Place' 
+	)</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2650222"></a>4.1.2. PostGIS EWKB, EWKT and Canonical Forms</h3></div></div><div></div></div><p>
+OGC formats only support 2d geometries, and the associated SRID
+is *never* embedded in the input/output representations.
+</p><p>
+Postgis extended formats are currently superset of OGC one (every
+valid WKB/WKT is a valid EWKB/EWKT) but this might vary in the
+future, specifically if OGC comes out with a new format conflicting
+with our extensions. Thus you SHOULD NOT rely on this feature!
+</p><p>
+Postgis EWKB/EWKT add 3dm,3dz,4d coordinates support and embedded
+SRID information.
+</p><p>Examples of the text representations (EWKT) of the
+      extended spatial objects of the features are as follows:</p><div class="itemizedlist"><ul type="disc"><li><p>POINT(0 0 0) -- XYZ</p></li><li><p>SRID=32632;POINT(0 0) -- XY with SRID</p></li><li><p>POINTM(0 0 0) -- XYM</p></li><li><p>POINT(0 0 0 0) -- XYZM</p></li><li><p>SRID=4326;MULTIPOINTM(0 0 0,1 2 1) -- XYM with SRID</p></li><li><p>MULTILINESTRING((0 0 0,1 1 0,1 2 1),(2 3 1,3 2 1,5 4
+          1))</p></li><li><p>POLYGON((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2 0,1 2
+          0,1 1 0))</p></li><li><p>MULTIPOLYGON(((0 0 0,4 0 0,4 4 0,0 4 0,0 0 0),(1 1 0,2 1 0,2 2
+          0,1 2 0,1 1 0)),((-1 -1 0,-1 -2 0,-2 -2 0,-2 -1 0,-1 -1 0)))</p></li><li><p>GEOMETRYCOLLECTIONM(POINTM(2 3 9),LINESTRINGM((2 3 4,3 4
+          5)))</p></li></ul></div><p>
+Input/Output of these formats are available using the following
+interfaces:
+</p><pre class="programlisting">
+	bytea EWKB = asEWKB(geometry);
+	text EWKT = asEWKT(geometry);
+	geometry = GeomFromEWKB(bytea EWKB);
+	geometry = GeomFromEWKT(text EWKT);
+	</pre><p>
+For example, a valid insert statement to create and insert a PostGIS spatial object would be:
+</p><pre class="programlisting">
+	INSERT INTO SPATIALTABLE ( 
+		  THE_GEOM, 
+		  THE_NAME 
+	) 
+	VALUES ( 
+		  GeomFromEWKT('SRID=312;POINTM(-126.4 45.32 15)'), 
+		  'A Place' 
+	)</pre><p>
+The "canonical forms" of a PostgreSQL type are the representations
+you get with a simple query (without any function call) and the one
+which is guaranteed to be accepted with a simple insert, update or
+copy. For the postgis 'geometry' type these are:
+
+	</p><pre class="programlisting">
+	- Output -
+	binary: EWKB
+	 ascii: HEXEWKB (EWKB in hex form)
+
+	- Input -
+	binary: EWKB
+	 ascii: HEXEWKB|EWKT
+	</pre><p>
+</p><p>
+For example this statement reads EWKT and returns HEXEWKB in the
+process of canonical ascii input/output:
+</p><pre class="programlisting">
+	=# SELECT 'SRID=4;POINT(0 0)'::geometry;
+			      geometry
+	----------------------------------------------------
+	 01010000200400000000000000000000000000000000000000
+	(1 row)
+	</pre></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2650378"></a>4.2. Using OpenGIS Standards</h2></div></div><div></div></div><p>The OpenGIS "Simple Features Specification for SQL" defines
+      standard GIS object types, the functions required to manipulate them,
+      and a set of meta-data tables. In order to ensure that meta-data remain
+      consistent, operations such as creating and removing a spatial column
+      are carried out through special procedures defined by OpenGIS.</p><p>There are two OpenGIS meta-data tables:
+      <tt class="varname">SPATIAL_REF_SYS</tt> and
+      <tt class="varname">GEOMETRY_COLUMNS</tt>. The
+      <tt class="varname">SPATIAL_REF_SYS</tt> table holds the numeric IDs and
+      textual descriptions of coordinate systems used in the spatial
+      database.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2650411"></a>4.2.1. The SPATIAL_REF_SYS Table</h3></div></div><div></div></div><p>The <tt class="varname">SPATIAL_REF_SYS</tt> table definition is as
+        follows:</p><pre class="programlisting">CREATE TABLE SPATIAL_REF_SYS ( 
+  SRID INTEGER NOT NULL PRIMARY KEY, 
+  AUTH_NAME VARCHAR(256), 
+  AUTH_SRID INTEGER, 
+  SRTEXT VARCHAR(2048), 
+  PROJ4TEXT VARCHAR(2048)
+)</pre><p>The <tt class="varname">SPATIAL_REF_SYS</tt> columns are as
+        follows:</p><div class="variablelist"><dl><dt><span class="term">SRID</span></dt><dd><p>An integer value that uniquely identifies the Spatial
+              Referencing System (SRS) within the database.</p></dd><dt><span class="term">AUTH_NAME</span></dt><dd><p>The name of the standard or standards body that is being
+              cited for this reference system. For example, "EPSG" would be a
+              valid <tt class="varname">AUTH_NAME</tt>.</p></dd><dt><span class="term">AUTH_SRID</span></dt><dd><p>The ID of the Spatial Reference System as defined by the
+              Authority cited in the <tt class="varname">AUTH_NAME</tt>. In the case
+              of EPSG, this is where the EPSG projection code would go.</p></dd><dt><span class="term">SRTEXT</span></dt><dd><p>The Well-Known Text representation of the Spatial
+              Reference System. An example of a WKT SRS representation
+              is:</p><pre class="programlisting">PROJCS["NAD83 / UTM Zone 10N", 
+  GEOGCS["NAD83",
+    DATUM["North_American_Datum_1983", 
+      SPHEROID["GRS 1980",6378137,298.257222101]
+    ], 
+    PRIMEM["Greenwich",0], 
+    UNIT["degree",0.0174532925199433] 
+  ],
+  PROJECTION["Transverse_Mercator"], 
+  PARAMETER["latitude_of_origin",0],
+  PARAMETER["central_meridian",-123], 
+  PARAMETER["scale_factor",0.9996],
+  PARAMETER["false_easting",500000], 
+  PARAMETER["false_northing",0],
+  UNIT["metre",1] 
+]</pre><p>For a listing of EPSG projection codes and their
+              corresponding WKT representations, see <a href="http://www.opengis.org/techno/interop/EPSG2WKT.TXT" target="_top">http://www.opengis.org/techno/interop/EPSG2WKT.TXT</a>.
+              For a discussion of WKT in general, see the OpenGIS "Coordinate
+              Transformation Services Implementation Specification" at <a href="http://www.opengis.org/techno/specs.htm" target="_top">http://www.opengis.org/techno/specs.htm</a>.
+              For information on the European Petroleum Survey Group (EPSG)
+              and their database of spatial reference systems, see <a href="http://epsg.org" target="_top">http://epsg.org</a>.</p></dd><dt><span class="term">PROJ4TEXT</span></dt><dd><p>PostGIS uses the Proj4 library to provide coordinate
+              transformation capabilities. The <tt class="varname">PROJ4TEXT</tt>
+              column contains the Proj4 coordinate definition string for a
+              particular SRID. For example:</p><pre class="programlisting">+proj=utm +zone=10 +ellps=clrk66 +datum=NAD27 +units=m</pre><p>For more information about, see the Proj4 web site at
+              <a href="http://www.remotesensing.org/proj" target="_top">http://www.remotesensing.org/proj</a>.
+              The <tt class="filename">spatial_ref_sys.sql</tt> file contains both
+              <tt class="varname">SRTEXT</tt> and <tt class="varname">PROJ4TEXT</tt>
+              definitions for all EPSG projections.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2650620"></a>4.2.2. The GEOMETRY_COLUMNS Table</h3></div></div><div></div></div><p>The <tt class="varname">GEOMETRY_COLUMNS</tt> table definition is as
+        follows:</p><pre class="programlisting">CREATE TABLE GEOMETRY_COLUMNS ( 
+  F_TABLE_CATALOG VARCHAR(256) NOT NULL, 
+  F_TABLE_SCHEMA VARCHAR(256) NOT NULL, 
+  F_TABLE_NAME VARCHAR(256) NOT NULL, 
+  F_GEOMETRY_COLUMN VARCHAR(256) NOT NULL,
+  COORD_DIMENSION INTEGER NOT NULL, 
+  SRID INTEGER NOT NULL, 
+  TYPE VARCHAR(30) NOT NULL 
+)</pre><p>The columns are as follows:</p><div class="variablelist"><dl><dt><span class="term">F_TABLE_CATALOG, F_TABLE_SCHEMA, F_TABLE_NAME</span></dt><dd><p>The fully qualified name of the feature table containing
+              the geometry column. Note that the terms "catalog" and "schema"
+              are Oracle-ish. There is not PostgreSQL analogue of "catalog" so
+              that column is left blank -- for "schema" the PostgreSQL schema
+              name is used (<tt class="varname">public</tt> is the default).</p></dd><dt><span class="term">F_GEOMETRY_COLUMN</span></dt><dd><p>The name of the geometry column in the feature
+              table.</p></dd><dt><span class="term">COORD_DIMENSION</span></dt><dd><p>The spatial dimension (2, 3 or 4 dimensional) of the
+              column.</p></dd><dt><span class="term">SRID</span></dt><dd><p>The ID of the spatial reference system used for the
+              coordinate geometry in this table. It is a foreign key reference
+              to the <tt class="varname">SPATIAL_REF_SYS</tt>.</p></dd><dt><span class="term">TYPE</span></dt><dd><p>The type of the spatial object. To restrict the spatial
+              column to a single type, use one of: POINT, LINESTRING, POLYGON,
+              MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION or
+	      corresponding XYM versions POINTM, LINESTRINGM, POLYGONM,
+	      MULTIPOINTM, MULTILINESTRINGM, MULTIPOLYGONM, GEOMETRYCOLLECTIONM.
+              For heterogeneous (mixed-type) collections, you can use
+              "GEOMETRY" as the type.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This attribute is (probably) not part of the OpenGIS
+                specification, but is required for ensuring type
+                homogeneity.</p></div></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2650754"></a>4.2.3. Creating a Spatial Table</h3></div></div><div></div></div><p>Creating a table with spatial data is done in two stages:</p><div class="itemizedlist"><ul type="disc"><li><p>Create a normal non-spatial table.</p><p>For example: <span><b class="command">CREATE TABLE ROADS_GEOM ( ID int4,
+            NAME varchar(25) )</b></span></p></li><li><p>Add a spatial column to the table using the OpenGIS
+            "AddGeometryColumn" function.</p><p>The syntax is:
+            </p><pre class="programlisting">AddGeometryColumn(&lt;schema_name&gt;, &lt;table_name&gt;,
+            &lt;column_name&gt;, &lt;srid&gt;, &lt;type&gt;,
+            &lt;dimension&gt;)</pre><p>
+
+	    Or, using current schema:
+            </p><pre class="programlisting">AddGeometryColumn(&lt;table_name&gt;,
+            &lt;column_name&gt;, &lt;srid&gt;, &lt;type&gt;,
+            &lt;dimension&gt;)</pre><p>
+	    </p><p>Example1: <span><b class="command">SELECT AddGeometryColumn('public',
+            'roads_geom', 'geom', 423, 'LINESTRING', 2)</b></span></p><p>Example2: <span><b class="command">SELECT AddGeometryColumn(
+            'roads_geom', 'geom', 423, 'LINESTRING', 2)</b></span></p></li></ul></div><p>Here is an example of SQL used to create a table and add a
+        spatial column (assuming that an SRID of 128
+        exists already):</p><pre class="programlisting">CREATE TABLE parks ( PARK_ID int4, PARK_NAME varchar(128), PARK_DATE date, PARK_TYPE varchar(2) );
+SELECT AddGeometryColumn('parks', 'park_geom', 128, 'MULTIPOLYGON', 2 );</pre><p>Here is another example, using the generic "geometry" type and
+        the undefined SRID value of -1:</p><pre class="programlisting">CREATE TABLE roads ( ROAD_ID int4, ROAD_NAME varchar(128) ); 
+SELECT AddGeometryColumn( 'roads', 'roads_geom', -1, 'GEOMETRY', 3 );</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2650861"></a>4.2.4. Ensuring OpenGIS compliancy of geometries</h3></div></div><div></div></div><p>Most of the functions implemented by the GEOS library
+	rely on the assumption that your geometries are valid
+        as specified by the OpenGIS Simple Feature Specification.
+	To check validity of geometries you can use the
+	<a href="#IsValid">IsValid()</a> function:</p><pre class="programlisting">gisdb=# select isvalid('LINESTRING(0 0, 1 1)'), isvalid('LINESTRING(0 0,0 0)');
+ isvalid | isvalid
+---------+---------
+ t       | f</pre><p>By default, PostGIS does not apply this validity check on geometry input, because
+        testing for validity needs lots of CPU time for complex geometries, especially polygons.
+        If you do not trust your data sources, you can manually enforce such a check to your tables
+        by adding a check constraint:</p><pre class="programlisting">ALTER TABLE mytable ADD CONSTRAINT geometry_valid_check CHECK (isvalid(the_geom));</pre><p>If you encounter any strange error messages such as "GEOS Intersection() threw an 
+        error!" or "JTS Intersection() threw an error!" when calling PostGIS functions with valid
+        input geometries, you likely found an error in either PostGIS or one of the libraries it
+        uses, and you should contact the PostGIS developers. The same is true if a PostGIS function returns
+        an invalid geometry for valid input.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+	Strictly compliant OGC geometries cannot have Z or M values.
+	The <a href="#IsValid">IsValid()</a> function won't
+	consider higher dimensioned geometries invalid! Invocations
+	of <a href="#AddGeometryColumn">AddGeometryColumn()</a>
+        will add a constraint checking geometry dimensions, so it is
+        enough to specify 2 there.
+	</p></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2650951"></a>4.3. Loading GIS Data</h2></div></div><div></div></div><p>Once you have created a spatial table, you are ready to upload GIS
+      data to the database. Currently, there are two ways to get data into a
+      PostGIS/PostgreSQL database: using formatted SQL statements or using the
+      Shape file loader/dumper.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2650964"></a>4.3.1. Using SQL</h3></div></div><div></div></div><p>If you can convert your data to a text representation, then
+        using formatted SQL might be the easiest way to get your data into
+        PostGIS. As with Oracle and other SQL databases, data can be bulk
+        loaded by piping a large text file full of SQL "INSERT" statements
+        into the SQL terminal monitor.</p><p>A data upload file (<tt class="filename">roads.sql</tt> for example)
+        might look like this:</p><pre class="programlisting">BEGIN;
+INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (1,GeomFromText('LINESTRING(191232 243118,191108 243242)',-1),'Jeff Rd'); 
+INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (2,GeomFromText('LINESTRING(189141 244158,189265 244817)',-1),'Geordie Rd'); 
+INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (3,GeomFromText('LINESTRING(192783 228138,192612 229814)',-1),'Paul St'); 
+INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (4,GeomFromText('LINESTRING(189412 252431,189631 259122)',-1),'Graeme Ave'); 
+INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (5,GeomFromText('LINESTRING(190131 224148,190871 228134)',-1),'Phil Tce'); 
+INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES (6,GeomFromText('LINESTRING(198231 263418,198213 268322)',-1),'Dave Cres');
+COMMIT;</pre><p>The data file can be piped into PostgreSQL very easily using the
+        "psql" SQL terminal monitor:</p><pre class="programlisting">psql -d [database] -f roads.sql</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2651020"></a>4.3.2. Using the Loader</h3></div></div><div></div></div><p>The <tt class="filename">shp2pgsql</tt> data loader converts ESRI
+        Shape files into SQL suitable for insertion into a PostGIS/PostgreSQL
+        database. The loader has several operating modes distinguished by
+        command line flags:</p><div class="variablelist"><dl><dt><span class="term">-d</span></dt><dd><p>Drops the database table before creating a new table with
+              the data in the Shape file.</p></dd><dt><span class="term">-a</span></dt><dd><p>Appends data from the Shape file into the database table.
+              Note that to use this option to load multiple files, the files
+              must have the same attributes and same data types.</p></dd><dt><span class="term">-c</span></dt><dd><p>Creates a new table and populates it from the Shape file.
+              <span class="emphasis"><em>This is the default mode.</em></span></p></dd><dt><span class="term">-p</span></dt><dd><p>Only produces the table creation SQL code, without adding 
+              any actual data. This can be used if you need to completely
+              separate the table creation and data loading steps.</p></dd><dt><span class="term">-D</span></dt><dd><p>Use the PostgreSQL "dump" format for the output data. This 
+              can be combined with -a, -c and -d. It is much faster to load
+              than the default "insert" SQL format. Use this for very large data
+              sets.</p></dd><dt><span class="term">-s &lt;SRID&gt;</span></dt><dd><p>Creates and populates the geometry tables with the
+              specified SRID.</p></dd><dt><span class="term">-k</span></dt><dd><p>Keep identifiers' case (column, schema and attributes). Note that attributes in Shapefile are all UPPERCASE.</p></dd><dt><span class="term">-i</span></dt><dd><p>Coerce all integers to standard 32-bit integers, do not
+              create 64-bit bigints, even if the DBF header signature appears
+              to warrant it.</p></dd><dt><span class="term">-I</span></dt><dd><p>Create a GiST index on the geometry column.</p></dd><dt><span class="term">-w</span></dt><dd><p>
+       	      Output WKT format, for use with older (0.x) versions of PostGIS.
+              Note  that this will introduce coordinate drifts and will drop M
+              values from shapefiles.
+              </p></dd><dt><span class="term">-W &lt;encoding&gt;</span></dt><dd><p>
+Specify encoding of the input data (dbf file).
+When used, all attributes of the dbf are converted from the specified
+encoding to UTF8. The resulting SQL output will contain a <tt class="code">SET
+CLIENT_ENCODING to UTF8</tt> command, so that the backend will be able
+to reconvert from UTF8 to whatever encoding the database is configured
+to use internally.
+		</p></dd></dl></div><p>Note that -a, -c, -d and -p are mutually exclusive.</p><p>An example session using the loader to create an input file and
+        uploading it might look like this:</p><pre class="programlisting"># shp2pgsql shaperoads myschema.roadstable &gt; roads.sql 
+# psql -d roadsdb -f roads.sql</pre><p>A conversion and upload can be done all in one step using UNIX
+        pipes:</p><pre class="programlisting"># shp2pgsql shaperoads myschema.roadstable | psql -d roadsdb</pre></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2651250"></a>4.4. Retrieving GIS Data</h2></div></div><div></div></div><p>Data can be extracted from the database using either SQL or the
+      Shape file loader/dumper. In the section on SQL we will discuss some of
+      the operators available to do comparisons and queries on spatial
+      tables.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2651263"></a>4.4.1. Using SQL</h3></div></div><div></div></div><p>The most straightforward means of pulling data out of the
+        database is to use a SQL select query and dump the resulting columns
+        into a parsable text file:</p><pre class="programlisting">db=# SELECT id, AsText(geom) AS geom, name FROM ROADS_GEOM; 
+id | geom                                    | name 
+---+-----------------------------------------+-----------
+ 1 | LINESTRING(191232 243118,191108 243242) | Jeff Rd  
+ 2 | LINESTRING(189141 244158,189265 244817) | Geordie Rd 
+ 3 | LINESTRING(192783 228138,192612 229814) | Paul St 
+ 4 | LINESTRING(189412 252431,189631 259122) | Graeme Ave 
+ 5 | LINESTRING(190131 224148,190871 228134) | Phil Tce 
+ 6 | LINESTRING(198231 263418,198213 268322) | Dave Cres 
+ 7 | LINESTRING(218421 284121,224123 241231) | Chris Way 
+(6 rows)</pre><p>However, there will be times when some kind of restriction is
+        necessary to cut down the number of fields returned. In the case of
+        attribute-based restrictions, just use the same SQL syntax as normal
+        with a non-spatial table. In the case of spatial restrictions, the
+        following operators are available/useful:</p><div class="variablelist"><dl><dt><span class="term">&amp;&amp;</span></dt><dd><p>This operator tells whether the bounding box of one
+              geometry intersects the bounding box of another.</p></dd><dt><span class="term">~=</span></dt><dd><p>This operators tests whether two geometries are
+              geometrically identical. For example, if 'POLYGON((0 0,1 1,1 0,0
+              0))' is the same as 'POLYGON((0 0,1 1,1 0,0 0))' (it is).</p></dd><dt><span class="term">=</span></dt><dd><p>This operator is a little more naive, it only tests
+              whether the bounding boxes of to geometries are the same.</p></dd></dl></div><p>Next, you can use these operators in queries. Note that when
+        specifying geometries and boxes on the SQL command line, you must
+        explicitly turn the string representations into geometries by using
+        the "GeomFromText()" function. So, for example:</p><pre class="programlisting">SELECT 
+  ID, NAME 
+FROM ROADS_GEOM 
+WHERE 
+  GEOM ~= GeomFromText('LINESTRING(191232 243118,191108 243242)',-1);</pre><p>The above query would return the single record from the
+        "ROADS_GEOM" table in which the geometry was equal to that
+        value.</p><p>When using the "&amp;&amp;" operator, you can specify either a
+        BOX3D as the comparison feature or a GEOMETRY. When you specify a
+        GEOMETRY, however, its bounding box will be used for the
+        comparison.</p><pre class="programlisting">SELECT 
+  ID, NAME 
+FROM ROADS_GEOM 
+WHERE 
+  GEOM &amp;&amp; GeomFromText('POLYGON((191232 243117,191232 243119,191234 243117,191232 243117))',-1);</pre><p>The above query will use the bounding box of the polygon for
+        comparison purposes.</p><p>The most common spatial query will probably be a "frame-based"
+        query, used by client software, like data browsers and web mappers, to
+        grab a "map frame" worth of data for display. Using a "BOX3D" object
+        for the frame, such a query looks like this:</p><pre class="programlisting">SELECT 
+  AsText(GEOM) AS GEOM 
+FROM ROADS_GEOM 
+WHERE 
+  GEOM &amp;&amp; SetSRID('BOX3D(191232 243117,191232 243119)'::box3d,-1);</pre><p>Note the use of the SRID, to specify the projection of the
+        BOX3D. The value -1 is used to indicate no specified SRID.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2651429"></a>4.4.2. Using the Dumper</h3></div></div><div></div></div><p>The <tt class="filename">pgsql2shp</tt> table dumper connects
+        directly to the database and converts a table (possibly defined by
+	a query) into a shape file. The
+        basic syntax is:</p><pre class="programlisting">pgsql2shp [&lt;options&gt;] &lt;database&gt; [&lt;schema&gt;.]&lt;table&gt;</pre><pre class="programlisting">pgsql2shp [&lt;options&gt;] &lt;database&gt; &lt;query&gt;</pre><p>The commandline options are:</p><div class="variablelist"><dl><dt><span class="term">-f &lt;filename&gt;</span></dt><dd><p>Write the output to a particular filename.</p></dd><dt><span class="term">-h &lt;host&gt;</span></dt><dd><p>The database host to connect to.</p></dd><dt><span class="term">-p &lt;port&gt;</span></dt><dd><p>The port to connect to on the database host.</p></dd><dt><span class="term">-P &lt;password&gt;</span></dt><dd><p>The password to use when connecting to the
+              database.</p></dd><dt><span class="term">-u &lt;user&gt;</span></dt><dd><p>The username to use when connecting to the
+              database.</p></dd><dt><span class="term">-g &lt;geometry column&gt;</span></dt><dd><p>In the case of tables with multiple geometry columns, the
+              geometry column to use when writing the shape file.</p></dd><dt><span class="term">-b</span></dt><dd><p>Use a binary cursor. This will make the operation faster,
+	      but will not work if any NON-geometry attribute in the table
+	      lacks a cast to text.</p></dd><dt><span class="term">-r</span></dt><dd><p>Raw mode. Do not drop the <tt class="varname">gid</tt> field, or
+              escape column names.</p></dd><dt><span class="term">-d</span></dt><dd><p>For backward compatibility: write a 3-dimensional shape
+	      file when dumping from old (pre-1.0.0) postgis databases (the
+	      default is to write a 2-dimensional shape file in that case).
+	      Starting from postgis-1.0.0+, dimensions are fully encoded.
+	      </p></dd></dl></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2651607"></a>4.5. Building Indexes</h2></div></div><div></div></div><p>Indexes are what make using a spatial database for large data sets
+      possible. Without indexing, any search for a feature would require a
+      "sequential scan" of every record in the database. Indexing speeds up
+      searching by organizing the data into a search tree which can be quickly
+      traversed to find a particular record. PostgreSQL supports three kinds
+      of indexes by default: B-Tree indexes, R-Tree indexes, and GiST
+      indexes.</p><div class="itemizedlist"><ul type="disc"><li><p>B-Trees are used for data which can be sorted along one axis;
+          for example, numbers, letters, dates. GIS data cannot be rationally
+          sorted along one axis (which is greater, (0,0) or (0,1) or (1,0)?)
+          so B-Tree indexing is of no use for us.</p></li><li><p>R-Trees break up data into rectangles, and sub-rectangles, and
+          sub-sub rectangles, etc. R-Trees are used by some spatial databases
+          to index GIS data, but the PostgreSQL R-Tree implementation is not
+          as robust as the GiST implementation.</p></li><li><p>GiST (Generalized Search Trees) indexes break up data into
+          "things to one side", "things which overlap", "things which are
+          inside" and can be used on a wide range of data-types, including GIS
+          data. PostGIS uses an R-Tree index implemented on top of GiST to
+          index GIS data.</p></li></ul></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2651660"></a>4.5.1. GiST Indexes</h3></div></div><div></div></div><p>GiST stands for "Generalized Search Tree" and is a generic form
+        of indexing. In addition to GIS indexing, GiST is used to speed up
+        searches on all kinds of irregular data structures (integer arrays,
+        spectral data, etc) which are not amenable to normal B-Tree
+        indexing.</p><p>Once a GIS data table exceeds a few thousand rows, you will want
+        to build an index to speed up spatial searches of the data (unless all
+        your searches are based on attributes, in which case you'll want to
+        build a normal index on the attribute fields).</p><p>The syntax for building a GiST index on a "geometry" column is
+        as follows:</p><pre class="programlisting">CREATE INDEX [indexname] ON [tablename] 
+  USING GIST ( [geometryfield] GIST_GEOMETRY_OPS ); </pre><p>Building a spatial index is a computationally intensive
+        exercise: on tables of around 1 million rows, on a 300MHz Solaris
+        machine, we have found building a GiST index takes about 1 hour. After
+        building an index, it is important to force PostgreSQL to collect
+        table statistics, which are used to optimize query plans:</p><pre class="programlisting">VACUUM ANALYZE [table_name] [column_name];
+
+-- This is only needed for PostgreSQL 7.4 installations and below
+SELECT UPDATE_GEOMETRY_STATS([table_name], [column_name]);</pre><p>GiST indexes have two advantages over R-Tree indexes in
+        PostgreSQL. Firstly, GiST indexes are "null safe", meaning they can
+        index columns which include null values. Secondly, GiST indexes
+        support the concept of "lossiness" which is important when dealing
+        with GIS objects larger than the PostgreSQL 8K page size. Lossiness
+        allows PostgreSQL to store only the "important" part of an object in
+        an index -- in the case of GIS objects, just the bounding box. GIS
+        objects larger than 8K will cause R-Tree indexes to fail in the
+        process of being built.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2651729"></a>4.5.2. Using Indexes</h3></div></div><div></div></div><p>Ordinarily, indexes invisibly speed up data access: once the
+        index is built, the query planner transparently decides when to use
+        index information to speed up a query plan. Unfortunately, the
+        PostgreSQL query planner does not optimize the use of GiST indexes
+        well, so sometimes searches which should use a spatial index instead
+        default to a sequence scan of the whole table.</p><p>If you find your spatial indexes are not being used (or your
+        attribute indexes, for that matter) there are a couple things you can
+        do:</p><div class="itemizedlist"><ul type="disc"><li><p>Firstly, make sure statistics are gathered about the number
+            and distributions of values in a table, to provide the query
+            planner with better information to make decisions around index
+            usage. For PostgreSQL 7.4 installations and below this is done by
+            running <span><b class="command">update_geometry_stats([table_name,
+            column_name])</b></span> (compute distribution) and <span><b class="command">VACUUM
+            ANALYZE [table_name] [column_name]</b></span> (compute number of
+            values). Starting with PostgreSQL 8.0 running <span><b class="command">VACUUM
+            ANALYZE</b></span> will do both operations. You should regularly
+            vacuum your databases anyways -- many PostgreSQL DBAs have
+            <span><b class="command">VACUUM</b></span> run as an off-peak cron job on a regular
+            basis.</p></li><li><p>If vacuuming does not work, you can force the planner to use
+            the index information by using the <span><b class="command">SET
+            ENABLE_SEQSCAN=OFF</b></span> command. You should only use this
+            command sparingly, and only on spatially indexed queries:
+            generally speaking, the planner knows better than you do about
+            when to use normal B-Tree indexes. Once you have run your query,
+            you should consider setting <tt class="varname">ENABLE_SEQSCAN</tt> back
+            on, so that other queries will utilize the planner as
+            normal.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>As of version 0.6, it should not be necessary to force the
+              planner to use the index with
+              <tt class="varname">ENABLE_SEQSCAN</tt>.</p></div></li><li><p>If you find the planner wrong about the cost of sequential
+            vs index scans try reducing the value of random_page_cost in
+            postgresql.conf or using SET random_page_cost=#. Default value for
+            the parameter is 4, try setting it to 1 or 2. Decrementing the
+            value makes the planner more inclined of using Index scans.</p></li></ul></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2651847"></a>4.6. Complex Queries</h2></div></div><div></div></div><p>The <span class="emphasis"><em>raison d'etre</em></span> of spatial database
+      functionality is performing queries inside the database which would
+      ordinarily require desktop GIS functionality. Using PostGIS effectively
+      requires knowing what spatial functions are available, and ensuring that
+      appropriate indexes are in place to provide good performance.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2651866"></a>4.6.1. Taking Advantage of Indexes</h3></div></div><div></div></div><p>When constructing a query it is important to remember that only
+        the bounding-box-based operators such as &amp;&amp; can take advantage
+        of the GiST spatial index. Functions such as
+        <tt class="varname">distance()</tt> cannot use the index to optimize their
+        operation. For example, the following query would be quite slow on a
+        large table:</p><pre class="programlisting">SELECT the_geom FROM geom_table
+WHERE distance( the_geom, GeomFromText( 'POINT(100000 200000)', -1 ) ) &lt; 100</pre><p>This query is selecting all the geometries in geom_table which
+        are within 100 units of the point (100000, 200000). It will be slow
+        because it is calculating the distance between each point in the table
+        and our specified point, ie. one <tt class="varname">distance()</tt>
+        calculation for each row in the table. We can avoid this by using the
+        &amp;&amp; operator to reduce the number of distance calculations
+        required:</p><pre class="programlisting">SELECT the_geom FROM geom_table
+WHERE the_geom &amp;&amp; 'BOX3D(90900 190900, 100100 200100)'::box3d
+  AND distance( the_geom, GeomFromText( 'POINT(100000 200000)', -1 ) ) &lt; 100</pre><p>This query selects the same geometries, but it does it in a more
+        efficient way. Assuming there is a GiST index on the_geom, the query
+        planner will recognize that it can use the index to reduce the number
+        of rows before calculating the result of the
+        <tt class="varname">distance()</tt> function. Notice that the
+        <tt class="varname">BOX3D</tt> geometry which is used in the &amp;&amp;
+        operation is a 200 unit square box centered on the original point -
+        this is our "query box". The &amp;&amp; operator uses the index to
+        quickly reduce the result set down to only those geometries which have
+        bounding boxes that overlap the "query box". Assuming that our query
+        box is much smaller than the extents of the entire geometry table,
+        this will drastically reduce the number of distance calculations that
+        need to be done.</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2651962"></a>4.6.2. Examples of Spatial SQL</h3></div></div><div></div></div><p>The examples in this section will make use of two tables, a
+        table of linear roads, and a table of polygonal municipality
+        boundaries. The table definitions for the <tt class="varname">bc_roads</tt>
+        table is:</p><pre class="programlisting">  Column    |       Type        |   Description
+------------+-------------------+-------------------
+ gid        | integer           | Unique ID
+ name       | character varying | Road Name
+ the_geom   | geometry          | Location Geometry (Linestring)</pre><p>The table definition for the <tt class="varname">bc_municipality</tt>
+        table is:</p><pre class="programlisting">  Column   |       Type        |   Description
+-----------+-------------------+-------------------
+ gid       | integer           | Unique ID
+ code      | integer           | Unique ID
+ name      | character varying | City / Town Name
+ the_geom  | geometry          | Location Geometry (Polygon)</pre><div class="qandaset"><dl><dt>4.6.2.1. <a href="#id2652008">What is the total length of all roads, expressed in
+                kilometers?</a></dt><dt>4.6.2.2. <a href="#id2652035">How large is the city of Prince George, in
+                hectares?</a></dt><dt>4.6.2.3. <a href="#id2652064">What is the largest municipality in the province, by
+                area?</a></dt><dt>4.6.2.4. <a href="#id2652106">What is the length of roads fully contained within each
+                municipality?</a></dt><dt>4.6.2.5. <a href="#id2652168">Create a new table with all the roads within the city of
+                Prince George.</a></dt><dt>4.6.2.6. <a href="#id2652207">What is the length in kilometers of "Douglas St" in
+                Victoria?</a></dt><dt>4.6.2.7. <a href="#id2652241">What is the largest municipality polygon that has a
+                hole?</a></dt></dl><table border="0" summary="Q and A Set"><col align="left" width="1%"><tbody><tr class="question"><td align="left" valign="top"><a name="id2652008"></a><a name="id2652010"></a><b>4.6.2.1.</b></td><td align="left" valign="top"><p>What is the total length of all roads, expressed in
+                kilometers?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>You can answer this question with a very simple piece of
+                SQL:</p><pre class="programlisting">postgis=# SELECT sum(length(the_geom))/1000 AS km_roads FROM bc_roads;
+     km_roads
+------------------
+ 70842.1243039643
+(1 row)</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2652035"></a><a name="id2652038"></a><b>4.6.2.2.</b></td><td align="left" valign="top"><p>How large is the city of Prince George, in
+                hectares?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>This query combines an attribute condition (on the
+                municipality name) with a spatial calculation (of the
+                area):</p><pre class="programlisting">postgis=# SELECT area(the_geom)/10000 AS hectares FROM bc_municipality 
+          WHERE name = 'PRINCE GEORGE';
+     hectares
+------------------
+ 32657.9103824927
+(1 row) </pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2652064"></a><a name="id2652066"></a><b>4.6.2.3.</b></td><td align="left" valign="top"><p>What is the largest municipality in the province, by
+                area?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>This query brings a spatial measurement into the query
+                condition. There are several ways of approaching this problem,
+                but the most efficient is below:</p><pre class="programlisting">postgis=# SELECT name, area(the_geom)/10000 AS hectares 
+          FROM bc_municipality 
+          ORDER BY hectares DESC 
+          LIMIT 1;
+     name      |    hectares
+---------------+-----------------
+ TUMBLER RIDGE | 155020.02556131
+(1 row)</pre><p>Note that in order to answer this query we have to
+                calculate the area of every polygon. If we were doing this a
+                lot it would make sense to add an area column to the table
+                that we could separately index for performance. By ordering
+                the results in a descending direction, and them using the
+                PostgreSQL "LIMIT" command we can easily pick off the largest
+                value without using an aggregate function like max().</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2652106"></a><a name="id2652108"></a><b>4.6.2.4.</b></td><td align="left" valign="top"><p>What is the length of roads fully contained within each
+                municipality?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>This is an example of a "spatial join", because we are
+                bringing together data from two tables (doing a join) but
+                using a spatial interaction condition ("contained") as the
+                join condition rather than the usual relational approach of
+                joining on a common key:</p><pre class="programlisting">postgis=# SELECT m.name, sum(length(r.the_geom))/1000 as roads_km 
+          FROM bc_roads AS r,bc_municipality AS m 
+          WHERE r.the_geom &amp;&amp; m.the_geom 
+          AND contains(m.the_geom,r.the_geom) 
+          GROUP BY m.name 
+          ORDER BY roads_km;
+
+            name            |     roads_km
+----------------------------+------------------
+ SURREY                     | 1539.47553551242
+ VANCOUVER                  | 1450.33093486576
+ LANGLEY DISTRICT           | 833.793392535662
+ BURNABY                    | 773.769091404338
+ PRINCE GEORGE              |  694.37554369147
+ ...</pre><p>This query takes a while, because every road in the
+                table is summarized into the final result (about 250K roads
+                for our particular example table). For smaller overlays
+                (several thousand records on several hundred) the response can
+                be very fast.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2652168"></a><a name="id2652170"></a><b>4.6.2.5.</b></td><td align="left" valign="top"><p>Create a new table with all the roads within the city of
+                Prince George.</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>This is an example of an "overlay", which takes in two
+                tables and outputs a new table that consists of spatially
+                clipped or cut resultants. Unlike the "spatial join"
+                demonstrated above, this query actually creates new
+                geometries. An overlay is like a turbo-charged spatial join,
+                and is useful for more exact analysis work:</p><pre class="programlisting">postgis=# CREATE TABLE pg_roads as
+          SELECT intersection(r.the_geom, m.the_geom) AS intersection_geom, 
+                 length(r.the_geom) AS rd_orig_length, 
+                 r.* 
+          FROM bc_roads AS r, bc_municipality AS m 
+          WHERE r.the_geom &amp;&amp; m.the_geom 
+          AND intersects(r.the_geom, m.the_geom) 
+          AND m.name = 'PRINCE GEORGE';</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2652207"></a><a name="id2652209"></a><b>4.6.2.6.</b></td><td align="left" valign="top"><p>What is the length in kilometers of "Douglas St" in
+                Victoria?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><pre class="programlisting">postgis=# SELECT sum(length(r.the_geom))/1000 AS kilometers 
+          FROM bc_roads r, bc_municipality m 
+          WHERE r.the_geom &amp;&amp; m.the_geom 
+          AND r.name = 'Douglas St' 
+          AND m.name = 'VICTORIA';
+    kilometers
+------------------
+ 4.89151904172838
+(1 row)</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2652241"></a><a name="id2652243"></a><b>4.6.2.7.</b></td><td align="left" valign="top"><p>What is the largest municipality polygon that has a
+                hole?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><pre class="programlisting">postgis=# SELECT gid, name, area(the_geom) AS area 
+          FROM bc_municipality 
+          WHERE nrings(the_geom) &gt; 1 
+          ORDER BY area DESC LIMIT 1;
+ gid |     name     |       area
+-----+--------------+------------------
+  12 | SPALLUMCHEEN | 257374619.430216
+(1 row)</pre></td></tr></tbody></table></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2652277"></a>4.7. Using Mapserver</h2></div></div><div></div></div><p>The Minnesota Mapserver is an internet web-mapping server which
+      conforms to the OpenGIS Web Mapping Server specification.</p><div class="itemizedlist"><ul type="disc"><li><p>The Mapserver homepage is at <a href="http://mapserver.gis.umn.edu" target="_top">http://mapserver.gis.umn.edu</a>.</p></li><li><p>The OpenGIS Web Map Specification is at <a href="http://www.opengis.org/techno/specs/01-047r2.pdf" target="_top">http://www.opengis.org/techno/specs/01-047r2.pdf</a>.</p></li></ul></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2652320"></a>4.7.1. Basic Usage</h3></div></div><div></div></div><p>To use PostGIS with Mapserver, you will need to know about how
+        to configure Mapserver, which is beyond the scope of this
+        documentation. This section will cover specific PostGIS issues and
+        configuration details.</p><p>To use PostGIS with Mapserver, you will need:</p><div class="itemizedlist"><ul type="disc"><li><p>Version 0.6 or newer of PostGIS.</p></li><li><p>Version 3.5 or newer of Mapserver.</p></li></ul></div><p>Mapserver accesses PostGIS/PostgreSQL data like any other
+        PostgreSQL client -- using <tt class="filename">libpq</tt>. This means that
+        Mapserver can be installed on any machine with network access to the
+        PostGIS server, as long as the system has the
+        <tt class="filename">libpq</tt> PostgreSQL client libraries.</p><div class="orderedlist"><ol type="1"><li><p>Compile and install Mapserver, with whatever options you
+            desire, including the "--with-postgis" configuration
+            option.</p></li><li><p>In your Mapserver map file, add a PostGIS layer. For
+            example:</p><pre class="programlisting">LAYER
+  CONNECTIONTYPE postgis
+  NAME "widehighways"
+  # Connect to a remote spatial database
+  CONNECTION "user=dbuser dbname=gisdatabase host=bigserver"
+  # Get the lines from the 'geom' column of the 'roads' table
+  DATA "geom from roads"
+  STATUS ON
+  TYPE LINE
+  # Of the lines in the extents, only render the wide highways
+  FILTER "type = 'highway' and numlanes &gt;= 4"
+  CLASS
+    # Make the superhighways brighter and 2 pixels wide
+    EXPRESSION ([numlanes] &gt;= 6)
+    COLOR 255 22 22      
+    SYMBOL "solid"
+    SIZE 2
+  END
+  CLASS
+    # All the rest are darker and only 1 pixel wide
+    EXPRESSION ([numlanes] &lt; 6)
+    COLOR 205 92 82      
+  END
+END</pre><p>In the example above, the PostGIS-specific directives are as
+            follows:</p><div class="variablelist"><dl><dt><span class="term">CONNECTIONTYPE</span></dt><dd><p>For PostGIS layers, this is always "postgis".</p></dd><dt><span class="term">CONNECTION</span></dt><dd><p>The database connection is governed by the a
+                  'connection string' which is a standard set of keys and
+                  values like this (with the default values in
+                  &lt;&gt;):</p><p>user=&lt;username&gt; password=&lt;password&gt;
+                  dbname=&lt;username&gt; hostname=&lt;server&gt;
+                  port=&lt;5432&gt;</p><p>An empty connection string is still valid, and any of
+                  the key/value pairs can be omitted. At a minimum you will
+                  generally supply the database name and username to connect
+                  with.</p></dd><dt><span class="term">DATA</span></dt><dd><p>The form of this parameter is "&lt;column&gt; from
+                  &lt;tablename&gt;" where the column is the spatial column to
+                  be rendered to the map.</p></dd><dt><span class="term">FILTER</span></dt><dd><p>The filter must be a valid SQL string corresponding to
+                  the logic normally following the "WHERE" keyword in a SQL
+                  query. So, for example, to render only roads with 6 or more
+                  lanes, use a filter of "num_lanes &gt;= 6".</p></dd></dl></div></li><li><p>In your spatial database, ensure you have spatial (GiST)
+            indexes built for any the layers you will be drawing.</p><pre class="programlisting">CREATE INDEX [indexname]
+  ON [tablename] 
+  USING GIST ( [geometrycolumn] GIST_GEOMETRY_OPS );</pre></li><li><p>If you will be querying your layers using Mapserver you will
+            also need an "oid index".</p><p>Mapserver requires unique identifiers for each spatial
+            record when doing queries, and the PostGIS module of Mapserver
+            uses the PostgreSQL <tt class="varname">oid</tt> value to provide these
+            unique identifiers. A side-effect of this is that in order to do
+            fast random access of records during queries, an index on the
+            <tt class="varname">oid</tt> is needed.</p><p>To build an "oid index", use the following SQL:</p><pre class="programlisting">CREATE INDEX [indexname] ON [tablename] ( oid );</pre></li></ol></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2652568"></a>4.7.2. Frequently Asked Questions</h3></div></div><div></div></div><div class="qandaset"><dl><dt>4.7.2.1. <a href="#id2652576">When I use an EXPRESSION in my map
+                file, the condition never returns as true, even though I know
+                the values exist in my table.</a></dt><dt>4.7.2.2. <a href="#id2652610">The FILTER I use for my Shape files is not working for
+                my PostGIS table of the same data.</a></dt><dt>4.7.2.3. <a href="#id2652639">My PostGIS layer draws much slower than my Shape file
+                layer, is this normal?</a></dt><dt>4.7.2.4. <a href="#id2652677">My PostGIS layer draws fine, but queries are really
+                slow. What is wrong?</a></dt></dl><table border="0" summary="Q and A Set"><col align="left" width="1%"><tbody><tr class="question"><td align="left" valign="top"><a name="id2652576"></a><a name="id2652578"></a><b>4.7.2.1.</b></td><td align="left" valign="top"><p>When I use an <tt class="varname">EXPRESSION</tt> in my map
+                file, the condition never returns as true, even though I know
+                the values exist in my table.</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>Unlike shape files, PostGIS field names have to be
+                referenced in EXPRESSIONS using <span class="emphasis"><em>lower
+                case</em></span>.</p><pre class="programlisting">EXPRESSION ([numlanes] &gt;= 6)</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2652610"></a><a name="id2652612"></a><b>4.7.2.2.</b></td><td align="left" valign="top"><p>The FILTER I use for my Shape files is not working for
+                my PostGIS table of the same data.</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>Unlike shape files, filters for PostGIS layers use SQL
+                syntax (they are appended to the SQL statement the PostGIS
+                connector generates for drawing layers in Mapserver).</p><pre class="programlisting">FILTER "type = 'highway' and numlanes &gt;= 4"</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2652639"></a><a name="id2652641"></a><b>4.7.2.3.</b></td><td align="left" valign="top"><p>My PostGIS layer draws much slower than my Shape file
+                layer, is this normal?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>In general, expect PostGIS layers to be 10% slower than
+                equivalent Shape files layers, due to the extra overhead
+                involved in database connections, data transformations and
+                data transit between the database and Mapserver.</p><p>If you are finding substantial draw performance
+                problems, it is likely that you have not build a spatial index
+                on your table.</p><pre class="programlisting">postgis# CREATE INDEX geotable_gix ON geotable USING GIST ( geocolumn );
+postgis# SELECT update_geometry_stats();  -- For PGSQL &lt; 8.0
+postgis# VACUUM ANALYZE;                  -- For PGSQL &gt;= 8.0</pre></td></tr><tr class="question"><td align="left" valign="top"><a name="id2652677"></a><a name="id2652679"></a><b>4.7.2.4.</b></td><td align="left" valign="top"><p>My PostGIS layer draws fine, but queries are really
+                slow. What is wrong?</p></td></tr><tr class="answer"><td align="left" valign="top"><b></b></td><td align="left" valign="top"><p>For queries to be fast, you must have a unique key for
+                your spatial table and you must have an index on that unique
+                key.</p><p>You can specify what unique key for mapserver to use
+                with the <tt class="varname">USING UNIQUE</tt> clause in your
+                <tt class="varname">DATA</tt> line:</p><pre class="programlisting">DATA "the_geom FROM geotable USING UNIQUE gid"</pre><p>If your table does not have an explicit unique column,
+                you can "fake" a unique column by using the PostgreSQL row
+                "oid" for your unique column. "oid" is the default unique
+                column if you do not declare one, so enhancing your query
+                speed is a matter of building an index on your spatial table
+                oid value.</p><pre class="programlisting">postgis# CREATE INDEX geotable_oid_idx ON geotable (oid);</pre></td></tr></tbody></table></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2652735"></a>4.7.3. Advanced Usage</h3></div></div><div></div></div><p>The <tt class="varname">USING</tt> pseudo-SQL clause is used to add
+        some information to help mapserver understand the results of more
+        complex queries. More specifically, when either a view or a subselect
+        is used as the source table (the thing to the right of "FROM" in a
+        <tt class="varname">DATA</tt> definition) it is more difficult for mapserver
+        to automatically determine a unique identifier for each row and also
+        the SRID for the table. The <tt class="varname">USING</tt> clause can
+        provide mapserver with these two pieces of information as
+        follows:</p><pre class="programlisting">DATA "the_geom FROM (SELECT table1.the_geom AS the_geom, table1.oid AS oid, table2.data AS data
+ FROM table1 LEFT JOIN table2 ON table1.id = table2.id) AS new_table USING UNIQUE oid USING SRID=-1"</pre><div class="variablelist"><dl><dt><span class="term">USING UNIQUE &lt;uniqueid&gt;</span></dt><dd><p>Mapserver requires a unique id for each row in order to
+              identify the row when doing map queries. Normally, it would use
+              the oid as the unique identifier, but views and subselects don't
+              automatically have an oid column. If you want to use Mapserver's
+              query functionality, you need to add a unique column to your
+              view or subselect, and declare it with <tt class="varname">USING
+              UNIQUE</tt>. For example, you could explicitly select one
+              of the table's oid values for this purpose, or any other column
+              which is guaranteed to be unique for the result set.</p><p>The <tt class="varname">USING</tt> statement can also be useful
+              even for simple <tt class="varname">DATA</tt> statements, if you are
+              doing map queries. It was previously recommended to add an index
+              on the oid column of tables used in query-able layers, in order
+              to speed up the performance of map queries. However, with the
+              <tt class="varname">USING</tt> clause, it is possible to tell
+              mapserver to use your table's primary key as the identifier for
+              map queries, and then it is no longer necessary to have an
+              additional index.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>"Querying a Map" is the action of clicking on a map to
+                ask for information about the map features in that location.
+                Don't confuse "map queries" with the SQL query in a
+                <tt class="varname">DATA</tt> definition.</p></div></dd><dt><span class="term">USING SRID=&lt;srid&gt;</span></dt><dd><p>PostGIS needs to know which spatial referencing system is
+              being used by the geometries in order to return the correct data
+              back to mapserver. Normally it is possible to find this
+              information in the "geometry_columns" table in the PostGIS
+              database, however, this is not possible for tables which are
+              created on the fly such as subselects and views. So the
+              <tt class="varname">USING SRID=</tt> option allows the correct SRID to
+              be specified in the <tt class="varname">DATA</tt> definition.</p></dd></dl></div><div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>The parser for Mapserver PostGIS layers is fairly primitive,
+          and is case sensitive in a few areas. Be careful to ensure that all
+          SQL keywords and all your <tt class="varname">USING</tt> clauses are in
+          upper case, and that your <tt class="varname">USING UNIQUE</tt> clause
+          precedes your <tt class="varname">USING SRID</tt> clause.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2580495"></a>4.7.4. Examples</h3></div></div><div></div></div><p>Lets start with a simple example and work our way up. Consider
+        the following Mapserver layer definition:</p><pre class="programlisting">LAYER
+ CONNECTIONTYPE postgis
+ NAME "roads"
+ CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
+ DATA "the_geom FROM roads"
+ STATUS ON
+ TYPE LINE
+ CLASS
+  COLOR 0 0 0
+ END
+END</pre><p>This layer will display all the road geometries in the roads
+        table as black lines.</p><p>Now lets say we want to show only the highways until we get
+        zoomed in to at least a 1:100000 scale - the next two layers will
+        achieve this effect:</p><pre class="programlisting">LAYER
+ CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
+ DATA "the_geom FROM roads"
+ MINSCALE 100000
+ STATUS ON
+ TYPE LINE
+ FILTER "road_type = 'highway'"
+ CLASS
+  COLOR 0 0 0
+ END
+END
+
+LAYER
+ CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
+ DATA "the_geom FROM roads"
+ MAXSCALE 100000
+ STATUS ON
+ TYPE LINE
+ CLASSITEM road_type
+ CLASS
+  EXPRESSION "highway"
+  SIZE 2
+  COLOR 255 0 0
+ END
+ CLASS
+  COLOR 0 0 0
+ END
+END</pre><p>The first layer is used when the scale is greater than 1:100000,
+        and displays only the roads of type "highway" as black lines. The
+        <tt class="varname">FILTER</tt> option causes only roads of type "highway"
+        to be displayed.</p><p>The second layer is used when the scale is less than 1:100000,
+        and will display highways as double-thick red lines, and other roads
+        as regular black lines.</p><p>So, we have done a couple of interesting things using only
+        mapserver functionality, but our <tt class="varname">DATA</tt> SQL statement
+        has remained simple. Suppose that the name of the road is stored in
+        another table (for whatever reason) and we need to do a join to get it
+        and label our roads.</p><pre class="programlisting">LAYER
+ CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
+ DATA "the_geom FROM (SELECT roads.oid AS oid, roads.the_geom AS the_geom, road_names.name as name
+   FROM roads LEFT JOIN road_names ON roads.road_name_id = road_names.road_name_id) AS named_roads
+   USING UNIQUE oid USING SRID=-1"
+ MAXSCALE 20000
+ STATUS ON
+ TYPE ANNOTATION
+ LABELITEM name
+ CLASS
+  LABEL
+   ANGLE auto
+   SIZE 8
+   COLOR 0 192 0
+   TYPE truetype
+   FONT arial
+  END
+ END
+END</pre><p>This annotation layer adds green labels to all the roads when
+        the scale gets down to 1:20000 or less. It also demonstrates how to
+        use an SQL join in a <tt class="varname">DATA</tt> definition.</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2580593"></a>4.8. Java Clients (JDBC)</h2></div></div><div></div></div><p>Java clients can access PostGIS "geometry" objects in the
+      PostgreSQL database either directly as text representations or using the
+      JDBC extension objects bundled with PostGIS. In order to use the
+      extension objects, the "postgis.jar" file must be in your CLASSPATH
+      along with the "postgresql.jar" JDBC driver package.</p><pre class="programlisting">import java.sql.*; 
+import java.util.*; 
+import java.lang.*; 
+import org.postgis.*; 
+
+public class JavaGIS { 
+  public static void main(String[] args) 
+  { 
+    java.sql.Connection conn; 
+    try 
+    { 
+      /* 
+      * Load the JDBC driver and establish a connection. 
+      */  
+      Class.forName("org.postgresql.Driver"); 
+      String url = "jdbc:postgresql://localhost:5432/database"; 
+      conn = DriverManager.getConnection(url, "postgres", ""); 
+    
+      /* 
+      * Add the geometry types to the connection. Note that you 
+      * must cast the connection to the pgsql-specific connection * implementation before calling the addDataType() method. 
+      */
+      ((org.postgresql.Connection)conn).addDataType("geometry","org.postgis.PGgeometry");
+      ((org.postgresql.Connection)conn).addDataType("box3d","org.postgis.PGbox3d");
+
+      /* 
+      * Create a statement and execute a select query. 
+      */ 
+      Statement s = conn.createStatement(); 
+      ResultSet r = s.executeQuery("select AsText(geom) as geom,id from geomtable"); 
+      while( r.next() ) 
+      { 
+        /* 
+        * Retrieve the geometry as an object then cast it to the geometry type. 
+        * Print things out. 
+        */ 
+        PGgeometry geom = (PGgeometry)r.getObject(1); 
+        int id = r.getInt(2);
+        System.out.println("Row " + id + ":"); 
+        System.out.println(geom.toString()); 
+      }
+      s.close(); 
+      conn.close(); 
+    } 
+    catch( Exception e ) 
+    { 
+      e.printStackTrace(); 
+    }  
+  }
+}</pre><p>The "PGgeometry" object is a wrapper object which contains a
+      specific topological geometry object (subclasses of the abstract class
+      "Geometry") depending on the type: Point, LineString, Polygon,
+      MultiPoint, MultiLineString, MultiPolygon.</p><pre class="programlisting">PGgeometry geom = (PGgeometry)r.getObject(1); 
+if( geom.getType() = Geometry.POLYGON ) 
+{ 
+  Polygon pl = (Polygon)geom.getGeometry();
+  for( int r = 0; r &lt; pl.numRings(); r++ ) 
+  { 
+    LinearRing rng = pl.getRing(r);
+    System.out.println("Ring: " + r); 
+    for( int p = 0; p &lt; rng.numPoints(); p++ ) 
+    { 
+      Point pt = rng.getPoint(p); 
+      System.out.println("Point: " + p);
+      System.out.println(pt.toString()); 
+    } 
+  } 
+}</pre><p>The JavaDoc for the extension objects provides a reference for the
+      various data accessor functions in the geometric objects.</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2653210"></a>4.9. C Clients (libpq)</h2></div></div><div></div></div><p>...</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2653219"></a>4.9.1. Text Cursors</h3></div></div><div></div></div><p>...</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2653229"></a>4.9.2. Binary Cursors</h3></div></div><div></div></div><p>...</p></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2653241"></a>Chapter 5. Performance tips</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id2653247">5.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2653253">5.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="#id2653305">5.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2653365">5.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="#id2653421">5.3. Avoiding dimension conversion</a></span></dt></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2653247"></a>5.1. Small tables of large geometries</h2></div></div><div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2653253"></a>5.1.1. Problem description</h3></div></div><div></div></div><p>
+Current PostgreSQL versions (including 8.0) suffer from a query
+optimizer weakness regarding TOAST tables. TOAST tables are a kind of
+"extension room" used to store large (in the sense of data size) values
+that do not fit into normal data pages (like long texts, images or
+complex geometries with lots of vertices), see
+http://www.postgresql.org/docs/8.0/static/storage-toast.html for more
+information).
+</p><p>
+The problem appears if you happen to have a table with rather large
+geometries, but not too much rows of them (like a table containing the
+boundaries of all European countries in high resolution). Then the table
+itself is small, but it uses lots of TOAST space. In our example case,
+the table itself had about 80 rows and used only 3 data pages, but the
+TOAST table used 8225 pages.
+</p><p>
+Now issue a query where you use the geometry operator &amp;&amp; to search for a
+bounding box that matches only very few of those rows. Now the query
+optimizer sees that the table has only 3 pages and 80 rows. He estimates
+that a sequential scan on such a small table is much faster than using
+an index. And so he decides to ignore the GIST index. Usually, this
+estimation is correct. But in our case, the &amp;&amp; operator has to fetch
+every geometry from disk to compare the bounding boxes, thus reading all
+TOAST pages, too.
+</p><p>
+To see whether your suffer from this bug, use the "EXPLAIN ANALYZE"
+postgresql command. For more information and the technical details, you
+can read the thread on the postgres performance mailing list:
+http://archives.postgresql.org/pgsql-performance/2005-02/msg00030.php
+</p></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2653305"></a>5.1.2. Workarounds</h3></div></div><div></div></div><p>
+The PostgreSQL people are trying to solve this issue by making the query
+estimation TOAST-aware. For now, here are two workarounds:
+</p><p>
+The first workaround is to force the query planner to use the index.
+Send "SET enable_seqscan TO off;" to the server before issuing the
+query. This basically forces the query planner to avoid sequential scans
+whenever possible. So it uses the GIST index as usual. But this flag has
+to be set on every connection, and it causes the query planner to make
+misestimations in other cases, so you should "SET enable_seqscan TO on;"
+after the query.
+</p><p>
+The second workaround is to make the sequential scan as fast as the
+query planner thinks. This can be achieved by creating an additional
+column that "caches" the bbox, and matching against this. In our
+example, the commands are like:
+</p><pre class="programlisting">
+SELECT addGeometryColumn('myschema','mytable','bbox','4326','GEOMETRY','2');
+
+UPDATE mytable set bbox = Envelope(Force_2d(the_geom));
+</pre><p>
+Now change your query to use the &amp;&amp; operator against bbox instead of
+geom_column, like:
+</p><pre class="programlisting">
+SELECT geom_column FROM mytable WHERE bbox &amp;&amp; SetSrid('BOX3D(0 0,1 1)'::box3d,4326);
+</pre><p>
+Of course, if you change or add rows to mytable, you have to keep the
+bbox "in sync". The most transparent way to do this would be triggers,
+but you also can modify your application to keep the bbox column current
+or run the UPDATE query above after every modification.
+</p></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2653365"></a>5.2. CLUSTERing on geometry indices</h2></div></div><div></div></div><p>
+For tables that are mostly read-only, and where a single index is used for the
+majority of queries, PostgreSQL offers the CLUSTER command. This command 
+physically reorders all the data rows in the same order as the index criteria,
+yielding two performance advantages: First, for index range scans, the number of 
+seeks on the data table is drastically reduced. Second, if your working set
+concentrates to some small intervals on the indices, you have a more efficient
+caching because the data rows are spread along fewer data pages. (Feel invited
+to read the CLUSTER command documentation from the PostgreSQL manual at this
+point.)
+</p><p>
+However, currently PostgreSQL does not allow clustering on PostGIS GIST indices
+because GIST indices simply ignores NULL values, you get an error message like:
+</p><pre class="programlisting">
+lwgeom=# CLUSTER my_geom_index ON my_table;
+ERROR:  cannot cluster when index access method does not handle null values
+HINT:  You may be able to work around this by marking column "the_geom" NOT NULL.
+</pre><p>
+As the HINT message tells you, one can work around this deficiency by adding a
+"not null" constraint to the table:
+</p><pre class="programlisting">
+lwgeom=# ALTER TABLE my_table ALTER COLUMN the_geom SET not null;
+ALTER TABLE
+</pre><p>
+Of course, this will not work if you in fact need NULL values in your geometry
+column. Additionally, you must use the above method to add the constraint, using
+a CHECK constraint like "ALTER TABLE blubb ADD CHECK (geometry is not null);" will
+not work.
+</p></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2653421"></a>5.3. Avoiding dimension conversion</h2></div></div><div></div></div><p>
+Sometimes, you happen to have 3D or 4D data in your table, but always access
+it using OpenGIS compliant asText() or asBinary() functions that only output
+2D geometries. They do this by internally calling the force_2d() function,
+which introduces a significant overhead for large geometries. To avoid this
+overhead, it may be feasible to pre-drop those additional dimensions once and
+forever:
+</p><pre class="programlisting">
+UPDATE mytable SET the_geom = force_2d(the_geom);
+VACUUM FULL ANALYZE mytable;
+</pre><p>
+Note that if you added your geometry column using AddGeometryColumn()
+there'll be a constraint on geometry dimension.
+To bypass it you will need to drop the constraint.
+Remember to update the entry in the geometry_columns table and
+recreate the constraint afterwards.
+</p><p>
+In case of large tables, it may be wise to divide this UPDATE into smaller portions
+by constraining the UPDATE to a part of the table via a WHERE clause and your
+primary key or another feasible criteria, and running a simple "VACUUM;" between
+your UPDATEs. This drastically reduces the need for temporary disk space.
+Additionally, if you have mixed dimension geometries, restricting the UPDATE by "WHERE 
+dimension(the_geom)&gt;2" skips re-writing of geometries that already are in 2D. 
+</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2653471"></a>Chapter 6. PostGIS Reference</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id2653484">6.1. OpenGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2653490">6.1.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2653580">6.1.2. Geometry Relationship Functions</a></span></dt><dt><span class="sect2"><a href="#id2653956">6.1.3. Geometry Processing Functions</a></span></dt><dt><span class="sect2"><a href="#id2654282">6.1.4. Geometry Accessors</a></span></dt><dt><span class="sect2"><a href="#id2654768">6.1.5. Geometry Constructors</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2655371">6.2. Postgis Extensions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2655376">6.2.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2655701">6.2.2. Operators</a></span></dt><dt><span class="sect2"><a href="#id2655909">6.2.3. Measurement Functions</a></span></dt><dt><span class="sect2"><a href="#id2656192">6.2.4. Geometry Outputs</a></span></dt><dt><span class="sect2"><a href="#id2656300">6.2.5. Geometry Constructors</a></span></dt><dt><span class="sect2"><a href="#id2656633">6.2.6. Geometry Editors</a></span></dt><dt><span class="sect2"><a href="#id2657229">6.2.7. Linear Referencing</a></span></dt><dt><span class="sect2"><a href="#id2657449">6.2.8. Misc</a></span></dt><dt><span class="sect2"><a href="#id2658447">6.2.9. Long Transactions support</a></span></dt></dl></dd></dl></div><p>The functions given below are the ones which a user of PostGIS is
+    likely to need. There are other functions which are required support
+    functions to the PostGIS objects which are not of use to a general
+    user.</p><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2653484"></a>6.1. OpenGIS Functions</h2></div></div><div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2653490"></a>6.1.1. Management Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><a name="AddGeometryColumn"></a><span class="term">AddGeometryColumn(varchar, varchar, varchar, integer,
+            varchar, integer)</span></dt><dd><p>Syntax: AddGeometryColumn(&lt;schema_name&gt;,
+              &lt;table_name&gt;, &lt;column_name&gt;, &lt;srid&gt;,
+              &lt;type&gt;, &lt;dimension&gt;). Adds a geometry column to an
+              existing table of attributes. The <tt class="varname">schema_name</tt>
+              is the name of the table schema (unused for pre-schema
+              PostgreSQL installations). The <tt class="varname">srid</tt> must be
+              an integer value reference to an entry in the SPATIAL_REF_SYS
+              table. The <tt class="varname">type</tt> must be an uppercase string
+              corresponding to the geometry type, eg, 'POLYGON' or
+              'MULTILINESTRING'.</p></dd><dt><span class="term">DropGeometryColumn(varchar, varchar, varchar)</span></dt><dd><p>Syntax: DropGeometryColumn(&lt;schema_name&gt;,
+              &lt;table_name&gt;, &lt;column_name&gt;). Remove a geometry
+              column from a spatial table. Note that schema_name will need to
+              match the f_schema_name field of the table's row in the
+              geometry_columns table.</p></dd><dt><span class="term">SetSRID(geometry, integer)</span></dt><dd><p>Set the SRID on a geometry to a particular integer value.
+              Useful in constructing bounding boxes for queries.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2653580"></a>6.1.2. Geometry Relationship Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">Distance(geometry, geometry)</span></dt><dd><p>Return the cartesian distance between two geometries in
+              projected units.</p></dd><dt><span class="term">Equals(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the given Geometries are
+	      "spatially equal". Use this for a 'better' answer than '='.
+	      equals('LINESTRING(0 0, 10 10)','LINESTRING(0 0, 5 5, 10 10)')
+	      is true.</p><p>Performed by the GEOS module</p><p>OGC SPEC s2.1.1.2</p></dd><dt><span class="term">Disjoint(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries are "spatially disjoint".
+	      </p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is the "allowable" version that returns a
+              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 //s2.1.13.3 - a.Relate(b,
+              'FF*FF****')</p></dd><dt><span class="term">Intersects(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially intersect".
+              </p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is the "allowable" version that returns a
+              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 //s2.1.13.3 - Intersects(g1, g2 ) --&gt;
+              Not (Disjoint(g1, g2 ))</p></dd><dt><span class="term">Touches(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially touch".
+              </p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is the "allowable" version that returns a
+              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3- a.Touches(b) -&gt; (I(a)
+              intersection I(b) = {empty set} ) and (a intersection b) not
+              empty</p></dd><dt><span class="term">Crosses(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially cross".
+              </p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is the "allowable" version that returns a
+              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3 - a.Relate(b,
+              'T*T******')</p></dd><dt><span class="term">Within(geometry A, geometry B)</span></dt><dd><p>Returns 1 (TRUE) if Geometry A is "spatially within"
+              Geometry B.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is the "allowable" version that returns a
+              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3 - a.Relate(b,
+              'T*F**F***')</p></dd><dt><span class="term">Overlaps(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially
+              overlap".</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is the "allowable" version that returns a
+              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3</p></dd><dt><span class="term">Contains(geometry A, geometry B)</span></dt><dd><p>Returns 1 (TRUE) if Geometry A "spatially contains"
+              Geometry B.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is the "allowable" version that returns a
+              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3 - same as
+              within(geometry B, geometry A)</p></dd><dt><span class="term">Intersects(geometry, geometry)</span></dt><dd><p>Returns 1 (TRUE) if the Geometries "spatially
+              intersect".</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is the "allowable" version that returns a
+              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3 - NOT
+              disjoint(geometry, geometry)</p></dd><dt><span class="term">Relate(geometry, geometry, intersectionPatternMatrix)</span></dt><dd><p>Returns 1 (TRUE) if this Geometry is spatially related to
+              anotherGeometry, by testing for intersections between the
+              Interior, Boundary and Exterior of the two geometries as
+              specified by the values in the intersectionPatternMatrix.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is the "allowable" version that returns a
+              boolean, not an integer.</p><p>OGC SPEC s2.1.1.2 // s2.1.13.3</p></dd><dt><span class="term">Relate(geometry, geometry)</span></dt><dd><p>returns the DE-9IM (dimensionally extended
+              nine-intersection matrix)</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>not in OGC spec, but implied. see s2.1.13.2</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2653956"></a>6.1.3. Geometry Processing Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">Centroid(geometry)</span></dt><dd><p>Returns the centroid of the geometry as a point.</p><p>Computation will be more accurate if performed by the GEOS
+              module (enabled at compile time).</p></dd><dt><span class="term">Area(geometry)</span></dt><dd><p>Returns the area of the geometry if it is a polygon or
+              multi-polygon. </p></dd><dt><span class="term">Length(geometry)</span></dt><dd><p>The length of this Curve in its associated spatial
+              reference.</p><p>synonym for length2d()</p><p>OGC SPEC 2.1.5.1</p></dd><dt><span class="term">PointOnSurface(geometry)</span></dt><dd><p>Return a Point guaranteed to lie on the surface</p><p>Implemented using GEOS</p><p>OGC SPEC 3.2.14.2 and 3.2.18.2 -</p></dd><dt><span class="term">Boundary(geometry)</span></dt><dd><p>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.</p><p>Performed by the GEOS module</p><p>OGC SPEC s2.1.1.1</p></dd><dt><span class="term">Buffer(geometry, double, [integer])</span></dt><dd><p>Returns a geometry that represents all points whose
+              distance from this Geometry is less than or equal to distance.
+              Calculations are in the Spatial Reference System of this
+              Geometry. The optional third parameter sets the
+	      number of segment used to approximate a quarter circle
+	      (defaults to 8).</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">ConvexHull(geometry)</span></dt><dd><p>Returns a geometry that represents the convex hull of this
+              Geometry.</p><p>Performed by the GEOS module</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">Intersection(geometry, geometry)</span></dt><dd><p>Returns a geometry that represents the point set
+              intersection of the Geometies.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">SymDifference(geometry A, geometry B)</span></dt><dd><p>Returns a geometry that represents the point set symmetric
+              difference of Geometry A with Geometry B.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">Difference(geometry A, geometry B)</span></dt><dd><p>Returns a geometry that represents the point set difference
+              of Geometry A with Geometry B.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">GeomUnion(geometry, geometry)</span></dt><dd><p>Returns a geometry that represents the point set union of
+              the Geometries.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection as an
+              argument</p><p>NOTE: this is renamed from "union" because union is an SQL
+              reserved word</p><p>OGC SPEC s2.1.1.3</p></dd><dt><span class="term">GeomUnion(geometry set)</span></dt><dd><p>Returns a geometry that represents the point set union of
+              this all Geometries in given set.</p><p>Performed by the GEOS module</p><p>Do not call with a GeometryCollection in the argument
+              set</p><p>Not explicitly defined in OGC SPEC</p></dd><dt><span class="term">MemGeomUnion(geometry set)</span></dt><dd><p>Same as the above, only memory-friendly (uses less memory
+              and more processor time).</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2654282"></a>6.1.4. Geometry Accessors</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">AsText(geometry)</span></dt><dd><p>Return the Well-Known Text representation of the geometry.
+              For example: POLYGON(0 0,0 1,1 1,1 0,0 0)</p><p>OGC SPEC s2.1.1.1</p></dd><dt><span class="term">AsBinary(geometry)</span></dt><dd><p>Returns the geometry in the OGC "well-known-binary"
+              format, using the endian encoding of the server on which the
+              database is running. This is useful in binary cursors to pull
+              data out of the database without converting it to a string
+              representation.</p><p>OGC SPEC s2.1.1.1 - also see
+              asBinary(&lt;geometry&gt;,'XDR') and
+              asBinary(&lt;geometry&gt;,'NDR')</p></dd><dt><span class="term">SRID(geometry)</span></dt><dd><p>Returns the integer SRID number of the spatial reference
+              system of the geometry.</p><p>OGC SPEC s2.1.1.1</p></dd><dt><span class="term">Dimension(geometry)</span></dt><dd><p>The inherent 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 points, 1 for lines, 2 for polygons,
+              and the largest dimension of the components of a
+              GEOMETRYCOLLECTION.</p><pre class="programlisting">select dimension('GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0 0)'); 
+dimension 
+-----------
+1</pre></dd><dt><span class="term">Envelope(geometry)</span></dt><dd><p>Returns a POLYGON representing the bounding box of the
+              geometry.</p><p>OGC SPEC s2.1.1.1 - The minimum bounding box for this
+              Geometry, returned as a Geometry. The polygon is defined by the
+              corner points of the bounding box ((MINX, MINY), (MAXX, MINY),
+              (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)).</p><p>NOTE:PostGIS will add a Zmin/Zmax coordinate as
+              well.</p></dd><dt><span class="term">IsEmpty(geometry)</span></dt><dd><p>Returns 1 (TRUE) if this Geometry is the empty geometry .
+              If true, then this Geometry represents the empty point set -
+              i.e. GEOMETRYCOLLECTION(EMPTY).</p><p>OGC SPEC s2.1.1.1</p></dd><dt><a name="IsSimple"></a><span class="term">IsSimple(geometry)</span></dt><dd><p>Returns 1 (TRUE) if this Geometry has no anomalous
+              geometric points, such as self intersection or self
+              tangency.</p><p>Performed by the GEOS module</p><p>OGC SPEC s2.1.1.1</p></dd><dt><a name="IsClosed"></a><span class="term">IsClosed(geometry)</span></dt><dd><p>Returns true of the geometry start and end points are
+              coincident.</p></dd><dt><span class="term">IsRing(geometry)</span></dt><dd><p>Returns 1 (TRUE) if this Curve is closed (StartPoint ( ) =
+              EndPoint ( )) and this Curve is simple (does not pass through
+              the same point more than once).</p><p>performed by GEOS</p><p>OGC spec 2.1.5.1</p></dd><dt><span class="term">NumGeometries(geometry)</span></dt><dd><p>If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the
+              number of geometries, otherwise return NULL.</p></dd><dt><span class="term">GeometryN(geometry,int)</span></dt><dd><p>Return the N'th geometry if the geometry is a
+              GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING or MULTIPOLYGON.
+              Otherwise, return NULL.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+		Index is 1-based as for OGC specs since version 0.8.0.
+		Previous versions implemented this as 0-based instead.
+		</p></div></dd><dt><span class="term">NumPoints(geometry)</span></dt><dd><p>Find and return the number of points in the first
+              linestring in the geometry. Return NULL if there is no
+              linestring in the geometry.</p></dd><dt><span class="term">PointN(geometry,integer)</span></dt><dd><p>Return the N'th point in the first linestring in the
+              geometry. Return NULL if there is no linestring in the
+              geometry.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+		Index is 1-based as for OGC specs since version 0.8.0.
+		Previous versions implemented this as 0-based instead.
+		</p></div></dd><dt><span class="term">ExteriorRing(geometry)</span></dt><dd><p>Return the exterior ring of the polygon geometry.
+	      Return NULL if the geometry is not a polygon.</p></dd><dt><span class="term">NumInteriorRings(geometry)</span></dt><dd><p>Return the number of interior rings of the first polygon
+              in the geometry. Return NULL if there is no polygon in the
+              geometry.</p></dd><dt><span class="term">NumInteriorRing(geometry)</span></dt><dd><p>Synonym to NumInteriorRings(geometry). The OpenGIS specs
+	      are ambiguous about the exact function naming, so we provide
+	      both spellings.</p></dd><dt><span class="term">InteriorRingN(geometry,integer)</span></dt><dd><p>Return the N'th interior ring of the polygon geometry.
+	      Return NULL if the geometry is not a polygon or the given
+	      N is out of range.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+		Index is 1-based as for OGC specs since version 0.8.0.
+		Previous versions implemented this as 0-based instead.
+		</p></div></dd><dt><span class="term">EndPoint(geometry)</span></dt><dd><p>Returns the last point of the LineString geometry as a point.</p></dd><dt><a name="StartPoint"></a><span class="term">StartPoint(geometry)</span></dt><dd><p>Returns the first point of the LineString geometry as a point.</p></dd><dt><a name="GeometryType"></a><span class="term">GeometryType(geometry)</span></dt><dd><p>Returns the type of the geometry as a string. Eg:
+              'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.</p><p>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.</p></dd><dt><span class="term">X(geometry)</span></dt><dd><p>Return the X coordinate of the point.
+	      Input must be a point.</p></dd><dt><span class="term">Y(geometry)</span></dt><dd><p>Return the Y coordinate of the point.
+	      Input must be a point.</p></dd><dt><span class="term">Z(geometry)</span></dt><dd><p>Return the Z coordinate of the point,
+	      or NULL if not available.
+	      Input must be a point.</p></dd><dt><span class="term">M(geometry)</span></dt><dd><p>Return the M coordinate of the point, 
+	      or NULL if not available.
+	      Input must be a point.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This is not (yet) part of the OGC spec,
+		but is listed here to complete the point coordinate
+	        extractor function list.</p></div></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2654768"></a>6.1.5. Geometry Constructors</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">GeomFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
+              suite</p></dd><dt><span class="term">PointFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
+              suite</p><p>Throws an error if the WKT is not a Point</p></dd><dt><span class="term">LineFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
+              suite</p><p>Throws an error if the WKT is not a Line</p></dd><dt><span class="term">LinestringFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>from the conformance suite</p><p>Throws an error if the WKT is not a Line</p></dd><dt><span class="term">PolyFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
+              suite</p><p>Throws an error if the WKT is not a Polygon</p></dd><dt><span class="term">PolygonFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>from the conformance suite</p><p>Throws an error if the WKT is not a Polygon</p></dd><dt><span class="term">MPointFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
+              suite</p><p>Throws an error if the WKT is not a MULTIPOINT</p></dd><dt><span class="term">MLineFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
+              suite</p><p>Throws an error if the WKT is not a MULTILINESTRING</p></dd><dt><span class="term">MPolyFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
+              suite</p><p>Throws an error if the WKT is not a MULTIPOLYGON</p></dd><dt><span class="term">GeomCollFromText(text,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKT with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
+              suite</p><p>Throws an error if the WKT is not a
+              GEOMETRYCOLLECTION</p></dd><dt><span class="term">GeomFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.6.2 - option SRID is from the conformance
+              suite</p></dd><dt><span class="term">GeomFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
+              suite</p></dd><dt><span class="term">PointFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
+              suite</p><p>throws an error if WKB is not a POINT</p></dd><dt><span class="term">LineFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
+              suite</p><p>throws an error if WKB is not a LINESTRING</p></dd><dt><span class="term">LinestringFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>from the conformance suite</p><p>throws an error if WKB is not a LINESTRING</p></dd><dt><span class="term">PolyFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
+              suite</p><p>throws an error if WKB is not a POLYGON</p></dd><dt><span class="term">PolygonFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>from the conformance suite</p><p>throws an error if WKB is not a POLYGON</p></dd><dt><span class="term">MPointFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
+              suite</p><p>throws an error if WKB is not a MULTIPOINT</p></dd><dt><span class="term">MLineFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
+              suite</p><p>throws an error if WKB is not a MULTILINESTRING</p></dd><dt><span class="term">MPolyFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
+              suite</p><p>throws an error if WKB is not a MULTIPOLYGON</p></dd><dt><span class="term">GeomCollFromWKB(bytea,[&lt;srid&gt;])</span></dt><dd><p>Makes a Geometry from WKB with the given SRID. If SRID is
+              not give, it defaults to -1.</p><p>OGC SPEC 3.2.7.2 - option SRID is from the conformance
+              suite</p><p>throws an error if WKB is not a GEOMETRYCOLLECTION</p></dd><dt><a name="BdPolyFromText"></a><span class="term">BdPolyFromText(text WKT, integer SRID)</span></dt><dd><p>
+		Construct a Polygon given an arbitrary
+		collection of closed linestrings as a
+		MultiLineString text representation.
+		</p><p>
+	      Throws an error if WKT is not a MULTILINESTRING.
+	      Throws an error if output is a MULTIPOLYGON; use <a href="#BdMPolyFromText">BdMPolyFromText</a> in
+	      that case, or see 
+		<a href="#BuildArea">BuildArea()</a>
+		for a postgis-specific approach.
+		</p><p>OGC SFSQL 1.1 - 3.2.6.2</p><p>
+		    Availability: 1.1.0 - requires GEOS &gt;= 2.1.0.
+		</p></dd><dt><a name="BdMPolyFromText"></a><span class="term">BdMPolyFromText(text WKT, integer SRID)</span></dt><dd><p>
+		Construct a MultiPolygon given an arbitrary
+		collection of closed linestrings as a
+		MultiLineString text representation.
+		</p><p>
+                Throws an error if WKT is not a MULTILINESTRING.
+		Forces MULTIPOLYGON output even when result is really
+		only composed by a single POLYGON; use <a href="#BdPolyFromText">BdPolyFromText</a> if you're sure
+		a single POLYGON will result from
+		operation, or see
+		<a href="#BuildArea">BuildArea()</a>
+		for a postgis-specific approach.
+		</p><p>OGC SFSQL 1.1 - 3.2.6.2</p><p>
+		    Availability: 1.1.0 - requires GEOS &gt;= 2.1.0.
+		</p></dd></dl></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2655371"></a>6.2. Postgis Extensions</h2></div></div><div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2655376"></a>6.2.1. Management Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">DropGeometryTable([&lt;schema_name&gt;],
+		  &lt;table_name&gt;)</span></dt><dd><p>Drops a table and all its references in geometry_columns.
+		    Note: uses current_schema() on schema-aware pgsql installations if
+		    schema is not provided.</p></dd><dt><span class="term">UpdateGeometrySRID([&lt;schema_name&gt;],
+		  &lt;table_name&gt;, &lt;column_name&gt;, &lt;srid&gt;)</span></dt><dd><p>Update the SRID of all features in a geometry column updating constraints and reference in geometry_columns.
+		    Note: uses current_schema() on schema-aware pgsql installations if schema is not provided.</p></dd><dt><span class="term">update_geometry_stats([&lt;table_name&gt;,
+		  &lt;column_name&gt;])</span></dt><dd><p>Update statistics about spatial tables for use by the query
+		    planner. You will also need to run "VACUUM ANALYZE [table_name]
+		    [column_name]" for the statistics gathering process to be
+		    complete. NOTE: starting with PostgreSQL 8.0 statistics gathering
+		    is automatically performed running "VACUUM ANALYZE".</p></dd><dt><span class="term">postgis_version()</span></dt><dd><p>Returns PostGIS version number and compile-time options</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+		Prior to version 1.1.0 this was a procedural function, thus possibly
+		returning inaccurate information (in case of incomplete database upgrades).
+		</p></div></dd><dt><a name="postgis_lib_version"></a><span class="term">postgis_lib_version()</span></dt><dd><p>Returns the version number of the PostGIS library.</p><p>
+	Availability: 0.9.0
+		</p></dd><dt><span class="term">postgis_lib_build_date()</span></dt><dd><p>Returns build date of the PostGIS library.</p><p>
+	Availability: 1.0.0RC1
+		</p></dd><dt><span class="term">postgis_script_build_date()</span></dt><dd><p>Returns build date of the PostGIS scripts.</p><p>
+	Availability: 1.0.0RC1
+		</p></dd><dt><span class="term">postgis_scripts_installed()</span></dt><dd><p>
+		Returns version of the postgis scripts
+		installed in this database.
+		</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+		If the output of this function doesn't match the output of
+		<a href="#postgis_scripts_released">postgis_scripts_released()</a>
+		you probably missed to properly upgrade an existing database.
+		See the <a href="#upgrading" title="2.2.1. Upgrading">Upgrading</a> section for more info.
+		</p></div><p>
+	Availability: 0.9.0
+		</p></dd><dt><a name="postgis_scripts_released"></a><span class="term">postgis_scripts_released()</span></dt><dd><p>Returns the version number of the lwpostgis.sql script
+            released with the installed postgis lib.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+		Starting with version 1.1.0 this function returns the same
+		value of <a href="#postgis_lib_version">postgis_lib_version()</a>.
+		Kept for backward compatibility.
+		</p></div><p>
+	Availability: 0.9.0 
+		</p></dd><dt><span class="term">postgis_geos_version()</span></dt><dd><p>Returns the version number of the GEOS library, or NULL if
+            GEOS support is not enabled.</p><p>
+	Availability: 0.9.0
+		</p></dd><dt><span class="term">postgis_jts_version()</span></dt><dd><p>Returns the version number of the JTS library, or NULL if
+            JTS support is not enabled.</p><p>
+	Availability: 1.1.0
+		</p></dd><dt><span class="term">postgis_proj_version()</span></dt><dd><p>Returns the version number of the PROJ4 library, or NULL if
+            PROJ4 support is not enabled.</p><p>
+	Availability: 0.9.0
+		</p></dd><dt><span class="term">postgis_uses_stats()</span></dt><dd><p>Returns true if STATS usage has been enabled, false
+            otherwise.</p><p>
+	Availability: 0.9.0
+		</p></dd><dt><a name="postgis_full_version"></a><span class="term">postgis_full_version()</span></dt><dd><p>Reports full postgis version and build configuration
+            infos.</p><p>Availability: 0.9.0</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2655701"></a>6.2.2. Operators</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">A &amp;&lt; B</span></dt><dd><p>The "&amp;&lt;" operator returns true if A's bounding box
+		    overlaps or is to the left of B's bounding box.</p></dd><dt><span class="term">A &amp;&gt; B</span></dt><dd><p>The "&amp;&gt;" operator returns true if A's bounding box
+		    overlaps or is to the right of B's bounding box.</p></dd><dt><span class="term">A &lt;&lt; B</span></dt><dd><p>The "&lt;&lt;" operator returns true if A's bounding box is
+		    strictly to the left of B's bounding box.</p></dd><dt><span class="term">A &gt;&gt; B</span></dt><dd><p>The "&gt;&gt;" operator returns true if A's bounding box is
+		    strictly to the right of B's bounding box.</p></dd><dt><span class="term">A &amp;&lt;| B</span></dt><dd><p>The "&amp;&lt;|" operator returns true if A's bounding box
+		    overlaps or is below B's bounding box.</p></dd><dt><span class="term">A |&amp;&gt; B</span></dt><dd><p>The "|&amp;&gt;" operator returns true if A's bounding box
+		    overlaps or is above B's bounding box.</p></dd><dt><span class="term">A &lt;&lt;| B</span></dt><dd><p>The "&lt;&lt;|" operator returns true if A's bounding box is
+		    strictly below B's bounding box.</p></dd><dt><span class="term">A |&gt;&gt; B</span></dt><dd><p>The "|&gt;&gt;" operator returns true if A's bounding box is
+		    strictly above B's bounding box.</p></dd><dt><span class="term">A ~= B</span></dt><dd><p>The "~=" operator is the "same as" operator. It tests actual
+		    geometric equality of two features. So if A and B are the same
+		    feature, vertex-by-vertex, the operator returns true.</p></dd><dt><span class="term">A @ B</span></dt><dd><p>The "@" operator returns true if A's bounding box is
+		    completely contained by B's bounding box.</p></dd><dt><span class="term">A ~ B</span></dt><dd><p>The "~" operator returns true if A's bounding box completely
+		    contains B's bounding box.</p></dd><dt><span class="term">A &amp;&amp; B</span></dt><dd><p>The "&amp;&amp;" operator is the "overlaps" operator. If A's
+		    bounding box overlaps B's bounding box the operator returns
+		    true.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2655909"></a>6.2.3. Measurement Functions</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">area2d(geometry)</span></dt><dd><p>Returns the area of the geometry if it is a polygon or
+		    multi-polygon.</p></dd><dt><span class="term">distance_sphere(point, point)</span></dt><dd><p>Returns linear distance in meters between two lat/lon
+            points. Uses a spherical earth and radius of 6370986 meters.
+            Faster than <a href="#distance_spheroid">distance_spheroid()</a>, but
+            less accurate.
+			Only implemented for points.</p></dd><dt><a name="distance_spheroid"></a><span class="term">distance_spheroid(point, point, spheroid)</span></dt><dd><p>Returns linear distance between two lat/lon points given a
+            particular spheroid. See the explanation of spheroids given for
+            <a href="#length_spheroid">length_spheroid()</a>.
+            Currently only implemented for points.</p></dd><dt><a name="length2d"></a><span class="term">length2d(geometry)</span></dt><dd><p>Returns the 2-dimensional length of the geometry if it is a
+            linestring or multi-linestring.</p></dd><dt><span class="term">length3d(geometry)</span></dt><dd><p>Returns the 3-dimensional length of the geometry if it is a
+            linestring or multi-linestring.</p></dd><dt><a name="length_spheroid"></a><span class="term">length_spheroid(geometry,spheroid)</span></dt><dd><p>Calculates the length of of a geometry on an ellipsoid. This
+            is useful if the coordinates of the geometry are in
+            latitude/longitude and a length is desired without reprojection.
+            The ellipsoid is a separate database type and can be constructed as
+            follows:</p><div class="literallayout"><p>SPHEROID[&lt;NAME&gt;,&lt;SEMI-MAJOR AXIS&gt;,&lt;INVERSE FLATTENING&gt;]</p></div><p>Eg:</p><div class="literallayout"><p>SPHEROID["GRS_1980",6378137,298.257222101]</p></div><p>An example calculation might look like this:</p><div class="literallayout"><p>SELECT<br>
+ length_spheroid(<br>
+  geometry_column,<br>
+  'SPHEROID["GRS_1980",6378137,298.257222101]'<br>
+ )<br>
+FROM geometry_table;</p></div></dd><dt><span class="term">length3d_spheroid(geometry,spheroid)</span></dt><dd><p>Calculates the length of of a geometry on an ellipsoid,
+            taking the elevation into account. This is just like
+            length_spheroid except vertical coordinates (expressed in the same
+            units as the spheroid axes) are used to calculate the extra
+            distance vertical displacement adds.</p></dd><dt><span class="term">distance(geometry, geometry)</span></dt><dd><p>Returns the smaller distance between two geometries.</p></dd><dt><span class="term">max_distance(linestring,linestring)</span></dt><dd><p>Returns the largest distance between two line
+            strings.</p></dd><dt><span class="term">perimeter(geometry)</span></dt><dd><p>Returns the 2-dimensional perimeter of the geometry, if it
+            is a polygon or multi-polygon.</p></dd><dt><span class="term">perimeter2d(geometry)</span></dt><dd><p>Returns the 2-dimensional perimeter of the geometry, if it
+            is a polygon or multi-polygon.</p></dd><dt><span class="term">perimeter3d(geometry)</span></dt><dd><p>Returns the 3-dimensional perimeter of the geometry, if it
+            is a polygon or multi-polygon.</p></dd><dt><span class="term">azimuth(geometry, geometry)</span></dt><dd><p>
+	Returns the azimuth of the segment defined by the given Point
+	geometries, or NULL if the two points are coincident.
+	Return value is in radians.
+            </p><p>
+			Availability: 1.1.0
+		</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2656192"></a>6.2.4. Geometry Outputs</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">AsBinary(geometry,{'NDR'|'XDR'})</span></dt><dd><p>Returns the geometry in the OGC "well-known-binary" format as a bytea, using little-endian (NDR) or big-endian (XDR) encoding. This is useful in binary cursors to pull data out of the database without converting it to a string representation.</p></dd><dt><span class="term">AsEWKT(geometry)</span></dt><dd><p>Returns a Geometry in EWKT format (as text).</p></dd><dt><span class="term">AsEWKB(geometry, {'NDR'|'XDR'})</span></dt><dd><p>Returns a Geometry in EWKB format (as bytea) using either little-endian (NDR) or big-endian (XDR) encoding.</p></dd><dt><span class="term">AsHEXEWKB(geometry, {'NDR'|'XDR'})</span></dt><dd><p>Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding.</p></dd><dt><span class="term">AsSVG(geometry, [rel], [precision])</span></dt><dd><p>Return the geometry as an SVG path data. Use 1 as second argument to have the path data implemented in terms of relative moves, the default (or 0) uses absolute moves. Third argument may be used to reduce the maximum number of decimal digits used in output (defaults to 15). Point geometries will be rendered as cx/cy when 'rel' arg is 0, x/y when 'rel' is 1.</p></dd><dt><span class="term">AsGML(geometry, [precision])</span></dt><dd><p>Return the geometry as a GML element.  Second argument may be used to reduce the maximum number of significant digits used in output (defaults to 15).</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2656300"></a>6.2.5. Geometry Constructors</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">GeomFromEWKT(text)</span></dt><dd><p>Makes a Geometry from EWKT.</p></dd><dt><span class="term">GeomFromEWKB(bytea)</span></dt><dd><p>Makes a Geometry from EWKB.</p></dd><dt><span class="term">MakePoint(&lt;x&gt;, &lt;y&gt;, [&lt;z&gt;], [&lt;m&gt;])</span></dt><dd><p>Creates a 2d,3dz or 4d point geometry.</p></dd><dt><span class="term">MakePointM(&lt;x&gt;, &lt;y&gt;, &lt;m&gt;)</span></dt><dd><p>Creates a 3dm point geometry.</p></dd><dt><span class="term">MakeBox2D(&lt;LL&gt;, &lt;UR&gt;)</span></dt><dd><p>Creates a BOX2D defined by the given point geometries.</p></dd><dt><span class="term">MakeBox3D(&lt;LLB&gt;, &lt;URT&gt;)</span></dt><dd><p>Creates a BOX3D defined by the given point geometries.</p></dd><dt><span class="term">MakeLine(geometry set)</span></dt><dd><p>Creates a Linestring from a set of point geometries.
+		    You might want to use a subselect to order points before
+		    feeding them to this aggregate.</p></dd><dt><span class="term">MakeLine(geometry, geometry)</span></dt><dd><p>Creates a Linestring from the two given point
+		    geometries.</p></dd><dt><span class="term">LineFromMultiPoint(multipoint)</span></dt><dd><p>Creates a LineString from a MultiPoint geometry.</p></dd><dt><span class="term">MakePolygon(linestring, [linestring[]])</span></dt><dd><p>Creates a Polygon formed by the given 
+		    shell and array of holes. You can construct
+		    a geometry array using <a href="#Accum">Accum</a>.
+		    Input geometries must be closed LINESTRINGS (see <a href="#IsClosed">IsClosed</a> and <a href="#GeometryType">GeometryType</a>).
+		    </p></dd><dt><a name="BuildArea"></a><span class="term">BuildArea(geometry)</span></dt><dd><p>Creates an areal geometry formed by the constituent
+		    linework of given geometry. The return type can
+		    be a Polygon or MultiPolygon, depending on input.
+		    If the input lineworks do not form polygons NULL is
+		    returned.
+		    </p><p>
+		    See also <a href="#BdPolyFromText">BdPolyFromText</a> and <a href="#BdMPolyFromText">BdMPolyFromText</a> - wrappers to this function with standard OGC interface.
+		    </p><p>
+		    Availability: 1.1.0 - requires GEOS &gt;= 2.1.0.
+		</p></dd><dt><span class="term">Polygonize(geometry set)</span></dt><dd><p>
+			Aggregate. Creates a GeometryCollection containing
+			possible polygons formed from the constituent linework
+			of a set of geometries.
+		</p><p>
+		    Availability: 1.0.0RC1 - requires GEOS &gt;= 2.1.0.
+		</p></dd><dt><span class="term">Collect(geometry set)</span></dt><dd><p>This function returns a GEOMETRYCOLLECTION or a MULTI object from a set
+		    of geometries. The collect() function is an "aggregate" function
+		    in the terminology of PostgreSQL. That means that it operators on
+		    lists of data, in the same way the sum() and mean() functions do.
+		    For example, "SELECT COLLECT(GEOM) FROM GEOMTABLE GROUP BY
+		    ATTRCOLUMN" will return a separate GEOMETRYCOLLECTION for each
+		    distinct value of ATTRCOLUMN.</p></dd><dt><span class="term">Collect(geometry, geometry)</span></dt><dd><p>This function returns a geometry being a collection
+		    of two input geometries. Output type can be a MULTI* or 
+		    a GEOMETRYCOLLECTION.</p></dd><dt><span class="term">Dump(geometry)</span></dt><dd><p>This is a set-returning function (SRF).
+		    It returns a set of geometry_dump rows, formed
+		    by a geometry (geom) and an array of integers (path).
+		    When the input geometry is a simple type
+		    (POINT,LINESTRING,POLYGON)
+		    a single record will be returned with an empty
+		    path array and the input geometry as geom.
+		    When the input geometry is a collection or multi
+		    it will return a record for each of the collection
+		    components, and the path will express the position
+		    of the component inside the collection.
+		    </p><p>
+		    Availability: PostGIS 1.0.0RC1.
+		    Requires PostgreSQL 7.3 or higher.
+		</p></dd><dt><span class="term">DumpRings(geometry)</span></dt><dd><p>This is a set-returning function (SRF).
+		    It returns a set of geometry_dump rows, formed
+		    by a geometry (geom) and an array of integers (path).
+		    The 'path' field holds the polygon ring index, contains
+		    a single element: 0 for the shell, hole number for holes.
+		    The 'geom' field contains the corresponding ring
+		    as a polygon.
+		    </p><p>
+		    Availability: PostGIS 1.1.3.
+		    Requires PostgreSQL 7.3 or higher.
+		</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2656633"></a>6.2.6. Geometry Editors</h3></div></div><div></div></div><div class="variablelist"><dl><dt><a name="addbbox"></a><span class="term">AddBBOX(geometry)</span></dt><dd><p>Add bounding box to the geometry. This would make bounding
+	    box based queries faster, but will increase the size of the
+	    geometry.</p></dd><dt><a name="dropbbox"></a><span class="term">DropBBOX(geometry)</span></dt><dd><p>Drop the bounding box cache from the geometry.
+	    This reduces geometry size, but makes bounding-box based
+	    queries slower.</p></dd><dt><span class="term">AddPoint(linestring, point, [&lt;position&gt;])</span></dt><dd><p>Adds a point to a LineString before point &lt;pos&gt;
+	    (0-based index).
+	    Third parameter can be omitted or set to -1 for appending.
+	    </p></dd><dt><span class="term">RemovePoint(linestring, offset)</span></dt><dd><p>
+			Removes point from a linestring. Offset is 0-based.
+		</p><p>
+			Availability: 1.1.0
+		</p></dd><dt><span class="term">SetPoint(linestring, N, point)</span></dt><dd><p>
+			Replace point N of linestring with given point.
+			Index is 0-based.
+		</p><p>
+			Availability: 1.1.0
+		</p></dd><dt><span class="term">Force_collection(geometry)</span></dt><dd><p>Converts the geometry into a GEOMETRYCOLLECTION. This is
+            useful for simplifying the WKB representation.</p></dd><dt><a name="force_2d"></a><span class="term">Force_2d(geometry)</span></dt><dd><p>Forces the geometries into a "2-dimensional mode" so that
+            all output representations will only have the X and Y coordinates.
+            This is useful for force OGC-compliant output (since OGC only
+            specifies 2-D geometries).</p></dd><dt><a name="force_3dz"></a><span class="term">Force_3dz(geometry), </span><span class="term">Force_3d(geometry), </span></dt><dd><p>Forces the geometries into XYZ mode.</p></dd><dt><a name="force_3dm"></a><span class="term">Force_3dm(geometry)</span></dt><dd><p>Forces the geometries into XYM mode.</p></dd><dt><a name="force_4d"></a><span class="term">Force_4d(geometry)</span></dt><dd><p>Forces the geometries into XYZM mode.</p></dd><dt><span class="term">Multi(geometry)</span></dt><dd><p>Returns the geometry as a MULTI* geometry. If the geometry
+            is already a MULTI*, it is returned unchanged.</p></dd><dt><span class="term">Transform(geometry,integer)</span></dt><dd><p>Returns a new geometry with its coordinates transformed to
+            the SRID referenced by the integer parameter. The destination SRID
+            must exist in the <tt class="varname">SPATIAL_REF_SYS</tt> table.</p></dd><dt><span class="term">Affine(geometry,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8)</span></dt><dd><p>Applies an 3d affine transformation to the geometry. The call 
+                </p><pre class="programlisting">
+                    Affine(geom, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff)
+                </pre><p>
+                represents the transformation matrix
+                </p><pre class="programlisting">
+                    /  a  b  c  xoff  \
+                    |  d  e  f  yoff  |
+                    |  g  h  i  zoff  |
+                    \  0  0  0  1     /
+                </pre><p>
+                and the vertices are transformed as follows:
+                </p><pre class="programlisting">
+                    x' = a*x + b*y + c*z + xoff
+                    y' = d*x + e*y + f*z + yoff
+                    z' = g*x + h*y + i*z + zoff   
+                </pre><p>
+                All of the translate / scale functions below are expressed via such an affine transformation.
+            </p><p>
+                Availability: 1.1.2.
+            </p></dd><dt><span class="term">Affine(geometry,float8,float8,float8,float8,float8,float8)</span></dt><dd><p>Applies an 2d affine transformation to the geometry. The call 
+                </p><pre class="programlisting">
+                    Affine(geom, a, b, d, e, xoff, yoff)
+                </pre><p>
+                represents the transformation matrix
+                </p><pre class="programlisting">
+                    /  a  b  0  xoff  \        /  a  b  xoff  \
+                    |  d  e  0  yoff  |  rsp.  |  d  e  yoff  |
+                    |  0  0  1  0     |        \  0  0  1     /
+                    \  0  0  0  1     /
+                </pre><p>
+                and the vertices are transformed as follows:
+                </p><pre class="programlisting">
+                    x' = a*x + b*y + xoff
+                    y' = d*x + e*y + yoff
+                    z' = z   
+                </pre><p>
+                This method is a subcase of the 3D method above.
+            </p><p>
+		Availability: 1.1.2.
+            </p></dd><dt><span class="term">Translate(geometry,float8,float8,float8)</span></dt><dd><p>Translates the geometry to a new location using the numeric
+            parameters as offsets. Ie: translate(geom, X, Y, Z).</p></dd><dt><span class="term">Scale(geometry,float8,float8,float8)</span></dt><dd><p>scales the geometry to a new size by multiplying the
+            ordinates with the parameters. Ie: scale(geom, Xfactor, Yfactor, Zfactor).</p><p>
+			Availability: 1.1.0
+		</p></dd><dt><a name="Rotate"></a><span class="term">RotateZ(geometry,float8), </span><span class="term">RotateX(geometry,float8), </span><span class="term">RotateY(geometry,float8), </span></dt><dd><p>
+			Rotate the geometry around the Z, X or Y axis by
+			the given angle given in radians. Follows the
+			right-hand rule. This is the same in
+			PostScript but opposite of SVG.
+		</p><p>
+			Availability: 1.1.2.
+		</p></dd><dt><span class="term">TransScale(geometry,float8,float8,float8,float8)</span></dt><dd><p>First, translates the geometry using the first two floats, then scales it
+                    using the second two floats, working in 2D only. Using
+                    <tt class="code">transscale(geom, X, Y, XFactor, YFactor)</tt> internally calls
+                    <tt class="code">affine(geom, XFactor, 0, 0,  0, YFactor, 0,  0, 0, 1,  X*XFactor, Y*YFactor, 0)</tt>.                
+                </p><p>
+                        Availability: 1.1.0.
+                </p></dd><dt><span class="term">Reverse(geometry)</span></dt><dd><p>Returns the geometry with vertex order reversed.</p></dd><dt><span class="term">ForceRHR(geometry)</span></dt><dd><p>Force polygons of the collection to obey Right-Hand-Rule.</p></dd><dt><span class="term">Simplify(geometry, tolerance)</span></dt><dd><p>Returns a "simplified" version of the given geometry using
+            the Douglas-Peuker algorithm. Will actually do something only with
+            (multi)lines and (multi)polygons but you can safely call it with
+            any kind of geometry. Since simplification occurs on a
+            object-by-object basis you can also feed a GeometryCollection to
+            this function. Note that returned geometry might loose its
+            simplicity (see <a href="#IsSimple">IsSimple</a>)</p></dd><dt><span class="term">SnapToGrid(geometry, originX, originY, sizeX, sizeY), </span><span class="term">SnapToGrid(geometry, sizeX, sizeY), </span><span class="term">SnapToGrid(geometry, size), </span></dt><dd><p>Snap all points of the input geometry to the grid
+	    defined by its origin and cell size.
+            Remove consecutive points falling on the same cell,
+	    eventually returning NULL if output points are not
+	    enough to define a geometry of the given type.
+	    Collapsed geometries in a collection are stripped
+	    from it.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+            The returned geometry might loose its
+            simplicity (see <a href="#IsSimple">IsSimple</a>).
+	</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+            Before release 1.1.0 this function always returned
+	    a 2d geometry. Starting at 1.1.0 the returned geometry
+	    will have same dimensionality as the input one with higher
+	    dimension values untouched. Use the version taking a second
+	    geometry argument to define all grid dimensions.
+	</p></div><p>
+			Availability: 1.0.0RC1
+		</p></dd><dt><span class="term">SnapToGrid(geometry, geometry, sizeX, sizeY, sizeZ, sizeM)</span></dt><dd><p>
+	    Snap all points of the input geometry to the grid
+	    defined by its origin (the second argument, must be a point)
+	    and cell sizes. Specify 0 as size for any dimension you don't
+	    want to snap to a grid.
+	    </p><p>
+			Availability: 1.1.0
+		</p></dd><dt><span class="term">Segmentize(geometry, maxlength)</span></dt><dd><p>Return a modified geometry having no segment
+            longer then the given distance. Interpolated points will have Z
+            and M values (if needed) set to 0. Distance computation is
+            performed in 2d only.</p></dd><dt><span class="term">LineMerge(geometry)</span></dt><dd><p>
+			Returns a (set of) LineString(s) formed by sewing
+			together constituent linework of input.
+		</p><p>
+			Availability: 1.1.0 - requires GEOS &gt;= 2.1.0
+		</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2657229"></a>6.2.7. Linear Referencing</h3></div></div><div></div></div><div class="variablelist"><dl><dt><a name="line_interpolate_point"></a><span class="term">line_interpolate_point(linestring, location)</span></dt><dd><p>
+		Returns a point interpolated along a line.
+		First argument must be a LINESTRING.
+		Second argument is a float8 between 0 and 1
+		representing fraction of total
+		<a href="#length2d">2d length</a> the point has
+		to be located.
+		</p><p>
+		See <a href="#line_locate_point">line_locate_point()</a>
+		for computing the line location nearest to a Point.
+		</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+            Since release 1.1.1 this function also interpolates
+	    M and Z values (when present), while prior releases
+	    set them to 0.0.
+	</p></div><p>
+			Availability: 0.8.2
+		</p></dd><dt><a name="line_substring"></a><span class="term">line_substring(linestring, start, end)</span></dt><dd><p>
+		Return a linestring being a substring of the input one starting
+		and ending at the given fractions of total 2d length. Second
+		and third arguments are float8 values between 0 and 1.
+		</p><p>
+		If 'start' and 'end' have the same value this is equivalent 
+		to <a href="#line_interpolate_point">line_interpolate_point()</a>.
+		</p><p>
+		See <a href="#line_locate_point">line_locate_point()</a>
+		for computing the line location nearest to a Point.
+		</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+            Since release 1.1.1 this function also interpolates
+	    M and Z values (when present), while prior releases
+	    set them to unspecified values.
+	</p></div><p>
+			Availability: 1.1.0
+		</p></dd><dt><a name="line_locate_point"></a><span class="term">line_locate_point(LineString, Point)</span></dt><dd><p>
+		Returns a float between 0 and 1 representing 
+		the location of the closest point on LineString
+		to the given Point, as a fraction of
+		total <a href="#length2d">2d line</a> length.
+		</p><p>
+	You can use the returned location to extract a Point (<a href="#line_interpolate_point">line_interpolate_point</a>) or a substring (<a href="#line_substring">line_substring</a>).
+		</p><p>
+			Availability: 1.1.0
+		</p></dd><dt><span class="term">locate_along_measure(geometry, float8)</span></dt><dd><p>
+		Return a derived geometry collection value with elements that
+		match the specified measure.
+		Polygonal elements are not supported.
+		</p><p>
+		Semantic is specified by: ISO/IEC CD 13249-3:200x(E) -
+		Text for Continuation CD Editing Meeting
+		</p><p>
+			Availability: 1.1.0
+		</p></dd><dt><span class="term">locate_between_measures(geometry, float8, float8)</span></dt><dd><p>
+		Return a derived geometry collection value with elements that
+		match the specified range of measures inclusively.
+		Polygonal elements are not supported. 
+		</p><p>
+		Semantic is specified by: ISO/IEC CD 13249-3:200x(E) -
+		Text for Continuation CD Editing Meeting
+		</p><p>
+			Availability: 1.1.0
+		</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2657449"></a>6.2.8. Misc</h3></div></div><div></div></div><div class="variablelist"><dl><dt><span class="term">Summary(geometry)</span></dt><dd><p>Returns a text summary of the contents of the geometry.</p></dd><dt><span class="term">box2d(geometry)</span></dt><dd><p>Returns a BOX2D representing the maximum extents of the geometry.</p></dd><dt><span class="term">box3d(geometry)</span></dt><dd><p>Returns a BOX3D representing the maximum extents of the geometry.</p></dd><dt><span class="term">extent(geometry set)</span></dt><dd><p>The extent() function is an "aggregate" function in the terminology of PostgreSQL. That means that it operators on lists of data, in the same way the sum() and mean() functions do. For example, "SELECT EXTENT(GEOM) FROM GEOMTABLE" will return a BOX3D giving the maximum extend of all features in the table. Similarly, "SELECT EXTENT(GEOM) FROM GEOMTABLE GROUP BY CATEGORY" will return one extent result for each category.</p></dd><dt><a name="zmflag"></a><span class="term">zmflag(geometry)</span></dt><dd><p>Returns ZM (dimension semantic) flag of the geometries as a small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.  </p></dd><dt><a name="hasbbox"></a><span class="term">HasBBOX(geometry)</span></dt><dd><p>Returns TRUE if the bbox of this geometry is cached, FALSE otherwise. Use <a href="#addbbox">addBBOX()</a> and <a href="#dropbbox">dropBBOX()</a> to control caching.</p></dd><dt><a name="ndims"></a><span class="term">ndims(geometry)</span></dt><dd><p>Returns number of dimensions of the geometry as a small int. Values are: 2,3 or 4.</p></dd><dt><span class="term">nrings(geometry)</span></dt><dd><p>If the geometry is a polygon or multi-polygon returns the number of rings.</p></dd><dt><span class="term">npoints(geometry)</span></dt><dd><p>Returns the number of points in the geometry.</p></dd><dt><a name="IsValid"></a><span class="term">isvalid(geometry)</span></dt><dd><p>returns true if this geometry is valid.</p></dd><dt><span class="term">expand(geometry, float)</span></dt><dd><p>This function returns a bounding box expanded in all
+		    directions from the bounding box of the input geometry, by an
+		    amount specified in the second argument. Very useful for
+		    distance() queries, to add an index filter to the query.</p></dd><dt><span class="term">estimated_extent([schema], table, geocolumn)</span></dt><dd><p> Return the 'estimated' extent of the given spatial table.  The estimated is taken from the geometry column's statistics. The current schema will be used if not specified.</p><p>For PostgreSQL&gt;=8.0.0 statistics are gathered by VACUUM ANALYZE and resulting extent will be about 95% of the real one.</p><p>For PostgreSQL&lt;8.0.0 statistics are gathered by update_geometry_stats() and resulting extent will be exact.</p></dd><dt><span class="term">find_srid(varchar,varchar,varchar)</span></dt><dd><p>The syntax is find_srid(&lt;db/schema&gt;, &lt;table&gt;,
+            &lt;column&gt;) and the function returns the integer SRID of the
+            specified column by searching through the GEOMETRY_COLUMNS table.
+            If the geometry column has not been properly added with the
+            AddGeometryColumns() function, this function will not work
+            either.</p></dd><dt><span class="term">mem_size(geometry)</span></dt><dd><p>Returns the amount of space (in bytes) the geometry
+            takes.</p></dd><dt><span class="term">numb_sub_objects(geometry)</span></dt><dd><p>Returns the number of objects stored in the geometry. This
+            is useful for MULTI-geometries and GEOMETRYCOLLECTIONs.</p></dd><dt><span class="term">point_inside_circle(geometry,float,float,float)</span></dt><dd><p>The syntax for this functions is
+            point_inside_circle(&lt;geometry&gt;,&lt;circle_center_x&gt;,&lt;circle_center_y&gt;,&lt;radius&gt;).
+            Returns the true if the geometry is a point and is inside the
+            circle. Returns false otherwise.</p></dd><dt><span class="term">xmin(box3d) ymin(box3d) zmin(box3d)</span></dt><dd><p>Returns the requested minima of a bounding box.</p></dd><dt><span class="term">xmax(box3d) ymax(box3d) zmax(box3d)</span></dt><dd><p>Returns the requested maxima of a bounding box.</p></dd><dt><a name="Accum"></a><span class="term">Accum(geometry set)</span></dt><dd><p>Aggregate. Constructs an array of geometries.</p></dd></dl></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2658447"></a>6.2.9. Long Transactions support</h3></div></div><div></div></div><p>
+This module and associated pl/pgsql functions have been implemented
+to provide long locking support required by
+<a href="https://portal.opengeospatial.org/files/?artifact_id=7176" target="_top">Web Feature Service</a> specification.
+	</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+  Users must use <a href="http://www.postgresql.org/docs/7.4/static/transaction-iso.html" target="_top">serializable transaction level</a> otherwise locking mechanism would break.
+	  </p></div><div class="variablelist"><dl><dt><a name="EnableLongTransactions"></a><span class="term">EnableLongTransactions()</span></dt><dd><p>
+		Enable long transaction support. This function creates the
+		required metadata tables, needs to be called once before
+		using the other functions in this section. Calling it twice
+		is harmless.
+	    </p><p>
+		    Availability: 1.1.3
+		</p></dd><dt><a name="DisableLongTransactions"></a><span class="term">DisableLongTransactions()</span></dt><dd><p>
+		Disable long transaction support. This function removes the
+		long transaction support metadata tables, and drops all
+		triggers attached to lock-checked tables.
+	    </p><p>
+		    Availability: 1.1.3
+		</p></dd><dt><a name="CheckAuth"></a><span class="term">CheckAuth([&lt;schema&gt;], &lt;table&gt;, &lt;rowid_col&gt;)</span></dt><dd><p>
+		Check updates and deletes of rows in
+		given table for being authorized.
+		Identify rows using &lt;rowid_col&gt; column.
+	    </p><p>
+		    Availability: 1.1.3
+		</p></dd><dt><a name="LockRow"></a><span class="term">LockRow([&lt;schema&gt;], &lt;table&gt;, &lt;rowid&gt;, &lt;authid&gt;, [&lt;expires&gt;])</span></dt><dd><p>
+	Set lock/authorization for specific row in table
+	&lt;authid&gt; is a text value, &lt;expires&gt; is a timestamp
+	defaulting to now()+1hour.
+	Returns 1 if lock has been assigned, 0 otherwise
+	(already locked by other auth)
+	    </p><p>
+		    Availability: 1.1.3
+		</p></dd><dt><a name="UnlockRows"></a><span class="term">UnlockRows(&lt;authid&gt;)</span></dt><dd><p>
+	Remove all locks held by specified authorization id.
+	Returns the number of locks released.
+	    </p><p>
+		    Availability: 1.1.3
+		</p></dd><dt><a name="AddAuth"></a><span class="term">AddAuth(&lt;authid&gt;)</span></dt><dd><p>
+	Add an authorization token to be used in current
+	transaction. 
+	    </p><p>
+		    Availability: 1.1.3
+		</p></dd></dl></div></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2658031"></a>Chapter 7. Reporting Bugs</h2></div></div><div></div></div><p>
+	Reporting bugs effectively is a fundamental way to help PostGIS
+	development. The most effective bug report is that enabling 
+	PostGIS developers to reproduce it, so it would ideally contain
+	a script triggering it and every information regarding the
+	environment in which it was detected. Good enough info can
+	be extracted running <tt class="code">SELECT postgis_full_version()</tt>
+	[for postgis] and <tt class="code">SELECT version()</tt> [for postgresql].
+		</p><p>
+	If you aren't using latest release, it's worth taking a look
+	at its <a href="http://postgis.refractions.net/CHANGES.txt" target="_top">release
+	changelog</a> first, to find out if your bug has already been
+	fixed.
+		</p><p>
+	Using the <a href="http://postgis.refractions.net/bugs/" target="_top">PostGIS
+	bug tracker</a> will ensure your reports are not discarded, and
+	will keep you informed on it's handling process. Before reporting
+	a new bug please query the database to see if it is a known one, and
+	if it is please add any new information you have about it.
+		</p><p>
+	You might want to read Simon Tatham's paper about <a href="http://www.chiark.greenend.org.uk/~sgtatham/bugs.html" target="_top">How
+	to Report Bugs Effectively</a> before filing a new report.
+		</p></div><div class="appendix" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="release_notes"></a>Appendix A. Appendix</h2></div></div><div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="#id2658101">A.1. Release Notes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2658106">A.1.1. Release 1.1.4</a></span></dt><dt><span class="sect2"><a href="#id2658230">A.1.2. Release 1.1.3</a></span></dt><dt><span class="sect2"><a href="#id2658396">A.1.3. Release 1.1.2</a></span></dt><dt><span class="sect2"><a href="#id2658690">A.1.4. Release 1.1.1</a></span></dt><dt><span class="sect2"><a href="#id2658820">A.1.5. Release 1.1.0</a></span></dt><dt><span class="sect2"><a href="#id2659145">A.1.6. Release 1.0.6</a></span></dt><dt><span class="sect2"><a href="#id2659254">A.1.7. Release 1.0.5</a></span></dt><dt><span class="sect2"><a href="#id2659386">A.1.8. Release 1.0.4</a></span></dt><dt><span class="sect2"><a href="#rel_1.0.3_upgrading">A.1.9. Release 1.0.3</a></span></dt><dt><span class="sect2"><a href="#id2659632">A.1.10. Release 1.0.2</a></span></dt><dt><span class="sect2"><a href="#id2659711">A.1.11. Release 1.0.1</a></span></dt><dt><span class="sect2"><a href="#id2659811">A.1.12. Release 1.0.0</a></span></dt><dt><span class="sect2"><a href="#id2659910">A.1.13. Release 1.0.0RC6</a></span></dt><dt><span class="sect2"><a href="#id2659984">A.1.14. Release 1.0.0RC5</a></span></dt><dt><span class="sect2"><a href="#id2660056">A.1.15. Release 1.0.0RC4</a></span></dt><dt><span class="sect2"><a href="#id2660181">A.1.16. Release 1.0.0RC3</a></span></dt><dt><span class="sect2"><a href="#id2660352">A.1.17. Release 1.0.0RC2</a></span></dt><dt><span class="sect2"><a href="#id2660450">A.1.18. Release 1.0.0RC1</a></span></dt></dl></dd></dl></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2658101"></a>A.1. Release Notes</h2></div></div><div></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2658106"></a>A.1.1. Release 1.1.4</h3></div></div><div></div></div><p>Release date: 2006/09/27</p><p>
+This is an bugfix release including some improvements in the Java interface.
+Upgrade is <span class="emphasis"><em>encouraged</em></span>.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658124"></a>A.1.1.1. Upgrading</h4></div></div><div></div></div><p>
+If you are upgrading from release 1.0.3 or later follow the
+<a href="#soft_upgrade" title="2.2.1.1. Soft upgrade">soft upgrade</a> procedure.
+				</p><p>
+If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6 and
+1.0.2</em></span> (inclusive) and really want a live upgrade read the
+<a href="#rel_1.0.3_upgrading" title="A.1.9. Release 1.0.3">upgrade section</a> of the 1.0.3
+release notes chapter.
+				</p><p>
+Upgrade from any release prior to 1.0.0RC6 requires an
+<a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a>.
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658173"></a>A.1.1.2. Bug fixes</h4></div></div><div></div></div><p>
+	Fixed support for PostgreSQL 8.2
+		</p><p>
+	Fixed bug in collect() function discarding SRID of
+	  input
+		</p><p>
+	Added SRID match check in MakeBox2d and MakeBox3d
+		</p><p>
+	Fixed regress tests to pass with GEOS-3.0.0
+		</p><p>
+	Improved pgsql2shp run concurrency.
+		</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658201"></a>A.1.1.3. Java changes</h4></div></div><div></div></div><p>
+		reworked JTS support to reflect new upstream
+		JTS developers' attitude to SRID handling.
+		Simplifies code and drops build depend on GNU trove.
+		</p><p>
+		Added EJB2 support generously donated by the
+		"Geodetix s.r.l. Company" http://www.geodetix.it/
+		</p><p>
+		Added EJB3 tutorial / examples donated by
+		Norman Barker &lt;nbarker at ittvis.com&gt;
+		</p><p>
+		Reorganized java directory layout a little.
+		</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2658230"></a>A.1.2. Release 1.1.3</h3></div></div><div></div></div><p>Release date: 2006/06/30</p><p>
+This is an bugfix release including also some new functionalities (most notably long transaction support) and portability enhancements.
+Upgrade is <span class="emphasis"><em>encouraged</em></span>.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658249"></a>A.1.2.1. Upgrading</h4></div></div><div></div></div><p>
+If you are upgrading from release 1.0.3 or later follow the
+<a href="#soft_upgrade" title="2.2.1.1. Soft upgrade">soft upgrade</a> procedure.
+				</p><p>
+If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6 and
+1.0.2</em></span> (inclusive) and really want a live upgrade read the
+<a href="#rel_1.0.3_upgrading" title="A.1.9. Release 1.0.3">upgrade section</a> of the 1.0.3
+release notes chapter.
+				</p><p>
+Upgrade from any release prior to 1.0.0RC6 requires an
+<a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a>.
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658295"></a>A.1.2.2. Bug fixes / correctness</h4></div></div><div></div></div><p> BUGFIX in distance(poly,poly) giving wrong results. </p><p> BUGFIX in pgsql2shp successful return code. </p><p> BUGFIX in shp2pgsql handling of MultiLine WKT. </p><p> BUGFIX in affine() failing to update bounding box. </p><p> WKT parser: forbidden construction of multigeometries with 
+	  EMPTY elements (still supported for GEOMETRYCOLLECTION). </p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658324"></a>A.1.2.3. New functionalities</h4></div></div><div></div></div><p> NEW Long Transactions support. </p><p> NEW DumpRings() function. </p><p> NEW AsHEXEWKB(geom, XDR|NDR) function. </p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658343"></a>A.1.2.4. JDBC changes</h4></div></div><div></div></div><p> Improved regression tests: MultiPoint and scientific ordinates </p><p> Fixed some minor bugs in jdbc code </p><p>
+Added proper accessor functions for all fields in preparation of 
+making those fields private later
+</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658363"></a>A.1.2.5. Other changes</h4></div></div><div></div></div><p> NEW regress test support for loader/dumper. </p><p> Added --with-proj-libdir and --with-geos-libdir configure switches. </p><p> Support for build Tru64 build. </p><p> Use Jade for generating documentation. </p><p> Don't link pgsql2shp to more libs then required. </p><p> Initial support for PostgreSQL 8.2. </p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2658396"></a>A.1.3. Release 1.1.2</h3></div></div><div></div></div><p>Release date: 2006/03/30</p><p>
+This is an bugfix release including some new functions and portability enhancements.
+Upgrade is <span class="emphasis"><em>encouraged</em></span>.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658414"></a>A.1.3.1. Upgrading</h4></div></div><div></div></div><p>
+If you are upgrading from release 1.0.3 or later follow the
+<a href="#soft_upgrade" title="2.2.1.1. Soft upgrade">soft upgrade</a> procedure.
+				</p><p>
+If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6 and
+1.0.2</em></span> (inclusive) and really want a live upgrade read the
+<a href="#rel_1.0.3_upgrading" title="A.1.9. Release 1.0.3">upgrade section</a> of the 1.0.3
+release notes chapter.
+				</p><p>
+Upgrade from any release prior to 1.0.0RC6 requires an
+<a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a>.
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658623"></a>A.1.3.2. Bug fixes</h4></div></div><div></div></div><p>BUGFIX in SnapToGrid() computation of output bounding box</p><p>BUGFIX in EnforceRHR() </p><p>jdbc2 SRID handling fixes in JTS code</p><p>Fixed support for 64bit archs</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658646"></a>A.1.3.3. New functionalities</h4></div></div><div></div></div><p>Regress tests can now be run *before* postgis installation</p><p>New affine() matrix transformation functions</p><p>New rotate{,X,Y,Z}() function </p><p>Old translating and scaling functions now use affine() internally</p><p>Embedded access control in estimated_extent() for builds against pgsql &gt;= 8.0.0</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658674"></a>A.1.3.4. Other changes</h4></div></div><div></div></div><p>More portable ./configure script</p><p>Changed ./run_test script to have more sane default behaviour</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2658690"></a>A.1.4. Release 1.1.1</h3></div></div><div></div></div><p>Release date: 2006/01/23</p><p>
+This is an important Bugfix release, upgrade is <span class="emphasis"><em>highly
+recommended</em></span>.
+Previous version contained a bug in postgis_restore.pl preventing
+<a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a> procedure to complete
+and a bug in GEOS-2.2+ connector preventing GeometryCollection objects
+to be used in topological operations.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658718"></a>A.1.4.1. Upgrading</h4></div></div><div></div></div><p>
+If you are upgrading from release 1.0.3 or later follow the
+<a href="#soft_upgrade" title="2.2.1.1. Soft upgrade">soft upgrade</a> procedure.
+				</p><p>
+If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6 and
+1.0.2</em></span> (inclusive) and really want a live upgrade read the
+<a href="#rel_1.0.3_upgrading" title="A.1.9. Release 1.0.3">upgrade section</a> of the 1.0.3
+release notes chapter.
+				</p><p>
+Upgrade from any release prior to 1.0.0RC6 requires an
+<a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a>.
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658765"></a>A.1.4.2. Bug fixes</h4></div></div><div></div></div><p>Fixed a premature exit in postgis_restore.pl </p><p>BUGFIX in geometrycollection handling of GEOS-CAPI connector</p><p>Solaris 2.7 and MingW support improvements</p><p>BUGFIX in line_locate_point()</p><p>Fixed handling of postgresql paths</p><p>BUGFIX in line_substring()</p><p>Added support for localized cluster in regress tester</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658800"></a>A.1.4.3. New functionalities</h4></div></div><div></div></div><p>New Z and M interpolation in line_substring()</p><p>New Z and M interpolation in line_interpolate_point()</p><p>added NumInteriorRing() alias due to OpenGIS ambiguity</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2658820"></a>A.1.5. Release 1.1.0</h3></div></div><div></div></div><p>Release date: 2005/12/21</p><p>
+This is a Minor release, containing many improvements and new things.
+Most notably: build procedure greatly simplified; transform() performance
+drastically improved; more stable GEOS connectivity (CAPI support);
+lots of new functions; draft topology support.
+			</p><p>
+It is <span class="emphasis"><em>highly recommended</em></span> that you upgrade to GEOS-2.2.x
+before installing PostGIS, this will ensure future GEOS upgrades won't
+require a rebuild of the PostGIS library.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658847"></a>A.1.5.1. Credits</h4></div></div><div></div></div><p>
+This release includes code from Mark Cave Ayland for caching of proj4
+objects. Markus Schaber added many improvements in his JDBC2 code.
+Alex Bodnaru helped with PostgreSQL source dependency relief and
+provided Debian specfiles.  Michael Fuhr tested new things on Solaris arch.
+David Techer and Gerald Fenoy helped testing GEOS C-API connector.
+Hartmut Tschauner provided code for the azimuth() function. 
+Devrim GUNDUZ provided RPM specfiles. Carl Anderson helped with
+the new area building functions.
+See the <a href="#credits" title="1.1. Credits">credits</a> section for more names.
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658874"></a>A.1.5.2. Upgrading</h4></div></div><div></div></div><p>
+If you are upgrading from release 1.0.3 or later you <span class="emphasis"><em>DO
+NOT</em></span> need a dump/reload.
+Simply sourcing the new lwpostgis_upgrade.sql script in all your
+existing databases will work.
+See the <a href="#soft_upgrade" title="2.2.1.1. Soft upgrade">soft upgrade</a> chapter
+for more information.
+				</p><p>
+If you are upgrading from a release <span class="emphasis"><em>between 1.0.0RC6 and
+1.0.2</em></span> (inclusive) and really want a live upgrade read the
+<a href="#rel_1.0.3_upgrading" title="A.1.9. Release 1.0.3">upgrade section</a> of the 1.0.3
+release notes chapter.
+				</p><p>
+Upgrade from any release prior to 1.0.0RC6 requires an
+<a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a>.
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658927"></a>A.1.5.3. New functions</h4></div></div><div></div></div><p>scale() and transscale() companion methods to translate()</p><p>line_substring() </p><p>line_locate_point()</p><p>M(point) </p><p>LineMerge(geometry) </p><p>shift_longitude(geometry) </p><p>azimuth(geometry) </p><p>locate_along_measure(geometry, float8) </p><p>locate_between_measures(geometry, float8, float8) </p><p>SnapToGrid by point offset (up to 4d support)</p><p>BuildArea(any_geometry) </p><p>OGC BdPolyFromText(linestring_wkt, srid) </p><p>OGC BdMPolyFromText(linestring_wkt, srid)</p><p>RemovePoint(linestring, offset)</p><p>ReplacePoint(linestring, offset, point)</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2658991"></a>A.1.5.4. Bug fixes</h4></div></div><div></div></div><p>Fixed memory leak in polygonize()</p><p>Fixed bug in lwgeom_as_anytype cast functions</p><p>
+Fixed USE_GEOS, USE_PROJ and USE_STATS elements of postgis_version()
+output to always reflect library state.
+</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659011"></a>A.1.5.5. Function semantic changes</h4></div></div><div></div></div><p>SnapToGrid doesn't discard higher dimensions</p><p>Changed Z() function to return NULL if requested dimension is not available</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659027"></a>A.1.5.6. Performance improvements</h4></div></div><div></div></div><p>
+Much faster transform() function, caching proj4 objects
+</p><p>
+Removed automatic call to fix_geometry_columns() in
+AddGeometryColumns() and update_geometry_stats()
+</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659043"></a>A.1.5.7. JDBC2 works</h4></div></div><div></div></div><p>Makefile improvements</p><p>JTS support improvements</p><p>Improved regression test system</p><p>Basic consistency check method for geometry collections</p><p>Support for (Hex)(E)wkb</p><p>Autoprobing DriverWrapper for HexWKB / EWKT switching</p><p>fix compile problems in ValueSetter for ancient jdk releases.</p><p>fix EWKT constructors to accept SRID=4711; representation</p><p>added preliminary read-only support for java2d geometries</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659086"></a>A.1.5.8. Other new things</h4></div></div><div></div></div><p>
+Full autoconf-based configuration, with PostgreSQL source dependency relief
+</p><p>GEOS C-API support (2.2.0 and higher)</p><p>Initial support for topology modelling</p><p>Debian and RPM specfiles</p><p>New lwpostgis_upgrade.sql script</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659113"></a>A.1.5.9. Other changes</h4></div></div><div></div></div><p>JTS support improvements</p><p>Stricter mapping between DBF and SQL integer and string attributes</p><p>Wider and cleaner regression test suite</p><p>old jdbc code removed from release</p><p>obsoleted direct use of postgis_proc_upgrade.pl</p><p>scripts version unified with release version</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2659145"></a>A.1.6. Release 1.0.6</h3></div></div><div></div></div><p>Release date: 2005/12/06</p><p>
+Contains a few bug fixes and improvements.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659159"></a>A.1.6.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
+				release 1.0.3 or later you <span class="emphasis"><em>DO
+				NOT</em></span> need a dump/reload.
+				</p><p>If you are upgrading from
+				a release <span class="emphasis"><em>between 1.0.0RC6 and
+				1.0.2</em></span> (inclusive) and really want
+				a live upgrade read the <a href="#rel_1.0.3_upgrading" title="A.1.9. Release 1.0.3">upgrade
+				section</a> of the 1.0.3 release notes
+				chapter.
+				</p><p>
+				Upgrade from any release prior to 1.0.0RC6
+				requires an <a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard
+				upgrade</a>.
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659203"></a>A.1.6.2. Bug fixes</h4></div></div><div></div></div><p>Fixed palloc(0) call in collection deserializer (only gives problem with --enable-cassert)</p><p>Fixed bbox cache handling bugs</p><p>Fixed geom_accum(NULL, NULL) segfault</p><p>Fixed segfault in addPoint()</p><p>Fixed short-allocation in lwcollection_clone()</p><p>Fixed bug in segmentize()</p><p>Fixed bbox computation of SnapToGrid output</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659238"></a>A.1.6.3. Improvements</h4></div></div><div></div></div><p>Initial support for postgresql 8.2</p><p>Added missing SRID mismatch checks in GEOS ops</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2659254"></a>A.1.7. Release 1.0.5</h3></div></div><div></div></div><p>Release date: 2005/11/25</p><p>
+Contains memory-alignment fixes in the library, a segfault fix in loader's
+handling of UTF8 attributes and a few improvements and cleanups.
+			</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>
+Return code of shp2pgsql changed from previous releases to conform to unix
+standards (return 0 on success).
+			</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659275"></a>A.1.7.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
+				release 1.0.3 or later you <span class="emphasis"><em>DO
+				NOT</em></span> need a dump/reload.
+				</p><p>If you are upgrading from
+				a release <span class="emphasis"><em>between 1.0.0RC6 and
+				1.0.2</em></span> (inclusive) and really want
+				a live upgrade read the <a href="#rel_1.0.3_upgrading" title="A.1.9. Release 1.0.3">upgrade
+				section</a> of the 1.0.3 release notes
+				chapter.
+				</p><p>
+				Upgrade from any release prior to 1.0.0RC6
+				requires an <a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard
+				upgrade</a>.
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659319"></a>A.1.7.2. Library changes</h4></div></div><div></div></div><p>Fixed memory alignment problems</p><p>Fixed computation of null values fraction in analyzer</p><p>Fixed a small bug in the getPoint4d_p() low-level function</p><p>Speedup of serializer functions</p><p>Fixed a bug in force_3dm(), force_3dz() and force_4d()</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659346"></a>A.1.7.3. Loader changes</h4></div></div><div></div></div><p>Fixed return code of shp2pgsql</p><p>Fixed back-compatibility issue in loader (load of null shapefiles)</p><p>Fixed handling of trailing dots in dbf numerical attributes</p><p>Segfault fix in shp2pgsql (utf8 encoding)</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659369"></a>A.1.7.4. Other changes</h4></div></div><div></div></div><p>Schema aware postgis_proc_upgrade.pl, support for pgsql 7.2+</p><p>New "Reporting Bugs" chapter in manual</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2659386"></a>A.1.8. Release 1.0.4</h3></div></div><div></div></div><p>Release date: 2005/09/09</p><p>
+Contains important bug fixes and a few improvements. In particular, it
+fixes a memory leak preventing successful build of GiST indexes
+for large spatial tables.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659401"></a>A.1.8.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
+				release 1.0.3 you <span class="emphasis"><em>DO
+				NOT</em></span> need a dump/reload.
+				</p><p>If you are upgrading from
+				a release <span class="emphasis"><em>between 1.0.0RC6 and
+				1.0.2</em></span> (inclusive) and really want
+				a live upgrade read the <a href="#rel_1.0.3_upgrading" title="A.1.9. Release 1.0.3">upgrade
+				section</a> of the 1.0.3 release notes
+				chapter.
+				</p><p>
+				Upgrade from any release prior to 1.0.0RC6
+				requires an <a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard
+				upgrade</a>.
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659445"></a>A.1.8.2. Bug fixes</h4></div></div><div></div></div><p>Memory leak plugged in GiST indexing</p><p>Segfault fix in transform() handling of proj4 errors</p><p>Fixed some proj4 texts in spatial_ref_sys (missing +proj)</p><p>Loader: fixed string functions usage, reworked NULL objects check, fixed segfault on MULTILINESTRING input.</p><p>Fixed bug in MakeLine dimension handling</p><p>Fixed bug in translate() corrupting output bounding box</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659477"></a>A.1.8.3. Improvements</h4></div></div><div></div></div><p>Documentation improvements</p><p>More robust selectivity estimator </p><p>Minor speedup in distance()</p><p>Minor cleanups </p><p>GiST indexing cleanup</p><p>Looser syntax acceptance in box3d parser</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="rel_1.0.3_upgrading"></a>A.1.9. Release 1.0.3</h3></div></div><div></div></div><p>Release date: 2005/08/08</p><p>
+Contains some bug fixes - <span class="emphasis"><em>including a severe one affecting
+correctness of stored geometries</em></span> - and a few improvements.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659530"></a>A.1.9.1. Upgrading</h4></div></div><div></div></div><p>
+Due to a bug in a bounding box computation routine, the upgrade procedure
+requires special attention, as bounding boxes cached in the database could
+be incorrect.
+				</p><p>
+An <a href="#hard_upgrade" title="2.2.1.2. Hard upgrade">hard upgrade</a> procedure (dump/reload)
+will force recomputation of all bounding boxes (not included in dumps).
+This is <span class="emphasis"><em>required</em></span> if upgrading from releases prior
+to 1.0.0RC6.
+				</p><p>
+If you are upgrading from versions 1.0.0RC6 or up, this release includes a
+perl script (utils/rebuild_bbox_caches.pl) to force recomputation of
+geometries' bounding boxes and invoke all operations required to propagate
+eventual changes in them (geometry statistics update, reindexing).
+Invoke the script after a make install (run with no args for syntax help).
+Optionally run utils/postgis_proc_upgrade.pl to refresh postgis procedures
+and functions signatures (see <a href="#soft_upgrade" title="2.2.1.1. Soft upgrade">Soft upgrade</a>).
+				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659578"></a>A.1.9.2. Bug fixes</h4></div></div><div></div></div><p>Severe bugfix in lwgeom's 2d bounding box computation</p><p>Bugfix in WKT (-w) POINT handling in loader</p><p>Bugfix in dumper on 64bit machines</p><p>Bugfix in dumper handling of user-defined queries </p><p>Bugfix in create_undef.pl script</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659604"></a>A.1.9.3. Improvements</h4></div></div><div></div></div><p>Small performance improvement in canonical input function</p><p>Minor cleanups in loader</p><p>Support for multibyte field names in loader</p><p>Improvement in the postgis_restore.pl script</p><p>New rebuild_bbox_caches.pl util script</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2659632"></a>A.1.10. Release 1.0.2</h3></div></div><div></div></div><p>Release date: 2005/07/04</p><p>
+			Contains a few bug fixes and improvements.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659646"></a>A.1.10.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
+				release 1.0.0RC6 or up you <span class="emphasis"><em>DO
+				NOT</em></span> need a dump/reload.</p><p>Upgrading from older releases
+				requires a dump/reload. 
+				See the <a href="#upgrading" title="2.2.1. Upgrading">upgrading</a>
+				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659673"></a>A.1.10.2. Bug fixes</h4></div></div><div></div></div><p>Fault tolerant btree ops</p><p>Memory leak plugged in pg_error</p><p>Rtree index fix</p><p>Cleaner build scripts (avoided mix of CFLAGS and CXXFLAGS)</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659695"></a>A.1.10.3. Improvements</h4></div></div><div></div></div><p>New index creation capabilities in loader (-I switch)</p><p>Initial support for postgresql 8.1dev</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2659711"></a>A.1.11. Release 1.0.1</h3></div></div><div></div></div><p>Release date: 2005/05/24</p><p>
+			Contains a few bug fixes and some improvements.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659725"></a>A.1.11.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
+				release 1.0.0RC6 or up you <span class="emphasis"><em>DO
+				NOT</em></span> need a dump/reload.</p><p>Upgrading from older releases
+				requires a dump/reload. 
+				See the <a href="#upgrading" title="2.2.1. Upgrading">upgrading</a>
+				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659752"></a>A.1.11.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in 3d computation of length_spheroid()</p><p>BUGFIX in join selectivity estimator</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659767"></a>A.1.11.3. Other changes/additions</h4></div></div><div></div></div><p>BUGFIX in shp2pgsql escape functions</p><p>better support for concurrent postgis in multiple schemas</p><p>documentation fixes</p><p>jdbc2: compile with "-target 1.2 -source 1.2" by default</p><p>NEW -k switch for pgsql2shp</p><p>NEW support for custom createdb options in postgis_restore.pl</p><p>BUGFIX in pgsql2shp attribute names unicity enforcement</p><p>BUGFIX in Paris projections definitions</p><p>postgis_restore.pl cleanups</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2659811"></a>A.1.12. Release 1.0.0</h3></div></div><div></div></div><p>Release date: 2005/04/19</p><p>Final 1.0.0 release.
+			Contains a few bug fixes, some improvements
+			in the loader (most notably support for older
+			postgis versions), and more docs.
+			</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659826"></a>A.1.12.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
+				release 1.0.0RC6 you <span class="emphasis"><em>DO
+				NOT</em></span> need a dump/reload.</p><p>Upgrading from any other precedent
+				release requires a dump/reload. 
+				See the <a href="#upgrading" title="2.2.1. Upgrading">upgrading</a>
+				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659853"></a>A.1.12.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in transform() releasing random memory address</p><p>BUGFIX in force_3dm() allocating less memory then required</p><p>BUGFIX in join selectivity estimator (defaults, leaks, tuplecount, sd)</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659873"></a>A.1.12.3. Other changes/additions</h4></div></div><div></div></div><p>BUGFIX in shp2pgsql escape of values starting with tab or single-quote</p><p>NEW manual pages for loader/dumper</p><p>NEW shp2pgsql support for old (HWGEOM) postgis versions</p><p>NEW -p (prepare) flag for shp2pgsql</p><p>NEW manual chapter about OGC compliancy enforcement</p><p>NEW autoconf support for JTS lib</p><p>BUGFIX in estimator testers (support for LWGEOM and schema parsing)</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2659910"></a>A.1.13. Release 1.0.0RC6</h3></div></div><div></div></div><p>Release date: 2005/03/30</p><p>Sixth release candidate for 1.0.0.
+			Contains a few bug fixes and cleanups.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659924"></a>A.1.13.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
+				from precedent releases. See the <a href="#upgrading" title="2.2.1. Upgrading">upgrading</a>
+				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659943"></a>A.1.13.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in multi()</p><p>early return [when noop] from multi()</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659957"></a>A.1.13.3. Scripts changes</h4></div></div><div></div></div><p>dropped {x,y}{min,max}(box2d) functions</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659968"></a>A.1.13.4. Other changes</h4></div></div><div></div></div><p>BUGFIX in postgis_restore.pl scrip</p><p>BUGFIX in dumper's 64bit support</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2659984"></a>A.1.14. Release 1.0.0RC5</h3></div></div><div></div></div><p>Release date: 2005/03/25</p><p>Fifth release candidate for 1.0.0.
+			Contains a few bug fixes and a improvements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2659998"></a>A.1.14.1. Upgrading</h4></div></div><div></div></div><p>If you are upgrading from
+				release 1.0.0RC4 you <span class="emphasis"><em>DO
+				NOT</em></span> need a dump/reload.</p><p>Upgrading from any other precedent
+				release requires a dump/reload. 
+				See the <a href="#upgrading" title="2.2.1. Upgrading">upgrading</a>
+				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660025"></a>A.1.14.2. Library changes</h4></div></div><div></div></div><p>BUGFIX (segfaulting) in box3d computation (yes, another!).</p><p>BUGFIX (segfaulting) in estimated_extent().</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660040"></a>A.1.14.3. Other changes</h4></div></div><div></div></div><p>Small build scripts and utilities refinements.</p><p>Additional performance tips documented.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2660056"></a>A.1.15. Release 1.0.0RC4</h3></div></div><div></div></div><p>Release date: 2005/03/18</p><p>Fourth release candidate for 1.0.0.
+			Contains bug fixes and a few improvements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660070"></a>A.1.15.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
+				from precedent releases. See the <a href="#upgrading" title="2.2.1. Upgrading">upgrading</a>
+				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660088"></a>A.1.15.2. Library changes</h4></div></div><div></div></div><p>BUGFIX (segfaulting) in geom_accum().</p><p>BUGFIX in 64bit architectures support.</p><p>BUGFIX in box3d computation function with collections.</p><p>NEW subselects support in selectivity estimator.</p><p>Early return from force_collection.</p><p>Consistency check fix in SnapToGrid().</p><p>Box2d output changed back to 15 significant digits.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660124"></a>A.1.15.3. Scripts changes</h4></div></div><div></div></div><p>NEW distance_sphere() function.</p><p>Changed get_proj4_from_srid implementation to use PL/PGSQL instead of SQL.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660139"></a>A.1.15.4. Other changes</h4></div></div><div></div></div><p>BUGFIX in loader and dumper handling of MultiLine shapes</p><p>BUGFIX in loader, skipping all but first hole of polygons.</p><p>jdbc2: code cleanups, Makefile improvements</p><p>FLEX and YACC variables set *after* pgsql Makefile.global is included and only if the pgsql *stripped* version evaluates to the empty string</p><p>Added already generated parser in release</p><p>Build scripts refinements</p><p>improved version handling, central Version.config</p><p>improvements in postgis_restore.pl</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2660181"></a>A.1.16. Release 1.0.0RC3</h3></div></div><div></div></div><p>Release date: 2005/02/24</p><p>Third release candidate for 1.0.0.
+			Contains many bug fixes and improvements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660195"></a>A.1.16.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
+				from precedent releases. See the <a href="#upgrading" title="2.2.1. Upgrading">upgrading</a>
+				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660213"></a>A.1.16.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in transform(): missing SRID, better error handling.</p><p>BUGFIX in memory alignment handling</p><p>BUGFIX in force_collection() causing mapserver connector failures on simple (single) geometry types.</p><p>BUGFIX in GeometryFromText() missing to add a bbox cache.</p><p>reduced precision of box2d output.</p><p>prefixed DEBUG macros with PGIS_ to avoid clash with pgsql one</p><p>plugged a leak in GEOS2POSTGIS converter</p><p>Reduced memory usage by early releasing query-context palloced one.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660254"></a>A.1.16.3. Scripts changes</h4></div></div><div></div></div><p>BUGFIX in 72 index bindings.</p><p>BUGFIX in probe_geometry_columns() to work with PG72 and support multiple geometry columns in a single table</p><p>NEW bool::text cast</p><p>Some functions made IMMUTABLE from STABLE, for performance
+	improvement.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660278"></a>A.1.16.4. JDBC changes</h4></div></div><div></div></div><p>jdbc2: small patches, box2d/3d tests, revised docs and license.</p><p>jdbc2: bug fix and testcase in for pgjdbc 8.0 type autoregistration</p><p>jdbc2: Removed use of jdk1.4 only features to enable build with older jdk releases.</p><p>jdbc2: Added support for building against pg72jdbc2.jar</p><p>jdbc2: updated and cleaned makefile</p><p>jdbc2: added BETA support for jts geometry classes</p><p>jdbc2: Skip known-to-fail tests against older PostGIS servers.</p><p>jdbc2: Fixed handling of measured geometries in EWKT.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660319"></a>A.1.16.5. Other changes</h4></div></div><div></div></div><p>new performance tips chapter in manual</p><p>documentation updates: pgsql72 requirement, lwpostgis.sql</p><p>few changes in autoconf </p><p>BUILDDATE extraction made more portable</p><p>fixed spatial_ref_sys.sql to avoid vacuuming the whole
+	database.</p><p>spatial_ref_sys: changed Paris entries to match the ones
+	distributed with 0.x.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2660352"></a>A.1.17. Release 1.0.0RC2</h3></div></div><div></div></div><p>Release date: 2005/01/26</p><p>Second release candidate for 1.0.0
+			containing bug fixes and a few improvements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660366"></a>A.1.17.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
+				from precedent releases. See the <a href="#upgrading" title="2.2.1. Upgrading">upgrading</a>
+				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660385"></a>A.1.17.2. Library changes</h4></div></div><div></div></div><p>BUGFIX in pointarray box3d computation</p><p>BUGFIX in distance_spheroid definition</p><p>BUGFIX in transform() missing to update bbox cache</p><p>NEW jdbc driver (jdbc2)</p><p>GEOMETRYCOLLECTION(EMPTY) syntax support for backward compatibility</p><p>Faster binary outputs</p><p>Stricter OGC WKB/WKT constructors</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660420"></a>A.1.17.3. Scripts changes</h4></div></div><div></div></div><p>More correct STABLE, IMMUTABLE, STRICT uses in lwpostgis.sql</p><p>stricter OGC WKB/WKT constructors</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660435"></a>A.1.17.4. Other changes</h4></div></div><div></div></div><p>Faster and more robust loader (both i18n and not)</p><p>Initial autoconf script</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2660450"></a>A.1.18. Release 1.0.0RC1</h3></div></div><div></div></div><p>Release date: 2005/01/13</p><p>This is the first candidate of a
+			major postgis release, with internal
+			storage of postgis types redesigned to be smaller
+			and faster on indexed queries.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660466"></a>A.1.18.1. Upgrading</h4></div></div><div></div></div><p>You need a dump/reload to upgrade
+				from precedent releases. See the <a href="#upgrading" title="2.2.1. Upgrading">upgrading</a>
+				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2660484"></a>A.1.18.2. Changes</h4></div></div><div></div></div><p>
+				Faster canonical input parsing.
+				</p><p>
+				Lossless canonical output.
+				</p><p>
+				EWKB Canonical binary IO with PG&gt;73.
+				</p><p>
+				Support for up to 4d coordinates, providing
+				lossless shapefile-&gt;postgis-&gt;shapefile
+				conversion.
+				</p><p>
+				New function: UpdateGeometrySRID(), AsGML(),
+				SnapToGrid(), ForceRHR(), estimated_extent(),
+				accum().
+				</p><p>
+				Vertical positioning indexed operators.
+				</p><p>
+				JOIN selectivity function.
+				</p><p>
+				More geometry constructors / editors.
+				</p><p>
+				Postgis extension API.
+				</p><p>
+				UTF8 support in loader.
+				</p></div></div></div></div></div></body></html>

Modified: packages/postgis/trunk/doc/postgis.xml
===================================================================
--- packages/postgis/trunk/doc/postgis.xml	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/doc/postgis.xml	2006-10-06 08:50:14 UTC (rev 563)
@@ -17,7 +17,7 @@
         Inc</ulink></orgname>
 
         <address>
-     <street>Suite 400, 1207 Douglas Street</street>
+     <street>Suite 300, 1207 Douglas Street</street>
      <city>Victoria</city>
      <state>British Columbia</state>
      <country>Canada</country>
@@ -56,7 +56,7 @@
           <term>Sandro Santilli &lt;strk at refractions.net&gt;</term>
 
           <listitem>
-            <para>Coordinates all bug fixing and maintainance effort,
+            <para>Coordinates all bug fixing and maintenance effort,
             integration of new GEOS functionality, and new function
             enhancements.</para>
           </listitem>
@@ -423,7 +423,7 @@
 By HARD UPGRADE we intend full dump/reload of postgis-enabled databases.
 You need an HARD UPGRADE when postgis objects' internal storage
 changes or when SOFT UPGRADE is not possible.
-The <link linkend="release_notes">Release Notes</link> appendix reports for each version wheter you need a
+The <link linkend="release_notes">Release Notes</link> appendix reports for each version whether you need a
 dump/reload (HARD UPGRADE) to upgrade.
 	</para>
 
@@ -493,7 +493,7 @@
             <para>Check that you you have installed PostgreSQL 7.2 or newer,
             and that you are compiling against the same version of the
             PostgreSQL source as the version of PostgreSQL that is running.
-            Mix-ups can occur when your (Linux) distrubution has already
+            Mix-ups can occur when your (Linux) distribution has already
             installed PostgreSQL, or you have otherwise installed PostgreSQL
             before and forgotten about it. PostGIS will only work with
             PostgreSQL 7.2 or newer, and strange, unexpected error messages
@@ -1437,7 +1437,7 @@
             <term>-k</term>
 
             <listitem>
-              <para>Keep idendifiers case (column, schema and attributes). Note that attributes in Shapefile are all UPPERCASE.</para>
+              <para>Keep identifiers' case (column, schema and attributes). Note that attributes in Shapefile are all UPPERCASE.</para>
             </listitem>
           </varlistentry>
 
@@ -1836,7 +1836,7 @@
           </listitem>
 
           <listitem>
-            <para>If you find the planner wrong about the cost of sequencial
+            <para>If you find the planner wrong about the cost of sequential
             vs index scans try reducing the value of random_page_cost in
             postgresql.conf or using SET random_page_cost=#. Default value for
             the parameter is 4, try setting it to 1 or 2. Decrementing the
@@ -1859,7 +1859,7 @@
         <title>Taking Advantage of Indexes</title>
 
         <para>When constructing a query it is important to remember that only
-        the bounding-box-based operators such as &amp;&amp; can take advatage
+        the bounding-box-based operators such as &amp;&amp; can take advantage
         of the GiST spatial index. Functions such as
         <varname>distance()</varname> cannot use the index to optimize their
         operation. For example, the following query would be quite slow on a
@@ -2437,7 +2437,7 @@
 
         <para>Now lets say we want to show only the highways until we get
         zoomed in to at least a 1:100000 scale - the next two layers will
-        acheive this effect:</para>
+        achieve this effect:</para>
 
         <programlisting>LAYER
  CONNECTION "user=theuser password=thepass dbname=thedb host=theserver"
@@ -2633,9 +2633,9 @@
 <para>
 The problem appears if you happen to have a table with rather large
 geometries, but not too much rows of them (like a table containing the
-boundaries of all european countries in high resolution). Then the table
-itsself is small, but it uses lots of TOAST space. In our example case,
-the table itsself had about 80 rows and used only 3 data pages, but the
+boundaries of all European countries in high resolution). Then the table
+itself is small, but it uses lots of TOAST space. In our example case,
+the table itself had about 80 rows and used only 3 data pages, but the
 TOAST table used 8225 pages.
 </para>
 
@@ -2699,7 +2699,7 @@
 </programlisting>
 
 <para>
-Of yourse, if you change or add rows to mytable, you have to keep the
+Of course, if you change or add rows to mytable, you have to keep the
 bbox "in sync". The most transparent way to do this would be triggers,
 but you also can modify your application to keep the bbox column current
 or run the UPDATE query above after every modification.
@@ -3210,8 +3210,8 @@
             <term>Difference(geometry A, geometry B)</term>
 
             <listitem>
-              <para>Returns a geometry that represents the point set symmetric
-              difference of Geometry A with Geometry B.</para>
+              <para>Returns a geometry that represents the point set difference
+              of Geometry A with Geometry B.</para>
 
               <para>Performed by the GEOS module</para>
 
@@ -3464,7 +3464,7 @@
 
             <listitem>
               <para>Synonym to NumInteriorRings(geometry). The OpenGIS specs
-	      are ambigous about the exact function naming, so we provide
+	      are ambiguous about the exact function naming, so we provide
 	      both spellings.</para>
             </listitem>
           </varlistentry>
@@ -4204,7 +4204,7 @@
 
 		  <listitem>
 		    <para>The "&amp;&amp;" operator is the "overlaps" operator. If A's
-		    bounding boux overlaps B's bounding box the operator returns
+		    bounding box overlaps B's bounding box the operator returns
 		    true.</para>
 		  </listitem>
 		</varlistentry>
@@ -4269,10 +4269,10 @@
           <term>length_spheroid(geometry,spheroid)</term>
 
           <listitem>
-            <para>Calculates the length of of a geometry on an elipsoid. This
+            <para>Calculates the length of of a geometry on an ellipsoid. This
             is useful if the coordinates of the geometry are in
             latitude/longitude and a length is desired without reprojection.
-            The elipsoid is a separate database type and can be constructed as
+            The ellipsoid is a separate database type and can be constructed as
             follows:</para>
 
             <literallayout>SPHEROID[&lt;NAME&gt;,&lt;SEMI-MAJOR AXIS&gt;,&lt;INVERSE FLATTENING&gt;]</literallayout>
@@ -4296,7 +4296,7 @@
           <term>length3d_spheroid(geometry,spheroid)</term>
 
           <listitem>
-            <para>Calculates the length of of a geometry on an elipsoid,
+            <para>Calculates the length of of a geometry on an ellipsoid,
             taking the elevation into account. This is just like
             length_spheroid except vertical coordinates (expressed in the same
             units as the spheroid axes) are used to calculate the extra
@@ -4512,7 +4512,7 @@
 		<varlistentry id="BuildArea">
 		  <term>BuildArea(geometry)</term>
 		  <listitem>
-		    <para>Creates an areal geometry formed by the costituent
+		    <para>Creates an areal geometry formed by the constituent
 		    linework of given geometry. The return type can
 		    be a Polygon or MultiPolygon, depending on input.
 		    If the input lineworks do not form polygons NULL is
@@ -4536,7 +4536,7 @@
 
 		<para>
 			Aggregate. Creates a GeometryCollection containing
-			possible polygons formed from the costituent linework
+			possible polygons formed from the constituent linework
 			of a set of geometries.
 		</para>
 
@@ -4949,7 +4949,7 @@
 
 		<para>
 			Returns a (set of) LineString(s) formed by sewing
-			togheter costituent linework of input.
+			together constituent linework of input.
 		</para>
 
 		<para>
@@ -4972,7 +4972,7 @@
 
           <listitem>
 		<para>
-		Returns a poin interpolated along a line.
+		Returns a point interpolated along a line.
 		First argument must be a LINESTRING.
 		Second argument is a float8 between 0 and 1
 		representing fraction of total
@@ -5275,7 +5275,7 @@
 	Reporting bugs effectively is a fundamental way to help PostGIS
 	development. The most effective bug report is that enabling 
 	PostGIS developers to reproduce it, so it would ideally contain
-	a script triggering it and every information reguarding the
+	a script triggering it and every information regarding the
 	environment in which it was detected. Good enough info can
 	be extracted running <code>SELECT postgis_full_version()</code>
 	[for postgis] and <code>SELECT version()</code> [for postgresql].
@@ -5313,6 +5313,78 @@
 		<title>Release Notes</title>
 
     		<sect2>
+			<title>Release 1.1.4</title>
+			<para>Release date: 2006/09/27</para>
+
+			<para>
+This is an bugfix release including some improvements in the Java interface.
+Upgrade is <emphasis>encouraged</emphasis>.
+			</para>
+
+			<sect3>
+				<title>Upgrading</title>
+
+				<para>
+If you are upgrading from release 1.0.3 or later follow the
+<link linkend="soft_upgrade">soft upgrade</link> procedure.
+				</para>
+
+				<para>
+If you are upgrading from a release <emphasis>between 1.0.0RC6 and
+1.0.2</emphasis> (inclusive) and really want a live upgrade read the
+<link linkend="rel_1.0.3_upgrading">upgrade section</link> of the 1.0.3
+release notes chapter.
+				</para>
+
+				<para>
+Upgrade from any release prior to 1.0.0RC6 requires an
+<link linkend="hard_upgrade">hard upgrade</link>.
+				</para>
+			</sect3>
+
+
+			<sect3>
+				<title>Bug fixes</title>
+		<para>
+	Fixed support for PostgreSQL 8.2
+		</para>
+		<para>
+	Fixed bug in collect() function discarding SRID of
+	  input
+		</para>
+		<para>
+	Added SRID match check in MakeBox2d and MakeBox3d
+		</para>
+		<para>
+	Fixed regress tests to pass with GEOS-3.0.0
+		</para>
+		<para>
+	Improved pgsql2shp run concurrency.
+		</para>
+			</sect3>
+
+			<sect3>
+				<title>Java changes</title>
+		<para>
+		reworked JTS support to reflect new upstream
+		JTS developers' attitude to SRID handling.
+		Simplifies code and drops build depend on GNU trove.
+		</para>
+		<para>
+		Added EJB2 support generously donated by the
+		"Geodetix s.r.l. Company" http://www.geodetix.it/
+		</para>
+		<para>
+		Added EJB3 tutorial / examples donated by
+		Norman Barker &lt;nbarker at ittvis.com&gt;
+		</para>
+        	<para>
+		Reorganized java directory layout a little.
+		</para>
+			</sect3>
+
+		</sect2>
+    		<sect2>
 			<title>Release 1.1.3</title>
 			<para>Release date: 2006/06/30</para>
 
@@ -5422,7 +5494,7 @@
 
 			<sect3>
 				<title>New functionalities</title>
-<para>Regress tests can now be run *before* postgis intallation</para>
+<para>Regress tests can now be run *before* postgis installation</para>
 <para>New affine() matrix transformation functions</para>
 <para>New rotate{,X,Y,Z}() function </para>
 <para>Old translating and scaling functions now use affine() internally</para>
@@ -5532,7 +5604,7 @@
 Simply sourcing the new lwpostgis_upgrade.sql script in all your
 existing databases will work.
 See the <link linkend="soft_upgrade">soft upgrade</link> chapter
-for more informations.
+for more information.
 				</para>
 
 				<para>
@@ -5570,7 +5642,7 @@
 			<sect3>
 				<title>Bug fixes</title>
 <para>Fixed memory leak in polygonize()</para>
-<para>Fixed bug in lwgeom_as_anytype cast funcions</para>
+<para>Fixed bug in lwgeom_as_anytype cast functions</para>
 <para>
 Fixed USE_GEOS, USE_PROJ and USE_STATS elements of postgis_version()
 output to always reflect library state.
@@ -5693,7 +5765,7 @@
 			</para>
 
 			<note><para>
-Return code of shp2pgsl changed from previous releases to conform to unix
+Return code of shp2pgsql changed from previous releases to conform to unix
 standards (return 0 on success).
 			</para></note>
 
@@ -5923,13 +5995,13 @@
 
 			<sect3>
 				<title>Library changes</title>
-	<para>BUGFIX in 3d computation of lenght_spheroid()</para>
+	<para>BUGFIX in 3d computation of length_spheroid()</para>
 	<para>BUGFIX in join selectivity estimator</para>
 			</sect3>
 
 			<sect3>
 				<title>Other changes/additions</title>
-	<para>BUGFIX in shp2pgql escape functions</para>
+	<para>BUGFIX in shp2pgsql escape functions</para>
 	<para>better support for concurrent postgis in multiple schemas</para>
 	<para>documentation fixes</para>
 	<para>jdbc2: compile with "-target 1.2 -source 1.2" by default</para>
@@ -6094,7 +6166,7 @@
 <para>BUGFIX in loader and dumper handling of MultiLine shapes</para>
 <para>BUGFIX in loader, skipping all but first hole of polygons.</para>
 <para>jdbc2: code cleanups, Makefile improvements</para>
-<para>FLEX and YACC variables set *after* pgsql Makefile.global is included and only if the pgsql *stripped* version evaulates to the empty string</para>
+<para>FLEX and YACC variables set *after* pgsql Makefile.global is included and only if the pgsql *stripped* version evaluates to the empty string</para>
 <para>Added already generated parser in release</para>
 <para>Build scripts refinements</para>
 <para>improved version handling, central Version.config</para>

Modified: packages/postgis/trunk/extras/WFS_locks/WFS_locks.sql.in
===================================================================
--- packages/postgis/trunk/extras/WFS_locks/WFS_locks.sql.in	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/extras/WFS_locks/WFS_locks.sql.in	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,6 +1,6 @@
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- 
--- $Id: WFS_locks.sql.in,v 1.4 2006/06/25 22:33:55 strk Exp $
+-- $Id: WFS_locks.sql.in 2394 2006-06-25 22:33:55Z strk $
 --
 -- PostGIS - Spatial Types for PostgreSQL
 -- http://postgis.refractions.net

Deleted: packages/postgis/trunk/extras/ogc_test_suite/.cvsignore
===================================================================
--- packages/postgis/trunk/extras/ogc_test_suite/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/extras/ogc_test_suite/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,2 +0,0 @@
-1_output.txt
-2_output.txt

Modified: packages/postgis/trunk/extras/ogc_test_suite/1_schema.sql
===================================================================
--- packages/postgis/trunk/extras/ogc_test_suite/1_schema.sql	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/extras/ogc_test_suite/1_schema.sql	2006-10-06 08:50:14 UTC (rev 563)
@@ -100,7 +100,12 @@
 -- create the spatial_ref_sys table or view via another mechanism.
 -- The size of the srtext VARCHAR exceeds that allowed on some systems.
 --
--- POSTGIS: This is already defined by postgis.sql so we comment it out.
+-- ---------------------
+-- !#@ ADAPTATION BEGIN
+-- This table is already defined by PostGIS so we comment it out here.
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 --CREATE TABLE spatial_ref_sys (
 --       srid       INTEGER NOT NULL PRIMARY KEY,
 --       auth_name  VARCHAR(256),
@@ -108,6 +113,10 @@
 --       srtext     VARCHAR(2048)
 --       srtext     VARCHAR(2000)
 --);
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 INSERT INTO spatial_ref_sys (SRID,AUTH_NAME,AUTH_SRID,SRTEXT) 
 VALUES (101, 'POSC', 32214, 
@@ -147,78 +156,208 @@
 --
 --
 --
--- POSTGIS: We break the schema creation into two steps, first create the 
--- POSTGIS: attribute table, second use the AddGeometryColumn() function 
--- POSTGIS: to create and register the geometry column.
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the 
+-- attribute table, second use the AddGeometryColumn() function 
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- CREATE TABLE lakes (
+--       fid               INTEGER NOT NULL PRIMARY KEY,
+--       name              VARCHAR(64),
+--       shore             POLYGON
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 CREATE TABLE lakes (
        fid               INTEGER NOT NULL PRIMARY KEY,
        name              VARCHAR(64)
---     shore             POLYGON
 );
 SELECT AddGeometryColumn('lakes','shore','101','POLYGON','2');
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
 --
 -- Road Segments
 --
 --
---
---
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the
+-- attribute table, second use the AddGeometryColumn() function
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- CREATE TABLE road_segments (
+--      fid               INTEGER NOT NULL PRIMARY KEY,
+--      name              VARCHAR(64),
+--      aliases           VARCHAR(64),
+--      num_lanes         INTEGER
+--      centerline        LINESTRING
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
+
 CREATE TABLE road_segments (
        fid               INTEGER NOT NULL PRIMARY KEY,
        name              VARCHAR(64),
        aliases           VARCHAR(64),
        num_lanes         INTEGER
---     centerline        LINESTRING
 );
 SELECT AddGeometryColumn('road_segments','centerline','101','LINESTRING','2');
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
 --
 -- Divided Routes
 --
 --
 --
 --
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the
+-- attribute table, second use the AddGeometryColumn() function
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- CREATE TABLE divided_routes (
+--       fid               INTEGER NOT NULL PRIMARY KEY,
+--       name              VARCHAR(64),
+--       num_lanes         INTEGER
+--       centerlines       MULTILINESTRING
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 CREATE TABLE divided_routes (
        fid               INTEGER NOT NULL PRIMARY KEY,
        name              VARCHAR(64),
        num_lanes         INTEGER
---     centerlines       MULTILINESTRING
 );
 SELECT AddGeometryColumn('divided_routes','centerlines','101','MULTILINESTRING','2');
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
 --
 -- Forests
 --
 --
 --
 --
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the
+-- attribute table, second use the AddGeometryColumn() function
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- CREATE TABLE forests (
+--       fid            INTEGER NOT NULL PRIMARY KEY,
+--       name           VARCHAR(64)
+--       boundary       MULTIPOLYGON
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 CREATE TABLE forests (
        fid            INTEGER NOT NULL PRIMARY KEY,
        name           VARCHAR(64)
---     boundary       MULTIPOLYGON
 );
 SELECT AddGeometryColumn('forests','boundary','101','MULTIPOLYGON','2');
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
 --
 -- Bridges
 --
 --
 --
 --
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the
+-- attribute table, second use the AddGeometryColumn() function
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- CREATE TABLE bridges (
+--       fid           INTEGER NOT NULL PRIMARY KEY,
+--       name          VARCHAR(64)
+--       position      POINT
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 CREATE TABLE bridges (
        fid           INTEGER NOT NULL PRIMARY KEY,
        name          VARCHAR(64)
---     position      POINT
 );
 SELECT AddGeometryColumn('bridges','position','101','POINT','2');
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
+
 --
 -- Streams
 --
 --
---
---
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the
+-- attribute table, second use the AddGeometryColumn() function
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- CREATE TABLE streams (
+--       fid             INTEGER NOT NULL PRIMARY KEY,
+--       name            VARCHAR(64)
+--       centerline      LINESTRING
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 CREATE TABLE streams (
        fid             INTEGER NOT NULL PRIMARY KEY,
        name            VARCHAR(64)
---     centerline      LINESTRING
 );
 SELECT AddGeometryColumn('streams','centerline','101','LINESTRING','2');
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
 --
 -- Buildings
 --
@@ -230,50 +369,138 @@
 --
 --
 --
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the
+-- attribute table, second use the AddGeometryColumn() function
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- CREATE TABLE buildings (
+--     fid             INTEGER NOT NULL PRIMARY KEY,
+--     address         VARCHAR(64)
+--     position        POINT
+--     footprint       POLYGON
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 CREATE TABLE buildings (
        fid             INTEGER NOT NULL PRIMARY KEY,
        address         VARCHAR(64)
---     position        POINT
---     footprint       POLYGON
 );
 SELECT AddGeometryColumn('buildings','position','101','POINT','2');
 SELECT AddGeometryColumn('buildings','footprint','101','POLYGON','2');
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
 --
 -- Ponds
 --
 --
 --
 --
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the
+-- attribute table, second use the AddGeometryColumn() function
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- CREATE TABLE ponds (
+--       fid             INTEGER NOT NULL PRIMARY KEY,
+--       name            VARCHAR(64),
+--       type            VARCHAR(64)
+--       shores          MULTIPOYLGON
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 CREATE TABLE ponds (
        fid             INTEGER NOT NULL PRIMARY KEY,
        name            VARCHAR(64),
        type            VARCHAR(64)
---     shores          MULTIPOYLGON
 );
 SELECT AddGeometryColumn('ponds','shores','101','MULTIPOLYGON','2');
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
 --
 -- Named Places
 --
 --
 --
 --
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the
+-- attribute table, second use the AddGeometryColumn() function
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+
+-- CREATE TABLE named_places (
+--       fid             INTEGER NOT NULL PRIMARY KEY,
+--       name            VARCHAR(64)
+--       boundary        POLYGON
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 CREATE TABLE named_places (
        fid             INTEGER NOT NULL PRIMARY KEY,
        name            VARCHAR(64)
---     boundary        POLYGON
 );
 SELECT AddGeometryColumn('named_places','boundary','101','POLYGON','2');
---
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
 -- Map Neatline
 --
 --
 --
 --
+-- !#@ ADAPTATION BEGIN
+-- We break the schema creation into two steps, first create the
+-- attribute table, second use the AddGeometryColumn() function
+-- to create and register the geometry column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- CREATE TABLE map_neatlines (
+--     fid             INTEGER NOT NULL PRIMARY KEY
+--     neatline        POLYGON
+-- );
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 CREATE TABLE map_neatlines (
        fid             INTEGER NOT NULL PRIMARY KEY
---     neatline        POLYGON
 );
 SELECT AddGeometryColumn('map_neatlines','neatline','101','POLYGON','2');
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
 --
 --
 --

Modified: packages/postgis/trunk/extras/ogc_test_suite/2_queries.sql
===================================================================
--- packages/postgis/trunk/extras/ogc_test_suite/2_queries.sql	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/extras/ogc_test_suite/2_queries.sql	2006-10-06 08:50:14 UTC (rev 563)
@@ -210,9 +210,28 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script incorrectly references the 'lakes' table
+-- instead of the 'divided_routes' table where 'Route 75' 
+-- appears.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT GeometryType(centerlines) 
+-- FROM lakes 
+-- WHERE name = 'Route 75';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT GeometryType(centerlines) 
 FROM divided_routes 
 WHERE name = 'Route 75';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T8	
@@ -301,9 +320,27 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script includes extraneous parenthesis around the 
+-- 'boundary' column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT AsText(Boundary((boundary)) 
+-- FROM named_places 
+-- WHERE name = 'Goose Island';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT AsText(Boundary(boundary)) 
 FROM named_places 
 WHERE name = 'Goose Island';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T14	
@@ -314,9 +351,27 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script includes extraneous parenthesis around the
+-- 'boundary' column.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT AsText(Envelope((boundary)) 
+-- FROM named_places 
+-- WHERE name = 'Goose Island';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT AsText(Envelope(boundary)) 
 FROM named_places 
 WHERE name = 'Goose Island';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --
 --
@@ -335,9 +390,27 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script reference to 'Bridges' is not correct, the 
+-- attribute value is 'Cam Bridge'.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT X(position) 
+-- FROM bridges 
+-- WHERE name = 'Bridges';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT X(position) 
 FROM bridges 
 WHERE name = 'Cam Bridge';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T16	
@@ -597,9 +670,28 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script does not wrap a geometry-returning function in
+-- AsText(), so there is no guarantee that the return string
+-- will match the official answer.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT GeometryN(centerlines, 2)
+-- FROM divided_routes 
+-- WHERE name = 'Route 75';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT AsText(GeometryN(centerlines, 2))
 FROM divided_routes 
 WHERE name = 'Route 75';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --
 --
@@ -751,9 +843,27 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- The test script attempts to test the 'Touch' function, but the 
+-- specification document uses 'Touches' as the function name.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Touch(centerline, shore)
+-- FROM streams, lakes 
+-- WHERE streams.name = 'Cam Stream' AND lakes.name = 'Blue Lake';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT Touches(centerline, shore)
 FROM streams, lakes 
 WHERE streams.name = 'Cam Stream' AND lakes.name = 'Blue Lake';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T40	
@@ -769,9 +879,29 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script reverses the correct order of arguments to 'Within()'. 
+-- Specification says 'Within(g1,g2) is 'TRUE if g1 is completely 
+-- contained in g2' and test explanation says we are checking if 
+-- the house (g1, footprint) is within Ashton (g2, boundary).
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Within(boundary, footprint)
+-- FROM named_places, buildings 
+-- WHERE named_places.name = 'Ashton' AND buildings.address = '215 Main Street';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT Within(footprint, boundary)
 FROM named_places, buildings 
 WHERE named_places.name = 'Ashton' AND buildings.address = '215 Main Street';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T41	
@@ -787,9 +917,27 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script uses 'Overlap()' as the function name and specification
+-- gives 'Overlaps()' as the function name.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Overlap(forest.boundary, named_places.boundary)
+-- FROM forests, named_places 
+-- WHERE forests.name = 'Green Forest' AND named_places.name = 'Ashton';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT Overlaps(forests.boundary, named_places.boundary)
 FROM forests, named_places 
 WHERE forests.name = 'Green Forest' AND named_places.name = 'Ashton';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T42	
@@ -805,9 +953,29 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script uses 'Cross()' as the function name and specification
+-- gives 'Crosses()' as the function name.
+-- Test script references 'road_segment' table and the correct table
+-- name is 'road_segments'.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Cross(road_segment.centerline, divided_routes.centerlines)
+-- FROM road_segment, divided_routes 
+-- WHERE road_segment.fid = 102 AND divided_routes.name = 'Route 75';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT Crosses(road_segments.centerline, divided_routes.centerlines)
 FROM road_segments, divided_routes 
 WHERE road_segments.fid = 102 AND divided_routes.name = 'Route 75';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T43	
@@ -823,9 +991,27 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script references 'road_segment' table and the correct table
+-- name is 'road_segments'.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Intersects(road_segment.centerline, divided_routes.centerlines)
+-- FROM road_segment, divided_routes 
+-- WHERE road_segment.fid = 102 AND divided_routes.name = 'Route 75';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT Intersects(road_segments.centerline, divided_routes.centerlines)
 FROM road_segments, divided_routes 
 WHERE road_segments.fid = 102 AND divided_routes.name = 'Route 75';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T44	
@@ -841,9 +1027,27 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script references 'forest' table and the correct table
+-- name is 'forests'.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Contains(forest.boundary, named_places.boundary)
+-- FROM forests, named_places 
+-- WHERE forests.name = 'Green Forest' AND named_places.name = 'Ashton';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT Contains(forests.boundary, named_places.boundary)
 FROM forests, named_places 
 WHERE forests.name = 'Green Forest' AND named_places.name = 'Ashton';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T45	
@@ -859,9 +1063,27 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script references 'forest' table and the correct table
+-- name is 'forests'.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Relate(forest.boundary, named_places.boundary, 'TTTTTTTTT')
+-- FROM forests, named_places 
+-- WHERE forests.name = 'Green Forest' AND named_places.name = 'Ashton';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT Relate(forests.boundary, named_places.boundary, 'TTTTTTTTT')
 FROM forests, named_places 
 WHERE forests.name = 'Green Forest' AND named_places.name = 'Ashton';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --
 --
@@ -902,9 +1124,28 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script does not wrap a geometry-returning function in
+-- AsText(), so there is no guarantee that the return string
+-- will match the official answer.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Intersection(centerline, shore)
+-- FROM streams, lakes 
+-- WHERE streams.name = 'Cam Stream' AND lakes.name = 'Blue Lake';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT AsText(Intersection(centerline, shore))
 FROM streams, lakes 
 WHERE streams.name = 'Cam Stream' AND lakes.name = 'Blue Lake';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T48	
@@ -917,9 +1158,30 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script does not wrap a geometry-returning function in
+-- AsText(), so there is no guarantee that the return string
+-- will match the official answer.
+-- Note that the return geometry is the same as the official
+-- answer but with a different start point.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Difference(named_places.boundary, forests.boundary)
+-- FROM named_places, forests 
+-- WHERE named_places.name = 'Ashton' AND forests.name = 'Green Forest';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT AsText(Difference(named_places.boundary, forests.boundary))
 FROM named_places, forests 
 WHERE named_places.name = 'Ashton' AND forests.name = 'Green Forest';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T49	
@@ -927,13 +1189,37 @@
 -- For this test we will determine the union of Blue Lake and Goose Island 
 --
 -- ANSWER: 'POLYGON((52 18,66 23,73 9,48 6,52 18))'
--- NOTE: The outer ring of BLue Lake is the answer.
+-- NOTE: The outer ring of Blue Lake is the answer.
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script does not wrap a geometry-returning function in
+-- AsText(), so there is no guarantee that the return string
+-- will match the official answer.
+-- Test script uses 'Ashton' as the place name where it means
+-- to use 'Goose Island'.
+-- Specification uses 'Union()' as a function name, but UNION
+-- is a SQL reserved work.  Function name adapted to 'GeomUnion()'
+-- for out implementation.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT Union(shore, boundary)
+-- FROM lakes, named_places 
+-- WHERE lakes.name = 'Blue Lake' AND named_places.name = Ashton';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT AsText(GeomUnion(shore, boundary))
 FROM lakes, named_places 
 WHERE lakes.name = 'Blue Lake' AND named_places.name = 'Goose Island';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T50	
@@ -942,13 +1228,34 @@
 -- and Goose Island 
 --
 -- ANSWER: 'POLYGON((52 18,66 23,73 9,48 6,52 18))'
--- NOTE: The outer ring of BLue Lake is the answer.
+-- NOTE: The outer ring of Blue Lake is the answer.
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script does not wrap a geometry-returning function in
+-- AsText(), so there is no guarantee that the return string
+-- will match the official answer.
+-- Test script uses 'Ashton' as the place name where it means
+-- to use 'Goose Island'.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT SymmetricDifference(shore, boundary)
+-- FROM lakes, named_places 
+-- WHERE lakes.name = 'Blue Lake' OR named_places.name = 'Ashton';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT AsText(SymmetricDifference(shore, boundary))
 FROM lakes, named_places 
 WHERE lakes.name = 'Blue Lake' AND named_places.name = 'Goose Island';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T51	
@@ -970,9 +1277,27 @@
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Our boolean function implementations return actual boolean values,
+-- so no further logical comparison (to 1 or 't') is required.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT count(*)
+-- FROM buildings, bridges
+-- WHERE Contains(Buffer(bridges.position, 15.0), buildings.footprint) = 1;
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT count(*)
 FROM buildings, bridges
 WHERE Contains(Buffer(bridges.position, 15.0), buildings.footprint);
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
 --
 --================================
 -- Conformance Item T52	
@@ -980,13 +1305,36 @@
 -- For this test we will determine the convex hull of Blue Lake 
 --
 -- ANSWER: 'POLYGON((52 18,66 23,73 9,48 6,52 18))'
--- NOTE: The outer ring of BLue Lake is the answer.
+-- NOTE: The outer ring of Blue Lake is the answer.
 --
 --================================
 --
+-- !#@ ADAPTATION BEGIN
+-- Test script does not wrap a geometry-returning function in
+-- AsText(), so there is no guarantee that the return string
+-- will match the official answer.
+-- Note that the return geometry is the same as the official
+-- answer but with a different start point.
+-- ---------------------
+-- -- BEGIN ORIGINAL SQL
+-- ---------------------
+-- SELECT ConvexHull(shore)
+-- FROM lakes
+-- WHERE lakes.name = 'Blue Lake';
+-- ---------------------
+-- -- END   ORIGINAL SQL
+-- ---------------------
+-- -- BEGIN ADAPTED  SQL
+-- ---------------------
 SELECT AsText(ConvexHull(shore))
 FROM lakes
 WHERE lakes.name = 'Blue Lake';
+-- ---------------------
+-- -- END   ADAPTED  SQL
+-- ---------------------
+-- -- !#@ ADAPTATION END
+
+
 --
 --
 --

Deleted: packages/postgis/trunk/extras/wkb_reader/.cvsignore
===================================================================
--- packages/postgis/trunk/extras/wkb_reader/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/extras/wkb_reader/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1 +0,0 @@
-readwkb

Copied: packages/postgis/trunk/java (from rev 562, packages/postgis/upstream/java)

Deleted: packages/postgis/trunk/loader/.cvsignore
===================================================================
--- packages/postgis/trunk/loader/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/loader/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,2 +0,0 @@
-pgsql2shp
-shp2pgsql

Modified: packages/postgis/trunk/loader/dbfopen.c
===================================================================
--- packages/postgis/trunk/loader/dbfopen.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/loader/dbfopen.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: dbfopen.c,v 1.8 2006/01/16 10:42:57 strk Exp $
+ * $Id: dbfopen.c 2472 2006-09-09 16:32:57Z pramsey $
  *
  * Project:  Shapelib
  * Purpose:  Implementation of .dbf access API documented in dbf_api.html.
@@ -33,7 +33,7 @@
  * DEALINGS IN THE SOFTWARE.
  ******************************************************************************
  *
- * $Log: dbfopen.c,v $
+ * $Log$
  * Revision 1.8  2006/01/16 10:42:57  strk
  * Added support for Bool and Date DBF<=>PGIS mapping
  *
@@ -204,7 +204,7 @@
  */
 
 static char rcsid[] = 
-  "$Id: dbfopen.c,v 1.8 2006/01/16 10:42:57 strk Exp $";
+  "$Id: dbfopen.c 2472 2006-09-09 16:32:57Z pramsey $";
 
 #include "shapefil.h"
 
@@ -919,7 +919,7 @@
 
       case 'D':
         /* NULL date fields have value "00000000" */
-        return strncmp(pszValue,"00000000",8) == 0;
+        return (strncmp(pszValue,"00000000",8) == 0 || strlen(pszValue) == 0);
 
       case 'L':
         /* NULL boolean fields have value "?" */ 

Modified: packages/postgis/trunk/loader/pgsql2shp.c
===================================================================
--- packages/postgis/trunk/loader/pgsql2shp.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/loader/pgsql2shp.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: pgsql2shp.c,v 1.85 2006/06/16 14:12:16 strk Exp $
+ * $Id: pgsql2shp.c 2486 2006-09-27 08:24:08Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -19,7 +19,7 @@
  **********************************************************************/
 
 static char rcsid[] =
-  "$Id: pgsql2shp.c,v 1.85 2006/06/16 14:12:16 strk Exp $";
+  "$Id: pgsql2shp.c 2486 2006-09-27 08:24:08Z strk $";
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -34,6 +34,8 @@
 #include "shapefil.h"
 #include "getopt.h"
 #include "compat.h"
+#include <sys/types.h> // for getpid()
+#include <unistd.h> // for getpid()
 
 #ifdef __CYGWIN__
 #include <sys/param.h>       
@@ -52,6 +54,7 @@
  * Verbosity:
  *   set to 1 to see record fetching progress
  *   set to 2 to see also shapefile creation progress
+ *   set to 3 for debugging
  */
 #define VERBOSE 1
 
@@ -69,6 +72,7 @@
 /* Global data */
 PGconn *conn;
 int rowbuflen;
+char temptablename[256];
 char *geo_col_name, *table, *shp_file, *schema, *usrquery;
 int type_ary[256];
 char *main_scan_query;
@@ -2505,7 +2509,6 @@
 		return 0;
 	}
 
-
 	/* Get geometry oid */
 	geo_oid = getGeometryOID(conn);
 	if ( geo_oid == -1 )
@@ -3240,7 +3243,15 @@
 	if ( strstr(spec, "SELECT ") || strstr(spec, "select ") )
 	{
 		usrquery = spec;
-		table = "__pgsql2shp_tmp_table";
+
+		/*
+		 * encode pid in table name to reduce 
+		 * clashes probability (see bug#115)
+		 */
+		sprintf(temptablename,
+			"__pgsql2shp%lu_tmp_table",
+			(long)getpid());
+		table = temptablename; 
 	}
 	else
 	{
@@ -3341,7 +3352,7 @@
 }
 
 /**********************************************************************
- * $Log: pgsql2shp.c,v $
+ * $Log$
  * Revision 1.85  2006/06/16 14:12:16  strk
  *         - BUGFIX in pgsql2shp successful return code.
  *         - BUGFIX in shp2pgsql handling of MultiLine WKT.

Modified: packages/postgis/trunk/loader/shapefil.h
===================================================================
--- packages/postgis/trunk/loader/shapefil.h	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/loader/shapefil.h	2006-10-06 08:50:14 UTC (rev 563)
@@ -2,7 +2,7 @@
 #define _SHAPEFILE_H_INCLUDED
 
 /******************************************************************************
- * $Id: shapefil.h,v 1.5 2006/01/16 10:42:58 strk Exp $
+ * $Id: shapefil.h 2280 2006-01-16 10:42:58Z strk $
  *
  * Project:  Shapelib
  * Purpose:  Primary include file for Shapelib.
@@ -36,7 +36,7 @@
  * DEALINGS IN THE SOFTWARE.
  ******************************************************************************
  *
- * $Log: shapefil.h,v $
+ * $Log$
  * Revision 1.5  2006/01/16 10:42:58  strk
  * Added support for Bool and Date DBF<=>PGIS mapping
  *

Modified: packages/postgis/trunk/loader/shp2pgsql.c
===================================================================
--- packages/postgis/trunk/loader/shp2pgsql.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/loader/shp2pgsql.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: shp2pgsql.c,v 1.108 2006/06/16 14:12:17 strk Exp $
+ * $Id: shp2pgsql.c 2383 2006-06-16 14:12:17Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -137,7 +137,7 @@
 static void print_wkb_double(double val);
 
 static char rcsid[] =
-  "$Id: shp2pgsql.c,v 1.108 2006/06/16 14:12:17 strk Exp $";
+  "$Id: shp2pgsql.c 2383 2006-06-16 14:12:17Z strk $";
 
 void *safe_malloc(size_t size)
 {
@@ -1697,7 +1697,7 @@
 #endif /* defined USE_ICONV */
 
 /**********************************************************************
- * $Log: shp2pgsql.c,v $
+ * $Log$
  * Revision 1.108  2006/06/16 14:12:17  strk
  *         - BUGFIX in pgsql2shp successful return code.
  *         - BUGFIX in shp2pgsql handling of MultiLine WKT.

Modified: packages/postgis/trunk/loader/shpopen.c
===================================================================
--- packages/postgis/trunk/loader/shpopen.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/loader/shpopen.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /******************************************************************************
- * $Id: shpopen.c,v 1.5 2003/12/01 20:52:00 strk Exp $
+ * $Id: shpopen.c 398 2003-12-01 20:52:00Z strk $
  *
  * Project:  Shapelib
  * Purpose:  Implementation of core Shapefile read/write functions.
@@ -33,7 +33,7 @@
  * DEALINGS IN THE SOFTWARE.
  ******************************************************************************
  *
- * $Log: shpopen.c,v $
+ * $Log$
  * Revision 1.5  2003/12/01 20:52:00  strk
  * shapelib put in sync with gdal cvs
  *
@@ -174,7 +174,7 @@
  */
 
 static char rcsid[] = 
-  "$Id: shpopen.c,v 1.5 2003/12/01 20:52:00 strk Exp $";
+  "$Id: shpopen.c 398 2003-12-01 20:52:00Z strk $";
 
 #include "shapefil.h"
 

Deleted: packages/postgis/trunk/lwgeom/.cvsignore
===================================================================
--- packages/postgis/trunk/lwgeom/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +0,0 @@
-liblwgeom.so*
-lwgeom.sql
-y.output
-lwpostgis.sql
-postgis_geos_version.h

Modified: packages/postgis/trunk/lwgeom/lex.yy.c
===================================================================
--- packages/postgis/trunk/lwgeom/lex.yy.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lex.yy.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -20,7 +20,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header: /home/cvs/postgis/postgis/lwgeom/lex.yy.c,v 1.7 2006/05/04 15:19:50 strk Exp $
+ * $Header$
  */
 
 #define FLEX_SCANNER

Modified: packages/postgis/trunk/lwgeom/long_xact.sql
===================================================================
--- packages/postgis/trunk/lwgeom/long_xact.sql	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/long_xact.sql	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,6 +1,6 @@
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- 
--- $Id: long_xact.sql,v 1.1 2006/06/25 23:59:32 strk Exp $
+-- $Id: long_xact.sql 2406 2006-07-07 13:56:52Z strk $
 --
 -- PostGIS - Spatial Types for PostgreSQL
 -- http://postgis.refractions.net
@@ -286,7 +286,7 @@
 			''n.nspname as schema, '' ||
 #endif
 			''c.relname as table, trim('' ||
-			quote_literal(''\\\\000'') ||
+			quote_literal(chr(92) || ''000'') ||
 			'' from t.tgargs) as id_column '' ||
 			''FROM pg_trigger t, pg_class c, pg_proc p '' ||
 #ifdef HAS_SCHEMAS

Modified: packages/postgis/trunk/lwgeom/lwcollection.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwcollection.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwcollection.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwcollection.c,v 1.32 2006/05/30 08:38:58 strk Exp $
+ * $Id: lwcollection.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwgeom.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom.c,v 1.33 2006/05/30 08:47:00 strk Exp $
+ * $Id: lwgeom.c 2370 2006-05-30 08:47:00Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwgeom_box2dfloat4.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_box2dfloat4.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_box2dfloat4.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,520 +1,523 @@
-#include <math.h>
-#include <float.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-
-#include "postgres.h"
-#include "access/gist.h"
-#include "access/itup.h"
-#include "fmgr.h"
-#include "utils/elog.h"
-#include "utils/geo_decls.h"
-
-#include "lwgeom_pg.h"
-#include "liblwgeom.h"
-#include "stringBuffer.h"
-
-
-/* #define PGIS_DEBUG */
-
-/* forward defs */
-Datum BOX2DFLOAT4_in(PG_FUNCTION_ARGS);
-Datum BOX2DFLOAT4_out(PG_FUNCTION_ARGS);
-Datum LWGEOM_to_BOX2DFLOAT4(PG_FUNCTION_ARGS);
-Datum BOX2DFLOAT4_expand(PG_FUNCTION_ARGS);
-Datum BOX2DFLOAT4_to_BOX3D(PG_FUNCTION_ARGS);
-Datum BOX2DFLOAT4_combine(PG_FUNCTION_ARGS);
-Datum BOX2DFLOAT4_to_LWGEOM(PG_FUNCTION_ARGS);
-Datum BOX2DFLOAT4_construct(PG_FUNCTION_ARGS);
-
-/* parser - "BOX(xmin ymin,xmax ymax)" */
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_in);
-Datum BOX2DFLOAT4_in(PG_FUNCTION_ARGS)
-{
-	char *str = PG_GETARG_CSTRING(0);
-	int nitems;
-	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *) palloc(sizeof(BOX2DFLOAT4));
-
-
-
-/*printf( "box3d_in gets '%s'\n",str); */
-
-	if (strstr(str,"BOX(") !=  str )
-	{
-		 pfree(box);
-		 elog(ERROR,"BOX2DFLOAT4 parser - doesnt start with BOX(");
-		 PG_RETURN_NULL();
-	}
-	nitems = sscanf(str,"BOX(%f %f,%f %f)", &box->xmin,&box->ymin,&box->xmax,&box->ymax);
-	if (nitems != 4)
-	{
-		 pfree(box);
-		 elog(ERROR,"BOX2DFLOAT4 parser - couldnt parse.  It should look like: BOX(xmin ymin,xmax ymax)");
-		 PG_RETURN_NULL();
-	}
-
-	if (box->xmin > box->xmax)
-	{
-		float tmp = box->xmin;
-		box->xmin = box->xmax;
-		box->xmax = tmp;
-	}
-	if (box->ymin > box->ymax)
-	{
-		float tmp = box->ymin;
-		box->ymin = box->ymax;
-		box->ymax = tmp;
-	}
-	PG_RETURN_POINTER(box);
-}
-
-/*writer  "BOX(xmin ymin,xmax ymax)" */
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_out);
-Datum BOX2DFLOAT4_out(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	char tmp[500]; /* big enough */
-	char *result;
-	int size;
-
-	size  = sprintf(tmp,"BOX(%.15g %.15g,%.15g %.15g)",
-		box->xmin, box->ymin, box->xmax, box->ymax);
-
-	result= palloc(size+1); /* +1= null term */
-
-	memcpy(result,tmp,size+1);
-	PG_RETURN_CSTRING(result);
-}
-
-
-/*convert a PG_LWGEOM to BOX2D */
-PG_FUNCTION_INFO_V1(LWGEOM_to_BOX2DFLOAT4);
-Datum LWGEOM_to_BOX2DFLOAT4(PG_FUNCTION_ARGS)
-{
-	PG_LWGEOM *lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
-	BOX2DFLOAT4 *result;
-
-	result = palloc(sizeof(BOX2DFLOAT4));
-	if ( ! getbox2d_p(SERIALIZED_FORM(lwgeom), result) )
-	{
-		PG_RETURN_NULL(); /* must be the empty geometry */
-	}
-
-	PG_RETURN_POINTER(result);
-}
-
-/*----------------------------------------------------------
- *	Relational operators for BOXes.
- *		<, >, <=, >=, and == are based on box area.
- *---------------------------------------------------------*/
-
-/*
- * box_same - are two boxes identical?
- */
-PG_FUNCTION_INFO_V1(BOX2D_same);
-Datum BOX2D_same(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPeq(box1->xmax, box2->xmax) &&
-				   FPeq(box1->xmin, box2->xmin) &&
-				   FPeq(box1->ymax, box2->ymax) &&
-				   FPeq(box1->ymin, box2->ymin));
-}
-
-/*
- * box_overlap - does box1 overlap box2?
- */
-PG_FUNCTION_INFO_V1(BOX2D_overlap);
-Datum BOX2D_overlap(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-	bool       result;
-
-
-	result = ((FPge(box1->xmax, box2->xmax) &&
-			 FPle(box1->xmin, box2->xmax)) ||
-			(FPge(box2->xmax, box1->xmax) &&
-			 FPle(box2->xmin, box1->xmax)))
-		&&
-		((FPge(box1->ymax, box2->ymax) &&
-		  FPle(box1->ymin, box2->ymax)) ||
-		 (FPge(box2->ymax, box1->ymax) &&
-		  FPle(box2->ymin, box1->ymax)));
-
-	PG_RETURN_BOOL(result);
-}
-
-
-/*
- * box_overleft - is the right edge of box1 to the left of
- *                the right edge of box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_overleft);
-Datum BOX2D_overleft(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4 *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPle(box1->xmax, box2->xmax));
-}
-
-/* 
- * box_left - is box1 strictly left of box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_left);
-Datum BOX2D_left(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPlt(box1->xmax, box2->xmin));
-}
-
-/*
- * box_right - is box1 strictly right of box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_right);
-Datum BOX2D_right(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPgt(box1->xmin, box2->xmax));
-}
-
-/* 
- * box_overright - is the left edge of box1 to the right of
- *                 the left edge of box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_overright);
-Datum BOX2D_overright(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPge(box1->xmin, box2->xmin));
-}
-
-/* 
- * box_overbelow - is the bottom edge of box1 below
- *                 the bottom edge of box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_overbelow);
-Datum BOX2D_overbelow(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPle(box1->ymin, box2->ymin));
-}
-
-/*
- * box_below - is box1 strictly below box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_below);
-Datum BOX2D_below(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPlt(box1->ymax, box2->ymin));
-}
-
-/*
- * box_above - is box1 strictly above box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_above);
-Datum BOX2D_above(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPgt(box1->ymin, box2->ymax));
-}
-
-/*
- * box_overabove - the top edge of box1 above
- *                 the top edge of box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_overabove);
-Datum BOX2D_overabove(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPge(box1->ymax, box2->ymax));
-}
-
-/*
- * box_contained - is box1 contained by box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_contained);
-Datum BOX2D_contained(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 =(BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPle(box1->xmax, box2->xmax) &&
-				   FPge(box1->xmin, box2->xmin) &&
-				   FPle(box1->ymax, box2->ymax) &&
-				   FPge(box1->ymin, box2->ymin));
-}
-
-/*
- * box_contain - does box1 contain box2?
- */
- PG_FUNCTION_INFO_V1(BOX2D_contain);
-Datum BOX2D_contain(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-
-	PG_RETURN_BOOL(FPge(box1->xmax, box2->xmax) &&
-				   FPle(box1->xmin, box2->xmin) &&
-				   FPge(box1->ymax, box2->ymax) &&
-				   FPle(box1->ymin, box2->ymin));
-
-}
-
-PG_FUNCTION_INFO_V1(BOX2D_intersects);
-Datum BOX2D_intersects(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *a = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4 *b = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
-	BOX2DFLOAT4 *n;
-
-
-	n = (BOX2DFLOAT4 *) palloc(sizeof(BOX2DFLOAT4));
-
-	n->xmax = LWGEOM_Minf(a->xmax, b->xmax);
-	n->ymax = LWGEOM_Minf(a->ymax, b->ymax);
-	n->xmin = LWGEOM_Maxf(a->xmin, b->xmin);
-	n->ymin = LWGEOM_Maxf(a->ymin, b->ymin);
-
-
-	if (n->xmax < n->xmin || n->ymax < n->ymin)
-	{
-		pfree(n);
-		/* Indicate "no intersection" by returning NULL pointer */
-		n = NULL;
-	}
-
-	PG_RETURN_POINTER(n);
-}
-
-
-/*
- * union of two BOX2Ds
- */
-PG_FUNCTION_INFO_V1(BOX2D_union);
-Datum BOX2D_union(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *a = (BOX2DFLOAT4*) PG_GETARG_POINTER(0);
-	BOX2DFLOAT4 *b = (BOX2DFLOAT4*) PG_GETARG_POINTER(1);
-	BOX2DFLOAT4 *n;
-
-	n = (BOX2DFLOAT4 *) lwalloc(sizeof(BOX2DFLOAT4));
-	if ( ! box2d_union_p(a,b,n) ) PG_RETURN_NULL();
-	PG_RETURN_POINTER(n);
-}
-
-
-/*
- * min(a,b)
- */
-float LWGEOM_Minf(float a, float b)
-{
-	if (a<b)
-		return a;
-	return b;
-}
-
-/*
- * max(a,b)
- */
-float LWGEOM_Maxf(float a, float b)
-{
-	if (b>a) return b;
-	return a;
-}
-
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_expand);
-Datum BOX2DFLOAT4_expand(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
-	double d = PG_GETARG_FLOAT8(1);
-	BOX2DFLOAT4 *result = (BOX2DFLOAT4 *)palloc(sizeof(BOX2DFLOAT4));
-
-	memcpy(result, box, sizeof(BOX2DFLOAT4));
-	expand_box2d(result, d);
-
-	PG_RETURN_POINTER(result);
-}
-
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_to_BOX3D);
-Datum BOX2DFLOAT4_to_BOX3D(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
-	BOX3D *result = palloc(sizeof(BOX3D));
-
-	box2df_to_box3d_p(box, result);
-
-	PG_RETURN_POINTER(result);
-}
-
-
-#define KEEP_OBSOLETED_FUNX 1
-#if KEEP_OBSOLETED_FUNX
-Datum BOX2DFLOAT4_xmin(PG_FUNCTION_ARGS);
-Datum BOX2DFLOAT4_ymin(PG_FUNCTION_ARGS);
-Datum BOX2DFLOAT4_xmax(PG_FUNCTION_ARGS);
-Datum BOX2DFLOAT4_ymax(PG_FUNCTION_ARGS);
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_xmin);
-Datum BOX2DFLOAT4_xmin(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
-	PG_RETURN_FLOAT4(box->xmin);
-}
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_ymin);
-Datum BOX2DFLOAT4_ymin(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
-	PG_RETURN_FLOAT4(box->ymin);
-}
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_xmax);
-Datum BOX2DFLOAT4_xmax(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
-	PG_RETURN_FLOAT4(box->xmax);
-}
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_ymax);
-Datum BOX2DFLOAT4_ymax(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
-	PG_RETURN_FLOAT4(box->ymax);
-}
-#endif
-
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_combine);
-Datum BOX2DFLOAT4_combine(PG_FUNCTION_ARGS)
-{
-	Pointer box2d_ptr = PG_GETARG_POINTER(0);
-	Pointer geom_ptr = PG_GETARG_POINTER(1);
-	BOX2DFLOAT4 *a,*b;
-	PG_LWGEOM *lwgeom;
-	BOX2DFLOAT4 box, *result;
-
-	if  ( (box2d_ptr == NULL) && (geom_ptr == NULL) )
-	{
-		PG_RETURN_NULL(); /* combine_box2d(null,null) => null */
-	}
-
-	result = (BOX2DFLOAT4 *)palloc(sizeof(BOX2DFLOAT4));
-
-	if (box2d_ptr == NULL)
-	{
-		lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
-		/* empty geom would make getbox2d_p return NULL */
-		if ( ! getbox2d_p(SERIALIZED_FORM(lwgeom), &box) ) PG_RETURN_NULL();
-		memcpy(result, &box, sizeof(BOX2DFLOAT4));
-		PG_RETURN_POINTER(result);
-	}
-
-	/* combine_bbox(BOX3D, null) => BOX3D */
-	if (geom_ptr == NULL)
-	{
-		memcpy(result, (char *)PG_GETARG_DATUM(0), sizeof(BOX2DFLOAT4));
-		PG_RETURN_POINTER(result);
-	}
-
-	/*combine_bbox(BOX3D, geometry) => union(BOX3D, geometry->bvol) */
-
-	lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
-	if ( ! getbox2d_p(SERIALIZED_FORM(lwgeom), &box) )
-	{
-		/* must be the empty geom */
-		memcpy(result, (char *)PG_GETARG_DATUM(0), sizeof(BOX2DFLOAT4));
-		PG_RETURN_POINTER(result);
-	}
-
-	a = (BOX2DFLOAT4 *)PG_GETARG_DATUM(0);
-	b = &box;
-
-	result->xmax = LWGEOM_Maxf(a->xmax, b->xmax);
-	result->ymax = LWGEOM_Maxf(a->ymax, b->ymax);
-	result->xmin = LWGEOM_Minf(a->xmin, b->xmin);
-	result->ymin = LWGEOM_Minf(a->ymin, b->ymin);
-
-	PG_RETURN_POINTER(result);
-}
-
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_to_LWGEOM);
-Datum BOX2DFLOAT4_to_LWGEOM(PG_FUNCTION_ARGS)
-{
-	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
-	POINT2D *pts = palloc(sizeof(POINT2D)*5);
-	POINTARRAY *pa[1];
-	LWPOLY *poly;
-	int wantbbox = 0;
-	PG_LWGEOM *result;
-	uchar *ser;
-
-	/* Assign coordinates to POINT2D array */
-	pts[0].x = box->xmin; pts[0].y = box->ymin;
-	pts[1].x = box->xmin; pts[1].y = box->ymax;
-	pts[2].x = box->xmax; pts[2].y = box->ymax;
-	pts[3].x = box->xmax; pts[3].y = box->ymin;
-	pts[4].x = box->xmin; pts[4].y = box->ymin;
-
-	/* Construct point array */
-	pa[0] = palloc(sizeof(POINTARRAY));
-	pa[0]->serialized_pointlist = (uchar *)pts;
-	TYPE_SETZM(pa[0]->dims, 0, 0);
-	pa[0]->npoints = 5;
-
-	/* Construct polygon */
-	poly = lwpoly_construct(-1, NULL, 1, pa);
-
-	/* Serialize polygon */
-	ser = lwpoly_serialize(poly);
-
-	/* Construct PG_LWGEOM  */
-	result = PG_LWGEOM_construct(ser, -1, wantbbox);
-	
-	PG_RETURN_POINTER(result);
-}
-
-PG_FUNCTION_INFO_V1(BOX2DFLOAT4_construct);
-Datum BOX2DFLOAT4_construct(PG_FUNCTION_ARGS)
-{
-	PG_LWGEOM *min = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
-	PG_LWGEOM *max = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
-	BOX2DFLOAT4 *result = palloc(sizeof(BOX2DFLOAT4));
-	LWGEOM *minpoint, *maxpoint;
-	POINT2D minp, maxp;
-
-	minpoint = lwgeom_deserialize(SERIALIZED_FORM(min));
-	maxpoint = lwgeom_deserialize(SERIALIZED_FORM(max));
-
-	if ( TYPE_GETTYPE(minpoint->type) != POINTTYPE ||
-		TYPE_GETTYPE(maxpoint->type) != POINTTYPE )
-	{
-		elog(ERROR, "BOX2DFLOAT4_construct: args must be points");
-		PG_RETURN_NULL();
-	}
-	getPoint2d_p(((LWPOINT *)minpoint)->point, 0, &minp);
-	getPoint2d_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
-
-	result->xmax = maxp.x;
-	result->ymax = maxp.y;
-
-	result->xmin = minp.x;
-	result->ymin = minp.y;
-
-	PG_RETURN_POINTER(result);
-}
-
+#include <math.h>
+#include <float.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "postgres.h"
+#include "access/gist.h"
+#include "access/itup.h"
+#include "fmgr.h"
+#include "utils/elog.h"
+#include "utils/geo_decls.h"
+
+#include "lwgeom_pg.h"
+#include "liblwgeom.h"
+#include "stringBuffer.h"
+
+
+/* #define PGIS_DEBUG */
+
+/* forward defs */
+Datum BOX2DFLOAT4_in(PG_FUNCTION_ARGS);
+Datum BOX2DFLOAT4_out(PG_FUNCTION_ARGS);
+Datum LWGEOM_to_BOX2DFLOAT4(PG_FUNCTION_ARGS);
+Datum BOX2DFLOAT4_expand(PG_FUNCTION_ARGS);
+Datum BOX2DFLOAT4_to_BOX3D(PG_FUNCTION_ARGS);
+Datum BOX2DFLOAT4_combine(PG_FUNCTION_ARGS);
+Datum BOX2DFLOAT4_to_LWGEOM(PG_FUNCTION_ARGS);
+Datum BOX2DFLOAT4_construct(PG_FUNCTION_ARGS);
+
+/* parser - "BOX(xmin ymin,xmax ymax)" */
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_in);
+Datum BOX2DFLOAT4_in(PG_FUNCTION_ARGS)
+{
+	char *str = PG_GETARG_CSTRING(0);
+	int nitems;
+	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *) palloc(sizeof(BOX2DFLOAT4));
+
+
+
+/*printf( "box3d_in gets '%s'\n",str); */
+
+	if (strstr(str,"BOX(") !=  str )
+	{
+		 pfree(box);
+		 elog(ERROR,"BOX2DFLOAT4 parser - doesnt start with BOX(");
+		 PG_RETURN_NULL();
+	}
+	nitems = sscanf(str,"BOX(%f %f,%f %f)", &box->xmin,&box->ymin,&box->xmax,&box->ymax);
+	if (nitems != 4)
+	{
+		 pfree(box);
+		 elog(ERROR,"BOX2DFLOAT4 parser - couldnt parse.  It should look like: BOX(xmin ymin,xmax ymax)");
+		 PG_RETURN_NULL();
+	}
+
+	if (box->xmin > box->xmax)
+	{
+		float tmp = box->xmin;
+		box->xmin = box->xmax;
+		box->xmax = tmp;
+	}
+	if (box->ymin > box->ymax)
+	{
+		float tmp = box->ymin;
+		box->ymin = box->ymax;
+		box->ymax = tmp;
+	}
+	PG_RETURN_POINTER(box);
+}
+
+/*writer  "BOX(xmin ymin,xmax ymax)" */
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_out);
+Datum BOX2DFLOAT4_out(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	char tmp[500]; /* big enough */
+	char *result;
+	int size;
+
+	size  = sprintf(tmp,"BOX(%.15g %.15g,%.15g %.15g)",
+		box->xmin, box->ymin, box->xmax, box->ymax);
+
+	result= palloc(size+1); /* +1= null term */
+
+	memcpy(result,tmp,size+1);
+	PG_RETURN_CSTRING(result);
+}
+
+
+/*convert a PG_LWGEOM to BOX2D */
+PG_FUNCTION_INFO_V1(LWGEOM_to_BOX2DFLOAT4);
+Datum LWGEOM_to_BOX2DFLOAT4(PG_FUNCTION_ARGS)
+{
+	PG_LWGEOM *lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+	BOX2DFLOAT4 *result;
+
+	result = palloc(sizeof(BOX2DFLOAT4));
+	if ( ! getbox2d_p(SERIALIZED_FORM(lwgeom), result) )
+	{
+		PG_RETURN_NULL(); /* must be the empty geometry */
+	}
+
+	PG_RETURN_POINTER(result);
+}
+
+/*----------------------------------------------------------
+ *	Relational operators for BOXes.
+ *		<, >, <=, >=, and == are based on box area.
+ *---------------------------------------------------------*/
+
+/*
+ * box_same - are two boxes identical?
+ */
+PG_FUNCTION_INFO_V1(BOX2D_same);
+Datum BOX2D_same(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPeq(box1->xmax, box2->xmax) &&
+				   FPeq(box1->xmin, box2->xmin) &&
+				   FPeq(box1->ymax, box2->ymax) &&
+				   FPeq(box1->ymin, box2->ymin));
+}
+
+/*
+ * box_overlap - does box1 overlap box2?
+ */
+PG_FUNCTION_INFO_V1(BOX2D_overlap);
+Datum BOX2D_overlap(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+	bool       result;
+
+
+	result = ((FPge(box1->xmax, box2->xmax) &&
+			 FPle(box1->xmin, box2->xmax)) ||
+			(FPge(box2->xmax, box1->xmax) &&
+			 FPle(box2->xmin, box1->xmax)))
+		&&
+		((FPge(box1->ymax, box2->ymax) &&
+		  FPle(box1->ymin, box2->ymax)) ||
+		 (FPge(box2->ymax, box1->ymax) &&
+		  FPle(box2->ymin, box1->ymax)));
+
+	PG_RETURN_BOOL(result);
+}
+
+
+/*
+ * box_overleft - is the right edge of box1 to the left of
+ *                the right edge of box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_overleft);
+Datum BOX2D_overleft(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4 *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPle(box1->xmax, box2->xmax));
+}
+
+/* 
+ * box_left - is box1 strictly left of box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_left);
+Datum BOX2D_left(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPlt(box1->xmax, box2->xmin));
+}
+
+/*
+ * box_right - is box1 strictly right of box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_right);
+Datum BOX2D_right(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPgt(box1->xmin, box2->xmax));
+}
+
+/* 
+ * box_overright - is the left edge of box1 to the right of
+ *                 the left edge of box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_overright);
+Datum BOX2D_overright(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPge(box1->xmin, box2->xmin));
+}
+
+/* 
+ * box_overbelow - is the bottom edge of box1 below
+ *                 the bottom edge of box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_overbelow);
+Datum BOX2D_overbelow(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPle(box1->ymin, box2->ymin));
+}
+
+/*
+ * box_below - is box1 strictly below box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_below);
+Datum BOX2D_below(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPlt(box1->ymax, box2->ymin));
+}
+
+/*
+ * box_above - is box1 strictly above box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_above);
+Datum BOX2D_above(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPgt(box1->ymin, box2->ymax));
+}
+
+/*
+ * box_overabove - the top edge of box1 above
+ *                 the top edge of box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_overabove);
+Datum BOX2D_overabove(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPge(box1->ymax, box2->ymax));
+}
+
+/*
+ * box_contained - is box1 contained by box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_contained);
+Datum BOX2D_contained(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 =(BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPle(box1->xmax, box2->xmax) &&
+				   FPge(box1->xmin, box2->xmin) &&
+				   FPle(box1->ymax, box2->ymax) &&
+				   FPge(box1->ymin, box2->ymin));
+}
+
+/*
+ * box_contain - does box1 contain box2?
+ */
+ PG_FUNCTION_INFO_V1(BOX2D_contain);
+Datum BOX2D_contain(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4		   *box1 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4		   *box2 = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+
+	PG_RETURN_BOOL(FPge(box1->xmax, box2->xmax) &&
+				   FPle(box1->xmin, box2->xmin) &&
+				   FPge(box1->ymax, box2->ymax) &&
+				   FPle(box1->ymin, box2->ymin));
+
+}
+
+PG_FUNCTION_INFO_V1(BOX2D_intersects);
+Datum BOX2D_intersects(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *a = (BOX2DFLOAT4 *) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4 *b = (BOX2DFLOAT4 *) PG_GETARG_POINTER(1);
+	BOX2DFLOAT4 *n;
+
+
+	n = (BOX2DFLOAT4 *) palloc(sizeof(BOX2DFLOAT4));
+
+	n->xmax = LWGEOM_Minf(a->xmax, b->xmax);
+	n->ymax = LWGEOM_Minf(a->ymax, b->ymax);
+	n->xmin = LWGEOM_Maxf(a->xmin, b->xmin);
+	n->ymin = LWGEOM_Maxf(a->ymin, b->ymin);
+
+
+	if (n->xmax < n->xmin || n->ymax < n->ymin)
+	{
+		pfree(n);
+		/* Indicate "no intersection" by returning NULL pointer */
+		n = NULL;
+	}
+
+	PG_RETURN_POINTER(n);
+}
+
+
+/*
+ * union of two BOX2Ds
+ */
+PG_FUNCTION_INFO_V1(BOX2D_union);
+Datum BOX2D_union(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *a = (BOX2DFLOAT4*) PG_GETARG_POINTER(0);
+	BOX2DFLOAT4 *b = (BOX2DFLOAT4*) PG_GETARG_POINTER(1);
+	BOX2DFLOAT4 *n;
+
+	n = (BOX2DFLOAT4 *) lwalloc(sizeof(BOX2DFLOAT4));
+	if ( ! box2d_union_p(a,b,n) ) PG_RETURN_NULL();
+	PG_RETURN_POINTER(n);
+}
+
+
+/*
+ * min(a,b)
+ */
+float LWGEOM_Minf(float a, float b)
+{
+	if (a<b)
+		return a;
+	return b;
+}
+
+/*
+ * max(a,b)
+ */
+float LWGEOM_Maxf(float a, float b)
+{
+	if (b>a) return b;
+	return a;
+}
+
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_expand);
+Datum BOX2DFLOAT4_expand(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
+	double d = PG_GETARG_FLOAT8(1);
+	BOX2DFLOAT4 *result = (BOX2DFLOAT4 *)palloc(sizeof(BOX2DFLOAT4));
+
+	memcpy(result, box, sizeof(BOX2DFLOAT4));
+	expand_box2d(result, d);
+
+	PG_RETURN_POINTER(result);
+}
+
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_to_BOX3D);
+Datum BOX2DFLOAT4_to_BOX3D(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
+	BOX3D *result = palloc(sizeof(BOX3D));
+
+	box2df_to_box3d_p(box, result);
+
+	PG_RETURN_POINTER(result);
+}
+
+
+#define KEEP_OBSOLETED_FUNX 1
+#if KEEP_OBSOLETED_FUNX
+Datum BOX2DFLOAT4_xmin(PG_FUNCTION_ARGS);
+Datum BOX2DFLOAT4_ymin(PG_FUNCTION_ARGS);
+Datum BOX2DFLOAT4_xmax(PG_FUNCTION_ARGS);
+Datum BOX2DFLOAT4_ymax(PG_FUNCTION_ARGS);
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_xmin);
+Datum BOX2DFLOAT4_xmin(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
+	PG_RETURN_FLOAT4(box->xmin);
+}
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_ymin);
+Datum BOX2DFLOAT4_ymin(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
+	PG_RETURN_FLOAT4(box->ymin);
+}
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_xmax);
+Datum BOX2DFLOAT4_xmax(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
+	PG_RETURN_FLOAT4(box->xmax);
+}
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_ymax);
+Datum BOX2DFLOAT4_ymax(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
+	PG_RETURN_FLOAT4(box->ymax);
+}
+#endif
+
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_combine);
+Datum BOX2DFLOAT4_combine(PG_FUNCTION_ARGS)
+{
+	Pointer box2d_ptr = PG_GETARG_POINTER(0);
+	Pointer geom_ptr = PG_GETARG_POINTER(1);
+	BOX2DFLOAT4 *a,*b;
+	PG_LWGEOM *lwgeom;
+	BOX2DFLOAT4 box, *result;
+
+	if  ( (box2d_ptr == NULL) && (geom_ptr == NULL) )
+	{
+		PG_RETURN_NULL(); /* combine_box2d(null,null) => null */
+	}
+
+	result = (BOX2DFLOAT4 *)palloc(sizeof(BOX2DFLOAT4));
+
+	if (box2d_ptr == NULL)
+	{
+		lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+		/* empty geom would make getbox2d_p return NULL */
+		if ( ! getbox2d_p(SERIALIZED_FORM(lwgeom), &box) ) PG_RETURN_NULL();
+		memcpy(result, &box, sizeof(BOX2DFLOAT4));
+		PG_RETURN_POINTER(result);
+	}
+
+	/* combine_bbox(BOX3D, null) => BOX3D */
+	if (geom_ptr == NULL)
+	{
+		memcpy(result, (char *)PG_GETARG_DATUM(0), sizeof(BOX2DFLOAT4));
+		PG_RETURN_POINTER(result);
+	}
+
+	/*combine_bbox(BOX3D, geometry) => union(BOX3D, geometry->bvol) */
+
+	lwgeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+	if ( ! getbox2d_p(SERIALIZED_FORM(lwgeom), &box) )
+	{
+		/* must be the empty geom */
+		memcpy(result, (char *)PG_GETARG_DATUM(0), sizeof(BOX2DFLOAT4));
+		PG_RETURN_POINTER(result);
+	}
+
+	a = (BOX2DFLOAT4 *)PG_GETARG_DATUM(0);
+	b = &box;
+
+	result->xmax = LWGEOM_Maxf(a->xmax, b->xmax);
+	result->ymax = LWGEOM_Maxf(a->ymax, b->ymax);
+	result->xmin = LWGEOM_Minf(a->xmin, b->xmin);
+	result->ymin = LWGEOM_Minf(a->ymin, b->ymin);
+
+	PG_RETURN_POINTER(result);
+}
+
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_to_LWGEOM);
+Datum BOX2DFLOAT4_to_LWGEOM(PG_FUNCTION_ARGS)
+{
+	BOX2DFLOAT4 *box = (BOX2DFLOAT4 *)PG_GETARG_POINTER(0);
+	POINT2D *pts = palloc(sizeof(POINT2D)*5);
+	POINTARRAY *pa[1];
+	LWPOLY *poly;
+	int wantbbox = 0;
+	PG_LWGEOM *result;
+	uchar *ser;
+
+	/* Assign coordinates to POINT2D array */
+	pts[0].x = box->xmin; pts[0].y = box->ymin;
+	pts[1].x = box->xmin; pts[1].y = box->ymax;
+	pts[2].x = box->xmax; pts[2].y = box->ymax;
+	pts[3].x = box->xmax; pts[3].y = box->ymin;
+	pts[4].x = box->xmin; pts[4].y = box->ymin;
+
+	/* Construct point array */
+	pa[0] = palloc(sizeof(POINTARRAY));
+	pa[0]->serialized_pointlist = (uchar *)pts;
+	TYPE_SETZM(pa[0]->dims, 0, 0);
+	pa[0]->npoints = 5;
+
+	/* Construct polygon */
+	poly = lwpoly_construct(-1, NULL, 1, pa);
+
+	/* Serialize polygon */
+	ser = lwpoly_serialize(poly);
+
+	/* Construct PG_LWGEOM  */
+	result = PG_LWGEOM_construct(ser, -1, wantbbox);
+	
+	PG_RETURN_POINTER(result);
+}
+
+PG_FUNCTION_INFO_V1(BOX2DFLOAT4_construct);
+Datum BOX2DFLOAT4_construct(PG_FUNCTION_ARGS)
+{
+	PG_LWGEOM *min = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+	PG_LWGEOM *max = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
+	BOX2DFLOAT4 *result = palloc(sizeof(BOX2DFLOAT4));
+	LWGEOM *minpoint, *maxpoint;
+	POINT2D minp, maxp;
+
+	minpoint = lwgeom_deserialize(SERIALIZED_FORM(min));
+	maxpoint = lwgeom_deserialize(SERIALIZED_FORM(max));
+
+	if ( TYPE_GETTYPE(minpoint->type) != POINTTYPE ||
+		TYPE_GETTYPE(maxpoint->type) != POINTTYPE )
+	{
+		elog(ERROR, "BOX2DFLOAT4_construct: args must be points");
+		PG_RETURN_NULL();
+	}
+
+	errorIfSRIDMismatch(minpoint->SRID, maxpoint->SRID);
+
+	getPoint2d_p(((LWPOINT *)minpoint)->point, 0, &minp);
+	getPoint2d_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
+
+	result->xmax = maxp.x;
+	result->ymax = maxp.y;
+
+	result->xmin = minp.x;
+	result->ymin = minp.y;
+
+	PG_RETURN_POINTER(result);
+}
+

Modified: packages/postgis/trunk/lwgeom/lwgeom_box3d.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_box3d.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_box3d.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -354,10 +354,12 @@
 	if ( TYPE_GETTYPE(minpoint->type) != POINTTYPE ||
 		TYPE_GETTYPE(maxpoint->type) != POINTTYPE )
 	{
-		elog(ERROR, "BOX2DFLOAT4_construct: args must be points");
+		elog(ERROR, "BOX3D_construct: args must be points");
 		PG_RETURN_NULL();
 	}
 
+	errorIfSRIDMismatch(minpoint->SRID, maxpoint->SRID);
+
 	getPoint3dz_p(((LWPOINT *)minpoint)->point, 0, &minp);
 	getPoint3dz_p(((LWPOINT *)maxpoint)->point, 0, &maxp);
 

Modified: packages/postgis/trunk/lwgeom/lwgeom_btree.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_btree.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_btree.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,6 +1,6 @@
 /***********************************************************
  *
- * $Id: lwgeom_btree.c,v 1.9 2006/01/09 15:55:55 strk Exp $
+ * $Id: lwgeom_btree.c 2273 2006-01-09 15:55:55Z strk $
  *
  * Comparision function for use in Binary Tree searches
  * (ORDER BY, GROUP BY, DISTINCT)
@@ -458,7 +458,7 @@
 
 /***********************************************************
  *
- * $Log: lwgeom_btree.c,v $
+ * $Log$
  * Revision 1.9  2006/01/09 15:55:55  strk
  * ISO C90 comments (finished in lwgeom/)
  *

Modified: packages/postgis/trunk/lwgeom/lwgeom_chip.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_chip.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_chip.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -711,10 +711,10 @@
 	 * CHIP units
 	 */
 
-	PIXEL p;
-
 	switch ( op )
 	{
+		PIXEL p;
+
 		case PIXELOP_OVERWRITE:
 			chip_setPixel(chip, x, y, pixel);
 			break;
@@ -1098,9 +1098,10 @@
 		state->x < state->chip->width )
 	{
 		char buf[256];
+		PIXEL p;
 
 		if ( ! state->chip ) lwerror("state->chip corrupted");
-		PIXEL p = chip_getPixel(state->chip, state->x, state->y);
+		p = chip_getPixel(state->chip, state->x, state->y);
 		pixel_writeval(&p, buf, 255);
 
 		sprintf(state->values[0], "%d", state->x);

Modified: packages/postgis/trunk/lwgeom/lwgeom_dump.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_dump.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_dump.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -271,13 +271,14 @@
 	while (state->ringnum < state->poly->nrings )
 	{
 		LWPOLY* poly = state->poly;
+		POINTARRAY *ring;
 
 		/* Switch to an appropriate memory context for POINTARRAY
 		 * cloning and hexwkb allocation */
 		oldcontext = MemoryContextSwitchTo(newcontext);
 
 		/* We need a copy of input ring here */
-		POINTARRAY *ring = ptarray_clone(poly->rings[state->ringnum]);
+		ring = ptarray_clone(poly->rings[state->ringnum]);
 
 		/* Construct another polygon with shell only */
 		LWGEOM* ringgeom = (LWGEOM*)lwpoly_construct(

Modified: packages/postgis/trunk/lwgeom/lwgeom_estimate.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_estimate.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_estimate.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_estimate.c,v 1.39 2006/05/30 08:38:58 strk Exp $
+ * $Id: lwgeom_estimate.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -2629,7 +2629,7 @@
 
 
 /**********************************************************************
- * $Log: lwgeom_estimate.c,v $
+ * $Log$
  * Revision 1.39  2006/05/30 08:38:58  strk
  * Added some missing copyright headers.
  *

Modified: packages/postgis/trunk/lwgeom/lwgeom_functions_analytic.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_functions_analytic.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_functions_analytic.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_functions_analytic.c,v 1.33 2006/01/29 13:54:38 strk Exp $
+ * $Id: lwgeom_functions_analytic.c 2298 2006-01-29 13:54:38Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwgeom_functions_basic.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_functions_basic.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_functions_basic.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_functions_basic.c,v 1.143 2006/06/26 00:41:24 strk Exp $
+ * $Id: lwgeom_functions_basic.c 2461 2006-07-28 13:07:06Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -1622,6 +1622,7 @@
 	LWGEOM *lwgeoms[2], *outlwg;
 	unsigned int type1, type2, outtype;
 	BOX2DFLOAT4 *box=NULL;
+	int SRID;
 
 	/* return null if both geoms are null */
 	if ( (geom1_ptr == NULL) && (geom2_ptr == NULL) )
@@ -1651,12 +1652,17 @@
 	elog(NOTICE, "LWGEOM_collect(%s, %s): call", lwgeom_typename(TYPE_GETTYPE(pglwgeom1->type)), lwgeom_typename(TYPE_GETTYPE(pglwgeom2->type)));
 #endif
 	
+#if 0
 	if ( pglwgeom_getSRID(pglwgeom1) != pglwgeom_getSRID(pglwgeom2) )
 	{
 		elog(ERROR, "Operation on two GEOMETRIES with different SRIDs\n");
 		PG_RETURN_NULL();
 	}
+#endif
 
+	SRID = pglwgeom_getSRID(pglwgeom1);
+	errorIfSRIDMismatch(SRID, pglwgeom_getSRID(pglwgeom2));
+
 	lwgeoms[0] = lwgeom_deserialize(SERIALIZED_FORM(pglwgeom1));
 	lwgeoms[1] = lwgeom_deserialize(SERIALIZED_FORM(pglwgeom2));
 
@@ -1686,7 +1692,7 @@
 	lwgeom_dropSRID(lwgeoms[1]);
 
 	outlwg = (LWGEOM *)lwcollection_construct(
-		outtype, lwgeoms[0]->SRID,
+		outtype, SRID,
 		box, 2, lwgeoms);
 
 	result = pglwgeom_serialize(outlwg);
@@ -2001,7 +2007,7 @@
 	LWMPOINT *mpoint;
 
 #ifdef PGIS_DEBUG
-	elog(NOTICE, "LWGEOM_makeline called");
+	elog(NOTICE, "LWGEOM_line_from_mpoint called");
 #endif
 
 	/* Get input PG_LWGEOM and deserialize it */
@@ -2168,11 +2174,7 @@
 		PG_RETURN_NULL();
 	}
 
-	if ( pglwgeom_getSRID(pglwg1) != pglwgeom_getSRID(pglwg2) )
-	{
-		elog(ERROR, "Operation with two geometries with different SRIDs\n");
-		PG_RETURN_NULL();
-	}
+	errorIfSRIDMismatch(pglwgeom_getSRID(pglwg1), pglwgeom_getSRID(pglwg2));
 
 	lwpoints[0] = lwpoint_deserialize(SERIALIZED_FORM(pglwg1));
 	lwpoints[1] = lwpoint_deserialize(SERIALIZED_FORM(pglwg2));

Modified: packages/postgis/trunk/lwgeom/lwgeom_functions_lrs.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_functions_lrs.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_functions_lrs.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_functions_lrs.c,v 1.5 2005/12/01 19:09:04 strk Exp $
+ * $Id: lwgeom_functions_lrs.c 2124 2005-12-01 19:09:04Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwgeom_gist.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_gist.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_gist.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -544,7 +544,11 @@
 
 			gistentryinit(*retval, PointerGetDatum(rr),
 				entry->rel, entry->page,
+#if USE_VERSION >= 82
+				entry->offset,
+#else
 				entry->offset, sizeof(BOX2DFLOAT4),
+#endif
 				FALSE);
 
 		}
@@ -554,7 +558,11 @@
 		elog(NOTICE,"GIST: LWGEOM_gist_compress got a NULL key");
 #endif
 			gistentryinit(*retval, (Datum) 0, entry->rel,
+#if USE_VERSION >= 82
+				entry->page, entry->offset, FALSE);
+#else
 				entry->page, entry->offset, 0, FALSE);
+#endif
 		}
 
 	}

Modified: packages/postgis/trunk/lwgeom/lwgeom_gml.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_gml.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_gml.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_gml.c,v 1.13 2006/01/09 15:55:55 strk Exp $
+ * $Id: lwgeom_gml.c 2273 2006-01-09 15:55:55Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -504,7 +504,7 @@
 }
 
 /**********************************************************************
- * $Log: lwgeom_gml.c,v $
+ * $Log$
  * Revision 1.13  2006/01/09 15:55:55  strk
  * ISO C90 comments (finished in lwgeom/)
  *

Modified: packages/postgis/trunk/lwgeom/lwgeom_ogc.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_ogc.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_ogc.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_ogc.c,v 1.49 2005/12/30 17:40:37 strk Exp $
+ * $Id: lwgeom_ogc.c 2243 2005-12-30 17:40:37Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwgeom_spheroid.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_spheroid.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_spheroid.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_spheroid.c,v 1.14 2006/01/09 15:12:02 strk Exp $
+ * $Id: lwgeom_spheroid.c 2272 2006-01-09 15:12:02Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwgeom_svg.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_svg.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_svg.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_svg.c,v 1.11 2006/01/09 15:55:55 strk Exp $
+ * $Id: lwgeom_svg.c 2273 2006-01-09 15:55:55Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -279,7 +279,7 @@
 
 
 /**********************************************************************
- * $Log: lwgeom_svg.c,v $
+ * $Log$
  * Revision 1.11  2006/01/09 15:55:55  strk
  * ISO C90 comments (finished in lwgeom/)
  *

Modified: packages/postgis/trunk/lwgeom/lwgeom_transform.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwgeom_transform.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwgeom_transform.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_transform.c,v 1.31 2006/01/09 15:55:55 strk Exp $
+ * $Id: lwgeom_transform.c 2273 2006-01-09 15:55:55Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwline.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwline.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwline.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwline.c,v 1.32 2006/05/30 08:38:58 strk Exp $
+ * $Id: lwline.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwmline.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwmline.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwmline.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwmline.c,v 1.14 2006/05/30 08:38:58 strk Exp $
+ * $Id: lwmline.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwmpoint.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwmpoint.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwmpoint.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwmpoint.c,v 1.14 2006/05/30 08:38:58 strk Exp $
+ * $Id: lwmpoint.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwmpoly.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwmpoly.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwmpoly.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwmpoly.c,v 1.15 2006/05/30 08:38:58 strk Exp $
+ * $Id: lwmpoly.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwpoint.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwpoint.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwpoint.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwpoint.c,v 1.23 2006/05/30 08:38:58 strk Exp $
+ * $Id: lwpoint.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwpoly.c
===================================================================
--- packages/postgis/trunk/lwgeom/lwpoly.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwpoly.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwpoly.c,v 1.23 2006/05/30 08:38:58 strk Exp $
+ * $Id: lwpoly.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/lwpostgis.sql.in
===================================================================
--- packages/postgis/trunk/lwgeom/lwpostgis.sql.in	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/lwpostgis.sql.in	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,6 +1,6 @@
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- 
--- $Id: lwpostgis.sql.in,v 1.159 2006/06/25 23:59:32 strk Exp $
+-- $Id: lwpostgis.sql.in 2406 2006-07-07 13:56:52Z strk $
 --
 -- PostGIS - Spatial Types for PostgreSQL
 -- http://postgis.refractions.net
@@ -2041,7 +2041,7 @@
 		table_name || ''.'' || column_name ||
 		'' SRID:'' || new_srid ||
 		'' TYPE:'' || new_type || 
-		'' DIMS:'' || new_dim || ''\n ''; 
+		'' DIMS:'' || new_dim || chr(10) || '' ''; 
 END;
 '
 LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
@@ -2623,7 +2623,7 @@
 -- Do not modify this w/out also changing postgis_proc_upgrade.pl
 --
 CREATEFUNCTION postgis_scripts_installed() RETURNS text
-        AS 'SELECT \'@POSTGIS_SCRIPTS_VERSION@\'::text AS version'
+        AS 'SELECT ''@POSTGIS_SCRIPTS_VERSION@''::text AS version'
         LANGUAGE 'sql' _IMMUTABLE;
 
 CREATEFUNCTION postgis_lib_version() RETURNS text
@@ -2648,7 +2648,7 @@
 	LANGUAGE 'C' _IMMUTABLE;
 
 CREATEFUNCTION postgis_scripts_build_date() RETURNS text
-        AS 'SELECT \'@POSTGIS_BUILD_DATE@\'::text AS version'
+        AS 'SELECT ''@POSTGIS_BUILD_DATE@''::text AS version'
         LANGUAGE 'sql' _IMMUTABLE;
 
 CREATEFUNCTION postgis_lib_build_date() RETURNS text
@@ -2677,29 +2677,29 @@
 	SELECT postgis_scripts_installed() INTO dbproc;
 	SELECT postgis_scripts_released() INTO relproc;
 
-	fullver = \'POSTGIS="\' || libver || \'"\';
+	fullver = ''POSTGIS="'' || libver || ''"'';
 
 	IF  geosver IS NOT NULL THEN
-		fullver = fullver || \' GEOS="\' || geosver || \'"\';
+		fullver = fullver || '' GEOS="'' || geosver || ''"'';
 	END IF;
 
 	IF  jtsver IS NOT NULL THEN
-		fullver = fullver || \' JTS="\' || jtsver || \'"\';
+		fullver = fullver || '' JTS="'' || jtsver || ''"'';
 	END IF;
 
 	IF  projver IS NOT NULL THEN
-		fullver = fullver || \' PROJ="\' || projver || \'"\';
+		fullver = fullver || '' PROJ="'' || projver || ''"'';
 	END IF;
 
 	IF usestats THEN
-		fullver = fullver || \' USE_STATS\';
+		fullver = fullver || '' USE_STATS'';
 	END IF;
 
-	-- fullver = fullver || \' DBPROC="\' || dbproc || \'"\';
-	-- fullver = fullver || \' RELPROC="\' || relproc || \'"\';
+	-- fullver = fullver || '' DBPROC="'' || dbproc || ''"'';
+	-- fullver = fullver || '' RELPROC="'' || relproc || ''"'';
 
 	IF dbproc != relproc THEN
-		fullver = fullver || \' (procs from \' || dbproc || \' need upgrade)\';
+		fullver = fullver || '' (procs from '' || dbproc || '' need upgrade)'';
 	END IF;
 
 	RETURN fullver;

Modified: packages/postgis/trunk/lwgeom/measures.c
===================================================================
--- packages/postgis/trunk/lwgeom/measures.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/measures.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: measures.c,v 1.11 2006/05/30 08:38:58 strk Exp $
+ * $Id: measures.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/ptarray.c
===================================================================
--- packages/postgis/trunk/lwgeom/ptarray.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/ptarray.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: ptarray.c,v 1.31 2006/05/30 08:38:58 strk Exp $
+ * $Id: ptarray.c 2369 2006-05-30 08:38:58Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net

Modified: packages/postgis/trunk/lwgeom/stringBuffer.h
===================================================================
--- packages/postgis/trunk/lwgeom/stringBuffer.h	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/stringBuffer.h	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,14 +1,14 @@
-
-typedef struct {
-	char * string;
-	int length; /* length of string, EXCLUDING null termination */
-	int size;   /* size of buffer -can be longer than */
-} STRBUFF;
-
-
-extern STRBUFF * new_strBUFF(int size);
-extern void delete_StrBUFF(STRBUFF* buff);
-extern char* to_CString(STRBUFF * buffer);
-extern void add_str_simple(STRBUFF* buffer, char* str);
-extern void catenate(STRBUFF *buffer, char* str, int length);
-extern int getSize(int buffer_size, int buffer_length, int strLength);
+
+typedef struct {
+	char * string;
+	int length; /* length of string, EXCLUDING null termination */
+	int size;   /* size of buffer -can be longer than */
+} STRBUFF;
+
+
+extern STRBUFF * new_strBUFF(int size);
+extern void delete_StrBUFF(STRBUFF* buff);
+extern char* to_CString(STRBUFF * buffer);
+extern void add_str_simple(STRBUFF* buffer, char* str);
+extern void catenate(STRBUFF *buffer, char* str, int length);
+extern int getSize(int buffer_size, int buffer_length, int strLength);

Modified: packages/postgis/trunk/lwgeom/wktparse.h
===================================================================
--- packages/postgis/trunk/lwgeom/wktparse.h	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/wktparse.h	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,88 +1,88 @@
-/*
- * Written by Ralph Mason ralph.mason<at>telogis.com
- *
- * Copyright Telogis 2004
- * www.telogis.com
- *
- */
-
-#ifndef _WKTPARSE_H
-#define _WKTPARSE_H
-
-#include <stdlib.h>
-
-
-#ifndef _LIBLWGEOM_H
-typedef unsigned char uchar;
-#endif
-typedef void* (*allocator)(size_t size);
-typedef void  (*freeor)(void* mem);
-typedef void  (*report_error)(const char* string, ...);
-
-/*typedef unsigned long int4;*/
-
-/* How much memory is allocated at a time(bytes) for tuples */
-#define ALLOC_CHUNKS 8192
-
-/* to shrink ints less than 0x7f to 1 byte */
-/* #define SHRINK_INTS */
-
-#define	POINTTYPE	1
-#define	LINETYPE	2
-#define	POLYGONTYPE	3
-#define	MULTIPOINTTYPE	4
-#define	MULTILINETYPE	5
-#define	MULTIPOLYGONTYPE	6
-#define	COLLECTIONTYPE	7
-
-/* Extended lwgeom integer types */
-#define POINTTYPEI    10
-#define LINETYPEI     11
-#define POLYGONTYPEI  12
-
-extern int srid;
-
-/*
-
-   These functions are used by  the
-   generated parser and are not meant
-   for public use
-
-*/
-
-void set_srid(double srid);
-void alloc_lwgeom(int srid);
-
-void alloc_point_2d(double x,double y);
-void alloc_point_3d(double x,double y,double z);
-void alloc_point_4d(double x,double y,double z,double m);
-
-void alloc_point(void);
-void alloc_linestring(void);
-void alloc_polygon(void);
-void alloc_multipoint(void);
-void alloc_multilinestring(void);
-void alloc_multipolygon(void);
-void alloc_geomertycollection(void);
-void alloc_empty();
-void alloc_counter(void);
-
-
-void pop(void);
-void popc(void);
-
-void alloc_wkb(const char* parser);
-
-/*
-	Use these functions to parse and unparse lwgeoms
-	You are responsible for freeing the returned memory.
-*/
-
-uchar* parse_lwg(const char* wkt,allocator allocfunc,report_error errfunc);
-uchar* parse_lwgi(const char* wkt,allocator allocfunc,report_error errfunc);
-char* unparse_WKT(uchar* serialized, allocator alloc,freeor free);
-char* unparse_WKB(uchar* serialized, allocator alloc,freeor free, char endian, size_t *outsize, uchar hexform);
-int lwg_parse_yyparse(void);
-int lwg_parse_yyerror(char* s);
-
-#endif /* _WKTPARSE_H */
+/*
+ * Written by Ralph Mason ralph.mason<at>telogis.com
+ *
+ * Copyright Telogis 2004
+ * www.telogis.com
+ *
+ */
+
+#ifndef _WKTPARSE_H
+#define _WKTPARSE_H
+
+#include <stdlib.h>
+
+
+#ifndef _LIBLWGEOM_H
+typedef unsigned char uchar;
+#endif
+typedef void* (*allocator)(size_t size);
+typedef void  (*freeor)(void* mem);
+typedef void  (*report_error)(const char* string, ...);
+
+/*typedef unsigned long int4;*/
+
+/* How much memory is allocated at a time(bytes) for tuples */
+#define ALLOC_CHUNKS 8192
+
+/* to shrink ints less than 0x7f to 1 byte */
+/* #define SHRINK_INTS */
+
+#define	POINTTYPE	1
+#define	LINETYPE	2
+#define	POLYGONTYPE	3
+#define	MULTIPOINTTYPE	4
+#define	MULTILINETYPE	5
+#define	MULTIPOLYGONTYPE	6
+#define	COLLECTIONTYPE	7
+
+/* Extended lwgeom integer types */
+#define POINTTYPEI    10
+#define LINETYPEI     11
+#define POLYGONTYPEI  12
+
+extern int srid;
+
+/*
+
+   These functions are used by  the
+   generated parser and are not meant
+   for public use
+
+*/
+
+void set_srid(double srid);
+void alloc_lwgeom(int srid);
+
+void alloc_point_2d(double x,double y);
+void alloc_point_3d(double x,double y,double z);
+void alloc_point_4d(double x,double y,double z,double m);
+
+void alloc_point(void);
+void alloc_linestring(void);
+void alloc_polygon(void);
+void alloc_multipoint(void);
+void alloc_multilinestring(void);
+void alloc_multipolygon(void);
+void alloc_geomertycollection(void);
+void alloc_empty();
+void alloc_counter(void);
+
+
+void pop(void);
+void popc(void);
+
+void alloc_wkb(const char* parser);
+
+/*
+	Use these functions to parse and unparse lwgeoms
+	You are responsible for freeing the returned memory.
+*/
+
+uchar* parse_lwg(const char* wkt,allocator allocfunc,report_error errfunc);
+uchar* parse_lwgi(const char* wkt,allocator allocfunc,report_error errfunc);
+char* unparse_WKT(uchar* serialized, allocator alloc,freeor free);
+char* unparse_WKB(uchar* serialized, allocator alloc,freeor free, char endian, size_t *outsize, uchar hexform);
+int lwg_parse_yyparse(void);
+int lwg_parse_yyerror(char* s);
+
+#endif /* _WKTPARSE_H */

Modified: packages/postgis/trunk/lwgeom/wktunparse.c
===================================================================
--- packages/postgis/trunk/lwgeom/wktunparse.c	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/lwgeom/wktunparse.c	2006-10-06 08:50:14 UTC (rev 563)
@@ -4,7 +4,7 @@
  * Copyright Telogis 2004
  * www.telogis.com
  *
- * $Id: wktunparse.c,v 1.23 2006/02/06 11:12:22 strk Exp $
+ * $Id: wktunparse.c 2305 2006-02-06 11:12:22Z strk $
  */
 
 
@@ -612,7 +612,7 @@
 
 
 /******************************************************************
- * $Log: wktunparse.c,v $
+ * $Log$
  * Revision 1.23  2006/02/06 11:12:22  strk
  * uint32_t typedef moved back from wktparse.h to lwgparse.c and wktunparse.c
  *

Deleted: packages/postgis/trunk/make_dist.sh
===================================================================
--- packages/postgis/trunk/make_dist.sh	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/make_dist.sh	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,86 +0,0 @@
-#!/bin/sh
-
-#
-# USAGE:
-#
-# -- postgis-cvs.tar.gz 
-# sh make_dist.sh
-#
-# -- postgis-1.1.0.tar.gz 
-# sh make_dist.sh 1.1.0
-#
-# NOTE: will not work prior to 1.1.0
-#
-#
-
-tag=HEAD
-version=cvs
-
-if [ -n "$1" ]; then
-	version="$1"
-	version=`echo $version | sed 's/RC/-rc/'`
-	tag=pgis_`echo "$version" | sed 's/\./_/g'`
-fi
-
-outdir="postgis-$version"
-package="postgis-$version.tar.gz"
-
-if [ -d "$outdir" ]; then
-	echo "Output directory $outdir already exist"
-	exit 1
-fi
-
-echo "Exporting tag $tag"
-cvs export -r "$tag" -d "$outdir" postgis 
-if [ $? -gt 0 ]; then
-	exit 1
-fi
-
-# remove .cvsignore, make_dist.sh and HOWTO_RELEASE
-echo "Removing .cvsignore and make_dist.sh files"
-find "$outdir" -name .cvsignore -exec rm {} \;
-rm -f "$outdir"/make_dist.sh "$outdir"/HOWTO_RELEASE
-
-# generating configure script
-echo "Running autogen.sh; ./configure"
-owd="$PWD"
-cd "$outdir"
-./autogen.sh
-./configure
-cd "$owd"
-
-# generating documentation
-echo "Generating documentation"
-owd="$PWD"
-cd "$outdir"/doc
-sleep 2 # wait some time to have 'make' recognize it needs to build html
-make 
-if [ $? -gt 0 ]; then
-	exit 1
-fi
-make clean # won't drop the html dir
-cd "$owd"
-
-## generating parser
-#echo "Generating parser"
-#owd="$PWD"
-#cd "$outdir"/lwgeom
-#make lex.yy.c
-#if [ $? -gt 0 ]; then
-#	exit 1
-#fi
-#cd "$owd"
-
-# Run make distclean
-echo "Running make distclean"
-owd="$PWD"
-cd "$outdir"
-make distclean
-cd "$owd"
-
-echo "Generating $package file"
-tar czf "$package" "$outdir"
-
-#echo "Cleaning up"
-#rm -Rf "$outdir"
-

Modified: packages/postgis/trunk/regress/Makefile
===================================================================
--- packages/postgis/trunk/regress/Makefile	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/regress/Makefile	2006-10-06 08:50:14 UTC (rev 563)
@@ -26,7 +26,8 @@
 	affine \
 	wkt \
 	measures \
-	long_xact
+	long_xact \
+	ctors
 
 ifeq ($(USE_GEOS),1)
 	TESTS += regress_ogc regress_bdpoly

Copied: packages/postgis/trunk/regress/ctors.sql (from rev 562, packages/postgis/upstream/regress/ctors.sql)
===================================================================
--- packages/postgis/trunk/regress/ctors.sql	                        (rev 0)
+++ packages/postgis/trunk/regress/ctors.sql	2006-10-06 08:50:14 UTC (rev 563)
@@ -0,0 +1,14 @@
+-- postgis-users/2006-July/012764.html
+SELECT SRID(collect('SRID=32749;POINT(0 0)', 'SRID=32749;POINT(1 1)'));
+
+SELECT collect('SRID=32749;POINT(0 0)', 'SRID=32740;POINT(1 1)');
+
+select asewkt(makeline('SRID=3;POINT(0 0)', 'SRID=3;POINT(1 1)'));
+select makeline('POINT(0 0)', 'SRID=3;POINT(1 1)');
+
+-- postgis-users/2006-July/012788.html
+select makebox2d('SRID=3;POINT(0 0)', 'SRID=3;POINT(1 1)');
+select makebox2d('POINT(0 0)', 'SRID=3;POINT(1 1)');
+
+select makebox3d('SRID=3;POINT(0 0)', 'SRID=3;POINT(1 1)');
+select makebox3d('POINT(0 0)', 'SRID=3;POINT(1 1)');

Copied: packages/postgis/trunk/regress/ctors_expected (from rev 562, packages/postgis/upstream/regress/ctors_expected)
===================================================================
--- packages/postgis/trunk/regress/ctors_expected	                        (rev 0)
+++ packages/postgis/trunk/regress/ctors_expected	2006-10-06 08:50:14 UTC (rev 563)
@@ -0,0 +1,8 @@
+32749
+ERROR:  Operation on mixed SRID geometries
+SRID=3;LINESTRING(0 0,1 1)
+ERROR:  Operation on mixed SRID geometries
+BOX(0 0,1 1)
+ERROR:  Operation on mixed SRID geometries
+BOX3D(0 0 0,1 1 0)
+ERROR:  Operation on mixed SRID geometries

Modified: packages/postgis/trunk/regress/loader/Arc.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/ArcM.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/MultiPoint.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/MultiPointM.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/MultiPointZ.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/Point.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/PointM.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/PointZ.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/Polygon.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/PolygonM.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/loader/PolygonZ.dbf
===================================================================
(Binary files differ)

Modified: packages/postgis/trunk/regress/regress_index.sql
===================================================================
--- packages/postgis/trunk/regress/regress_index.sql	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/regress/regress_index.sql	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,16 +1,16 @@
---- build a larger database
-\i regress_lots_of_points.sql
-
---- test some of the searching capabilities
-
--- GiST index
-
-CREATE INDEX quick_gist on test using gist (the_geom gist_geometry_ops);
-
- select num,astext(the_geom) from test where the_geom && 'BOX3D(125 125,135 135)'::box3d order by num;
-
-set enable_seqscan = off;
-
- select num,astext(the_geom) from test where the_geom && 'BOX3D(125 125,135 135)'::box3d  order by num;
-
-DROP TABLE test;
+--- build a larger database
+\i regress_lots_of_points.sql
+
+--- test some of the searching capabilities
+
+-- GiST index
+
+CREATE INDEX quick_gist on test using gist (the_geom gist_geometry_ops);
+
+ select num,astext(the_geom) from test where the_geom && 'BOX3D(125 125,135 135)'::box3d order by num;
+
+set enable_seqscan = off;
+
+ select num,astext(the_geom) from test where the_geom && 'BOX3D(125 125,135 135)'::box3d  order by num;
+
+DROP TABLE test;

Modified: packages/postgis/trunk/regress/regress_ogc.sql
===================================================================
--- packages/postgis/trunk/regress/regress_ogc.sql	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/regress/regress_ogc.sql	2006-10-06 08:50:14 UTC (rev 563)
@@ -8,7 +8,7 @@
 SELECT 'buffer', astext(SnapToGrid(buffer('POINT(0 0)', 1, 2), 1.0e-6));
 
 SELECT 'geomunion', astext(geomunion('POINT(0 0)', 'POINT(1 1)'));
-SELECT 'unite_garray', astext(unite_garray(geom_accum('{POINT(0 0)}', 'POINT(2 3)')));
+SELECT 'unite_garray', equals(unite_garray(geom_accum('{POINT(0 0)}', 'POINT(2 3)')), 'MULTIPOINT(2 3,0 0)');
 SELECT 'convexhull', asewkt(convexhull('POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(2 2, 2 4, 4 4, 4 2, 2 2))'));
 SELECT 'relate', relate('POINT(0 0)', 'LINESTRING(0 0, 1 1)');
 SELECT 'relate', relate('POINT(0 0)', 'LINESTRING(0 0, 1 1)', 'F0FFFF*02');

Modified: packages/postgis/trunk/regress/regress_ogc_expected
===================================================================
--- packages/postgis/trunk/regress/regress_ogc_expected	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/regress/regress_ogc_expected	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,6 +1,6 @@
 buffer|POLYGON((1 0,0.707107 -0.707107,0 -1,-0.707107 -0.707107,-1 0,-0.707107 0.707107,0 1,0.707107 0.707107,1 0))
 geomunion|MULTIPOINT(0 0,1 1)
-unite_garray|MULTIPOINT(2 3,0 0)
+unite_garray|t
 convexhull|POLYGON((0 0,0 10,10 10,10 0,0 0))
 relate|F0FFFF102
 relate|t

Deleted: packages/postgis/trunk/topology/.cvsignore
===================================================================
--- packages/postgis/trunk/topology/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/topology/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1 +0,0 @@
-topology.sql

Deleted: packages/postgis/trunk/topology/ER/.cvsignore
===================================================================
--- packages/postgis/trunk/topology/ER/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/topology/ER/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1 +0,0 @@
-topology.png

Deleted: packages/postgis/trunk/topology/test/.cvsignore
===================================================================
--- packages/postgis/trunk/topology/test/.cvsignore	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/topology/test/.cvsignore	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,2 +0,0 @@
-geom_predicates.sql
-topo_predicates.sql

Modified: packages/postgis/trunk/topology/topology.sql.in
===================================================================
--- packages/postgis/trunk/topology/topology.sql.in	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/topology/topology.sql.in	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,6 +1,6 @@
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- 
--- $Id: topology.sql.in,v 1.5 2005/11/01 11:56:20 strk Exp $
+-- $Id: topology.sql.in 2469 2006-09-06 11:16:59Z strk $
 --
 -- PostGIS - Spatial Types for PostgreSQL
 -- http://postgis.refractions.net
@@ -702,12 +702,6 @@
 '
 LANGUAGE 'sql' _VOLATILE;
 
-CREATEFUNCTION topology.AddTopoGeometryColumn(varchar, varchar, varchar, varchar, varchar)
-	RETURNS integer
-AS '
-	SELECT topology.AddTopoGeometryColumn($1, $2, $3, $4, $5, NULL);
-'
-LANGUAGE 'sql' _VOLATILE;
 --
 --} AddTopoGeometryColumn
 

Modified: packages/postgis/trunk/utils/profile_intersects.pl
===================================================================
--- packages/postgis/trunk/utils/profile_intersects.pl	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/utils/profile_intersects.pl	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-# $Id: profile_intersects.pl,v 1.4 2004/09/27 08:23:45 strk Exp $
+# $Id: profile_intersects.pl 895 2004-09-27 08:23:45Z strk $
 # 
 # TODO:
 #
@@ -379,7 +379,7 @@
 }
 
 # 
-# $Log: profile_intersects.pl,v $
+# $Log$
 # Revision 1.4  2004/09/27 08:23:45  strk
 # Added USE_GIST variable on top of file. Changed true values report
 # as fraction of total rows.

Modified: packages/postgis/trunk/utils/test_estimation.pl
===================================================================
--- packages/postgis/trunk/utils/test_estimation.pl	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/utils/test_estimation.pl	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-# $Id: test_estimation.pl,v 1.9 2005/04/18 13:30:25 strk Exp $
+# $Id: test_estimation.pl 1631 2005-04-18 13:30:25Z strk $
 # 
 # TODO:
 #
@@ -285,7 +285,7 @@
 }
 
 # 
-# $Log: test_estimation.pl,v $
+# $Log$
 # Revision 1.9  2005/04/18 13:30:25  strk
 # Fixed to work against LWGEOM installations
 #

Modified: packages/postgis/trunk/utils/test_joinestimation.pl
===================================================================
--- packages/postgis/trunk/utils/test_joinestimation.pl	2006-10-06 08:47:10 UTC (rev 562)
+++ packages/postgis/trunk/utils/test_joinestimation.pl	2006-10-06 08:50:14 UTC (rev 563)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-# $Id: test_joinestimation.pl,v 1.3 2005/04/18 13:50:14 strk Exp $
+# $Id: test_joinestimation.pl 1633 2005-04-18 13:50:14Z strk $
 # 
 # TODO:
 #
@@ -255,7 +255,7 @@
 }
 
 # 
-# $Log: test_joinestimation.pl,v $
+# $Log$
 # Revision 1.3  2005/04/18 13:50:14  strk
 # Fixed bug in table2 schema parsing.
 #




More information about the Pkg-grass-devel mailing list