[DebianGIS-dev] r758 - in packages/postgis/upstream: . doc doc/html extras/rpm/patches extras/rpm/spec extras/template_gis java/ejb3/src/org/postgis/hibernate java/jdbc java/jdbc/jtssrc/examples java/jdbc/jtssrc/org/postgis/jts java/jdbc/src/org/postgis lwgeom regress utils

Fabio Tranchitella kobold at alioth.debian.org
Fri Apr 13 07:15:31 UTC 2007


Author: kobold
Date: 2007-04-13 07:15:27 +0000 (Fri, 13 Apr 2007)
New Revision: 758

Added:
   packages/postgis/upstream/extras/rpm/patches/postgis-configure.patch
   packages/postgis/upstream/extras/rpm/patches/postgis-javamakefile.patch
   packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JTSShape.java
   packages/postgis/upstream/lwgeom/long_xact.sql.in
   packages/postgis/upstream/lwgeom/lwcompound.c
   packages/postgis/upstream/lwgeom/lwcurve.c
   packages/postgis/upstream/lwgeom/lwcurvepoly.c
   packages/postgis/upstream/lwgeom/lwgeom_kml.c
   packages/postgis/upstream/lwgeom/lwgeom_sqlmm.c
   packages/postgis/upstream/lwgeom/lwmcurve.c
   packages/postgis/upstream/lwgeom/lwmsurface.c
   packages/postgis/upstream/lwgeom/sqldefines.h
   packages/postgis/upstream/lwgeom/sqlmm.sql.in
   packages/postgis/upstream/regress/regress_index_nulls.sql
   packages/postgis/upstream/regress/regress_index_nulls_expected
   packages/postgis/upstream/regress/regress_lots_of_nulls.sql
   packages/postgis/upstream/regress/sql-mm-serialize.sql
   packages/postgis/upstream/regress/sql-mm-serialize_expected
Modified:
   packages/postgis/upstream/CREDITS
   packages/postgis/upstream/ChangeLog
   packages/postgis/upstream/GNUmakefile
   packages/postgis/upstream/NEWS
   packages/postgis/upstream/README.postgis
   packages/postgis/upstream/TODO
   packages/postgis/upstream/Version.config
   packages/postgis/upstream/configure
   packages/postgis/upstream/configure.in
   packages/postgis/upstream/doc/html/postgis.html
   packages/postgis/upstream/doc/postgis.xml
   packages/postgis/upstream/extras/rpm/spec/postgis.spec
   packages/postgis/upstream/extras/template_gis/Makefile
   packages/postgis/upstream/java/ejb3/src/org/postgis/hibernate/GeometryType.java
   packages/postgis/upstream/java/jdbc/Makefile
   packages/postgis/upstream/java/jdbc/jtssrc/examples/JtsTestParser.java
   packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JtsBinaryWriter.java
   packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JtsWrapper.java
   packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapper.java
   packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapperAutoprobe.java
   packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapperLW.java
   packages/postgis/upstream/lwgeom/Makefile
   packages/postgis/upstream/lwgeom/SERIALIZED_FORM
   packages/postgis/upstream/lwgeom/lex.yy.c
   packages/postgis/upstream/lwgeom/liblwgeom.c
   packages/postgis/upstream/lwgeom/liblwgeom.h
   packages/postgis/upstream/lwgeom/lwcollection.c
   packages/postgis/upstream/lwgeom/lwgeom.c
   packages/postgis/upstream/lwgeom/lwgeom_api.c
   packages/postgis/upstream/lwgeom/lwgeom_functions_analytic.c
   packages/postgis/upstream/lwgeom/lwgeom_functions_basic.c
   packages/postgis/upstream/lwgeom/lwgeom_geos.c
   packages/postgis/upstream/lwgeom/lwgeom_geos_c.c
   packages/postgis/upstream/lwgeom/lwgeom_gist.c
   packages/postgis/upstream/lwgeom/lwgeom_pg.c
   packages/postgis/upstream/lwgeom/lwgeom_spheroid.c
   packages/postgis/upstream/lwgeom/lwgeom_transform.c
   packages/postgis/upstream/lwgeom/lwgparse.c
   packages/postgis/upstream/lwgeom/lwline.c
   packages/postgis/upstream/lwgeom/lwpostgis.sql.in
   packages/postgis/upstream/lwgeom/ptarray.c
   packages/postgis/upstream/lwgeom/wktparse.h
   packages/postgis/upstream/lwgeom/wktparse.lex
   packages/postgis/upstream/lwgeom/wktparse.tab.c
   packages/postgis/upstream/lwgeom/wktparse.tab.h
   packages/postgis/upstream/lwgeom/wktparse.y
   packages/postgis/upstream/lwgeom/wktunparse.c
   packages/postgis/upstream/regress/Makefile
   packages/postgis/upstream/regress/README
   packages/postgis/upstream/regress/lwgeom_regress_expected
   packages/postgis/upstream/utils/postgis_restore.pl
Log:
Importing postgis 1.2.1.


Modified: packages/postgis/upstream/CREDITS
===================================================================
--- packages/postgis/upstream/CREDITS	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/CREDITS	2007-04-13 07:15:27 UTC (rev 758)
@@ -50,5 +50,9 @@
 Version 1.1.0 of PostGIS includes patches from:
   Obe, Regina <robe.dnd at cityofboston.gov> with -k switch for pgsql2shp.
 
+Version 1.2.1 of PostGIS includes patches from:
+  Eduin Carrillo <yecarrillo at yahoo.com> for AsKML() and Transform() 
+  short circuit.
+
 See the postgis manual for more contributors.
 

Modified: packages/postgis/upstream/ChangeLog
===================================================================
--- packages/postgis/upstream/ChangeLog	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/ChangeLog	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,3 +1,144 @@
+
+---------  PostGIS-1.2.1 release [2007-01-11] --------------------------
+
+2007-01-08 Markus Schaber <schabi at logix-tt.com>
+
+        * java/jdbc/Makefile:
+          Fixed gcj classpath problems
+        * src/org/postgis/DriverWrapperLW.java,
+          src/org/postgis/DriverWrapperAutoprobe.java,
+          src/org/postgis/DriverWrapper.java,
+          jtssrc/org/postgis/jts/JtsWrapper.java:
+          fixed 8.2 compatibility
+
+2007-01-05 Sandro Santilli <strk at refractions.net>
+
+	* GNUmakefile: bring in extra/template_gis for all rules.
+	* extras/template_gis/Makefile: have 'install' also install manuals.
+
+2006-12-29 Sandro Santilli <strk at refractions.net>
+
+	* configure.in: fixed GEOS_LDFLAGS detection
+	  for older GEOS versions.
+	* doc/postgis.xml: cleaned up Hard Upgrade section
+	  (was unreadable).
+
+2006-12-22 Markus Schaber <schabi at logix-tt.com>
+
+        * java/jdbc/Makefile
+          Added generation of basic javadoc zip file.
+
+2006-12-20 Sandro Santilli <strk at refractions.net>
+
+	* regress/README: wrote info about adding regression tests
+
+2006-12-20 Kevein Neufeld <kneufeld at refractions.net>
+
+	* lwgeom/lwgeom_gist.c
+	  Added fix to permit gist indexes to have more than 459 null
+	  geometries in a table
+
+2006-12-15 Markus Schaber <schabi at logix-tt.com>
+
+        * java/jdbc/Makefile
+          Fixed Makefile for jts tests, commented debug options better
+          
+        * java/jdbc/jtssrc/org/postgis/jts/JtsBinaryWriter.java 
+          Fix multi-dimension handling in JtsBinaryWriter, thanks to 
+          Thomas Marti for the hints
+          
+        * java/jdbc/jtssrc/examples/JtsTestParser.java
+          Improved SRID handling in regression tests and added 
+          CoordinateArraySequence tests.
+
+2006-12-15 Eduin Carrillo <yecarrillo at yahoo.com>
+
+	* lwgeom/lwgeom_transform.c:
+	  short circuit when source and target SRID are the same.
+
+2006-12-15 Eduin Carrillo <yecarrillo at yahoo.com>
+
+	* lwgeom/: Makefile, lwgeom_kml.c, lwpostgis.sql.in:
+	  New AsKML() function
+	* doc/postgis.xml: document new AsKML function.
+
+
+2006-12-13 Markus Schaber <schabi at logix-tt.com>
+
+	* README.postgis
+          Fixed "hard upgrade" instructions.
+
+---------  PostGIS-1.2.0 release [2006-12-08] --------------------------
+
+2006-12-05 Mark Leslie <mleslie at refractions.net>
+
+	* doc/postgis.xml:
+	  Added sections for the SQL-MM and ArcSDE function ports.
+
+2006-12-05 Kevin Neufeld <kneufeld at refractions.net>
+
+	* Added sqlmm.sql.in: ESRI's ArcSDE subset of SQL/MM functions
+	* Moved common sql defines to their own header file.
+
+2006-12-01 Mark Leslie <mleslie at refractions.net>
+
+	* lwgeom/lwcompound.c, lwgeom/lwcurve.c, lwgeom/lwmsurface.c,
+	  lwgeom/lwmcurve.c, lwgeom/lwcurvepoly.c:
+	  Added serialize/deserialize support for curved geometries.
+	* lwgeom/liblwgeom.h:
+	  Added typedefs and minimum function prototypes for curved
+	  geometries.
+	* lwgeom/lwgeom_sqlmm.c:
+	  Functions to determine curve centers for use in creating bounding
+	  boxs.
+	* lwgeom/wktunparse.c, lwgeom/lwgparse.c, lwgeom/wktparse.h, 
+	  lwgeom/wktparse.lex, lwgeom/wktparse.y:
+	  Minimum parsing/printing support and struct allocations.
+  	* lwgeom/liblwgeom.c, lwgeom/lwgeom_api.c, lwgeom/lwgeom.c:
+	  Included curved types in various switches in generic functions.
+	* lwgeom/lwgeom_functions_analytic.c:
+	  Added point-in-polygon function
+	* lwgeom/lwgeom_geos_c.c:
+	  Added short-circuit for the point-in-polygon case to both Contains
+	  and Within.
+	* lwgeom/Makefile:
+	  Added new files to the makefile.
+	* regress/sql-mm-serialize.sql, regress/sql-mm-serialize_expected:
+	  Created a regression test set for the serialization/deserialization
+	  of the curved types.
+	* regress/Makefile:
+	  Added the new regression test for curve serialization.
+
+2006-11-29 Markus Schaber <schabi at logix-tt.com>
+
+	* Added java/jdbc/jtssrc/org/postgis/jts/JTSShape.java
+
+2006-11-22 Markus Schaber <schabi at logix-tt.com>
+
+	* java/ejb3/src/org/postgis/hibernate/GeometryType.java
+          Added Nullpointer Fix by Norman Barker
+
+2006-11-20 Sandro Santilli <strk at refractions.net>
+
+	* utils/postgis_restore.pl (canonicalize_typename):
+	  canonicalize 'timezone .* time stamp' to 'timezone'
+	  (fixes bug #121)
+
+2006-11-17 "Antoine Bajolet" <antoine.bajolet at tdf.fr>
+
+	* lwgeom/lwgeom_gist.c: fixed 'directives may not be used inside a
+	  macro argument' error raised by some compilers.
+
+2006-11-10 Sandro Santilli <strk at refractions.net>
+
+	* configure.in (geos detection): use $geos_prefix/lib when
+	  --ldflags is not supported by geos-config available.
+
+2006-11-10 Havard Tveite <havard.tveite at nlh.no>
+
+	* doc/postgix.xml (Hard Upgrade): add info about createdb params
+	* utils/postgis_restore.pl: fix use of createdb params
+
 2006-11-02 Sandro Santilli <strk at refractions.net>
 
 	* doc/postgis.xml: list setSRID bug fix in 'Bug fixes' section.

Modified: packages/postgis/upstream/GNUmakefile
===================================================================
--- packages/postgis/upstream/GNUmakefile	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/GNUmakefile	2007-04-13 07:15:27 UTC (rev 758)
@@ -4,13 +4,13 @@
 #
 #-----------------------------------------------------
 
-all: Makefile.config liblwgeom loaderdumper utils 
+all: Makefile.config liblwgeom loaderdumper utils templategis
 
-install: all liblwgeom-install loaderdumper-install 
+install: all liblwgeom-install loaderdumper-install templategis-install
 
-uninstall: liblwgeom-uninstall loaderdumper-uninstall docs-uninstall
+uninstall: liblwgeom-uninstall loaderdumper-uninstall docs-uninstall templategis-uninstall
 
-clean: Makefile.config liblwgeom-clean loaderdumper-clean docs-clean test-clean 
+clean: Makefile.config liblwgeom-clean loaderdumper-clean docs-clean test-clean templategis-clean
 	rm -f lwpostgis.sql lwpostgis_upgrade.sql
 
 distclean: clean
@@ -59,6 +59,18 @@
 loaderdumper-uninstall:
 	$(MAKE) -C loader uninstall
 
+templategis: Makefile.config
+	$(MAKE) -C extras/template_gis
+
+templategis-clean:
+	$(MAKE) -C extras/template_gis clean
+
+templategis-install:
+	$(MAKE) -C extras/template_gis install
+
+templategis-uninstall:
+	$(MAKE) -C extras/template_gis uninstall
+
 docs: Makefile.config
 	$(MAKE) -C doc 
 

Modified: packages/postgis/upstream/NEWS
===================================================================
--- packages/postgis/upstream/NEWS	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/NEWS	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,3 +1,24 @@
+PostGIS 1.2.1
+2007/01/11
+        - Fix point-in-polygon shortcut bug in Within()
+        - Fix PgSQL 8.2 null handling for indexes
+        - Update RPM spec files
+        - Add AsKML() function
+        - Add short-circuit for transform() in no-op case
+        - JDBC: - Fixed JTS handling for multi-dimensional geometries
+                  (thanks to Thomas Marti for hint and partial patch)
+                - Additionally, now JavaDoc is compiled and packaged
+                - Fixed classpath problems with GCJ
+                - Fixed pgjdbc 8.2 compatibility, losing support for
+                  jdk 1.3 and older.
+
+PostGIS 1.2.0
+2006/12/08
+        - Added curved geometry type support for serialization/deserialization.
+        - Added point-in-polygon shortcircuit to Contains and Within functions.
+        - JDBC: Added awt.shape implementation for JTS geometries
+        - EJB3: Fixed NullPointer bug, thanks to Norman Barker
+
 PostGIS 1.1.6
 2006/11/02
 

Modified: packages/postgis/upstream/README.postgis
===================================================================
--- packages/postgis/upstream/README.postgis	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/README.postgis	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,7 +1,7 @@
 PostGIS - Geographic Information Systems Extensions to PostgreSQL
 ~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-VERSION: 1.1.2 (2006/03/30)
+VERSION: 1.2.1 (2007/01/11)
 
 MORE INFORMATION: http://postgis.refractions.net
 
@@ -11,25 +11,27 @@
 
 Directory structure:
 
-  ./          Build scripts and install directions.
-  ./lwgeom    Library source code.
-  ./jdbc2     Extensions to the PostgreSQL JDBC drivers to support
-              the GIS objects. 
-  ./doc       PostGIS Documentation 
-  ./loader    A program to convert ESRI Shape files into SQL text
-              suitable for uploading into a PostGIS/PostgreSQL database
-              and a program for converting PostGIS spatial tables into
-              Shape files..
-  ./utils     Utility scripts for PostGIS (upgrade, profiling, ...)
-  ./extras    Various pieces that didn't belong to mainstream
-	      (package management specfiles, WFS_locks, sample wkb parser)
-  ./regress   Regression tests
+  ./            Build scripts and install directions.
+  ./lwgeom      Library source code.
+  ./java/ejb    EJB Java support
+  ./java/jdbc   Extensions to the PostgreSQL JDBC drivers to support
+                the GIS objects. 
+  ./java/pljava PostgreSQL PL/Java spatial object support
+  ./doc         PostGIS Documentation 
+  ./loader      A program to convert ESRI Shape files into SQL text
+                suitable for uploading into a PostGIS/PostgreSQL database
+                and a program for converting PostGIS spatial tables into
+                Shape files.
+  ./utils       Utility scripts for PostGIS (upgrade, profiling, ...)
+  ./extras      Various pieces that didn't belong to mainstream
+	        (package management specfiles, WFS_locks, sample wkb parser)
+  ./regress     Regression tests
 	        
 
 REQUIREMENTS
 ------------
 
-PostGIS is compatible with PostgreSQL 7.2 and above.
+PostGIS is compatible with PostgreSQL 7.4 and above.
 
 You *must* have full PostgreSQL - including server headers - installed
 for this to work. Note that server headers are not installed by
@@ -53,8 +55,8 @@
 
     http://geos.refractions.net
 
-  In order to use the GEOS support, you *may* need to specially compile 
-  your version of PostgreSQL to link the C++ runtime library.
+  OLD NOTE: In order to use the GEOS support, you *may* need to 
+  specially compile your version of PostgreSQL to link the C++ runtime library.
   To do this, invoke the PgSQL configuration script this way:
  
   LDFLAGS=-lstdc++ ./configure --your-options-go-here
@@ -113,15 +115,15 @@
 
   make install
 
-Installation paths will tipically be derived by ``pg_config'':
+Installation paths will typically be derived by ``pg_config'':
 
 	- Lib in `pg_config --pkglibdir`
 	- Binaries (loader/dumper) in `pg_config --bindir`
 	- Important support files in [prefix]/share/contrib
-	- Manpages in [prefix]/man
+	- Manual pages in [prefix]/man
 	- Documentation in in [prefix]/share/doc
 
-Where [prefix] above is exctracted by `pg_config --configure`.
+Where [prefix] above is extracted by `pg_config --configure`.
 
 You can change them using ./configure switches.
 See CONFIGURARION section.
@@ -213,7 +215,7 @@
 	# If you did make additions we assume you know how to backup them before
 	# upgrading the table. Replace it with the new like this:
 	$ psql newdb
-	newdb=> drop table spatial_ref_sys;
+	newdb=> DELETE FROM spatial_ref_sys;
 	DROP
 	newdb=> \i spatial_ref_sys.sql
 

Modified: packages/postgis/upstream/TODO
===================================================================
--- packages/postgis/upstream/TODO	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/TODO	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,7 +1,6 @@
 2005/01/13
 
 - Clean up mapserver connectivity
-- Submit to OpenGIS Consortium for testing
 - Network creation and network operations 
   (upstream, downstream, least cost path)
 - Standardized handling for topology and coverages with 

Modified: packages/postgis/upstream/Version.config
===================================================================
--- packages/postgis/upstream/Version.config	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/Version.config	2007-04-13 07:15:27 UTC (rev 758)
@@ -4,6 +4,6 @@
 # See HOWTO_RELEASE file in SVN for definitions of those three.
 
 REL_MAJOR_VERSION=1
-REL_MINOR_VERSION=1
-REL_MICRO_VERSION=6
+REL_MINOR_VERSION=2
+REL_MICRO_VERSION=1
 

Modified: packages/postgis/upstream/configure
===================================================================
--- packages/postgis/upstream/configure	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/configure	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,8 +1,9 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59.
+# Generated by GNU Autoconf 2.60.
 #
-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 # This configure script is free software; the Free Software Foundation
 # gives unlimited permission to copy, distribute and modify it.
 ## --------------------- ##
@@ -16,11 +17,35 @@
   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
-  set -o posix
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
 fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
 DUALCASE=1; export DUALCASE # for MKS sh
 
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
 # Support unset when possible.
 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   as_unset=unset
@@ -29,8 +54,43 @@
 fi
 
 
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
 # Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
 PS1='$ '
 PS2='> '
 PS4='+ '
@@ -44,18 +104,19 @@
   if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
     eval $as_var=C; export $as_var
   else
-    $as_unset $as_var
+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
   fi
 done
 
 # Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
 else
   as_expr=false
 fi
 
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
   as_basename=basename
 else
   as_basename=false
@@ -63,157 +124,386 @@
 
 
 # Name of the executable.
-as_me=`$as_basename "$0" ||
+as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)$' \| \
-	 .     : '\(.\)' 2>/dev/null ||
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
 echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
-  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\/\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
 
+# CDPATH.
+$as_unset CDPATH
 
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
 
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  echo "#! /bin/sh" >conf$$.sh
-  echo  "exit 0"   >>conf$$.sh
-  chmod +x conf$$.sh
-  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
-    PATH_SEPARATOR=';'
-  else
-    PATH_SEPARATOR=:
-  fi
-  rm -f conf$$.sh
+if test "x$CONFIG_SHELL" = x; then
+  if (eval ":") 2>/dev/null; then
+  as_have_required=yes
+else
+  as_have_required=no
 fi
 
+  if test $as_have_required = yes && 	 (eval ":
+(as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
 
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
-  # Find who we are.  Look in the path if we contain no path at all
-  # relative or not.
-  case $0 in
-    *[\\/]* ) as_myself=$0 ;;
-    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
 
-       ;;
-  esac
-  # We did not find ourselves, most probably we were run as `sh COMMAND'
-  # in which case we are not to be found in the path.
-  if test "x$as_myself" = x; then
-    as_myself=$0
-  fi
-  if test ! -f "$as_myself"; then
-    { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
-   { (exit 1); exit 1; }; }
-  fi
-  case $CONFIG_SHELL in
-  '')
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0) || { (exit 1); exit 1; }
+
+(
+  as_lineno_1=\$LINENO
+  as_lineno_2=\$LINENO
+  test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&
+  test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }
+") 2> /dev/null; then
+  :
+else
+  as_candidate_shells=
     as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+for as_dir in /usr/bin/posix$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-  for as_base in sh bash ksh sh5; do
-	 case $as_dir in
+  case $as_dir in
 	 /*)
-	   if ("$as_dir/$as_base" -c '
+	   for as_base in sh bash ksh sh5; do
+	     as_candidate_shells="$as_candidate_shells $as_dir/$as_base"
+	   done;;
+       esac
+done
+IFS=$as_save_IFS
+
+
+      for as_shell in $as_candidate_shells $SHELL; do
+	 # Try only shells that exist, to save several forks.
+	 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		{ ("$as_shell") 2> /dev/null <<\_ASEOF
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+:
+_ASEOF
+}; then
+  CONFIG_SHELL=$as_shell
+	       as_have_required=yes
+	       if { "$as_shell" 2> /dev/null <<\_ASEOF
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+  emulate sh
+  NULLCMD=:
+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+:
+(as_func_return () {
+  (exit $1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = "$1" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test $exitcode = 0) || { (exit 1); exit 1; }
+
+(
   as_lineno_1=$LINENO
   as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
   test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
-	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
-	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
-	     CONFIG_SHELL=$as_dir/$as_base
-	     export CONFIG_SHELL
-	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
-	   fi;;
-	 esac
-       done
-done
-;;
-  esac
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }
 
+_ASEOF
+}; then
+  break
+fi
+
+fi
+
+      done
+
+      if test "x$CONFIG_SHELL" != x; then
+  for as_var in BASH_ENV ENV
+        do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+        done
+        export CONFIG_SHELL
+        exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+
+    if test $as_have_required = no; then
+  echo This script requires a shell more modern than all the
+      echo shells that I found on your system.  Please install a
+      echo modern shell, or manually run the script under such a
+      echo shell if you do have one.
+      { (exit 1); exit 1; }
+fi
+
+
+fi
+
+fi
+
+
+
+(eval "as_func_return () {
+  (exit \$1)
+}
+as_func_success () {
+  as_func_return 0
+}
+as_func_failure () {
+  as_func_return 1
+}
+as_func_ret_success () {
+  return 0
+}
+as_func_ret_failure () {
+  return 1
+}
+
+exitcode=0
+if as_func_success; then
+  :
+else
+  exitcode=1
+  echo as_func_success failed.
+fi
+
+if as_func_failure; then
+  exitcode=1
+  echo as_func_failure succeeded.
+fi
+
+if as_func_ret_success; then
+  :
+else
+  exitcode=1
+  echo as_func_ret_success failed.
+fi
+
+if as_func_ret_failure; then
+  exitcode=1
+  echo as_func_ret_failure succeeded.
+fi
+
+if ( set x; as_func_ret_success y && test x = \"\$1\" ); then
+  :
+else
+  exitcode=1
+  echo positional parameters were not saved.
+fi
+
+test \$exitcode = 0") || {
+  echo No shell found that supports shell functions.
+  echo Please tell autoconf at gnu.org about your system,
+  echo including any error possibly output before this
+  echo message
+}
+
+
+
+  as_lineno_1=$LINENO
+  as_lineno_2=$LINENO
+  test "x$as_lineno_1" != "x$as_lineno_2" &&
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
+
   # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
   # uniformly replaced by the line number.  The first 'sed' inserts a
-  # line-number line before each line; the second 'sed' does the real
-  # work.  The second script uses 'N' to pair each line-number line
-  # with the numbered line, and appends trailing '-' during
-  # substitution so that $LINENO is not a special case at line end.
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
   # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
-  sed '=' <$as_myself |
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
     sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
       N
-      s,$,-,
-      : loop
-      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
       t loop
-      s,-$,,
-      s,^['$as_cr_digits']*\n,,
+      s/-\n.*//
     ' >$as_me.lineno &&
-  chmod +x $as_me.lineno ||
+  chmod +x "$as_me.lineno" ||
     { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
    { (exit 1); exit 1; }; }
 
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
-  # original and so on.  Autoconf is especially sensible to this).
-  . ./$as_me.lineno
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
   # Exit status is that of the last command.
   exit
 }
 
 
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
-  *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T='	' ;;
-  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
-  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
 esac
 
-if expr a : '\(a\)' >/dev/null 2>&1; then
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
 else
   as_expr=false
 fi
 
 rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir
+fi
 echo >conf$$.file
 if ln -s conf$$.file conf$$ 2>/dev/null; then
-  # We could just check for DJGPP; but this test a) works b) is more generic
-  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
-  if test -f conf$$.exe; then
-    # Don't use ln at all; we don't have any links
+  as_ln_s='ln -s'
+  # ... but there are two gotchas:
+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+  # In both cases, we have to default to `cp -p'.
+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
     as_ln_s='cp -p'
-  else
-    as_ln_s='ln -s'
-  fi
 elif ln conf$$.file conf$$ 2>/dev/null; then
   as_ln_s=ln
 else
   as_ln_s='cp -p'
 fi
-rm -f conf$$ conf$$.exe conf$$.file
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
 
 if mkdir -p . 2>/dev/null; then
   as_mkdir_p=:
@@ -222,7 +512,19 @@
   as_mkdir_p=false
 fi
 
-as_executable_p="test -f"
+# Find out whether ``test -x'' works.  Don't use a zero-byte file, as
+# systems may use methods other than mode bits to determine executability.
+cat >conf$$.file <<_ASEOF
+#! /bin/sh
+exit 0
+_ASEOF
+chmod +x conf$$.file
+if test -x conf$$.file >/dev/null 2>&1; then
+  as_executable_p="test -x"
+else
+  as_executable_p=:
+fi
+rm -f conf$$.file
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -231,39 +533,27 @@
 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
 
 
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" 	$as_nl"
 
-# CDPATH.
-$as_unset CDPATH
+exec 7<&0 </dev/null 6>&1
 
-
 # Name of the host.
 # hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
 # so uname gets run too.
 ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
 
-exec 6>&1
-
 #
 # Initializations.
 #
 ac_default_prefix=/usr/local
+ac_clean_files=
 ac_config_libobj_dir=.
+LIBOBJS=
 cross_compiling=no
 subdirs=
 MFLAGS=
 MAKEFLAGS=
 SHELL=${CONFIG_SHELL-/bin/sh}
 
-# Maximum number of lines to put in a shell here document.
-# This variable seems obsolete.  It should probably be removed, and
-# only ac_max_sed_lines should be used.
-: ${ac_max_here_lines=38}
-
 # Identity of this package.
 PACKAGE_NAME=
 PACKAGE_TARNAME=
@@ -300,18 +590,134 @@
 #endif
 #if HAVE_INTTYPES_H
 # include <inttypes.h>
-#else
-# if HAVE_STDINT_H
-#  include <stdint.h>
-# endif
 #endif
+#if HAVE_STDINT_H
+# include <stdint.h>
+#endif
 #if HAVE_UNISTD_H
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX LN_S USE_ICONV ICONV_LDFLAGS CPP EGREP build build_cpu build_vendor build_os host host_cpu host_vendor host_os PGCONFIG PGFEINCLUDES PGBEINCLUDES PGFELIBS PGBELIBS PGBIN PGTEMPLATE LPATH PWDREGRESS USE_GEOS GEOS_DIR GEOS_LDFLAGS USE_GEOS_CAPI GEOSCONFIG USE_PROJ PROJ_DIR PROJ_LIBDIR PROJ USE_JTS JTS_INCLUDES JTS_LIBDIR JTSCONFIG FLEX DLLWRAP DLLTOOL YACC INSTALL PERL docdir XSLBASE XSLTPROC PDFXMLTEX DB2PDF JW DOC_RULE PORTNAME DLSUFFIX DLFLAGS EXE HOST_OS ELF_SYS LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL
+PATH_SEPARATOR
+PACKAGE_NAME
+PACKAGE_TARNAME
+PACKAGE_VERSION
+PACKAGE_STRING
+PACKAGE_BUGREPORT
+exec_prefix
+prefix
+program_transform_name
+bindir
+sbindir
+libexecdir
+datarootdir
+datadir
+sysconfdir
+sharedstatedir
+localstatedir
+includedir
+oldincludedir
+docdir
+infodir
+htmldir
+dvidir
+pdfdir
+psdir
+libdir
+localedir
+mandir
+DEFS
+ECHO_C
+ECHO_N
+ECHO_T
+LIBS
+build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+CPPFLAGS
+ac_ct_CC
+EXEEXT
+OBJEXT
+CXX
+CXXFLAGS
+ac_ct_CXX
+LN_S
+USE_ICONV
+ICONV_LDFLAGS
+CPP
+GREP
+EGREP
+build
+build_cpu
+build_vendor
+build_os
+host
+host_cpu
+host_vendor
+host_os
+PGCONFIG
+PGFEINCLUDES
+PGBEINCLUDES
+PGFELIBS
+PGBELIBS
+PGBIN
+PGTEMPLATE
+LPATH
+PWDREGRESS
+USE_GEOS
+GEOS_DIR
+GEOS_LDFLAGS
+USE_GEOS_CAPI
+GEOSCONFIG
+USE_PROJ
+PROJ_DIR
+PROJ_LIBDIR
+PROJ
+USE_JTS
+JTS_INCLUDES
+JTS_LIBDIR
+JTSCONFIG
+FLEX
+DLLWRAP
+DLLTOOL
+YACC
+YFLAGS
+INSTALL
+PERL
+XSLBASE
+XSLTPROC
+PDFXMLTEX
+DB2PDF
+JW
+DOC_RULE
+PORTNAME
+DLSUFFIX
+DLFLAGS
+EXE
+HOST_OS
+ELF_SYS
+LIBOBJS
+LTLIBOBJS'
 ac_subst_files=''
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+CPPFLAGS
+CXX
+CXXFLAGS
+CCC
+CPP
+YACC
+YFLAGS'
 
+
 # Initialize some variables set by options.
 ac_init_help=
 ac_init_version=false
@@ -337,34 +743,48 @@
 # and all the variables that are supposed to be based on exec_prefix
 # by default will actually change.
 # Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
 bindir='${exec_prefix}/bin'
 sbindir='${exec_prefix}/sbin'
 libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
+docdir='${datarootdir}/doc/${PACKAGE}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
 
 ac_prev=
+ac_dashdash=
 for ac_option
 do
   # If the previous option needs an argument, assign it.
   if test -n "$ac_prev"; then
-    eval "$ac_prev=\$ac_option"
+    eval $ac_prev=\$ac_option
     ac_prev=
     continue
   fi
 
-  ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+  case $ac_option in
+  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)	ac_optarg=yes ;;
+  esac
 
   # Accept the important Cygnus configure options, so we can diagnose typos.
 
-  case $ac_option in
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
 
   -bindir | --bindir | --bindi | --bind | --bin | --bi)
     ac_prev=bindir ;;
@@ -386,12 +806,18 @@
   --config-cache | -C)
     cache_file=config.cache ;;
 
-  -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+  -datadir | --datadir | --datadi | --datad)
     ac_prev=datadir ;;
-  -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
-  | --da=*)
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
     datadir=$ac_optarg ;;
 
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
   -disable-* | --disable-*)
     ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
     # Reject names that are not valid shell variable names.
@@ -399,8 +825,18 @@
       { echo "$as_me: error: invalid feature name: $ac_feature" >&2
    { (exit 1); exit 1; }; }
     ac_feature=`echo $ac_feature | sed 's/-/_/g'`
-    eval "enable_$ac_feature=no" ;;
+    eval enable_$ac_feature=no ;;
 
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
   -enable-* | --enable-*)
     ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
     # Reject names that are not valid shell variable names.
@@ -408,11 +844,7 @@
       { echo "$as_me: error: invalid feature name: $ac_feature" >&2
    { (exit 1); exit 1; }; }
     ac_feature=`echo $ac_feature | sed 's/-/_/g'`
-    case $ac_option in
-      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
-      *) ac_optarg=yes ;;
-    esac
-    eval "enable_$ac_feature='$ac_optarg'" ;;
+    eval enable_$ac_feature=\$ac_optarg ;;
 
   -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
   | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
@@ -439,6 +871,12 @@
   -host=* | --host=* | --hos=* | --ho=*)
     host_alias=$ac_optarg ;;
 
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
   -includedir | --includedir | --includedi | --included | --include \
   | --includ | --inclu | --incl | --inc)
     ac_prev=includedir ;;
@@ -463,13 +901,16 @@
   | --libexe=* | --libex=* | --libe=*)
     libexecdir=$ac_optarg ;;
 
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
   -localstatedir | --localstatedir | --localstatedi | --localstated \
-  | --localstate | --localstat | --localsta | --localst \
-  | --locals | --local | --loca | --loc | --lo)
+  | --localstate | --localstat | --localsta | --localst | --locals)
     ac_prev=localstatedir ;;
   -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
-  | --localstate=* | --localstat=* | --localsta=* | --localst=* \
-  | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
     localstatedir=$ac_optarg ;;
 
   -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
@@ -534,6 +975,16 @@
   | --progr-tra=* | --program-tr=* | --program-t=*)
     program_transform_name=$ac_optarg ;;
 
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
@@ -590,11 +1041,7 @@
       { echo "$as_me: error: invalid package name: $ac_package" >&2
    { (exit 1); exit 1; }; }
     ac_package=`echo $ac_package| sed 's/-/_/g'`
-    case $ac_option in
-      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
-      *) ac_optarg=yes ;;
-    esac
-    eval "with_$ac_package='$ac_optarg'" ;;
+    eval with_$ac_package=\$ac_optarg ;;
 
   -without-* | --without-*)
     ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
@@ -603,7 +1050,7 @@
       { echo "$as_me: error: invalid package name: $ac_package" >&2
    { (exit 1); exit 1; }; }
     ac_package=`echo $ac_package | sed 's/-/_/g'`
-    eval "with_$ac_package=no" ;;
+    eval with_$ac_package=no ;;
 
   --x)
     # Obsolete; use --with-x.
@@ -634,8 +1081,7 @@
     expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
       { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
    { (exit 1); exit 1; }; }
-    ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
-    eval "$ac_envvar='$ac_optarg'"
+    eval $ac_envvar=\$ac_optarg
     export $ac_envvar ;;
 
   *)
@@ -655,29 +1101,21 @@
    { (exit 1); exit 1; }; }
 fi
 
-# Be sure to have absolute paths.
-for ac_var in exec_prefix prefix
+# Be sure to have absolute directory names.
+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
+		datadir sysconfdir sharedstatedir localstatedir includedir \
+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+		libdir localedir mandir
 do
-  eval ac_val=$`echo $ac_var`
+  eval ac_val=\$$ac_var
   case $ac_val in
-    [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
-    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
-   { (exit 1); exit 1; }; };;
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
   esac
+  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+   { (exit 1); exit 1; }; }
 done
 
-# Be sure to have absolute paths.
-for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
-	      localstatedir libdir includedir oldincludedir infodir mandir
-do
-  eval ac_val=$`echo $ac_var`
-  case $ac_val in
-    [\\/$]* | ?:[\\/]* ) ;;
-    *)  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
-   { (exit 1); exit 1; }; };;
-  esac
-done
-
 # There might be people who depend on the old broken behavior: `$host'
 # used to hold the argument of --host etc.
 # FIXME: To remove some day.
@@ -702,82 +1140,76 @@
 test "$silent" = yes && exec 6>/dev/null
 
 
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  { echo "$as_me: error: Working directory cannot be determined" >&2
+   { (exit 1); exit 1; }; }
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  { echo "$as_me: error: pwd does not report name of working directory" >&2
+   { (exit 1); exit 1; }; }
+
+
 # Find the source files, if location was not specified.
 if test -z "$srcdir"; then
   ac_srcdir_defaulted=yes
-  # Try the directory containing this script, then its parent.
-  ac_confdir=`(dirname "$0") 2>/dev/null ||
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$0" ||
 $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$0" : 'X\(//\)[^/]' \| \
 	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
 echo X"$0" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
   srcdir=$ac_confdir
-  if test ! -r $srcdir/$ac_unique_file; then
+  if test ! -r "$srcdir/$ac_unique_file"; then
     srcdir=..
   fi
 else
   ac_srcdir_defaulted=no
 fi
-if test ! -r $srcdir/$ac_unique_file; then
-  if test "$ac_srcdir_defaulted" = yes; then
-    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
    { (exit 1); exit 1; }; }
-  else
-    { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+	cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2
    { (exit 1); exit 1; }; }
-  fi
+	pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
 fi
-(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
-  { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
-   { (exit 1); exit 1; }; }
-srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
-ac_env_build_alias_set=${build_alias+set}
-ac_env_build_alias_value=$build_alias
-ac_cv_env_build_alias_set=${build_alias+set}
-ac_cv_env_build_alias_value=$build_alias
-ac_env_host_alias_set=${host_alias+set}
-ac_env_host_alias_value=$host_alias
-ac_cv_env_host_alias_set=${host_alias+set}
-ac_cv_env_host_alias_value=$host_alias
-ac_env_target_alias_set=${target_alias+set}
-ac_env_target_alias_value=$target_alias
-ac_cv_env_target_alias_set=${target_alias+set}
-ac_cv_env_target_alias_value=$target_alias
-ac_env_CC_set=${CC+set}
-ac_env_CC_value=$CC
-ac_cv_env_CC_set=${CC+set}
-ac_cv_env_CC_value=$CC
-ac_env_CFLAGS_set=${CFLAGS+set}
-ac_env_CFLAGS_value=$CFLAGS
-ac_cv_env_CFLAGS_set=${CFLAGS+set}
-ac_cv_env_CFLAGS_value=$CFLAGS
-ac_env_LDFLAGS_set=${LDFLAGS+set}
-ac_env_LDFLAGS_value=$LDFLAGS
-ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
-ac_cv_env_LDFLAGS_value=$LDFLAGS
-ac_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_env_CPPFLAGS_value=$CPPFLAGS
-ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_cv_env_CPPFLAGS_value=$CPPFLAGS
-ac_env_CXX_set=${CXX+set}
-ac_env_CXX_value=$CXX
-ac_cv_env_CXX_set=${CXX+set}
-ac_cv_env_CXX_value=$CXX
-ac_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_env_CXXFLAGS_value=$CXXFLAGS
-ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_cv_env_CXXFLAGS_value=$CXXFLAGS
-ac_env_CPP_set=${CPP+set}
-ac_env_CPP_value=$CPP
-ac_cv_env_CPP_set=${CPP+set}
-ac_cv_env_CPP_value=$CPP
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
 
 #
 # Report the --help message.
@@ -806,9 +1238,6 @@
   -n, --no-create         do not create output files
       --srcdir=DIR        find the sources in DIR [configure dir or \`..']
 
-_ACEOF
-
-  cat <<_ACEOF
 Installation directories:
   --prefix=PREFIX         install architecture-independent files in PREFIX
 			  [$ac_default_prefix]
@@ -826,15 +1255,22 @@
   --bindir=DIR           user executables [EPREFIX/bin]
   --sbindir=DIR          system admin executables [EPREFIX/sbin]
   --libexecdir=DIR       program executables [EPREFIX/libexec]
-  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
   --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR    modifiable single-machine data [PREFIX/var]
   --libdir=DIR           object code libraries [EPREFIX/lib]
   --includedir=DIR       C header files [PREFIX/include]
   --oldincludedir=DIR    C header files for non-gcc [/usr/include]
-  --infodir=DIR          info documentation [PREFIX/info]
-  --mandir=DIR           man documentation [PREFIX/man]
+  --datarootdir=DIR      read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR          read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR          info documentation [DATAROOTDIR/info]
+  --localedir=DIR        locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR           man documentation [DATAROOTDIR/man]
+  --docdir=DIR           documentation root [DATAROOTDIR/doc/PACKAGE]
+  --htmldir=DIR          html documentation [DOCDIR]
+  --dvidir=DIR           dvi documentation [DOCDIR]
+  --pdfdir=DIR           pdf documentation [DOCDIR]
+  --psdir=DIR            ps documentation [DOCDIR]
 _ACEOF
 
   cat <<\_ACEOF
@@ -870,128 +1306,101 @@
   CFLAGS      C compiler flags
   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
               nonstandard directory <lib dir>
-  CPPFLAGS    C/C++ preprocessor flags, e.g. -I<include dir> if you have
-              headers in a nonstandard directory <include dir>
+  CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
   CPP         C preprocessor
+  YACC        The `Yet Another C Compiler' implementation to use. Defaults to
+              the first program found out of: `bison -y', `byacc', `yacc'.
+  YFLAGS      The list of arguments that will be passed by default to $YACC.
+              This script will default YFLAGS to the empty string to avoid a
+              default value of `-d' given by some make applications.
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
 _ACEOF
+ac_status=$?
 fi
 
 if test "$ac_init_help" = "recursive"; then
   # If there are subdirs, report their specific --help.
-  ac_popdir=`pwd`
   for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
-    test -d $ac_dir || continue
+    test -d "$ac_dir" || continue
     ac_builddir=.
 
-if test "$ac_dir" != .; then
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
   ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
-  # A "../" for each directory in $ac_dir_suffix.
-  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
-  ac_dir_suffix= ac_top_builddir=
-fi
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
 
 case $srcdir in
-  .)  # No --srcdir option.  We are building in place.
+  .)  # We are building in place.
     ac_srcdir=.
-    if test -z "$ac_top_builddir"; then
-       ac_top_srcdir=.
-    else
-       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
-    fi ;;
-  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
     ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir ;;
-  *) # Relative path.
-    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
 esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
 
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
-  case "$ac_dir" in
-  .) ac_abs_builddir=`pwd`;;
-  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
-  *) ac_abs_builddir=`pwd`/"$ac_dir";;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
-  case ${ac_top_builddir}. in
-  .) ac_abs_top_builddir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
-  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
-  case $ac_srcdir in
-  .) ac_abs_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
-  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
-  case $ac_top_srcdir in
-  .) ac_abs_top_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
-  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
-  esac;;
-esac
-
-    cd $ac_dir
-    # Check for guested configure; otherwise get Cygnus style configure.
-    if test -f $ac_srcdir/configure.gnu; then
-      echo
-      $SHELL $ac_srcdir/configure.gnu  --help=recursive
-    elif test -f $ac_srcdir/configure; then
-      echo
-      $SHELL $ac_srcdir/configure  --help=recursive
-    elif test -f $ac_srcdir/configure.ac ||
-	   test -f $ac_srcdir/configure.in; then
-      echo
-      $ac_configure --help
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
     else
       echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
-    fi
-    cd $ac_popdir
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
   done
 fi
 
-test -n "$ac_init_help" && exit 0
+test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
+configure
+generated by GNU Autoconf 2.60
 
-Copyright (C) 2003 Free Software Foundation, Inc.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
-  exit 0
+  exit
 fi
-exec 5>config.log
-cat >&5 <<_ACEOF
+cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
 It was created by $as_me, which was
-generated by GNU Autoconf 2.59.  Invocation command line was
+generated by GNU Autoconf 2.60.  Invocation command line was
 
   $ $0 $@
 
 _ACEOF
+exec 5>>config.log
 {
 cat <<_ASUNAME
 ## --------- ##
@@ -1010,7 +1419,7 @@
 /bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
 /usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-hostinfo               = `(hostinfo) 2>/dev/null               || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
 /bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
 /bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
@@ -1024,6 +1433,7 @@
   test -z "$as_dir" && as_dir=.
   echo "PATH: $as_dir"
 done
+IFS=$as_save_IFS
 
 } >&5
 
@@ -1045,7 +1455,6 @@
 ac_configure_args=
 ac_configure_args0=
 ac_configure_args1=
-ac_sep=
 ac_must_keep_next=false
 for ac_pass in 1 2
 do
@@ -1056,7 +1465,7 @@
     -q | -quiet | --quiet | --quie | --qui | --qu | --q \
     | -silent | --silent | --silen | --sile | --sil)
       continue ;;
-    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+    *\'*)
       ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
     esac
     case $ac_pass in
@@ -1078,9 +1487,7 @@
 	  -* ) ac_must_keep_next=true ;;
 	esac
       fi
-      ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
-      # Get rid of the leading space.
-      ac_sep=" "
+      ac_configure_args="$ac_configure_args '$ac_arg'"
       ;;
     esac
   done
@@ -1091,8 +1498,8 @@
 # When interrupted or exit'd, cleanup temporary files, and complete
 # config.log.  We remove comments because anyway the quotes in there
 # would cause problems or look ugly.
-# WARNING: Be sure not to use single quotes in there, as some shells,
-# such as our DU 5.0 friend, will then `close' the trap.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
 trap 'exit_status=$?
   # Save into config.log some information that might help in debugging.
   {
@@ -1105,20 +1512,34 @@
 _ASBOX
     echo
     # The following way of writing the cache mishandles newlines in values,
-{
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
   (set) 2>&1 |
-    case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
-    *ac_space=\ *)
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
       sed -n \
-	"s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
-      ;;
+	"s/'\''/'\''\\\\'\'''\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
     *)
-      sed -n \
-	"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
       ;;
-    esac;
-}
+    esac |
+    sort
+)
     echo
 
     cat <<\_ASBOX
@@ -1129,22 +1550,28 @@
     echo
     for ac_var in $ac_subst_vars
     do
-      eval ac_val=$`echo $ac_var`
-      echo "$ac_var='"'"'$ac_val'"'"'"
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      echo "$ac_var='\''$ac_val'\''"
     done | sort
     echo
 
     if test -n "$ac_subst_files"; then
       cat <<\_ASBOX
-## ------------- ##
-## Output files. ##
-## ------------- ##
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
 _ASBOX
       echo
       for ac_var in $ac_subst_files
       do
-	eval ac_val=$`echo $ac_var`
-	echo "$ac_var='"'"'$ac_val'"'"'"
+	eval ac_val=\$$ac_var
+	case $ac_val in
+	*\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	esac
+	echo "$ac_var='\''$ac_val'\''"
       done | sort
       echo
     fi
@@ -1156,26 +1583,24 @@
 ## ----------- ##
 _ASBOX
       echo
-      sed "/^$/d" confdefs.h | sort
+      cat confdefs.h
       echo
     fi
     test "$ac_signal" != 0 &&
       echo "$as_me: caught signal $ac_signal"
     echo "$as_me: exit $exit_status"
   } >&5
-  rm -f core *.core &&
-  rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
     exit $exit_status
-     ' 0
+' 0
 for ac_signal in 1 2 13 15; do
   trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
 done
 ac_signal=0
 
 # confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo >confdefs.h
+rm -f -r conftest* confdefs.h
 
 # Predefined preprocessor variables.
 
@@ -1206,14 +1631,17 @@
 
 # Let the site file select an alternate cache file if it wants to.
 # Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
-  if test "x$prefix" != xNONE; then
-    CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
-  else
-    CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
-  fi
+if test -n "$CONFIG_SITE"; then
+  set x "$CONFIG_SITE"
+elif test "x$prefix" != xNONE; then
+  set x "$prefix/share/config.site" "$prefix/etc/config.site"
+else
+  set x "$ac_default_prefix/share/config.site" \
+	"$ac_default_prefix/etc/config.site"
 fi
-for ac_site_file in $CONFIG_SITE; do
+shift
+for ac_site_file
+do
   if test -r "$ac_site_file"; then
     { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
 echo "$as_me: loading site script $ac_site_file" >&6;}
@@ -1229,8 +1657,8 @@
     { echo "$as_me:$LINENO: loading cache $cache_file" >&5
 echo "$as_me: loading cache $cache_file" >&6;}
     case $cache_file in
-      [\\/]* | ?:[\\/]* ) . $cache_file;;
-      *)                      . ./$cache_file;;
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
     esac
   fi
 else
@@ -1242,12 +1670,11 @@
 # Check that the precious variables saved in the cache have kept the same
 # value.
 ac_cache_corrupted=false
-for ac_var in `(set) 2>&1 |
-	       sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+for ac_var in $ac_precious_vars; do
   eval ac_old_set=\$ac_cv_env_${ac_var}_set
   eval ac_new_set=\$ac_env_${ac_var}_set
-  eval ac_old_val="\$ac_cv_env_${ac_var}_value"
-  eval ac_new_val="\$ac_env_${ac_var}_value"
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
   case $ac_old_set,$ac_new_set in
     set,)
       { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
@@ -1272,8 +1699,7 @@
   # Pass precious variables to config.status.
   if test "$ac_new_set" = set; then
     case $ac_new_val in
-    *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
-      ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
     *) ac_arg=$ac_var=$ac_new_val ;;
     esac
     case " $ac_configure_args " in
@@ -1290,11 +1716,6 @@
    { (exit 1); exit 1; }; }
 fi
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
@@ -1311,13 +1732,17 @@
 
 
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+ac_config_headers="$ac_config_headers config.h"
 
-          ac_config_headers="$ac_config_headers config.h"
 
 
-
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -1326,8 +1751,8 @@
 if test -n "$ac_tool_prefix"; then
   # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -1340,32 +1765,34 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 fi
 if test -z "$ac_cv_prog_CC"; then
   ac_ct_CC=$CC
   # Extract the first word of "gcc", so it can be a program name with args.
 set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -1378,36 +1805,51 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="gcc"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
+  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
-  CC=$ac_ct_CC
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf at gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
 else
   CC="$ac_cv_prog_CC"
 fi
 
 if test -z "$CC"; then
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
 set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -1420,74 +1862,34 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="cc"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
+
   fi
-done
-done
-
 fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-  CC=$ac_ct_CC
-else
-  CC="$ac_cv_prog_CC"
-fi
-
-fi
 if test -z "$CC"; then
   # Extract the first word of "cc", so it can be a program name with args.
 set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -1501,7 +1903,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
@@ -1512,6 +1914,7 @@
   fi
 done
 done
+IFS=$as_save_IFS
 
 if test $ac_prog_rejected = yes; then
   # We found a bogon in the path, so make sure we never use it.
@@ -1529,22 +1932,23 @@
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 fi
 if test -z "$CC"; then
   if test -n "$ac_tool_prefix"; then
-  for ac_prog in cl
+  for ac_prog in cl.exe
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_prog_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -1557,36 +1961,38 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 CC=$ac_cv_prog_CC
 if test -n "$CC"; then
-  echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
+  { echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
     test -n "$CC" && break
   done
 fi
 if test -z "$CC"; then
   ac_ct_CC=$CC
-  for ac_prog in cl
+  for ac_prog in cl.exe
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -1599,29 +2005,45 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CC=$ac_cv_prog_ac_ct_CC
 if test -n "$ac_ct_CC"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
+  { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
   test -n "$ac_ct_CC" && break
 done
 
-  CC=$ac_ct_CC
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf at gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
 fi
 
 fi
@@ -1634,21 +2056,35 @@
    { (exit 1); exit 1; }; }
 
 # Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
-     "checking for C compiler version" >&5
+echo "$as_me:$LINENO: checking for C compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
-  (eval $ac_compiler --version </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
-  (eval $ac_compiler -v </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
-  (eval $ac_compiler -V </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
@@ -1673,46 +2109,70 @@
 # Try to create an executable without -o first, disregard a.out.
 # It will help us diagnose broken compilers, and finding out an intuition
 # of exeext.
-echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; }
 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
-  (eval $ac_link_default) 2>&5
+#
+# List of possible output files, starting from the most likely.
+# The algorithm is not robust to junk in `.', hence go to wildcards (a.*)
+# only as a last resort.  b.out is created by i960 compilers.
+ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out'
+#
+# The IRIX 6 linker writes into existing files which may not be
+# executable, retaining their permissions.  Remove them first so a
+# subsequent execution test works.
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { (ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link_default") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  # Find the output, starting from the most likely.  This scheme is
-# not robust to junk in `.', hence go to wildcards (a.*) only as a last
-# resort.
-
-# Be careful to initialize this variable, since it used to be cached.
-# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
-ac_cv_exeext=
-# b.out is created by i960 compilers.
-for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files
 do
   test -f "$ac_file" || continue
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj )
 	;;
-    conftest.$ac_ext )
-	# This is the source file.
-	;;
     [ab].out )
 	# We found the default executable, but exeext='' is most
 	# certainly right.
 	break;;
     *.* )
-	ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	# FIXME: I believe we export ac_cv_exeext for Libtool,
-	# but it would be cool to find out if it's true.  Does anybody
-	# maintain Libtool? --akim.
-	export ac_cv_exeext
+        if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an `-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
 	break;;
     * )
 	break;;
   esac
 done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
@@ -1725,19 +2185,23 @@
 fi
 
 ac_exeext=$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6
+{ echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6; }
 
-# Check the compiler produces executables we can run.  If not, either
+# Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether the C compiler works" >&5
-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; }
 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0
 # If not cross compiling, check that we can run a simple program.
 if test "$cross_compiling" != yes; then
   if { ac_try='./$ac_file'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -1756,22 +2220,27 @@
     fi
   fi
 fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+{ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
 
 rm -f a.out a.exe conftest$ac_cv_exeext b.out
 ac_clean_files=$ac_clean_files_save
-# Check the compiler produces executables we can run.  If not, either
+# Check that the compiler produces executables we can run.  If not, either
 # the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6
+{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6; }
 
-echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+{ echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; }
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
@@ -1782,9 +2251,8 @@
 for ac_file in conftest.exe conftest conftest.*; do
   test -f "$ac_file" || continue
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;;
     *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	  export ac_cv_exeext
 	  break;;
     * ) break;;
   esac
@@ -1798,14 +2266,14 @@
 fi
 
 rm -f conftest$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6; }
 
 rm -f conftest.$ac_ext
 EXEEXT=$ac_cv_exeext
 ac_exeext=$EXEEXT
-echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; }
 if test "${ac_cv_objext+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -1825,14 +2293,20 @@
 }
 _ACEOF
 rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>&5
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; then
-  for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
   case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;;
     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
        break;;
   esac
@@ -1850,12 +2324,12 @@
 
 rm -f conftest.$ac_cv_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6; }
 OBJEXT=$ac_cv_objext
 ac_objext=$OBJEXT
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; }
 if test "${ac_cv_c_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -1878,24 +2352,36 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -1904,24 +2390,28 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_compiler_gnu=no
+	ac_compiler_gnu=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_cv_c_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; }
 GCC=`test $ac_compiler_gnu = yes && echo yes`
 ac_test_CFLAGS=${CFLAGS+set}
 ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; }
 if test "${ac_cv_prog_cc_g+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -1937,24 +2427,36 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -1963,12 +2465,131 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_prog_cc_g=no
+	CFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  :
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_c_werror_flag=$ac_save_c_werror_flag
+	 CFLAGS="-g"
+	 cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_prog_cc_g=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; }
 if test "$ac_test_CFLAGS" = set; then
   CFLAGS=$ac_save_CFLAGS
 elif test $ac_cv_prog_cc_g = yes; then
@@ -1984,12 +2605,12 @@
     CFLAGS=
   fi
 fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
+{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5
+echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_prog_cc_stdc=no
+  ac_cv_prog_cc_c89=no
 ac_save_CC=$CC
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -2023,12 +2644,17 @@
 /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
    function prototypes and stuff, but not '\xHH' hex character constants.
    These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std1 is added to get
+   as 'x'.  The following induces an error, until -std is added to get
    proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
    array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std1.  */
+   that's true only with -std.  */
 int osf4_cc_array ['\x00' == 0 ? 1 : -1];
 
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
 int test (int i, double x);
 struct s1 {int (*f) (int a);};
 struct s2 {int (*f) (double a);};
@@ -2043,223 +2669,96 @@
   return 0;
 }
 _ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX			-qlanglvl=ansi
-# Ultrix and OSF/1	-std1
-# HP-UX 10.20 and later	-Ae
-# HP-UX older versions	-Aa -D_HPUX_SOURCE
-# SVR4			-Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
 do
   CC="$ac_save_CC $ac_arg"
   rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  ac_cv_prog_cc_stdc=$ac_arg
-break
+  ac_cv_prog_cc_c89=$ac_arg
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+
 fi
-rm -f conftest.err conftest.$ac_objext
+
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
 done
-rm -f conftest.$ac_ext conftest.$ac_objext
+rm -f conftest.$ac_ext
 CC=$ac_save_CC
 
 fi
-
-case "x$ac_cv_prog_cc_stdc" in
-  x|xno)
-    echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6; } ;;
+  xno)
+    { echo "$as_me:$LINENO: result: unsupported" >&5
+echo "${ECHO_T}unsupported" >&6; } ;;
   *)
-    echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
-    CC="$CC $ac_cv_prog_cc_stdc" ;;
+    CC="$CC $ac_cv_prog_cc_c89"
+    { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;;
 esac
 
-# Some people use a C++ compiler to compile C.  Since we use `exit',
-# in C++ we need to declare it.  In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
-  choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  for ac_declaration in \
-   '' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  :
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-$ac_declaration
-int
-main ()
-{
-exit (42);
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; } &&
-	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
-  ac_status=$?
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); }; }; then
-  break
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
-fi
-
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-ac_ext=cc
+ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
 ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
   do
     # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_prog_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -2272,36 +2771,38 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 CXX=$ac_cv_prog_CXX
 if test -n "$CXX"; then
-  echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6
+  { echo "$as_me:$LINENO: result: $CXX" >&5
+echo "${ECHO_T}$CXX" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
     test -n "$CXX" && break
   done
 fi
 if test -z "$CXX"; then
   ac_ct_CXX=$CXX
-  for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -2314,55 +2815,85 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_ac_ct_CXX="$ac_prog"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
 if test -n "$ac_ct_CXX"; then
-  echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6
+  { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
+echo "${ECHO_T}$ac_ct_CXX" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
   test -n "$ac_ct_CXX" && break
 done
-test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
 
-  CXX=$ac_ct_CXX
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf at gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf at gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
 fi
 
-
+  fi
+fi
 # Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
-     "checking for C++ compiler version" >&5
+echo "$as_me:$LINENO: checking for C++ compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
-  (eval $ac_compiler --version </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler --version >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler --version >&5") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
-  (eval $ac_compiler -v </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler -v >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -v >&5") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
-  (eval $ac_compiler -V </dev/null >&5) 2>&5
+{ (ac_try="$ac_compiler -V >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compiler -V >&5") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }
 
-echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; }
 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -2385,24 +2916,36 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -2411,24 +2954,28 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_compiler_gnu=no
+	ac_compiler_gnu=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; }
 GXX=`test $ac_compiler_gnu = yes && echo yes`
 ac_test_CXXFLAGS=${CXXFLAGS+set}
 ac_save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
+echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; }
 if test "${ac_cv_prog_cxx_g+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -2444,24 +2991,36 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -2470,70 +3029,53 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_prog_cxx_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-for ac_declaration in \
-   '' \
-   'extern "C" void std::exit (int) throw (); using std::exit;' \
-   'extern "C" void std::exit (int); using std::exit;' \
-   'extern "C" void exit (int) throw ();' \
-   'extern "C" void exit (int);' \
-   'void exit (int);'
-do
-  cat >conftest.$ac_ext <<_ACEOF
+	CXXFLAGS=""
+      cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_declaration
-#include <stdlib.h>
+
 int
 main ()
 {
-exit (42);
+
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -2542,76 +3084,106 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-  cat >conftest.$ac_ext <<_ACEOF
+	ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-$ac_declaration
+
 int
 main ()
 {
-exit (42);
+
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_cxx_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
-  break
+  ac_cv_prog_cxx_g=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
+
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
-  echo '#ifdef __cplusplus' >>confdefs.h
-  echo $ac_declaration      >>confdefs.h
-  echo '#endif'             >>confdefs.h
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-echo "$as_me:$LINENO: checking whether ln -s works" >&5
-echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking whether ln -s works" >&5
+echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; }
 LN_S=$as_ln_s
 if test "$LN_S" = "ln -s"; then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+  { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
 else
-  echo "$as_me:$LINENO: result: no, using $LN_S" >&5
-echo "${ECHO_T}no, using $LN_S" >&6
+  { echo "$as_me:$LINENO: result: no, using $LN_S" >&5
+echo "${ECHO_T}no, using $LN_S" >&6; }
 fi
 
 
@@ -2621,18 +3193,18 @@
 ICONV_LDFLAGS=
 USE_ICONV=1
 
-# Check whether --with-iconv or --without-iconv was given.
+# Check whether --with-iconv was given.
 if test "${with_iconv+set}" = set; then
-  withval="$with_iconv"
-  if test "$with_iconv" = "no"; then
+  withval=$with_iconv; if test "$with_iconv" = "no"; then
 		USE_ICONV=0
 	fi
 
-fi;
+fi
 
+
 if test "$USE_ICONV" = 1; then
-	echo "$as_me:$LINENO: checking for iconv_open in -liconv" >&5
-echo $ECHO_N "checking for iconv_open in -liconv... $ECHO_C" >&6
+	{ echo "$as_me:$LINENO: checking for iconv_open in -liconv" >&5
+echo $ECHO_N "checking for iconv_open in -liconv... $ECHO_C" >&6; }
 if test "${ac_cv_lib_iconv_iconv_open+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -2645,40 +3217,52 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-/* Override any gcc2 internal prototype to avoid an error.  */
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
 char iconv_open ();
 int
 main ()
 {
-iconv_open ();
+return iconv_open ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -2687,21 +3271,22 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_iconv_iconv_open=no
+	ac_cv_lib_iconv_iconv_open=no
 fi
-rm -f conftest.err conftest.$ac_objext \
+
+rm -f core conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_iconv_iconv_open" >&5
-echo "${ECHO_T}$ac_cv_lib_iconv_iconv_open" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_iconv_iconv_open" >&5
+echo "${ECHO_T}$ac_cv_lib_iconv_iconv_open" >&6; }
 if test $ac_cv_lib_iconv_iconv_open = yes; then
   USE_ICONV=1
 		ICONV_LDFLAGS=-liconv
 
 else
-  echo "$as_me:$LINENO: checking for libiconv_open in -liconv" >&5
-echo $ECHO_N "checking for libiconv_open in -liconv... $ECHO_C" >&6
+  { echo "$as_me:$LINENO: checking for libiconv_open in -liconv" >&5
+echo $ECHO_N "checking for libiconv_open in -liconv... $ECHO_C" >&6; }
 if test "${ac_cv_lib_iconv_libiconv_open+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -2714,40 +3299,52 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-/* Override any gcc2 internal prototype to avoid an error.  */
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
 char libiconv_open ();
 int
 main ()
 {
-libiconv_open ();
+return libiconv_open ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -2756,21 +3353,22 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_iconv_libiconv_open=no
+	ac_cv_lib_iconv_libiconv_open=no
 fi
-rm -f conftest.err conftest.$ac_objext \
+
+rm -f core conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_iconv_libiconv_open" >&5
-echo "${ECHO_T}$ac_cv_lib_iconv_libiconv_open" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_iconv_libiconv_open" >&5
+echo "${ECHO_T}$ac_cv_lib_iconv_libiconv_open" >&6; }
 if test $ac_cv_lib_iconv_libiconv_open = yes; then
   USE_ICONV=1
 			ICONV_LDFLAGS=-liconv
 
 else
-  echo "$as_me:$LINENO: checking for iconv_open in -lc" >&5
-echo $ECHO_N "checking for iconv_open in -lc... $ECHO_C" >&6
+  { echo "$as_me:$LINENO: checking for iconv_open in -lc" >&5
+echo $ECHO_N "checking for iconv_open in -lc... $ECHO_C" >&6; }
 if test "${ac_cv_lib_c_iconv_open+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -2784,40 +3382,52 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 
-/* Override any gcc2 internal prototype to avoid an error.  */
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
 #ifdef __cplusplus
 extern "C"
 #endif
-/* We use char because int might match the return type of a gcc2
-   builtin and then its argument prototype would still apply.  */
 char iconv_open ();
 int
 main ()
 {
-iconv_open ();
+return iconv_open ();
   ;
   return 0;
 }
 _ACEOF
 rm -f conftest.$ac_objext conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>conftest.er1
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -2826,14 +3436,15 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_lib_c_iconv_open=no
+	ac_cv_lib_c_iconv_open=no
 fi
-rm -f conftest.err conftest.$ac_objext \
+
+rm -f core conftest.err conftest.$ac_objext \
       conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-echo "$as_me:$LINENO: result: $ac_cv_lib_c_iconv_open" >&5
-echo "${ECHO_T}$ac_cv_lib_c_iconv_open" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_c_iconv_open" >&5
+echo "${ECHO_T}$ac_cv_lib_c_iconv_open" >&6; }
 if test $ac_cv_lib_c_iconv_open = yes; then
   USE_ICONV=1
 
@@ -2855,8 +3466,8 @@
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
-echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
-echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; }
 # On Suns, sometimes $CPP names a directory.
 if test -n "$CPP" && test -d "$CPP"; then
   CPP=
@@ -2890,8 +3501,13 @@
 #endif
 		     Syntax error
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -2916,9 +3532,10 @@
   # Broken: fails on valid input.
 continue
 fi
+
 rm -f conftest.err conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether non-existent headers
+  # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -2928,8 +3545,13 @@
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -2956,6 +3578,7 @@
 ac_preproc_ok=:
 break
 fi
+
 rm -f conftest.err conftest.$ac_ext
 
 done
@@ -2973,8 +3596,8 @@
 else
   ac_cv_prog_CPP=$CPP
 fi
-echo "$as_me:$LINENO: result: $CPP" >&5
-echo "${ECHO_T}$CPP" >&6
+{ echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6; }
 ac_preproc_ok=false
 for ac_c_preproc_warn_flag in '' yes
 do
@@ -2997,8 +3620,13 @@
 #endif
 		     Syntax error
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -3023,9 +3651,10 @@
   # Broken: fails on valid input.
 continue
 fi
+
 rm -f conftest.err conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether non-existent headers
+  # OK, works on sane cases.  Now check whether nonexistent headers
   # can be detected and how.
   cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
@@ -3035,8 +3664,13 @@
 /* end confdefs.h.  */
 #include <ac_nonexistent.h>
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -3063,6 +3697,7 @@
 ac_preproc_ok=:
 break
 fi
+
 rm -f conftest.err conftest.$ac_ext
 
 done
@@ -3085,23 +3720,170 @@
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-echo "$as_me:$LINENO: checking for egrep" >&5
-echo $ECHO_N "checking for egrep... $ECHO_C" >&6
-if test "${ac_cv_prog_egrep+set}" = set; then
+{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5
+echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  if echo a | (grep -E '(a|b)') >/dev/null 2>&1
-    then ac_cv_prog_egrep='grep -E'
-    else ac_cv_prog_egrep='egrep'
+  # Extract the first word of "grep ggrep" to use in msg output
+if test -z "$GREP"; then
+set dummy grep ggrep; ac_prog_name=$2
+if test "${ac_cv_path_GREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_GREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in grep ggrep; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_GREP" && $as_executable_p "$ac_path_GREP"; } || continue
+    # Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
     fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_GREP_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
 fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
-echo "${ECHO_T}$ac_cv_prog_egrep" >&6
- EGREP=$ac_cv_prog_egrep
 
+GREP="$ac_cv_path_GREP"
+if test -z "$GREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
-echo "$as_me:$LINENO: checking for ANSI C header files" >&5
-echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5
+echo "${ECHO_T}$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     # Extract the first word of "egrep" to use in msg output
+if test -z "$EGREP"; then
+set dummy egrep; ac_prog_name=$2
+if test "${ac_cv_path_EGREP+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_path_EGREP_found=false
+# Loop through the user's path and test for each of PROGNAME-LIST
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_prog in egrep; do
+  for ac_exec_ext in '' $ac_executable_extensions; do
+    ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+    { test -f "$ac_path_EGREP" && $as_executable_p "$ac_path_EGREP"; } || continue
+    # Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    ac_count=`expr $ac_count + 1`
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+
+    $ac_path_EGREP_found && break 3
+  done
+done
+
+done
+IFS=$as_save_IFS
+
+
+fi
+
+EGREP="$ac_cv_path_EGREP"
+if test -z "$EGREP"; then
+  { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5
+echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+
+   fi
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5
+echo "${ECHO_T}$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; }
 if test "${ac_cv_header_stdc+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -3125,24 +3907,36 @@
 }
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -3151,10 +3945,11 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_cv_header_stdc=no
+	ac_cv_header_stdc=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
 if test $ac_cv_header_stdc = yes; then
   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
   cat >conftest.$ac_ext <<_ACEOF
@@ -3209,6 +4004,7 @@
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #include <ctype.h>
+#include <stdlib.h>
 #if ((' ' & 0x0FF) == 0x020)
 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
@@ -3228,18 +4024,27 @@
   for (i = 0; i < 256; i++)
     if (XOR (islower (i), ISLOWER (i))
 	|| toupper (i) != TOUPPER (i))
-      exit(2);
-  exit (0);
+      return 2;
+  return 0;
 }
 _ACEOF
 rm -f conftest$ac_exeext
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
-  (eval $ac_link) 2>&5
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -3252,12 +4057,14 @@
 ( exit $ac_status )
 ac_cv_header_stdc=no
 fi
-rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
 fi
+
+
 fi
 fi
-echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
-echo "${ECHO_T}$ac_cv_header_stdc" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6; }
 if test $ac_cv_header_stdc = yes; then
 
 cat >>confdefs.h <<\_ACEOF
@@ -3280,9 +4087,9 @@
 		  inttypes.h stdint.h unistd.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -3296,24 +4103,36 @@
 #include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -3322,12 +4141,14 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-eval "$as_ac_Header=no"
+	eval "$as_ac_Header=no"
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
   cat >>confdefs.h <<_ACEOF
 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
@@ -3342,18 +4163,19 @@
 for ac_header in iconv.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
-  echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
 else
   # Is the header compilable?
-echo "$as_me:$LINENO: checking $ac_header usability" >&5
-echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -3364,24 +4186,36 @@
 #include <$ac_header>
 _ACEOF
 rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
-  (eval $ac_compile) 2>conftest.er1
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+	 { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; } &&
 	 { ac_try='test -s conftest.$ac_objext'
-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
-  (eval $ac_try) 2>&5
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
   ac_status=$?
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); }; }; then
@@ -3390,15 +4224,16 @@
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-ac_header_compiler=no
+	ac_header_compiler=no
 fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
-echo "${ECHO_T}$ac_header_compiler" >&6
 
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
 # Is the header present?
-echo "$as_me:$LINENO: checking $ac_header presence" >&5
-echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; }
 cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
@@ -3407,8 +4242,13 @@
 /* end confdefs.h.  */
 #include <$ac_header>
 _ACEOF
-if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
-  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -3432,9 +4272,10 @@
 
   ac_header_preproc=no
 fi
+
 rm -f conftest.err conftest.$ac_ext
-echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
-echo "${ECHO_T}$ac_header_preproc" >&6
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
 
 # So?  What about this header?
 case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
@@ -3458,25 +4299,19 @@
 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
     { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
-    (
-      cat <<\_ASBOX
-## ------------------------------------------ ##
-## Report this to the AC_PACKAGE_NAME lists.  ##
-## ------------------------------------------ ##
-_ASBOX
-    ) |
-      sed "s/^/$as_me: WARNING:     /" >&2
+
     ;;
 esac
-echo "$as_me:$LINENO: checking for $ac_header" >&5
-echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
-if eval "test \"\${$as_ac_Header+set}\" = set"; then
+{ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
   eval "$as_ac_Header=\$ac_header_preproc"
 fi
-echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
-echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
 
 fi
 if test `eval echo '${'$as_ac_Header'}'` = yes; then
@@ -3492,92 +4327,126 @@
 
 
 ac_aux_dir=
-for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
-  if test -f $ac_dir/install-sh; then
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+  if test -f "$ac_dir/install-sh"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install-sh -c"
     break
-  elif test -f $ac_dir/install.sh; then
+  elif test -f "$ac_dir/install.sh"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/install.sh -c"
     break
-  elif test -f $ac_dir/shtool; then
+  elif test -f "$ac_dir/shtool"; then
     ac_aux_dir=$ac_dir
     ac_install_sh="$ac_aux_dir/shtool install -c"
     break
   fi
 done
 if test -z "$ac_aux_dir"; then
-  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
-echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5
+echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}
    { (exit 1); exit 1; }; }
 fi
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"
-ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
 
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
 # Make sure we can run config.sub.
-$ac_config_sub sun4 >/dev/null 2>&1 ||
-  { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
-echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5
+echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;}
    { (exit 1); exit 1; }; }
 
-echo "$as_me:$LINENO: checking build system type" >&5
-echo $ECHO_N "checking build system type... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6; }
 if test "${ac_cv_build+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_build_alias=$build_alias
-test -z "$ac_cv_build_alias" &&
-  ac_cv_build_alias=`$ac_config_guess`
-test -z "$ac_cv_build_alias" &&
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
   { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
 echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
    { (exit 1); exit 1; }; }
-ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
-  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;}
    { (exit 1); exit 1; }; }
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_build" >&5
-echo "${ECHO_T}$ac_cv_build" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5
+echo "$as_me: error: invalid value of canonical build" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
 build=$ac_cv_build
-build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
 
 
-echo "$as_me:$LINENO: checking host system type" >&5
-echo $ECHO_N "checking host system type... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6; }
 if test "${ac_cv_host+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_cv_host_alias=$host_alias
-test -z "$ac_cv_host_alias" &&
-  ac_cv_host_alias=$ac_cv_build_alias
-ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
-  { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
-echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5
+echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;}
    { (exit 1); exit 1; }; }
+fi
 
 fi
-echo "$as_me:$LINENO: result: $ac_cv_host" >&5
-echo "${ECHO_T}$ac_cv_host" >&6
+{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5
+echo "$as_me: error: invalid value of canonical host" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
 host=$ac_cv_host
-host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
-host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
-host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
 
 
 
 
 PGCONFIG=
 
-# Check whether --with-pgsql or --without-pgsql was given.
+# Check whether --with-pgsql was given.
 if test "${with_pgsql+set}" = set; then
-  withval="$with_pgsql"
-  if test "$with_pgsql" != "no" -a "$with_pgsql" != "yes"; then
+  withval=$with_pgsql; if test "$with_pgsql" != "no" -a "$with_pgsql" != "yes"; then
 		if test ! -f "$with_pgsql"; then
 			{ { echo "$as_me:$LINENO: error: Invalid argument to --with-pgsql" >&5
 echo "$as_me: error: Invalid argument to --with-pgsql" >&2;}
@@ -3586,12 +4455,13 @@
 		PGCONFIG="$with_pgsql"
 	fi
 
-fi;
+fi
+
 if test -z "$PGCONFIG"; then
 	# Extract the first word of "pg_config", so it can be a program name with args.
 set dummy pg_config; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_PGCONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -3606,27 +4476,28 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PGCONFIG="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 PGCONFIG=$ac_cv_path_PGCONFIG
-
 if test -n "$PGCONFIG"; then
-  echo "$as_me:$LINENO: result: $PGCONFIG" >&5
-echo "${ECHO_T}$PGCONFIG" >&6
+  { echo "$as_me:$LINENO: result: $PGCONFIG" >&5
+echo "${ECHO_T}$PGCONFIG" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 fi
 if test -z "$PGCONFIG"; then
 	{ { echo "$as_me:$LINENO: error: PostgreSQL is required by PostGIS" >&5
@@ -3671,8 +4542,8 @@
 
 # Extract the first word of "geos-config", so it can be a program name with args.
 set dummy geos-config; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_GEOSCONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -3687,36 +4558,36 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_GEOSCONFIG="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 GEOSCONFIG=$ac_cv_path_GEOSCONFIG
-
 if test -n "$GEOSCONFIG"; then
-  echo "$as_me:$LINENO: result: $GEOSCONFIG" >&5
-echo "${ECHO_T}$GEOSCONFIG" >&6
+  { echo "$as_me:$LINENO: result: $GEOSCONFIG" >&5
+echo "${ECHO_T}$GEOSCONFIG" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 if test -n "$GEOSCONFIG"; then
 	USE_GEOS=1
 fi
 
 
-# Check whether --with-geos or --without-geos was given.
+# Check whether --with-geos was given.
 if test "${with_geos+set}" = set; then
-  withval="$with_geos"
-  if test "$with_geos" = "no"; then
+  withval=$with_geos; if test "$with_geos" = "no"; then
 		USE_GEOS=0
 	else
 		if test "$with_geos" != "yes"; then
@@ -3731,11 +4602,21 @@
 		fi
 	fi
 
-fi;
+fi
 
+
 if test $USE_GEOS -gt 0; then
 	GEOS_DIR=`$GEOSCONFIG --prefix`
-	GEOS_LDFLAGS=`$GEOSCONFIG --ldflags`
+
+	GEOS_LDFLAGS=`$GEOSCONFIG --ldflags 2> /dev/null`
+	if test x"$GEOS_LDFLAGS" = "x"; then
+		# older geos-config versions did not
+		# support the --ldflags switch, we'll
+		# default to GEOS_DIR/lib in this case.
+		#
+		GEOS_LDFLAGS="-L${GEOS_DIR}/lib"
+	fi
+
 	GEOS_MAJOR=`$GEOSCONFIG --version | cut -d. -f1`
 	if test "$GEOS_MAJOR" = "@GEOS_VERSION@"; then
 		GEOS_MAJOR=1
@@ -3751,10 +4632,9 @@
 fi
 
 
-# Check whether --with-geos-libdir or --without-geos-libdir was given.
+# Check whether --with-geos-libdir was given.
 if test "${with_geos_libdir+set}" = set; then
-  withval="$with_geos_libdir"
-
+  withval=$with_geos_libdir;
 case "$with_geos_libdir" in
 	no|yes)
 		{ { echo "$as_me:$LINENO: error: Invalid argument to --with-geos-libdir" >&5
@@ -3768,19 +4648,20 @@
 
 else
   with_geos_libdir=no
-fi;
+fi
 
 
 
 
 
+
 USE_PROJ=0
 PROJ_DIR=
 PROJ_LIBDIR=
 # Extract the first word of "proj", so it can be a program name with args.
 set dummy proj; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_PROJ+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -3795,37 +4676,37 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PROJ="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 PROJ=$ac_cv_path_PROJ
-
 if test -n "$PROJ"; then
-  echo "$as_me:$LINENO: result: $PROJ" >&5
-echo "${ECHO_T}$PROJ" >&6
+  { echo "$as_me:$LINENO: result: $PROJ" >&5
+echo "${ECHO_T}$PROJ" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 if test -n "$PROJ"; then
 	USE_PROJ=1
 	PROJ_DIR=`dirname ${PROJ}`/..
 	owd=`pwd`; cd ${PROJ_DIR}; PROJ_DIR=`pwd`; cd $owd;
 fi
 
-# Check whether --with-proj or --without-proj was given.
+# Check whether --with-proj was given.
 if test "${with_proj+set}" = set; then
-  withval="$with_proj"
-  if test "$with_proj" = "no"; then
+  withval=$with_proj; if test "$with_proj" = "no"; then
 		USE_PROJ=0
 	else
 		USE_PROJ=1
@@ -3834,7 +4715,8 @@
 		fi
 	fi
 
-fi;
+fi
+
 if test $USE_PROJ -gt 0; then
 	if test ! -f $PROJ_DIR/include/projects.h; then
 		{ { echo "$as_me:$LINENO: error: Can't find proj dir." >&5
@@ -3845,10 +4727,9 @@
 fi
 
 
-# Check whether --with-proj-libdir or --without-proj-libdir was given.
+# Check whether --with-proj-libdir was given.
 if test "${with_proj_libdir+set}" = set; then
-  withval="$with_proj_libdir"
-
+  withval=$with_proj_libdir;
 case "$with_proj_libdir" in
 	no|yes)
 		{ { echo "$as_me:$LINENO: error: Invalid argument to --with-proj-libdir" >&5
@@ -3862,19 +4743,19 @@
 
 else
   with_proj_libdir=no
-fi;
+fi
 
 
 
 
+
 USE_JTS=0
 JTS_INCLUDES=
 JTS_INCLUDES=
 
-# Check whether --with-jts or --without-jts was given.
+# Check whether --with-jts was given.
 if test "${with_jts+set}" = set; then
-  withval="$with_jts"
-  if test "$with_jts" != "no"; then
+  withval=$with_jts; if test "$with_jts" != "no"; then
 		USE_JTS=1
 		if test "$with_jts" != "yes"; then
 			if test ! -f "$with_jts"; then
@@ -3887,13 +4768,14 @@
 		fi
 	fi
 
-fi;
+fi
+
 if test $USE_JTS -gt 0; then
 	if test -z "$JTSCONFIG"; then
 		# Extract the first word of "jts-config", so it can be a program name with args.
 set dummy jts-config; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_JTSCONFIG+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -3908,27 +4790,28 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_JTSCONFIG="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 JTSCONFIG=$ac_cv_path_JTSCONFIG
-
 if test -n "$JTSCONFIG"; then
-  echo "$as_me:$LINENO: result: $JTSCONFIG" >&5
-echo "${ECHO_T}$JTSCONFIG" >&6
+  { echo "$as_me:$LINENO: result: $JTSCONFIG" >&5
+echo "${ECHO_T}$JTSCONFIG" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 		if test -z "$JTSCONFIG"; then
 			{ { echo "$as_me:$LINENO: error: Can't find jts-config" >&5
 echo "$as_me: error: Can't find jts-config" >&2;}
@@ -3942,8 +4825,8 @@
 
 # Extract the first word of "flex", so it can be a program name with args.
 set dummy flex; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_FLEX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -3958,27 +4841,28 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_FLEX="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 FLEX=$ac_cv_path_FLEX
-
 if test -n "$FLEX"; then
-  echo "$as_me:$LINENO: result: $FLEX" >&5
-echo "${ECHO_T}$FLEX" >&6
+  { echo "$as_me:$LINENO: result: $FLEX" >&5
+echo "${ECHO_T}$FLEX" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 if test -z "$FLEX"; then
 	{ { echo "$as_me:$LINENO: error: Can't find 'flex'" >&5
 echo "$as_me: error: Can't find 'flex'" >&2;}
@@ -3988,8 +4872,8 @@
 
 # Extract the first word of "dllwrap", so it can be a program name with args.
 set dummy dllwrap; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_DLLWRAP+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -4004,32 +4888,33 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_DLLWRAP="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 DLLWRAP=$ac_cv_path_DLLWRAP
-
 if test -n "$DLLWRAP"; then
-  echo "$as_me:$LINENO: result: $DLLWRAP" >&5
-echo "${ECHO_T}$DLLWRAP" >&6
+  { echo "$as_me:$LINENO: result: $DLLWRAP" >&5
+echo "${ECHO_T}$DLLWRAP" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
 
+
 # Extract the first word of "dlltool", so it can be a program name with args.
 set dummy dlltool; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_DLLTOOL+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -4044,34 +4929,35 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_DLLTOOL="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 DLLTOOL=$ac_cv_path_DLLTOOL
-
 if test -n "$DLLTOOL"; then
-  echo "$as_me:$LINENO: result: $DLLTOOL" >&5
-echo "${ECHO_T}$DLLTOOL" >&6
+  { echo "$as_me:$LINENO: result: $DLLTOOL" >&5
+echo "${ECHO_T}$DLLTOOL" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
 
+
 for ac_prog in 'bison -y' byacc
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_prog_YACC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -4084,25 +4970,27 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_prog_YACC="$ac_prog"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
 fi
 fi
 YACC=$ac_cv_prog_YACC
 if test -n "$YACC"; then
-  echo "$as_me:$LINENO: result: $YACC" >&5
-echo "${ECHO_T}$YACC" >&6
+  { echo "$as_me:$LINENO: result: $YACC" >&5
+echo "${ECHO_T}$YACC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
   test -n "$YACC" && break
 done
 test -n "$YACC" || YACC="yacc"
@@ -4119,8 +5007,8 @@
 
 # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_PERL+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -4135,27 +5023,28 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PERL="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 PERL=$ac_cv_path_PERL
-
 if test -n "$PERL"; then
-  echo "$as_me:$LINENO: result: $PERL" >&5
-echo "${ECHO_T}$PERL" >&6
+  { echo "$as_me:$LINENO: result: $PERL" >&5
+echo "${ECHO_T}$PERL" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 if test -z "$PERL"; then
 	{ { echo "$as_me:$LINENO: error: Can't find 'perl'" >&5
 echo "$as_me: error: Can't find 'perl'" >&2;}
@@ -4165,10 +5054,9 @@
 
 docdir='${prefix}/share/doc'
 
-# Check whether --with-docdir or --without-docdir was given.
+# Check whether --with-docdir was given.
 if test "${with_docdir+set}" = set; then
-  withval="$with_docdir"
-  if test "$with_docdir" = "yes"; then
+  withval=$with_docdir; if test "$with_docdir" = "yes"; then
 		{ { echo "$as_me:$LINENO: error: option --with-docdir requires an argument" >&5
 echo "$as_me: error: option --with-docdir requires an argument" >&2;}
    { (exit 1); exit 1; }; }
@@ -4177,9 +5065,10 @@
 		docdir="$with_docdir"
 	fi
 
-fi;
+fi
 
 
+
 XSLBASE=
 SEARCHPATH="
 	/usr/share/sgml/docbook/xsl-stylesheets
@@ -4195,8 +5084,8 @@
 
 # Extract the first word of "xsltproc", so it can be a program name with args.
 set dummy xsltproc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_XSLTPROC+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -4211,31 +5100,32 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_XSLTPROC="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 XSLTPROC=$ac_cv_path_XSLTPROC
-
 if test -n "$XSLTPROC"; then
-  echo "$as_me:$LINENO: result: $XSLTPROC" >&5
-echo "${ECHO_T}$XSLTPROC" >&6
+  { echo "$as_me:$LINENO: result: $XSLTPROC" >&5
+echo "${ECHO_T}$XSLTPROC" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 # Extract the first word of "pdfxmltex", so it can be a program name with args.
 set dummy pdfxmltex; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_PDFXMLTEX+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -4250,31 +5140,32 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_PDFXMLTEX="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 PDFXMLTEX=$ac_cv_path_PDFXMLTEX
-
 if test -n "$PDFXMLTEX"; then
-  echo "$as_me:$LINENO: result: $PDFXMLTEX" >&5
-echo "${ECHO_T}$PDFXMLTEX" >&6
+  { echo "$as_me:$LINENO: result: $PDFXMLTEX" >&5
+echo "${ECHO_T}$PDFXMLTEX" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 # Extract the first word of "db2pdf", so it can be a program name with args.
 set dummy db2pdf; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_DB2PDF+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -4289,31 +5180,32 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_DB2PDF="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 DB2PDF=$ac_cv_path_DB2PDF
-
 if test -n "$DB2PDF"; then
-  echo "$as_me:$LINENO: result: $DB2PDF" >&5
-echo "${ECHO_T}$DB2PDF" >&6
+  { echo "$as_me:$LINENO: result: $DB2PDF" >&5
+echo "${ECHO_T}$DB2PDF" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
+
 # Extract the first word of "jw", so it can be a program name with args.
 set dummy jw; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
 if test "${ac_cv_path_JW+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
@@ -4328,31 +5220,32 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
   for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then
     ac_cv_path_JW="$as_dir/$ac_word$ac_exec_ext"
     echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
 done
 done
+IFS=$as_save_IFS
 
   ;;
 esac
 fi
 JW=$ac_cv_path_JW
-
 if test -n "$JW"; then
-  echo "$as_me:$LINENO: result: $JW" >&5
-echo "${ECHO_T}$JW" >&6
+  { echo "$as_me:$LINENO: result: $JW" >&5
+echo "${ECHO_T}$JW" >&6; }
 else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
 fi
 
 
 
 
 
+
 DOC_RULE=requirements_not_met
 if test -n "${XSLBASE}"; then
 	if test -n "${XSLTPROC}"; then
@@ -4487,8 +5380,8 @@
 
 # --with-template parsing is done in the single
 # pg_config --configure scan above
-echo "$as_me:$LINENO: checking which template to use" >&5
-echo $ECHO_N "checking which template to use... $ECHO_C" >&6
+{ echo "$as_me:$LINENO: checking which template to use" >&5
+echo $ECHO_N "checking which template to use... $ECHO_C" >&6; }
 template=$PGTEMPLATE
 
 case $host_os in
@@ -4547,8 +5440,8 @@
    { (exit 1); exit 1; }; }
   fi
 
-echo "$as_me:$LINENO: result: $template" >&5
-echo "${ECHO_T}$template" >&6
+{ echo "$as_me:$LINENO: result: $template" >&5
+echo "${ECHO_T}$template" >&6; }
 
 PORTNAME=$template
 
@@ -4613,7 +5506,8 @@
 
 
 
-          ac_config_files="$ac_config_files Makefile.config"
+ac_config_files="$ac_config_files Makefile.config"
+
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -4632,39 +5526,58 @@
 
 # The following way of writing the cache mishandles newlines in values,
 # but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
+# So, we kill variables containing newlines.
 # Ultrix sh set writes to stderr and can't be redirected directly,
 # and sets the high bit in the cache file unless we assign to the vars.
-{
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5
+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      *) $as_unset $ac_var ;;
+      esac ;;
+    esac
+  done
+
   (set) 2>&1 |
-    case `(ac_space=' '; set | grep ac_space) 2>&1` in
-    *ac_space=\ *)
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
       # `set' does not quote correctly, so add quotes (double-quote
       # substitution turns \\\\ into \\, and sed turns \\ into \).
       sed -n \
 	"s/'/'\\\\''/g;
 	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-      ;;
+      ;; #(
     *)
       # `set' quotes correctly as required by POSIX, so do not add quotes.
-      sed -n \
-	"s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
       ;;
-    esac;
-} |
+    esac |
+    sort
+) |
   sed '
+     /^ac_cv_env_/b end
      t clear
-     : clear
+     :clear
      s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
      t end
-     /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
-     : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
-  if test -w $cache_file; then
-    test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { echo "$as_me:$LINENO: updating cache $cache_file" >&5
+echo "$as_me: updating cache $cache_file" >&6;}
     cat confcache >$cache_file
   else
-    echo "not updating unwritable cache $cache_file"
+    { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5
+echo "$as_me: not updating unwritable cache $cache_file" >&6;}
   fi
 fi
 rm -f confcache
@@ -4673,32 +5586,18 @@
 # Let make expand exec_prefix.
 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
 
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
-s/:*\$(srcdir):*/:/;
-s/:*\${srcdir}:*/:/;
-s/:*@srcdir@:*/:/;
-s/^\([^=]*=[	 ]*\):*/\1/;
-s/:*$//;
-s/^[^=]*=[	 ]*$//;
-}'
-fi
-
 DEFS=-DHAVE_CONFIG_H
 
 ac_libobjs=
 ac_ltlibobjs=
 for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
   # 1. Remove the extension, and $U if already installed.
-  ac_i=`echo "$ac_i" |
-	 sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
-  # 2. Add them.
-  ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
-  ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'
 done
 LIBOBJS=$ac_libobjs
 
@@ -4736,11 +5635,35 @@
   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
   # is contrary to our usage.  Disable this feature.
   alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
-  set -o posix
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
 fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
 DUALCASE=1; export DUALCASE # for MKS sh
 
+
+# PATH needs CR
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+
 # Support unset when possible.
 if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
   as_unset=unset
@@ -4749,8 +5672,43 @@
 fi
 
 
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+as_nl='
+'
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  { (exit 1); exit 1; }
+fi
+
 # Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
+for as_var in ENV MAIL MAILPATH
+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
+done
 PS1='$ '
 PS2='> '
 PS4='+ '
@@ -4764,18 +5722,19 @@
   if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
     eval $as_var=C; export $as_var
   else
-    $as_unset $as_var
+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var
   fi
 done
 
 # Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
 else
   as_expr=false
 fi
 
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
   as_basename=basename
 else
   as_basename=false
@@ -4783,159 +5742,120 @@
 
 
 # Name of the executable.
-as_me=`$as_basename "$0" ||
+as_me=`$as_basename -- "$0" ||
 $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
 	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)$' \| \
-	 .     : '\(.\)' 2>/dev/null ||
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
 echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
-  	  /^X\/\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\/\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
 
+# CDPATH.
+$as_unset CDPATH
 
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
 
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  echo "#! /bin/sh" >conf$$.sh
-  echo  "exit 0"   >>conf$$.sh
-  chmod +x conf$$.sh
-  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
-    PATH_SEPARATOR=';'
-  else
-    PATH_SEPARATOR=:
-  fi
-  rm -f conf$$.sh
-fi
 
-
   as_lineno_1=$LINENO
   as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
   test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2"  || {
-  # Find who we are.  Look in the path if we contain no path at all
-  # relative or not.
-  case $0 in
-    *[\\/]* ) as_myself=$0 ;;
-    *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {
 
-       ;;
-  esac
-  # We did not find ourselves, most probably we were run as `sh COMMAND'
-  # in which case we are not to be found in the path.
-  if test "x$as_myself" = x; then
-    as_myself=$0
-  fi
-  if test ! -f "$as_myself"; then
-    { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
-echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
-   { (exit 1); exit 1; }; }
-  fi
-  case $CONFIG_SHELL in
-  '')
-    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for as_base in sh bash ksh sh5; do
-	 case $as_dir in
-	 /*)
-	   if ("$as_dir/$as_base" -c '
-  as_lineno_1=$LINENO
-  as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
-  test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2" ') 2>/dev/null; then
-	     $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
-	     $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
-	     CONFIG_SHELL=$as_dir/$as_base
-	     export CONFIG_SHELL
-	     exec "$CONFIG_SHELL" "$0" ${1+"$@"}
-	   fi;;
-	 esac
-       done
-done
-;;
-  esac
-
   # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
   # uniformly replaced by the line number.  The first 'sed' inserts a
-  # line-number line before each line; the second 'sed' does the real
-  # work.  The second script uses 'N' to pair each line-number line
-  # with the numbered line, and appends trailing '-' during
-  # substitution so that $LINENO is not a special case at line end.
+  # line-number line after each line using $LINENO; the second 'sed'
+  # does the real work.  The second script uses 'N' to pair each
+  # line-number line with the line containing $LINENO, and appends
+  # trailing '-' during substitution so that $LINENO is not a special
+  # case at line end.
   # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
-  # second 'sed' script.  Blame Lee E. McMahon for sed's syntax.  :-)
-  sed '=' <$as_myself |
+  # scripts with optimization help from Paolo Bonzini.  Blame Lee
+  # E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
     sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
       N
-      s,$,-,
-      : loop
-      s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
       t loop
-      s,-$,,
-      s,^['$as_cr_digits']*\n,,
+      s/-\n.*//
     ' >$as_me.lineno &&
-  chmod +x $as_me.lineno ||
-    { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
-echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+  chmod +x "$as_me.lineno" ||
+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
    { (exit 1); exit 1; }; }
 
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
-  # original and so on.  Autoconf is especially sensible to this).
-  . ./$as_me.lineno
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
   # Exit status is that of the last command.
   exit
 }
 
 
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
-  *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T='	' ;;
-  *c*,*  ) ECHO_N=-n ECHO_C= ECHO_T= ;;
-  *)       ECHO_N= ECHO_C='\c' ECHO_T= ;;
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in
+-n*)
+  case `echo 'x\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  *)   ECHO_C='\c';;
+  esac;;
+*)
+  ECHO_N='-n';;
 esac
 
-if expr a : '\(a\)' >/dev/null 2>&1; then
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
   as_expr=expr
 else
   as_expr=false
 fi
 
 rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir
+fi
 echo >conf$$.file
 if ln -s conf$$.file conf$$ 2>/dev/null; then
-  # We could just check for DJGPP; but this test a) works b) is more generic
-  # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
-  if test -f conf$$.exe; then
-    # Don't use ln at all; we don't have any links
+  as_ln_s='ln -s'
+  # ... but there are two gotchas:
+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+  # In both cases, we have to default to `cp -p'.
+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
     as_ln_s='cp -p'
-  else
-    as_ln_s='ln -s'
-  fi
 elif ln conf$$.file conf$$ 2>/dev/null; then
   as_ln_s=ln
 else
   as_ln_s='cp -p'
 fi
-rm -f conf$$ conf$$.exe conf$$.file
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
 
 if mkdir -p . 2>/dev/null; then
   as_mkdir_p=:
@@ -4944,7 +5864,19 @@
   as_mkdir_p=false
 fi
 
-as_executable_p="test -f"
+# Find out whether ``test -x'' works.  Don't use a zero-byte file, as
+# systems may use methods other than mode bits to determine executability.
+cat >conf$$.file <<_ASEOF
+#! /bin/sh
+exit 0
+_ASEOF
+chmod +x conf$$.file
+if test -x conf$$.file >/dev/null 2>&1; then
+  as_executable_p="test -x"
+else
+  as_executable_p=:
+fi
+rm -f conf$$.file
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -4953,31 +5885,14 @@
 as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
 
 
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" 	$as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
 exec 6>&1
 
-# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# Save the log message, to keep $[0] and so on meaningful, and to
 # report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.  Logging --version etc. is OK.
-exec 5>>config.log
-{
-  echo
-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-} >&5
-cat >&5 <<_CSEOF
-
+# values after options handling.
+ac_log="
 This file was extended by $as_me, which was
-generated by GNU Autoconf 2.59.  Invocation command line was
+generated by GNU Autoconf 2.60.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -4985,30 +5900,19 @@
   CONFIG_COMMANDS = $CONFIG_COMMANDS
   $ $0 $@
 
-_CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
-echo >&5
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
 _ACEOF
 
+cat >>$CONFIG_STATUS <<_ACEOF
 # Files that config.status was made for.
-if test -n "$ac_config_files"; then
-  echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
-fi
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
 
-if test -n "$ac_config_headers"; then
-  echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
-fi
+_ACEOF
 
-if test -n "$ac_config_links"; then
-  echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_commands"; then
-  echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
-fi
-
 cat >>$CONFIG_STATUS <<\_ACEOF
-
 ac_cs_usage="\
 \`$as_me' instantiates files from templates according to the
 current configuration.
@@ -5032,18 +5936,20 @@
 $config_headers
 
 Report bugs to <bug-autoconf at gnu.org>."
+
 _ACEOF
-
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
 config.status
-configured by $0, generated by GNU Autoconf 2.59,
-  with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+configured by $0, generated by GNU Autoconf 2.60,
+  with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
 
-Copyright (C) 2003 Free Software Foundation, Inc.
+Copyright (C) 2006 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
 _ACEOF
 
 cat >>$CONFIG_STATUS <<\_ACEOF
@@ -5054,39 +5960,24 @@
 do
   case $1 in
   --*=*)
-    ac_option=`expr "x$1" : 'x\([^=]*\)='`
-    ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
     ac_shift=:
     ;;
-  -*)
+  *)
     ac_option=$1
     ac_optarg=$2
     ac_shift=shift
     ;;
-  *) # This is not an option, so the user has probably given explicit
-     # arguments.
-     ac_option=$1
-     ac_need_defaults=false;;
   esac
 
   case $ac_option in
   # Handling of the options.
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
     ac_cs_recheck=: ;;
-  --version | --vers* | -V )
-    echo "$ac_cs_version"; exit 0 ;;
-  --he | --h)
-    # Conflict between --help and --header
-    { { echo "$as_me:$LINENO: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2;}
-   { (exit 1); exit 1; }; };;
-  --help | --hel | -h )
-    echo "$ac_cs_usage"; exit 0 ;;
-  --debug | --d* | -d )
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    echo "$ac_cs_version"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
     debug=: ;;
   --file | --fil | --fi | --f )
     $ac_shift
@@ -5096,18 +5987,24 @@
     $ac_shift
     CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
     ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    { echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2
+   { (exit 1); exit 1; }; };;
+  --help | --hel | -h )
+    echo "$ac_cs_usage"; exit ;;
   -q | -quiet | --quiet | --quie | --qui | --qu | --q \
   | -silent | --silent | --silen | --sile | --sil | --si | --s)
     ac_cs_silent=: ;;
 
   # This is an error.
-  -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2;}
+  -*) { echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2
    { (exit 1); exit 1; }; } ;;
 
-  *) ac_config_targets="$ac_config_targets $1" ;;
+  *) ac_config_targets="$ac_config_targets $1"
+     ac_need_defaults=false ;;
 
   esac
   shift
@@ -5123,29 +6020,43 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
 if \$ac_cs_recheck; then
-  echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
-  exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+  CONFIG_SHELL=$SHELL
+  export CONFIG_SHELL
+  exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
 fi
 
 _ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  echo "$ac_log"
+} >&5
 
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+_ACEOF
 
+cat >>$CONFIG_STATUS <<\_ACEOF
 
-
-
-cat >>$CONFIG_STATUS <<\_ACEOF
+# Handling of arguments.
 for ac_config_target in $ac_config_targets
 do
-  case "$ac_config_target" in
-  # Handling of arguments.
-  "Makefile.config" ) CONFIG_FILES="$CONFIG_FILES Makefile.config" ;;
-  "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;;
+
   *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
 echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
    { (exit 1); exit 1; }; };;
   esac
 done
 
+
 # If the user did not use the arguments to specify the items to instantiate,
 # then the envvar interface is used.  Set only those that are not.
 # We use the long form for the default assignment because of an extremely
@@ -5156,599 +6067,593 @@
 fi
 
 # Have a temporary directory for convenience.  Make it in the build tree
-# simply because there is no reason to put it here, and in addition,
+# simply because there is no reason against having it here, and in addition,
 # creating and moving files from /tmp can sometimes cause problems.
-# Create a temporary directory, and hook for its removal unless debugging.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
 $debug ||
 {
-  trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
   trap '{ (exit 1); exit 1; }' 1 2 13 15
 }
-
 # Create a (secure) tmp directory for tmp files.
 
 {
-  tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
   test -n "$tmp" && test -d "$tmp"
 }  ||
 {
-  tmp=./confstat$$-$RANDOM
-  (umask 077 && mkdir $tmp)
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
 } ||
 {
    echo "$me: cannot create a temporary directory in ." >&2
    { (exit 1); exit 1; }
 }
 
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-
 #
-# CONFIG_FILES section.
+# Set up the sed scripts for CONFIG_FILES section.
 #
 
 # No need to generate the scripts if there are no CONFIG_FILES.
 # This happens for instance when ./config.status config.h
-if test -n "\$CONFIG_FILES"; then
-  # Protect against being on the right side of a sed subst in config.status.
-  sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
-   s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
-s, at SHELL@,$SHELL,;t t
-s, at PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s, at PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s, at PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s, at PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s, at PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s, at PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
-s, at exec_prefix@,$exec_prefix,;t t
-s, at prefix@,$prefix,;t t
-s, at program_transform_name@,$program_transform_name,;t t
-s, at bindir@,$bindir,;t t
-s, at sbindir@,$sbindir,;t t
-s, at libexecdir@,$libexecdir,;t t
-s, at datadir@,$datadir,;t t
-s, at sysconfdir@,$sysconfdir,;t t
-s, at sharedstatedir@,$sharedstatedir,;t t
-s, at localstatedir@,$localstatedir,;t t
-s, at libdir@,$libdir,;t t
-s, at includedir@,$includedir,;t t
-s, at oldincludedir@,$oldincludedir,;t t
-s, at infodir@,$infodir,;t t
-s, at mandir@,$mandir,;t t
-s, at build_alias@,$build_alias,;t t
-s, at host_alias@,$host_alias,;t t
-s, at target_alias@,$target_alias,;t t
-s, at DEFS@,$DEFS,;t t
-s, at ECHO_C@,$ECHO_C,;t t
-s, at ECHO_N@,$ECHO_N,;t t
-s, at ECHO_T@,$ECHO_T,;t t
-s, at LIBS@,$LIBS,;t t
-s, at CC@,$CC,;t t
-s, at CFLAGS@,$CFLAGS,;t t
-s, at LDFLAGS@,$LDFLAGS,;t t
-s, at CPPFLAGS@,$CPPFLAGS,;t t
-s, at ac_ct_CC@,$ac_ct_CC,;t t
-s, at EXEEXT@,$EXEEXT,;t t
-s, at OBJEXT@,$OBJEXT,;t t
-s, at CXX@,$CXX,;t t
-s, at CXXFLAGS@,$CXXFLAGS,;t t
-s, at ac_ct_CXX@,$ac_ct_CXX,;t t
-s, at LN_S@,$LN_S,;t t
-s, at USE_ICONV@,$USE_ICONV,;t t
-s, at ICONV_LDFLAGS@,$ICONV_LDFLAGS,;t t
-s, at CPP@,$CPP,;t t
-s, at EGREP@,$EGREP,;t t
-s, at build@,$build,;t t
-s, at build_cpu@,$build_cpu,;t t
-s, at build_vendor@,$build_vendor,;t t
-s, at build_os@,$build_os,;t t
-s, at host@,$host,;t t
-s, at host_cpu@,$host_cpu,;t t
-s, at host_vendor@,$host_vendor,;t t
-s, at host_os@,$host_os,;t t
-s, at PGCONFIG@,$PGCONFIG,;t t
-s, at PGFEINCLUDES@,$PGFEINCLUDES,;t t
-s, at PGBEINCLUDES@,$PGBEINCLUDES,;t t
-s, at PGFELIBS@,$PGFELIBS,;t t
-s, at PGBELIBS@,$PGBELIBS,;t t
-s, at PGBIN@,$PGBIN,;t t
-s, at PGTEMPLATE@,$PGTEMPLATE,;t t
-s, at LPATH@,$LPATH,;t t
-s, at PWDREGRESS@,$PWDREGRESS,;t t
-s, at USE_GEOS@,$USE_GEOS,;t t
-s, at GEOS_DIR@,$GEOS_DIR,;t t
-s, at GEOS_LDFLAGS@,$GEOS_LDFLAGS,;t t
-s, at USE_GEOS_CAPI@,$USE_GEOS_CAPI,;t t
-s, at GEOSCONFIG@,$GEOSCONFIG,;t t
-s, at USE_PROJ@,$USE_PROJ,;t t
-s, at PROJ_DIR@,$PROJ_DIR,;t t
-s, at PROJ_LIBDIR@,$PROJ_LIBDIR,;t t
-s, at PROJ@,$PROJ,;t t
-s, at USE_JTS@,$USE_JTS,;t t
-s, at JTS_INCLUDES@,$JTS_INCLUDES,;t t
-s, at JTS_LIBDIR@,$JTS_LIBDIR,;t t
-s, at JTSCONFIG@,$JTSCONFIG,;t t
-s, at FLEX@,$FLEX,;t t
-s, at DLLWRAP@,$DLLWRAP,;t t
-s, at DLLTOOL@,$DLLTOOL,;t t
-s, at YACC@,$YACC,;t t
-s, at INSTALL@,$INSTALL,;t t
-s, at PERL@,$PERL,;t t
-s, at docdir@,$docdir,;t t
-s, at XSLBASE@,$XSLBASE,;t t
-s, at XSLTPROC@,$XSLTPROC,;t t
-s, at PDFXMLTEX@,$PDFXMLTEX,;t t
-s, at DB2PDF@,$DB2PDF,;t t
-s, at JW@,$JW,;t t
-s, at DOC_RULE@,$DOC_RULE,;t t
-s, at PORTNAME@,$PORTNAME,;t t
-s, at DLSUFFIX@,$DLSUFFIX,;t t
-s, at DLFLAGS@,$DLFLAGS,;t t
-s, at EXE@,$EXE,;t t
-s, at HOST_OS@,$HOST_OS,;t t
-s, at ELF_SYS@,$ELF_SYS,;t t
-s, at LIBOBJS@,$LIBOBJS,;t t
-s, at LTLIBOBJS@,$LTLIBOBJS,;t t
-CEOF
+if test -n "$CONFIG_FILES"; then
 
 _ACEOF
 
-  cat >>$CONFIG_STATUS <<\_ACEOF
-  # Split the substitutions into bite-sized pieces for seds with
-  # small command number limits, like on Digital OSF/1 and HP-UX.
-  ac_max_sed_lines=48
-  ac_sed_frag=1 # Number of current file.
-  ac_beg=1 # First line for current file.
-  ac_end=$ac_max_sed_lines # Line after last line for current file.
-  ac_more_lines=:
-  ac_sed_cmds=
-  while $ac_more_lines; do
-    if test $ac_beg -gt 1; then
-      sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
-    else
-      sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
-    fi
-    if test ! -s $tmp/subs.frag; then
-      ac_more_lines=false
-    else
-      # The purpose of the label and of the branching condition is to
-      # speed up the sed processing (if there are no `@' at all, there
-      # is no need to browse any of the substitutions).
-      # These are the two extra sed commands mentioned above.
-      (echo ':t
-  /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
-      if test -z "$ac_sed_cmds"; then
-	ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
-      else
-	ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
-      fi
-      ac_sed_frag=`expr $ac_sed_frag + 1`
-      ac_beg=$ac_end
-      ac_end=`expr $ac_end + $ac_max_sed_lines`
-    fi
-  done
-  if test -z "$ac_sed_cmds"; then
-    ac_sed_cmds=cat
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
+SHELL!$SHELL$ac_delim
+PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim
+PACKAGE_NAME!$PACKAGE_NAME$ac_delim
+PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim
+PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim
+PACKAGE_STRING!$PACKAGE_STRING$ac_delim
+PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim
+exec_prefix!$exec_prefix$ac_delim
+prefix!$prefix$ac_delim
+program_transform_name!$program_transform_name$ac_delim
+bindir!$bindir$ac_delim
+sbindir!$sbindir$ac_delim
+libexecdir!$libexecdir$ac_delim
+datarootdir!$datarootdir$ac_delim
+datadir!$datadir$ac_delim
+sysconfdir!$sysconfdir$ac_delim
+sharedstatedir!$sharedstatedir$ac_delim
+localstatedir!$localstatedir$ac_delim
+includedir!$includedir$ac_delim
+oldincludedir!$oldincludedir$ac_delim
+docdir!$docdir$ac_delim
+infodir!$infodir$ac_delim
+htmldir!$htmldir$ac_delim
+dvidir!$dvidir$ac_delim
+pdfdir!$pdfdir$ac_delim
+psdir!$psdir$ac_delim
+libdir!$libdir$ac_delim
+localedir!$localedir$ac_delim
+mandir!$mandir$ac_delim
+DEFS!$DEFS$ac_delim
+ECHO_C!$ECHO_C$ac_delim
+ECHO_N!$ECHO_N$ac_delim
+ECHO_T!$ECHO_T$ac_delim
+LIBS!$LIBS$ac_delim
+build_alias!$build_alias$ac_delim
+host_alias!$host_alias$ac_delim
+target_alias!$target_alias$ac_delim
+CC!$CC$ac_delim
+CFLAGS!$CFLAGS$ac_delim
+LDFLAGS!$LDFLAGS$ac_delim
+CPPFLAGS!$CPPFLAGS$ac_delim
+ac_ct_CC!$ac_ct_CC$ac_delim
+EXEEXT!$EXEEXT$ac_delim
+OBJEXT!$OBJEXT$ac_delim
+CXX!$CXX$ac_delim
+CXXFLAGS!$CXXFLAGS$ac_delim
+ac_ct_CXX!$ac_ct_CXX$ac_delim
+LN_S!$LN_S$ac_delim
+USE_ICONV!$USE_ICONV$ac_delim
+ICONV_LDFLAGS!$ICONV_LDFLAGS$ac_delim
+CPP!$CPP$ac_delim
+GREP!$GREP$ac_delim
+EGREP!$EGREP$ac_delim
+build!$build$ac_delim
+build_cpu!$build_cpu$ac_delim
+build_vendor!$build_vendor$ac_delim
+build_os!$build_os$ac_delim
+host!$host$ac_delim
+host_cpu!$host_cpu$ac_delim
+host_vendor!$host_vendor$ac_delim
+host_os!$host_os$ac_delim
+PGCONFIG!$PGCONFIG$ac_delim
+PGFEINCLUDES!$PGFEINCLUDES$ac_delim
+PGBEINCLUDES!$PGBEINCLUDES$ac_delim
+PGFELIBS!$PGFELIBS$ac_delim
+PGBELIBS!$PGBELIBS$ac_delim
+PGBIN!$PGBIN$ac_delim
+PGTEMPLATE!$PGTEMPLATE$ac_delim
+LPATH!$LPATH$ac_delim
+PWDREGRESS!$PWDREGRESS$ac_delim
+USE_GEOS!$USE_GEOS$ac_delim
+GEOS_DIR!$GEOS_DIR$ac_delim
+GEOS_LDFLAGS!$GEOS_LDFLAGS$ac_delim
+USE_GEOS_CAPI!$USE_GEOS_CAPI$ac_delim
+GEOSCONFIG!$GEOSCONFIG$ac_delim
+USE_PROJ!$USE_PROJ$ac_delim
+PROJ_DIR!$PROJ_DIR$ac_delim
+PROJ_LIBDIR!$PROJ_LIBDIR$ac_delim
+PROJ!$PROJ$ac_delim
+USE_JTS!$USE_JTS$ac_delim
+JTS_INCLUDES!$JTS_INCLUDES$ac_delim
+JTS_LIBDIR!$JTS_LIBDIR$ac_delim
+JTSCONFIG!$JTSCONFIG$ac_delim
+FLEX!$FLEX$ac_delim
+DLLWRAP!$DLLWRAP$ac_delim
+DLLTOOL!$DLLTOOL$ac_delim
+YACC!$YACC$ac_delim
+YFLAGS!$YFLAGS$ac_delim
+INSTALL!$INSTALL$ac_delim
+PERL!$PERL$ac_delim
+XSLBASE!$XSLBASE$ac_delim
+XSLTPROC!$XSLTPROC$ac_delim
+PDFXMLTEX!$PDFXMLTEX$ac_delim
+DB2PDF!$DB2PDF$ac_delim
+JW!$JW$ac_delim
+DOC_RULE!$DOC_RULE$ac_delim
+PORTNAME!$PORTNAME$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
   fi
-fi # test -n "$CONFIG_FILES"
+done
 
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
 _ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+CEOF$ac_eof
+_ACEOF
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
+DLSUFFIX!$DLSUFFIX$ac_delim
+DLFLAGS!$DLFLAGS$ac_delim
+EXE!$EXE$ac_delim
+HOST_OS!$HOST_OS$ac_delim
+ELF_SYS!$ELF_SYS$ac_delim
+LIBOBJS!$LIBOBJS$ac_delim
+LTLIBOBJS!$LTLIBOBJS$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 7; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+:end
+s/|#_!!_#|//g
+CEOF$ac_eof
+_ACEOF
+
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[	 ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[	 ]*$//
+}'
+fi
+
 cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
-  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
-  case $ac_file in
-  - | *:- | *:-:* ) # input from stdin
-	cat >$tmp/stdin
-	ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  * )   ac_file_in=$ac_file.in ;;
+fi # test -n "$CONFIG_FILES"
+
+
+for ac_tag in  :F $CONFIG_FILES  :H $CONFIG_HEADERS
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
   esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5
+echo "$as_me: error: Invalid tag $ac_tag." >&2;}
+   { (exit 1); exit 1; }; };;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
 
-  # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
-  ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5
+echo "$as_me: error: cannot find input file: $ac_f" >&2;}
+   { (exit 1); exit 1; }; };;
+      esac
+      ac_file_inputs="$ac_file_inputs $ac_f"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input="Generated from "`IFS=:
+	  echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    fi
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin";;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
 $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$ac_file" : 'X\(//\)[^/]' \| \
 	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
 echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-  { if $as_mkdir_p; then
-    mkdir -p "$ac_dir"
-  else
-    as_dir="$ac_dir"
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  { as_dir="$ac_dir"
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {
     as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
-      as_dir=`(dirname "$as_dir") 2>/dev/null ||
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
 $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
 	 X"$as_dir" : 'X\(//\)[^/]' \| \
 	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
 echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
     done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5
+echo "$as_me: error: cannot create directory $as_dir" >&2;}
    { (exit 1); exit 1; }; }; }
-
   ac_builddir=.
 
-if test "$ac_dir" != .; then
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
   ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
-  # A "../" for each directory in $ac_dir_suffix.
-  ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
-  ac_dir_suffix= ac_top_builddir=
-fi
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
 
 case $srcdir in
-  .)  # No --srcdir option.  We are building in place.
+  .)  # We are building in place.
     ac_srcdir=.
-    if test -z "$ac_top_builddir"; then
-       ac_top_srcdir=.
-    else
-       ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
-    fi ;;
-  [\\/]* | ?:[\\/]* )  # Absolute path.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
     ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir ;;
-  *) # Relative path.
-    ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_builddir$srcdir ;;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
 esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
 
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
-  case "$ac_dir" in
-  .) ac_abs_builddir=`pwd`;;
-  [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
-  *) ac_abs_builddir=`pwd`/"$ac_dir";;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
-  case ${ac_top_builddir}. in
-  .) ac_abs_top_builddir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
-  *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
-  case $ac_srcdir in
-  .) ac_abs_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
-  *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
-  esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
-  case $ac_top_srcdir in
-  .) ac_abs_top_srcdir=$ac_abs_builddir;;
-  [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
-  *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
-  esac;;
-esac
 
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
 
+_ACEOF
 
-  if test x"$ac_file" != x-; then
-    { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-    rm -f "$ac_file"
-  fi
-  # Let's still pretend it is `configure' which instantiates (i.e., don't
-  # use $as_me), people would be surprised to read:
-  #    /* config.h.  Generated by config.status.  */
-  if test x"$ac_file" = x-; then
-    configure_input=
-  else
-    configure_input="$ac_file.  "
-  fi
-  configure_input=$configure_input"Generated from `echo $ac_file_in |
-				     sed 's,.*/,,'` by configure."
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
 
-  # First look for the input files in the build tree, otherwise in the
-  # src tree.
-  ac_file_inputs=`IFS=:
-    for f in $ac_file_in; do
-      case $f in
-      -) echo $tmp/stdin ;;
-      [\\/$]*)
-	 # Absolute (can't be DOS-style, as IFS=:)
-	 test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 echo "$f";;
-      *) # Relative
-	 if test -f "$f"; then
-	   # Build tree
-	   echo "$f"
-	 elif test -f "$srcdir/$f"; then
-	   # Source tree
-	   echo "$srcdir/$f"
-	 else
-	   # /dev/null tree
-	   { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 fi;;
-      esac
-    done` || { (exit 1); exit 1; }
+case `sed -n '/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p
+' $ac_file_inputs` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+    s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF
   sed "$ac_vpsub
 $extrasub
 _ACEOF
 cat >>$CONFIG_STATUS <<\_ACEOF
 :t
 /@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s, at configure_input@,$configure_input,;t t
-s, at srcdir@,$ac_srcdir,;t t
-s, at abs_srcdir@,$ac_abs_srcdir,;t t
-s, at top_srcdir@,$ac_top_srcdir,;t t
-s, at abs_top_srcdir@,$ac_abs_top_srcdir,;t t
-s, at builddir@,$ac_builddir,;t t
-s, at abs_builddir@,$ac_abs_builddir,;t t
-s, at top_builddir@,$ac_top_builddir,;t t
-s, at abs_top_builddir@,$ac_abs_top_builddir,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
-  rm -f $tmp/stdin
-  if test x"$ac_file" != x-; then
-    mv $tmp/out $ac_file
-  else
-    cat $tmp/out
-    rm -f $tmp/out
-  fi
+s&@configure_input@&$configure_input&;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+$ac_datarootdir_hack
+" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out
 
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
 
-#
-# CONFIG_HEADER section.
-#
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s,^\([	 ]*\)#\([	 ]*define[	 ][	 ]*\)'
-ac_dB='[	 ].*$,\1#\2'
-ac_dC=' '
-ac_dD=',;t'
-# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_uA='s,^\([	 ]*\)#\([	 ]*\)undef\([	 ][	 ]*\)'
-ac_uB='$,\1#\2define\3'
-ac_uC=' '
-ac_uD=',;t'
-
-for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
-  # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+  rm -f "$tmp/stdin"
   case $ac_file in
-  - | *:- | *:-:* ) # input from stdin
-	cat >$tmp/stdin
-	ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
-	ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
-  * )   ac_file_in=$ac_file.in ;;
+  -) cat "$tmp/out"; rm -f "$tmp/out";;
+  *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;
   esac
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+_ACEOF
 
-  test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
+# Transform confdefs.h into a sed script `conftest.defines', that
+# substitutes the proper values into config.h.in to produce config.h.
+rm -f conftest.defines conftest.tail
+# First, append a space to every undef/define line, to ease matching.
+echo 's/$/ /' >conftest.defines
+# Then, protect against being on the right side of a sed subst, or in
+# an unquoted here document, in config.status.  If some macros were
+# called several times there might be several #defines for the same
+# symbol, which is useless.  But do not sort them, since the last
+# AC_DEFINE must be honored.
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where
+# NAME is the cpp macro being defined, VALUE is the value it is being given.
+# PARAMS is the parameter list in the macro definition--in most cases, it's
+# just an empty string.
+ac_dA='s,^\\([	 #]*\\)[^	 ]*\\([	 ]*'
+ac_dB='\\)[	 (].*,\\1define\\2'
+ac_dC=' '
+ac_dD=' ,'
 
-  # First look for the input files in the build tree, otherwise in the
-  # src tree.
-  ac_file_inputs=`IFS=:
-    for f in $ac_file_in; do
-      case $f in
-      -) echo $tmp/stdin ;;
-      [\\/$]*)
-	 # Absolute (can't be DOS-style, as IFS=:)
-	 test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 # Do quote $f, to prevent DOS paths from being IFS'd.
-	 echo "$f";;
-      *) # Relative
-	 if test -f "$f"; then
-	   # Build tree
-	   echo "$f"
-	 elif test -f "$srcdir/$f"; then
-	   # Source tree
-	   echo "$srcdir/$f"
-	 else
-	   # /dev/null tree
-	   { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
-   { (exit 1); exit 1; }; }
-	 fi;;
-      esac
-    done` || { (exit 1); exit 1; }
-  # Remove the trailing spaces.
-  sed 's/[	 ]*$//' $ac_file_inputs >$tmp/in
+uniq confdefs.h |
+  sed -n '
+	t rset
+	:rset
+	s/^[	 ]*#[	 ]*define[	 ][	 ]*//
+	t ok
+	d
+	:ok
+	s/[\\&,]/\\&/g
+	s/^\('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p
+	s/^\('"$ac_word_re"'\)[	 ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p
+  ' >>conftest.defines
 
-_ACEOF
-
-# Transform confdefs.h into two sed scripts, `conftest.defines' and
-# `conftest.undefs', that substitutes the proper values into
-# config.h.in to produce config.h.  The first handles `#define'
-# templates, and the second `#undef' templates.
-# And first: Protect against being on the right side of a sed subst in
-# config.status.  Protect against being in an unquoted here document
-# in config.status.
-rm -f conftest.defines conftest.undefs
-# Using a here document instead of a string reduces the quoting nightmare.
-# Putting comments in sed scripts is not portable.
-#
-# `end' is used to avoid that the second main sed command (meant for
-# 0-ary CPP macros) applies to n-ary macro definitions.
-# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\_ACEOF
-s/[\\&,]/\\&/g
-s,[\\$`],\\&,g
-t clear
-: clear
-s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 (][^	 (]*\)\(([^)]*)\)[	 ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
-t end
-s,^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 ][^	 ]*\)[	 ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
-: end
-_ACEOF
-# If some macros were called several times there might be several times
-# the same #defines, which is useless.  Nevertheless, we may not want to
-# sort them, since we want the *last* AC-DEFINE to be honored.
-uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
-sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
-rm -f confdef2sed.sed
-
-# This sed command replaces #undef with comments.  This is necessary, for
+# Remove the space that was appended to ease matching.
+# Then replace #undef with comments.  This is necessary, for
 # example, in the case of _POSIX_SOURCE, which is predefined and required
 # on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\_ACEOF
-s,^[	 ]*#[	 ]*undef[	 ][	 ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-_ACEOF
+# (The regexp can be short, since the line contains either #define or #undef.)
+echo 's/ $//
+s,^[	 #]*u.*,/* & */,' >>conftest.defines
 
-# Break up conftest.defines because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo '  # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo '  if grep "^[	 ]*#[	 ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
-echo '  # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
-echo '  :' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.defines >/dev/null
+# Break up conftest.defines:
+ac_max_sed_lines=50
+
+# First sed command is:	 sed -f defines.sed $ac_file_inputs >"$tmp/out1"
+# Second one is:	 sed -f defines.sed "$tmp/out1" >"$tmp/out2"
+# Third one will be:	 sed -f defines.sed "$tmp/out2" >"$tmp/out1"
+# et cetera.
+ac_in='$ac_file_inputs'
+ac_out='"$tmp/out1"'
+ac_nxt='"$tmp/out2"'
+
+while :
 do
-  # Write a limited-size here document to $tmp/defines.sed.
-  echo '  cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
-  # Speed up: don't consider the non `#define' lines.
-  echo '/^[	 ]*#[	 ]*define/!b' >>$CONFIG_STATUS
-  # Work around the forget-to-reset-the-flag bug.
-  echo 't clr' >>$CONFIG_STATUS
-  echo ': clr' >>$CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+  # Write a here document:
+    cat >>$CONFIG_STATUS <<_ACEOF
+    # First, check the format of the line:
+    cat >"\$tmp/defines.sed" <<\\CEOF
+/^[	 ]*#[	 ]*undef[	 ][	 ]*$ac_word_re[	 ]*\$/b def
+/^[	 ]*#[	 ]*define[	 ][	 ]*$ac_word_re[(	 ]/b def
+b
+:def
+_ACEOF
+  sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS
   echo 'CEOF
-  sed -f $tmp/defines.sed $tmp/in >$tmp/out
-  rm -f $tmp/in
-  mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+    sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS
+  ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in
+  sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail
+  grep . conftest.tail >/dev/null || break
   rm -f conftest.defines
   mv conftest.tail conftest.defines
 done
-rm -f conftest.defines
-echo '  fi # grep' >>$CONFIG_STATUS
-echo >>$CONFIG_STATUS
+rm -f conftest.defines conftest.tail
 
-# Break up conftest.undefs because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo '  # Handle all the #undef templates' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.undefs >/dev/null
-do
-  # Write a limited-size here document to $tmp/undefs.sed.
-  echo '  cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
-  # Speed up: don't consider the non `#undef'
-  echo '/^[	 ]*#[	 ]*undef/!b' >>$CONFIG_STATUS
-  # Work around the forget-to-reset-the-flag bug.
-  echo 't clr' >>$CONFIG_STATUS
-  echo ': clr' >>$CONFIG_STATUS
-  sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
-  echo 'CEOF
-  sed -f $tmp/undefs.sed $tmp/in >$tmp/out
-  rm -f $tmp/in
-  mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
-  sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
-  rm -f conftest.undefs
-  mv conftest.tail conftest.undefs
-done
-rm -f conftest.undefs
-
+echo "ac_result=$ac_in" >>$CONFIG_STATUS
 cat >>$CONFIG_STATUS <<\_ACEOF
-  # Let's still pretend it is `configure' which instantiates (i.e., don't
-  # use $as_me), people would be surprised to read:
-  #    /* config.h.  Generated by config.status.  */
-  if test x"$ac_file" = x-; then
-    echo "/* Generated by configure.  */" >$tmp/config.h
-  else
-    echo "/* $ac_file.  Generated by configure.  */" >$tmp/config.h
-  fi
-  cat $tmp/in >>$tmp/config.h
-  rm -f $tmp/in
   if test x"$ac_file" != x-; then
-    if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+    echo "/* $configure_input  */" >"$tmp/config.h"
+    cat "$ac_result" >>"$tmp/config.h"
+    if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then
       { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
 echo "$as_me: $ac_file is unchanged" >&6;}
     else
-      ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_file" : 'X\(//\)[^/]' \| \
-	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-      { if $as_mkdir_p; then
-    mkdir -p "$ac_dir"
-  else
-    as_dir="$ac_dir"
-    as_dirs=
-    while test ! -d "$as_dir"; do
-      as_dirs="$as_dir $as_dirs"
-      as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| \
-	 .     : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
-  	  /^X\(\/\/\)[^/].*/{ s//\1/; q; }
-  	  /^X\(\/\/\)$/{ s//\1/; q; }
-  	  /^X\(\/\).*/{ s//\1/; q; }
-  	  s/.*/./; q'`
-    done
-    test ! -n "$as_dirs" || mkdir $as_dirs
-  fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
-   { (exit 1); exit 1; }; }; }
-
       rm -f $ac_file
-      mv $tmp/config.h $ac_file
+      mv "$tmp/config.h" $ac_file
     fi
   else
-    cat $tmp/config.h
-    rm -f $tmp/config.h
+    echo "/* $configure_input  */"
+    cat "$ac_result"
   fi
-done
-_ACEOF
+  rm -f "$tmp/out12"
+ ;;
 
-cat >>$CONFIG_STATUS <<\_ACEOF
 
+  esac
+
+done # for ac_tag
+
+
 { (exit 0); exit 0; }
 _ACEOF
 chmod +x $CONFIG_STATUS
@@ -5777,69 +6682,69 @@
 fi
 
 
-echo "$as_me:$LINENO: result:  " >&5
-echo "${ECHO_T} " >&6
-echo "$as_me:$LINENO: result:  SUMMARY" >&5
-echo "${ECHO_T} SUMMARY" >&6
-echo "$as_me:$LINENO: result:  -------------------------------------------------------" >&5
-echo "${ECHO_T} -------------------------------------------------------" >&6
-echo "$as_me:$LINENO: result:  " >&5
-echo "${ECHO_T} " >&6
-echo "$as_me:$LINENO: result:  HOST_OS: $host_os" >&5
-echo "${ECHO_T} HOST_OS: $host_os" >&6
-echo "$as_me:$LINENO: result:  " >&5
-echo "${ECHO_T} " >&6
-echo "$as_me:$LINENO: result:    PGSQL: $PGCONFIG" >&5
-echo "${ECHO_T}   PGSQL: $PGCONFIG" >&6
+{ echo "$as_me:$LINENO: result:  " >&5
+echo "${ECHO_T} " >&6; }
+{ echo "$as_me:$LINENO: result:  SUMMARY" >&5
+echo "${ECHO_T} SUMMARY" >&6; }
+{ echo "$as_me:$LINENO: result:  -------------------------------------------------------" >&5
+echo "${ECHO_T} -------------------------------------------------------" >&6; }
+{ echo "$as_me:$LINENO: result:  " >&5
+echo "${ECHO_T} " >&6; }
+{ echo "$as_me:$LINENO: result:  HOST_OS: $host_os" >&5
+echo "${ECHO_T} HOST_OS: $host_os" >&6; }
+{ echo "$as_me:$LINENO: result:  " >&5
+echo "${ECHO_T} " >&6; }
+{ echo "$as_me:$LINENO: result:    PGSQL: $PGCONFIG" >&5
+echo "${ECHO_T}   PGSQL: $PGCONFIG" >&6; }
 
 if test $USE_JTS -gt 0; then
-	echo "$as_me:$LINENO: result:      JTS: includedir=$JTS_INCLUDES libdir=$JTS_LIBDIR" >&5
-echo "${ECHO_T}     JTS: includedir=$JTS_INCLUDES libdir=$JTS_LIBDIR" >&6
+	{ echo "$as_me:$LINENO: result:      JTS: includedir=$JTS_INCLUDES libdir=$JTS_LIBDIR" >&5
+echo "${ECHO_T}     JTS: includedir=$JTS_INCLUDES libdir=$JTS_LIBDIR" >&6; }
 fi
 if test $USE_GEOS -gt 0; then
 	if test $USE_GEOS_CAPI -gt 0; then
-		echo "$as_me:$LINENO: result:     GEOS: $GEOSCONFIG (with C-API)" >&5
-echo "${ECHO_T}    GEOS: $GEOSCONFIG (with C-API)" >&6
+		{ echo "$as_me:$LINENO: result:     GEOS: $GEOSCONFIG (with C-API)" >&5
+echo "${ECHO_T}    GEOS: $GEOSCONFIG (with C-API)" >&6; }
 	else
-		echo "$as_me:$LINENO: result:     GEOS: $GEOSCONFIG" >&5
-echo "${ECHO_T}    GEOS: $GEOSCONFIG" >&6
+		{ echo "$as_me:$LINENO: result:     GEOS: $GEOSCONFIG" >&5
+echo "${ECHO_T}    GEOS: $GEOSCONFIG" >&6; }
 	fi
-        echo "$as_me:$LINENO: result:           (ldflags: $GEOS_LDFLAGS)" >&5
-echo "${ECHO_T}          (ldflags: $GEOS_LDFLAGS)" >&6
+        { echo "$as_me:$LINENO: result:           (ldflags: $GEOS_LDFLAGS)" >&5
+echo "${ECHO_T}          (ldflags: $GEOS_LDFLAGS)" >&6; }
 fi
 if test $USE_PROJ -gt 0; then
-	echo "$as_me:$LINENO: result:     PROJ: prefix=$PROJ_DIR libdir=$PROJ_LIBDIR" >&5
-echo "${ECHO_T}    PROJ: prefix=$PROJ_DIR libdir=$PROJ_LIBDIR" >&6
+	{ echo "$as_me:$LINENO: result:     PROJ: prefix=$PROJ_DIR libdir=$PROJ_LIBDIR" >&5
+echo "${ECHO_T}    PROJ: prefix=$PROJ_DIR libdir=$PROJ_LIBDIR" >&6; }
 fi
-echo "$as_me:$LINENO: result:    ICONV: $USE_ICONV $ICONV_LDFLAGS" >&5
-echo "${ECHO_T}   ICONV: $USE_ICONV $ICONV_LDFLAGS" >&6
+{ echo "$as_me:$LINENO: result:    ICONV: $USE_ICONV $ICONV_LDFLAGS" >&5
+echo "${ECHO_T}   ICONV: $USE_ICONV $ICONV_LDFLAGS" >&6; }
 
-echo "$as_me:$LINENO: result:   " >&5
-echo "${ECHO_T}  " >&6
-echo "$as_me:$LINENO: result:  PORTNAME: $PORTNAME" >&5
-echo "${ECHO_T} PORTNAME: $PORTNAME" >&6
-echo "$as_me:$LINENO: result:    PREFIX: $prefix" >&5
-echo "${ECHO_T}   PREFIX: $prefix" >&6
-echo "$as_me:$LINENO: result:   EPREFIX: $exec_prefix" >&5
-echo "${ECHO_T}  EPREFIX: $exec_prefix" >&6
-echo "$as_me:$LINENO: result:       DOC: $docdir" >&5
-echo "${ECHO_T}      DOC: $docdir" >&6
-echo "$as_me:$LINENO: result:      DATA: $datadir" >&5
-echo "${ECHO_T}     DATA: $datadir" >&6
-echo "$as_me:$LINENO: result:       MAN: $mandir" >&5
-echo "${ECHO_T}      MAN: $mandir" >&6
-echo "$as_me:$LINENO: result:       BIN: $bindir" >&5
-echo "${ECHO_T}      BIN: $bindir" >&6
+{ echo "$as_me:$LINENO: result:   " >&5
+echo "${ECHO_T}  " >&6; }
+{ echo "$as_me:$LINENO: result:  PORTNAME: $PORTNAME" >&5
+echo "${ECHO_T} PORTNAME: $PORTNAME" >&6; }
+{ echo "$as_me:$LINENO: result:    PREFIX: $prefix" >&5
+echo "${ECHO_T}   PREFIX: $prefix" >&6; }
+{ echo "$as_me:$LINENO: result:   EPREFIX: $exec_prefix" >&5
+echo "${ECHO_T}  EPREFIX: $exec_prefix" >&6; }
+{ echo "$as_me:$LINENO: result:       DOC: $docdir" >&5
+echo "${ECHO_T}      DOC: $docdir" >&6; }
+{ echo "$as_me:$LINENO: result:      DATA: $datadir" >&5
+echo "${ECHO_T}     DATA: $datadir" >&6; }
+{ echo "$as_me:$LINENO: result:       MAN: $mandir" >&5
+echo "${ECHO_T}      MAN: $mandir" >&6; }
+{ echo "$as_me:$LINENO: result:       BIN: $bindir" >&5
+echo "${ECHO_T}      BIN: $bindir" >&6; }
 if test "$MODULE_INSTALLDIR" = "$LPATH"; then
-	echo "$as_me:$LINENO: result:       EXT: $libdir" >&5
-echo "${ECHO_T}      EXT: $libdir" >&6
+	{ echo "$as_me:$LINENO: result:       EXT: $libdir" >&5
+echo "${ECHO_T}      EXT: $libdir" >&6; }
 else
-	echo "$as_me:$LINENO: result:       EXT: $libdir ($LPATH)" >&5
-echo "${ECHO_T}      EXT: $libdir ($LPATH)" >&6
+	{ echo "$as_me:$LINENO: result:       EXT: $libdir ($LPATH)" >&5
+echo "${ECHO_T}      EXT: $libdir ($LPATH)" >&6; }
 fi
 
-echo "$as_me:$LINENO: result:  -------------------------------------------------------" >&5
-echo "${ECHO_T} -------------------------------------------------------" >&6
-echo "$as_me:$LINENO: result:  " >&5
-echo "${ECHO_T} " >&6
+{ echo "$as_me:$LINENO: result:  -------------------------------------------------------" >&5
+echo "${ECHO_T} -------------------------------------------------------" >&6; }
+{ echo "$as_me:$LINENO: result:  " >&5
+echo "${ECHO_T} " >&6; }
 

Modified: packages/postgis/upstream/configure.in
===================================================================
--- packages/postgis/upstream/configure.in	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/configure.in	2007-04-13 07:15:27 UTC (rev 758)
@@ -147,7 +147,16 @@
 
 if test $USE_GEOS -gt 0; then
 	GEOS_DIR=`$GEOSCONFIG --prefix`
-	GEOS_LDFLAGS=`$GEOSCONFIG --ldflags`
+
+	GEOS_LDFLAGS=`$GEOSCONFIG --ldflags 2> /dev/null`
+	if test x"$GEOS_LDFLAGS" = "x"; then
+		# older geos-config versions did not
+		# support the --ldflags switch, we'll
+		# default to GEOS_DIR/lib in this case.
+		#
+		GEOS_LDFLAGS="-L${GEOS_DIR}/lib"
+	fi
+
 	GEOS_MAJOR=`$GEOSCONFIG --version | cut -d. -f1`
 	if test "$GEOS_MAJOR" = "@GEOS_VERSION@"; then
 		GEOS_MAJOR=1

Modified: packages/postgis/upstream/doc/html/postgis.html
===================================================================
--- packages/postgis/upstream/doc/html/postgis.html	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/doc/html/postgis.html	2007-04-13 07:15:27 UTC (rev 758)
@@ -2,11 +2,12 @@
       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.6"></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="id2680245"></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
+      processing of GIS objects. This is the manual for version 1.2.1"></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="id2695011"></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.6</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="#id2682230">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="#id2682060">1.2. More Information</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2709347">2. Installation</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2709353">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="#templatepostgis">2.2.1. Creating PostGIS spatially-enabled databases from an in-built template</a></span></dt><dt><span class="sect2"><a href="#upgrading">2.2.2. Upgrading</a></span></dt><dt><span class="sect2"><a href="#id2681276">2.2.3. Common Problems</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2749646">2.3. JDBC</a></span></dt><dt><span class="sect1"><a href="#id2749723">2.4. Loader/Dumper</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2749763">3. Frequently Asked Questions</a></span></dt><dt><span class="chapter"><a href="#id2750223">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="#id2750250">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="#id2750358">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2750514">4.2. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2750547">4.2.1. The SPATIAL_REF_SYS Table</a></span></dt><dt><span class="sect2"><a href="#id2750749">4.2.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="#id2750882">4.2.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="#id2750989">4.2.4. Ensuring OpenGIS compliancy of geometries</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2751072">4.3. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2751085">4.3.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2751141">4.3.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2751371">4.4. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2751384">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2680553">4.4.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2751855">4.5. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2751908">4.5.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="#id2751976">4.5.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2752095">4.6. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2752113">4.6.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="#id2752209">4.6.2. Examples of Spatial SQL</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2752525">4.7. Using Mapserver</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2752567">4.7.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="#id2752816">4.7.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="#id2752983">4.7.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="#id2753142">4.7.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2753248">4.8. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="#id2753329">4.9. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2753338">4.9.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="#id2753348">4.9.2. Binary Cursors</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id2753360">5. Performance tips</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2753366">5.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2753372">5.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="#id2753430">5.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2753491">5.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="#id2753547">5.3. Avoiding dimension conversion</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2753590">6. PostGIS Reference</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2753603">6.1. OpenGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2753609">6.1.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2753699">6.1.2. Geometry Relationship Functions</a></span></dt><dt><span class="sect2"><a href="#id2754075">6.1.3. Geometry Processing Functions</a></span></dt><dt><span class="sect2"><a href="#id2754401">6.1.4. Geometry Accessors</a></span></dt><dt><span class="sect2"><a href="#id2754887">6.1.5. Geometry Constructors</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2755490">6.2. Postgis Extensions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2755496">6.2.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2755821">6.2.2. Operators</a></span></dt><dt><span class="sect2"><a href="#id2756028">6.2.3. Measurement Functions</a></span></dt><dt><span class="sect2"><a href="#id2756312">6.2.4. Geometry Outputs</a></span></dt><dt><span class="sect2"><a href="#id2756420">6.2.5. Geometry Constructors</a></span></dt><dt><span class="sect2"><a href="#id2756753">6.2.6. Geometry Editors</a></span></dt><dt><span class="sect2"><a href="#id2757354">6.2.7. Linear Referencing</a></span></dt><dt><span class="sect2"><a href="#id2757573">6.2.8. Misc</a></span></dt><dt><span class="sect2"><a href="#id2758572">6.2.9. Long Transactions support</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id2758155">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="#id2758225">A.1. Release Notes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2758231">A.1.1. Release 1.1.6</a></span></dt><dt><span class="sect2"><a href="#id2758351">A.1.2. Release 1.1.5</a></span></dt><dt><span class="sect2"><a href="#id2758466">A.1.3. Release 1.1.4</a></span></dt><dt><span class="sect2"><a href="#id2758750">A.1.4. Release 1.1.3</a></span></dt><dt><span class="sect2"><a href="#id2758916">A.1.5. Release 1.1.2</a></span></dt><dt><span class="sect2"><a href="#id2759048">A.1.6. Release 1.1.1</a></span></dt><dt><span class="sect2"><a href="#id2759178">A.1.7. Release 1.1.0</a></span></dt><dt><span class="sect2"><a href="#id2759504">A.1.8. Release 1.0.6</a></span></dt><dt><span class="sect2"><a href="#id2759612">A.1.9. Release 1.0.5</a></span></dt><dt><span class="sect2"><a href="#id2759744">A.1.10. Release 1.0.4</a></span></dt><dt><span class="sect2"><a href="#rel_1.0.3_upgrading">A.1.11. Release 1.0.3</a></span></dt><dt><span class="sect2"><a href="#id2759991">A.1.12. Release 1.0.2</a></span></dt><dt><span class="sect2"><a href="#id2760069">A.1.13. Release 1.0.1</a></span></dt><dt><span class="sect2"><a href="#id2760169">A.1.14. Release 1.0.0</a></span></dt><dt><span class="sect2"><a href="#id2760268">A.1.15. Release 1.0.0RC6</a></span></dt><dt><span class="sect2"><a href="#id2760342">A.1.16. Release 1.0.0RC5</a></span></dt><dt><span class="sect2"><a href="#id2760414">A.1.17. Release 1.0.0RC4</a></span></dt><dt><span class="sect2"><a href="#id2760539">A.1.18. Release 1.0.0RC3</a></span></dt><dt><span class="sect2"><a href="#id2760710">A.1.19. Release 1.0.0RC2</a></span></dt><dt><span class="sect2"><a href="#id2760809">A.1.20. 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="id2682230"></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="#id2682060">1.2. More Information</a></span></dt></dl></div><p>PostGIS is developed by Refractions Research Inc, as a spatial
+      processing of GIS objects.</p><p>This is the manual for version 1.2.1</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="#id2695940">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="#id2695778">1.2. More Information</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2723071">2. Installation</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2723077">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="#templatepostgis">2.2.1. Creating PostGIS spatially-enabled databases from an in-built
+        template</a></span></dt><dt><span class="sect2"><a href="#upgrading">2.2.2. Upgrading</a></span></dt><dt><span class="sect2"><a href="#id2763269">2.2.3. Common Problems</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2763415">2.3. JDBC</a></span></dt><dt><span class="sect1"><a href="#id2763491">2.4. Loader/Dumper</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2763531">3. Frequently Asked Questions</a></span></dt><dt><span class="chapter"><a href="#id2764010">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="#id2764042">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="#id2764151">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt><dt><span class="sect2"><a href="#id2764316">4.1.3. SQL-MM Part 3</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2764400">4.2. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2764441">4.2.1. The SPATIAL_REF_SYS Table</a></span></dt><dt><span class="sect2"><a href="#id2764652">4.2.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="#id2764797">4.2.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="#id2764911">4.2.4. Ensuring OpenGIS compliancy of geometries</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2765010">4.3. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2765024">4.3.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2765088">4.3.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2765328">4.4. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2765341">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2765514">4.4.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2765691">4.5. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2765757">4.5.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="#id2765837">4.5.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2765955">4.6. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2765973">4.6.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="#id2766061">4.6.2. Examples of Spatial SQL</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2766374">4.7. Using Mapserver</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2766416">4.7.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="#id2766674">4.7.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="#id2766856">4.7.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="#id2767038">4.7.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2767148">4.8. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="#id2767233">4.9. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2767242">4.9.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="#id2767252">4.9.2. Binary Cursors</a></span></dt></dl></dd></dl></dd><dt><span class="chapter"><a href="#id2767264">5. Performance tips</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2767270">5.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2767276">5.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="#id2767350">5.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2767434">5.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="#id2767496">5.3. Avoiding dimension conversion</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2767560">6. PostGIS Reference</a></span></dt><dd><dl><dt><span class="sect1"><a href="#id2767572">6.1. OpenGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2767578">6.1.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2767667">6.1.2. Geometry Relationship Functions</a></span></dt><dt><span class="sect2"><a href="#id2768066">6.1.3. Geometry Processing Functions</a></span></dt><dt><span class="sect2"><a href="#id2768393">6.1.4. Geometry Accessors</a></span></dt><dt><span class="sect2"><a href="#id2768904">6.1.5. Geometry Constructors</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2769510">6.2. Postgis Extensions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2769516">6.2.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2769855">6.2.2. Operators</a></span></dt><dt><span class="sect2"><a href="#id2770079">6.2.3. Measurement Functions</a></span></dt><dt><span class="sect2"><a href="#id2770368">6.2.4. Geometry Outputs</a></span></dt><dt><span class="sect2"><a href="#id2770508">6.2.5. Geometry Constructors</a></span></dt><dt><span class="sect2"><a href="#id2770859">6.2.6. Geometry Editors</a></span></dt><dt><span class="sect2"><a href="#id2771471">6.2.7. Linear Referencing</a></span></dt><dt><span class="sect2"><a href="#id2771698">6.2.8. Misc</a></span></dt><dt><span class="sect2"><a href="#id2772712">6.2.9. Long Transactions support</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2772297">6.3. SQL-MM Functions</a></span></dt><dt><span class="sect1"><a href="#id2773715">6.4. ArcSDE Functions</a></span></dt></dl></dd><dt><span class="chapter"><a href="#id2773833">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="#id2773913">A.1. Release Notes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2773918">A.1.1. Release 1.2.1</a></span></dt><dt><span class="sect2"><a href="#id2773964">A.1.2. Release 1.2.0</a></span></dt><dt><span class="sect2"><a href="#id2773998">A.1.3. Release 1.1.6</a></span></dt><dt><span class="sect2"><a href="#id2774117">A.1.4. Release 1.1.5</a></span></dt><dt><span class="sect2"><a href="#id2774231">A.1.5. Release 1.1.4</a></span></dt><dt><span class="sect2"><a href="#id2774358">A.1.6. Release 1.1.3</a></span></dt><dt><span class="sect2"><a href="#id2774525">A.1.7. Release 1.1.2</a></span></dt><dt><span class="sect2"><a href="#id2774658">A.1.8. Release 1.1.1</a></span></dt><dt><span class="sect2"><a href="#id2774789">A.1.9. Release 1.1.0</a></span></dt><dt><span class="sect2"><a href="#id2775120">A.1.10. Release 1.0.6</a></span></dt><dt><span class="sect2"><a href="#id2775228">A.1.11. Release 1.0.5</a></span></dt><dt><span class="sect2"><a href="#id2775363">A.1.12. Release 1.0.4</a></span></dt><dt><span class="sect2"><a href="#rel_1.0.3_upgrading">A.1.13. Release 1.0.3</a></span></dt><dt><span class="sect2"><a href="#id2775629">A.1.14. Release 1.0.2</a></span></dt><dt><span class="sect2"><a href="#id2775707">A.1.15. Release 1.0.1</a></span></dt><dt><span class="sect2"><a href="#id2775809">A.1.16. Release 1.0.0</a></span></dt><dt><span class="sect2"><a href="#id2775909">A.1.17. Release 1.0.0RC6</a></span></dt><dt><span class="sect2"><a href="#id2775982">A.1.18. Release 1.0.0RC5</a></span></dt><dt><span class="sect2"><a href="#id2776055">A.1.19. Release 1.0.0RC4</a></span></dt><dt><span class="sect2"><a href="#id2776181">A.1.20. Release 1.0.0RC3</a></span></dt><dt><span class="sect2"><a href="#id2776354">A.1.21. Release 1.0.0RC2</a></span></dt><dt><span class="sect2"><a href="#id2776453">A.1.22. 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="id2695940"></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="#id2695778">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
@@ -15,161 +16,141 @@
     (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
+            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>
+            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="id2682060"></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
+            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="id2695778"></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="id2709347"></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="#id2709353">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="#templatepostgis">2.2.1. Creating PostGIS spatially-enabled databases from an in-built template</a></span></dt><dt><span class="sect2"><a href="#upgrading">2.2.2. Upgrading</a></span></dt><dt><span class="sect2"><a href="#id2681276">2.2.3. Common Problems</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2749646">2.3. JDBC</a></span></dt><dt><span class="sect1"><a href="#id2749723">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="id2709353"></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
+          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="id2723071"></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="#id2723077">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="#templatepostgis">2.2.1. Creating PostGIS spatially-enabled databases from an in-built
+        template</a></span></dt><dt><span class="sect2"><a href="#upgrading">2.2.2. Upgrading</a></span></dt><dt><span class="sect2"><a href="#id2763269">2.2.3. Common Problems</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2763415">2.3. JDBC</a></span></dt><dt><span class="sect1"><a href="#id2763491">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="id2723077"></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
+          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.6
-      <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.6 can be built against PostgreSQL
+      server. As such, PostGIS 1.2.1 <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.2.1 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
+            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.6.tar.gz" target="_top">http://postgis.refractions.net/postgis-1.1.6.tar.gz</a>.
-          Uncompress and untar the archive.
-	  </p><pre class="programlisting"># gzip -d -c postgis-1.1.6.tar.gz | tar xvf -</pre></li><li><p>Enter the postgis-1.1.6 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
+            course.</p></div></li><li><p>Retrieve the PostGIS source archive from <a href="http://postgis.refractions.net/postgis-1.2.1.tar.gz" target="_top">http://postgis.refractions.net/postgis-1.2.1.tar.gz</a>.
+          Uncompress and untar the archive.</p><pre class="programlisting"># gzip -d -c postgis-1.2.1.tar.gz
+          | tar xvf -</pre></li><li><p>Enter the postgis-1.2.1 directory, and run:
+          </p><pre class="programlisting"># ./configure</pre><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="templatepostgis"></a>2.2.1. Creating PostGIS spatially-enabled databases from an in-built template</h3></div></div><div></div></div><p>Some packaged distributions of PostGIS (in particular the Win32 installers for PostGIS &gt;= 1.1.5) load the PostGIS functions into a template database called <tt class="varname">template_postgis</tt>. If the <tt class="varname">template_postgis</tt> database exists in your PostgreSQL installation then it is possible for users and/or applications to create spatially-enabled databases using a single command. Note that in both cases, the database user must have been granted the privilege to create new databases.</p><p>From the shell:</p><pre class="programlisting"># createdb -T template_postgis my_spatial_db</pre><p>From SQL:</p><pre class="programlisting">postgres=# CREATE DATABASE my_spatial_db TEMPLATE=template_postgis</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="upgrading"></a>2.2.2. 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.2.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.2.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:
+          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="templatepostgis"></a>2.2.1. Creating PostGIS spatially-enabled databases from an in-built
+        template</h3></div></div><div></div></div><p>Some packaged distributions of PostGIS (in particular the Win32
+        installers for PostGIS &gt;= 1.1.5) load the PostGIS functions into a
+        template database called <tt class="varname">template_postgis</tt>. If the
+        <tt class="varname">template_postgis</tt> database exists in your PostgreSQL
+        installation then it is possible for users and/or applications to
+        create spatially-enabled databases using a single command. Note that
+        in both cases, the database user must have been granted the privilege
+        to create new databases.</p><p>From the shell:</p><pre class="programlisting"># createdb -T template_postgis my_spatial_db</pre><p>From SQL:</p><pre class="programlisting">postgres=# CREATE DATABASE my_spatial_db
+        TEMPLATE=template_postgis</pre></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="upgrading"></a>2.2.2. 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.2.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.2.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><p>
+	  Create a "custom-format" dump of the database you want
+	  to upgrade (let's call it "olddb")
+	  </p><pre class="programlisting">
+$ pg_dump -Fc olddb &gt; olddb.dump
+	</pre><p>
+Restore the dump contextually upgrading postgis into a new database. The
+new database doesn't have to exist.  postgis_restore accepts createdb
+parameters after the dump file name, and that can for instance be used
+if you are using a non-default character encoding for your database.
+Let's call it "newdb", with UNICODE as the character encoding:
 	</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="id2681276"></a>2.2.3. Common Problems</h3></div></div><div></div></div><p>There are several things to check when your installation or
+$ sh utils/postgis_restore.pl lwpostgis.sql newdb olddb.dump -E=UNICODE &gt; restore.log
+	  </pre><p>
+Check that all restored dump objects really had to be restored from dump 
+and do not conflict with the ones defined in lwpostgis.sql
+	</p><pre class="programlisting">
+$ grep ^KEEPING restore.log | less
+	</pre><p>
+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 !
+	</p><pre class="programlisting">
+$ 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"
+	</pre><p>
+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:
+	</p><pre class="programlisting">
+$ 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="id2763269"></a>2.2.3. 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
@@ -196,9 +177,8 @@
             <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="id2749646"></a>2.3. JDBC</h2></div></div><div></div></div><p>The JDBC extensions provide Java objects corresponding to 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="id2763415"></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
@@ -206,62 +186,58 @@
           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="id2749723"></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.6/loader 
-# make
-# make install</pre><p>The loader is called <tt class="filename">shp2pgsql</tt> and converts
+          libraries.</p></li></ol></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2763491"></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.2.1/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. For more verbose documentation,
-      see the online help, and the manual pages.</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2749763"></a>Chapter 3. Frequently Asked Questions</h2></div></div><div></div></div><div class="qandaset"><dl><dt>3.1. <a href="#id2749771">What kind of geometric objects can I store?</a></dt><dt>3.2. <a href="#id2749791">How do I insert a GIS object into the database?</a></dt><dt>3.3. <a href="#id2749887">How do I construct a spatial query?</a></dt><dt>3.4. <a href="#id2749952">How do I speed up spatial queries on large tables?</a></dt><dt>3.5. <a href="#id2750034">Why aren't PostgreSQL R-Tree indexes supported?</a></dt><dt>3.6. <a href="#id2750086">Why should I use the AddGeometryColumn()
-          function and all the other OpenGIS stuff?</a></dt><dt>3.7. <a href="#id2750134">What is the best way to find all objects within a radius of
-          another object?</a></dt><dt>3.8. <a href="#id2750186">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="id2749771"></a><a name="id2749773"></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,
+      tables (or queries) into ESRI Shape files. For more verbose
+      documentation, see the online help, and the manual pages.</p></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2763531"></a>Chapter 3. Frequently Asked Questions</h2></div></div><div></div></div><div class="qandaset"><dl><dt>3.1. <a href="#id2763539">What kind of geometric objects can I store?</a></dt><dt>3.2. <a href="#id2763560">How do I insert a GIS object into the database?</a></dt><dt>3.3. <a href="#id2763666">How do I construct a spatial query?</a></dt><dt>3.4. <a href="#id2763736">How do I speed up spatial queries on large tables?</a></dt><dt>3.5. <a href="#id2763824">Why aren't PostgreSQL R-Tree indexes supported?</a></dt><dt>3.6. <a href="#id2763883">Why should I use the AddGeometryColumn()
+          function and all the other OpenGIS stuff?</a></dt><dt>3.7. <a href="#id2763930">What is the best way to find all objects within a radius of
+          another object?</a></dt><dt>3.8. <a href="#id2763979">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="id2763539"></a><a name="id2763542"></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="id2749791"></a><a name="id2749793"></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
+          Open GIS Well Known Text Format (with XYZ,XYM,XYZM extentions).</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2763560"></a><a name="id2763562"></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="id2749887"></a><a name="id2749889"></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
+          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="id2763666"></a><a name="id2763669"></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
+          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="id2749952"></a><a name="id2749954"></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
+          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="id2763736"></a><a name="id2763738"></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
+          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="id2750034"></a><a name="id2750036"></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.
+          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="id2763824"></a><a name="id2763826"></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
@@ -269,23 +245,22 @@
           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="id2750086"></a><a name="id2750089"></a><b>3.6.</b></td><td align="left" valign="top"><p>Why should I use the <tt class="varname">AddGeometryColumn()</tt>
+              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="id2763883"></a><a name="id2763885"></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
+          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="id2750134"></a><a name="id2750136"></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
+          reprojection of features into the correct map projection.</p></td></tr><tr class="question"><td align="left" valign="top"><a name="id2763930"></a><a name="id2763933"></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
@@ -294,365 +269,307 @@
           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="id2750186"></a><a name="id2750188"></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
+          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="id2763979"></a><a name="id2763981"></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="id2750223"></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="#id2750250">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="#id2750358">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2750514">4.2. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2750547">4.2.1. The SPATIAL_REF_SYS Table</a></span></dt><dt><span class="sect2"><a href="#id2750749">4.2.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="#id2750882">4.2.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="#id2750989">4.2.4. Ensuring OpenGIS compliancy of geometries</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2751072">4.3. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2751085">4.3.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2751141">4.3.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2751371">4.4. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2751384">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2680553">4.4.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2751855">4.5. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2751908">4.5.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="#id2751976">4.5.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2752095">4.6. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2752113">4.6.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="#id2752209">4.6.2. Examples of Spatial SQL</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2752525">4.7. Using Mapserver</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2752567">4.7.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="#id2752816">4.7.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="#id2752983">4.7.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="#id2753142">4.7.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2753248">4.8. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="#id2753329">4.9. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2753338">4.9.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="#id2753348">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="id2750250"></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="id2750358"></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="id2750514"></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="id2750547"></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
+          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="id2764010"></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="#id2764042">4.1.1. OpenGIS WKB and WKT</a></span></dt><dt><span class="sect2"><a href="#id2764151">4.1.2. PostGIS EWKB, EWKT and Canonical Forms</a></span></dt><dt><span class="sect2"><a href="#id2764316">4.1.3. SQL-MM Part 3</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2764400">4.2. Using OpenGIS Standards</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2764441">4.2.1. The SPATIAL_REF_SYS Table</a></span></dt><dt><span class="sect2"><a href="#id2764652">4.2.2. The GEOMETRY_COLUMNS Table</a></span></dt><dt><span class="sect2"><a href="#id2764797">4.2.3. Creating a Spatial Table</a></span></dt><dt><span class="sect2"><a href="#id2764911">4.2.4. Ensuring OpenGIS compliancy of geometries</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2765010">4.3. Loading GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2765024">4.3.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2765088">4.3.2. Using the Loader</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2765328">4.4. Retrieving GIS Data</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2765341">4.4.1. Using SQL</a></span></dt><dt><span class="sect2"><a href="#id2765514">4.4.2. Using the Dumper</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2765691">4.5. Building Indexes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2765757">4.5.1. GiST Indexes</a></span></dt><dt><span class="sect2"><a href="#id2765837">4.5.2. Using Indexes</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2765955">4.6. Complex Queries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2765973">4.6.1. Taking Advantage of Indexes</a></span></dt><dt><span class="sect2"><a href="#id2766061">4.6.2. Examples of Spatial SQL</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2766374">4.7. Using Mapserver</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2766416">4.7.1. Basic Usage</a></span></dt><dt><span class="sect2"><a href="#id2766674">4.7.2. Frequently Asked Questions</a></span></dt><dt><span class="sect2"><a href="#id2766856">4.7.3. Advanced Usage</a></span></dt><dt><span class="sect2"><a href="#id2767038">4.7.4. Examples</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2767148">4.8. Java Clients (JDBC)</a></span></dt><dt><span class="sect1"><a href="#id2767233">4.9. C Clients (libpq)</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2767242">4.9.1. Text Cursors</a></span></dt><dt><span class="sect2"><a href="#id2767252">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="id2764042"></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="id2764151"></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>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 class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2764316"></a>4.1.3. SQL-MM Part 3</h3></div></div><div></div></div><p>The SQL Multimedia Applications Spatial specification extends
+        the simple features for SQL spec by defining a number of circularly
+        interpolated curves.</p><p>The SQL-MM definitions include 3dm, 3dz and 4d coordinates, but
+        do not allow the embedding of SRID information.</p><p>The well-known text extensions are not yet fully supported.
+        Examples of some simple curved geometries are shown below:</p><div class="itemizedlist"><ul type="disc"><li><p>CIRCULARSTRING(0 0, 1 1, 1 0)</p></li><li><p>COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 1 0),(1 0, 0 1))</p></li><li><p>CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0),(1 1, 3
+            3, 3 1, 1 1))</p></li><li><p>MULTICURVE((0 0, 5 5),CIRCULARSTRING(4 0, 4 4, 8 4))</p></li><li><p>MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4,
+            0 0),(1 1, 3 3, 3 1, 1 1)),((10 10, 14 12, 11 10, 10 10),(11 11,
+            11.5 11, 11 11.5, 11 11)))</p></li></ul></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Currently, PostGIS cannot support the use of Compound Curves
+          in a Curve Polygon.</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>All floating point comparisons within the SQL-MM
+          implementation are performed to a specified tolerance, currently
+          1E-8.</p></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2764400"></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="id2764441"></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
+              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
+              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 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
+              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="id2750749"></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
+              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="id2764652"></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="id2750882"></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,
+              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="id2764797"></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;,
+            "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>
-
-	    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="id2750989"></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="id2751072"></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
+            &lt;dimension&gt;)</pre><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="id2764911"></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="id2765010"></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="id2751085"></a>4.3.1. Using SQL</h3></div></div><div></div></div><p>If you can convert your data to a text representation, then
+      Shape file loader/dumper.</p><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2765024"></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="id2751141"></a>4.3.2. Using the Loader</h3></div></div><div></div></div><p>The <tt class="filename">shp2pgsql</tt> data loader converts ESRI
+        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="id2765088"></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 
+              <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
+              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="id2751371"></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
+              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="id2765328"></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="id2751384"></a>4.4.1. Using SQL</h3></div></div><div></div></div><p>The most straightforward means of pulling data out of the
+      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="id2765341"></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
+        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
+              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
+        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="id2680553"></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
+        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="id2765514"></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
+              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="id2751855"></a>4.5. Building Indexes</h2></div></div><div></div></div><p>Indexes are what make using a spatial database for large data sets
+              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="id2765691"></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;
+      "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="id2751908"></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
+          "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="id2765757"></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
+        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="id2751976"></a>4.5.2. Using Indexes</h3></div></div><div></div></div><p>Ordinarily, indexes invisibly speed up data access: once the
+        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="id2765837"></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
@@ -663,546 +580,389 @@
             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
+            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="id2752095"></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
+            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="id2765955"></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="id2752113"></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
+      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="id2765973"></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
+        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
+        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="id2752209"></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
+        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="id2766061"></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="#id2752256">What is the total length of all roads, expressed in
-                kilometers?</a></dt><dt>4.6.2.2. <a href="#id2752283">How large is the city of Prince George, in
-                hectares?</a></dt><dt>4.6.2.3. <a href="#id2752312">What is the largest municipality in the province, by
-                area?</a></dt><dt>4.6.2.4. <a href="#id2752354">What is the length of roads fully contained within each
-                municipality?</a></dt><dt>4.6.2.5. <a href="#id2752416">Create a new table with all the roads within the city of
-                Prince George.</a></dt><dt>4.6.2.6. <a href="#id2752455">What is the length in kilometers of "Douglas St" in
-                Victoria?</a></dt><dt>4.6.2.7. <a href="#id2752489">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="id2752256"></a><a name="id2752258"></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="id2752283"></a><a name="id2752285"></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="id2752312"></a><a name="id2752314"></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="id2752354"></a><a name="id2752356"></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="id2752416"></a><a name="id2752418"></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="id2752455"></a><a name="id2752457"></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="id2752489"></a><a name="id2752491"></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="id2752525"></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="id2752567"></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
+        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="#id2766106">What is the total length of all roads, expressed in
+              kilometers?</a></dt><dt>4.6.2.2. <a href="#id2766133">How large is the city of Prince George, in hectares?</a></dt><dt>4.6.2.3. <a href="#id2766161">What is the largest municipality in the province, by area?</a></dt><dt>4.6.2.4. <a href="#id2766207">What is the length of roads fully contained within each
+              municipality?</a></dt><dt>4.6.2.5. <a href="#id2766268">Create a new table with all the roads within the city of
+              Prince George.</a></dt><dt>4.6.2.6. <a href="#id2766306">What is the length in kilometers of "Douglas St"
+              in Victoria?</a></dt><dt>4.6.2.7. <a href="#id2766338">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="id2766106"></a><a name="id2766108"></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="id2766133"></a><a name="id2766135"></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="id2766161"></a><a name="id2766164"></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="id2766207"></a><a name="id2766209"></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="id2766268"></a><a name="id2766270"></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="id2766306"></a><a name="id2766308"></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="id2766338"></a><a name="id2766340"></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="id2766374"></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="id2766416"></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
+        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
+            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
+                  '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
+                  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="id2752816"></a>4.7.2. Frequently Asked Questions</h3></div></div><div></div></div><div class="qandaset"><dl><dt>4.7.2.1. <a href="#id2752824">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="#id2752858">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="#id2752886">My PostGIS layer draws much slower than my Shape file
-                layer, is this normal?</a></dt><dt>4.7.2.4. <a href="#id2752925">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="id2752824"></a><a name="id2752826"></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="id2752858"></a><a name="id2752860"></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="id2752886"></a><a name="id2752888"></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="id2752925"></a><a name="id2752927"></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="id2752983"></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
+            <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="id2766674"></a>4.7.2. Frequently Asked Questions</h3></div></div><div></div></div><div class="qandaset"><dl><dt>4.7.2.1. <a href="#id2766682">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="#id2766716">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="#id2766745">My PostGIS layer draws much slower than my Shape file
+              layer, is this normal?</a></dt><dt>4.7.2.4. <a href="#id2766784">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="id2766682"></a><a name="id2766684"></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="id2766716"></a><a name="id2766718"></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="id2766745"></a><a name="id2766748"></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="id2766784"></a><a name="id2766786"></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="id2766856"></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
+        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
+              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
+              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
+              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="id2753142"></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
+          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="id2767038"></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,
+        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
+        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="id2753248"></a>4.8. Java Clients (JDBC)</h2></div></div><div></div></div><p>Java clients can access PostGIS "geometry" objects in the
+        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="id2767148"></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. 
-      */
+      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
+      /* * 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="id2753329"></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="id2753338"></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="id2753348"></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="id2753360"></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="#id2753366">5.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2753372">5.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="#id2753430">5.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2753491">5.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="#id2753547">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="id2753366"></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="id2753372"></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="id2753430"></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="id2753491"></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="id2753547"></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="id2753590"></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="#id2753603">6.1. OpenGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2753609">6.1.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2753699">6.1.2. Geometry Relationship Functions</a></span></dt><dt><span class="sect2"><a href="#id2754075">6.1.3. Geometry Processing Functions</a></span></dt><dt><span class="sect2"><a href="#id2754401">6.1.4. Geometry Accessors</a></span></dt><dt><span class="sect2"><a href="#id2754887">6.1.5. Geometry Constructors</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2755490">6.2. Postgis Extensions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2755496">6.2.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2755821">6.2.2. Operators</a></span></dt><dt><span class="sect2"><a href="#id2756028">6.2.3. Measurement Functions</a></span></dt><dt><span class="sect2"><a href="#id2756312">6.2.4. Geometry Outputs</a></span></dt><dt><span class="sect2"><a href="#id2756420">6.2.5. Geometry Constructors</a></span></dt><dt><span class="sect2"><a href="#id2756753">6.2.6. Geometry Editors</a></span></dt><dt><span class="sect2"><a href="#id2757354">6.2.7. Linear Referencing</a></span></dt><dt><span class="sect2"><a href="#id2757573">6.2.8. Misc</a></span></dt><dt><span class="sect2"><a href="#id2758572">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
+      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="id2767233"></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="id2767242"></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="id2767252"></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="id2767264"></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="#id2767270">5.1. Small tables of large geometries</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2767276">5.1.1. Problem description</a></span></dt><dt><span class="sect2"><a href="#id2767350">5.1.2. Workarounds</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2767434">5.2. CLUSTERing on geometry indices</a></span></dt><dt><span class="sect1"><a href="#id2767496">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="id2767270"></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="id2767276"></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="id2767350"></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="id2767434"></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="id2767496"></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="id2767560"></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="#id2767572">6.1. OpenGIS Functions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2767578">6.1.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2767667">6.1.2. Geometry Relationship Functions</a></span></dt><dt><span class="sect2"><a href="#id2768066">6.1.3. Geometry Processing Functions</a></span></dt><dt><span class="sect2"><a href="#id2768393">6.1.4. Geometry Accessors</a></span></dt><dt><span class="sect2"><a href="#id2768904">6.1.5. Geometry Constructors</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2769510">6.2. Postgis Extensions</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2769516">6.2.1. Management Functions</a></span></dt><dt><span class="sect2"><a href="#id2769855">6.2.2. Operators</a></span></dt><dt><span class="sect2"><a href="#id2770079">6.2.3. Measurement Functions</a></span></dt><dt><span class="sect2"><a href="#id2770368">6.2.4. Geometry Outputs</a></span></dt><dt><span class="sect2"><a href="#id2770508">6.2.5. Geometry Constructors</a></span></dt><dt><span class="sect2"><a href="#id2770859">6.2.6. Geometry Editors</a></span></dt><dt><span class="sect2"><a href="#id2771471">6.2.7. Linear Referencing</a></span></dt><dt><span class="sect2"><a href="#id2771698">6.2.8. Misc</a></span></dt><dt><span class="sect2"><a href="#id2772712">6.2.9. Long Transactions support</a></span></dt></dl></dd><dt><span class="sect1"><a href="#id2772297">6.3. SQL-MM Functions</a></span></dt><dt><span class="sect1"><a href="#id2773715">6.4. ArcSDE Functions</a></span></dt></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="id2753603"></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="id2753609"></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,
+    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="id2767572"></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="id2767578"></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>
+              &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
@@ -1213,52 +973,42 @@
               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="id2753699"></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
+              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="id2767667"></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)
+              "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,
+              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
+              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="id2754075"></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
+              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="id2768066"></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
+              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
@@ -1268,85 +1018,68 @@
               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. 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="id2754401"></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
+              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="id2768393"></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
+              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 .
+              (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
+              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
+              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
+              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
+              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="id2754887"></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
+              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="id2768904"></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
@@ -1363,8 +1096,7 @@
               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
+              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
@@ -1384,373 +1116,250 @@
               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="id2755490"></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="id2755496"></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.2. 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="id2755821"></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="id2756028"></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="id2756312"></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="id2756420"></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="id2756753"></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="id2757354"></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="id2757573"></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="id2758572"></a>6.2.9. Long Transactions support</h3></div></div><div></div></div><p>
+              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="id2769510"></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="id2769516"></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.2. 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="id2769855"></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="id2770079"></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<br>
+              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 length_spheroid( geometry_column,<br>
+              'SPHEROID["GRS_1980",6378137,298.257222101]' )<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="id2770368"></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><dt><span class="term">AsKML(geometry, [precision])</span></dt><dd><p>Return the geometry as a KML 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="id2770508"></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="id2770859"></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="id2771471"></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="id2771698"></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="id2772712"></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.
@@ -1793,353 +1402,232 @@
 	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="id2758155"></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="#id2758225">A.1. Release Notes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2758231">A.1.1. Release 1.1.6</a></span></dt><dt><span class="sect2"><a href="#id2758351">A.1.2. Release 1.1.5</a></span></dt><dt><span class="sect2"><a href="#id2758466">A.1.3. Release 1.1.4</a></span></dt><dt><span class="sect2"><a href="#id2758750">A.1.4. Release 1.1.3</a></span></dt><dt><span class="sect2"><a href="#id2758916">A.1.5. Release 1.1.2</a></span></dt><dt><span class="sect2"><a href="#id2759048">A.1.6. Release 1.1.1</a></span></dt><dt><span class="sect2"><a href="#id2759178">A.1.7. Release 1.1.0</a></span></dt><dt><span class="sect2"><a href="#id2759504">A.1.8. Release 1.0.6</a></span></dt><dt><span class="sect2"><a href="#id2759612">A.1.9. Release 1.0.5</a></span></dt><dt><span class="sect2"><a href="#id2759744">A.1.10. Release 1.0.4</a></span></dt><dt><span class="sect2"><a href="#rel_1.0.3_upgrading">A.1.11. Release 1.0.3</a></span></dt><dt><span class="sect2"><a href="#id2759991">A.1.12. Release 1.0.2</a></span></dt><dt><span class="sect2"><a href="#id2760069">A.1.13. Release 1.0.1</a></span></dt><dt><span class="sect2"><a href="#id2760169">A.1.14. Release 1.0.0</a></span></dt><dt><span class="sect2"><a href="#id2760268">A.1.15. Release 1.0.0RC6</a></span></dt><dt><span class="sect2"><a href="#id2760342">A.1.16. Release 1.0.0RC5</a></span></dt><dt><span class="sect2"><a href="#id2760414">A.1.17. Release 1.0.0RC4</a></span></dt><dt><span class="sect2"><a href="#id2760539">A.1.18. Release 1.0.0RC3</a></span></dt><dt><span class="sect2"><a href="#id2760710">A.1.19. Release 1.0.0RC2</a></span></dt><dt><span class="sect2"><a href="#id2760809">A.1.20. 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="id2758225"></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="id2758231"></a>A.1.1. Release 1.1.6</h3></div></div><div></div></div><p>Release date: 2006/11/02</p><p>This is a bugfix release, in particular fixing
-			    a critical error with GEOS interface in 64bit
-			    systems. Includes an updated of the SRS parameters
-			    and an improvement in reprojections (take Z in 
-			    consideration).
-                            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="id2758253"></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.2.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.11. 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.2.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2758301"></a>A.1.1.2. Bug fixes</h4></div></div><div></div></div><p>
-	fixed CAPI change that broke 64-bit platforms
-	</p><p>
-	loader/dumper: fixed regression tests and usage output
-	</p><p>
-	Fixed setSRID() bug in JDBC, thanks to Thomas Marti
-        </p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2758321"></a>A.1.1.3. Other changes</h4></div></div><div></div></div><p>
-	use Z ordinate in reprojections
-	</p><p>
-	spatial_ref_sys.sql updated to EPSG 6.11.1 
-	</p><p>
-	Simplified Version.config infrastructure to use a single
-          pack of version variables for everything.
-	</p><p>
-	Include the Version.config in loader/dumper USAGE messages
-	</p><p>
-        Replace hand-made, fragile JDBC version parser with Properties
-	</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2758351"></a>A.1.2. Release 1.1.5</h3></div></div><div></div></div><p>Release date: 2006/10/13</p><p>This is an bugfix release, including a critical 
-                            segfault on win32. 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="id2758369"></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.2.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.11. 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.2.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2758416"></a>A.1.2.2. Bug fixes</h4></div></div><div></div></div><p>Fixed MingW link error that was causing pgsql2shp to
-	                        segfault on Win32 when compiled for PostgreSQL 8.2</p><p>fixed nullpointer Exception in Geometry.equals() method 
-                                in Java</p><p>Added EJB3Spatial.odt to fulfill the GPL requirement of
-                                distributing the "preferred form of modification"</p><p>Removed obsolete synchronization from JDBC Jts code.</p><p>Updated heavily outdated README files for shp2pgsql/pgsql2shp by
-                                merging them with the manpages.</p><p>Fixed version tag in jdbc code that still said "1.1.3" in the
-                                "1.1.4" release.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2758454"></a>A.1.2.3. New Features</h4></div></div><div></div></div><p>Added -S option for non-multi geometries to shp2pgsql</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2758466"></a>A.1.3. 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="id2758484"></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.2.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.11. 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.2.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2758531"></a>A.1.3.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="id2758559"></a>A.1.3.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="id2758750"></a>A.1.4. 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="id2758769"></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.2.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.11. 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.2.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2758816"></a>A.1.4.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="id2758845"></a>A.1.4.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="id2758864"></a>A.1.4.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="id2758884"></a>A.1.4.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="id2758916"></a>A.1.5. 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="id2758935"></a>A.1.5.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.2.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.11. 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.2.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2758981"></a>A.1.5.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="id2759004"></a>A.1.5.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="id2759032"></a>A.1.5.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="id2759048"></a>A.1.6. 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.2.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="id2759076"></a>A.1.6.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.2.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.11. 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.2.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2759123"></a>A.1.6.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="id2759158"></a>A.1.6.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="id2759178"></a>A.1.7. 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="id2759205"></a>A.1.7.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="id2759232"></a>A.1.7.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.2.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.11. 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.2.2. Hard upgrade">hard upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2759285"></a>A.1.7.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="id2759349"></a>A.1.7.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="id2759369"></a>A.1.7.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="id2759385"></a>A.1.7.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="id2759401"></a>A.1.7.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="id2759444"></a>A.1.7.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="id2759471"></a>A.1.7.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="id2759504"></a>A.1.8. 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="id2759517"></a>A.1.8.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.11. 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.2.2. Hard upgrade">hard
-				upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2759561"></a>A.1.8.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="id2759596"></a>A.1.8.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="id2759612"></a>A.1.9. 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="id2759633"></a>A.1.9.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.11. 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.2.2. Hard upgrade">hard
-				upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2759677"></a>A.1.9.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="id2759704"></a>A.1.9.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="id2759727"></a>A.1.9.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="id2759744"></a>A.1.10. 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="id2759759"></a>A.1.10.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.11. 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.2.2. Hard upgrade">hard
-				upgrade</a>.
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2759803"></a>A.1.10.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="id2759835"></a>A.1.10.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.11. 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="id2759888"></a>A.1.11.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.2.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.2.1. Soft upgrade">Soft upgrade</a>).
-				</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2759936"></a>A.1.11.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="id2759963"></a>A.1.11.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="id2759991"></a>A.1.12. 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="id2760004"></a>A.1.12.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.2. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2760031"></a>A.1.12.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="id2760053"></a>A.1.12.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="id2760069"></a>A.1.13. 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="id2760083"></a>A.1.13.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.2. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2760110"></a>A.1.13.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="id2760125"></a>A.1.13.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="id2760169"></a>A.1.14. 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="id2760184"></a>A.1.14.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.2. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2760211"></a>A.1.14.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="id2760231"></a>A.1.14.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="id2760268"></a>A.1.15. 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="id2760282"></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.2. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2760301"></a>A.1.15.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="id2760315"></a>A.1.15.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="id2760326"></a>A.1.15.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="id2760342"></a>A.1.16. 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="id2760356"></a>A.1.16.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.2. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2760383"></a>A.1.16.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="id2760398"></a>A.1.16.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="id2760414"></a>A.1.17. 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="id2760428"></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.2. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2760446"></a>A.1.17.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="id2760482"></a>A.1.17.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="id2760497"></a>A.1.17.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="id2760539"></a>A.1.18. 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="id2760553"></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.2. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2760571"></a>A.1.18.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="id2760612"></a>A.1.18.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="id2760636"></a>A.1.18.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="id2760678"></a>A.1.18.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="id2760710"></a>A.1.19. 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="id2760725"></a>A.1.19.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.2. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2760743"></a>A.1.19.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="id2760778"></a>A.1.19.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="id2760793"></a>A.1.19.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="id2760809"></a>A.1.20. 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="id2760824"></a>A.1.20.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.2. Upgrading">upgrading</a>
-				chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2760843"></a>A.1.20.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>
+		</p></dd></dl></div></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2772297"></a>6.3. SQL-MM Functions</h2></div></div><div></div></div><p>This is a listing of the SQL-MM defined functions that PostGIS
+      currently supports. The implementations of these functions follow the
+      ArcSDE implementation, and thus deviate somewhat from the spec. These
+      deviations will be noted.</p><p>As of version 1.2.0, these functions have been implemented by
+      wrapping existing PostGIS functions. As a result, full support for
+      curved geometries may not be in place for many functions.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>SQL-MM defines the default SRID of all geometry constructors as
+        0. PostGIS uses a default SRID of -1.</p></div><div class="variablelist"><dl><dt><span class="term">ST_Area</span></dt><dd><p>Return the area measurement of an ST_Surface or
+            ST_MultiSurface value.</p><p>SQL-MM 3: 8.1.2, 9.5.3</p></dd><dt><span class="term">ST_AsBinary</span></dt><dd><p>Return the well-known binary representation of an
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.37</p></dd><dt><span class="term">ST_AsText</span></dt><dd><p>Return the well-known text representation of an ST_Geometry
+            value.</p><p>SQL-MM 3: 5.1.25</p></dd><dt><span class="term">ST_Boundary</span></dt><dd><p>Return the boundary of the ST_Geometry value.</p><p>SQL-MM 3: 5.1.14</p></dd><dt><span class="term">ST_Buffer</span></dt><dd><p>Return a buffer around the ST_Geometry value.</p><p>SQL-MM 3: 5.1.17</p></dd><dt><span class="term">ST_Centroid</span></dt><dd><p>Return mathematical centroid of the ST_Surface or
+            ST_MultiSurface value.</p><p>SQL-MM 3: 8.1.4, 9.5.5</p></dd><dt><span class="term">ST_Contains</span></dt><dd><p>Test if an ST_Geometry value spatially contains another
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.31</p></dd><dt><span class="term">ST_ConvexHull</span></dt><dd><p>Return the convex hull of the ST_Geometry value.</p><p>SQL-MM 3: 5.1.16</p></dd><dt><span class="term">ST_CoordDim</span></dt><dd><p>Return the coodinate dimension of the ST_Geometry value.</p><p>SQL-MM 3: 5.1.3</p></dd><dt><span class="term">ST_Crosses</span></dt><dd><p>Test if an ST_Geometry value spatially crosses another
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.29</p></dd><dt><span class="term">ST_Difference</span></dt><dd><p>Return an ST_Geometry value that represents the point set
+            difference of two ST_Geometry values.</p><p>SQL-MM 3: 5.1.20</p></dd><dt><span class="term">ST_Dimension</span></dt><dd><p>Return the dimension of the ST_Geometry value.</p><p>SQL-MM 3: 5.1.2</p></dd><dt><span class="term">ST_Disjoint</span></dt><dd><p>Test if an ST_Geometry value is spatially disjoint from
+            another ST_Geometry value.</p><p>SQL-MM 3: 5.1.26</p></dd><dt><span class="term">ST_Distance</span></dt><dd><p>Return the distance between two geometries.</p><p>SQL-MM 3: 5.1.23</p></dd><dt><span class="term">ST_EndPoint</span></dt><dd><p>Return an ST_Point value that is the end point of an
+            ST_Curve value.</p><p>SQL-MM 3: 7.1.4</p></dd><dt><span class="term">ST_Envelope</span></dt><dd><p>Return the bounding rectangle for the ST_Geometry value.</p><p>SQL-MM 3: 5.1.15</p></dd><dt><span class="term">ST_Equals</span></dt><dd><p>Test if an ST_Geometry alue as spatially equal to another
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.24</p></dd><dt><span class="term">ST_ExteriorRing</span></dt><dd><p>Return the exterior ring of an ST_Surface</p><p>SQL-MM 3: 8.2.3, 8.3.3</p></dd><dt><span class="term">ST_GeometryN</span></dt><dd><p>Return the indicated ST_Geometry value from an
+            ST_GeomCollection.</p><p>SQL-MM 3: 9.1.5</p></dd><dt><span class="term">ST_GeometryType</span></dt><dd><p>Return the geometry type of the ST_Geometry value.</p><p>SQL-MM 3: 5.1.4</p></dd><dt><span class="term">ST_GeomFromText</span></dt><dd><p>Return a specified ST_Geometry value.</p><p>SQL-MM 3: 5.1.40</p></dd><dt><span class="term">ST_GeomFromWKB</span></dt><dd><p>Return a specified ST_Geometry value.</p><p>SQL-MM 3: 5.1.41</p></dd><dt><span class="term">ST_InteriorRingN</span></dt><dd><p>Return the specified interior ring of an ST_Surface value.</p><p>SQL-MM 3: 8.2.6, 8.3.5</p></dd><dt><span class="term">ST_Intersection</span></dt><dd><p>Return an ST_Geometry value that represents the point set
+            intersection of two ST_Geometry values.</p><p>SQL-MM 3: 5.1.18</p></dd><dt><span class="term">ST_Intersects</span></dt><dd><p>Test if an ST_Geometry value spatially intersects another
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.27</p></dd><dt><span class="term">ST_IsClosed</span></dt><dd><p>Test if an ST_Curve or ST_MultiCurve value is closed.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>SQL-MM defines the result of ST_IsClosed(NULL) to be 0,
+              while PostGIS returns NULL.</p></div><p>SQL-MM 3: 7.1.5, 9.3.3</p></dd><dt><span class="term">ST_IsEmpty</span></dt><dd><p>Test if an ST_Geometry value corresponds to the empty set.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>SQL-MM defines the result of ST_IsEmpty(NULL) to be 0,
+              while PostGIS returns NULL.</p></div><p>SQL-MM 3: 5.1.7</p></dd><dt><span class="term">ST_IsRing</span></dt><dd><p>Test if an ST_Curve value is a ring.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>SQL-MM defines the result of ST_IsRing(NULL) to be 0,
+              while PostGIS returns NULL.</p></div><p>SQL-MM 3: 7.1.6</p></dd><dt><span class="term">ST_IsSimple</span></dt><dd><p>Test if an ST_Geometry value has no anomalous geometryc
+            points, such as self intersection or self tangency.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>SQL-MM defines the result of ST_IsSimple(NULL) to be 0,
+              while PostGIS returns NULL.</p></div><p>SQL-MM 3: 5.1.8</p></dd><dt><span class="term">ST_IsValid</span></dt><dd><p>Test if an ST_Geometry value is well formed.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>SQL-MM defines the result of ST_IsValid(NULL) to be 0,
+              while PostGIS returns NULL.</p></div><p>QL-MM defines the result of ST_IsValid(NULL) to be 1</p><p>SQL-MM 3: 5.1.9</p></dd><dt><span class="term">ST_Length</span></dt><dd><p>Return the length measurement of an ST_Curve or
+            ST_MultiCurve value.</p><p>SQL-MM 3: 7.1.2, 9.3.4</p></dd><dt><span class="term">ST_LineFromText</span></dt><dd><p>Return a specified ST_LineString value.</p><p>SQL-MM 3: 7.2.8</p></dd><dt><span class="term">ST_LineFromWKB</span></dt><dd><p>Return a specified ST_LineString value.</p><p>SQL-MM 3: 7.2.9</p></dd><dt><span class="term">ST_MLineFromText</span></dt><dd><p>Return a specified ST_MultiLineString value.</p><p>SQL-MM 3: 9.4.4</p></dd><dt><span class="term">ST_MLineFromWKB</span></dt><dd><p>Return a specified ST_MultiLineString value.</p><p>SQL-MM 3: 9.4.5</p></dd><dt><span class="term">ST_MPointFromText</span></dt><dd><p>Return a specified ST_MultiPoint value.</p><p>SQL-MM 3: 9.2.4</p></dd><dt><span class="term">ST_MPointFromWKB</span></dt><dd><p>Return a specified ST_MultiPoint value.</p><p>SQL-MM 3: 9.2.5</p></dd><dt><span class="term">ST_MPolyFromText</span></dt><dd><p>Return a specified ST_MultiPolygon value.</p><p>SQL-MM 3: 9.6.4</p></dd><dt><span class="term">ST_MPolyFromWKB</span></dt><dd><p>Return a specified ST_MultiPolygon value.</p><p>SQL-MM 3: 9.6.5</p></dd><dt><span class="term">ST_NumGeometries</span></dt><dd><p>Return the number of geometries in an ST_GeomCollection.</p><p>SQL-MM 3: 9.1.4</p></dd><dt><span class="term">ST_NumInteriorRing</span></dt><dd><p>Return the number of interior rings in an ST_Surface.</p><p>SQL-MM 3: 8.2.5</p></dd><dt><span class="term">ST_NumPoints</span></dt><dd><p>Return the number of points in an ST_LineString or
+            ST_CircularString value.</p><p>SQL-MM 3: 7.2.4</p></dd><dt><span class="term">ST_OrderingEquals</span></dt><dd><p>ST_OrderingEquals compares two geometries and t (TRUE) if
+            the geometries are equal and the coordinates are in the same
+            order; otherwise it returns f (FALSE).</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This function is implemented as per the ArcSDE SQL
+              specification rather than SQL-MM.
+              http://edndoc.esri.com/arcsde/9.1/sql_api/sqlapi3.htm#ST_OrderingEquals</p></div><p>SQL-MM 3: 5.1.43</p></dd><dt><span class="term">ST_Overlaps</span></dt><dd><p>Test if an ST_Geometry value spatially overlays another
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.32</p></dd><dt><span class="term">ST_Perimeter</span></dt><dd><p>Return the length measurement of the boundary of an
+            ST_Surface or ST_MultiRSurface value.</p><p>SQL-MM 3: 8.1.3, 9.5.4</p></dd><dt><span class="term">ST_Point</span></dt><dd><p>Returns an ST_Point with the given coordinate values.</p><p>SQL-MM 3: 6.1.2</p></dd><dt><span class="term">ST_PointFromText</span></dt><dd><p>Return a specified ST_Point value.</p><p>SQL-MM 3: 6.1.8</p></dd><dt><span class="term">ST_PointFromWKB</span></dt><dd><p>Return a specified ST_Point value.</p><p>SQL-MM 3: 6.1.9</p></dd><dt><span class="term">ST_PointN</span></dt><dd><p>Return the specified ST_Point value in an ST_LineString or
+            ST_CircularString</p><p>SQL-MM 3: 7.2.5, 7.3.5</p></dd><dt><span class="term">ST_PointOnSurface</span></dt><dd><p>Return an ST_Point value guaranteed to spatially intersect
+            the ST_Surface or ST_MultiSurface value.</p><p>SQL-MM 3: 8.1.5, 9.5.6</p></dd><dt><span class="term">ST_PolyFromText</span></dt><dd><p>Return a specified ST_Polygon value.</p><p>SQL-MM 3: 8.3.6</p></dd><dt><span class="term">ST_PolyFromWKB</span></dt><dd><p>Return a specified ST_Polygon value.</p><p>SQL-MM 3: 8.3.7</p></dd><dt><span class="term">ST_Polygon</span></dt><dd><p>Return a polygon build from the specified linestring and
+            SRID.</p><p>SQL-MM 3: 8.3.2</p></dd><dt><span class="term">ST_Relate</span></dt><dd><p>Test if an ST_Geometry value is spatially related to another
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.25</p></dd><dt><span class="term">ST_SRID</span></dt><dd><p>Return the spatial reference system identifier of the
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.5</p></dd><dt><span class="term">ST_StartPoint</span></dt><dd><p>Return an ST_Point value that is the start point of an
+            ST_Curve value.</p><p>SQL-MM 3: 7.1.3</p></dd><dt><span class="term">ST_SymDifference</span></dt><dd><p>Return an ST_Geometry value that represents the point set
+            symmetrcy difference of two ST_Geometry values.</p><p>SQL-MM 3: 5.1.21</p></dd><dt><span class="term">ST_Touches</span></dt><dd><p>Test if an ST_Geometry value spatially touches another
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.28</p></dd><dt><span class="term">ST_Transform</span></dt><dd><p>Return an ST_Geometry value transformed to the specified
+            spatial reference system.</p><p>SQL-MM 3: 5.1.6</p></dd><dt><span class="term">ST_Union</span></dt><dd><p>Return an ST_Geometry value that represents the point set
+            union of two sST_Geometry values.</p><p>SQL-MM 3: 5.1.19</p></dd><dt><span class="term">ST_Within</span></dt><dd><p>Test if an ST_Geometry value is spatially within another
+            ST_Geometry value.</p><p>SQL-MM 3: 5.1.30</p></dd><dt><span class="term">ST_WKBToSQL</span></dt><dd><p>Return an ST_Geometry value for a given well-known binary
+            representation.</p><p>SQL-MM 3: 5.1.36</p></dd><dt><span class="term">ST_WKTToSQL</span></dt><dd><p>Return an ST_Geometry value for a given well-known text
+            representation.</p><p>SQL-MM 3: 5.1.34</p></dd><dt><span class="term">ST_X</span></dt><dd><p>Returns the x coordinate value of an ST_Point value.</p><p>SQL-MM 3: 6.1.3</p></dd><dt><span class="term">ST_Y</span></dt><dd><p>Returns the y coordinate value of an ST_Point value.</p><p>SQL-MM 3: 6.1.4</p></dd></dl></div></div><div class="sect1" lang="en"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2773715"></a>6.4. ArcSDE Functions</h2></div></div><div></div></div><p>Additional functions have been added to improve support for an
+      ArcSDE style interface.</p><div class="variablelist"><dl><dt><span class="term">SE_EnvelopesIntersect</span></dt><dd><p>Returns t (TRUE) if the envelopes of two geometries
+            intersect; otherwise, it returns f (FALSE).</p></dd><dt><span class="term">SE_Is3d</span></dt><dd><p>Test if a geometry value has z coordinate values.</p></dd><dt><span class="term">SE_IsMeasured</span></dt><dd><p>Test if a geometry value has m coordinate values.</p></dd><dt><span class="term">SE_LocateAlong</span></dt><dd><p>Return a derived geometry collection value with elements
+            that match the specified measur.</p></dd><dt><span class="term">SE_LocateBetween</span></dt><dd><p>Return a derived geometry collection value with elements
+            that match the specified range of measures inclusively.</p></dd><dt><span class="term">SE_M</span></dt><dd><p>Returns the m coordinate value of an ST_Point value.</p></dd><dt><span class="term">SE_Z</span></dt><dd><p>Returns the z coordinate value of an ST_Point value</p></dd></dl></div></div></div><div class="chapter" lang="en"><div class="titlepage"><div><div><h2 class="title"><a name="id2773833"></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="#id2773913">A.1. Release Notes</a></span></dt><dd><dl><dt><span class="sect2"><a href="#id2773918">A.1.1. Release 1.2.1</a></span></dt><dt><span class="sect2"><a href="#id2773964">A.1.2. Release 1.2.0</a></span></dt><dt><span class="sect2"><a href="#id2773998">A.1.3. Release 1.1.6</a></span></dt><dt><span class="sect2"><a href="#id2774117">A.1.4. Release 1.1.5</a></span></dt><dt><span class="sect2"><a href="#id2774231">A.1.5. Release 1.1.4</a></span></dt><dt><span class="sect2"><a href="#id2774358">A.1.6. Release 1.1.3</a></span></dt><dt><span class="sect2"><a href="#id2774525">A.1.7. Release 1.1.2</a></span></dt><dt><span class="sect2"><a href="#id2774658">A.1.8. Release 1.1.1</a></span></dt><dt><span class="sect2"><a href="#id2774789">A.1.9. Release 1.1.0</a></span></dt><dt><span class="sect2"><a href="#id2775120">A.1.10. Release 1.0.6</a></span></dt><dt><span class="sect2"><a href="#id2775228">A.1.11. Release 1.0.5</a></span></dt><dt><span class="sect2"><a href="#id2775363">A.1.12. Release 1.0.4</a></span></dt><dt><span class="sect2"><a href="#rel_1.0.3_upgrading">A.1.13. Release 1.0.3</a></span></dt><dt><span class="sect2"><a href="#id2775629">A.1.14. Release 1.0.2</a></span></dt><dt><span class="sect2"><a href="#id2775707">A.1.15. Release 1.0.1</a></span></dt><dt><span class="sect2"><a href="#id2775809">A.1.16. Release 1.0.0</a></span></dt><dt><span class="sect2"><a href="#id2775909">A.1.17. Release 1.0.0RC6</a></span></dt><dt><span class="sect2"><a href="#id2775982">A.1.18. Release 1.0.0RC5</a></span></dt><dt><span class="sect2"><a href="#id2776055">A.1.19. Release 1.0.0RC4</a></span></dt><dt><span class="sect2"><a href="#id2776181">A.1.20. Release 1.0.0RC3</a></span></dt><dt><span class="sect2"><a href="#id2776354">A.1.21. Release 1.0.0RC2</a></span></dt><dt><span class="sect2"><a href="#id2776453">A.1.22. 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="id2773913"></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="id2773918"></a>A.1.1. Release 1.2.1</h3></div></div><div></div></div><p>Release date: 2007/01/11</p><p>This release provides bug fixes in PostgreSQL 8.2 
+        support and some small performance enhancements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2773933"></a>A.1.1.1. Changes</h4></div></div><div></div></div><p>Fixed point-in-polygon shortcut bug in Within().</p><p>Fixed PostgreSQL 8.2 NULL handling for indexes.</p><p>Updated RPM spec files.</p><p>Added short-circuit for Transform() in no-op case.</p><p>JDBC: Fixed JTS handling for multi-dimensional geometries (thanks to Thomas Marti for hint and partial patch).  Additionally, now JavaDoc is compiled and packaged. Fixed classpath problems with GCJ. Fixed pgjdbc 8.2 compatibility, losing support for jdk 1.3 and older.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2773964"></a>A.1.2. Release 1.2.0</h3></div></div><div></div></div><p>Release date: 2006/12/08</p><p>This release provides type definitions along with
+        serialization/deserialization capabilities for SQL-MM defined curved
+        geometries, as well as performance enhancements.</p><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2773980"></a>A.1.2.1. Changes</h4></div></div><div></div></div><p>Added curved geometry type support for
+          serialization/deserialization</p><p>Added point-in-polygon shortcircuit to the Contains and Within
+          functions to improve performance for these cases.</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2773998"></a>A.1.3. Release 1.1.6</h3></div></div><div></div></div><p>Release date: 2006/11/02</p><p>This is a bugfix release, in particular fixing a critical error
+        with GEOS interface in 64bit systems. Includes an updated of the SRS
+        parameters and an improvement in reprojections (take Z in
+        consideration). 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="id2774018"></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.2.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2774068"></a>A.1.3.2. Bug fixes</h4></div></div><div></div></div><p>fixed CAPI change that broke 64-bit platforms</p><p>loader/dumper: fixed regression tests and usage output</p><p>Fixed setSRID() bug in JDBC, thanks to Thomas Marti</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2774087"></a>A.1.3.3. Other changes</h4></div></div><div></div></div><p>use Z ordinate in reprojections</p><p>spatial_ref_sys.sql updated to EPSG 6.11.1</p><p>Simplified Version.config infrastructure to use a single pack
+          of version variables for everything.</p><p>Include the Version.config in loader/dumper USAGE messages</p><p>Replace hand-made, fragile JDBC version parser with Properties</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2774117"></a>A.1.4. Release 1.1.5</h3></div></div><div></div></div><p>Release date: 2006/10/13</p><p>This is an bugfix release, including a critical segfault on
+        win32. 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="id2774135"></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.2.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2774182"></a>A.1.4.2. Bug fixes</h4></div></div><div></div></div><p>Fixed MingW link error that was causing pgsql2shp to segfault
+          on Win32 when compiled for PostgreSQL 8.2</p><p>fixed nullpointer Exception in Geometry.equals() method in
+          Java</p><p>Added EJB3Spatial.odt to fulfill the GPL requirement of
+          distributing the "preferred form of modification"</p><p>Removed obsolete synchronization from JDBC Jts code.</p><p>Updated heavily outdated README files for shp2pgsql/pgsql2shp
+          by merging them with the manpages.</p><p>Fixed version tag in jdbc code that still said "1.1.3"
+          in the "1.1.4" release.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2774218"></a>A.1.4.3. New Features</h4></div></div><div></div></div><p>Added -S option for non-multi geometries to shp2pgsql</p></div></div><div class="sect2" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="id2774231"></a>A.1.5. 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="id2774248"></a>A.1.5.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.2.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2774296"></a>A.1.5.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="id2774322"></a>A.1.5.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="id2774358"></a>A.1.6. 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="id2774377"></a>A.1.6.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.2.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2774424"></a>A.1.6.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="id2774453"></a>A.1.6.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="id2774471"></a>A.1.6.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="id2774492"></a>A.1.6.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="id2774525"></a>A.1.7. 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="id2774543"></a>A.1.7.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.2.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2774590"></a>A.1.7.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="id2774612"></a>A.1.7.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="id2774642"></a>A.1.7.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="id2774658"></a>A.1.8. 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.2.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="id2774687"></a>A.1.8.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.2.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2774734"></a>A.1.8.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="id2774769"></a>A.1.8.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="id2774789"></a>A.1.9. 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="id2774818"></a>A.1.9.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="id2774846"></a>A.1.9.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.2.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2774899"></a>A.1.9.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="id2774964"></a>A.1.9.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="id2774984"></a>A.1.9.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="id2775001"></a>A.1.9.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="id2775017"></a>A.1.9.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="id2775060"></a>A.1.9.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="id2775088"></a>A.1.9.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="id2775120"></a>A.1.10. 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="id2775133"></a>A.1.10.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2775177"></a>A.1.10.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="id2775212"></a>A.1.10.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="id2775228"></a>A.1.11. 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="id2775252"></a>A.1.11.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2775296"></a>A.1.11.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="id2775323"></a>A.1.11.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="id2775347"></a>A.1.11.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="id2775363"></a>A.1.12. 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="id2775379"></a>A.1.12.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.13. 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.2.2. Hard upgrade">hard upgrade</a>.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2775422"></a>A.1.12.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="id2775455"></a>A.1.12.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.13. 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="id2775508"></a>A.1.13.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.2.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.2.1. Soft upgrade">Soft upgrade</a>).</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2775572"></a>A.1.13.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="id2775601"></a>A.1.13.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="id2775629"></a>A.1.14. 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="id2775642"></a>A.1.14.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.2. Upgrading">upgrading</a> chapter for more
+          informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2775669"></a>A.1.14.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="id2775691"></a>A.1.14.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="id2775707"></a>A.1.15. 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="id2775721"></a>A.1.15.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.2. Upgrading">upgrading</a> chapter for more
+          informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2775748"></a>A.1.15.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="id2775763"></a>A.1.15.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="id2775809"></a>A.1.16. 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="id2775824"></a>A.1.16.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.2. Upgrading">upgrading</a>
+          chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2775851"></a>A.1.16.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="id2775871"></a>A.1.16.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="id2775909"></a>A.1.17. 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="id2775923"></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.2. Upgrading">upgrading</a> chapter for more
+          informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2775942"></a>A.1.17.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="id2775956"></a>A.1.17.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="id2775967"></a>A.1.17.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="id2775982"></a>A.1.18. 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="id2775997"></a>A.1.18.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.2. Upgrading">upgrading</a>
+          chapter for more informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2776024"></a>A.1.18.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="id2776039"></a>A.1.18.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="id2776055"></a>A.1.19. 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="id2776069"></a>A.1.19.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.2. Upgrading">upgrading</a> chapter for more
+          informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2776088"></a>A.1.19.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="id2776123"></a>A.1.19.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="id2776139"></a>A.1.19.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="id2776181"></a>A.1.20. 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="id2776195"></a>A.1.20.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.2. Upgrading">upgrading</a> chapter for more
+          informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2776214"></a>A.1.20.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="id2776255"></a>A.1.20.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="id2776279"></a>A.1.20.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="id2776321"></a>A.1.20.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="id2776354"></a>A.1.21. 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="id2776369"></a>A.1.21.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.2. Upgrading">upgrading</a> chapter for more
+          informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2776388"></a>A.1.21.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="id2776422"></a>A.1.21.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="id2776438"></a>A.1.21.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="id2776453"></a>A.1.22. 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="id2776469"></a>A.1.22.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.2. Upgrading">upgrading</a> chapter for more
+          informations.</p></div><div class="sect3" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="id2776488"></a>A.1.22.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/upstream/doc/postgis.xml
===================================================================
--- packages/postgis/upstream/doc/postgis.xml	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/doc/postgis.xml	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
 "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
-  <!ENTITY long_xact SYSTEM "long_xact.xml">
+<!ENTITY long_xact SYSTEM "long_xact.xml">
 ]>
 <book>
   <title>PostGIS Manual</title>
@@ -16,13 +16,9 @@
         <orgname><ulink url="http://www.refractions.net">Refractions Research
         Inc</ulink></orgname>
 
-        <address>
-     <street>Suite 300, 1207 Douglas Street</street>
-     <city>Victoria</city>
-     <state>British Columbia</state>
-     <country>Canada</country>
-     <email>pramsey at refractions.net</email>
-    </address>
+        <address><street>Suite 300, 1207 Douglas Street</street> <city>Victoria</city>
+        <state>British Columbia</state> <country>Canada</country>
+        <email>pramsey at refractions.net</email></address>
       </affiliation>
     </editor>
 
@@ -32,6 +28,7 @@
       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.</para>
+
       <para>This is the manual for version @@LAST_RELEASE_VERSION@@</para>
     </abstract>
   </bookinfo>
@@ -53,7 +50,7 @@
 
       <variablelist>
         <varlistentry>
-          <term>Sandro Santilli &lt;strk at refractions.net&gt;</term>
+          <term>Sandro Santilli &#60;strk at refractions.net&#62;</term>
 
           <listitem>
             <para>Coordinates all bug fixing and maintenance effort,
@@ -63,7 +60,7 @@
         </varlistentry>
 
         <varlistentry>
-          <term>Chris Hodgson &lt;chodgson at refractions.net&gt;</term>
+          <term>Chris Hodgson &#60;chodgson at refractions.net&#62;</term>
 
           <listitem>
             <para>Maintains new functions and the 7.2 index bindings.</para>
@@ -71,16 +68,15 @@
         </varlistentry>
 
         <varlistentry>
-          <term>Paul Ramsey &lt;pramsey at refractions.net&gt;</term>
+          <term>Paul Ramsey &#60;pramsey at refractions.net&#62;</term>
 
           <listitem>
-            <para>Keeps track of the
-            documentation and packaging.</para>
+            <para>Keeps track of the documentation and packaging.</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>Jeff Lounsbury &lt;jeffloun at refractions.net&gt;</term>
+          <term>Jeff Lounsbury &#60;jeffloun at refractions.net&#62;</term>
 
           <listitem>
             <para>Original development of the Shape file loader/dumper.</para>
@@ -88,7 +84,7 @@
         </varlistentry>
 
         <varlistentry>
-          <term>Dave Blasby &lt;dblasby at gmail.com&gt;</term>
+          <term>Dave Blasby &#60;dblasby at gmail.com&#62;</term>
 
           <listitem>
             <para>The original developer of PostGIS. Dave wrote the server
@@ -101,33 +97,29 @@
           <term>Other contributors</term>
 
           <listitem>
-            <para>
-		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.
-            </para>
+            <para>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.</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
           <term>Important Support Libraries</term>
+
           <listitem>
             <para>The <ulink url="http://geos.refractions.net">GEOS</ulink>
-            geometry operations library, and the algorithmic work of 
-            Martin Davis &lt;mbdavis at vividsolutions.com&gt; of Vivid Solutions
-            in making it all work.</para>
+            geometry operations library, and the algorithmic work of Martin
+            Davis &#60;mbdavis at vividsolutions.com&#62; of Vivid Solutions in
+            making it all work.</para>
+
             <para>The <ulink url="http://proj4.maptools.org">Proj4</ulink>
             cartographic projection library, and the work of Gerald Evenden
             and Frank Warmerdam in creating and maintaining it.</para>
-           </listitem>
+          </listitem>
         </varlistentry>
-
       </variablelist>
     </sect1>
 
@@ -149,8 +141,7 @@
 
         <listitem>
           <para>More information about the Proj4 reprojection library is
-          available at <ulink
-          url="http://www.remotesensing.org/proj">http://www.remotesensing.org/proj</ulink>.</para>
+          available at <ulink url="http://www.remotesensing.org/proj">http://www.remotesensing.org/proj</ulink>.</para>
         </listitem>
 
         <listitem>
@@ -167,16 +158,13 @@
 
         <listitem>
           <para>More information about Mapserver internet map server is
-          available at <ulink
-          url="http://mapserver.gis.umn.edu/">http://mapserver.gis.umn.edu</ulink>.</para>
+          available at <ulink url="http://mapserver.gis.umn.edu/">http://mapserver.gis.umn.edu</ulink>.</para>
         </listitem>
 
         <listitem>
-          <para>The "<ulink
-          url="http://www.opengis.org/docs/99-049.pdf">Simple Features
-          for Specification for SQL</ulink>" is available at the OpenGIS
-          Consortium web site: <ulink
-          url="http://www.opengis.org">http://www.opengis.org</ulink>.</para>
+          <para>The &#34;<ulink url="http://www.opengis.org/docs/99-049.pdf">Simple
+          Features for Specification for SQL</ulink>&#34; is available at the
+          OpenGIS Consortium web site: <ulink url="http://www.opengis.org">http://www.opengis.org</ulink>.</para>
         </listitem>
       </itemizedlist>
     </sect1>
@@ -188,17 +176,14 @@
     <sect1>
       <title>Requirements</title>
 
-      <para>PostGIS has the following requirements for building and
-      usage:</para>
+      <para>PostGIS has the following requirements for building and usage:</para>
 
       <itemizedlist>
         <listitem>
-          <para>
-	  A complete installation of PostgreSQL (including server headers).
-          PostgreSQL is available from <ulink
+          <para>A complete installation of PostgreSQL (including server
+          headers). PostgreSQL is available from <ulink
           url="http://www.postgresql.org">http://www.postgresql.org</ulink>.
-	  Version 7.2 or higher is required.
-	  </para>
+          Version 7.2 or higher is required.</para>
         </listitem>
 
         <listitem>
@@ -208,12 +193,11 @@
         </listitem>
 
         <listitem>
-          <para>GNU Make (<filename>gmake</filename> or
-          <filename>make</filename>). For many systems, GNU
-          <filename>make</filename> is the default version of make. Check the
-          version by invoking <filename>make -v</filename>. Other versions of
-          <filename>make</filename> may not process the PostGIS
-          <filename>Makefile</filename> properly.</para>
+          <para>GNU Make (<filename>gmake</filename> or <filename>make</filename>).
+          For many systems, GNU <filename>make</filename> is the default
+          version of make. Check the version by invoking <filename>make -v</filename>.
+          Other versions of <filename>make</filename> may not process the
+          PostGIS <filename>Makefile</filename> properly.</para>
         </listitem>
 
         <listitem>
@@ -237,9 +221,9 @@
       <title>PostGIS</title>
 
       <para>The PostGIS module is a extension to the PostgreSQL backend
-      server. As such, PostGIS @@LAST_RELEASE_VERSION@@
-      <emphasis>requires</emphasis> full PostgreSQL server headers access
-      in order to compile. The PostgreSQL source code is available at <ulink
+      server. As such, PostGIS @@LAST_RELEASE_VERSION@@ <emphasis>requires</emphasis>
+      full PostgreSQL server headers access in order to compile. The
+      PostgreSQL source code is available at <ulink
       url="http://www.postgresql.org">http://www.postgresql.org</ulink>.</para>
 
       <para>PostGIS @@LAST_RELEASE_VERSION@@ can be built against PostgreSQL
@@ -253,8 +237,7 @@
 
           <note>
             <para>If you plan to use GEOS functionality you might need to
-            explicitly link PostgreSQL against the standard C++
-            library:</para>
+            explicitly link PostgreSQL against the standard C++ library:</para>
 
             <programlisting>LDFLAGS=-lstdc++ ./configure [YOUR OPTIONS HERE]</programlisting>
 
@@ -269,34 +252,29 @@
         <listitem>
           <para>Retrieve the PostGIS source archive from <ulink
           url="http://postgis.refractions.net/postgis-@@LAST_RELEASE_VERSION@@.tar.gz">http://postgis.refractions.net/postgis-@@LAST_RELEASE_VERSION@@.tar.gz</ulink>.
-          Uncompress and untar the archive.
-	  </para>
+          Uncompress and untar the archive.</para>
 
-          <programlisting># gzip -d -c postgis-@@LAST_RELEASE_VERSION@@.tar.gz | tar xvf -</programlisting>
+          <programlisting># gzip -d -c postgis-@@LAST_RELEASE_VERSION@@.tar.gz
+          | tar xvf -</programlisting>
         </listitem>
 
         <listitem>
           <para>Enter the postgis-@@LAST_RELEASE_VERSION@@ directory, and run:
-<programlisting># ./configure</programlisting>
-	  </para>
+          <programlisting># ./configure</programlisting></para>
 
           <itemizedlist>
             <listitem>
-		<para>
-		If you want support for coordinate reprojection, you must have
-		the Proj4 library installed. If ./configure didn't find
-		it, try using <code>--with-proj=PATH</code>
-		switch specify a specific Proj4 installation directory.
-		</para>
+              <para>If you want support for coordinate reprojection, you must
+              have the Proj4 library installed. If ./configure didn&#39;t find
+              it, try using <code>--with-proj=PATH</code> switch specify a
+              specific Proj4 installation directory.</para>
             </listitem>
 
             <listitem>
-		<para>
-		If you want to use GEOS functionality, you must have the GEOS
-		library installed. If ./configure didn't find it, try
-		using <code>--with-geos=PATH</code> to specify the full 
-                path to the geos-config program full path.
-		</para>
+              <para>If you want to use GEOS functionality, you must have the
+              GEOS library installed. If ./configure didn&#39;t find it, try
+              using <code>--with-geos=PATH</code> to specify the full path to
+              the geos-config program full path.</para>
             </listitem>
           </itemizedlist>
         </listitem>
@@ -304,22 +282,19 @@
         <listitem>
           <para>Run the compile and install commands.</para>
 
-          <programlisting># make 
-# make install</programlisting>
+          <programlisting># make # make install</programlisting>
 
-          <para>All files are installed using information provided
-	  by <filename>pg_config</filename></para>
+          <para>All files are installed using information provided by
+          <filename>pg_config</filename></para>
 
           <itemizedlist>
             <listitem>
-              <para>Libraries are installed
-              <filename>[pkglibdir]/lib/contrib</filename>.</para>
+              <para>Libraries are installed <filename>[pkglibdir]/lib/contrib</filename>.</para>
             </listitem>
 
             <listitem>
-              <para>Important support files such as
-              <filename>lwpostgis.sql</filename> are installed in
-              <filename>[prefix]/share/contrib</filename>.</para>
+              <para>Important support files such as <filename>lwpostgis.sql</filename>
+              are installed in <filename>[prefix]/share/contrib</filename>.</para>
             </listitem>
 
             <listitem>
@@ -332,163 +307,176 @@
         <listitem>
           <para>PostGIS requires the PL/pgSQL procedural language extension.
           Before loading the <filename>lwpostgis.sql</filename> file, you must
-          first enable PL/pgSQL. You should use the
-          <filename>createlang</filename> command. The PostgreSQL 
-          Programmer's Guide has the details if you want to this manually for
-          some reason.</para>
+          first enable PL/pgSQL. You should use the <filename>createlang</filename>
+          command. The PostgreSQL Programmer&#39;s Guide has the details if
+          you want to this manually for some reason.</para>
 
           <programlisting># createlang plpgsql [yourdatabase]</programlisting>
         </listitem>
 
         <listitem>
           <para>Now load the PostGIS object and function definitions into your
-          database by loading the <filename>lwpostgis.sql</filename> definitions
-          file.</para>
+          database by loading the <filename>lwpostgis.sql</filename>
+          definitions file.</para>
 
           <programlisting># psql -d [yourdatabase] -f lwpostgis.sql</programlisting>
 
-          <para>The PostGIS server extensions are now loaded and ready to
-          use.</para>
+          <para>The PostGIS server extensions are now loaded and ready to use.</para>
         </listitem>
 
         <listitem>
           <para>For a complete set of EPSG coordinate system definition
-          identifiers, you can also load the
-          <filename>spatial_ref_sys.sql</filename> definitions file and
-          populate the <varname>SPATIAL_REF_SYS</varname> table.</para>
+          identifiers, you can also load the <filename>spatial_ref_sys.sql</filename>
+          definitions file and populate the <varname>SPATIAL_REF_SYS</varname>
+          table.</para>
 
           <programlisting># psql -d [yourdatabase] -f spatial_ref_sys.sql</programlisting>
         </listitem>
       </orderedlist>
 
-	  <sect2 id="templatepostgis">
-		<title>Creating PostGIS spatially-enabled databases from an in-built template</title>
-		<para>Some packaged distributions of PostGIS (in particular the Win32 installers for PostGIS &gt;= 1.1.5) load the PostGIS functions into a template database called <varname>template_postgis</varname>. If the <varname>template_postgis</varname> database exists in your PostgreSQL installation then it is possible for users and/or applications to create spatially-enabled databases using a single command. Note that in both cases, the database user must have been granted the privilege to create new databases.</para>
+      <sect2 id="templatepostgis">
+        <title>Creating PostGIS spatially-enabled databases from an in-built
+        template</title>
 
-		<para>From the shell:</para>
+        <para>Some packaged distributions of PostGIS (in particular the Win32
+        installers for PostGIS &#62;= 1.1.5) load the PostGIS functions into a
+        template database called <varname>template_postgis</varname>. If the
+        <varname>template_postgis</varname> database exists in your PostgreSQL
+        installation then it is possible for users and/or applications to
+        create spatially-enabled databases using a single command. Note that
+        in both cases, the database user must have been granted the privilege
+        to create new databases.</para>
 
-		<programlisting># createdb -T template_postgis my_spatial_db</programlisting>
+        <para>From the shell:</para>
 
-		<para>From SQL:</para>
+        <programlisting># createdb -T template_postgis my_spatial_db</programlisting>
 
-		<programlisting>postgres=# CREATE DATABASE my_spatial_db TEMPLATE=template_postgis</programlisting>
-	  </sect2>
+        <para>From SQL:</para>
 
+        <programlisting>postgres=# CREATE DATABASE my_spatial_db
+        TEMPLATE=template_postgis</programlisting>
+      </sect2>
+
       <sect2 id="upgrading">
         <title>Upgrading</title>
 
-<para>
-Upgrading existing spatial databases can be tricky as it requires
-replacement or introduction of new PostGIS object definitions.
-</para>
+        <para>Upgrading existing spatial databases can be tricky as it
+        requires replacement or introduction of new PostGIS object
+        definitions.</para>
 
-<para>
-Unfortunately not all definitions can be easily replaced in 
-a live database, so sometimes your best bet is a dump/reload
-process. 
-</para>
+        <para>Unfortunately not all definitions can be easily replaced in a
+        live database, so sometimes your best bet is a dump/reload process.</para>
 
-<para>
-PostGIS provides a SOFT UPGRADE procedure for minor or bugfix
-releases, and an HARD UPGRADE procedure for major releases.
-</para>
+        <para>PostGIS provides a SOFT UPGRADE procedure for minor or bugfix
+        releases, and an HARD UPGRADE procedure for major releases.</para>
 
-	<para>
-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.
-	</para>
+        <para>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.</para>
 
-	<sect3 id="soft_upgrade">
-		<title>Soft upgrade</title>
+        <sect3 id="soft_upgrade">
+          <title>Soft upgrade</title>
 
-<para>
-Soft upgrade consists of sourcing the lwpostgis_upgrade.sql
-script in your spatial database:
-</para>
+          <para>Soft upgrade consists of sourcing the lwpostgis_upgrade.sql
+          script in your spatial database:</para>
 
-<programlisting>psql -f lwpostgis_upgrade.sql -d your_spatial_database</programlisting>
+          <programlisting>$ psql -f lwpostgis_upgrade.sql -d your_spatial_database</programlisting>
 
-<para>
-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.
-</para>
+          <para>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.</para>
 
-<note>
-<para>
-If you can't find the <filename>lwpostgis_upgrade.sql</filename> 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:
-</para>
+          <note>
+            <para>If you can&#39;t find the <filename>lwpostgis_upgrade.sql</filename>
+            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:</para>
 
-<programlisting>utils/postgis_proc_upgrade.pl lwpostgis.sql > lwpostgis_upgrade.sql</programlisting>
-</note>
+            <programlisting>$ utils/postgis_proc_upgrade.pl lwpostgis.sql &#62; lwpostgis_upgrade.sql</programlisting>
+          </note>
+        </sect3>
 
+        <sect3 id="hard_upgrade">
+          <title>Hard upgrade</title>
 
-	</sect3>
+          <para>By HARD UPGRADE we intend full dump/reload of postgis-enabled
+          databases. You need an HARD UPGRADE when postgis objects&#39;
+          internal storage changes or when SOFT UPGRADE is not possible. The
+          <link linkend="release_notes">Release Notes</link> appendix reports
+          for each version whether you need a dump/reload (HARD UPGRADE) to
+          upgrade.</para>
 
+          <para>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:</para>
 
-	<sect3 id="hard_upgrade">
-		<title>Hard upgrade</title>
+          <para>
+	  Create a &#34;custom-format&#34; dump of the database you want
+	  to upgrade (let&#39;s call it &#34;olddb&#34;)
+	  </para>
 
+	<programlisting>
+$ pg_dump -Fc olddb &#62; olddb.dump
+	</programlisting>
+
 	<para>
-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 whether you need a
-dump/reload (HARD UPGRADE) to upgrade.
+Restore the dump contextually upgrading postgis into a new database. The
+new database doesn&#39;t have to exist.  postgis_restore accepts createdb
+parameters after the dump file name, and that can for instance be used
+if you are using a non-default character encoding for your database.
+Let&#39;s call it &#34;newdb&#34;, with UNICODE as the character encoding:
 	</para>
 
+	  <programlisting>
+$ sh utils/postgis_restore.pl lwpostgis.sql newdb olddb.dump -E=UNICODE &#62; restore.log
+	  </programlisting>
+
 	<para>
-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:
+Check that all restored dump objects really had to be restored from dump 
+and do not conflict with the ones defined in lwpostgis.sql
 	</para>
 
 	<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
+$ grep ^KEEPING restore.log | less
+	</programlisting>
 
-	# 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
+	<para>
+If upgrading from PostgreSQL &#60; 8.0 to &#62;= 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&#39;t hurt.
+	DROPPING THEM WHEN REALLY NEEDED WILL DO HURT !
+	</para>
 
-	# 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
+	<programlisting>
+$ psql newdb -c &#34;ALTER TABLE geometry_columns DROP attrelid&#34;
+$ psql newdb -c &#34;ALTER TABLE geometry_columns DROP varattnum&#34;
+$ psql newdb -c &#34;ALTER TABLE geometry_columns DROP stats&#34;
+	</programlisting>
 
-	# 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"
+	<para>
+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:
+	</para>
 
-	# 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
+	<programlisting>
+$ psql newdb
+newdb=&#62; delete from spatial_ref_sys;
+DROP
+newdb=&#62; \i spatial_ref_sys.sql
 	</programlisting>
 
-	</sect3>
-
+        </sect3>
       </sect2>
 
       <sect2>
         <title>Common Problems</title>
 
         <para>There are several things to check when your installation or
-        upgrade doesn't go as you expected.</para>
+        upgrade doesn&#39;t go as you expected.</para>
 
         <orderedlist>
           <listitem>
@@ -538,9 +526,8 @@
           <listitem>
             <para>If you want to be able to use GEOS functions you must
             install the GEOS library on your system, and set the
-            <varname>USE_GEOS</varname> to 1 and the
-            <varname>GEOS_DIR</varname> to your installation prefix in the
-            Makefile.config</para>
+            <varname>USE_GEOS</varname> to 1 and the <varname>GEOS_DIR</varname>
+            to your installation prefix in the Makefile.config</para>
           </listitem>
         </orderedlist>
       </sect2>
@@ -580,15 +567,14 @@
       <para>The data loader and dumper are built and installed automatically
       as part of the PostGIS build. To build and install them manually:</para>
 
-      <programlisting># cd postgis-@@LAST_RELEASE_VERSION@@/loader 
-# make
-# make install</programlisting>
+      <programlisting># cd postgis-@@LAST_RELEASE_VERSION@@/loader # make #
+      make install</programlisting>
 
       <para>The loader is called <filename>shp2pgsql</filename> and converts
       ESRI Shape files into SQL suitable for loading in PostGIS/PostgreSQL.
       The dumper is called <filename>pgsql2shp</filename> and converts PostGIS
-      tables (or queries) into ESRI Shape files. For more verbose documentation,
-      see the online help, and the manual pages.</para>
+      tables (or queries) into ESRI Shape files. For more verbose
+      documentation, see the online help, and the manual pages.</para>
     </sect1>
   </chapter>
 
@@ -615,11 +601,12 @@
 
         <answer>
           <para>First, you need to create a table with a column of type
-          "geometry" to hold your GIS data. Connect to your database with
-          <filename>psql</filename> and try the following SQL:</para>
+          &#34;geometry&#34; to hold your GIS data. Connect to your database
+          with <filename>psql</filename> and try the following SQL:</para>
 
           <programlisting>CREATE TABLE gtest ( ID int4, NAME varchar(20) );
-SELECT AddGeometryColumn('', 'gtest','geom',-1,'LINESTRING',2);</programlisting>
+          SELECT AddGeometryColumn(&#39;&#39;,
+          &#39;gtest&#39;,&#39;geom&#39;,-1,&#39;LINESTRING&#39;,2);</programlisting>
 
           <para>If the geometry column addition fails, you probably have not
           loaded the PostGIS functions and objects into this database. See the
@@ -627,9 +614,11 @@
 
           <para>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:</para>
+          OpenGIS Consortium &#34;well-known text&#34; format:</para>
 
-          <programlisting>INSERT INTO gtest (ID, NAME, GEOM) VALUES (1, 'First Geometry', GeomFromText('LINESTRING(2 3,4 5,6 5,7 8)', -1));</programlisting>
+          <programlisting>INSERT INTO gtest (ID, NAME, GEOM) VALUES (1,
+          &#39;First Geometry&#39;, GeomFromText(&#39;LINESTRING(2 3,4 5,6 5,7
+          8)&#39;, -1));</programlisting>
 
           <para>For more information about other GIS objects, see the <link
           linkend="RefObject">object reference</link>.</para>
@@ -640,10 +629,9 @@
 
           <para>The return value should look something like this:</para>
 
-          <programlisting> id | name           | geom
-----+----------------+-----------------------------
-  1 | First Geometry | LINESTRING(2 3,4 5,6 5,7 8) 
-(1 row)</programlisting>
+          <programlisting>id | name | geom
+          ----+----------------+----------------------------- 1 | First
+          Geometry | LINESTRING(2 3,4 5,6 5,7 8) (1 row)</programlisting>
         </answer>
       </qandaentry>
 
@@ -661,12 +649,12 @@
           index you can make use of; and, are you doing expensive calculations
           on a large number of geometries.</para>
 
-          <para>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.</para>
+          <para>In general, you will want to use the &#34;intersects
+          operator&#34; (&#38;&#38;) which tests whether the bounding boxes of
+          features intersect. The reason the &#38;&#38; operator is useful is
+          because if a spatial index is available to speed up the test, the
+          &#38;&#38; operator will make use of this. This can make queries
+          much much faster.</para>
 
           <para>You will also make use of spatial functions, such as
           Distance(), Intersects(), Contains() and Within(), among others, to
@@ -676,11 +664,9 @@
           <emphasis>might</emphasis> meet the condition of interest. The
           spatial functions are then use to test the condition exactly.</para>
 
-          <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))';</programlisting>
+          <programlisting>SELECT id, the_geom FROM thetable WHERE the_geom
+          &#38;&#38; &#39;POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))&#39; AND
+          Contains(the_geom,&#39;POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))&#39;;</programlisting>
         </answer>
       </qandaentry>
 
@@ -691,33 +677,31 @@
 
         <answer>
           <para>Fast queries on large tables is the <emphasis>raison
-          d'etre</emphasis> of spatial databases (along with transaction
+          d&#39;etre</emphasis> of spatial databases (along with transaction
           support) so having a good index is important.</para>
 
-          <para>To build a spatial index on a table with a
-          <varname>geometry</varname> column, use the "CREATE INDEX" function
-          as follows:</para>
+          <para>To build a spatial index on a table with a <varname>geometry</varname>
+          column, use the &#34;CREATE INDEX&#34; function as follows:</para>
 
-          <programlisting>CREATE INDEX [indexname] ON [tablename]  
-  USING GIST ( [geometrycolumn] );</programlisting>
+          <programlisting>CREATE INDEX [indexname] ON [tablename] USING GIST (
+          [geometrycolumn] );</programlisting>
 
-          <para>The "USING GIST" option tells the server to use a GiST
+          <para>The &#34;USING GIST&#34; option tells the server to use a GiST
           (Generalized Search Tree) index.</para>
 
           <note>
-            <para>
-            GiST indexes are assumed to be lossy.
-	    Lossy indexes uses a proxy object (in the spatial case,
-	    a bounding box) for building the index.</para>
+            <para>GiST indexes are assumed to be lossy. Lossy indexes uses a
+            proxy object (in the spatial case, a bounding box) for building
+            the index.</para>
           </note>
 
           <para>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.</para>
+          when to use it. To do this, you have to &#34;gather statistics&#34;
+          on your geometry tables.</para>
 
-          <para>For PostgreSQL 8.0.x and greater, just run the <command>VACUUM
-          ANALYZE</command> command.</para>
+          <para>For PostgreSQL 8.0.x and greater, just run the
+          <command>VACUUM ANALYZE</command> command.</para>
 
           <para>For PostgreSQL 7.4.x and below, run the <command>SELECT
           UPDATE_GEOMETRY_STATS()</command> command.</para>
@@ -726,7 +710,7 @@
 
       <qandaentry>
         <question>
-          <para>Why aren't PostgreSQL R-Tree indexes supported?</para>
+          <para>Why aren&#39;t PostgreSQL R-Tree indexes supported?</para>
         </question>
 
         <answer>
@@ -744,14 +728,14 @@
           <itemizedlist>
             <listitem>
               <para>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.</para>
+              are larger than 8K in size. GiST indexes can, using the
+              &#34;lossy&#34; trick of substituting the bounding box for the
+              feature itself.</para>
             </listitem>
 
             <listitem>
-              <para>R-Tree indexes in PostgreSQL are not "null safe", so
-              building an index on a geometry column which contains null
+              <para>R-Tree indexes in PostgreSQL are not &#34;null safe&#34;,
+              so building an index on a geometry column which contains null
               geometries will fail.</para>
             </listitem>
           </itemizedlist>
@@ -771,9 +755,8 @@
           will have SRIDs of -1, and the OpenGIS meta-data tables will
           <emphasis>not</emphasis> be filled in properly. However, this will
           cause most applications based on PostGIS to fail, and it is
-          generally suggested that you do use
-          <varname>AddGeometryColumn()</varname> to create geometry
-          tables.</para>
+          generally suggested that you do use <varname>AddGeometryColumn()</varname>
+          to create geometry tables.</para>
 
           <para>Mapserver is one application which makes use of the
           <varname>geometry_columns</varname> meta-data. Specifically,
@@ -803,19 +786,16 @@
           <para>For example, to find all objects with 100 meters of POINT(1000
           1000) the following query would work well:</para>
 
-          <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;</programlisting>
+          <programlisting>SELECT * FROM GEOTABLE WHERE GEOCOLUMN &#38;&#38;
+          Expand(GeomFromText(&#39;POINT(1000 1000)&#39;,-1),100) AND
+          Distance(GeomFromText(&#39;POINT(1000 1000)&#39;,-1),GEOCOLUMN)
+          &#60; 100;</programlisting>
         </answer>
       </qandaentry>
 
       <qandaentry>
         <question>
-          <para>How do I perform a coordinate reprojection as part of a
-          query?</para>
+          <para>How do I perform a coordinate reprojection as part of a query?</para>
         </question>
 
         <answer>
@@ -837,10 +817,10 @@
     <sect1 id="RefObject">
       <title>GIS Objects</title>
 
-      <para>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.</para>
+      <para>The GIS objects supported by PostGIS are a superset of the
+      &#34;Simple Features&#34; defined by the OpenGIS Consortium (OGC). As of
+      version 0.9, PostGIS supports all the objects and functions specified in
+      the OGC &#34;Simple Features for SQL&#34; specification.</para>
 
       <para>PostGIS extends the standard with support for 3DZ,3DM and 4D
       coordinates.</para>
@@ -849,223 +829,216 @@
         <title>OpenGIS WKB and WKT</title>
 
         <para>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.</para>
+        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.</para>
 
-      <para>Examples of the text representations (WKT) of the spatial
-      objects of the features are as follows:</para>
+        <para>Examples of the text representations (WKT) of the spatial
+        objects of the features are as follows:</para>
 
-      <itemizedlist>
-        <listitem>
-          <para>POINT(0 0)</para>
-        </listitem>
+        <itemizedlist>
+          <listitem>
+            <para>POINT(0 0)</para>
+          </listitem>
 
-        <listitem>
-          <para>LINESTRING(0 0,1 1,1 2)</para>
-        </listitem>
+          <listitem>
+            <para>LINESTRING(0 0,1 1,1 2)</para>
+          </listitem>
 
-        <listitem>
-          <para>POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))</para>
-        </listitem>
+          <listitem>
+            <para>POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))</para>
+          </listitem>
 
-        <listitem>
-          <para>MULTIPOINT(0 0,1 2)</para>
-        </listitem>
+          <listitem>
+            <para>MULTIPOINT(0 0,1 2)</para>
+          </listitem>
 
-        <listitem>
-          <para>MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))</para>
-        </listitem>
+          <listitem>
+            <para>MULTILINESTRING((0 0,1 1,1 2),(2 3,3 2,5 4))</para>
+          </listitem>
 
-        <listitem>
-          <para>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)))</para>
-        </listitem>
+          <listitem>
+            <para>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)))</para>
+          </listitem>
 
-        <listitem>
-          <para>GEOMETRYCOLLECTION(POINT(2 3),LINESTRING((2 3,3 4)))</para>
-        </listitem>
+          <listitem>
+            <para>GEOMETRYCOLLECTION(POINT(2 3),LINESTRING((2 3,3 4)))</para>
+          </listitem>
+        </itemizedlist>
 
-      </itemizedlist>
+        <para>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.</para>
 
+        <para>Input/Output of these formats are available using the following
+        interfaces:</para>
 
-        <para>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.</para>
+        <programlisting>bytea WKB = asBinary(geometry); text WKT =
+        asText(geometry); geometry = GeomFromWKB(bytea WKB, SRID); geometry =
+        GeometryFromText(text WKT, SRID);</programlisting>
 
-<para>
-Input/Output of these formats are available using the following
-interfaces:
-</para>
+        <para>For example, a valid insert statement to create and insert an
+        OGC spatial object would be:</para>
 
-	<programlisting>
-	bytea WKB = asBinary(geometry);
-	text WKT = asText(geometry);
-	geometry = GeomFromWKB(bytea WKB, SRID); 
-	geometry = GeometryFromText(text WKT, SRID);
-	</programlisting>
+        <programlisting>INSERT INTO SPATIALTABLE ( THE_GEOM, THE_NAME ) VALUES
+        ( GeomFromText(&#39;POINT(-126.4 45.32)&#39;, 312), &#39;A Place&#39;
+        )</programlisting>
+      </sect2>
 
-	<para> For example, a valid insert statement to create and insert an OGC spatial object would be:</para>
+      <sect2>
+        <title>PostGIS EWKB, EWKT and Canonical Forms</title>
 
-        <programlisting>
-	INSERT INTO SPATIALTABLE ( 
-		  THE_GEOM, 
-		  THE_NAME 
-	) 
-	VALUES ( 
-		  GeomFromText('POINT(-126.4 45.32)', 312), 
-		  'A Place' 
-	)</programlisting>
+        <para>OGC formats only support 2d geometries, and the associated SRID
+        is *never* embedded in the input/output representations.</para>
 
+        <para>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!</para>
 
-      </sect2>
+        <para>Postgis EWKB/EWKT add 3dm,3dz,4d coordinates support and
+        embedded SRID information.</para>
 
-	<sect2>
-        <title>PostGIS EWKB, EWKT and Canonical Forms</title>
+        <para>Examples of the text representations (EWKT) of the extended
+        spatial objects of the features are as follows:</para>
 
+        <itemizedlist>
+          <listitem>
+            <para>POINT(0 0 0) -- XYZ</para>
+          </listitem>
 
-<para>
-OGC formats only support 2d geometries, and the associated SRID
-is *never* embedded in the input/output representations.
-</para>
+          <listitem>
+            <para>SRID=32632;POINT(0 0) -- XY with SRID</para>
+          </listitem>
 
-<para>
-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!
-</para>
+          <listitem>
+            <para>POINTM(0 0 0) -- XYM</para>
+          </listitem>
 
-<para>
-Postgis EWKB/EWKT add 3dm,3dz,4d coordinates support and embedded
-SRID information.
-</para>
+          <listitem>
+            <para>POINT(0 0 0 0) -- XYZM</para>
+          </listitem>
 
-      <para>Examples of the text representations (EWKT) of the
-      extended spatial objects of the features are as follows:</para>
+          <listitem>
+            <para>SRID=4326;MULTIPOINTM(0 0 0,1 2 1) -- XYM with SRID</para>
+          </listitem>
 
-      <itemizedlist>
+          <listitem>
+            <para>MULTILINESTRING((0 0 0,1 1 0,1 2 1),(2 3 1,3 2 1,5 4 1))</para>
+          </listitem>
 
-        <listitem>
-          <para>POINT(0 0 0) -- XYZ</para>
-        </listitem>
+          <listitem>
+            <para>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))</para>
+          </listitem>
 
-        <listitem>
-          <para>SRID=32632;POINT(0 0) -- XY with SRID</para>
-        </listitem>
+          <listitem>
+            <para>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)))</para>
+          </listitem>
 
-        <listitem>
-          <para>POINTM(0 0 0) -- XYM</para>
-        </listitem>
+          <listitem>
+            <para>GEOMETRYCOLLECTIONM(POINTM(2 3 9),LINESTRINGM((2 3 4,3 4
+            5)))</para>
+          </listitem>
+        </itemizedlist>
 
-        <listitem>
-          <para>POINT(0 0 0 0) -- XYZM</para>
-        </listitem>
+        <para>Input/Output of these formats are available using the following
+        interfaces:</para>
 
-        <listitem>
-          <para>SRID=4326;MULTIPOINTM(0 0 0,1 2 1) -- XYM with SRID</para>
-        </listitem>
+        <programlisting>bytea EWKB = asEWKB(geometry); text EWKT =
+        asEWKT(geometry); geometry = GeomFromEWKB(bytea EWKB); geometry =
+        GeomFromEWKT(text EWKT);</programlisting>
 
-        <listitem>
-          <para>MULTILINESTRING((0 0 0,1 1 0,1 2 1),(2 3 1,3 2 1,5 4
-          1))</para>
-        </listitem>
+        <para>For example, a valid insert statement to create and insert a
+        PostGIS spatial object would be:</para>
 
-        <listitem>
-          <para>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))</para>
-        </listitem>
+        <programlisting>INSERT INTO SPATIALTABLE ( THE_GEOM, THE_NAME ) VALUES
+        ( GeomFromEWKT(&#39;SRID=312;POINTM(-126.4 45.32 15)&#39;), &#39;A
+        Place&#39; )</programlisting>
 
-        <listitem>
-          <para>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)))</para>
-        </listitem>
+        <para>The &#34;canonical forms&#34; 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 &#39;geometry&#39; type these
+        are: <programlisting> - Output - binary: EWKB ascii: HEXEWKB (EWKB in
+        hex form) - Input - binary: EWKB ascii: HEXEWKB|EWKT </programlisting></para>
 
-        <listitem>
-          <para>GEOMETRYCOLLECTIONM(POINTM(2 3 9),LINESTRINGM((2 3 4,3 4
-          5)))</para>
-        </listitem>
+        <para>For example this statement reads EWKT and returns HEXEWKB in the
+        process of canonical ascii input/output:</para>
 
-      </itemizedlist>
+        <programlisting>=# SELECT &#39;SRID=4;POINT(0 0)&#39;::geometry;
+        geometry ----------------------------------------------------
+        01010000200400000000000000000000000000000000000000 (1 row)</programlisting>
+      </sect2>
 
+      <sect2>
+        <title>SQL-MM Part 3</title>
 
-<para>
-Input/Output of these formats are available using the following
-interfaces:
-</para>
+        <para>The SQL Multimedia Applications Spatial specification extends
+        the simple features for SQL spec by defining a number of circularly
+        interpolated curves.</para>
 
-	<programlisting>
-	bytea EWKB = asEWKB(geometry);
-	text EWKT = asEWKT(geometry);
-	geometry = GeomFromEWKB(bytea EWKB);
-	geometry = GeomFromEWKT(text EWKT);
-	</programlisting>
+        <para>The SQL-MM definitions include 3dm, 3dz and 4d coordinates, but
+        do not allow the embedding of SRID information.</para>
 
-<para>
-For example, a valid insert statement to create and insert a PostGIS spatial object would be:
-</para>
+        <para>The well-known text extensions are not yet fully supported.
+        Examples of some simple curved geometries are shown below:</para>
 
-        <programlisting>
-	INSERT INTO SPATIALTABLE ( 
-		  THE_GEOM, 
-		  THE_NAME 
-	) 
-	VALUES ( 
-		  GeomFromEWKT('SRID=312;POINTM(-126.4 45.32 15)'), 
-		  'A Place' 
-	)</programlisting>
+        <itemizedlist>
+          <listitem>
+            <para>CIRCULARSTRING(0 0, 1 1, 1 0)</para>
+          </listitem>
 
-<para>
-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:
+          <listitem>
+            <para>COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 1 0),(1 0, 0 1))</para>
+          </listitem>
 
-	<programlisting>
-	- Output -
-	binary: EWKB
-	 ascii: HEXEWKB (EWKB in hex form)
+          <listitem>
+            <para>CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4, 0 0),(1 1, 3
+            3, 3 1, 1 1))</para>
+          </listitem>
 
-	- Input -
-	binary: EWKB
-	 ascii: HEXEWKB|EWKT
-	</programlisting>
-</para>
+          <listitem>
+            <para>MULTICURVE((0 0, 5 5),CIRCULARSTRING(4 0, 4 4, 8 4))</para>
+          </listitem>
 
-<para>
-For example this statement reads EWKT and returns HEXEWKB in the
-process of canonical ascii input/output:
-</para>
+          <listitem>
+            <para>MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(0 0, 4 0, 4 4, 0 4,
+            0 0),(1 1, 3 3, 3 1, 1 1)),((10 10, 14 12, 11 10, 10 10),(11 11,
+            11.5 11, 11 11.5, 11 11)))</para>
+          </listitem>
+        </itemizedlist>
 
-        <programlisting>
-	=# SELECT 'SRID=4;POINT(0 0)'::geometry;
-			      geometry
-	----------------------------------------------------
-	 01010000200400000000000000000000000000000000000000
-	(1 row)
-	</programlisting>
+        <note>
+          <para>Currently, PostGIS cannot support the use of Compound Curves
+          in a Curve Polygon.</para>
+        </note>
 
-
+        <note>
+          <para>All floating point comparisons within the SQL-MM
+          implementation are performed to a specified tolerance, currently
+          1E-8.</para>
+        </note>
       </sect2>
     </sect1>
 
     <sect1>
       <title>Using OpenGIS Standards</title>
 
-      <para>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.</para>
+      <para>The OpenGIS &#34;Simple Features Specification for SQL&#34;
+      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.</para>
 
-      <para>There are two OpenGIS meta-data tables:
-      <varname>SPATIAL_REF_SYS</varname> and
-      <varname>GEOMETRY_COLUMNS</varname>. The
-      <varname>SPATIAL_REF_SYS</varname> table holds the numeric IDs and
-      textual descriptions of coordinate systems used in the spatial
-      database.</para>
+      <para>There are two OpenGIS meta-data tables: <varname>SPATIAL_REF_SYS</varname>
+      and <varname>GEOMETRY_COLUMNS</varname>. The <varname>SPATIAL_REF_SYS</varname>
+      table holds the numeric IDs and textual descriptions of coordinate
+      systems used in the spatial database.</para>
 
       <sect2>
         <title>The SPATIAL_REF_SYS Table</title>
@@ -1073,16 +1046,11 @@
         <para>The <varname>SPATIAL_REF_SYS</varname> table definition is as
         follows:</para>
 
-        <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)
-)</programlisting>
+        <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) )</programlisting>
 
-        <para>The <varname>SPATIAL_REF_SYS</varname> columns are as
-        follows:</para>
+        <para>The <varname>SPATIAL_REF_SYS</varname> columns are as follows:</para>
 
         <variablelist>
           <varlistentry>
@@ -1099,8 +1067,8 @@
 
             <listitem>
               <para>The name of the standard or standards body that is being
-              cited for this reference system. For example, "EPSG" would be a
-              valid <varname>AUTH_NAME</varname>.</para>
+              cited for this reference system. For example, &#34;EPSG&#34;
+              would be a valid <varname>AUTH_NAME</varname>.</para>
             </listitem>
           </varlistentry>
 
@@ -1119,31 +1087,27 @@
 
             <listitem>
               <para>The Well-Known Text representation of the Spatial
-              Reference System. An example of a WKT SRS representation
-              is:</para>
+              Reference System. An example of a WKT SRS representation is:</para>
 
-              <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] 
-]</programlisting>
+              <programlisting>PROJCS[&#34;NAD83 / UTM Zone 10N&#34;,
+              GEOGCS[&#34;NAD83&#34;,
+              DATUM[&#34;North_American_Datum_1983&#34;, SPHEROID[&#34;GRS
+              1980&#34;,6378137,298.257222101] ],
+              PRIMEM[&#34;Greenwich&#34;,0],
+              UNIT[&#34;degree&#34;,0.0174532925199433] ],
+              PROJECTION[&#34;Transverse_Mercator&#34;],
+              PARAMETER[&#34;latitude_of_origin&#34;,0],
+              PARAMETER[&#34;central_meridian&#34;,-123],
+              PARAMETER[&#34;scale_factor&#34;,0.9996],
+              PARAMETER[&#34;false_easting&#34;,500000],
+              PARAMETER[&#34;false_northing&#34;,0], UNIT[&#34;metre&#34;,1] ]</programlisting>
 
               <para>For a listing of EPSG projection codes and their
               corresponding WKT representations, see <ulink
               url="http://www.opengis.org/techno/interop/EPSG2WKT.TXT">http://www.opengis.org/techno/interop/EPSG2WKT.TXT</ulink>.
-              For a discussion of WKT in general, see the OpenGIS "Coordinate
-              Transformation Services Implementation Specification" at <ulink
+              For a discussion of WKT in general, see the OpenGIS
+              &#34;Coordinate Transformation Services Implementation
+              Specification&#34; at <ulink
               url="http://www.opengis.org/techno/specs.htm">http://www.opengis.org/techno/specs.htm</ulink>.
               For information on the European Petroleum Survey Group (EPSG)
               and their database of spatial reference systems, see <ulink
@@ -1160,11 +1124,11 @@
               column contains the Proj4 coordinate definition string for a
               particular SRID. For example:</para>
 
-              <programlisting>+proj=utm +zone=10 +ellps=clrk66 +datum=NAD27 +units=m</programlisting>
+              <programlisting>+proj=utm +zone=10 +ellps=clrk66 +datum=NAD27
+              +units=m</programlisting>
 
               <para>For more information about, see the Proj4 web site at
-              <ulink
-              url="http://www.remotesensing.org/proj">http://www.remotesensing.org/proj</ulink>.
+              <ulink url="http://www.remotesensing.org/proj">http://www.remotesensing.org/proj</ulink>.
               The <filename>spatial_ref_sys.sql</filename> file contains both
               <varname>SRTEXT</varname> and <varname>PROJ4TEXT</varname>
               definitions for all EPSG projections.</para>
@@ -1179,15 +1143,11 @@
         <para>The <varname>GEOMETRY_COLUMNS</varname> table definition is as
         follows:</para>
 
-        <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 
-)</programlisting>
+        <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 )</programlisting>
 
         <para>The columns are as follows:</para>
 
@@ -1197,10 +1157,11 @@
 
             <listitem>
               <para>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 (<varname>public</varname> is the default).</para>
+              the geometry column. Note that the terms &#34;catalog&#34; and
+              &#34;schema&#34; are Oracle-ish. There is not PostgreSQL
+              analogue of &#34;catalog&#34; so that column is left blank --
+              for &#34;schema&#34; the PostgreSQL schema name is used (<varname>public</varname>
+              is the default).</para>
             </listitem>
           </varlistentry>
 
@@ -1208,8 +1169,7 @@
             <term>F_GEOMETRY_COLUMN</term>
 
             <listitem>
-              <para>The name of the geometry column in the feature
-              table.</para>
+              <para>The name of the geometry column in the feature table.</para>
             </listitem>
           </varlistentry>
 
@@ -1239,15 +1199,14 @@
               <para>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.</para>
+              corresponding XYM versions POINTM, LINESTRINGM, POLYGONM,
+              MULTIPOINTM, MULTILINESTRINGM, MULTIPOLYGONM,
+              GEOMETRYCOLLECTIONM. For heterogeneous (mixed-type) collections,
+              you can use &#34;GEOMETRY&#34; as the type.</para>
 
               <note>
                 <para>This attribute is (probably) not part of the OpenGIS
-                specification, but is required for ensuring type
-                homogeneity.</para>
+                specification, but is required for ensuring type homogeneity.</para>
               </note>
             </listitem>
           </varlistentry>
@@ -1269,80 +1228,79 @@
 
           <listitem>
             <para>Add a spatial column to the table using the OpenGIS
-            "AddGeometryColumn" function.</para>
-	    
-	    <para>The syntax is:
-            <programlisting>AddGeometryColumn(&lt;schema_name&gt;, &lt;table_name&gt;,
-            &lt;column_name&gt;, &lt;srid&gt;, &lt;type&gt;,
-            &lt;dimension&gt;)</programlisting>
+            &#34;AddGeometryColumn&#34; function.</para>
 
-	    Or, using current schema:
-            <programlisting>AddGeometryColumn(&lt;table_name&gt;,
-            &lt;column_name&gt;, &lt;srid&gt;, &lt;type&gt;,
-            &lt;dimension&gt;)</programlisting>
-	    </para>
+            <para>The syntax is: <programlisting>AddGeometryColumn(&#60;schema_name&#62;,
+            &#60;table_name&#62;, &#60;column_name&#62;, &#60;srid&#62;,
+            &#60;type&#62;, &#60;dimension&#62;)</programlisting> Or, using
+            current schema: <programlisting>AddGeometryColumn(&#60;table_name&#62;,
+            &#60;column_name&#62;, &#60;srid&#62;, &#60;type&#62;,
+            &#60;dimension&#62;)</programlisting></para>
 
-            <para>Example1: <command>SELECT AddGeometryColumn('public',
-            'roads_geom', 'geom', 423, 'LINESTRING', 2)</command></para>
+            <para>Example1: <command>SELECT
+            AddGeometryColumn(&#39;public&#39;, &#39;roads_geom&#39;,
+            &#39;geom&#39;, 423, &#39;LINESTRING&#39;, 2)</command></para>
+
             <para>Example2: <command>SELECT AddGeometryColumn(
-            'roads_geom', 'geom', 423, 'LINESTRING', 2)</command></para>
+            &#39;roads_geom&#39;, &#39;geom&#39;, 423, &#39;LINESTRING&#39;,
+            2)</command></para>
           </listitem>
         </itemizedlist>
 
         <para>Here is an example of SQL used to create a table and add a
-        spatial column (assuming that an SRID of 128
-        exists already):</para>
+        spatial column (assuming that an SRID of 128 exists already):</para>
 
-        <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 );</programlisting>
+        <programlisting>CREATE TABLE parks ( PARK_ID int4, PARK_NAME
+        varchar(128), PARK_DATE date, PARK_TYPE varchar(2) ); SELECT
+        AddGeometryColumn(&#39;parks&#39;, &#39;park_geom&#39;, 128,
+        &#39;MULTIPOLYGON&#39;, 2 );</programlisting>
 
-        <para>Here is another example, using the generic "geometry" type and
-        the undefined SRID value of -1:</para>
+        <para>Here is another example, using the generic &#34;geometry&#34;
+        type and the undefined SRID value of -1:</para>
 
-        <programlisting>CREATE TABLE roads ( ROAD_ID int4, ROAD_NAME varchar(128) ); 
-SELECT AddGeometryColumn( 'roads', 'roads_geom', -1, 'GEOMETRY', 3 );</programlisting>
+        <programlisting>CREATE TABLE roads ( ROAD_ID int4, ROAD_NAME
+        varchar(128) ); SELECT AddGeometryColumn( &#39;roads&#39;,
+        &#39;roads_geom&#39;, -1, &#39;GEOMETRY&#39;, 3 );</programlisting>
       </sect2>
 
       <sect2>
         <title>Ensuring OpenGIS compliancy of geometries</title>
 
-        <para>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
-	<link linkend="IsValid">IsValid()</link> function:</para>
+        <para>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 <link linkend="IsValid">IsValid()</link> function:</para>
 
-        <programlisting>gisdb=# select isvalid('LINESTRING(0 0, 1 1)'), isvalid('LINESTRING(0 0,0 0)');
- isvalid | isvalid
----------+---------
- t       | f</programlisting>
-        
-        
-        <para>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:</para>
+        <programlisting>gisdb=# select isvalid(&#39;LINESTRING(0 0, 1
+        1)&#39;), isvalid(&#39;LINESTRING(0 0,0 0)&#39;); isvalid | isvalid
+        ---------+--------- t | f</programlisting>
 
-        <programlisting>ALTER TABLE mytable ADD CONSTRAINT geometry_valid_check CHECK (isvalid(the_geom));</programlisting>
+        <para>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:</para>
 
-        <para>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.</para>
+        <programlisting>ALTER TABLE mytable ADD CONSTRAINT
+        geometry_valid_check CHECK (isvalid(the_geom));</programlisting>
 
-	<note>
-	<para>
-	Strictly compliant OGC geometries cannot have Z or M values.
-	The <link linkend="IsValid">IsValid()</link> function won't
-	consider higher dimensioned geometries invalid! Invocations
-	of <link linkend="AddGeometryColumn">AddGeometryColumn()</link>
-        will add a constraint checking geometry dimensions, so it is
-        enough to specify 2 there.
-	</para>
-	</note>
+        <para>If you encounter any strange error messages such as &#34;GEOS
+        Intersection() threw an error!&#34; or &#34;JTS Intersection() threw
+        an error!&#34; 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.</para>
 
-      </sect2>    
+        <note>
+          <para>Strictly compliant OGC geometries cannot have Z or M values.
+          The <link linkend="IsValid">IsValid()</link> function won&#39;t
+          consider higher dimensioned geometries invalid! Invocations of <link
+          linkend="AddGeometryColumn">AddGeometryColumn()</link> will add a
+          constraint checking geometry dimensions, so it is enough to specify
+          2 there.</para>
+        </note>
+      </sect2>
     </sect1>
 
     <sect1>
@@ -1359,23 +1317,30 @@
         <para>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.</para>
+        loaded by piping a large text file full of SQL &#34;INSERT&#34;
+        statements into the SQL terminal monitor.</para>
 
         <para>A data upload file (<filename>roads.sql</filename> for example)
         might look like this:</para>
 
-        <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;</programlisting>
+        <programlisting>BEGIN; INSERT INTO ROADS_GEOM (ID,GEOM,NAME ) VALUES
+        (1,GeomFromText(&#39;LINESTRING(191232 243118,191108
+        243242)&#39;,-1),&#39;Jeff Rd&#39;); INSERT INTO ROADS_GEOM
+        (ID,GEOM,NAME ) VALUES (2,GeomFromText(&#39;LINESTRING(189141
+        244158,189265 244817)&#39;,-1),&#39;Geordie Rd&#39;); INSERT INTO
+        ROADS_GEOM (ID,GEOM,NAME ) VALUES
+        (3,GeomFromText(&#39;LINESTRING(192783 228138,192612
+        229814)&#39;,-1),&#39;Paul St&#39;); INSERT INTO ROADS_GEOM
+        (ID,GEOM,NAME ) VALUES (4,GeomFromText(&#39;LINESTRING(189412
+        252431,189631 259122)&#39;,-1),&#39;Graeme Ave&#39;); INSERT INTO
+        ROADS_GEOM (ID,GEOM,NAME ) VALUES
+        (5,GeomFromText(&#39;LINESTRING(190131 224148,190871
+        228134)&#39;,-1),&#39;Phil Tce&#39;); INSERT INTO ROADS_GEOM
+        (ID,GEOM,NAME ) VALUES (6,GeomFromText(&#39;LINESTRING(198231
+        263418,198213 268322)&#39;,-1),&#39;Dave Cres&#39;); COMMIT;</programlisting>
 
         <para>The data file can be piped into PostgreSQL very easily using the
-        "psql" SQL terminal monitor:</para>
+        &#34;psql&#34; SQL terminal monitor:</para>
 
         <programlisting>psql -d [database] -f roads.sql</programlisting>
       </sect2>
@@ -1421,7 +1386,7 @@
             <term>-p</term>
 
             <listitem>
-              <para>Only produces the table creation SQL code, without adding 
+              <para>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.</para>
             </listitem>
@@ -1431,15 +1396,15 @@
             <term>-D</term>
 
             <listitem>
-              <para>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.</para>
+              <para>Use the PostgreSQL &#34;dump&#34; format for the output
+              data. This can be combined with -a, -c and -d. It is much faster
+              to load than the default &#34;insert&#34; SQL format. Use this
+              for very large data sets.</para>
             </listitem>
           </varlistentry>
 
           <varlistentry>
-            <term>-s &lt;SRID&gt;</term>
+            <term>-s &#60;SRID&#62;</term>
 
             <listitem>
               <para>Creates and populates the geometry tables with the
@@ -1451,7 +1416,9 @@
             <term>-k</term>
 
             <listitem>
-              <para>Keep identifiers' case (column, schema and attributes). Note that attributes in Shapefile are all UPPERCASE.</para>
+              <para>Keep identifiers&#39; case (column, schema and
+              attributes). Note that attributes in Shapefile are all
+              UPPERCASE.</para>
             </listitem>
           </varlistentry>
 
@@ -1477,29 +1444,24 @@
             <term>-w</term>
 
             <listitem>
-              <para>
-       	      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.
-              </para>
+              <para>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.</para>
             </listitem>
           </varlistentry>
 
           <varlistentry>
-            <term>-W &lt;encoding&gt;</term>
+            <term>-W &#60;encoding&#62;</term>
 
             <listitem>
-		<para>
-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 <code>SET
-CLIENT_ENCODING to UTF8</code> command, so that the backend will be able
-to reconvert from UTF8 to whatever encoding the database is configured
-to use internally.
-		</para>
+              <para>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
+              <code>SET CLIENT_ENCODING to UTF8</code> command, so that the
+              backend will be able to reconvert from UTF8 to whatever encoding
+              the database is configured to use internally.</para>
             </listitem>
           </varlistentry>
-
         </variablelist>
 
         <para>Note that -a, -c, -d and -p are mutually exclusive.</para>
@@ -1507,13 +1469,14 @@
         <para>An example session using the loader to create an input file and
         uploading it might look like this:</para>
 
-        <programlisting># shp2pgsql shaperoads myschema.roadstable &gt; roads.sql 
-# psql -d roadsdb -f roads.sql</programlisting>
+        <programlisting># shp2pgsql shaperoads myschema.roadstable &#62;
+        roads.sql # psql -d roadsdb -f roads.sql</programlisting>
 
         <para>A conversion and upload can be done all in one step using UNIX
         pipes:</para>
 
-        <programlisting># shp2pgsql shaperoads myschema.roadstable | psql -d roadsdb</programlisting>
+        <programlisting># shp2pgsql shaperoads myschema.roadstable | psql -d
+        roadsdb</programlisting>
       </sect2>
     </sect1>
 
@@ -1522,8 +1485,7 @@
 
       <para>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.</para>
+      the operators available to do comparisons and queries on spatial tables.</para>
 
       <sect2>
         <title>Using SQL</title>
@@ -1532,17 +1494,16 @@
         database is to use a SQL select query and dump the resulting columns
         into a parsable text file:</para>
 
-        <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)</programlisting>
+        <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)</programlisting>
 
         <para>However, there will be times when some kind of restriction is
         necessary to cut down the number of fields returned. In the case of
@@ -1552,7 +1513,7 @@
 
         <variablelist>
           <varlistentry>
-            <term>&amp;&amp;</term>
+            <term>&#38;&#38;</term>
 
             <listitem>
               <para>This operator tells whether the bounding box of one
@@ -1565,8 +1526,9 @@
 
             <listitem>
               <para>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).</para>
+              geometrically identical. For example, if &#39;POLYGON((0 0,1 1,1
+              0,0 0))&#39; is the same as &#39;POLYGON((0 0,1 1,1 0,0 0))&#39;
+              (it is).</para>
             </listitem>
           </varlistentry>
 
@@ -1583,42 +1545,36 @@
         <para>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:</para>
+        the &#34;GeomFromText()&#34; function. So, for example:</para>
 
-        <programlisting>SELECT 
-  ID, NAME 
-FROM ROADS_GEOM 
-WHERE 
-  GEOM ~= GeomFromText('LINESTRING(191232 243118,191108 243242)',-1);</programlisting>
+        <programlisting>SELECT ID, NAME FROM ROADS_GEOM WHERE GEOM ~=
+        GeomFromText(&#39;LINESTRING(191232 243118,191108 243242)&#39;,-1);</programlisting>
 
         <para>The above query would return the single record from the
-        "ROADS_GEOM" table in which the geometry was equal to that
+        &#34;ROADS_GEOM&#34; table in which the geometry was equal to that
         value.</para>
 
-        <para>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
+        <para>When using the &#34;&#38;&#38;&#34; 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.</para>
 
-        <programlisting>SELECT 
-  ID, NAME 
-FROM ROADS_GEOM 
-WHERE 
-  GEOM &amp;&amp; GeomFromText('POLYGON((191232 243117,191232 243119,191234 243117,191232 243117))',-1);</programlisting>
+        <programlisting>SELECT ID, NAME FROM ROADS_GEOM WHERE GEOM &#38;&#38;
+        GeomFromText(&#39;POLYGON((191232 243117,191232 243119,191234
+        243117,191232 243117))&#39;,-1);</programlisting>
 
         <para>The above query will use the bounding box of the polygon for
         comparison purposes.</para>
 
-        <para>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:</para>
+        <para>The most common spatial query will probably be a
+        &#34;frame-based&#34; query, used by client software, like data
+        browsers and web mappers, to grab a &#34;map frame&#34; worth of data
+        for display. Using a &#34;BOX3D&#34; object for the frame, such a
+        query looks like this:</para>
 
-        <programlisting>SELECT 
-  AsText(GEOM) AS GEOM 
-FROM ROADS_GEOM 
-WHERE 
-  GEOM &amp;&amp; SetSRID('BOX3D(191232 243117,191232 243119)'::box3d,-1);</programlisting>
+        <programlisting>SELECT AsText(GEOM) AS GEOM FROM ROADS_GEOM WHERE GEOM
+        &#38;&#38; SetSRID(&#39;BOX3D(191232 243117,191232
+        243119)&#39;::box3d,-1);</programlisting>
 
         <para>Note the use of the SRID, to specify the projection of the
         BOX3D. The value -1 is used to indicate no specified SRID.</para>
@@ -1628,18 +1584,20 @@
         <title>Using the Dumper</title>
 
         <para>The <filename>pgsql2shp</filename> table dumper connects
-        directly to the database and converts a table (possibly defined by
-	a query) into a shape file. The
-        basic syntax is:</para>
+        directly to the database and converts a table (possibly defined by a
+        query) into a shape file. The basic syntax is:</para>
 
-        <programlisting>pgsql2shp [&lt;options&gt;] &lt;database&gt; [&lt;schema&gt;.]&lt;table&gt;</programlisting>
-        <programlisting>pgsql2shp [&lt;options&gt;] &lt;database&gt; &lt;query&gt;</programlisting>
+        <programlisting>pgsql2shp [&#60;options&#62;] &#60;database&#62;
+        [&#60;schema&#62;.]&#60;table&#62;</programlisting>
 
+        <programlisting>pgsql2shp [&#60;options&#62;] &#60;database&#62;
+        &#60;query&#62;</programlisting>
+
         <para>The commandline options are:</para>
 
         <variablelist>
           <varlistentry>
-            <term>-f &lt;filename&gt;</term>
+            <term>-f &#60;filename&#62;</term>
 
             <listitem>
               <para>Write the output to a particular filename.</para>
@@ -1647,7 +1605,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>-h &lt;host&gt;</term>
+            <term>-h &#60;host&#62;</term>
 
             <listitem>
               <para>The database host to connect to.</para>
@@ -1655,7 +1613,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>-p &lt;port&gt;</term>
+            <term>-p &#60;port&#62;</term>
 
             <listitem>
               <para>The port to connect to on the database host.</para>
@@ -1663,25 +1621,23 @@
           </varlistentry>
 
           <varlistentry>
-            <term>-P &lt;password&gt;</term>
+            <term>-P &#60;password&#62;</term>
 
             <listitem>
-              <para>The password to use when connecting to the
-              database.</para>
+              <para>The password to use when connecting to the database.</para>
             </listitem>
           </varlistentry>
 
           <varlistentry>
-            <term>-u &lt;user&gt;</term>
+            <term>-u &#60;user&#62;</term>
 
             <listitem>
-              <para>The username to use when connecting to the
-              database.</para>
+              <para>The username to use when connecting to the database.</para>
             </listitem>
           </varlistentry>
 
           <varlistentry>
-            <term>-g &lt;geometry column&gt;</term>
+            <term>-g &#60;geometry column&#62;</term>
 
             <listitem>
               <para>In the case of tables with multiple geometry columns, the
@@ -1694,8 +1650,8 @@
 
             <listitem>
               <para>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.</para>
+              but will not work if any NON-geometry attribute in the table
+              lacks a cast to text.</para>
             </listitem>
           </varlistentry>
 
@@ -1712,14 +1668,12 @@
             <term>-d</term>
 
             <listitem>
-	      <para>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.
-	      </para>
+              <para>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.</para>
             </listitem>
           </varlistentry>
-
         </variablelist>
       </sect2>
     </sect1>
@@ -1729,11 +1683,11 @@
 
       <para>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.</para>
+      &#34;sequential scan&#34; 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.</para>
 
       <itemizedlist>
         <listitem>
@@ -1752,32 +1706,32 @@
 
         <listitem>
           <para>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.</para>
+          &#34;things to one side&#34;, &#34;things which overlap&#34;,
+          &#34;things which are inside&#34; 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.</para>
         </listitem>
       </itemizedlist>
 
       <sect2>
         <title>GiST Indexes</title>
 
-        <para>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
+        <para>GiST stands for &#34;Generalized Search Tree&#34; 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.</para>
 
         <para>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).</para>
+        your searches are based on attributes, in which case you&#39;ll want
+        to build a normal index on the attribute fields).</para>
 
-        <para>The syntax for building a GiST index on a "geometry" column is
-        as follows:</para>
+        <para>The syntax for building a GiST index on a &#34;geometry&#34;
+        column is as follows:</para>
 
-        <para><programlisting>CREATE INDEX [indexname] ON [tablename] 
-  USING GIST ( [geometryfield] GIST_GEOMETRY_OPS ); </programlisting></para>
+        <para><programlisting>CREATE INDEX [indexname] ON [tablename] USING
+        GIST ( [geometryfield] GIST_GEOMETRY_OPS ); </programlisting></para>
 
         <para>Building a spatial index is a computationally intensive
         exercise: on tables of around 1 million rows, on a 300MHz Solaris
@@ -1785,20 +1739,19 @@
         building an index, it is important to force PostgreSQL to collect
         table statistics, which are used to optimize query plans:</para>
 
-        <para><programlisting>VACUUM ANALYZE [table_name] [column_name];
+        <para><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]);</programlisting></para>
 
--- This is only needed for PostgreSQL 7.4 installations and below
-SELECT UPDATE_GEOMETRY_STATS([table_name], [column_name]);</programlisting></para>
-
         <para>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.</para>
+        PostgreSQL. Firstly, GiST indexes are &#34;null safe&#34;, meaning
+        they can index columns which include null values. Secondly, GiST
+        indexes support the concept of &#34;lossiness&#34; which is important
+        when dealing with GIS objects larger than the PostgreSQL 8K page size.
+        Lossiness allows PostgreSQL to store only the &#34;important&#34; 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.</para>
       </sect2>
 
       <sect2>
@@ -1821,31 +1774,28 @@
             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 <command>update_geometry_stats([table_name,
-            column_name])</command> (compute distribution) and <command>VACUUM
-            ANALYZE [table_name] [column_name]</command> (compute number of
-            values). Starting with PostgreSQL 8.0 running <command>VACUUM
-            ANALYZE</command> will do both operations. You should regularly
-            vacuum your databases anyways -- many PostgreSQL DBAs have
-            <command>VACUUM</command> run as an off-peak cron job on a regular
-            basis.</para>
+            running <command>update_geometry_stats([table_name, column_name])</command>
+            (compute distribution) and <command>VACUUM ANALYZE [table_name]
+            [column_name]</command> (compute number of values). Starting with
+            PostgreSQL 8.0 running <command>VACUUM ANALYZE</command> will do
+            both operations. You should regularly vacuum your databases
+            anyways -- many PostgreSQL DBAs have <command>VACUUM</command> run
+            as an off-peak cron job on a regular basis.</para>
           </listitem>
 
           <listitem>
             <para>If vacuuming does not work, you can force the planner to use
-            the index information by using the <command>SET
-            ENABLE_SEQSCAN=OFF</command> 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 <varname>ENABLE_SEQSCAN</varname> back
-            on, so that other queries will utilize the planner as
-            normal.</para>
+            the index information by using the <command>SET ENABLE_SEQSCAN=OFF</command>
+            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
+            <varname>ENABLE_SEQSCAN</varname> back on, so that other queries
+            will utilize the planner as normal.</para>
 
             <note>
               <para>As of version 0.6, it should not be necessary to force the
-              planner to use the index with
-              <varname>ENABLE_SEQSCAN</varname>.</para>
+              planner to use the index with <varname>ENABLE_SEQSCAN</varname>.</para>
             </note>
           </listitem>
 
@@ -1863,7 +1813,7 @@
     <sect1>
       <title>Complex Queries</title>
 
-      <para>The <emphasis>raison d'etre</emphasis> of spatial database
+      <para>The <emphasis>raison d&#39;etre</emphasis> 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
@@ -1873,40 +1823,40 @@
         <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 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
-        large table:</para>
+        the bounding-box-based operators such as &#38;&#38; 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 large table:</para>
 
-        <programlisting>SELECT the_geom FROM geom_table
-WHERE distance( the_geom, GeomFromText( 'POINT(100000 200000)', -1 ) ) &lt; 100</programlisting>
+        <programlisting>SELECT the_geom FROM geom_table WHERE distance(
+        the_geom, GeomFromText( &#39;POINT(100000 200000)&#39;, -1 ) ) &#60;
+        100</programlisting>
 
         <para>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 <varname>distance()</varname>
         calculation for each row in the table. We can avoid this by using the
-        &amp;&amp; operator to reduce the number of distance calculations
+        &#38;&#38; operator to reduce the number of distance calculations
         required:</para>
 
-        <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</programlisting>
+        <programlisting>SELECT the_geom FROM geom_table WHERE the_geom
+        &#38;&#38; &#39;BOX3D(90900 190900, 100100 200100)&#39;::box3d AND
+        distance( the_geom, GeomFromText( &#39;POINT(100000 200000)&#39;, -1 )
+        ) &#60; 100</programlisting>
 
         <para>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
-        <varname>distance()</varname> function. Notice that the
-        <varname>BOX3D</varname> 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.</para>
+        of rows before calculating the result of the <varname>distance()</varname>
+        function. Notice that the <varname>BOX3D</varname> geometry which is
+        used in the &#38;&#38; operation is a 200 unit square box centered on
+        the original point - this is our &#34;query box&#34;. The &#38;&#38;
+        operator uses the index to quickly reduce the result set down to only
+        those geometries which have bounding boxes that overlap the &#34;query
+        box&#34;. 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.</para>
       </sect2>
 
       <sect2>
@@ -1917,189 +1867,159 @@
         boundaries. The table definitions for the <varname>bc_roads</varname>
         table is:</para>
 
-        <programlisting>  Column    |       Type        |   Description
-------------+-------------------+-------------------
- gid        | integer           | Unique ID
- name       | character varying | Road Name
- the_geom   | geometry          | Location Geometry (Linestring)</programlisting>
+        <programlisting>Column | Type | Description
+        ------------+-------------------+------------------- gid | integer |
+        Unique ID name | character varying | Road Name the_geom | geometry |
+        Location Geometry (Linestring)</programlisting>
 
         <para>The table definition for the <varname>bc_municipality</varname>
         table is:</para>
 
-        <programlisting>  Column   |       Type        |   Description
------------+-------------------+-------------------
- gid       | integer           | Unique ID
- code      | integer           | Unique ID
- name      | character varying | City / Town Name
- the_geom  | geometry          | Location Geometry (Polygon)</programlisting>
+        <programlisting>Column | Type | Description
+        -----------+-------------------+------------------- gid | integer |
+        Unique ID code | integer | Unique ID name | character varying | City /
+        Town Name the_geom | geometry | Location Geometry (Polygon)</programlisting>
 
         <qandaset>
-            <qandaentry>
-              <question>
-                <para>What is the total length of all roads, expressed in
-                kilometers?</para>
-              </question>
+          <qandaentry>
+            <question>
+              <para>What is the total length of all roads, expressed in
+              kilometers?</para>
+            </question>
 
-              <answer>
-                <para>You can answer this question with a very simple piece of
-                SQL:</para>
+            <answer>
+              <para>You can answer this question with a very simple piece of
+              SQL:</para>
 
-                <programlisting>postgis=# SELECT sum(length(the_geom))/1000 AS km_roads FROM bc_roads;
-     km_roads
-------------------
- 70842.1243039643
-(1 row)</programlisting>
-              </answer>
-            </qandaentry>
+              <programlisting>postgis=# SELECT sum(length(the_geom))/1000 AS
+              km_roads FROM bc_roads; km_roads ------------------
+              70842.1243039643 (1 row)</programlisting>
+            </answer>
+          </qandaentry>
 
-            <qandaentry>
-              <question>
-                <para>How large is the city of Prince George, in
-                hectares?</para>
-              </question>
+          <qandaentry>
+            <question>
+              <para>How large is the city of Prince George, in hectares?</para>
+            </question>
 
-              <answer>
-                <para>This query combines an attribute condition (on the
-                municipality name) with a spatial calculation (of the
-                area):</para>
+            <answer>
+              <para>This query combines an attribute condition (on the
+              municipality name) with a spatial calculation (of the area):</para>
 
-                <programlisting>postgis=# SELECT area(the_geom)/10000 AS hectares FROM bc_municipality 
-          WHERE name = 'PRINCE GEORGE';
-     hectares
-------------------
- 32657.9103824927
-(1 row) </programlisting>
-              </answer>
-            </qandaentry>
+              <programlisting>postgis=# SELECT area(the_geom)/10000 AS
+              hectares FROM bc_municipality WHERE name = &#39;PRINCE
+              GEORGE&#39;; hectares ------------------ 32657.9103824927 (1
+              row)</programlisting>
+            </answer>
+          </qandaentry>
 
-            <qandaentry>
-              <question>
-                <para>What is the largest municipality in the province, by
-                area?</para>
-              </question>
+          <qandaentry>
+            <question>
+              <para>What is the largest municipality in the province, by area?</para>
+            </question>
 
-              <answer>
-                <para>This query brings a spatial measurement into the query
-                condition. There are several ways of approaching this problem,
-                but the most efficient is below:</para>
+            <answer>
+              <para>This query brings a spatial measurement into the query
+              condition. There are several ways of approaching this problem,
+              but the most efficient is below:</para>
 
-                <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)</programlisting>
+              <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)</programlisting>
 
-                <para>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().</para>
-              </answer>
-            </qandaentry>
+              <para>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
+              &#34;LIMIT&#34; command we can easily pick off the largest value
+              without using an aggregate function like max().</para>
+            </answer>
+          </qandaentry>
 
-            <qandaentry>
-              <question>
-                <para>What is the length of roads fully contained within each
-                municipality?</para>
-              </question>
+          <qandaentry>
+            <question>
+              <para>What is the length of roads fully contained within each
+              municipality?</para>
+            </question>
 
-              <answer>
-                <para>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:</para>
+            <answer>
+              <para>This is an example of a &#34;spatial join&#34;, because we
+              are bringing together data from two tables (doing a join) but
+              using a spatial interaction condition (&#34;contained&#34;) as
+              the join condition rather than the usual relational approach of
+              joining on a common key:</para>
 
-                <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;
+              <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 &#38;&#38; 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 ...</programlisting>
 
-            name            |     roads_km
-----------------------------+------------------
- SURREY                     | 1539.47553551242
- VANCOUVER                  | 1450.33093486576
- LANGLEY DISTRICT           | 833.793392535662
- BURNABY                    | 773.769091404338
- PRINCE GEORGE              |  694.37554369147
- ...</programlisting>
+              <para>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.</para>
+            </answer>
+          </qandaentry>
 
-                <para>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.</para>
-              </answer>
-            </qandaentry>
+          <qandaentry>
+            <question>
+              <para>Create a new table with all the roads within the city of
+              Prince George.</para>
+            </question>
 
-            <qandaentry>
-              <question>
-                <para>Create a new table with all the roads within the city of
-                Prince George.</para>
-              </question>
+            <answer>
+              <para>This is an example of an &#34;overlay&#34;, which takes in
+              two tables and outputs a new table that consists of spatially
+              clipped or cut resultants. Unlike the &#34;spatial join&#34;
+              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:</para>
 
-              <answer>
-                <para>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:</para>
+              <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 &#38;&#38; m.the_geom AND
+              intersects(r.the_geom, m.the_geom) AND m.name = &#39;PRINCE
+              GEORGE&#39;;</programlisting>
+            </answer>
+          </qandaentry>
 
-                <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';</programlisting>
-              </answer>
-            </qandaentry>
+          <qandaentry>
+            <question>
+              <para>What is the length in kilometers of &#34;Douglas St&#34;
+              in Victoria?</para>
+            </question>
 
-            <qandaentry>
-              <question>
-                <para>What is the length in kilometers of "Douglas St" in
-                Victoria?</para>
-              </question>
+            <answer>
+              <programlisting>postgis=# SELECT sum(length(r.the_geom))/1000 AS
+              kilometers FROM bc_roads r, bc_municipality m WHERE r.the_geom
+              &#38;&#38; m.the_geom AND r.name = &#39;Douglas St&#39; AND
+              m.name = &#39;VICTORIA&#39;; kilometers ------------------
+              4.89151904172838 (1 row)</programlisting>
+            </answer>
+          </qandaentry>
 
-              <answer>
-                <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)</programlisting>
-              </answer>
-            </qandaentry>
+          <qandaentry>
+            <question>
+              <para>What is the largest municipality polygon that has a hole?</para>
+            </question>
 
-            <qandaentry>
-              <question>
-                <para>What is the largest municipality polygon that has a
-                hole?</para>
-              </question>
-
-              <answer>
-                <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)</programlisting>
-              </answer>
-            </qandaentry>
+            <answer>
+              <programlisting>postgis=# SELECT gid, name, area(the_geom) AS
+              area FROM bc_municipality WHERE nrings(the_geom) &#62; 1 ORDER
+              BY area DESC LIMIT 1; gid | name | area
+              -----+--------------+------------------ 12 | SPALLUMCHEEN |
+              257374619.430216 (1 row)</programlisting>
+            </answer>
+          </qandaentry>
         </qandaset>
       </sect2>
     </sect1>
@@ -2145,13 +2065,13 @@
         <para>Mapserver accesses PostGIS/PostgreSQL data like any other
         PostgreSQL client -- using <filename>libpq</filename>. This means that
         Mapserver can be installed on any machine with network access to the
-        PostGIS server, as long as the system has the
-        <filename>libpq</filename> PostgreSQL client libraries.</para>
+        PostGIS server, as long as the system has the <filename>libpq</filename>
+        PostgreSQL client libraries.</para>
 
         <orderedlist>
           <listitem>
             <para>Compile and install Mapserver, with whatever options you
-            desire, including the "--with-postgis" configuration
+            desire, including the &#34;--with-postgis&#34; configuration
             option.</para>
           </listitem>
 
@@ -2159,30 +2079,18 @@
             <para>In your Mapserver map file, add a PostGIS layer. For
             example:</para>
 
-            <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</programlisting>
+            <programlisting>LAYER CONNECTIONTYPE postgis NAME
+            &#34;widehighways&#34; # Connect to a remote spatial database
+            CONNECTION &#34;user=dbuser dbname=gisdatabase host=bigserver&#34;
+            # Get the lines from the &#39;geom&#39; column of the
+            &#39;roads&#39; table DATA &#34;geom from roads&#34; STATUS ON
+            TYPE LINE # Of the lines in the extents, only render the wide
+            highways FILTER &#34;type = &#39;highway&#39; and numlanes &#62;=
+            4&#34; CLASS # Make the superhighways brighter and 2 pixels wide
+            EXPRESSION ([numlanes] &#62;= 6) COLOR 255 22 22 SYMBOL
+            &#34;solid&#34; SIZE 2 END CLASS # All the rest are darker and
+            only 1 pixel wide EXPRESSION ([numlanes] &#60; 6) COLOR 205 92 82
+            END END</programlisting>
 
             <para>In the example above, the PostGIS-specific directives are as
             follows:</para>
@@ -2192,7 +2100,7 @@
                 <term>CONNECTIONTYPE</term>
 
                 <listitem>
-                  <para>For PostGIS layers, this is always "postgis".</para>
+                  <para>For PostGIS layers, this is always &#34;postgis&#34;.</para>
                 </listitem>
               </varlistentry>
 
@@ -2201,13 +2109,13 @@
 
                 <listitem>
                   <para>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;):</para>
+                  &#39;connection string&#39; which is a standard set of keys
+                  and values like this (with the default values in
+                  &#60;&#62;):</para>
 
-                  <para>user=&lt;username&gt; password=&lt;password&gt;
-                  dbname=&lt;username&gt; hostname=&lt;server&gt;
-                  port=&lt;5432&gt;</para>
+                  <para>user=&#60;username&#62; password=&#60;password&#62;
+                  dbname=&#60;username&#62; hostname=&#60;server&#62;
+                  port=&#60;5432&#62;</para>
 
                   <para>An empty connection string is still valid, and any of
                   the key/value pairs can be omitted. At a minimum you will
@@ -2220,9 +2128,9 @@
                 <term>DATA</term>
 
                 <listitem>
-                  <para>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.</para>
+                  <para>The form of this parameter is &#34;&#60;column&#62;
+                  from &#60;tablename&#62;&#34; where the column is the
+                  spatial column to be rendered to the map.</para>
                 </listitem>
               </varlistentry>
 
@@ -2231,9 +2139,9 @@
 
                 <listitem>
                   <para>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".</para>
+                  the logic normally following the &#34;WHERE&#34; keyword in
+                  a SQL query. So, for example, to render only roads with 6 or
+                  more lanes, use a filter of &#34;num_lanes &#62;= 6&#34;.</para>
                 </listitem>
               </varlistentry>
             </variablelist>
@@ -2243,14 +2151,13 @@
             <para>In your spatial database, ensure you have spatial (GiST)
             indexes built for any the layers you will be drawing.</para>
 
-            <programlisting>CREATE INDEX [indexname]
-  ON [tablename] 
-  USING GIST ( [geometrycolumn] GIST_GEOMETRY_OPS );</programlisting>
+            <programlisting>CREATE INDEX [indexname] ON [tablename] USING GIST
+            ( [geometrycolumn] GIST_GEOMETRY_OPS );</programlisting>
           </listitem>
 
           <listitem>
             <para>If you will be querying your layers using Mapserver you will
-            also need an "oid index".</para>
+            also need an &#34;oid index&#34;.</para>
 
             <para>Mapserver requires unique identifiers for each spatial
             record when doing queries, and the PostGIS module of Mapserver
@@ -2259,7 +2166,7 @@
             fast random access of records during queries, an index on the
             <varname>oid</varname> is needed.</para>
 
-            <para>To build an "oid index", use the following SQL:</para>
+            <para>To build an &#34;oid index&#34;, use the following SQL:</para>
 
             <programlisting>CREATE INDEX [indexname] ON [tablename] ( oid );</programlisting>
           </listitem>
@@ -2270,86 +2177,89 @@
         <title>Frequently Asked Questions</title>
 
         <qandaset>
-            <qandaentry>
-              <question>
-                <para>When I use an <varname>EXPRESSION</varname> in my map
-                file, the condition never returns as true, even though I know
-                the values exist in my table.</para>
-              </question>
+          <qandaentry>
+            <question>
+              <para>When I use an <varname>EXPRESSION</varname> in my map
+              file, the condition never returns as true, even though I know
+              the values exist in my table.</para>
+            </question>
 
-              <answer>
-                <para>Unlike shape files, PostGIS field names have to be
-                referenced in EXPRESSIONS using <emphasis>lower
-                case</emphasis>.</para>
+            <answer>
+              <para>Unlike shape files, PostGIS field names have to be
+              referenced in EXPRESSIONS using <emphasis>lower case</emphasis>.</para>
 
-                <programlisting>EXPRESSION ([numlanes] &gt;= 6)</programlisting>
-              </answer>
-            </qandaentry>
+              <programlisting>EXPRESSION ([numlanes] &#62;= 6)</programlisting>
+            </answer>
+          </qandaentry>
 
-            <qandaentry>
-              <question>
-                <para>The FILTER I use for my Shape files is not working for
-                my PostGIS table of the same data.</para>
-              </question>
+          <qandaentry>
+            <question>
+              <para>The FILTER I use for my Shape files is not working for my
+              PostGIS table of the same data.</para>
+            </question>
 
-              <answer>
-                <para>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).</para>
+            <answer>
+              <para>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).</para>
 
-                <programlisting>FILTER "type = 'highway' and numlanes &gt;= 4"</programlisting>
-              </answer>
-            </qandaentry>
+              <programlisting>FILTER &#34;type = &#39;highway&#39; and
+              numlanes &#62;= 4&#34;</programlisting>
+            </answer>
+          </qandaentry>
 
-            <qandaentry>
-              <question>
-                <para>My PostGIS layer draws much slower than my Shape file
-                layer, is this normal?</para>
-              </question>
+          <qandaentry>
+            <question>
+              <para>My PostGIS layer draws much slower than my Shape file
+              layer, is this normal?</para>
+            </question>
 
-              <answer>
-                <para>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.</para>
+            <answer>
+              <para>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.</para>
 
-                <para>If you are finding substantial draw performance
-                problems, it is likely that you have not build a spatial index
-                on your table.</para>
+              <para>If you are finding substantial draw performance problems,
+              it is likely that you have not build a spatial index on your
+              table.</para>
 
-                <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</programlisting>
-              </answer>
-            </qandaentry>
+              <programlisting>postgis# CREATE INDEX geotable_gix ON geotable
+              USING GIST ( geocolumn ); postgis# SELECT
+              update_geometry_stats(); -- For PGSQL &#60; 8.0 postgis# VACUUM
+              ANALYZE; -- For PGSQL &#62;= 8.0</programlisting>
+            </answer>
+          </qandaentry>
 
-            <qandaentry>
-              <question>
-                <para>My PostGIS layer draws fine, but queries are really
-                slow. What is wrong?</para>
-              </question>
+          <qandaentry>
+            <question>
+              <para>My PostGIS layer draws fine, but queries are really slow.
+              What is wrong?</para>
+            </question>
 
-              <answer>
-                <para>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.</para>
+            <answer>
+              <para>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.</para>
 
-                <para>You can specify what unique key for mapserver to use
-                with the <varname>USING UNIQUE</varname> clause in your
-                <varname>DATA</varname> line:</para>
+              <para>You can specify what unique key for mapserver to use with
+              the <varname>USING UNIQUE</varname> clause in your
+              <varname>DATA</varname> line:</para>
 
-                <programlisting>DATA "the_geom FROM geotable USING UNIQUE gid"</programlisting>
+              <programlisting>DATA &#34;the_geom FROM geotable USING UNIQUE
+              gid&#34;</programlisting>
 
-                <para>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.</para>
+              <para>If your table does not have an explicit unique column, you
+              can &#34;fake&#34; a unique column by using the PostgreSQL row
+              &#34;oid&#34; for your unique column. &#34;oid&#34; 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.</para>
 
-                <programlisting>postgis# CREATE INDEX geotable_oid_idx ON geotable (oid);</programlisting>
-              </answer>
-            </qandaentry>
+              <programlisting>postgis# CREATE INDEX geotable_oid_idx ON
+              geotable (oid);</programlisting>
+            </answer>
+          </qandaentry>
         </qandaset>
       </sect2>
 
@@ -2359,30 +2269,32 @@
         <para>The <varname>USING</varname> 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
-        <varname>DATA</varname> definition) it is more difficult for mapserver
-        to automatically determine a unique identifier for each row and also
-        the SRID for the table. The <varname>USING</varname> clause can
-        provide mapserver with these two pieces of information as
-        follows:</para>
+        is used as the source table (the thing to the right of &#34;FROM&#34;
+        in a <varname>DATA</varname> definition) it is more difficult for
+        mapserver to automatically determine a unique identifier for each row
+        and also the SRID for the table. The <varname>USING</varname> clause
+        can provide mapserver with these two pieces of information as follows:</para>
 
-        <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"</programlisting>
+        <programlisting>DATA &#34;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&#34;</programlisting>
 
         <variablelist>
           <varlistentry>
-            <term>USING UNIQUE &lt;uniqueid&gt;</term>
+            <term>USING UNIQUE &#60;uniqueid&#62;</term>
 
             <listitem>
               <para>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 <varname>USING
-              UNIQUE</varname>. 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.</para>
+              the oid as the unique identifier, but views and subselects
+              don&#39;t automatically have an oid column. If you want to use
+              Mapserver&#39;s query functionality, you need to add a unique
+              column to your view or subselect, and declare it with
+              <varname>USING UNIQUE</varname>. For example, you could
+              explicitly select one of the table&#39;s oid values for this
+              purpose, or any other column which is guaranteed to be unique
+              for the result set.</para>
 
               <para>The <varname>USING</varname> statement can also be useful
               even for simple <varname>DATA</varname> statements, if you are
@@ -2390,29 +2302,29 @@
               on the oid column of tables used in query-able layers, in order
               to speed up the performance of map queries. However, with the
               <varname>USING</varname> 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
+              mapserver to use your table&#39;s primary key as the identifier
+              for map queries, and then it is no longer necessary to have an
               additional index.</para>
 
               <note>
-                <para>"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
-                <varname>DATA</varname> definition.</para>
+                <para>&#34;Querying a Map&#34; is the action of clicking on a
+                map to ask for information about the map features in that
+                location. Don&#39;t confuse &#34;map queries&#34; with the SQL
+                query in a <varname>DATA</varname> definition.</para>
               </note>
             </listitem>
           </varlistentry>
 
           <varlistentry>
-            <term>USING SRID=&lt;srid&gt;</term>
+            <term>USING SRID=&#60;srid&#62;</term>
 
             <listitem>
               <para>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
+              information in the &#34;geometry_columns&#34; 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
               <varname>USING SRID=</varname> option allows the correct SRID to
               be specified in the <varname>DATA</varname> definition.</para>
             </listitem>
@@ -2434,17 +2346,10 @@
         <para>Lets start with a simple example and work our way up. Consider
         the following Mapserver layer definition:</para>
 
-        <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</programlisting>
+        <programlisting>LAYER CONNECTIONTYPE postgis NAME &#34;roads&#34;
+        CONNECTION &#34;user=theuser password=thepass dbname=thedb
+        host=theserver&#34; DATA &#34;the_geom FROM roads&#34; STATUS ON TYPE
+        LINE CLASS COLOR 0 0 0 END END</programlisting>
 
         <para>This layer will display all the road geometries in the roads
         table as black lines.</para>
@@ -2453,39 +2358,19 @@
         zoomed in to at least a 1:100000 scale - the next two layers will
         achieve this effect:</para>
 
-        <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
+        <programlisting>LAYER CONNECTION &#34;user=theuser password=thepass
+        dbname=thedb host=theserver&#34; DATA &#34;the_geom FROM roads&#34;
+        MINSCALE 100000 STATUS ON TYPE LINE FILTER &#34;road_type =
+        &#39;highway&#39;&#34; CLASS COLOR 0 0 0 END END LAYER CONNECTION
+        &#34;user=theuser password=thepass dbname=thedb host=theserver&#34;
+        DATA &#34;the_geom FROM roads&#34; MAXSCALE 100000 STATUS ON TYPE LINE
+        CLASSITEM road_type CLASS EXPRESSION &#34;highway&#34; SIZE 2 COLOR
+        255 0 0 END CLASS COLOR 0 0 0 END END</programlisting>
 
-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</programlisting>
-
         <para>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
-        <varname>FILTER</varname> option causes only roads of type "highway"
-        to be displayed.</para>
+        and displays only the roads of type &#34;highway&#34; as black lines.
+        The <varname>FILTER</varname> option causes only roads of type
+        &#34;highway&#34; to be displayed.</para>
 
         <para>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
@@ -2497,25 +2382,14 @@
         another table (for whatever reason) and we need to do a join to get it
         and label our roads.</para>
 
-        <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</programlisting>
+        <programlisting>LAYER CONNECTION &#34;user=theuser password=thepass
+        dbname=thedb host=theserver&#34; DATA &#34;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&#34; 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</programlisting>
 
         <para>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
@@ -2526,84 +2400,45 @@
     <sect1>
       <title>Java Clients (JDBC)</title>
 
-      <para>Java clients can access PostGIS "geometry" objects in the
+      <para>Java clients can access PostGIS &#34;geometry&#34; 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.</para>
+      extension objects, the &#34;postgis.jar&#34; file must be in your
+      CLASSPATH along with the &#34;postgresql.jar&#34; JDBC driver package.</para>
 
-      <programlisting>import java.sql.*; 
-import java.util.*; 
-import java.lang.*; 
-import org.postgis.*; 
+      <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(&#34;org.postgresql.Driver&#34;); String url =
+      &#34;jdbc:postgresql://localhost:5432/database&#34;; conn =
+      DriverManager.getConnection(url, &#34;postgres&#34;, &#34;&#34;); /* *
+      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(&#34;geometry&#34;,&#34;org.postgis.PGgeometry&#34;);
+      ((org.postgresql.Connection)conn).addDataType(&#34;box3d&#34;,&#34;org.postgis.PGbox3d&#34;);
+      /* * Create a statement and execute a select query. */ Statement s =
+      conn.createStatement(); ResultSet r = s.executeQuery(&#34;select
+      AsText(geom) as geom,id from geomtable&#34;); 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(&#34;Row &#34; + id + &#34;:&#34;);
+      System.out.println(geom.toString()); } s.close(); conn.close(); } catch(
+      Exception e ) { e.printStackTrace(); } } }</programlisting>
 
-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(); 
-    }  
-  }
-}</programlisting>
-
-      <para>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,
+      <para>The &#34;PGgeometry&#34; object is a wrapper object which contains
+      a specific topological geometry object (subclasses of the abstract class
+      &#34;Geometry&#34;) depending on the type: Point, LineString, Polygon,
       MultiPoint, MultiLineString, MultiPolygon.</para>
 
-      <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()); 
-    } 
-  } 
-}</programlisting>
+      <programlisting>PGgeometry geom = (PGgeometry)r.getObject(1); if(
+      geom.getType() = Geometry.POLYGON ) { Polygon pl =
+      (Polygon)geom.getGeometry(); for( int r = 0; r &#60; pl.numRings(); r++
+      ) { LinearRing rng = pl.getRing(r); System.out.println(&#34;Ring: &#34;
+      + r); for( int p = 0; p &#60; rng.numPoints(); p++ ) { Point pt =
+      rng.getPoint(p); System.out.println(&#34;Point: &#34; + p);
+      System.out.println(pt.toString()); } } }</programlisting>
 
       <para>The JavaDoc for the extension objects provides a reference for the
       various data accessor functions in the geometric objects.</para>
@@ -2628,190 +2463,153 @@
     </sect1>
   </chapter>
 
-<chapter> <title>Performance tips</title>
+  <chapter>
+    <title>Performance tips</title>
 
-<sect1> <title>Small tables of large geometries</title>
+    <sect1>
+      <title>Small tables of large geometries</title>
 
-<sect2><title>Problem description</title>
+      <sect2>
+        <title>Problem description</title>
 
-<para>
-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).
-</para>
+        <para>Current PostgreSQL versions (including 8.0) suffer from a query
+        optimizer weakness regarding TOAST tables. TOAST tables are a kind of
+        &#34;extension room&#34; 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).</para>
 
-<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
-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>
+        <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 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>
 
-<para>
-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.
-</para>
+        <para>Now issue a query where you use the geometry operator &#38;&#38;
+        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
+        &#38;&#38; operator has to fetch every geometry from disk to compare
+        the bounding boxes, thus reading all TOAST pages, too.</para>
 
-<para>
-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
-</para>
+        <para>To see whether your suffer from this bug, use the &#34;EXPLAIN
+        ANALYZE&#34; 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</para>
+      </sect2>
 
-</sect2>
+      <sect2>
+        <title>Workarounds</title>
 
-<sect2><title>Workarounds</title>
+        <para>The PostgreSQL people are trying to solve this issue by making
+        the query estimation TOAST-aware. For now, here are two workarounds:</para>
 
-<para>
-The PostgreSQL people are trying to solve this issue by making the query
-estimation TOAST-aware. For now, here are two workarounds:
-</para>
+        <para>The first workaround is to force the query planner to use the
+        index. Send &#34;SET enable_seqscan TO off;&#34; 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
+        &#34;SET enable_seqscan TO on;&#34; after the query.</para>
 
-<para>
-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.
-</para>
+        <para>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 &#34;caches&#34; the bbox, and matching against
+        this. In our example, the commands are like:</para>
 
-<para>
-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:
-</para>
+        <programlisting>SELECT
+        addGeometryColumn(&#39;myschema&#39;,&#39;mytable&#39;,&#39;bbox&#39;,&#39;4326&#39;,&#39;GEOMETRY&#39;,&#39;2&#39;);
+        UPDATE mytable set bbox = Envelope(Force_2d(the_geom));</programlisting>
 
-<programlisting>
-SELECT addGeometryColumn('myschema','mytable','bbox','4326','GEOMETRY','2');
+        <para>Now change your query to use the &#38;&#38; operator against
+        bbox instead of geom_column, like:</para>
 
-UPDATE mytable set bbox = Envelope(Force_2d(the_geom));
-</programlisting>
+        <programlisting>SELECT geom_column FROM mytable WHERE bbox &#38;&#38;
+        SetSrid(&#39;BOX3D(0 0,1 1)&#39;::box3d,4326);</programlisting>
 
-<para>
-Now change your query to use the &amp;&amp; operator against bbox instead of
-geom_column, like:
-</para>
+        <para>Of course, if you change or add rows to mytable, you have to
+        keep the bbox &#34;in sync&#34;. 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.</para>
+      </sect2>
+    </sect1>
 
-<programlisting>
-SELECT geom_column FROM mytable WHERE bbox &amp;&amp; SetSrid('BOX3D(0 0,1 1)'::box3d,4326);
-</programlisting>
+    <sect1>
+      <title>CLUSTERing on geometry indices</title>
 
-<para>
-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.
-</para>
+      <para>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.)</para>
 
-</sect2>
+      <para>However, currently PostgreSQL does not allow clustering on PostGIS
+      GIST indices because GIST indices simply ignores NULL values, you get an
+      error message like:</para>
 
-</sect1>
+      <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
+      &#34;the_geom&#34; NOT NULL.</programlisting>
 
+      <para>As the HINT message tells you, one can work around this deficiency
+      by adding a &#34;not null&#34; constraint to the table:</para>
 
-<sect1> <title>CLUSTERing on geometry indices</title>
+      <programlisting>lwgeom=# ALTER TABLE my_table ALTER COLUMN the_geom SET
+      not null; ALTER TABLE</programlisting>
 
-<para>
-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.)
-</para>
+      <para>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 &#34;ALTER TABLE blubb ADD
+      CHECK (geometry is not null);&#34; will not work.</para>
+    </sect1>
 
-<para>
-However, currently PostgreSQL does not allow clustering on PostGIS GIST indices
-because GIST indices simply ignores NULL values, you get an error message like:
-</para>
+    <sect1>
+      <title>Avoiding dimension conversion</title>
 
-<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.
-</programlisting>
+      <para>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:</para>
 
-<para>
-As the HINT message tells you, one can work around this deficiency by adding a
-"not null" constraint to the table:
-</para>
+      <programlisting>UPDATE mytable SET the_geom = force_2d(the_geom); VACUUM
+      FULL ANALYZE mytable;</programlisting>
 
-<programlisting>
-lwgeom=# ALTER TABLE my_table ALTER COLUMN the_geom SET not null;
-ALTER TABLE
-</programlisting>
+      <para>Note that if you added your geometry column using
+      AddGeometryColumn() there&#39;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.</para>
 
-<para>
-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.
-</para>
+      <para>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 &#34;VACUUM;&#34; between your UPDATEs. This
+      drastically reduces the need for temporary disk space. Additionally, if
+      you have mixed dimension geometries, restricting the UPDATE by
+      &#34;WHERE dimension(the_geom)&#62;2&#34; skips re-writing of geometries
+      that already are in 2D.</para>
+    </sect1>
+  </chapter>
 
-</sect1>
-
-<sect1><title>Avoiding dimension conversion</title>
-
-<para>
-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:
-</para>
-
-<programlisting>
-UPDATE mytable SET the_geom = force_2d(the_geom);
-VACUUM FULL ANALYZE mytable;
-</programlisting>
-
-<para>
-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.
-</para>
-
-<para>
-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)>2" skips re-writing of geometries that already are in 2D. 
-</para>
-
-</sect1>
-
-</chapter>
-
   <chapter>
     <title>PostGIS Reference</title>
 
     <para>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.</para>
+    functions to the PostGIS objects which are not of use to a general user.</para>
 
     <sect1>
       <title>OpenGIS Functions</title>
@@ -2825,16 +2623,16 @@
             varchar, integer)</term>
 
             <listitem>
-              <para>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 <varname>schema_name</varname>
+              <para>Syntax: AddGeometryColumn(&#60;schema_name&#62;,
+              &#60;table_name&#62;, &#60;column_name&#62;, &#60;srid&#62;,
+              &#60;type&#62;, &#60;dimension&#62;). Adds a geometry column to
+              an existing table of attributes. The <varname>schema_name</varname>
               is the name of the table schema (unused for pre-schema
               PostgreSQL installations). The <varname>srid</varname> must be
               an integer value reference to an entry in the SPATIAL_REF_SYS
               table. The <varname>type</varname> must be an uppercase string
-              corresponding to the geometry type, eg, 'POLYGON' or
-              'MULTILINESTRING'.</para>
+              corresponding to the geometry type, eg, &#39;POLYGON&#39; or
+              &#39;MULTILINESTRING&#39;.</para>
             </listitem>
           </varlistentry>
 
@@ -2842,10 +2640,10 @@
             <term>DropGeometryColumn(varchar, varchar, varchar)</term>
 
             <listitem>
-              <para>Syntax: DropGeometryColumn(&lt;schema_name&gt;,
-              &lt;table_name&gt;, &lt;column_name&gt;). Remove a geometry
+              <para>Syntax: DropGeometryColumn(&#60;schema_name&#62;,
+              &#60;table_name&#62;, &#60;column_name&#62;). 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
+              match the f_schema_name field of the table&#39;s row in the
               geometry_columns table.</para>
             </listitem>
           </varlistentry>
@@ -2879,9 +2677,9 @@
 
             <listitem>
               <para>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.</para>
+              &#34;spatially equal&#34;. Use this for a &#39;better&#39;
+              answer than &#39;=&#39;. equals(&#39;LINESTRING(0 0, 10
+              10)&#39;,&#39;LINESTRING(0 0, 5 5, 10 10)&#39;) is true.</para>
 
               <para>Performed by the GEOS module</para>
 
@@ -2893,19 +2691,18 @@
             <term>Disjoint(geometry, geometry)</term>
 
             <listitem>
-              <para>Returns 1 (TRUE) if the Geometries are "spatially disjoint".
-	      </para>
+              <para>Returns 1 (TRUE) if the Geometries are &#34;spatially
+              disjoint&#34;.</para>
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</para>
+              <para>NOTE: this is the &#34;allowable&#34; version that returns
+              a boolean, not an integer.</para>
 
               <para>OGC SPEC s2.1.1.2 //s2.1.13.3 - a.Relate(b,
-              'FF*FF****')</para>
+              &#39;FF*FF****&#39;)</para>
             </listitem>
           </varlistentry>
 
@@ -2913,19 +2710,18 @@
             <term>Intersects(geometry, geometry)</term>
 
             <listitem>
-              <para>Returns 1 (TRUE) if the Geometries "spatially intersect".
-              </para>
+              <para>Returns 1 (TRUE) if the Geometries &#34;spatially
+              intersect&#34;.</para>
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</para>
+              <para>NOTE: this is the &#34;allowable&#34; version that returns
+              a boolean, not an integer.</para>
 
-              <para>OGC SPEC s2.1.1.2 //s2.1.13.3 - Intersects(g1, g2 ) --&gt;
-              Not (Disjoint(g1, g2 ))</para>
+              <para>OGC SPEC s2.1.1.2 //s2.1.13.3 - Intersects(g1, g2 )
+              --&#62; Not (Disjoint(g1, g2 ))</para>
             </listitem>
           </varlistentry>
 
@@ -2933,18 +2729,17 @@
             <term>Touches(geometry, geometry)</term>
 
             <listitem>
-              <para>Returns 1 (TRUE) if the Geometries "spatially touch".
-              </para>
+              <para>Returns 1 (TRUE) if the Geometries &#34;spatially
+              touch&#34;.</para>
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</para>
+              <para>NOTE: this is the &#34;allowable&#34; version that returns
+              a boolean, not an integer.</para>
 
-              <para>OGC SPEC s2.1.1.2 // s2.1.13.3- a.Touches(b) -&gt; (I(a)
+              <para>OGC SPEC s2.1.1.2 // s2.1.13.3- a.Touches(b) -&#62; (I(a)
               intersection I(b) = {empty set} ) and (a intersection b) not
               empty</para>
             </listitem>
@@ -2954,19 +2749,18 @@
             <term>Crosses(geometry, geometry)</term>
 
             <listitem>
-              <para>Returns 1 (TRUE) if the Geometries "spatially cross".
-              </para>
+              <para>Returns 1 (TRUE) if the Geometries &#34;spatially
+              cross&#34;.</para>
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</para>
+              <para>NOTE: this is the &#34;allowable&#34; version that returns
+              a boolean, not an integer.</para>
 
               <para>OGC SPEC s2.1.1.2 // s2.1.13.3 - a.Relate(b,
-              'T*T******')</para>
+              &#39;T*T******&#39;)</para>
             </listitem>
           </varlistentry>
 
@@ -2974,19 +2768,18 @@
             <term>Within(geometry A, geometry B)</term>
 
             <listitem>
-              <para>Returns 1 (TRUE) if Geometry A is "spatially within"
-              Geometry B.</para>
+              <para>Returns 1 (TRUE) if Geometry A is &#34;spatially
+              within&#34; Geometry B.</para>
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</para>
+              <para>NOTE: this is the &#34;allowable&#34; version that returns
+              a boolean, not an integer.</para>
 
               <para>OGC SPEC s2.1.1.2 // s2.1.13.3 - a.Relate(b,
-              'T*F**F***')</para>
+              &#39;T*F**F***&#39;)</para>
             </listitem>
           </varlistentry>
 
@@ -2994,16 +2787,15 @@
             <term>Overlaps(geometry, geometry)</term>
 
             <listitem>
-              <para>Returns 1 (TRUE) if the Geometries "spatially
-              overlap".</para>
+              <para>Returns 1 (TRUE) if the Geometries &#34;spatially
+              overlap&#34;.</para>
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</para>
+              <para>NOTE: this is the &#34;allowable&#34; version that returns
+              a boolean, not an integer.</para>
 
               <para>OGC SPEC s2.1.1.2 // s2.1.13.3</para>
             </listitem>
@@ -3013,19 +2805,18 @@
             <term>Contains(geometry A, geometry B)</term>
 
             <listitem>
-              <para>Returns 1 (TRUE) if Geometry A "spatially contains"
-              Geometry B.</para>
+              <para>Returns 1 (TRUE) if Geometry A &#34;spatially
+              contains&#34; Geometry B.</para>
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</para>
+              <para>NOTE: this is the &#34;allowable&#34; version that returns
+              a boolean, not an integer.</para>
 
-              <para>OGC SPEC s2.1.1.2 // s2.1.13.3 - same as
-              within(geometry B, geometry A)</para>
+              <para>OGC SPEC s2.1.1.2 // s2.1.13.3 - same as within(geometry
+              B, geometry A)</para>
             </listitem>
           </varlistentry>
 
@@ -3033,19 +2824,18 @@
             <term>Intersects(geometry, geometry)</term>
 
             <listitem>
-              <para>Returns 1 (TRUE) if the Geometries "spatially
-              intersect".</para>
+              <para>Returns 1 (TRUE) if the Geometries &#34;spatially
+              intersect&#34;.</para>
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</para>
+              <para>NOTE: this is the &#34;allowable&#34; version that returns
+              a boolean, not an integer.</para>
 
-              <para>OGC SPEC s2.1.1.2 // s2.1.13.3 - NOT
-              disjoint(geometry, geometry)</para>
+              <para>OGC SPEC s2.1.1.2 // s2.1.13.3 - NOT disjoint(geometry,
+              geometry)</para>
             </listitem>
           </varlistentry>
 
@@ -3060,11 +2850,10 @@
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is the "allowable" version that returns a
-              boolean, not an integer.</para>
+              <para>NOTE: this is the &#34;allowable&#34; version that returns
+              a boolean, not an integer.</para>
 
               <para>OGC SPEC s2.1.1.2 // s2.1.13.3</para>
             </listitem>
@@ -3079,8 +2868,7 @@
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
               <para>not in OGC spec, but implied. see s2.1.13.2</para>
             </listitem>
@@ -3108,7 +2896,7 @@
 
             <listitem>
               <para>Returns the area of the geometry if it is a polygon or
-              multi-polygon. </para>
+              multi-polygon.</para>
             </listitem>
           </varlistentry>
 
@@ -3162,14 +2950,12 @@
               <para>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).</para>
+              Geometry. The optional third parameter sets the number of
+              segment used to approximate a quarter circle (defaults to 8).</para>
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
               <para>OGC SPEC s2.1.1.3</para>
             </listitem>
@@ -3197,8 +2983,7 @@
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
               <para>OGC SPEC s2.1.1.3</para>
             </listitem>
@@ -3213,8 +2998,7 @@
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
               <para>OGC SPEC s2.1.1.3</para>
             </listitem>
@@ -3224,13 +3008,12 @@
             <term>Difference(geometry A, geometry B)</term>
 
             <listitem>
-              <para>Returns a geometry that represents the point set 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>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
               <para>OGC SPEC s2.1.1.3</para>
             </listitem>
@@ -3245,11 +3028,10 @@
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection as an
-              argument</para>
+              <para>Do not call with a GeometryCollection as an argument</para>
 
-              <para>NOTE: this is renamed from "union" because union is an SQL
-              reserved word</para>
+              <para>NOTE: this is renamed from &#34;union&#34; because union
+              is an SQL reserved word</para>
 
               <para>OGC SPEC s2.1.1.3</para>
             </listitem>
@@ -3264,8 +3046,7 @@
 
               <para>Performed by the GEOS module</para>
 
-              <para>Do not call with a GeometryCollection in the argument
-              set</para>
+              <para>Do not call with a GeometryCollection in the argument set</para>
 
               <para>Not explicitly defined in OGC SPEC</para>
             </listitem>
@@ -3301,15 +3082,15 @@
             <term>AsBinary(geometry)</term>
 
             <listitem>
-              <para>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.</para>
+              <para>Returns the geometry in the OGC
+              &#34;well-known-binary&#34; 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.</para>
 
               <para>OGC SPEC s2.1.1.1 - also see
-              asBinary(&lt;geometry&gt;,'XDR') and
-              asBinary(&lt;geometry&gt;,'NDR')</para>
+              asBinary(&#60;geometry&#62;,&#39;XDR&#39;) and
+              asBinary(&#60;geometry&#62;,&#39;NDR&#39;)</para>
             </listitem>
           </varlistentry>
 
@@ -3334,10 +3115,9 @@
               and the largest dimension of the components of a
               GEOMETRYCOLLECTION.</para>
 
-              <programlisting>select dimension('GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0 0)'); 
-dimension 
------------
-1</programlisting>
+              <programlisting>select
+              dimension(&#39;GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0
+              0)&#39;); dimension ----------- 1</programlisting>
             </listitem>
           </varlistentry>
 
@@ -3353,8 +3133,7 @@
               corner points of the bounding box ((MINX, MINY), (MAXX, MINY),
               (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)).</para>
 
-              <para>NOTE:PostGIS will add a Zmin/Zmax coordinate as
-              well.</para>
+              <para>NOTE:PostGIS will add a Zmin/Zmax coordinate as well.</para>
             </listitem>
           </varlistentry>
 
@@ -3375,8 +3154,7 @@
 
             <listitem>
               <para>Returns 1 (TRUE) if this Geometry has no anomalous
-              geometric points, such as self intersection or self
-              tangency.</para>
+              geometric points, such as self intersection or self tangency.</para>
 
               <para>Performed by the GEOS module</para>
 
@@ -3386,6 +3164,7 @@
 
           <varlistentry id="IsClosed">
             <term>IsClosed(geometry)</term>
+
             <listitem>
               <para>Returns true of the geometry start and end points are
               coincident.</para>
@@ -3419,14 +3198,14 @@
             <term>GeometryN(geometry,int)</term>
 
             <listitem>
-              <para>Return the N'th geometry if the geometry is a
+              <para>Return the N&#39;th geometry if the geometry is a
               GEOMETRYCOLLECTION, MULTIPOINT, MULTILINESTRING or MULTIPOLYGON.
               Otherwise, return NULL.</para>
 
-		<note> <para>
-		Index is 1-based as for OGC specs since version 0.8.0.
-		Previous versions implemented this as 0-based instead.
-		</para></note>
+              <note>
+                <para>Index is 1-based as for OGC specs since version 0.8.0.
+                Previous versions implemented this as 0-based instead.</para>
+              </note>
             </listitem>
           </varlistentry>
 
@@ -3444,13 +3223,13 @@
             <term>PointN(geometry,integer)</term>
 
             <listitem>
-              <para>Return the N'th point in the first linestring in the
-              geometry. Return NULL if there is no linestring in the
-              geometry.</para>
-		<note> <para>
-		Index is 1-based as for OGC specs since version 0.8.0.
-		Previous versions implemented this as 0-based instead.
-		</para></note>
+              <para>Return the N&#39;th point in the first linestring in the
+              geometry. Return NULL if there is no linestring in the geometry.</para>
+
+              <note>
+                <para>Index is 1-based as for OGC specs since version 0.8.0.
+                Previous versions implemented this as 0-based instead.</para>
+              </note>
             </listitem>
           </varlistentry>
 
@@ -3458,8 +3237,8 @@
             <term>ExteriorRing(geometry)</term>
 
             <listitem>
-              <para>Return the exterior ring of the polygon geometry.
-	      Return NULL if the geometry is not a polygon.</para>
+              <para>Return the exterior ring of the polygon geometry. Return
+              NULL if the geometry is not a polygon.</para>
             </listitem>
           </varlistentry>
 
@@ -3478,8 +3257,8 @@
 
             <listitem>
               <para>Synonym to NumInteriorRings(geometry). The OpenGIS specs
-	      are ambiguous about the exact function naming, so we provide
-	      both spellings.</para>
+              are ambiguous about the exact function naming, so we provide
+              both spellings.</para>
             </listitem>
           </varlistentry>
 
@@ -3487,13 +3266,14 @@
             <term>InteriorRingN(geometry,integer)</term>
 
             <listitem>
-              <para>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.</para>
-		<note> <para>
-		Index is 1-based as for OGC specs since version 0.8.0.
-		Previous versions implemented this as 0-based instead.
-		</para></note>
+              <para>Return the N&#39;th interior ring of the polygon geometry.
+              Return NULL if the geometry is not a polygon or the given N is
+              out of range.</para>
+
+              <note>
+                <para>Index is 1-based as for OGC specs since version 0.8.0.
+                Previous versions implemented this as 0-based instead.</para>
+              </note>
             </listitem>
           </varlistentry>
 
@@ -3501,7 +3281,8 @@
             <term>EndPoint(geometry)</term>
 
             <listitem>
-              <para>Returns the last point of the LineString geometry as a point.</para>
+              <para>Returns the last point of the LineString geometry as a
+              point.</para>
             </listitem>
           </varlistentry>
 
@@ -3509,15 +3290,18 @@
             <term>StartPoint(geometry)</term>
 
             <listitem>
-              <para>Returns the first point of the LineString geometry as a point.</para>
+              <para>Returns the first point of the LineString geometry as a
+              point.</para>
             </listitem>
           </varlistentry>
 
           <varlistentry id="GeometryType">
             <term>GeometryType(geometry)</term>
+
             <listitem>
               <para>Returns the type of the geometry as a string. Eg:
-              'LINESTRING', 'POLYGON', 'MULTIPOINT', etc.</para>
+              &#39;LINESTRING&#39;, &#39;POLYGON&#39;, &#39;MULTIPOINT&#39;,
+              etc.</para>
 
               <para>OGC SPEC s2.1.1.1 - Returns the name of the instantiable
               subtype of Geometry of which this Geometry instance is a member.
@@ -3530,8 +3314,8 @@
             <term>X(geometry)</term>
 
             <listitem>
-              <para>Return the X coordinate of the point.
-	      Input must be a point.</para>
+              <para>Return the X coordinate of the point. Input must be a
+              point.</para>
             </listitem>
           </varlistentry>
 
@@ -3539,8 +3323,8 @@
             <term>Y(geometry)</term>
 
             <listitem>
-              <para>Return the Y coordinate of the point.
-	      Input must be a point.</para>
+              <para>Return the Y coordinate of the point. Input must be a
+              point.</para>
             </listitem>
           </varlistentry>
 
@@ -3548,9 +3332,8 @@
             <term>Z(geometry)</term>
 
             <listitem>
-              <para>Return the Z coordinate of the point,
-	      or NULL if not available.
-	      Input must be a point.</para>
+              <para>Return the Z coordinate of the point, or NULL if not
+              available. Input must be a point.</para>
             </listitem>
           </varlistentry>
 
@@ -3558,16 +3341,15 @@
             <term>M(geometry)</term>
 
             <listitem>
-              <para>Return the M coordinate of the point, 
-	      or NULL if not available.
-	      Input must be a point.</para>
+              <para>Return the M coordinate of the point, or NULL if not
+              available. Input must be a point.</para>
 
-		<note><para>This is not (yet) part of the OGC spec,
-		but is listed here to complete the point coordinate
-	        extractor function list.</para></note>
+              <note>
+                <para>This is not (yet) part of the OGC spec, but is listed
+                here to complete the point coordinate extractor function list.</para>
+              </note>
             </listitem>
           </varlistentry>
-
         </variablelist>
       </sect2>
 
@@ -3575,9 +3357,9 @@
         <title>Geometry Constructors</title>
 
         <variablelist>
+          <varlistentry>
+            <term>GeomFromText(text,[&#60;srid&#62;])</term>
 
-          <varlistentry>
-            <term>GeomFromText(text,[&lt;srid&gt;])</term>
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID.</para>
 
@@ -3587,7 +3369,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>PointFromText(text,[&lt;srid&gt;])</term>
+            <term>PointFromText(text,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID. If SRID is
@@ -3601,7 +3383,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>LineFromText(text,[&lt;srid&gt;])</term>
+            <term>LineFromText(text,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID. If SRID is
@@ -3615,7 +3397,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>LinestringFromText(text,[&lt;srid&gt;])</term>
+            <term>LinestringFromText(text,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID. If SRID is
@@ -3628,7 +3410,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>PolyFromText(text,[&lt;srid&gt;])</term>
+            <term>PolyFromText(text,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID. If SRID is
@@ -3642,7 +3424,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>PolygonFromText(text,[&lt;srid&gt;])</term>
+            <term>PolygonFromText(text,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID. If SRID is
@@ -3655,7 +3437,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>MPointFromText(text,[&lt;srid&gt;])</term>
+            <term>MPointFromText(text,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID. If SRID is
@@ -3669,7 +3451,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>MLineFromText(text,[&lt;srid&gt;])</term>
+            <term>MLineFromText(text,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID. If SRID is
@@ -3683,7 +3465,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>MPolyFromText(text,[&lt;srid&gt;])</term>
+            <term>MPolyFromText(text,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID. If SRID is
@@ -3697,7 +3479,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>GeomCollFromText(text,[&lt;srid&gt;])</term>
+            <term>GeomCollFromText(text,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKT with the given SRID. If SRID is
@@ -3706,13 +3488,12 @@
               <para>OGC SPEC 3.2.6.2 - option SRID is from the conformance
               suite</para>
 
-              <para>Throws an error if the WKT is not a
-              GEOMETRYCOLLECTION</para>
+              <para>Throws an error if the WKT is not a GEOMETRYCOLLECTION</para>
             </listitem>
           </varlistentry>
 
           <varlistentry>
-            <term>GeomFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>GeomFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3724,7 +3505,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>GeomFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>GeomFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3736,7 +3517,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>PointFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>PointFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3750,7 +3531,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>LineFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>LineFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3764,7 +3545,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>LinestringFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>LinestringFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3777,7 +3558,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>PolyFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>PolyFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3791,7 +3572,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>PolygonFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>PolygonFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3804,7 +3585,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>MPointFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>MPointFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3818,7 +3599,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>MLineFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>MLineFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3832,7 +3613,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>MPolyFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>MPolyFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3846,7 +3627,7 @@
           </varlistentry>
 
           <varlistentry>
-            <term>GeomCollFromWKB(bytea,[&lt;srid&gt;])</term>
+            <term>GeomCollFromWKB(bytea,[&#60;srid&#62;])</term>
 
             <listitem>
               <para>Makes a Geometry from WKB with the given SRID. If SRID is
@@ -3863,26 +3644,18 @@
             <term>BdPolyFromText(text WKT, integer SRID)</term>
 
             <listitem>
-		<para>
-		Construct a Polygon given an arbitrary
-		collection of closed linestrings as a
-		MultiLineString text representation.
-		</para>
+              <para>Construct a Polygon given an arbitrary collection of
+              closed linestrings as a MultiLineString text representation.</para>
 
-		<para>
-	      Throws an error if WKT is not a MULTILINESTRING.
-	      Throws an error if output is a MULTIPOLYGON; use <link
-	      linkend="BdMPolyFromText">BdMPolyFromText</link> in
-	      that case, or see 
-		<link linkend="BuildArea">BuildArea()</link>
-		for a postgis-specific approach.
-		</para>
+              <para>Throws an error if WKT is not a MULTILINESTRING. Throws an
+              error if output is a MULTIPOLYGON; use <link
+              linkend="BdMPolyFromText">BdMPolyFromText</link> in that case,
+              or see <link linkend="BuildArea">BuildArea()</link> for a
+              postgis-specific approach.</para>
 
               <para>OGC SFSQL 1.1 - 3.2.6.2</para>
 
-		<para>
-		    Availability: 1.1.0 - requires GEOS >= 2.1.0.
-		</para>
+              <para>Availability: 1.1.0 - requires GEOS &#62;= 2.1.0.</para>
             </listitem>
           </varlistentry>
 
@@ -3890,30 +3663,21 @@
             <term>BdMPolyFromText(text WKT, integer SRID)</term>
 
             <listitem>
-		<para>
-		Construct a MultiPolygon given an arbitrary
-		collection of closed linestrings as a
-		MultiLineString text representation.
-		</para>
-		<para>
-                Throws an error if WKT is not a MULTILINESTRING.
-		Forces MULTIPOLYGON output even when result is really
-		only composed by a single POLYGON; use <link
-		linkend="BdPolyFromText">BdPolyFromText</link> if you're sure
-		a single POLYGON will result from
-		operation, or see
-		<link linkend="BuildArea">BuildArea()</link>
-		for a postgis-specific approach.
-		</para>
+              <para>Construct a MultiPolygon given an arbitrary collection of
+              closed linestrings as a MultiLineString text representation.</para>
 
+              <para>Throws an error if WKT is not a MULTILINESTRING. Forces
+              MULTIPOLYGON output even when result is really only composed by
+              a single POLYGON; use <link linkend="BdPolyFromText">BdPolyFromText</link>
+              if you&#39;re sure a single POLYGON will result from operation,
+              or see <link linkend="BuildArea">BuildArea()</link> for a
+              postgis-specific approach.</para>
+
               <para>OGC SFSQL 1.1 - 3.2.6.2</para>
 
-		<para>
-		    Availability: 1.1.0 - requires GEOS >= 2.1.0.
-		</para>
+              <para>Availability: 1.1.0 - requires GEOS &#62;= 2.1.0.</para>
             </listitem>
           </varlistentry>
-
         </variablelist>
       </sect2>
     </sect1>
@@ -3922,2562 +3686,3398 @@
       <title>Postgis Extensions</title>
 
       <sect2>
-      	<title>Management Functions</title>
-	  <variablelist>
-		<varlistentry>
-		  <term>DropGeometryTable([&lt;schema_name&gt;],
-		  &lt;table_name&gt;)</term>
+        <title>Management Functions</title>
 
-		  <listitem>
-		    <para>Drops a table and all its references in geometry_columns.
-		    Note: uses current_schema() on schema-aware pgsql installations if
-		    schema is not provided.</para>
-		  </listitem>
-		</varlistentry>
+        <variablelist>
+          <varlistentry>
+            <term>DropGeometryTable([&#60;schema_name&#62;],
+            &#60;table_name&#62;)</term>
 
-		<varlistentry>
-		  <term>UpdateGeometrySRID([&lt;schema_name&gt;],
-		  &lt;table_name&gt;, &lt;column_name&gt;, &lt;srid&gt;)</term>
-		  <listitem>
-		    <para>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.</para>
-		  </listitem>
-		</varlistentry>
+            <listitem>
+              <para>Drops a table and all its references in geometry_columns.
+              Note: uses current_schema() on schema-aware pgsql installations
+              if schema is not provided.</para>
+            </listitem>
+          </varlistentry>
 
-		<varlistentry>
-		  <term>update_geometry_stats([&lt;table_name&gt;,
-		  &lt;column_name&gt;])</term>
+          <varlistentry>
+            <term>UpdateGeometrySRID([&#60;schema_name&#62;],
+            &#60;table_name&#62;, &#60;column_name&#62;, &#60;srid&#62;)</term>
 
-		  <listitem>
-		    <para>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".</para>
-		  </listitem>
-		</varlistentry>
+            <listitem>
+              <para>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.</para>
+            </listitem>
+          </varlistentry>
 
-        <varlistentry>
-          <term>postgis_version()</term>
+          <varlistentry>
+            <term>update_geometry_stats([&#60;table_name&#62;,
+            &#60;column_name&#62;])</term>
 
-          <listitem>
-		<para>Returns PostGIS version number and compile-time options</para>
+            <listitem>
+              <para>Update statistics about spatial tables for use by the
+              query planner. You will also need to run &#34;VACUUM ANALYZE
+              [table_name] [column_name]&#34; for the statistics gathering
+              process to be complete. NOTE: starting with PostgreSQL 8.0
+              statistics gathering is automatically performed running
+              &#34;VACUUM ANALYZE&#34;.</para>
+            </listitem>
+          </varlistentry>
 
-		<note><para>
-		Prior to version 1.1.0 this was a procedural function, thus possibly
-		returning inaccurate information (in case of incomplete database upgrades).
-		</para></note>
+          <varlistentry>
+            <term>postgis_version()</term>
 
-          </listitem>
-        </varlistentry>
+            <listitem>
+              <para>Returns PostGIS version number and compile-time options</para>
 
-        <varlistentry id="postgis_lib_version">
-          <term>postgis_lib_version()</term>
-          <listitem>
-            <para>Returns the version number of the PostGIS library.</para>
-		<para>
-	Availability: 0.9.0
-		</para>
-          </listitem>
-        </varlistentry>
+              <note>
+                <para>Prior to version 1.1.0 this was a procedural function,
+                thus possibly returning inaccurate information (in case of
+                incomplete database upgrades).</para>
+              </note>
+            </listitem>
+          </varlistentry>
 
-        <varlistentry>
-          <term>postgis_lib_build_date()</term>
-          <listitem>
-            <para>Returns build date of the PostGIS library.</para>
-		<para>
-	Availability: 1.0.0RC1
-		</para>
-          </listitem>
-        </varlistentry>
+          <varlistentry id="postgis_lib_version">
+            <term>postgis_lib_version()</term>
 
-        <varlistentry>
-          <term>postgis_script_build_date()</term>
-          <listitem>
-            <para>Returns build date of the PostGIS scripts.</para>
-		<para>
-	Availability: 1.0.0RC1
-		</para>
-          </listitem>
-        </varlistentry>
+            <listitem>
+              <para>Returns the version number of the PostGIS library.</para>
 
-        <varlistentry>
-          <term>postgis_scripts_installed()</term>
+              <para>Availability: 0.9.0</para>
+            </listitem>
+          </varlistentry>
 
-          <listitem>
-		<para>
-		Returns version of the postgis scripts
-		installed in this database.
-		</para>
+          <varlistentry>
+            <term>postgis_lib_build_date()</term>
 
-		<note> <para>
-		If the output of this function doesn't match the output of
-		<link linkend="postgis_scripts_released">postgis_scripts_released()</link>
-		you probably missed to properly upgrade an existing database.
-		See the <link linkend="upgrading">Upgrading</link> section for more info.
-		</para></note>
+            <listitem>
+              <para>Returns build date of the PostGIS library.</para>
 
-		<para>
-	Availability: 0.9.0
-		</para>
-          </listitem>
-        </varlistentry>
+              <para>Availability: 1.0.0RC1</para>
+            </listitem>
+          </varlistentry>
 
-        <varlistentry id="postgis_scripts_released">
-          <term>postgis_scripts_released()</term>
+          <varlistentry>
+            <term>postgis_script_build_date()</term>
 
-          <listitem>
-            <para>Returns the version number of the lwpostgis.sql script
-            released with the installed postgis lib.</para>
+            <listitem>
+              <para>Returns build date of the PostGIS scripts.</para>
 
-		<note> <para>
-		Starting with version 1.1.0 this function returns the same
-		value of <link linkend="postgis_lib_version">postgis_lib_version()</link>.
-		Kept for backward compatibility.
-		</para></note>
+              <para>Availability: 1.0.0RC1</para>
+            </listitem>
+          </varlistentry>
 
-		<para>
-	Availability: 0.9.0 
-		</para>
+          <varlistentry>
+            <term>postgis_scripts_installed()</term>
 
+            <listitem>
+              <para>Returns version of the postgis scripts installed in this
+              database.</para>
 
-          </listitem>
-        </varlistentry>
+              <note>
+                <para>If the output of this function doesn&#39;t match the
+                output of <link linkend="postgis_scripts_released">postgis_scripts_released()</link>
+                you probably missed to properly upgrade an existing database.
+                See the <link linkend="upgrading">Upgrading</link> section for
+                more info.</para>
+              </note>
 
-        <varlistentry>
-          <term>postgis_geos_version()</term>
+              <para>Availability: 0.9.0</para>
+            </listitem>
+          </varlistentry>
 
-          <listitem>
-            <para>Returns the version number of the GEOS library, or NULL if
-            GEOS support is not enabled.</para>
-		<para>
-	Availability: 0.9.0
-		</para>
-          </listitem>
-        </varlistentry>
+          <varlistentry id="postgis_scripts_released">
+            <term>postgis_scripts_released()</term>
 
-        <varlistentry>
-          <term>postgis_jts_version()</term>
+            <listitem>
+              <para>Returns the version number of the lwpostgis.sql script
+              released with the installed postgis lib.</para>
 
-          <listitem>
-            <para>Returns the version number of the JTS library, or NULL if
-            JTS support is not enabled.</para>
+              <note>
+                <para>Starting with version 1.1.0 this function returns the
+                same value of <link linkend="postgis_lib_version">postgis_lib_version()</link>.
+                Kept for backward compatibility.</para>
+              </note>
 
-		<para>
-	Availability: 1.1.0
-		</para>
+              <para>Availability: 0.9.0</para>
+            </listitem>
+          </varlistentry>
 
-          </listitem>
-        </varlistentry>
+          <varlistentry>
+            <term>postgis_geos_version()</term>
 
-        <varlistentry>
-          <term>postgis_proj_version()</term>
+            <listitem>
+              <para>Returns the version number of the GEOS library, or NULL if
+              GEOS support is not enabled.</para>
 
-          <listitem>
-            <para>Returns the version number of the PROJ4 library, or NULL if
-            PROJ4 support is not enabled.</para>
-		<para>
-	Availability: 0.9.0
-		</para>
-          </listitem>
-        </varlistentry>
+              <para>Availability: 0.9.0</para>
+            </listitem>
+          </varlistentry>
 
-        <varlistentry>
-          <term>postgis_uses_stats()</term>
+          <varlistentry>
+            <term>postgis_jts_version()</term>
 
-          <listitem>
-            <para>Returns true if STATS usage has been enabled, false
-            otherwise.</para>
-		<para>
-	Availability: 0.9.0
-		</para>
-          </listitem>
-        </varlistentry>
+            <listitem>
+              <para>Returns the version number of the JTS library, or NULL if
+              JTS support is not enabled.</para>
 
-        <varlistentry id="postgis_full_version">
-          <term>postgis_full_version()</term>
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
 
-          <listitem>
-            <para>Reports full postgis version and build configuration
-            infos.</para>
+          <varlistentry>
+            <term>postgis_proj_version()</term>
 
-		<para>Availability: 0.9.0</para>
-          </listitem>
-        </varlistentry>
+            <listitem>
+              <para>Returns the version number of the PROJ4 library, or NULL
+              if PROJ4 support is not enabled.</para>
 
-	   </variablelist>
+              <para>Availability: 0.9.0</para>
+            </listitem>
+          </varlistentry>
 
-	</sect2>
+          <varlistentry>
+            <term>postgis_uses_stats()</term>
 
-	<sect2>
-	  <title>Operators</title>
-	    <variablelist>
+            <listitem>
+              <para>Returns true if STATS usage has been enabled, false
+              otherwise.</para>
 
-		<varlistentry>
-		  <term>A &amp;&lt; B</term>
+              <para>Availability: 0.9.0</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>The "&amp;&lt;" operator returns true if A's bounding box
-		    overlaps or is to the left of B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+          <varlistentry id="postgis_full_version">
+            <term>postgis_full_version()</term>
 
-		<varlistentry>
-		  <term>A &amp;&gt; B</term>
+            <listitem>
+              <para>Reports full postgis version and build configuration
+              infos.</para>
 
-		  <listitem>
-		    <para>The "&amp;&gt;" operator returns true if A's bounding box
-		    overlaps or is to the right of B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+              <para>Availability: 0.9.0</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </sect2>
 
-		<varlistentry>
-		  <term>A &lt;&lt; B</term>
+      <sect2>
+        <title>Operators</title>
 
-		  <listitem>
-		    <para>The "&lt;&lt;" operator returns true if A's bounding box is
-		    strictly to the left of B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+        <variablelist>
+          <varlistentry>
+            <term>A &#38;&#60; B</term>
 
-		<varlistentry>
-		  <term>A &gt;&gt; B</term>
+            <listitem>
+              <para>The &#34;&#38;&#60;&#34; operator returns true if A&#39;s
+              bounding box overlaps or is to the left of B&#39;s bounding box.</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>The "&gt;&gt;" operator returns true if A's bounding box is
-		    strictly to the right of B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+          <varlistentry>
+            <term>A &#38;&#62; B</term>
 
-		<varlistentry>
-		  <term>A &amp;&lt;| B</term>
+            <listitem>
+              <para>The &#34;&#38;&#62;&#34; operator returns true if A&#39;s
+              bounding box overlaps or is to the right of B&#39;s bounding
+              box.</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>The "&amp;&lt;|" operator returns true if A's bounding box
-		    overlaps or is below B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+          <varlistentry>
+            <term>A &#60;&#60; B</term>
 
-		<varlistentry>
-		  <term>A |&amp;&gt; B</term>
+            <listitem>
+              <para>The &#34;&#60;&#60;&#34; operator returns true if A&#39;s
+              bounding box is strictly to the left of B&#39;s bounding box.</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>The "|&amp;&gt;" operator returns true if A's bounding box
-		    overlaps or is above B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+          <varlistentry>
+            <term>A &#62;&#62; B</term>
 
-		<varlistentry>
-		  <term>A &lt;&lt;| B</term>
+            <listitem>
+              <para>The &#34;&#62;&#62;&#34; operator returns true if A&#39;s
+              bounding box is strictly to the right of B&#39;s bounding box.</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>The "&lt;&lt;|" operator returns true if A's bounding box is
-		    strictly below B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+          <varlistentry>
+            <term>A &#38;&#60;| B</term>
 
-		<varlistentry>
-		  <term>A |&gt;&gt; B</term>
+            <listitem>
+              <para>The &#34;&#38;&#60;|&#34; operator returns true if A&#39;s
+              bounding box overlaps or is below B&#39;s bounding box.</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>The "|&gt;&gt;" operator returns true if A's bounding box is
-		    strictly above B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+          <varlistentry>
+            <term>A |&#38;&#62; B</term>
 
-		<varlistentry>
-		  <term>A ~= B</term>
+            <listitem>
+              <para>The &#34;|&#38;&#62;&#34; operator returns true if A&#39;s
+              bounding box overlaps or is above B&#39;s bounding box.</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>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.</para>
-		  </listitem>
-		</varlistentry>
+          <varlistentry>
+            <term>A &#60;&#60;| B</term>
 
-		<varlistentry>
-		  <term>A @ B</term>
+            <listitem>
+              <para>The &#34;&#60;&#60;|&#34; operator returns true if A&#39;s
+              bounding box is strictly below B&#39;s bounding box.</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>The "@" operator returns true if A's bounding box is
-		    completely contained by B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+          <varlistentry>
+            <term>A |&#62;&#62; B</term>
 
-		<varlistentry>
-		  <term>A ~ B</term>
+            <listitem>
+              <para>The &#34;|&#62;&#62;&#34; operator returns true if A&#39;s
+              bounding box is strictly above B&#39;s bounding box.</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>The "~" operator returns true if A's bounding box completely
-		    contains B's bounding box.</para>
-		  </listitem>
-		</varlistentry>
+          <varlistentry>
+            <term>A ~= B</term>
 
-		<varlistentry>
-		  <term>A &amp;&amp; B</term>
+            <listitem>
+              <para>The &#34;~=&#34; operator is the &#34;same as&#34;
+              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.</para>
+            </listitem>
+          </varlistentry>
 
-		  <listitem>
-		    <para>The "&amp;&amp;" operator is the "overlaps" operator. If A's
-		    bounding box overlaps B's bounding box the operator returns
-		    true.</para>
-		  </listitem>
-		</varlistentry>
-	  </variablelist>
+          <varlistentry>
+            <term>A @ B</term>
+
+            <listitem>
+              <para>The &#34;@&#34; operator returns true if A&#39;s bounding
+              box is completely contained by B&#39;s bounding box.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>A ~ B</term>
+
+            <listitem>
+              <para>The &#34;~&#34; operator returns true if A&#39;s bounding
+              box completely contains B&#39;s bounding box.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>A &#38;&#38; B</term>
+
+            <listitem>
+              <para>The &#34;&#38;&#38;&#34; operator is the
+              &#34;overlaps&#34; operator. If A&#39;s bounding box overlaps
+              B&#39;s bounding box the operator returns true.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
       </sect2>
 
       <sect2>
         <title>Measurement Functions</title>
-	  <variablelist>
 
-		<varlistentry>
-		  <term>area2d(geometry)</term>
+        <variablelist>
+          <varlistentry>
+            <term>area2d(geometry)</term>
 
-		  <listitem>
-		    <para>Returns the area of the geometry if it is a polygon or
-		    multi-polygon.</para>
-		  </listitem>
-		</varlistentry>
+            <listitem>
+              <para>Returns the area of the geometry if it is a polygon or
+              multi-polygon.</para>
+            </listitem>
+          </varlistentry>
 
+          <varlistentry>
+            <term>distance_sphere(point, point)</term>
+
+            <listitem>
+              <para>Returns linear distance in meters between two lat/lon
+              points. Uses a spherical earth and radius of 6370986 meters.
+              Faster than <link linkend="distance_spheroid">distance_spheroid()</link>,
+              but less accurate. Only implemented for points.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="distance_spheroid">
+            <term>distance_spheroid(point, point, spheroid)</term>
+
+            <listitem>
+              <para>Returns linear distance between two lat/lon points given a
+              particular spheroid. See the explanation of spheroids given for
+              <link linkend="length_spheroid">length_spheroid()</link>.
+              Currently only implemented for points.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="length2d">
+            <term>length2d(geometry)</term>
+
+            <listitem>
+              <para>Returns the 2-dimensional length of the geometry if it is
+              a linestring or multi-linestring.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>length3d(geometry)</term>
+
+            <listitem>
+              <para>Returns the 3-dimensional length of the geometry if it is
+              a linestring or multi-linestring.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="length_spheroid">
+            <term>length_spheroid(geometry,spheroid)</term>
+
+            <listitem>
+              <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 ellipsoid is a separate database type and can be constructed
+              as follows:</para>
+
+              <literallayout>SPHEROID[&#60;NAME&#62;,&#60;SEMI-MAJOR
+              AXIS&#62;,&#60;INVERSE FLATTENING&#62;]</literallayout>
+
+              <para>Eg:</para>
+
+              <literallayout>SPHEROID[&#34;GRS_1980&#34;,6378137,298.257222101]</literallayout>
+
+              <para>An example calculation might look like this:</para>
+
+              <literallayout>SELECT length_spheroid( geometry_column,
+              &#39;SPHEROID[&#34;GRS_1980&#34;,6378137,298.257222101]&#39; )
+              FROM geometry_table;</literallayout>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>length3d_spheroid(geometry,spheroid)</term>
+
+            <listitem>
+              <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
+              distance vertical displacement adds.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>distance(geometry, geometry)</term>
+
+            <listitem>
+              <para>Returns the smaller distance between two geometries.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>max_distance(linestring,linestring)</term>
+
+            <listitem>
+              <para>Returns the largest distance between two line strings.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>perimeter(geometry)</term>
+
+            <listitem>
+              <para>Returns the 2-dimensional perimeter of the geometry, if it
+              is a polygon or multi-polygon.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>perimeter2d(geometry)</term>
+
+            <listitem>
+              <para>Returns the 2-dimensional perimeter of the geometry, if it
+              is a polygon or multi-polygon.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>perimeter3d(geometry)</term>
+
+            <listitem>
+              <para>Returns the 3-dimensional perimeter of the geometry, if it
+              is a polygon or multi-polygon.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>azimuth(geometry, geometry)</term>
+
+            <listitem>
+              <para>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.</para>
+
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </sect2>
+
+      <sect2>
+        <title>Geometry Outputs</title>
+
+        <variablelist>
+          <varlistentry>
+            <term>AsBinary(geometry,{&#39;NDR&#39;|&#39;XDR&#39;})</term>
+
+            <listitem>
+              <para>Returns the geometry in the OGC
+              &#34;well-known-binary&#34; 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.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>AsEWKT(geometry)</term>
+
+            <listitem>
+              <para>Returns a Geometry in EWKT format (as text).</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>AsEWKB(geometry, {&#39;NDR&#39;|&#39;XDR&#39;})</term>
+
+            <listitem>
+              <para>Returns a Geometry in EWKB format (as bytea) using either
+              little-endian (NDR) or big-endian (XDR) encoding.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>AsHEXEWKB(geometry, {&#39;NDR&#39;|&#39;XDR&#39;})</term>
+
+            <listitem>
+              <para>Returns a Geometry in HEXEWKB format (as text) using
+              either little-endian (NDR) or big-endian (XDR) encoding.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>AsSVG(geometry, [rel], [precision])</term>
+
+            <listitem>
+              <para>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 &#39;rel&#39; arg is 0, x/y when &#39;rel&#39; is 1.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>AsGML(geometry, [precision])</term>
+
+            <listitem>
+              <para>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).</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>AsKML(geometry, [precision])</term>
+            <listitem>
+              <para>Return the geometry as a KML element.  Second argument may be used to reduce the maximum number of significant digits used in output (defaults to 15).</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </sect2>
+
+      <sect2>
+        <title>Geometry Constructors</title>
+
+        <variablelist>
+          <varlistentry>
+            <term>GeomFromEWKT(text)</term>
+
+            <listitem>
+              <para>Makes a Geometry from EWKT.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>GeomFromEWKB(bytea)</term>
+
+            <listitem>
+              <para>Makes a Geometry from EWKB.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>MakePoint(&#60;x&#62;, &#60;y&#62;, [&#60;z&#62;],
+            [&#60;m&#62;])</term>
+
+            <listitem>
+              <para>Creates a 2d,3dz or 4d point geometry.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>MakePointM(&#60;x&#62;, &#60;y&#62;, &#60;m&#62;)</term>
+
+            <listitem>
+              <para>Creates a 3dm point geometry.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>MakeBox2D(&#60;LL&#62;, &#60;UR&#62;)</term>
+
+            <listitem>
+              <para>Creates a BOX2D defined by the given point geometries.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>MakeBox3D(&#60;LLB&#62;, &#60;URT&#62;)</term>
+
+            <listitem>
+              <para>Creates a BOX3D defined by the given point geometries.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>MakeLine(geometry set)</term>
+
+            <listitem>
+              <para>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.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>MakeLine(geometry, geometry)</term>
+
+            <listitem>
+              <para>Creates a Linestring from the two given point geometries.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>LineFromMultiPoint(multipoint)</term>
+
+            <listitem>
+              <para>Creates a LineString from a MultiPoint geometry.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>MakePolygon(linestring, [linestring[]])</term>
+
+            <listitem>
+              <para>Creates a Polygon formed by the given shell and array of
+              holes. You can construct a geometry array using <link
+              linkend="Accum">Accum</link>. Input geometries must be closed
+              LINESTRINGS (see <link linkend="IsClosed">IsClosed</link> and
+              <link linkend="GeometryType">GeometryType</link>).</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="BuildArea">
+            <term>BuildArea(geometry)</term>
+
+            <listitem>
+              <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 returned.</para>
+
+              <para>See also <link linkend="BdPolyFromText">BdPolyFromText</link>
+              and <link linkend="BdMPolyFromText">BdMPolyFromText</link> -
+              wrappers to this function with standard OGC interface.</para>
+
+              <para>Availability: 1.1.0 - requires GEOS &#62;= 2.1.0.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Polygonize(geometry set)</term>
+
+            <listitem>
+              <para>Aggregate. Creates a GeometryCollection containing
+              possible polygons formed from the constituent linework of a set
+              of geometries.</para>
+
+              <para>Availability: 1.0.0RC1 - requires GEOS &#62;= 2.1.0.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Collect(geometry set)</term>
+
+            <listitem>
+              <para>This function returns a GEOMETRYCOLLECTION or a MULTI
+              object from a set of geometries. The collect() function is an
+              &#34;aggregate&#34; 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, &#34;SELECT
+              COLLECT(GEOM) FROM GEOMTABLE GROUP BY ATTRCOLUMN&#34; will
+              return a separate GEOMETRYCOLLECTION for each distinct value of
+              ATTRCOLUMN.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Collect(geometry, geometry)</term>
+
+            <listitem>
+              <para>This function returns a geometry being a collection of two
+              input geometries. Output type can be a MULTI* or a
+              GEOMETRYCOLLECTION.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Dump(geometry)</term>
+
+            <listitem>
+              <para>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.</para>
+
+              <para>Availability: PostGIS 1.0.0RC1. Requires PostgreSQL 7.3 or
+              higher.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>DumpRings(geometry)</term>
+
+            <listitem>
+              <para>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 &#39;path&#39; field holds the polygon
+              ring index, contains a single element: 0 for the shell, hole
+              number for holes. The &#39;geom&#39; field contains the
+              corresponding ring as a polygon.</para>
+
+              <para>Availability: PostGIS 1.1.3. Requires PostgreSQL 7.3 or
+              higher.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </sect2>
+
+      <sect2>
+        <title>Geometry Editors</title>
+
+        <variablelist>
+          <varlistentry id="addbbox">
+            <term>AddBBOX(geometry)</term>
+
+            <listitem>
+              <para>Add bounding box to the geometry. This would make bounding
+              box based queries faster, but will increase the size of the
+              geometry.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="dropbbox">
+            <term>DropBBOX(geometry)</term>
+
+            <listitem>
+              <para>Drop the bounding box cache from the geometry. This
+              reduces geometry size, but makes bounding-box based queries
+              slower.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>AddPoint(linestring, point, [&#60;position&#62;])</term>
+
+            <listitem>
+              <para>Adds a point to a LineString before point &#60;pos&#62;
+              (0-based index). Third parameter can be omitted or set to -1 for
+              appending.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>RemovePoint(linestring, offset)</term>
+
+            <listitem>
+              <para>Removes point from a linestring. Offset is 0-based.</para>
+
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>SetPoint(linestring, N, point)</term>
+
+            <listitem>
+              <para>Replace point N of linestring with given point. Index is
+              0-based.</para>
+
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Force_collection(geometry)</term>
+
+            <listitem>
+              <para>Converts the geometry into a GEOMETRYCOLLECTION. This is
+              useful for simplifying the WKB representation.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="force_2d">
+            <term>Force_2d(geometry)</term>
+
+            <listitem>
+              <para>Forces the geometries into a &#34;2-dimensional mode&#34;
+              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).</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="force_3dz">
+            <term>Force_3dz(geometry)</term>
+
+            <term>Force_3d(geometry)</term>
+
+            <listitem>
+              <para>Forces the geometries into XYZ mode.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="force_3dm">
+            <term>Force_3dm(geometry)</term>
+
+            <listitem>
+              <para>Forces the geometries into XYM mode.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="force_4d">
+            <term>Force_4d(geometry)</term>
+
+            <listitem>
+              <para>Forces the geometries into XYZM mode.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Multi(geometry)</term>
+
+            <listitem>
+              <para>Returns the geometry as a MULTI* geometry. If the geometry
+              is already a MULTI*, it is returned unchanged.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Transform(geometry,integer)</term>
+
+            <listitem>
+              <para>Returns a new geometry with its coordinates transformed to
+              the SRID referenced by the integer parameter. The destination
+              SRID must exist in the <varname>SPATIAL_REF_SYS</varname> table.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Affine(geometry,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8)</term>
+
+            <listitem>
+              <para>Applies an 3d affine transformation to the geometry. The
+              call <programlisting> Affine(geom, a, b, c, d, e, f, g, h, i,
+              xoff, yoff, zoff) </programlisting> represents the
+              transformation matrix <programlisting> / a b c xoff \ | d e f
+              yoff | | g h i zoff | \ 0 0 0 1 / </programlisting> and the
+              vertices are transformed as follows:
+              <programlisting> x&#39; = a*x + b*y + c*z + xoff y&#39; = d*x +
+              e*y + f*z + yoff z&#39; = g*x + h*y + i*z + zoff
+              </programlisting> All of the translate / scale functions below
+              are expressed via such an affine transformation.</para>
+
+              <para>Availability: 1.1.2.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Affine(geometry,float8,float8,float8,float8,float8,float8)</term>
+
+            <listitem>
+              <para>Applies an 2d affine transformation to the geometry. The
+              call <programlisting> Affine(geom, a, b, d, e, xoff, yoff)
+              </programlisting> represents the transformation matrix
+              <programlisting> / a b 0 xoff \ / a b xoff \ | d e 0 yoff | rsp.
+              | d e yoff | | 0 0 1 0 | \ 0 0 1 / \ 0 0 0 1 / </programlisting>
+              and the vertices are transformed as follows:
+              <programlisting> x&#39; = a*x + b*y + xoff y&#39; = d*x + e*y +
+              yoff z&#39; = z </programlisting> This method is a subcase of
+              the 3D method above.</para>
+
+              <para>Availability: 1.1.2.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Translate(geometry,float8,float8,float8)</term>
+
+            <listitem>
+              <para>Translates the geometry to a new location using the
+              numeric parameters as offsets. Ie: translate(geom, X, Y, Z).</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Scale(geometry,float8,float8,float8)</term>
+
+            <listitem>
+              <para>scales the geometry to a new size by multiplying the
+              ordinates with the parameters. Ie: scale(geom, Xfactor, Yfactor,
+              Zfactor).</para>
+
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="Rotate">
+            <term>RotateZ(geometry,float8)</term>
+
+            <term>RotateX(geometry,float8)</term>
+
+            <term>RotateY(geometry,float8)</term>
+
+            <listitem>
+              <para>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.</para>
+
+              <para>Availability: 1.1.2.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>TransScale(geometry,float8,float8,float8,float8)</term>
+
+            <listitem>
+              <para>First, translates the geometry using the first two floats,
+              then scales it using the second two floats, working in 2D only.
+              Using <code>transscale(geom, X, Y, XFactor, YFactor)</code>
+              internally calls <code>affine(geom, XFactor, 0, 0, 0, YFactor,
+              0, 0, 0, 1, X*XFactor, Y*YFactor, 0)</code>.</para>
+
+              <para>Availability: 1.1.0.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Reverse(geometry)</term>
+
+            <listitem>
+              <para>Returns the geometry with vertex order reversed.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>ForceRHR(geometry)</term>
+
+            <listitem>
+              <para>Force polygons of the collection to obey Right-Hand-Rule.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Simplify(geometry, tolerance)</term>
+
+            <listitem>
+              <para>Returns a &#34;simplified&#34; 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 <link linkend="IsSimple">IsSimple</link>)</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>SnapToGrid(geometry, originX, originY, sizeX, sizeY)</term>
+
+            <term>SnapToGrid(geometry, sizeX, sizeY)</term>
+
+            <term>SnapToGrid(geometry, size)</term>
+
+            <listitem>
+              <para>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.</para>
+
+              <note>
+                <para>The returned geometry might loose its simplicity (see
+                <link linkend="IsSimple">IsSimple</link>).</para>
+              </note>
+
+              <note>
+                <para>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.</para>
+              </note>
+
+              <para>Availability: 1.0.0RC1</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>SnapToGrid(geometry, geometry, sizeX, sizeY, sizeZ, sizeM)</term>
+
+            <listitem>
+              <para>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&#39;t want to
+              snap to a grid.</para>
+
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>Segmentize(geometry, maxlength)</term>
+
+            <listitem>
+              <para>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.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>LineMerge(geometry)</term>
+
+            <listitem>
+              <para>Returns a (set of) LineString(s) formed by sewing together
+              constituent linework of input.</para>
+
+              <para>Availability: 1.1.0 - requires GEOS &#62;= 2.1.0</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </sect2>
+
+      <sect2>
+        <title>Linear Referencing</title>
+
+        <variablelist>
+          <varlistentry id="line_interpolate_point">
+            <term>line_interpolate_point(linestring, location)</term>
+
+            <listitem>
+              <para>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 <link linkend="length2d">2d
+              length</link> the point has to be located.</para>
+
+              <para>See <link linkend="line_locate_point">line_locate_point()</link>
+              for computing the line location nearest to a Point.</para>
+
+              <note>
+                <para>Since release 1.1.1 this function also interpolates M
+                and Z values (when present), while prior releases set them to
+                0.0.</para>
+              </note>
+
+              <para>Availability: 0.8.2</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="line_substring">
+            <term>line_substring(linestring, start, end)</term>
+
+            <listitem>
+              <para>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.</para>
+
+              <para>If &#39;start&#39; and &#39;end&#39; have the same value
+              this is equivalent to <link linkend="line_interpolate_point">line_interpolate_point()</link>.</para>
+
+              <para>See <link linkend="line_locate_point">line_locate_point()</link>
+              for computing the line location nearest to a Point.</para>
+
+              <note>
+                <para>Since release 1.1.1 this function also interpolates M
+                and Z values (when present), while prior releases set them to
+                unspecified values.</para>
+              </note>
+
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="line_locate_point">
+            <term>line_locate_point(LineString, Point)</term>
+
+            <listitem>
+              <para>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 <link linkend="length2d">2d line</link>
+              length.</para>
+
+              <para>You can use the returned location to extract a Point (<link
+              linkend="line_interpolate_point">line_interpolate_point</link>)
+              or a substring (<link linkend="line_substring">line_substring</link>).</para>
+
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>locate_along_measure(geometry, float8)</term>
+
+            <listitem>
+              <para>Return a derived geometry collection value with elements
+              that match the specified measure. Polygonal elements are not
+              supported.</para>
+
+              <para>Semantic is specified by: ISO/IEC CD 13249-3:200x(E) -
+              Text for Continuation CD Editing Meeting</para>
+
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>locate_between_measures(geometry, float8, float8)</term>
+
+            <listitem>
+              <para>Return a derived geometry collection value with elements
+              that match the specified range of measures inclusively.
+              Polygonal elements are not supported.</para>
+
+              <para>Semantic is specified by: ISO/IEC CD 13249-3:200x(E) -
+              Text for Continuation CD Editing Meeting</para>
+
+              <para>Availability: 1.1.0</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </sect2>
+
+      <sect2>
+        <title>Misc</title>
+
+        <variablelist>
+          <varlistentry>
+            <term>Summary(geometry)</term>
+
+            <listitem>
+              <para>Returns a text summary of the contents of the geometry.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>box2d(geometry)</term>
+
+            <listitem>
+              <para>Returns a BOX2D representing the maximum extents of the
+              geometry.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>box3d(geometry)</term>
+
+            <listitem>
+              <para>Returns a BOX3D representing the maximum extents of the
+              geometry.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>extent(geometry set)</term>
+
+            <listitem>
+              <para>The extent() function is an &#34;aggregate&#34; 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, &#34;SELECT EXTENT(GEOM) FROM GEOMTABLE&#34;
+              will return a BOX3D giving the maximum extend of all features in
+              the table. Similarly, &#34;SELECT EXTENT(GEOM) FROM GEOMTABLE
+              GROUP BY CATEGORY&#34; will return one extent result for each
+              category.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="zmflag">
+            <term>zmflag(geometry)</term>
+
+            <listitem>
+              <para>Returns ZM (dimension semantic) flag of the geometries as
+              a small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="hasbbox">
+            <term>HasBBOX(geometry)</term>
+
+            <listitem>
+              <para>Returns TRUE if the bbox of this geometry is cached, FALSE
+              otherwise. Use <link linkend="addbbox">addBBOX()</link> and
+              <link linkend="dropbbox">dropBBOX()</link> to control caching.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="ndims">
+            <term>ndims(geometry)</term>
+
+            <listitem>
+              <para>Returns number of dimensions of the geometry as a small
+              int. Values are: 2,3 or 4.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>nrings(geometry)</term>
+
+            <listitem>
+              <para>If the geometry is a polygon or multi-polygon returns the
+              number of rings.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>npoints(geometry)</term>
+
+            <listitem>
+              <para>Returns the number of points in the geometry.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="IsValid">
+            <term>isvalid(geometry)</term>
+
+            <listitem>
+              <para>returns true if this geometry is valid.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>expand(geometry, float)</term>
+
+            <listitem>
+              <para>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.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>estimated_extent([schema], table, geocolumn)</term>
+
+            <listitem>
+              <para>Return the &#39;estimated&#39; extent of the given spatial
+              table. The estimated is taken from the geometry column&#39;s
+              statistics. The current schema will be used if not specified.</para>
+
+              <para>For PostgreSQL&#62;=8.0.0 statistics are gathered by
+              VACUUM ANALYZE and resulting extent will be about 95% of the
+              real one.</para>
+
+              <para>For PostgreSQL&#60;8.0.0 statistics are gathered by
+              update_geometry_stats() and resulting extent will be exact.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>find_srid(varchar,varchar,varchar)</term>
+
+            <listitem>
+              <para>The syntax is find_srid(&#60;db/schema&#62;,
+              &#60;table&#62;, &#60;column&#62;) 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.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>mem_size(geometry)</term>
+
+            <listitem>
+              <para>Returns the amount of space (in bytes) the geometry takes.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>numb_sub_objects(geometry)</term>
+
+            <listitem>
+              <para>Returns the number of objects stored in the geometry. This
+              is useful for MULTI-geometries and GEOMETRYCOLLECTIONs.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>point_inside_circle(geometry,float,float,float)</term>
+
+            <listitem>
+              <para>The syntax for this functions is
+              point_inside_circle(&#60;geometry&#62;,&#60;circle_center_x&#62;,&#60;circle_center_y&#62;,&#60;radius&#62;).
+              Returns the true if the geometry is a point and is inside the
+              circle. Returns false otherwise.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>xmin(box3d) ymin(box3d) zmin(box3d)</term>
+
+            <listitem>
+              <para>Returns the requested minima of a bounding box.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry>
+            <term>xmax(box3d) ymax(box3d) zmax(box3d)</term>
+
+            <listitem>
+              <para>Returns the requested maxima of a bounding box.</para>
+            </listitem>
+          </varlistentry>
+
+          <varlistentry id="Accum">
+            <term>Accum(geometry set)</term>
+
+            <listitem>
+              <para>Aggregate. Constructs an array of geometries.</para>
+            </listitem>
+          </varlistentry>
+        </variablelist>
+      </sect2>
+
+      &long_xact;
+    </sect1>
+
+    <sect1>
+      <title>SQL-MM Functions</title>
+
+      <para>This is a listing of the SQL-MM defined functions that PostGIS
+      currently supports. The implementations of these functions follow the
+      ArcSDE implementation, and thus deviate somewhat from the spec. These
+      deviations will be noted.</para>
+
+      <para>As of version 1.2.0, these functions have been implemented by
+      wrapping existing PostGIS functions. As a result, full support for
+      curved geometries may not be in place for many functions.</para>
+
+      <note>
+        <para>SQL-MM defines the default SRID of all geometry constructors as
+        0. PostGIS uses a default SRID of -1.</para>
+      </note>
+
+      <variablelist>
         <varlistentry>
-          <term>distance_sphere(point, point)</term>
+          <term>ST_Area</term>
 
           <listitem>
-            <para>Returns linear distance in meters between two lat/lon
-            points. Uses a spherical earth and radius of 6370986 meters.
-            Faster than <link linkend="distance_spheroid">distance_spheroid()</link>, but
-            less accurate.
-			Only implemented for points.</para>			
+            <para>Return the area measurement of an ST_Surface or
+            ST_MultiSurface value.</para>
+
+            <para>SQL-MM 3: 8.1.2, 9.5.3</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="distance_spheroid">
-          <term>distance_spheroid(point, point, spheroid)</term>
+        <varlistentry>
+          <term>ST_AsBinary</term>
 
           <listitem>
-            <para>Returns linear distance between two lat/lon points given a
-            particular spheroid. See the explanation of spheroids given for
-            <link linkend="length_spheroid">length_spheroid()</link>.
-            Currently only implemented for points.</para>
+            <para>Return the well-known binary representation of an
+            ST_Geometry value.</para>
+
+            <para>SQL-MM 3: 5.1.37</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="length2d">
-          <term>length2d(geometry)</term>
+        <varlistentry>
+          <term>ST_AsText</term>
 
           <listitem>
-            <para>Returns the 2-dimensional length of the geometry if it is a
-            linestring or multi-linestring.</para>
+            <para>Return the well-known text representation of an ST_Geometry
+            value.</para>
+
+            <para>SQL-MM 3: 5.1.25</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>length3d(geometry)</term>
+          <term>ST_Boundary</term>
 
           <listitem>
-            <para>Returns the 3-dimensional length of the geometry if it is a
-            linestring or multi-linestring.</para>
+            <para>Return the boundary of the ST_Geometry value.</para>
+
+            <para>SQL-MM 3: 5.1.14</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="length_spheroid">
-          <term>length_spheroid(geometry,spheroid)</term>
+        <varlistentry>
+          <term>ST_Buffer</term>
 
           <listitem>
-            <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 ellipsoid is a separate database type and can be constructed as
-            follows:</para>
+            <para>Return a buffer around the ST_Geometry value.</para>
 
-            <literallayout>SPHEROID[&lt;NAME&gt;,&lt;SEMI-MAJOR AXIS&gt;,&lt;INVERSE FLATTENING&gt;]</literallayout>
+            <para>SQL-MM 3: 5.1.17</para>
+          </listitem>
+        </varlistentry>
 
-            <para>Eg:</para>
+        <varlistentry>
+          <term>ST_Centroid</term>
 
-            <literallayout>SPHEROID["GRS_1980",6378137,298.257222101]</literallayout>
+          <listitem>
+            <para>Return mathematical centroid of the ST_Surface or
+            ST_MultiSurface value.</para>
 
-            <para>An example calculation might look like this:</para>
+            <para>SQL-MM 3: 8.1.4, 9.5.5</para>
+          </listitem>
+        </varlistentry>
 
-            <literallayout>SELECT
- length_spheroid(
-  geometry_column,
-  'SPHEROID["GRS_1980",6378137,298.257222101]'
- )
-FROM geometry_table;</literallayout>
+        <varlistentry>
+          <term>ST_Contains</term>
+
+          <listitem>
+            <para>Test if an ST_Geometry value spatially contains another
+            ST_Geometry value.</para>
+
+            <para>SQL-MM 3: 5.1.31</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>length3d_spheroid(geometry,spheroid)</term>
+          <term>ST_ConvexHull</term>
 
           <listitem>
-            <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
-            distance vertical displacement adds.</para>
+            <para>Return the convex hull of the ST_Geometry value.</para>
+
+            <para>SQL-MM 3: 5.1.16</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>distance(geometry, geometry)</term>
+          <term>ST_CoordDim</term>
 
           <listitem>
-            <para>Returns the smaller distance between two geometries.</para>
+            <para>Return the coodinate dimension of the ST_Geometry value.</para>
+
+            <para>SQL-MM 3: 5.1.3</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>max_distance(linestring,linestring)</term>
+          <term>ST_Crosses</term>
 
           <listitem>
-            <para>Returns the largest distance between two line
-            strings.</para>
+            <para>Test if an ST_Geometry value spatially crosses another
+            ST_Geometry value.</para>
+
+            <para>SQL-MM 3: 5.1.29</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>perimeter(geometry)</term>
+          <term>ST_Difference</term>
 
           <listitem>
-            <para>Returns the 2-dimensional perimeter of the geometry, if it
-            is a polygon or multi-polygon.</para>
+            <para>Return an ST_Geometry value that represents the point set
+            difference of two ST_Geometry values.</para>
+
+            <para>SQL-MM 3: 5.1.20</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>perimeter2d(geometry)</term>
+          <term>ST_Dimension</term>
 
           <listitem>
-            <para>Returns the 2-dimensional perimeter of the geometry, if it
-            is a polygon or multi-polygon.</para>
+            <para>Return the dimension of the ST_Geometry value.</para>
+
+            <para>SQL-MM 3: 5.1.2</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>perimeter3d(geometry)</term>
+          <term>ST_Disjoint</term>
 
           <listitem>
-            <para>Returns the 3-dimensional perimeter of the geometry, if it
-            is a polygon or multi-polygon.</para>
+            <para>Test if an ST_Geometry value is spatially disjoint from
+            another ST_Geometry value.</para>
+
+            <para>SQL-MM 3: 5.1.26</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>azimuth(geometry, geometry)</term>
+          <term>ST_Distance</term>
 
           <listitem>
-            <para>
-	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.
-            </para>
-		<para>
-			Availability: 1.1.0
-		</para>
+            <para>Return the distance between two geometries.</para>
+
+            <para>SQL-MM 3: 5.1.23</para>
           </listitem>
         </varlistentry>
 
+        <varlistentry>
+          <term>ST_EndPoint</term>
 
-	  </variablelist>
+          <listitem>
+            <para>Return an ST_Point value that is the end point of an
+            ST_Curve value.</para>
 
-      </sect2>
+            <para>SQL-MM 3: 7.1.4</para>
+          </listitem>
+        </varlistentry>
 
-	<sect2>
-		<title>Geometry Outputs</title>
-		<variablelist>
+        <varlistentry>
+          <term>ST_Envelope</term>
 
-			<varlistentry>
-				<term>AsBinary(geometry,{'NDR'|'XDR'})</term>
+          <listitem>
+            <para>Return the bounding rectangle for the ST_Geometry value.</para>
 
-				<listitem>
-					<para>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.</para>
-				</listitem>
-			</varlistentry>
+            <para>SQL-MM 3: 5.1.15</para>
+          </listitem>
+        </varlistentry>
 
-			<varlistentry>
-				<term>AsEWKT(geometry)</term>
-				<listitem>
-					<para>Returns a Geometry in EWKT format (as text).</para>
-				</listitem>
-			</varlistentry>
+        <varlistentry>
+          <term>ST_Equals</term>
 
-			<varlistentry>
-				<term>AsEWKB(geometry, {'NDR'|'XDR'})</term>
-				<listitem>
-					<para>Returns a Geometry in EWKB format (as bytea) using either little-endian (NDR) or big-endian (XDR) encoding.</para>
-				</listitem>
-			</varlistentry>
+          <listitem>
+            <para>Test if an ST_Geometry alue as spatially equal to another
+            ST_Geometry value.</para>
 
-			<varlistentry>
-				<term>AsHEXEWKB(geometry, {'NDR'|'XDR'})</term>
-				<listitem>
-					<para>Returns a Geometry in HEXEWKB format (as text) using either little-endian (NDR) or big-endian (XDR) encoding.</para>
-				</listitem>
-			</varlistentry>
+            <para>SQL-MM 3: 5.1.24</para>
+          </listitem>
+        </varlistentry>
 
-			<varlistentry>
-				<term>AsSVG(geometry, [rel], [precision])</term>
-				<listitem>
-					<para>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.</para>
-				</listitem>
-			</varlistentry>
+        <varlistentry>
+          <term>ST_ExteriorRing</term>
 
-			<varlistentry>
-				<term>AsGML(geometry, [precision])</term>
-				<listitem>
-					<para>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).</para>
-				</listitem>
-			</varlistentry>
+          <listitem>
+            <para>Return the exterior ring of an ST_Surface</para>
 
-		</variablelist>
-	</sect2>
+            <para>SQL-MM 3: 8.2.3, 8.3.3</para>
+          </listitem>
+        </varlistentry>
 
+        <varlistentry>
+          <term>ST_GeometryN</term>
 
-      <sect2>
-      	<title>Geometry Constructors</title>
+          <listitem>
+            <para>Return the indicated ST_Geometry value from an
+            ST_GeomCollection.</para>
 
-	  <variablelist>
+            <para>SQL-MM 3: 9.1.5</para>
+          </listitem>
+        </varlistentry>
 
-		<varlistentry>
-			<term>GeomFromEWKT(text)</term>
-			<listitem>
-				<para>Makes a Geometry from EWKT.</para>
-			</listitem>
-		</varlistentry>
+        <varlistentry>
+          <term>ST_GeometryType</term>
 
-		<varlistentry>
-			<term>GeomFromEWKB(bytea)</term>
-			<listitem>
-				<para>Makes a Geometry from EWKB.</para>
-			</listitem>
-		</varlistentry>
+          <listitem>
+            <para>Return the geometry type of the ST_Geometry value.</para>
 
-		<varlistentry>
-		  <term>MakePoint(&lt;x&gt;, &lt;y&gt;, [&lt;z&gt;], [&lt;m&gt;])</term>
-		  <listitem>
-		    <para>Creates a 2d,3dz or 4d point geometry.</para>
-		  </listitem>
-		</varlistentry>
+            <para>SQL-MM 3: 5.1.4</para>
+          </listitem>
+        </varlistentry>
 
-		<varlistentry>
-		  <term>MakePointM(&lt;x&gt;, &lt;y&gt;, &lt;m&gt;)</term>
+        <varlistentry>
+          <term>ST_GeomFromText</term>
 
-		  <listitem>
-		    <para>Creates a 3dm point geometry.</para>
-		  </listitem>
-		</varlistentry>
+          <listitem>
+            <para>Return a specified ST_Geometry value.</para>
 
+            <para>SQL-MM 3: 5.1.40</para>
+          </listitem>
+        </varlistentry>
 
-		<varlistentry>
-		  <term>MakeBox2D(&lt;LL&gt;, &lt;UR&gt;)</term>
+        <varlistentry>
+          <term>ST_GeomFromWKB</term>
 
-		  <listitem>
-		    <para>Creates a BOX2D defined by the given point geometries.</para>
-		  </listitem>
-		</varlistentry>
+          <listitem>
+            <para>Return a specified ST_Geometry value.</para>
 
-		<varlistentry>
-		  <term>MakeBox3D(&lt;LLB&gt;, &lt;URT&gt;)</term>
+            <para>SQL-MM 3: 5.1.41</para>
+          </listitem>
+        </varlistentry>
 
-		  <listitem>
-		    <para>Creates a BOX3D defined by the given point geometries.</para>
-		  </listitem>
-		</varlistentry>
+        <varlistentry>
+          <term>ST_InteriorRingN</term>
 
-		<varlistentry>
-		  <term>MakeLine(geometry set)</term>
+          <listitem>
+            <para>Return the specified interior ring of an ST_Surface value.</para>
 
-		  <listitem>
-		    <para>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.</para>
-		  </listitem>
-		</varlistentry>
+            <para>SQL-MM 3: 8.2.6, 8.3.5</para>
+          </listitem>
+        </varlistentry>
 
-		<varlistentry>
-		  <term>MakeLine(geometry, geometry)</term>
-		  <listitem>
-		    <para>Creates a Linestring from the two given point
-		    geometries.</para>
-		  </listitem>
-		</varlistentry>
+        <varlistentry>
+          <term>ST_Intersection</term>
 
-		<varlistentry>
-		  <term>LineFromMultiPoint(multipoint)</term>
+          <listitem>
+            <para>Return an ST_Geometry value that represents the point set
+            intersection of two ST_Geometry values.</para>
 
-		  <listitem>
-		    <para>Creates a LineString from a MultiPoint geometry.</para>
-		  </listitem>
-		</varlistentry>
+            <para>SQL-MM 3: 5.1.18</para>
+          </listitem>
+        </varlistentry>
 
+        <varlistentry>
+          <term>ST_Intersects</term>
 
+          <listitem>
+            <para>Test if an ST_Geometry value spatially intersects another
+            ST_Geometry value.</para>
 
-		<varlistentry>
-		  <term>MakePolygon(linestring, [linestring[]])</term>
-		  <listitem>
-		    <para>Creates a Polygon formed by the given 
-		    shell and array of holes. You can construct
-		    a geometry array using <link linkend="Accum">Accum</link>.
-		    Input geometries must be closed LINESTRINGS (see <link linkend="IsClosed">IsClosed</link> and <link linkend="GeometryType">GeometryType</link>).
-		    </para>
-		  </listitem>
-		</varlistentry>
+            <para>SQL-MM 3: 5.1.27</para>
+          </listitem>
+        </varlistentry>
 
-		<varlistentry id="BuildArea">
-		  <term>BuildArea(geometry)</term>
-		  <listitem>
-		    <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
-		    returned.
-		    </para>
+        <varlistentry>
+          <term>ST_IsClosed</term>
 
-		    <para>
-		    See also <link linkend="BdPolyFromText">BdPolyFromText</link> and <link linkend="BdMPolyFromText">BdMPolyFromText</link> - wrappers to this function with standard OGC interface.
-		    </para>
+          <listitem>
+            <para>Test if an ST_Curve or ST_MultiCurve value is closed.</para>
 
-		<para>
-		    Availability: 1.1.0 - requires GEOS >= 2.1.0.
-		</para>
-		  </listitem>
-		</varlistentry>
+            <note>
+              <para>SQL-MM defines the result of ST_IsClosed(NULL) to be 0,
+              while PostGIS returns NULL.</para>
+            </note>
 
-		<varlistentry>
-		  <term>Polygonize(geometry set)</term>
+            <para>SQL-MM 3: 7.1.5, 9.3.3</para>
+          </listitem>
+        </varlistentry>
 
-		  <listitem>
+        <varlistentry>
+          <term>ST_IsEmpty</term>
 
-		<para>
-			Aggregate. Creates a GeometryCollection containing
-			possible polygons formed from the constituent linework
-			of a set of geometries.
-		</para>
+          <listitem>
+            <para>Test if an ST_Geometry value corresponds to the empty set.</para>
 
-		<para>
-		    Availability: 1.0.0RC1 - requires GEOS >= 2.1.0.
-		</para>
+            <note>
+              <para>SQL-MM defines the result of ST_IsEmpty(NULL) to be 0,
+              while PostGIS returns NULL.</para>
+            </note>
 
-		  </listitem>
-		</varlistentry>
+            <para>SQL-MM 3: 5.1.7</para>
+          </listitem>
+        </varlistentry>
 
-		<varlistentry>
-		  <term>Collect(geometry set)</term>
+        <varlistentry>
+          <term>ST_IsRing</term>
 
-		  <listitem>
-		    <para>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.</para>
-		  </listitem>
-		</varlistentry>
+          <listitem>
+            <para>Test if an ST_Curve value is a ring.</para>
 
-		<varlistentry>
-		  <term>Collect(geometry, geometry)</term>
+            <note>
+              <para>SQL-MM defines the result of ST_IsRing(NULL) to be 0,
+              while PostGIS returns NULL.</para>
+            </note>
 
-		  <listitem>
-		    <para>This function returns a geometry being a collection
-		    of two input geometries. Output type can be a MULTI* or 
-		    a GEOMETRYCOLLECTION.</para>
-		  </listitem>
-		</varlistentry>
+            <para>SQL-MM 3: 7.1.6</para>
+          </listitem>
+        </varlistentry>
 
-		<varlistentry>
-		  <term>Dump(geometry)</term>
+        <varlistentry>
+          <term>ST_IsSimple</term>
 
-		  <listitem>
-		    <para>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.
-		    </para>
+          <listitem>
+            <para>Test if an ST_Geometry value has no anomalous geometryc
+            points, such as self intersection or self tangency.</para>
 
-		<para>
-		    Availability: PostGIS 1.0.0RC1.
-		    Requires PostgreSQL 7.3 or higher.
-		</para>
+            <note>
+              <para>SQL-MM defines the result of ST_IsSimple(NULL) to be 0,
+              while PostGIS returns NULL.</para>
+            </note>
 
-		  </listitem>
-		</varlistentry>
+            <para>SQL-MM 3: 5.1.8</para>
+          </listitem>
+        </varlistentry>
 
-		<varlistentry>
-		  <term>DumpRings(geometry)</term>
+        <varlistentry>
+          <term>ST_IsValid</term>
 
-		  <listitem>
-		    <para>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.
-		    </para>
+          <listitem>
+            <para>Test if an ST_Geometry value is well formed.</para>
 
-		<para>
-		    Availability: PostGIS 1.1.3.
-		    Requires PostgreSQL 7.3 or higher.
-		</para>
+            <note>
+              <para>SQL-MM defines the result of ST_IsValid(NULL) to be 0,
+              while PostGIS returns NULL.</para>
+            </note>
 
-		  </listitem>
-		</varlistentry>
+            <para>QL-MM defines the result of ST_IsValid(NULL) to be 1</para>
 
-	  </variablelist>
-      </sect2>
+            <para>SQL-MM 3: 5.1.9</para>
+          </listitem>
+        </varlistentry>
 
-      <sect2>
-      	<title>Geometry Editors</title>
-	  <variablelist>
+        <varlistentry>
+          <term>ST_Length</term>
 
-        <varlistentry id="addbbox">
-          <term>AddBBOX(geometry)</term>
           <listitem>
-            <para>Add bounding box to the geometry. This would make bounding
-	    box based queries faster, but will increase the size of the
-	    geometry.</para>
+            <para>Return the length measurement of an ST_Curve or
+            ST_MultiCurve value.</para>
+
+            <para>SQL-MM 3: 7.1.2, 9.3.4</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="dropbbox">
-          <term>DropBBOX(geometry)</term>
+        <varlistentry>
+          <term>ST_LineFromText</term>
+
           <listitem>
-            <para>Drop the bounding box cache from the geometry.
-	    This reduces geometry size, but makes bounding-box based
-	    queries slower.</para>
+            <para>Return a specified ST_LineString value.</para>
+
+            <para>SQL-MM 3: 7.2.8</para>
           </listitem>
         </varlistentry>
 
-	<varlistentry>
-	  <term>AddPoint(linestring, point, [&lt;position&gt;])</term>
+        <varlistentry>
+          <term>ST_LineFromWKB</term>
 
-	  <listitem>
-	    <para>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.
-	    </para>
-	  </listitem>
-	</varlistentry>
+          <listitem>
+            <para>Return a specified ST_LineString value.</para>
 
-	<varlistentry>
-	  <term>RemovePoint(linestring, offset)</term>
-	  <listitem>
-		<para>
-			Removes point from a linestring. Offset is 0-based.
-		</para>
-		<para>
-			Availability: 1.1.0
-		</para>
-	  </listitem>
-	</varlistentry>
+            <para>SQL-MM 3: 7.2.9</para>
+          </listitem>
+        </varlistentry>
 
-	<varlistentry>
-	  <term>SetPoint(linestring, N, point)</term>
-	  <listitem>
-		<para>
-			Replace point N of linestring with given point.
-			Index is 0-based.
-		</para>
-		<para>
-			Availability: 1.1.0
-		</para>
-	  </listitem>
-	</varlistentry>
-
         <varlistentry>
-          <term>Force_collection(geometry)</term>
+          <term>ST_MLineFromText</term>
 
           <listitem>
-            <para>Converts the geometry into a GEOMETRYCOLLECTION. This is
-            useful for simplifying the WKB representation.</para>
+            <para>Return a specified ST_MultiLineString value.</para>
+
+            <para>SQL-MM 3: 9.4.4</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="force_2d">
-          <term>Force_2d(geometry)</term>
+        <varlistentry>
+          <term>ST_MLineFromWKB</term>
 
           <listitem>
-            <para>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).</para>
+            <para>Return a specified ST_MultiLineString value.</para>
+
+            <para>SQL-MM 3: 9.4.5</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="force_3dz">
-          <term>Force_3dz(geometry)</term>
-          <term>Force_3d(geometry)</term>
+        <varlistentry>
+          <term>ST_MPointFromText</term>
 
           <listitem>
-            <para>Forces the geometries into XYZ mode.</para>
+            <para>Return a specified ST_MultiPoint value.</para>
+
+            <para>SQL-MM 3: 9.2.4</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="force_3dm">
-          <term>Force_3dm(geometry)</term>
+        <varlistentry>
+          <term>ST_MPointFromWKB</term>
 
           <listitem>
-            <para>Forces the geometries into XYM mode.</para>
+            <para>Return a specified ST_MultiPoint value.</para>
+
+            <para>SQL-MM 3: 9.2.5</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="force_4d">
-          <term>Force_4d(geometry)</term>
+        <varlistentry>
+          <term>ST_MPolyFromText</term>
 
           <listitem>
-            <para>Forces the geometries into XYZM mode.</para>
+            <para>Return a specified ST_MultiPolygon value.</para>
+
+            <para>SQL-MM 3: 9.6.4</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>Multi(geometry)</term>
+          <term>ST_MPolyFromWKB</term>
 
           <listitem>
-            <para>Returns the geometry as a MULTI* geometry. If the geometry
-            is already a MULTI*, it is returned unchanged.</para>
+            <para>Return a specified ST_MultiPolygon value.</para>
+
+            <para>SQL-MM 3: 9.6.5</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>Transform(geometry,integer)</term>
+          <term>ST_NumGeometries</term>
 
           <listitem>
-            <para>Returns a new geometry with its coordinates transformed to
-            the SRID referenced by the integer parameter. The destination SRID
-            must exist in the <varname>SPATIAL_REF_SYS</varname> table.</para>
+            <para>Return the number of geometries in an ST_GeomCollection.</para>
+
+            <para>SQL-MM 3: 9.1.4</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>Affine(geometry,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8)</term>
+          <term>ST_NumInteriorRing</term>
 
           <listitem>
-            <para>Applies an 3d affine transformation to the geometry. The call 
-                <programlisting>
-                    Affine(geom, a, b, c, d, e, f, g, h, i, xoff, yoff, zoff)
-                </programlisting>
-                represents the transformation matrix
-                <programlisting>
-                    /  a  b  c  xoff  \
-                    |  d  e  f  yoff  |
-                    |  g  h  i  zoff  |
-                    \  0  0  0  1     /
-                </programlisting>
-                and the vertices are transformed as follows:
-                <programlisting>
-                    x' = a*x + b*y + c*z + xoff
-                    y' = d*x + e*y + f*z + yoff
-                    z' = g*x + h*y + i*z + zoff   
-                </programlisting>
-                All of the translate / scale functions below are expressed via such an affine transformation.
-            </para>
-            <para>
-                Availability: 1.1.2.
-            </para>
+            <para>Return the number of interior rings in an ST_Surface.</para>
+
+            <para>SQL-MM 3: 8.2.5</para>
           </listitem>
         </varlistentry>
-	
+
         <varlistentry>
-          <term>Affine(geometry,float8,float8,float8,float8,float8,float8)</term>
+          <term>ST_NumPoints</term>
 
           <listitem>
-            <para>Applies an 2d affine transformation to the geometry. The call 
-                <programlisting>
-                    Affine(geom, a, b, d, e, xoff, yoff)
-                </programlisting>
-                represents the transformation matrix
-                <programlisting>
-                    /  a  b  0  xoff  \        /  a  b  xoff  \
-                    |  d  e  0  yoff  |  rsp.  |  d  e  yoff  |
-                    |  0  0  1  0     |        \  0  0  1     /
-                    \  0  0  0  1     /
-                </programlisting>
-                and the vertices are transformed as follows:
-                <programlisting>
-                    x' = a*x + b*y + xoff
-                    y' = d*x + e*y + yoff
-                    z' = z   
-                </programlisting>
-                This method is a subcase of the 3D method above.
-            </para>
-            <para>
-		Availability: 1.1.2.
-            </para>
+            <para>Return the number of points in an ST_LineString or
+            ST_CircularString value.</para>
+
+            <para>SQL-MM 3: 7.2.4</para>
           </listitem>
         </varlistentry>
-	
+
         <varlistentry>
-          <term>Translate(geometry,float8,float8,float8)</term>
+          <term>ST_OrderingEquals</term>
 
           <listitem>
-            <para>Translates the geometry to a new location using the numeric
-            parameters as offsets. Ie: translate(geom, X, Y, Z).</para>
+            <para>ST_OrderingEquals compares two geometries and t (TRUE) if
+            the geometries are equal and the coordinates are in the same
+            order; otherwise it returns f (FALSE).</para>
+
+            <note>
+              <para>This function is implemented as per the ArcSDE SQL
+              specification rather than SQL-MM.
+              http://edndoc.esri.com/arcsde/9.1/sql_api/sqlapi3.htm#ST_OrderingEquals</para>
+            </note>
+
+            <para>SQL-MM 3: 5.1.43</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>Scale(geometry,float8,float8,float8)</term>
+          <term>ST_Overlaps</term>
 
           <listitem>
-            <para>scales the geometry to a new size by multiplying the
-            ordinates with the parameters. Ie: scale(geom, Xfactor, Yfactor, Zfactor).</para>
-		<para>
-			Availability: 1.1.0
-		</para>
+            <para>Test if an ST_Geometry value spatially overlays another
+            ST_Geometry value.</para>
+
+            <para>SQL-MM 3: 5.1.32</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="Rotate">
-          <term>RotateZ(geometry,float8)</term>
-          <term>RotateX(geometry,float8)</term>
-          <term>RotateY(geometry,float8)</term>
+        <varlistentry>
+          <term>ST_Perimeter</term>
+
           <listitem>
-		<para>
-			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.
-		</para>
-		<para>
-			Availability: 1.1.2.
-		</para>
+            <para>Return the length measurement of the boundary of an
+            ST_Surface or ST_MultiRSurface value.</para>
+
+            <para>SQL-MM 3: 8.1.3, 9.5.4</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>TransScale(geometry,float8,float8,float8,float8)</term>
+          <term>ST_Point</term>
 
           <listitem>
-                <para>First, translates the geometry using the first two floats, then scales it
-                    using the second two floats, working in 2D only. Using
-                    <code>transscale(geom, X, Y, XFactor, YFactor)</code> internally calls
-                    <code>affine(geom, XFactor, 0, 0,  0, YFactor, 0,  0, 0, 1,  X*XFactor, Y*YFactor, 0)</code>.                
-                </para>
-                <para>
-                        Availability: 1.1.0.
-                </para>
+            <para>Returns an ST_Point with the given coordinate values.</para>
+
+            <para>SQL-MM 3: 6.1.2</para>
           </listitem>
         </varlistentry>
 
+        <varlistentry>
+          <term>ST_PointFromText</term>
 
-        <varlistentry>
-          <term>Reverse(geometry)</term>
           <listitem>
-            <para>Returns the geometry with vertex order reversed.</para>
+            <para>Return a specified ST_Point value.</para>
+
+            <para>SQL-MM 3: 6.1.8</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>ForceRHR(geometry)</term>
+          <term>ST_PointFromWKB</term>
+
           <listitem>
-            <para>Force polygons of the collection to obey Right-Hand-Rule.</para>
+            <para>Return a specified ST_Point value.</para>
+
+            <para>SQL-MM 3: 6.1.9</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>Simplify(geometry, tolerance)</term>
+          <term>ST_PointN</term>
 
           <listitem>
-            <para>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 <link linkend="IsSimple">IsSimple</link>)</para>
+            <para>Return the specified ST_Point value in an ST_LineString or
+            ST_CircularString</para>
+
+            <para>SQL-MM 3: 7.2.5, 7.3.5</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>SnapToGrid(geometry, originX, originY, sizeX, sizeY)</term>
-          <term>SnapToGrid(geometry, sizeX, sizeY)</term>
-          <term>SnapToGrid(geometry, size)</term>
+          <term>ST_PointOnSurface</term>
 
           <listitem>
-            <para>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.</para>
+            <para>Return an ST_Point value guaranteed to spatially intersect
+            the ST_Surface or ST_MultiSurface value.</para>
 
-	<note><para>
-            The returned geometry might loose its
-            simplicity (see <link linkend="IsSimple">IsSimple</link>).
-	</para></note>
-
-	<note><para>
-            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.
-	</para></note>
-
-		<para>
-			Availability: 1.0.0RC1
-		</para>
+            <para>SQL-MM 3: 8.1.5, 9.5.6</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>SnapToGrid(geometry, geometry, sizeX, sizeY, sizeZ, sizeM)</term>
+          <term>ST_PolyFromText</term>
+
           <listitem>
-            <para>
-	    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.
-	    </para>
+            <para>Return a specified ST_Polygon value.</para>
 
-		<para>
-			Availability: 1.1.0
-		</para>
+            <para>SQL-MM 3: 8.3.6</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>Segmentize(geometry, maxlength)</term>
+          <term>ST_PolyFromWKB</term>
 
           <listitem>
-            <para>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.</para>
+            <para>Return a specified ST_Polygon value.</para>
+
+            <para>SQL-MM 3: 8.3.7</para>
           </listitem>
         </varlistentry>
 
-		<varlistentry>
-		  <term>LineMerge(geometry)</term>
+        <varlistentry>
+          <term>ST_Polygon</term>
 
-		  <listitem>
+          <listitem>
+            <para>Return a polygon build from the specified linestring and
+            SRID.</para>
 
-		<para>
-			Returns a (set of) LineString(s) formed by sewing
-			together constituent linework of input.
-		</para>
+            <para>SQL-MM 3: 8.3.2</para>
+          </listitem>
+        </varlistentry>
 
-		<para>
-			Availability: 1.1.0 - requires GEOS >= 2.1.0
-		</para>
+        <varlistentry>
+          <term>ST_Relate</term>
 
-		  </listitem>
-		</varlistentry>
+          <listitem>
+            <para>Test if an ST_Geometry value is spatially related to another
+            ST_Geometry value.</para>
 
-	  </variablelist>
-      </sect2>
+            <para>SQL-MM 3: 5.1.25</para>
+          </listitem>
+        </varlistentry>
 
-      <sect2>
-	<title>Linear Referencing</title>
+        <varlistentry>
+          <term>ST_SRID</term>
 
-	<variablelist>
-
-        <varlistentry id="line_interpolate_point">
-          <term>line_interpolate_point(linestring, location)</term>
-
           <listitem>
-		<para>
-		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
-		<link linkend="length2d">2d length</link> the point has
-		to be located.
-		</para>
+            <para>Return the spatial reference system identifier of the
+            ST_Geometry value.</para>
 
-		<para>
-		See <link linkend="line_locate_point">line_locate_point()</link>
-		for computing the line location nearest to a Point.
-		</para>
-
-	<note><para>
-            Since release 1.1.1 this function also interpolates
-	    M and Z values (when present), while prior releases
-	    set them to 0.0.
-	</para></note>
-
-		<para>
-			Availability: 0.8.2
-		</para>
+            <para>SQL-MM 3: 5.1.5</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="line_substring">
-          <term>line_substring(linestring, start, end)</term>
+        <varlistentry>
+          <term>ST_StartPoint</term>
 
           <listitem>
-            	<para>
-		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.
-		</para>
+            <para>Return an ST_Point value that is the start point of an
+            ST_Curve value.</para>
 
-		<para>
-		If 'start' and 'end' have the same value this is equivalent 
-		to <link linkend="line_interpolate_point">line_interpolate_point()</link>.
-		</para>
+            <para>SQL-MM 3: 7.1.3</para>
+          </listitem>
+        </varlistentry>
 
-		<para>
-		See <link linkend="line_locate_point">line_locate_point()</link>
-		for computing the line location nearest to a Point.
-		</para>
+        <varlistentry>
+          <term>ST_SymDifference</term>
 
-	<note><para>
-            Since release 1.1.1 this function also interpolates
-	    M and Z values (when present), while prior releases
-	    set them to unspecified values.
-	</para></note>
+          <listitem>
+            <para>Return an ST_Geometry value that represents the point set
+            symmetrcy difference of two ST_Geometry values.</para>
 
-		<para>
-			Availability: 1.1.0
-		</para>
+            <para>SQL-MM 3: 5.1.21</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="line_locate_point">
-          <term>line_locate_point(LineString, Point)</term>
+        <varlistentry>
+          <term>ST_Touches</term>
+
           <listitem>
-            	<para>
-		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 <link linkend="length2d">2d line</link> length.
-		</para>
+            <para>Test if an ST_Geometry value spatially touches another
+            ST_Geometry value.</para>
 
-		<para>
-	You can use the returned location to extract a Point (<link linkend="line_interpolate_point">line_interpolate_point</link>) or a substring (<link linkend="line_substring">line_substring</link>).
-		</para>
-
-		<para>
-			Availability: 1.1.0
-		</para>
+            <para>SQL-MM 3: 5.1.28</para>
           </listitem>
         </varlistentry>
 
-
         <varlistentry>
-          <term>locate_along_measure(geometry, float8)</term>
+          <term>ST_Transform</term>
 
           <listitem>
-            	<para>
-		Return a derived geometry collection value with elements that
-		match the specified measure.
-		Polygonal elements are not supported.
-		</para>
+            <para>Return an ST_Geometry value transformed to the specified
+            spatial reference system.</para>
 
-		<para>
-		Semantic is specified by: ISO/IEC CD 13249-3:200x(E) -
-		Text for Continuation CD Editing Meeting
-		</para>
-
-		<para>
-			Availability: 1.1.0
-		</para>
+            <para>SQL-MM 3: 5.1.6</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>locate_between_measures(geometry, float8, float8)</term>
+          <term>ST_Union</term>
 
           <listitem>
-            	<para>
-		Return a derived geometry collection value with elements that
-		match the specified range of measures inclusively.
-		Polygonal elements are not supported. 
-		</para>
+            <para>Return an ST_Geometry value that represents the point set
+            union of two sST_Geometry values.</para>
 
-		<para>
-		Semantic is specified by: ISO/IEC CD 13249-3:200x(E) -
-		Text for Continuation CD Editing Meeting
-		</para>
-
-		<para>
-			Availability: 1.1.0
-		</para>
+            <para>SQL-MM 3: 5.1.19</para>
           </listitem>
         </varlistentry>
 
-	</variablelist>
+        <varlistentry>
+          <term>ST_Within</term>
 
-	</sect2>
+          <listitem>
+            <para>Test if an ST_Geometry value is spatially within another
+            ST_Geometry value.</para>
 
-      <sect2>
-	<title>Misc</title>
-	  <variablelist>
+            <para>SQL-MM 3: 5.1.30</para>
+          </listitem>
+        </varlistentry>
 
-			<varlistentry>
-				<term>Summary(geometry)</term>
-				<listitem>
-					<para>Returns a text summary of the contents of the geometry.</para>
-				</listitem>
-			</varlistentry>
+        <varlistentry>
+          <term>ST_WKBToSQL</term>
 
-			<varlistentry>
-				<term>box2d(geometry)</term>
-				<listitem>
-					<para>Returns a BOX2D representing the maximum extents of the geometry.</para>
-				</listitem>
-			</varlistentry>
+          <listitem>
+            <para>Return an ST_Geometry value for a given well-known binary
+            representation.</para>
 
-			<varlistentry>
-				<term>box3d(geometry)</term>
-				<listitem>
-					<para>Returns a BOX3D representing the maximum extents of the geometry.</para>
-				</listitem>
-			</varlistentry>
+            <para>SQL-MM 3: 5.1.36</para>
+          </listitem>
+        </varlistentry>
 
-			<varlistentry>
-				<term>extent(geometry set)</term>
+        <varlistentry>
+          <term>ST_WKTToSQL</term>
 
-				<listitem>
-					<para>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.</para>
-				</listitem>
-			</varlistentry>
+          <listitem>
+            <para>Return an ST_Geometry value for a given well-known text
+            representation.</para>
 
-			<varlistentry id="zmflag">
-				<term>zmflag(geometry)</term>
-				<listitem>
-					<para>Returns ZM (dimension semantic) flag of the geometries as a small int. Values are: 0=2d, 1=3dm, 2=3dz, 3=4d.  </para>
-				</listitem>
-			</varlistentry>
+            <para>SQL-MM 3: 5.1.34</para>
+          </listitem>
+        </varlistentry>
 
-			<varlistentry id="hasbbox">
-				<term>HasBBOX(geometry)</term>
-				<listitem>
-					<para>Returns TRUE if the bbox of this geometry is cached, FALSE otherwise. Use <link linkend="addbbox">addBBOX()</link> and <link linkend="dropbbox">dropBBOX()</link> to control caching.</para>
-				</listitem>
-			</varlistentry>
+        <varlistentry>
+          <term>ST_X</term>
 
-			<varlistentry id="ndims">
-				<term>ndims(geometry)</term>
-				<listitem>
-					<para>Returns number of dimensions of the geometry as a small int. Values are: 2,3 or 4.</para>
-				</listitem>
-			</varlistentry>
+          <listitem>
+            <para>Returns the x coordinate value of an ST_Point value.</para>
 
-			<varlistentry>
-				<term>nrings(geometry)</term>
-				<listitem>
-					<para>If the geometry is a polygon or multi-polygon returns the number of rings.</para>
-				</listitem>
-			</varlistentry>
+            <para>SQL-MM 3: 6.1.3</para>
+          </listitem>
+        </varlistentry>
 
-			<varlistentry>
-				<term>npoints(geometry)</term>
-				<listitem>
-					<para>Returns the number of points in the geometry.</para>
-				</listitem>
-			</varlistentry>
+        <varlistentry>
+          <term>ST_Y</term>
 
-		<varlistentry id="IsValid">
-		  <term>isvalid(geometry)</term>
+          <listitem>
+            <para>Returns the y coordinate value of an ST_Point value.</para>
 
-		  <listitem>
-		    <para>returns true if this geometry is valid.</para>
-		  </listitem>
-		</varlistentry>
+            <para>SQL-MM 3: 6.1.4</para>
+          </listitem>
+        </varlistentry>
+      </variablelist>
+    </sect1>
 
-		<varlistentry>
-		  <term>expand(geometry, float)</term>
+    <sect1>
+      <title>ArcSDE Functions</title>
 
-		  <listitem>
-		    <para>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.</para>
-		  </listitem>
-		</varlistentry>
+      <para>Additional functions have been added to improve support for an
+      ArcSDE style interface.</para>
 
-		<varlistentry>
-			<term>estimated_extent([schema], table, geocolumn)</term>
-			<listitem>
-				<para> 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.</para>
+      <variablelist>
+        <varlistentry>
+          <term>SE_EnvelopesIntersect</term>
 
-				<para>For PostgreSQL&gt;=8.0.0 statistics are gathered by VACUUM ANALYZE and resulting extent will be about 95% of the real one.</para>
-				<para>For PostgreSQL&lt;8.0.0 statistics are gathered by update_geometry_stats() and resulting extent will be exact.</para>
-			</listitem>
-		</varlistentry>
-
-	<varlistentry>
-          <term>find_srid(varchar,varchar,varchar)</term>
-
           <listitem>
-            <para>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.</para>
+            <para>Returns t (TRUE) if the envelopes of two geometries
+            intersect; otherwise, it returns f (FALSE).</para>
           </listitem>
         </varlistentry>
 
-
         <varlistentry>
-          <term>mem_size(geometry)</term>
+          <term>SE_Is3d</term>
 
           <listitem>
-            <para>Returns the amount of space (in bytes) the geometry
-            takes.</para>
+            <para>Test if a geometry value has z coordinate values.</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>numb_sub_objects(geometry)</term>
+          <term>SE_IsMeasured</term>
 
           <listitem>
-            <para>Returns the number of objects stored in the geometry. This
-            is useful for MULTI-geometries and GEOMETRYCOLLECTIONs.</para>
+            <para>Test if a geometry value has m coordinate values.</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>point_inside_circle(geometry,float,float,float)</term>
+          <term>SE_LocateAlong</term>
 
           <listitem>
-            <para>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.</para>
+            <para>Return a derived geometry collection value with elements
+            that match the specified measur.</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>xmin(box3d) ymin(box3d) zmin(box3d)</term>
+          <term>SE_LocateBetween</term>
 
           <listitem>
-            <para>Returns the requested minima of a bounding box.</para>
+            <para>Return a derived geometry collection value with elements
+            that match the specified range of measures inclusively.</para>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>xmax(box3d) ymax(box3d) zmax(box3d)</term>
+          <term>SE_M</term>
 
           <listitem>
-            <para>Returns the requested maxima of a bounding box.</para>
+            <para>Returns the m coordinate value of an ST_Point value.</para>
           </listitem>
         </varlistentry>
 
-        <varlistentry id="Accum">
-          <term>Accum(geometry set)</term>
+        <varlistentry>
+          <term>SE_Z</term>
 
           <listitem>
-            <para>Aggregate. Constructs an array of geometries.</para>
+            <para>Returns the z coordinate value of an ST_Point value</para>
           </listitem>
         </varlistentry>
+      </variablelist>
+    </sect1>
+  </chapter>
 
-        </variablelist>
-      </sect2>
+  <chapter>
+    <title>Reporting Bugs</title>
 
-      &long_xact;
+    <para>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 <code>SELECT
+    postgis_full_version()</code> [for postgis] and <code>SELECT version()</code>
+    [for postgresql].</para>
 
-    </sect1>
+    <para>If you aren&#39;t using latest release, it&#39;s worth taking a look
+    at its <ulink url="http://postgis.refractions.net/CHANGES.txt">release
+    changelog</ulink> first, to find out if your bug has already been fixed.</para>
+
+    <para>Using the <ulink url="http://postgis.refractions.net/bugs/">PostGIS
+    bug tracker</ulink> will ensure your reports are not discarded, and will
+    keep you informed on it&#39;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.</para>
+
+    <para>You might want to read Simon Tatham&#39;s paper about <ulink
+    url="http://www.chiark.greenend.org.uk/~sgtatham/bugs.html">How to Report
+    Bugs Effectively</ulink> before filing a new report.</para>
   </chapter>
 
-	<chapter>
-		<title>Reporting Bugs</title>
+  <appendix id="release_notes">
+    <title>Appendix</title>
 
-		<para>
-	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 <code>SELECT postgis_full_version()</code>
-	[for postgis] and <code>SELECT version()</code> [for postgresql].
-		</para>
+    <sect1>
+      <title>Release Notes</title>
 
-		<para>
-	If you aren't using latest release, it's worth taking a look
-	at its <ulink
-	url="http://postgis.refractions.net/CHANGES.txt">release
-	changelog</ulink> first, to find out if your bug has already been
-	fixed.
-		</para>
+      <sect2>
+        <title>Release 1.2.1</title>
 
-		<para>
-	Using the <ulink url="http://postgis.refractions.net/bugs/">PostGIS
-	bug tracker</ulink> 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.
-		</para>
+        <para>Release date: 2007/01/11</para>
 
-		<para>
-	You might want to read Simon Tatham's paper about <ulink
-	url="http://www.chiark.greenend.org.uk/~sgtatham/bugs.html">How
-	to Report Bugs Effectively</ulink> before filing a new report.
-		</para>
+        <para>This release provides bug fixes in PostgreSQL 8.2 
+        support and some small performance enhancements.</para>
 
-	</chapter>
+        <sect3>
+          <title>Changes</title>
 
-	<appendix id="release_notes">
-	<title>Appendix</title>
+          <para>Fixed point-in-polygon shortcut bug in Within().</para>
+          <para>Fixed PostgreSQL 8.2 NULL handling for indexes.</para>
+          <para>Updated RPM spec files.</para>
+          <para>Added short-circuit for Transform() in no-op case.</para>
+          <para>JDBC: Fixed JTS handling for multi-dimensional geometries (thanks to Thomas Marti for hint and partial patch).  Additionally, now JavaDoc is compiled and packaged. Fixed classpath problems with GCJ. Fixed pgjdbc 8.2 compatibility, losing support for jdk 1.3 and older.</para>
+        </sect3>
+      </sect2>
 
-	<sect1>
+      <sect2>
+        <title>Release 1.2.0</title>
 
-		<title>Release Notes</title>
+        <para>Release date: 2006/12/08</para>
 
-                <sect2>
-                        <title>Release 1.1.6</title>
-                        <para>Release date: 2006/11/02</para>
-                        <para>This is a bugfix release, in particular fixing
-			    a critical error with GEOS interface in 64bit
-			    systems. Includes an updated of the SRS parameters
-			    and an improvement in reprojections (take Z in 
-			    consideration).
-                            Upgrade is <emphasis>encouraged</emphasis>.
-			</para>
-                        
-			<sect3>
-				<title>Upgrading</title>
+        <para>This release provides type definitions along with
+        serialization/deserialization capabilities for SQL-MM defined curved
+        geometries, as well as performance enhancements.</para>
 
-				<para>
-If you are upgrading from release 1.0.3 or later follow the
-<link linkend="soft_upgrade">soft upgrade</link> procedure.
-				</para>
+        <sect3>
+          <title>Changes</title>
 
-				<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>Added curved geometry type support for
+          serialization/deserialization</para>
 
-				<para>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<link linkend="hard_upgrade">hard upgrade</link>.
-				</para>
-			</sect3>
+          <para>Added point-in-polygon shortcircuit to the Contains and Within
+          functions to improve performance for these cases.</para>
+        </sect3>
+      </sect2>
 
-			<sect3>
-			    <title>Bug fixes</title>
-	<para>
-	fixed CAPI change that broke 64-bit platforms
-	</para>
-        <para>
-	loader/dumper: fixed regression tests and usage output
-	</para>
-        <para>
-	Fixed setSRID() bug in JDBC, thanks to Thomas Marti
-        </para>
-			</sect3>
-			<sect3>
-			    <title>Other changes</title>
-	<para>
-	use Z ordinate in reprojections
-	</para>
-	<para>
-	spatial_ref_sys.sql updated to EPSG 6.11.1 
-	</para>
-        <para>
-	Simplified Version.config infrastructure to use a single
-          pack of version variables for everything.
-	</para>
-        <para>
-	Include the Version.config in loader/dumper USAGE messages
-	</para>
-        <para>
-        Replace hand-made, fragile JDBC version parser with Properties
-	</para>
-                        </sect3>
-                </sect2>
+      <sect2>
+        <title>Release 1.1.6</title>
 
-                <sect2>
-                        <title>Release 1.1.5</title>
-                        <para>Release date: 2006/10/13</para>
-                        <para>This is an bugfix release, including a critical 
-                            segfault on win32. Upgrade is <emphasis>encouraged</emphasis>.
-			</para>
-                        
-			<sect3>
-				<title>Upgrading</title>
+        <para>Release date: 2006/11/02</para>
 
-				<para>
-If you are upgrading from release 1.0.3 or later follow the
-<link linkend="soft_upgrade">soft upgrade</link> procedure.
-				</para>
+        <para>This is a bugfix release, in particular fixing a critical error
+        with GEOS interface in 64bit systems. Includes an updated of the SRS
+        parameters and an improvement in reprojections (take Z in
+        consideration). Upgrade is <emphasis>encouraged</emphasis>.</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>
+        <sect3>
+          <title>Upgrading</title>
 
-				<para>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<link linkend="hard_upgrade">hard upgrade</link>.
-				</para>
-			</sect3>
+          <para>If you are upgrading from release 1.0.3 or later follow the
+          <link linkend="soft_upgrade">soft upgrade</link> procedure.</para>
 
-			<sect3>
-			    <title>Bug fixes</title>
-		            <para>Fixed MingW link error that was causing pgsql2shp to
-	                        segfault on Win32 when compiled for PostgreSQL 8.2</para>
-                            <para>fixed nullpointer Exception in Geometry.equals() method 
-                                in Java</para>
-                            <para>Added EJB3Spatial.odt to fulfill the GPL requirement of
-                                distributing the "preferred form of modification"</para>
-                            <para>Removed obsolete synchronization from JDBC Jts code.</para>
-                            <para>Updated heavily outdated README files for shp2pgsql/pgsql2shp by
-                                merging them with the manpages.</para>
-                            <para>Fixed version tag in jdbc code that still said "1.1.3" in the
-                                "1.1.4" release.</para>
-                        </sect3>
-			<sect3>
-			    <title>New Features</title>
-		            <para>Added -S option for non-multi geometries to shp2pgsql</para>
-                        </sect3>
-                </sect2>
+          <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>
 
-    		<sect2>
-			<title>Release 1.1.4</title>
-			<para>Release date: 2006/09/27</para>
+          <para>Upgrade from any release prior to 1.0.0RC6 requires an <link
+          linkend="hard_upgrade">hard upgrade</link>.</para>
+        </sect3>
 
-			<para>
-This is an bugfix release including some improvements in the Java interface.
-Upgrade is <emphasis>encouraged</emphasis>.
-			</para>
+        <sect3>
+          <title>Bug fixes</title>
 
-			<sect3>
-				<title>Upgrading</title>
+          <para>fixed CAPI change that broke 64-bit platforms</para>
 
-				<para>
-If you are upgrading from release 1.0.3 or later follow the
-<link linkend="soft_upgrade">soft upgrade</link> procedure.
-				</para>
+          <para>loader/dumper: fixed regression tests and usage output</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>Fixed setSRID() bug in JDBC, thanks to Thomas Marti</para>
+        </sect3>
 
-				<para>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<link linkend="hard_upgrade">hard upgrade</link>.
-				</para>
-			</sect3>
+        <sect3>
+          <title>Other changes</title>
 
+          <para>use Z ordinate in reprojections</para>
 
-			<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>
+          <para>spatial_ref_sys.sql updated to EPSG 6.11.1</para>
 
-			<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>
+          <para>Simplified Version.config infrastructure to use a single pack
+          of version variables for everything.</para>
 
-		</sect2>
-    		<sect2>
-			<title>Release 1.1.3</title>
-			<para>Release date: 2006/06/30</para>
+          <para>Include the Version.config in loader/dumper USAGE messages</para>
 
-			<para>
-This is an bugfix release including also some new functionalities (most notably long transaction support) and portability enhancements.
-Upgrade is <emphasis>encouraged</emphasis>.
-			</para>
+          <para>Replace hand-made, fragile JDBC version parser with Properties</para>
+        </sect3>
+      </sect2>
 
-			<sect3>
-				<title>Upgrading</title>
+      <sect2>
+        <title>Release 1.1.5</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>Release date: 2006/10/13</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>This is an bugfix release, including a critical segfault on
+        win32. Upgrade is <emphasis>encouraged</emphasis>.</para>
 
-				<para>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<link linkend="hard_upgrade">hard upgrade</link>.
-				</para>
-			</sect3>
+        <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>
 
-			<sect3>
-				<title>Bug fixes / correctness</title>
-<para> BUGFIX in distance(poly,poly) giving wrong results. </para>
-<para> BUGFIX in pgsql2shp successful return code. </para>
-<para> BUGFIX in shp2pgsql handling of MultiLine WKT. </para>
-<para> BUGFIX in affine() failing to update bounding box. </para>
-<para> WKT parser: forbidden construction of multigeometries with 
-	  EMPTY elements (still supported for GEOMETRYCOLLECTION). </para>
-			</sect3>
+          <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>
 
-			<sect3>
-				<title>New functionalities</title>
-<para> NEW Long Transactions support. </para>
-<para> NEW DumpRings() function. </para>
-<para> NEW AsHEXEWKB(geom, XDR|NDR) function. </para>
-			</sect3>
+          <para>Upgrade from any release prior to 1.0.0RC6 requires an <link
+          linkend="hard_upgrade">hard upgrade</link>.</para>
+        </sect3>
 
-			<sect3>
-				<title>JDBC changes</title>
-<para> Improved regression tests: MultiPoint and scientific ordinates </para>
-<para> Fixed some minor bugs in jdbc code </para>
-<para>
-Added proper accessor functions for all fields in preparation of 
-making those fields private later
-</para>
-			</sect3>
+        <sect3>
+          <title>Bug fixes</title>
 
-			<sect3>
-				<title>Other changes</title>
-<para> NEW regress test support for loader/dumper. </para>
-<para> Added --with-proj-libdir and --with-geos-libdir configure switches. </para>
-<para> Support for build Tru64 build. </para>
-<para> Use Jade for generating documentation. </para>
-<para> Don't link pgsql2shp to more libs then required. </para>
-<para> Initial support for PostgreSQL 8.2. </para>
-			</sect3>
+          <para>Fixed MingW link error that was causing pgsql2shp to segfault
+          on Win32 when compiled for PostgreSQL 8.2</para>
 
-		</sect2>
+          <para>fixed nullpointer Exception in Geometry.equals() method in
+          Java</para>
 
-    		<sect2>
-			<title>Release 1.1.2</title>
-			<para>Release date: 2006/03/30</para>
+          <para>Added EJB3Spatial.odt to fulfill the GPL requirement of
+          distributing the &#34;preferred form of modification&#34;</para>
 
-			<para>
-This is an bugfix release including some new functions and portability enhancements.
-Upgrade is <emphasis>encouraged</emphasis>.
-			</para>
+          <para>Removed obsolete synchronization from JDBC Jts code.</para>
 
-			<sect3>
-				<title>Upgrading</title>
+          <para>Updated heavily outdated README files for shp2pgsql/pgsql2shp
+          by merging them with the manpages.</para>
 
-				<para>
-If you are upgrading from release 1.0.3 or later follow the
-<link linkend="soft_upgrade">soft upgrade</link> procedure.
-				</para>
+          <para>Fixed version tag in jdbc code that still said &#34;1.1.3&#34;
+          in the &#34;1.1.4&#34; release.</para>
+        </sect3>
 
-				<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>
+        <sect3>
+          <title>New Features</title>
 
-				<para>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<link linkend="hard_upgrade">hard upgrade</link>.
-				</para>
-			</sect3>
+          <para>Added -S option for non-multi geometries to shp2pgsql</para>
+        </sect3>
+      </sect2>
 
-			<sect3>
-				<title>Bug fixes</title>
-<para>BUGFIX in SnapToGrid() computation of output bounding box</para>
-<para>BUGFIX in EnforceRHR() </para>
-<para>jdbc2 SRID handling fixes in JTS code</para>
-<para>Fixed support for 64bit archs</para>
-			</sect3>
+      <sect2>
+        <title>Release 1.1.4</title>
 
-			<sect3>
-				<title>New functionalities</title>
-<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>
-<para>Embedded access control in estimated_extent() for builds against pgsql >= 8.0.0</para>
-			</sect3>
+        <para>Release date: 2006/09/27</para>
 
-			<sect3>
-				<title>Other changes</title>
-<para>More portable ./configure script</para>
-<para>Changed ./run_test script to have more sane default behaviour</para>
-			</sect3>
+        <para>This is an bugfix release including some improvements in the
+        Java interface. Upgrade is <emphasis>encouraged</emphasis>.</para>
 
-		</sect2>
+        <sect3>
+          <title>Upgrading</title>
 
-    		<sect2>
-			<title>Release 1.1.1</title>
-			<para>Release date: 2006/01/23</para>
+          <para>If you are upgrading from release 1.0.3 or later follow the
+          <link linkend="soft_upgrade">soft upgrade</link> procedure.</para>
 
-			<para>
-This is an important Bugfix release, upgrade is <emphasis>highly
-recommended</emphasis>.
-Previous version contained a bug in postgis_restore.pl preventing
-<link linkend="hard_upgrade">hard upgrade</link> procedure to complete
-and a bug in GEOS-2.2+ connector preventing GeometryCollection objects
-to be used in topological operations.
-			</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>
 
-			<sect3>
-				<title>Upgrading</title>
+          <para>Upgrade from any release prior to 1.0.0RC6 requires an <link
+          linkend="hard_upgrade">hard upgrade</link>.</para>
+        </sect3>
 
-				<para>
-If you are upgrading from release 1.0.3 or later follow the
-<link linkend="soft_upgrade">soft upgrade</link> procedure.
-				</para>
+        <sect3>
+          <title>Bug fixes</title>
 
-				<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>Fixed support for PostgreSQL 8.2</para>
 
-				<para>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<link linkend="hard_upgrade">hard upgrade</link>.
-				</para>
-			</sect3>
+          <para>Fixed bug in collect() function discarding SRID of input</para>
 
-			<sect3>
-				<title>Bug fixes</title>
-<para>Fixed a premature exit in postgis_restore.pl </para>
-<para>BUGFIX in geometrycollection handling of GEOS-CAPI connector</para>
-<para>Solaris 2.7 and MingW support improvements</para>
-<para>BUGFIX in line_locate_point()</para>
-<para>Fixed handling of postgresql paths</para>
-<para>BUGFIX in line_substring()</para>
-<para>Added support for localized cluster in regress tester</para>
-			</sect3>
+          <para>Added SRID match check in MakeBox2d and MakeBox3d</para>
 
-			<sect3>
-				<title>New functionalities</title>
-<para>New Z and M interpolation in line_substring()</para>
-<para>New Z and M interpolation in line_interpolate_point()</para>
-<para>added NumInteriorRing() alias due to OpenGIS ambiguity</para>
-			</sect3>
+          <para>Fixed regress tests to pass with GEOS-3.0.0</para>
 
-		</sect2>
-    		<sect2>
-			<title>Release 1.1.0</title>
-			<para>Release date: 2005/12/21</para>
+          <para>Improved pgsql2shp run concurrency.</para>
+        </sect3>
 
-			<para>
-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.
-			</para>
+        <sect3>
+          <title>Java changes</title>
 
-			<para>
-It is <emphasis>highly recommended</emphasis> 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.
-			</para>
+          <para>reworked JTS support to reflect new upstream JTS
+          developers&#39; attitude to SRID handling. Simplifies code and drops
+          build depend on GNU trove.</para>
 
-			<sect3>
-				<title>Credits</title>
+          <para>Added EJB2 support generously donated by the &#34;Geodetix
+          s.r.l. Company&#34; http://www.geodetix.it/</para>
 
-				<para>
-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 <link linkend="credits">credits</link> section for more names.
-				</para>
-			</sect3>
+          <para>Added EJB3 tutorial / examples donated by Norman Barker
+          &#60;nbarker at ittvis.com&#62;</para>
 
-			<sect3>
-				<title>Upgrading</title>
+          <para>Reorganized java directory layout a little.</para>
+        </sect3>
+      </sect2>
 
-				<para>
-If you are upgrading from release 1.0.3 or later you <emphasis>DO
-NOT</emphasis> need a dump/reload.
-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 information.
-				</para>
+      <sect2>
+        <title>Release 1.1.3</title>
 
-				<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>Release date: 2006/06/30</para>
 
-				<para>
-Upgrade from any release prior to 1.0.0RC6 requires an
-<link linkend="hard_upgrade">hard upgrade</link>.
-				</para>
-			</sect3>
+        <para>This is an bugfix release including also some new
+        functionalities (most notably long transaction support) and
+        portability enhancements. Upgrade is <emphasis>encouraged</emphasis>.</para>
 
-			<sect3>
-				<title>New functions</title>
-<para>scale() and transscale() companion methods to translate()</para>
-<para>line_substring() </para>
-<para>line_locate_point()</para>
-<para>M(point) </para>
-<para>LineMerge(geometry) </para>
-<para>shift_longitude(geometry) </para>
-<para>azimuth(geometry) </para>
-<para>locate_along_measure(geometry, float8) </para>
-<para>locate_between_measures(geometry, float8, float8) </para>
-<para>SnapToGrid by point offset (up to 4d support)</para>
-<para>BuildArea(any_geometry) </para>
-<para>OGC BdPolyFromText(linestring_wkt, srid) </para>
-<para>OGC BdMPolyFromText(linestring_wkt, srid)</para>
-<para>RemovePoint(linestring, offset)</para>
-<para>ReplacePoint(linestring, offset, point)</para>
-			</sect3>
+        <sect3>
+          <title>Upgrading</title>
 
-			<sect3>
-				<title>Bug fixes</title>
-<para>Fixed memory leak in polygonize()</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.
-</para>
-			</sect3>
+          <para>If you are upgrading from release 1.0.3 or later follow the
+          <link linkend="soft_upgrade">soft upgrade</link> procedure.</para>
 
-			<sect3>
-				<title>Function semantic changes</title>
-<para>SnapToGrid doesn't discard higher dimensions</para>
-<para>Changed Z() function to return NULL if requested dimension is not available</para>
-			</sect3>
+          <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>
 
-			<sect3>
-				<title>Performance improvements</title>
-<para>
-Much faster transform() function, caching proj4 objects
-</para>
-<para>
-Removed automatic call to fix_geometry_columns() in
-AddGeometryColumns() and update_geometry_stats()
-</para>
-			</sect3>
+          <para>Upgrade from any release prior to 1.0.0RC6 requires an <link
+          linkend="hard_upgrade">hard upgrade</link>.</para>
+        </sect3>
 
-			<sect3>
-				<title>JDBC2 works</title>
-<para>Makefile improvements</para>
-<para>JTS support improvements</para>
-<para>Improved regression test system</para>
-<para>Basic consistency check method for geometry collections</para>
-<para>Support for (Hex)(E)wkb</para>
-<para>Autoprobing DriverWrapper for HexWKB / EWKT switching</para>
-<para>fix compile problems in ValueSetter for ancient jdk releases.</para>
-<para>fix EWKT constructors to accept SRID=4711; representation</para>
-<para>added preliminary read-only support for java2d geometries</para>
-			</sect3>
+        <sect3>
+          <title>Bug fixes / correctness</title>
 
-			<sect3>
-				<title>Other new things</title>
-<para>
-Full autoconf-based configuration, with PostgreSQL source dependency relief
-</para>
-<para>GEOS C-API support (2.2.0 and higher)</para>
-<para>Initial support for topology modelling</para>
-<para>Debian and RPM specfiles</para>
-<para>New lwpostgis_upgrade.sql script</para>
-			</sect3>
+          <para>BUGFIX in distance(poly,poly) giving wrong results.</para>
 
-			<sect3>
-				<title>Other changes</title>
-<para>JTS support improvements</para>
-<para>Stricter mapping between DBF and SQL integer and string attributes</para>
-<para>Wider and cleaner regression test suite</para>
-<para>old jdbc code removed from release</para>
-<para>obsoleted direct use of postgis_proc_upgrade.pl</para>
-<para>scripts version unified with release version</para>
-			</sect3>
+          <para>BUGFIX in pgsql2shp successful return code.</para>
 
+          <para>BUGFIX in shp2pgsql handling of MultiLine WKT.</para>
 
-		</sect2>
-    		<sect2>
-			<title>Release 1.0.6</title>
-			<para>Release date: 2005/12/06</para>
+          <para>BUGFIX in affine() failing to update bounding box.</para>
 
-			<para>
-Contains a few bug fixes and improvements.
-			</para>
+          <para>WKT parser: forbidden construction of multigeometries with
+          EMPTY elements (still supported for GEOMETRYCOLLECTION).</para>
+        </sect3>
 
-			<sect3>
-				<title>Upgrading</title>
+        <sect3>
+          <title>New functionalities</title>
 
-				<para>If you are upgrading from
-				release 1.0.3 or later you <emphasis>DO
-				NOT</emphasis> need a dump/reload.
-				</para>
+          <para>NEW Long Transactions support.</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>NEW DumpRings() function.</para>
 
-				<para>
-				Upgrade from any release prior to 1.0.0RC6
-				requires an <link linkend="hard_upgrade">hard
-				upgrade</link>.
-				</para>
-			</sect3>
+          <para>NEW AsHEXEWKB(geom, XDR|NDR) function.</para>
+        </sect3>
 
-			<sect3>
-				<title>Bug fixes</title>
-	<para>Fixed palloc(0) call in collection deserializer (only gives problem with --enable-cassert)</para>
-	<para>Fixed bbox cache handling bugs</para>
-	<para>Fixed geom_accum(NULL, NULL) segfault</para>
-	<para>Fixed segfault in addPoint()</para>
-	<para>Fixed short-allocation in lwcollection_clone()</para>
-	<para>Fixed bug in segmentize()</para>
-	<para>Fixed bbox computation of SnapToGrid output</para>
-			</sect3>
+        <sect3>
+          <title>JDBC changes</title>
 
-			<sect3>
-				<title>Improvements</title>
-	<para>Initial support for postgresql 8.2</para>
-	<para>Added missing SRID mismatch checks in GEOS ops</para>
+          <para>Improved regression tests: MultiPoint and scientific ordinates</para>
 
-			</sect3>
+          <para>Fixed some minor bugs in jdbc code</para>
 
+          <para>Added proper accessor functions for all fields in preparation
+          of making those fields private later</para>
+        </sect3>
 
-		</sect2>
+        <sect3>
+          <title>Other changes</title>
 
-    		<sect2>
-			<title>Release 1.0.5</title>
-			<para>Release date: 2005/11/25</para>
+          <para>NEW regress test support for loader/dumper.</para>
 
-			<para>
-Contains memory-alignment fixes in the library, a segfault fix in loader's
-handling of UTF8 attributes and a few improvements and cleanups.
-			</para>
+          <para>Added --with-proj-libdir and --with-geos-libdir configure
+          switches.</para>
 
-			<note><para>
-Return code of shp2pgsql changed from previous releases to conform to unix
-standards (return 0 on success).
-			</para></note>
+          <para>Support for build Tru64 build.</para>
 
-			<sect3>
-				<title>Upgrading</title>
+          <para>Use Jade for generating documentation.</para>
 
-				<para>If you are upgrading from
-				release 1.0.3 or later you <emphasis>DO
-				NOT</emphasis> need a dump/reload.
-				</para>
+          <para>Don&#39;t link pgsql2shp to more libs then required.</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>Initial support for PostgreSQL 8.2.</para>
+        </sect3>
+      </sect2>
 
-				<para>
-				Upgrade from any release prior to 1.0.0RC6
-				requires an <link linkend="hard_upgrade">hard
-				upgrade</link>.
-				</para>
-			</sect3>
+      <sect2>
+        <title>Release 1.1.2</title>
 
-			<sect3>
-				<title>Library changes</title>
-	<para>Fixed memory alignment problems</para>
-	<para>Fixed computation of null values fraction in analyzer</para>
-	<para>Fixed a small bug in the getPoint4d_p() low-level function</para>
-	<para>Speedup of serializer functions</para>
-	<para>Fixed a bug in force_3dm(), force_3dz() and force_4d()</para>
-			</sect3>
+        <para>Release date: 2006/03/30</para>
 
-			<sect3>
-				<title>Loader changes</title>
-	<para>Fixed return code of shp2pgsql</para>
-	<para>Fixed back-compatibility issue in loader (load of null shapefiles)</para>
-	<para>Fixed handling of trailing dots in dbf numerical attributes</para>
-	<para>Segfault fix in shp2pgsql (utf8 encoding)</para>
-			</sect3>
+        <para>This is an bugfix release including some new functions and
+        portability enhancements. Upgrade is <emphasis>encouraged</emphasis>.</para>
 
-			<sect3>
-				<title>Other changes</title>
-	<para>Schema aware postgis_proc_upgrade.pl, support for pgsql 7.2+</para>
-	<para>New "Reporting Bugs" chapter in manual</para>
-			</sect3>
+        <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>
 
-		</sect2>
+          <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>
 
-    		<sect2>
-			<title>Release 1.0.4</title>
-			<para>Release date: 2005/09/09</para>
+          <para>Upgrade from any release prior to 1.0.0RC6 requires an <link
+          linkend="hard_upgrade">hard upgrade</link>.</para>
+        </sect3>
 
-			<para>
-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.
-			</para>
+        <sect3>
+          <title>Bug fixes</title>
 
-			<sect3>
-				<title>Upgrading</title>
+          <para>BUGFIX in SnapToGrid() computation of output bounding box</para>
 
-				<para>If you are upgrading from
-				release 1.0.3 you <emphasis>DO
-				NOT</emphasis> need a dump/reload.
-				</para>
+          <para>BUGFIX in EnforceRHR()</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>jdbc2 SRID handling fixes in JTS code</para>
 
-				<para>
-				Upgrade from any release prior to 1.0.0RC6
-				requires an <link linkend="hard_upgrade">hard
-				upgrade</link>.
-				</para>
-			</sect3>
+          <para>Fixed support for 64bit archs</para>
+        </sect3>
 
-			<sect3>
-				<title>Bug fixes</title>
-	<para>Memory leak plugged in GiST indexing</para>
-	<para>Segfault fix in transform() handling of proj4 errors</para>
-	<para>Fixed some proj4 texts in spatial_ref_sys (missing +proj)</para>
-	<para>Loader: fixed string functions usage, reworked NULL objects check, fixed segfault on MULTILINESTRING input.</para>
-	<para>Fixed bug in MakeLine dimension handling</para>
-	<para>Fixed bug in translate() corrupting output bounding box</para>
-			</sect3>
+        <sect3>
+          <title>New functionalities</title>
 
-			<sect3>
-				<title>Improvements</title>
-	<para>Documentation improvements</para>
-	<para>More robust selectivity estimator </para>
-	<para>Minor speedup in distance()</para>
-	<para>Minor cleanups </para>
-	<para>GiST indexing cleanup</para>
-	<para>Looser syntax acceptance in box3d parser</para>
-			</sect3>
+          <para>Regress tests can now be run *before* postgis installation</para>
 
-		</sect2>
+          <para>New affine() matrix transformation functions</para>
 
-    		<sect2 id="rel_1.0.3_upgrading">
-			<title>Release 1.0.3</title>
-			<para>Release date: 2005/08/08</para>
+          <para>New rotate{,X,Y,Z}() function</para>
 
-			<para>
-Contains some bug fixes - <emphasis>including a severe one affecting
-correctness of stored geometries</emphasis> - and a few improvements.
-			</para>
+          <para>Old translating and scaling functions now use affine()
+          internally</para>
 
-			<sect3>
-				<title>Upgrading</title>
+          <para>Embedded access control in estimated_extent() for builds
+          against pgsql &#62;= 8.0.0</para>
+        </sect3>
 
-				<para>
-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.
-				</para>
+        <sect3>
+          <title>Other changes</title>
 
-				<para>
-An <link linkend="hard_upgrade">hard upgrade</link> procedure (dump/reload)
-will force recomputation of all bounding boxes (not included in dumps).
-This is <emphasis>required</emphasis> if upgrading from releases prior
-to 1.0.0RC6.
-				</para>
+          <para>More portable ./configure script</para>
 
-				<para>
-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 <link linkend="soft_upgrade">Soft upgrade</link>).
-				</para>
+          <para>Changed ./run_test script to have more sane default behaviour</para>
+        </sect3>
+      </sect2>
 
+      <sect2>
+        <title>Release 1.1.1</title>
 
-			</sect3>
+        <para>Release date: 2006/01/23</para>
 
-			<sect3>
-				<title>Bug fixes</title>
-	<para>Severe bugfix in lwgeom's 2d bounding box computation</para>
-	<para>Bugfix in WKT (-w) POINT handling in loader</para>
-	<para>Bugfix in dumper on 64bit machines</para>
-	<para>Bugfix in dumper handling of user-defined queries </para>
-	<para>Bugfix in create_undef.pl script</para>
-			</sect3>
+        <para>This is an important Bugfix release, upgrade is
+        <emphasis>highly recommended</emphasis>. Previous version contained a
+        bug in postgis_restore.pl preventing <link linkend="hard_upgrade">hard
+        upgrade</link> procedure to complete and a bug in GEOS-2.2+ connector
+        preventing GeometryCollection objects to be used in topological
+        operations.</para>
 
-			<sect3>
-				<title>Improvements</title>
-	<para>Small performance improvement in canonical input function</para>
-	<para>Minor cleanups in loader</para>
-	<para>Support for multibyte field names in loader</para>
-	<para>Improvement in the postgis_restore.pl script</para>
-	<para>New rebuild_bbox_caches.pl util script</para>
-			</sect3>
+        <sect3>
+          <title>Upgrading</title>
 
-		</sect2>
+          <para>If you are upgrading from release 1.0.3 or later follow the
+          <link linkend="soft_upgrade">soft upgrade</link> procedure.</para>
 
-    		<sect2>
-			<title>Release 1.0.2</title>
-			<para>Release date: 2005/07/04</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>
-			Contains a few bug fixes and improvements.
-			</para>
+          <para>Upgrade from any release prior to 1.0.0RC6 requires an <link
+          linkend="hard_upgrade">hard upgrade</link>.</para>
+        </sect3>
 
-			<sect3>
-				<title>Upgrading</title>
+        <sect3>
+          <title>Bug fixes</title>
 
-				<para>If you are upgrading from
-				release 1.0.0RC6 or up you <emphasis>DO
-				NOT</emphasis> need a dump/reload.</para>
+          <para>Fixed a premature exit in postgis_restore.pl</para>
 
-				<para>Upgrading from older releases
-				requires a dump/reload. 
-				See the <link
-				linkend="upgrading">upgrading</link>
-				chapter for more informations.</para>
-			</sect3>
+          <para>BUGFIX in geometrycollection handling of GEOS-CAPI connector</para>
 
-			<sect3>
-				<title>Bug fixes</title>
-	<para>Fault tolerant btree ops</para>
-	<para>Memory leak plugged in pg_error</para>
-	<para>Rtree index fix</para>
-	<para>Cleaner build scripts (avoided mix of CFLAGS and CXXFLAGS)</para>
-			</sect3>
+          <para>Solaris 2.7 and MingW support improvements</para>
 
-			<sect3>
-				<title>Improvements</title>
-	<para>New index creation capabilities in loader (-I switch)</para>
-	<para>Initial support for postgresql 8.1dev</para>
-			</sect3>
+          <para>BUGFIX in line_locate_point()</para>
 
-		</sect2>
+          <para>Fixed handling of postgresql paths</para>
 
-    		<sect2>
-			<title>Release 1.0.1</title>
-			<para>Release date: 2005/05/24</para>
+          <para>BUGFIX in line_substring()</para>
 
-			<para>
-			Contains a few bug fixes and some improvements.
-			</para>
+          <para>Added support for localized cluster in regress tester</para>
+        </sect3>
 
-			<sect3>
-				<title>Upgrading</title>
+        <sect3>
+          <title>New functionalities</title>
 
-				<para>If you are upgrading from
-				release 1.0.0RC6 or up you <emphasis>DO
-				NOT</emphasis> need a dump/reload.</para>
+          <para>New Z and M interpolation in line_substring()</para>
 
-				<para>Upgrading from older releases
-				requires a dump/reload. 
-				See the <link
-				linkend="upgrading">upgrading</link>
-				chapter for more informations.</para>
-			</sect3>
+          <para>New Z and M interpolation in line_interpolate_point()</para>
 
-			<sect3>
-				<title>Library changes</title>
-	<para>BUGFIX in 3d computation of length_spheroid()</para>
-	<para>BUGFIX in join selectivity estimator</para>
-			</sect3>
+          <para>added NumInteriorRing() alias due to OpenGIS ambiguity</para>
+        </sect3>
+      </sect2>
 
-			<sect3>
-				<title>Other changes/additions</title>
-	<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>
-	<para>NEW -k switch for pgsql2shp</para>
-	<para>NEW support for custom createdb options in postgis_restore.pl</para>
-	<para>BUGFIX in pgsql2shp attribute names unicity enforcement</para>
-	<para>BUGFIX in Paris projections definitions</para>
-	<para>postgis_restore.pl cleanups</para>
-			</sect3>
+      <sect2>
+        <title>Release 1.1.0</title>
 
-		</sect2>
+        <para>Release date: 2005/12/21</para>
 
-    		<sect2>
-			<title>Release 1.0.0</title>
-			<para>Release date: 2005/04/19</para>
+        <para>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.</para>
 
-			<para>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.
-			</para>
+        <para>It is <emphasis>highly recommended</emphasis> that you upgrade
+        to GEOS-2.2.x before installing PostGIS, this will ensure future GEOS
+        upgrades won&#39;t require a rebuild of the PostGIS library.</para>
 
-			<sect3>
-				<title>Upgrading</title>
+        <sect3>
+          <title>Credits</title>
 
-				<para>If you are upgrading from
-				release 1.0.0RC6 you <emphasis>DO
-				NOT</emphasis> need a dump/reload.</para>
+          <para>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 <link
+          linkend="credits">credits</link> section for more names.</para>
+        </sect3>
 
-				<para>Upgrading from any other precedent
-				release requires a dump/reload. 
-				See the <link
-				linkend="upgrading">upgrading</link>
-				chapter for more informations.</para>
-			</sect3>
+        <sect3>
+          <title>Upgrading</title>
 
-			<sect3>
-				<title>Library changes</title>
-	<para>BUGFIX in transform() releasing random memory address</para>
-	<para>BUGFIX in force_3dm() allocating less memory then required</para>
-	<para>BUGFIX in join selectivity estimator (defaults, leaks, tuplecount, sd)</para>
-			</sect3>
+          <para>If you are upgrading from release 1.0.3 or later you
+          <emphasis>DO NOT</emphasis> need a dump/reload. 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 information.</para>
 
-			<sect3>
-				<title>Other changes/additions</title>
-	<para>BUGFIX in shp2pgsql escape of values starting with tab or single-quote</para>
-	<para>NEW manual pages for loader/dumper</para>
-	<para>NEW shp2pgsql support for old (HWGEOM) postgis versions</para>
-	<para>NEW -p (prepare) flag for shp2pgsql</para>
-	<para>NEW manual chapter about OGC compliancy enforcement</para>
-	<para>NEW autoconf support for JTS lib</para>
-	<para>BUGFIX in estimator testers (support for LWGEOM and schema parsing)</para>
-			</sect3>
+          <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>
 
-		</sect2>
+          <para>Upgrade from any release prior to 1.0.0RC6 requires an <link
+          linkend="hard_upgrade">hard upgrade</link>.</para>
+        </sect3>
 
+        <sect3>
+          <title>New functions</title>
 
-    		<sect2>
-			<title>Release 1.0.0RC6</title>
-			<para>Release date: 2005/03/30</para>
+          <para>scale() and transscale() companion methods to translate()</para>
 
-			<para>Sixth release candidate for 1.0.0.
-			Contains a few bug fixes and cleanups.</para>
+          <para>line_substring()</para>
 
-			<sect3>
-				<title>Upgrading</title>
-				<para>You need a dump/reload to upgrade
-				from precedent releases. See the <link
-				linkend="upgrading">upgrading</link>
-				chapter for more informations.</para>
-			</sect3>
+          <para>line_locate_point()</para>
 
-			<sect3>
-				<title>Library changes</title>
-	<para>BUGFIX in multi()</para>
-	<para>early return [when noop] from multi()</para>
-			</sect3>
+          <para>M(point)</para>
 
-			<sect3>
-				<title>Scripts changes</title>
-	<para>dropped {x,y}{min,max}(box2d) functions</para>
-			</sect3>
+          <para>LineMerge(geometry)</para>
 
-			<sect3>
-				<title>Other changes</title>
-	<para>BUGFIX in postgis_restore.pl scrip</para>
-	<para>BUGFIX in dumper's 64bit support</para>
-			</sect3>
+          <para>shift_longitude(geometry)</para>
 
-		</sect2>
+          <para>azimuth(geometry)</para>
 
+          <para>locate_along_measure(geometry, float8)</para>
 
-    		<sect2>
-			<title>Release 1.0.0RC5</title>
-			<para>Release date: 2005/03/25</para>
+          <para>locate_between_measures(geometry, float8, float8)</para>
 
-			<para>Fifth release candidate for 1.0.0.
-			Contains a few bug fixes and a improvements.</para>
+          <para>SnapToGrid by point offset (up to 4d support)</para>
 
-			<sect3>
-				<title>Upgrading</title>
+          <para>BuildArea(any_geometry)</para>
 
-				<para>If you are upgrading from
-				release 1.0.0RC4 you <emphasis>DO
-				NOT</emphasis> need a dump/reload.</para>
+          <para>OGC BdPolyFromText(linestring_wkt, srid)</para>
 
-				<para>Upgrading from any other precedent
-				release requires a dump/reload. 
-				See the <link
-				linkend="upgrading">upgrading</link>
-				chapter for more informations.</para>
-			</sect3>
+          <para>OGC BdMPolyFromText(linestring_wkt, srid)</para>
 
-			<sect3>
-				<title>Library changes</title>
-	<para>BUGFIX (segfaulting) in box3d computation (yes, another!).</para>
-	<para>BUGFIX (segfaulting) in estimated_extent().</para>
-			</sect3>
+          <para>RemovePoint(linestring, offset)</para>
 
-			<sect3>
-				<title>Other changes</title>
-	<para>Small build scripts and utilities refinements.</para>
-        <para>Additional performance tips documented.</para>
-			</sect3>
+          <para>ReplacePoint(linestring, offset, point)</para>
+        </sect3>
 
-		</sect2>
+        <sect3>
+          <title>Bug fixes</title>
 
-    		<sect2>
-			<title>Release 1.0.0RC4</title>
-			<para>Release date: 2005/03/18</para>
+          <para>Fixed memory leak in polygonize()</para>
 
-			<para>Fourth release candidate for 1.0.0.
-			Contains bug fixes and a few improvements.</para>
+          <para>Fixed bug in lwgeom_as_anytype cast functions</para>
 
-			<sect3>
-				<title>Upgrading</title>
-				<para>You need a dump/reload to upgrade
-				from precedent releases. See the <link
-				linkend="upgrading">upgrading</link>
-				chapter for more informations.</para>
-			</sect3>
+          <para>Fixed USE_GEOS, USE_PROJ and USE_STATS elements of
+          postgis_version() output to always reflect library state.</para>
+        </sect3>
 
-			<sect3>
-				<title>Library changes</title>
-<para>BUGFIX (segfaulting) in geom_accum().</para>
-<para>BUGFIX in 64bit architectures support.</para>
-<para>BUGFIX in box3d computation function with collections.</para>
-<para>NEW subselects support in selectivity estimator.</para>
-<para>Early return from force_collection.</para>
-<para>Consistency check fix in SnapToGrid().</para>
-<para>Box2d output changed back to 15 significant digits.</para>
-			</sect3>
+        <sect3>
+          <title>Function semantic changes</title>
 
-			<sect3>
-				<title>Scripts changes</title>
-<para>NEW distance_sphere() function.</para>
-<para>Changed get_proj4_from_srid implementation to use PL/PGSQL instead of SQL.</para>
-			</sect3>
+          <para>SnapToGrid doesn&#39;t discard higher dimensions</para>
 
-			<sect3>
-				<title>Other changes</title>
-<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 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>
-<para>improvements in postgis_restore.pl</para>
-			</sect3>
+          <para>Changed Z() function to return NULL if requested dimension is
+          not available</para>
+        </sect3>
 
-		</sect2>
+        <sect3>
+          <title>Performance improvements</title>
 
-    		<sect2>
-			<title>Release 1.0.0RC3</title>
-			<para>Release date: 2005/02/24</para>
+          <para>Much faster transform() function, caching proj4 objects</para>
 
-			<para>Third release candidate for 1.0.0.
-			Contains many bug fixes and improvements.</para>
+          <para>Removed automatic call to fix_geometry_columns() in
+          AddGeometryColumns() and update_geometry_stats()</para>
+        </sect3>
 
-			<sect3>
-				<title>Upgrading</title>
-				<para>You need a dump/reload to upgrade
-				from precedent releases. See the <link
-				linkend="upgrading">upgrading</link>
-				chapter for more informations.</para>
-			</sect3>
+        <sect3>
+          <title>JDBC2 works</title>
 
-			<sect3>
-				<title>Library changes</title>
-	<para>BUGFIX in transform(): missing SRID, better error handling.</para>
-	<para>BUGFIX in memory alignment handling</para>
-	<para>BUGFIX in force_collection() causing mapserver connector failures on simple (single) geometry types.</para>
-	<para>BUGFIX in GeometryFromText() missing to add a bbox cache.</para>
-	<para>reduced precision of box2d output.</para>
-	<para>prefixed DEBUG macros with PGIS_ to avoid clash with pgsql one</para>
-	<para>plugged a leak in GEOS2POSTGIS converter</para>
-	<para>Reduced memory usage by early releasing query-context palloced one.</para>
-			</sect3>
+          <para>Makefile improvements</para>
 
-			<sect3>
-				<title>Scripts changes</title>
-	<para>BUGFIX in 72 index bindings.</para>
-	<para>BUGFIX in probe_geometry_columns() to work with PG72 and support multiple geometry columns in a single table</para>
-	<para>NEW bool::text cast</para>
-	<para>Some functions made IMMUTABLE from STABLE, for performance
-	improvement.</para>
-			</sect3>
+          <para>JTS support improvements</para>
 
-			<sect3>
-				<title>JDBC changes</title>
-	<para>jdbc2: small patches, box2d/3d tests, revised docs and license.</para>
-	<para>jdbc2: bug fix and testcase in for pgjdbc 8.0 type autoregistration</para>
-	<para>jdbc2: Removed use of jdk1.4 only features to enable build with older jdk releases.</para>
-	<para>jdbc2: Added support for building against pg72jdbc2.jar</para>
-	<para>jdbc2: updated and cleaned makefile</para>
-	<para>jdbc2: added BETA support for jts geometry classes</para>
-	<para>jdbc2: Skip known-to-fail tests against older PostGIS servers.</para>
-	<para>jdbc2: Fixed handling of measured geometries in EWKT.</para>
-			</sect3>
+          <para>Improved regression test system</para>
 
-			<sect3>
-				<title>Other changes</title>
-	<para>new performance tips chapter in manual</para>
-	<para>documentation updates: pgsql72 requirement, lwpostgis.sql</para>
-	<para>few changes in autoconf </para>
-	<para>BUILDDATE extraction made more portable</para>
-	<para>fixed spatial_ref_sys.sql to avoid vacuuming the whole
-	database.</para>
-	<para>spatial_ref_sys: changed Paris entries to match the ones
-	distributed with 0.x.</para>
-			</sect3>
+          <para>Basic consistency check method for geometry collections</para>
 
-		</sect2>
+          <para>Support for (Hex)(E)wkb</para>
 
-    		<sect2>
-			<title>Release 1.0.0RC2</title>
-			<para>Release date: 2005/01/26</para>
+          <para>Autoprobing DriverWrapper for HexWKB / EWKT switching</para>
 
-			<para>Second release candidate for 1.0.0
-			containing bug fixes and a few improvements.</para>
+          <para>fix compile problems in ValueSetter for ancient jdk releases.</para>
 
-			<sect3>
-				<title>Upgrading</title>
-	
-				<para>You need a dump/reload to upgrade
-				from precedent releases. See the <link
-				linkend="upgrading">upgrading</link>
-				chapter for more informations.</para>
-			</sect3>
+          <para>fix EWKT constructors to accept SRID=4711; representation</para>
 
-			<sect3>
-				<title>Library changes</title>
+          <para>added preliminary read-only support for java2d geometries</para>
+        </sect3>
 
-<para>BUGFIX in pointarray box3d computation</para>
-<para>BUGFIX in distance_spheroid definition</para>
-<para>BUGFIX in transform() missing to update bbox cache</para>
-<para>NEW jdbc driver (jdbc2)</para>
-<para>GEOMETRYCOLLECTION(EMPTY) syntax support for backward compatibility</para>
-<para>Faster binary outputs</para>
-<para>Stricter OGC WKB/WKT constructors</para>
+        <sect3>
+          <title>Other new things</title>
 
-			</sect3>
+          <para>Full autoconf-based configuration, with PostgreSQL source
+          dependency relief</para>
 
-			<sect3>
-				<title>Scripts changes</title>
+          <para>GEOS C-API support (2.2.0 and higher)</para>
 
-<para>More correct STABLE, IMMUTABLE, STRICT uses in lwpostgis.sql</para>
-<para>stricter OGC WKB/WKT constructors</para>
+          <para>Initial support for topology modelling</para>
 
-			</sect3>
+          <para>Debian and RPM specfiles</para>
 
-			<sect3>
-				<title>Other changes</title>
+          <para>New lwpostgis_upgrade.sql script</para>
+        </sect3>
 
-<para>Faster and more robust loader (both i18n and not)</para>
-<para>Initial autoconf script</para>
+        <sect3>
+          <title>Other changes</title>
 
-			</sect3>
+          <para>JTS support improvements</para>
 
-		</sect2>
+          <para>Stricter mapping between DBF and SQL integer and string
+          attributes</para>
 
-    		<sect2>
-			<title>Release 1.0.0RC1</title>
-			<para>Release date: 2005/01/13</para>
+          <para>Wider and cleaner regression test suite</para>
 
-			<para>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.</para>
+          <para>old jdbc code removed from release</para>
 
-			<sect3>
-				<title>Upgrading</title>
+          <para>obsoleted direct use of postgis_proc_upgrade.pl</para>
 
-				<para>You need a dump/reload to upgrade
-				from precedent releases. See the <link
-				linkend="upgrading">upgrading</link>
-				chapter for more informations.</para>
-			</sect3>
+          <para>scripts version unified with release version</para>
+        </sect3>
+      </sect2>
 
-			<sect3>
-				<title>Changes</title>
+      <sect2>
+        <title>Release 1.0.6</title>
 
-				<para>
-				Faster canonical input parsing.
-				</para>
+        <para>Release date: 2005/12/06</para>
 
-				<para>
-				Lossless canonical output.
-				</para>
+        <para>Contains a few bug fixes and improvements.</para>
 
-				<para>
-				EWKB Canonical binary IO with PG>73.
-				</para>
+        <sect3>
+          <title>Upgrading</title>
 
-				<para>
-				Support for up to 4d coordinates, providing
-				lossless shapefile->postgis->shapefile
-				conversion.
-				</para>
+          <para>If you are upgrading from release 1.0.3 or later you
+          <emphasis>DO NOT</emphasis> need a dump/reload.</para>
 
-				<para>
-				New function: UpdateGeometrySRID(), AsGML(),
-				SnapToGrid(), ForceRHR(), estimated_extent(),
-				accum().
-				</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>
-				Vertical positioning indexed operators.
-				</para>
+          <para>Upgrade from any release prior to 1.0.0RC6 requires an <link
+          linkend="hard_upgrade">hard upgrade</link>.</para>
+        </sect3>
 
-				<para>
-				JOIN selectivity function.
-				</para>
+        <sect3>
+          <title>Bug fixes</title>
 
-				<para>
-				More geometry constructors / editors.
-				</para>
+          <para>Fixed palloc(0) call in collection deserializer (only gives
+          problem with --enable-cassert)</para>
 
-				<para>
-				Postgis extension API.
-				</para>
+          <para>Fixed bbox cache handling bugs</para>
 
-				<para>
-				UTF8 support in loader.
-				</para>
+          <para>Fixed geom_accum(NULL, NULL) segfault</para>
 
-			</sect3>
-		</sect2>
-	</sect1>
-	</appendix>
+          <para>Fixed segfault in addPoint()</para>
+
+          <para>Fixed short-allocation in lwcollection_clone()</para>
+
+          <para>Fixed bug in segmentize()</para>
+
+          <para>Fixed bbox computation of SnapToGrid output</para>
+        </sect3>
+
+        <sect3>
+          <title>Improvements</title>
+
+          <para>Initial support for postgresql 8.2</para>
+
+          <para>Added missing SRID mismatch checks in GEOS ops</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.5</title>
+
+        <para>Release date: 2005/11/25</para>
+
+        <para>Contains memory-alignment fixes in the library, a segfault fix
+        in loader&#39;s handling of UTF8 attributes and a few improvements and
+        cleanups.</para>
+
+        <note>
+          <para>Return code of shp2pgsql changed from previous releases to
+          conform to unix standards (return 0 on success).</para>
+        </note>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>If you are upgrading from release 1.0.3 or later you
+          <emphasis>DO NOT</emphasis> need a dump/reload.</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>Library changes</title>
+
+          <para>Fixed memory alignment problems</para>
+
+          <para>Fixed computation of null values fraction in analyzer</para>
+
+          <para>Fixed a small bug in the getPoint4d_p() low-level function</para>
+
+          <para>Speedup of serializer functions</para>
+
+          <para>Fixed a bug in force_3dm(), force_3dz() and force_4d()</para>
+        </sect3>
+
+        <sect3>
+          <title>Loader changes</title>
+
+          <para>Fixed return code of shp2pgsql</para>
+
+          <para>Fixed back-compatibility issue in loader (load of null
+          shapefiles)</para>
+
+          <para>Fixed handling of trailing dots in dbf numerical attributes</para>
+
+          <para>Segfault fix in shp2pgsql (utf8 encoding)</para>
+        </sect3>
+
+        <sect3>
+          <title>Other changes</title>
+
+          <para>Schema aware postgis_proc_upgrade.pl, support for pgsql 7.2+</para>
+
+          <para>New &#34;Reporting Bugs&#34; chapter in manual</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.4</title>
+
+        <para>Release date: 2005/09/09</para>
+
+        <para>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.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>If you are upgrading from release 1.0.3 you
+          <emphasis>DO NOT</emphasis> need a dump/reload.</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>Memory leak plugged in GiST indexing</para>
+
+          <para>Segfault fix in transform() handling of proj4 errors</para>
+
+          <para>Fixed some proj4 texts in spatial_ref_sys (missing +proj)</para>
+
+          <para>Loader: fixed string functions usage, reworked NULL objects
+          check, fixed segfault on MULTILINESTRING input.</para>
+
+          <para>Fixed bug in MakeLine dimension handling</para>
+
+          <para>Fixed bug in translate() corrupting output bounding box</para>
+        </sect3>
+
+        <sect3>
+          <title>Improvements</title>
+
+          <para>Documentation improvements</para>
+
+          <para>More robust selectivity estimator</para>
+
+          <para>Minor speedup in distance()</para>
+
+          <para>Minor cleanups</para>
+
+          <para>GiST indexing cleanup</para>
+
+          <para>Looser syntax acceptance in box3d parser</para>
+        </sect3>
+      </sect2>
+
+      <sect2 id="rel_1.0.3_upgrading">
+        <title>Release 1.0.3</title>
+
+        <para>Release date: 2005/08/08</para>
+
+        <para>Contains some bug fixes - <emphasis>including a severe one
+        affecting correctness of stored geometries</emphasis> - and a few
+        improvements.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>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.</para>
+
+          <para>An <link linkend="hard_upgrade">hard upgrade</link> procedure
+          (dump/reload) will force recomputation of all bounding boxes (not
+          included in dumps). This is <emphasis>required</emphasis> if
+          upgrading from releases prior to 1.0.0RC6.</para>
+
+          <para>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&#39; 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 <link linkend="soft_upgrade">Soft upgrade</link>).</para>
+        </sect3>
+
+        <sect3>
+          <title>Bug fixes</title>
+
+          <para>Severe bugfix in lwgeom&#39;s 2d bounding box computation</para>
+
+          <para>Bugfix in WKT (-w) POINT handling in loader</para>
+
+          <para>Bugfix in dumper on 64bit machines</para>
+
+          <para>Bugfix in dumper handling of user-defined queries</para>
+
+          <para>Bugfix in create_undef.pl script</para>
+        </sect3>
+
+        <sect3>
+          <title>Improvements</title>
+
+          <para>Small performance improvement in canonical input function</para>
+
+          <para>Minor cleanups in loader</para>
+
+          <para>Support for multibyte field names in loader</para>
+
+          <para>Improvement in the postgis_restore.pl script</para>
+
+          <para>New rebuild_bbox_caches.pl util script</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.2</title>
+
+        <para>Release date: 2005/07/04</para>
+
+        <para>Contains a few bug fixes and improvements.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>If you are upgrading from release 1.0.0RC6 or up you
+          <emphasis>DO NOT</emphasis> need a dump/reload.</para>
+
+          <para>Upgrading from older releases requires a dump/reload. See the
+          <link linkend="upgrading">upgrading</link> chapter for more
+          informations.</para>
+        </sect3>
+
+        <sect3>
+          <title>Bug fixes</title>
+
+          <para>Fault tolerant btree ops</para>
+
+          <para>Memory leak plugged in pg_error</para>
+
+          <para>Rtree index fix</para>
+
+          <para>Cleaner build scripts (avoided mix of CFLAGS and CXXFLAGS)</para>
+        </sect3>
+
+        <sect3>
+          <title>Improvements</title>
+
+          <para>New index creation capabilities in loader (-I switch)</para>
+
+          <para>Initial support for postgresql 8.1dev</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.1</title>
+
+        <para>Release date: 2005/05/24</para>
+
+        <para>Contains a few bug fixes and some improvements.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>If you are upgrading from release 1.0.0RC6 or up you
+          <emphasis>DO NOT</emphasis> need a dump/reload.</para>
+
+          <para>Upgrading from older releases requires a dump/reload. See the
+          <link linkend="upgrading">upgrading</link> chapter for more
+          informations.</para>
+        </sect3>
+
+        <sect3>
+          <title>Library changes</title>
+
+          <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 shp2pgsql escape functions</para>
+
+          <para>better support for concurrent postgis in multiple schemas</para>
+
+          <para>documentation fixes</para>
+
+          <para>jdbc2: compile with &#34;-target 1.2 -source 1.2&#34; by
+          default</para>
+
+          <para>NEW -k switch for pgsql2shp</para>
+
+          <para>NEW support for custom createdb options in postgis_restore.pl</para>
+
+          <para>BUGFIX in pgsql2shp attribute names unicity enforcement</para>
+
+          <para>BUGFIX in Paris projections definitions</para>
+
+          <para>postgis_restore.pl cleanups</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.0</title>
+
+        <para>Release date: 2005/04/19</para>
+
+        <para>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.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>If you are upgrading from release 1.0.0RC6 you
+          <emphasis>DO NOT</emphasis> need a dump/reload.</para>
+
+          <para>Upgrading from any other precedent release requires a
+          dump/reload. See the <link linkend="upgrading">upgrading</link>
+          chapter for more informations.</para>
+        </sect3>
+
+        <sect3>
+          <title>Library changes</title>
+
+          <para>BUGFIX in transform() releasing random memory address</para>
+
+          <para>BUGFIX in force_3dm() allocating less memory then required</para>
+
+          <para>BUGFIX in join selectivity estimator (defaults, leaks,
+          tuplecount, sd)</para>
+        </sect3>
+
+        <sect3>
+          <title>Other changes/additions</title>
+
+          <para>BUGFIX in shp2pgsql escape of values starting with tab or
+          single-quote</para>
+
+          <para>NEW manual pages for loader/dumper</para>
+
+          <para>NEW shp2pgsql support for old (HWGEOM) postgis versions</para>
+
+          <para>NEW -p (prepare) flag for shp2pgsql</para>
+
+          <para>NEW manual chapter about OGC compliancy enforcement</para>
+
+          <para>NEW autoconf support for JTS lib</para>
+
+          <para>BUGFIX in estimator testers (support for LWGEOM and schema
+          parsing)</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.0RC6</title>
+
+        <para>Release date: 2005/03/30</para>
+
+        <para>Sixth release candidate for 1.0.0. Contains a few bug fixes and
+        cleanups.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>You need a dump/reload to upgrade from precedent releases. See
+          the <link linkend="upgrading">upgrading</link> chapter for more
+          informations.</para>
+        </sect3>
+
+        <sect3>
+          <title>Library changes</title>
+
+          <para>BUGFIX in multi()</para>
+
+          <para>early return [when noop] from multi()</para>
+        </sect3>
+
+        <sect3>
+          <title>Scripts changes</title>
+
+          <para>dropped {x,y}{min,max}(box2d) functions</para>
+        </sect3>
+
+        <sect3>
+          <title>Other changes</title>
+
+          <para>BUGFIX in postgis_restore.pl scrip</para>
+
+          <para>BUGFIX in dumper&#39;s 64bit support</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.0RC5</title>
+
+        <para>Release date: 2005/03/25</para>
+
+        <para>Fifth release candidate for 1.0.0. Contains a few bug fixes and
+        a improvements.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>If you are upgrading from release 1.0.0RC4 you
+          <emphasis>DO NOT</emphasis> need a dump/reload.</para>
+
+          <para>Upgrading from any other precedent release requires a
+          dump/reload. See the <link linkend="upgrading">upgrading</link>
+          chapter for more informations.</para>
+        </sect3>
+
+        <sect3>
+          <title>Library changes</title>
+
+          <para>BUGFIX (segfaulting) in box3d computation (yes, another!).</para>
+
+          <para>BUGFIX (segfaulting) in estimated_extent().</para>
+        </sect3>
+
+        <sect3>
+          <title>Other changes</title>
+
+          <para>Small build scripts and utilities refinements.</para>
+
+          <para>Additional performance tips documented.</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.0RC4</title>
+
+        <para>Release date: 2005/03/18</para>
+
+        <para>Fourth release candidate for 1.0.0. Contains bug fixes and a few
+        improvements.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>You need a dump/reload to upgrade from precedent releases. See
+          the <link linkend="upgrading">upgrading</link> chapter for more
+          informations.</para>
+        </sect3>
+
+        <sect3>
+          <title>Library changes</title>
+
+          <para>BUGFIX (segfaulting) in geom_accum().</para>
+
+          <para>BUGFIX in 64bit architectures support.</para>
+
+          <para>BUGFIX in box3d computation function with collections.</para>
+
+          <para>NEW subselects support in selectivity estimator.</para>
+
+          <para>Early return from force_collection.</para>
+
+          <para>Consistency check fix in SnapToGrid().</para>
+
+          <para>Box2d output changed back to 15 significant digits.</para>
+        </sect3>
+
+        <sect3>
+          <title>Scripts changes</title>
+
+          <para>NEW distance_sphere() function.</para>
+
+          <para>Changed get_proj4_from_srid implementation to use PL/PGSQL
+          instead of SQL.</para>
+        </sect3>
+
+        <sect3>
+          <title>Other changes</title>
+
+          <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 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>
+
+          <para>improvements in postgis_restore.pl</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.0RC3</title>
+
+        <para>Release date: 2005/02/24</para>
+
+        <para>Third release candidate for 1.0.0. Contains many bug fixes and
+        improvements.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>You need a dump/reload to upgrade from precedent releases. See
+          the <link linkend="upgrading">upgrading</link> chapter for more
+          informations.</para>
+        </sect3>
+
+        <sect3>
+          <title>Library changes</title>
+
+          <para>BUGFIX in transform(): missing SRID, better error handling.</para>
+
+          <para>BUGFIX in memory alignment handling</para>
+
+          <para>BUGFIX in force_collection() causing mapserver connector
+          failures on simple (single) geometry types.</para>
+
+          <para>BUGFIX in GeometryFromText() missing to add a bbox cache.</para>
+
+          <para>reduced precision of box2d output.</para>
+
+          <para>prefixed DEBUG macros with PGIS_ to avoid clash with pgsql one</para>
+
+          <para>plugged a leak in GEOS2POSTGIS converter</para>
+
+          <para>Reduced memory usage by early releasing query-context palloced
+          one.</para>
+        </sect3>
+
+        <sect3>
+          <title>Scripts changes</title>
+
+          <para>BUGFIX in 72 index bindings.</para>
+
+          <para>BUGFIX in probe_geometry_columns() to work with PG72 and
+          support multiple geometry columns in a single table</para>
+
+          <para>NEW bool::text cast</para>
+
+          <para>Some functions made IMMUTABLE from STABLE, for performance
+          improvement.</para>
+        </sect3>
+
+        <sect3>
+          <title>JDBC changes</title>
+
+          <para>jdbc2: small patches, box2d/3d tests, revised docs and
+          license.</para>
+
+          <para>jdbc2: bug fix and testcase in for pgjdbc 8.0 type
+          autoregistration</para>
+
+          <para>jdbc2: Removed use of jdk1.4 only features to enable build
+          with older jdk releases.</para>
+
+          <para>jdbc2: Added support for building against pg72jdbc2.jar</para>
+
+          <para>jdbc2: updated and cleaned makefile</para>
+
+          <para>jdbc2: added BETA support for jts geometry classes</para>
+
+          <para>jdbc2: Skip known-to-fail tests against older PostGIS servers.</para>
+
+          <para>jdbc2: Fixed handling of measured geometries in EWKT.</para>
+        </sect3>
+
+        <sect3>
+          <title>Other changes</title>
+
+          <para>new performance tips chapter in manual</para>
+
+          <para>documentation updates: pgsql72 requirement, lwpostgis.sql</para>
+
+          <para>few changes in autoconf</para>
+
+          <para>BUILDDATE extraction made more portable</para>
+
+          <para>fixed spatial_ref_sys.sql to avoid vacuuming the whole
+          database.</para>
+
+          <para>spatial_ref_sys: changed Paris entries to match the ones
+          distributed with 0.x.</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.0RC2</title>
+
+        <para>Release date: 2005/01/26</para>
+
+        <para>Second release candidate for 1.0.0 containing bug fixes and a
+        few improvements.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>You need a dump/reload to upgrade from precedent releases. See
+          the <link linkend="upgrading">upgrading</link> chapter for more
+          informations.</para>
+        </sect3>
+
+        <sect3>
+          <title>Library changes</title>
+
+          <para>BUGFIX in pointarray box3d computation</para>
+
+          <para>BUGFIX in distance_spheroid definition</para>
+
+          <para>BUGFIX in transform() missing to update bbox cache</para>
+
+          <para>NEW jdbc driver (jdbc2)</para>
+
+          <para>GEOMETRYCOLLECTION(EMPTY) syntax support for backward
+          compatibility</para>
+
+          <para>Faster binary outputs</para>
+
+          <para>Stricter OGC WKB/WKT constructors</para>
+        </sect3>
+
+        <sect3>
+          <title>Scripts changes</title>
+
+          <para>More correct STABLE, IMMUTABLE, STRICT uses in lwpostgis.sql</para>
+
+          <para>stricter OGC WKB/WKT constructors</para>
+        </sect3>
+
+        <sect3>
+          <title>Other changes</title>
+
+          <para>Faster and more robust loader (both i18n and not)</para>
+
+          <para>Initial autoconf script</para>
+        </sect3>
+      </sect2>
+
+      <sect2>
+        <title>Release 1.0.0RC1</title>
+
+        <para>Release date: 2005/01/13</para>
+
+        <para>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.</para>
+
+        <sect3>
+          <title>Upgrading</title>
+
+          <para>You need a dump/reload to upgrade from precedent releases. See
+          the <link linkend="upgrading">upgrading</link> chapter for more
+          informations.</para>
+        </sect3>
+
+        <sect3>
+          <title>Changes</title>
+
+          <para>Faster canonical input parsing.</para>
+
+          <para>Lossless canonical output.</para>
+
+          <para>EWKB Canonical binary IO with PG&#62;73.</para>
+
+          <para>Support for up to 4d coordinates, providing lossless
+          shapefile-&#62;postgis-&#62;shapefile conversion.</para>
+
+          <para>New function: UpdateGeometrySRID(), AsGML(), SnapToGrid(),
+          ForceRHR(), estimated_extent(), accum().</para>
+
+          <para>Vertical positioning indexed operators.</para>
+
+          <para>JOIN selectivity function.</para>
+
+          <para>More geometry constructors / editors.</para>
+
+          <para>Postgis extension API.</para>
+
+          <para>UTF8 support in loader.</para>
+        </sect3>
+      </sect2>
+    </sect1>
+  </appendix>
 </book>

Added: packages/postgis/upstream/extras/rpm/patches/postgis-configure.patch
===================================================================
--- packages/postgis/upstream/extras/rpm/patches/postgis-configure.patch	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/extras/rpm/patches/postgis-configure.patch	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,16 @@
+--- configure.old	2006-12-25 14:39:26.000000000 +0200
++++ configure	2006-12-25 14:39:35.000000000 +0200
+@@ -4609,13 +4609,6 @@
+ 	GEOS_DIR=`$GEOSCONFIG --prefix`
+ 
+ 	GEOS_LDFLAGS=`$GEOSCONFIG --ldflags 2> /dev/null`
+-	if test x"$GEOS_LDFLAGS" = "x"; then
+-		# older geos-config versions did not
+-		# support the --ldflags switch, we'll
+-		# default to GEOS_DIR/lib in this case.
+-		#
+-		GEOS_LDFLAGS="$GEOS_DIR/lib"
+-	fi
+ 
+ 	GEOS_MAJOR=`$GEOSCONFIG --version | cut -d. -f1`
+ 	if test "$GEOS_MAJOR" = "@GEOS_VERSION@"; then

Added: packages/postgis/upstream/extras/rpm/patches/postgis-javamakefile.patch
===================================================================
--- packages/postgis/upstream/extras/rpm/patches/postgis-javamakefile.patch	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/extras/rpm/patches/postgis-javamakefile.patch	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,11 @@
+--- java/jdbc/Makefile.old	2006-12-25 15:25:19.000000000 +0200
++++ java/jdbc/Makefile	2006-12-25 15:25:26.000000000 +0200
+@@ -27,7 +27,7 @@
+ 
+ # Configure the helper executables used during build.
+ 
+-JAVAC?=javac -target 1.2 -source 1.2
++JAVAC?=javac -target 1.5 -source 1.5
+ JAVA?=java
+ JAR?=jar
+ MKDIR?=mkdir -p

Modified: packages/postgis/upstream/extras/rpm/spec/postgis.spec
===================================================================
--- packages/postgis/upstream/extras/rpm/spec/postgis.spec	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/extras/rpm/spec/postgis.spec	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,122 +1,156 @@
-%define pg_version      %(rpm -q --queryformat '%{VERSION}' postgresql-devel)
-%{!?jdbc2:%define jdbc2 0}
-%{!?utils:%define utils 1}
+%{!?javabuild:%define	javabuild 1}
+%{!?utils:%define	utils 1}
+%{!?gcj_support:%define	gcj_support 1}
 
-Summary:        Geographic Information Systems Extensions to PostgreSQL
-Name:           postgis
-Version:        1.1.2
-Release:        1
-License:        GPL v2
-Group:          Applications/Databases
-Source0:        http://postgis.refractions.net/download/%{name}-%{version}.tar.gz
-Source2:       postgis-jdbcdedectver.sh
-Source4:        filter-requires-perl-Pg.sh
-Vendor:         The PostGIS Project
-URL:            http://postgis.refractions.net/
-BuildRequires:  postgresql-devel,proj-devel, geos-devel >= 2.1.1
-Requires:       postgresql = %{pg_version} geos proj
-BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)
+Summary:	Geographic Information Systems Extensions to PostgreSQL
+Name:		postgis
+Version:	1.2.0
+Release:	2%{?dist}
+License:	GPL
+Group:		Applications/Databases
+Source0:	http://postgis.refractions.net/download/%{name}-%{version}.tar.gz
+Source4:	filter-requires-perl-Pg.sh
+Patch1:		postgis-configure.patch
+Patch2:		postgis-javamakefile.patch
+URL:		http://postgis.refractions.net/
+BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
+BuildRequires:	postgresql-devel, proj-devel, geos-devel, byacc, proj-devel, flex, postgresql-jdbc
+Requires:	postgresql, geos, proj
+
 %description
 PostGIS adds support for geographic objects to the PostgreSQL object-relational
 database. In effect, PostGIS "spatially enables" the PostgreSQL server,
 allowing it to be used as a backend spatial database for geographic information
-systems (GIS), much like ESRI's SDE or Oracle's Spatial extension. PostGIS
-follows the OpenGIS "Simple Features Specification for SQL" and will be
-submitted for conformance testing at version 1.0.
+systems (GIS), much like ESRI's SDE or Oracle's Spatial extension. PostGIS 
+follows the OpenGIS "Simple Features Specification for SQL" and has been 
+certified as compliant with the "Types and Functions" profile.
 
-%if %jdbc2
-%package jdbc2
-Summary: The JDBC2 driver for PostGIS
-Group: Applications/Interfaces
-Provides: %{name}_%{version}.jar
-Requires: postgis
-                                                                                                    
-%description jdbc2
-The postgis-jdbc2 package provides the essential jdbc2 driver for PostGIS.
+%if %javabuild
+%package jdbc
+Summary:	The JDBC driver for PostGIS
+Group:		Applications/Databases
+License:	LGPL
+Requires:	postgis
+BuildRequires:  ant >= 0:1.6.2, junit >= 0:3.7
+
+%if %{gcj_support}
+BuildRequires:		gcc-java
+Requires(post):		java-1.4.2-gcj-compat
+Requires(postun):	java-1.4.2-gcj-compat
 %endif
 
+%description jdbc
+The postgis-jdbc package provides the essential jdbc driver for PostGIS.
+%endif
+
 %if %utils
 %package utils
-Summary: The utils for PostGIS
-Group: Applications/Interfaces
-Requires: postgis, perl-DBD-Pg
-                                                                                                    
+Summary:	The utils for PostGIS
+Group:		Applications/Databases
+Requires:	postgis, perl-DBD-Pg
+
 %description utils
 The postgis-utils package provides the utilities for PostGIS.
 %endif
-                                                                                                    
+
 %define __perl_requires %{SOURCE4}
 
 %prep
 %setup -q
+%patch1 -p0
+%patch2 -p0
 
 %build
-make %{?_smp_mflags} PGXS=1 PGSQL_SRC=/usr/lib/pgsql/pgxs LPATH=\$\(pkglibdir\) shlib="%{name}.so"  'CFLAGS=-Wno-pointer-sign '
+%configure 
+make %{?_smp_mflags} LPATH=`pg_config --pkglibdir` shlib="%{name}.so"
 
-%if %jdbc2
-export MAKEFILE_DIR=/usr/src/redhat/BUILD/%{name}-%{version}/jdbc2
-sh %{SOURCE2}
- make -C jdbc2
+%if %javabuild
+export MAKEFILE_DIR=%{_builddir}/%{name}-%{version}/java/jdbc
+JDBC_VERSION_RPM=`rpm -ql postgresql-jdbc| grep 'jdbc.jar$'|awk -F '/' '{print $5}'`
+sed 's/postgresql.jar/'${JDBC_VERSION_RPM}'/g' $MAKEFILE_DIR/Makefile > $MAKEFILE_DIR/Makefile.new
+mv -f $MAKEFILE_DIR/Makefile.new $MAKEFILE_DIR/Makefile
+make -C java/jdbc
 %endif
-                                                                                                    
+
 %if %utils
  make -C utils
 %endif
 
 %install
-rm -rf $RPM_BUILD_ROOT
-make install DESTDIR=$RPM_BUILD_ROOT PGXS=1 PGSQL_SRC=/usr/lib/pgsql/pgxs
-install lwgeom/%{name}.so $RPM_BUILD_ROOT%{_libdir}/pgsql
-#install -d  $RPM_BUILD_ROOT/usr/share/pgsql/postgresql/contrib/
-#install -m 755 *.sql $RPM_BUILD_ROOT/usr/share/pgsql/postgresql/contrib/
-install -d  $RPM_BUILD_ROOT/usr/share/pgsql/contrib/
-install -m 755 *.sql $RPM_BUILD_ROOT/usr/share/pgsql/contrib/
+rm -rf %{buildroot}
+make install DESTDIR=%{buildroot}
+install -d %{buildroot}%{_libdir}/pgsql/
+install lwgeom/liblwgeom.so* %{buildroot}%{_libdir}/pgsql/
+install -d  %{buildroot}%{_datadir}/pgsql/contrib/
+install -m 644 *.sql %{buildroot}%{_datadir}/pgsql/contrib/
+rm -f  %{buildroot}%{_libdir}/liblwgeom.so*
+rm -f  %{buildroot}%{_datadir}/*.sql
 
-%if %jdbc2
-# JDBC2
-# Red Hat's standard place to put jarfiles is /usr/share/java
-  install -d $RPM_BUILD_ROOT/usr/share/java
-  install -m 755 jdbc2/%{name}_%{version}.jar $RPM_BUILD_ROOT/usr/share/java
+%if %javabuild
+install -d %{buildroot}%{_javadir}
+install -m 755 java/jdbc/%{name}_%{version}.jar %{buildroot}%{_javadir}
+%if %{gcj_support}
+aot-compile-rpm
 %endif
-                                                                                                    
+%endif
+
+strip %{buildroot}/%{_libdir}/gcj/%{name}/*.jar.so
+
 %if %utils
- install -d $RPM_BUILD_ROOT/usr/bin
- install -m 755 utils/*.pl $RPM_BUILD_ROOT/usr/bin
+install -d %{buildroot}%{_datadir}/%{name}
+install -m 644 utils/*.pl %{buildroot}%{_datadir}/%{name}
 %endif
 
 %clean
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
 
+%post -p %{_bindir}/rebuild-gcj-db
+
+%postun -p %{_bindir}/rebuild-gcj-db
+
 %files
-%defattr(644,root,root,755)
-%doc NEWS CREDITS README.postgis TODO doc/html loader/README.* *.sql doc/postgis.xml  doc/ZMSgeoms.txt 
+%defattr(-,root,root)
+%doc COPYING CREDITS NEWS TODO README.%{name} TODO doc/html loader/README.* doc/%{name}.xml  doc/ZMSgeoms.txt 
 %attr(755,root,root) %{_bindir}/*
-%attr(755,root,root) %{_libdir}/pgsql/*.so*
-#%attr(755,root,root) %{_mandir}/man1/*
-%attr(755,root,root) /usr/share/pgsql/contrib/*
+%attr(755,root,root) %{_libdir}/pgsql/liblwgeom.so*
+%{_datadir}/pgsql/contrib/*.sql
 
-%if %jdbc2
-%files jdbc2
-%defattr(644,root,root,755)
-%attr(755,root,root) /usr/share/java/%{name}_%{version}.jar
+%if %javabuild
+%files jdbc
+%defattr(-,root,root)
+%doc java/jdbc/COPYING_LGPL java/jdbc/README
+%attr(755,root,root) %{_javadir}/%{name}_%{version}.jar
+%if %{gcj_support}
+%dir %{_libdir}/gcj/%{name}
+%{_libdir}/gcj/%{name}/*.jar.so
+%{_libdir}/gcj/%{name}/*.jar.db
 %endif
+%endif
 
 %if %utils
 %files utils
-%defattr(644,root,root,755)
-%attr(755,root,root) %{_bindir}/create_undef.pl
-%attr(755,root,root) %{_bindir}/test_estimation.pl
-%attr(755,root,root) %{_bindir}/test_joinestimation.pl
-%attr(755,root,root) %{_bindir}/postgis_restore.pl
-%attr(755,root,root) %{_bindir}/profile_intersects.pl
-
+%defattr(-,root,root)
+%doc utils/README
+%attr(755,root,root) %{_datadir}/%{name}/test_estimation.pl
+%attr(755,root,root) %{_datadir}/%{name}/profile_intersects.pl
+%attr(755,root,root) %{_datadir}/%{name}/test_joinestimation.pl
+%attr(644,root,root) %{_datadir}/%{name}/create_undef.pl
+%attr(644,root,root) %{_datadir}/%{name}/%{name}_proc_upgrade.pl
+%attr(644,root,root) %{_datadir}/%{name}/%{name}_restore.pl
 %endif
 
 %changelog
-* Thu May 11 2006 - Laurent WANDREBECK <lw at hygeos.com> 1.1.2-1
-- update to 1.1.2
+* Mon Dec 26 2006 - Devrim GUNDUZ <devrim at commandprompt.com> 1.2.0-2
+- More spec file fixes per bugzilla review #220743
 
+* Mon Dec 25 2006 - Devrim GUNDUZ <devrim at commandprompt.com> 1.2.0-1
+- Initial submission for Fedora Core Extras
+- Spec file changes and fixes per FC Extras packaging guidelines
+
+* Fri Jun 23 2006 - Devrim GUNDUZ <devrim at commandprompt.com> 1.1.2-2
+- Update to 1.1.2
+
 * Tue Dec 22 2005 - Devrim GUNDUZ <devrim at commandprompt.com> 1.1.0-2
 - Final fixes for 1.1.0
 
@@ -126,23 +160,23 @@
 * Mon Oct 03 2005 - Devrim GUNDUZ <devrim at gunduz.org>
 - Make PostGIS build against pgxs so that we don't need PostgreSQL sources.
 - Fixed all build errors except jdbc (so, defaulted to 0)
-- Added new files under %utils
+- Added new files under %%utils
 - Removed postgis-jdbc2-makefile.patch (applied to -head)
                                                                                                     
 * Tue Sep 27 2005 - Devrim GUNDUZ <devrim at gunduz.org>
 - Update to 1.0.4
-                                                                                                    
-* Sun Apr 20 2005 - Devrim GUNDUZ <devrim at gunuz.org>
+
+* Sun Apr 20 2005 - Devrim GUNDUZ <devrim at gunduz.org>
 - 1.0.0 Gold
-                                                                                                    
-* Sun Apr 17 2005 - Devrim GUNDUZ <devrim at gunuz.org>
+
+* Sun Apr 17 2005 - Devrim GUNDUZ <devrim at gunduz.org>
 - Modified the spec file so that we can build JDBC2 RPMs...
 - Added -utils RPM to package list.
-                                                                                                    
-* Fri Apr 15 2005 - Devrim GUNDUZ <devrim at gunuz.org>
+
+* Fri Apr 15 2005 - Devrim GUNDUZ <devrim at gunduz.org>
 - Added preun and postun scripts.
-                                                                                                    
-* Sat Apr 09 2005 - Devrim GUNDUZ <devrim at gunuz.org>
+
+* Sat Apr 09 2005 - Devrim GUNDUZ <devrim at gunduz.org>
 - Initial RPM build
 - Fixed libdir so that PostgreSQL installations will not complain about it.
 - Enabled --with-geos and modified the old spec.

Modified: packages/postgis/upstream/extras/template_gis/Makefile
===================================================================
--- packages/postgis/upstream/extras/template_gis/Makefile	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/extras/template_gis/Makefile	2007-04-13 07:15:27 UTC (rev 758)
@@ -23,6 +23,14 @@
               $(LN_S) $(SCRIPT_TARGET) $(SCRIPT_LINKDIR)
 SCRIPT_UNINSTALL=rm -f $(SCRIPT_TARGET)
 SCRIPT_UNLINK=rm -f $(SCRIPT_LINK)
+
+# would probably be nice to link these somewhere as well
+MANPAGES1:=$(wildcard *.1)
+MAN1_TARGETDIR=$(DESTDIR)$(mandir)/man1
+MAN1_TARGET=$(MAN1_TARGETDIR)/$(MAN1)
+MAN1_INSTALL=$(INSTALL_DATA) $(MAN1) $(MAN1_TARGET)
+MAN1_UNINSTALL=rm -f $(MAN1_TARGET)
+
 DEFAULTS_DIR=$(DESTDIR)/etc/default
 SCRIPT_DEFAULTS=$(DEFAULTS_DIR)/postgis
 
@@ -37,10 +45,13 @@
 	@mkdir -p $(DEFAULTS_DIR)
 	cp profile $(SCRIPT_DEFAULTS)
 	rm -f $(SCRIPT_TARGETDIR)/profile
+	@mkdir -p $(MAN1_TARGETDIR)
+	$(foreach MAN1, $(MANPAGES1), $(MAN1_INSTALL);)
 
 uninstall:
 	$(foreach SCRIPT, $(PUBLIC_SCRIPTS), $(SCRIPT_UNLINK);)
 	$(foreach SCRIPT, $(SCRIPTS), $(SCRIPT_UNINSTALL);)
+	$(foreach MAN1, $(MANPAGES1), $(MAN1_UNINSTALL);)
 
 purge: uninstall
 	rm -f $(SCRIPT_DEFAULTS)

Modified: packages/postgis/upstream/java/ejb3/src/org/postgis/hibernate/GeometryType.java
===================================================================
--- packages/postgis/upstream/java/ejb3/src/org/postgis/hibernate/GeometryType.java	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/java/ejb3/src/org/postgis/hibernate/GeometryType.java	2007-04-13 07:15:27 UTC (rev 758)
@@ -19,7 +19,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
  * http://www.gnu.org.
  * 
- * $Id: GeometryType.java 2501 2006-10-09 17:22:15Z mschaber $
+ * $Id: GeometryType.java 2531 2006-11-22 10:42:17Z mschaber $
  */
 package org.postgis.hibernate;
 
@@ -86,11 +86,13 @@
 	 */
 	public Object nullSafeGet(ResultSet resultSet, 
 		      String[] names, Object owner) throws HibernateException, SQLException {
-	    Geometry result = null;
-	    String geom = resultSet.getString(names[0]);
-	    BinaryParser parser = new BinaryParser();
-	    result = parser.parse(geom);
-	    return result;
+        Geometry result = null;
+        String geom = resultSet.getString(names[0]);
+        if(geom != null ) {
+            BinaryParser parser = new BinaryParser();
+            result = parser.parse(geom);
+        }
+        return result;
 	}
 
 	/**

Modified: packages/postgis/upstream/java/jdbc/Makefile
===================================================================
--- packages/postgis/upstream/java/jdbc/Makefile	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/java/jdbc/Makefile	2007-04-13 07:15:27 UTC (rev 758)
@@ -82,22 +82,25 @@
 PGURL?=//$(PGHOST):$(PGPORT)/$(PGDATABASE)
 
 # Where to put the output from regression tests. If you want to have it on
-# stdout, set TESTOUT to the empty string. Be careful - this will be deleted
-# by "make clean".
+# stdout, set TESTRD to the empty string. If you want to have it in another
+# file, set TESTOUTPUT to the file path.
+# Be careful - that file will be deleted by "make clean".
 TESTOUTPUT?=test.log
+# Output redirect for tests
+TESTRD?= >>$(TESTOUTPUT) 
 
 ### Config variable section ends ###
 
 # build internal constants follow:
-SRCDIR=src
+SRCDIR=./src
 EXAMPLES=examples
-BUILD=bin
+BUILD=./bin
 RUNCP=$(POSTGIS_BUILD_CLASSPATH)$(CPSEP)./postgis.jar
 BUILDCP=$(STUBBUILD)$(CPSEP)$(POSTGIS_BUILD_CLASSPATH)$(CPSEP)$(SRCDIR)
 
 # The pgjdbc 7.2/7.4/8.0 compatibility stub stuff
 STUBDIR=stubs
-STUBBUILD=stubbin/
+STUBBUILD=./stubbin/
 
 # What to put into the JAR files:
 JARCONTENTS=-C $(BUILD) org \
@@ -122,8 +125,6 @@
 VERSIONPATH=$(BUILD)/org/postgis
 VERSIONTARGET=$(VERSIONPATH)/version.properties
 
-# Output redirect for tests
-TESTRD?= >>$(TESTOUTPUT) 
 
 # Preliminary jts support - not stable yet!
 JTSDIR=jtssrc
@@ -137,12 +138,13 @@
 
 STUBSRC = $(STUBDIR)/org/postgresql/*.java
 
-JTSSRC = $(JTSDIR)/org/postgis/jts/*.java
+JTSSRC = $(JTSDIR)/org/postgis/jts/*.java $(JTSDIR)/examples/*.java
 
 
 # Now the makefile targets that do the work:
 # The default target:
 all:	jar \
+		postgis-jdbc-javadoc.zip \
 	offlinetests
 
 # Packing the archives
@@ -225,6 +227,7 @@
 	echo cleaning...
 	$(DELETE) $(BUILD) bin stubbin postgis.jar postgis_debug.jar \
 		compile stubcompile jtscompile $(JTSBUILD) postgis_jts.jar \
+		javadoc-build postgis-jdbc-javadoc.zip \
 		$(TESTOUTPUT) \
 		postgis_$(VERSION).jar \
 		postgis_debug_$(VERSION).jar \
@@ -243,6 +246,14 @@
 installdirs:
 	@mkdir -p $(DESTDIR)
 
+postgis-jdbc-javadoc.zip: javadoc-build
+	$(JAR) -cf postgis-jdbc-javadoc.zip -C javadoc-build .
+
+javadoc-build: jtscompile compile
+	$(MKDIR) javadoc-build
+	javadoc -d javadoc-build -sourcepath src:jtssrc \
+		org.postgis org.postgis.jts org.postgis.binary org.postgis.java2d examples
+
 # Preliminary JTS support
 
 postgis_jts: postgis_jts.jar jtstestoffline

Modified: packages/postgis/upstream/java/jdbc/jtssrc/examples/JtsTestParser.java
===================================================================
--- packages/postgis/upstream/java/jdbc/jtssrc/examples/JtsTestParser.java	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/java/jdbc/jtssrc/examples/JtsTestParser.java	2007-04-13 07:15:27 UTC (rev 758)
@@ -21,28 +21,35 @@
  * Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
  * http://www.gnu.org.
  * 
- * $Id: JtsTestParser.java 1730 2005-05-25 10:12:54Z mschaber $
+ * $Id: JtsTestParser.java 2557 2006-12-18 14:12:20Z mschaber $
  */
 
 package examples;
 
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
+
 import org.postgis.binary.ValueSetter;
 import org.postgis.jts.JtsBinaryParser;
 import org.postgis.jts.JtsBinaryWriter;
 import org.postgis.jts.JtsGeometry;
-
 import org.postgresql.util.PGtokenizer;
 
 import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.GeometryCollection;
+import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.LinearRing;
+import com.vividsolutions.jts.geom.MultiLineString;
+import com.vividsolutions.jts.geom.MultiPoint;
+import com.vividsolutions.jts.geom.MultiPolygon;
+import com.vividsolutions.jts.geom.Point;
+import com.vividsolutions.jts.geom.Polygon;
 
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Types;
-
 public class JtsTestParser {
 
     public static String ALL = "ALL", ONLY10 = "ONLY10", EQUAL10 = "EQUAL10";
@@ -50,79 +57,53 @@
     /**
      * Our set of geometries to test.
      */
-    public static final String[][] testset = new String[][]{
-        {
-            ALL, // 2D
-            "POINT(10 10)"},
-        {
-            ALL, // 3D with 3rd coordinate set to 0
-            "POINT(10 10 0)"},
-        {
-            ALL, // 3D
-            "POINT(10 10 20)"},
-        {
-            ALL,
-            "MULTIPOINT(11 12, 20 20)"},
-        {
-            ALL,
-            "MULTIPOINT(11 12 13, 20 20 20)"},
-        {
-            ALL,
-            "LINESTRING(10 10,20 20,50 50,34 34)"},
-        {
-            ALL,
-            "LINESTRING(10 10 20,20 20 20,50 50 50,34 34 34)"},
-        {
-            ALL,
-            "POLYGON((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5))"},
-        {
-            ALL,
-            "POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"},
-        {
-            ALL,
-            "MULTIPOLYGON(((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5)),((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5)))"},
-        {
-            ALL,
-            "MULTIPOLYGON(((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))"},
-        {
-            ALL,
-            "MULTILINESTRING((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5))"},
-        {
-            ALL,
-            "MULTILINESTRING((10 10 5,20 10 5,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))"},
-        {
-            ALL,
-            "GEOMETRYCOLLECTION(POINT(10 10),POINT(20 20))"},
-        {
-            ALL,
-            "GEOMETRYCOLLECTION(POINT(10 10 20),POINT(20 20 20))"},
-        {
-            ALL,
-            "GEOMETRYCOLLECTION(LINESTRING(10 10 20,20 20 20, 50 50 50, 34 34 34),LINESTRING(10 10 20,20 20 20, 50 50 50, 34 34 34))"},
-        {
-            ALL,
-            "GEOMETRYCOLLECTION(POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))"},
-        {
-            ONLY10, // Cannot be parsed by 0.X servers
-            "GEOMETRYCOLLECTION(MULTIPOINT(10 10 10, 20 20 20),MULTIPOINT(10 10 10, 20 20 20))"},
-        {
-            EQUAL10, // PostGIs 0.X "flattens" this geometry, so it is not
-            // equal after reparsing.
-            "GEOMETRYCOLLECTION(MULTILINESTRING((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))"},
-        {
-            EQUAL10,// PostGIs 0.X "flattens" this geometry, so it is not equal
-            // after reparsing.
-            "GEOMETRYCOLLECTION(MULTIPOLYGON(((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))),MULTIPOLYGON(((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))))"},
-        {
-            ALL,
-            "GEOMETRYCOLLECTION(POINT(10 10 20),LINESTRING(10 10 20,20 20 20, 50 50 50, 34 34 34),POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))"},
-        {
-            ONLY10, // Collections that contain both X and MultiX do not work on
-            // PostGIS 0.x
-            "GEOMETRYCOLLECTION(POINT(10 10 20),MULTIPOINT(10 10 10, 20 20 20),LINESTRING(10 10 20,20 20 20, 50 50 50, 34 34 34),POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),MULTIPOLYGON(((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))),MULTILINESTRING((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))"},
-        {
-            ALL,// new (correct) representation
-            "GEOMETRYCOLLECTION EMPTY"},
+    public static final String[][] testset = new String[][] {
+            { ALL, // 2D
+                    "POINT(10 10)" },
+            { ALL, // 3D with 3rd coordinate set to 0
+                    "POINT(10 10 0)" },
+            { ALL, // 3D
+                    "POINT(10 10 20)" },
+            { ALL, "MULTIPOINT(11 12, 20 20)" },
+            { ALL, "MULTIPOINT(11 12 13, 20 20 20)" },
+            { ALL, "LINESTRING(10 10,20 20,50 50,34 34)" },
+            { ALL, "LINESTRING(10 10 20,20 20 20,50 50 50,34 34 34)" },
+            { ALL, "POLYGON((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5))" },
+            { ALL, "POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))" },
+            {
+                    ALL,
+                    "MULTIPOLYGON(((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5)),((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5)))" },
+            {
+                    ALL,
+                    "MULTIPOLYGON(((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))" },
+            { ALL, "MULTILINESTRING((10 10,20 10,20 20,20 10,10 10),(5 5,5 6,6 6,6 5,5 5))" },
+            { ALL, "MULTILINESTRING((10 10 5,20 10 5,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))" },
+            { ALL, "GEOMETRYCOLLECTION(POINT(10 10),POINT(20 20))" },
+            { ALL, "GEOMETRYCOLLECTION(POINT(10 10 20),POINT(20 20 20))" },
+            {
+                    ALL,
+                    "GEOMETRYCOLLECTION(LINESTRING(10 10 20,20 20 20, 50 50 50, 34 34 34),LINESTRING(10 10 20,20 20 20, 50 50 50, 34 34 34))" },
+            {
+                    ALL,
+                    "GEOMETRYCOLLECTION(POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))" },
+            { ONLY10, // Cannot be parsed by 0.X servers
+                    "GEOMETRYCOLLECTION(MULTIPOINT(10 10 10, 20 20 20),MULTIPOINT(10 10 10, 20 20 20))" },
+            { EQUAL10, // PostGIs 0.X "flattens" this geometry, so it is not
+                    // equal after reparsing.
+                    "GEOMETRYCOLLECTION(MULTILINESTRING((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))" },
+            { EQUAL10,// PostGIs 0.X "flattens" this geometry, so it is not
+                        // equal
+                    // after reparsing.
+                    "GEOMETRYCOLLECTION(MULTIPOLYGON(((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))),MULTIPOLYGON(((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))))" },
+            {
+                    ALL,
+                    "GEOMETRYCOLLECTION(POINT(10 10 20),LINESTRING(10 10 20,20 20 20, 50 50 50, 34 34 34),POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))" },
+            { ONLY10, // Collections that contain both X and MultiX do not
+                        // work on
+                    // PostGIS 0.x
+                    "GEOMETRYCOLLECTION(POINT(10 10 20),MULTIPOINT(10 10 10, 20 20 20),LINESTRING(10 10 20,20 20 20, 50 50 50, 34 34 34),POLYGON((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),MULTIPOLYGON(((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)),((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0))),MULTILINESTRING((10 10 0,20 10 0,20 20 0,20 10 0,10 10 0),(5 5 0,5 6 0,6 6 0,6 5 0,5 5 0)))" },
+            { ALL,// new (correct) representation
+                    "GEOMETRYCOLLECTION EMPTY" },
     // end
     };
 
@@ -136,6 +117,7 @@
     public static int failcount = 0;
 
     private static JtsBinaryParser bp = new JtsBinaryParser();
+
     private static final JtsBinaryWriter bw = new JtsBinaryWriter();
 
     /** The actual test method */
@@ -143,13 +125,22 @@
         System.out.println("Original:  " + WKT);
         Geometry geom = JtsGeometry.geomFromString(WKT);
         String parsed = geom.toString();
+        if (WKT.startsWith("SRID=")) {
+            parsed = "SRID="+geom.getSRID()+";"+parsed;
+        }
         System.out.println("Parsed:    " + parsed);
         Geometry regeom = JtsGeometry.geomFromString(parsed);
         String reparsed = regeom.toString();
+        if (WKT.startsWith("SRID=")) {
+            reparsed = "SRID="+geom.getSRID()+";"+reparsed;
+        }
         System.out.println("Re-Parsed: " + reparsed);
         if (!geom.equalsExact(regeom)) {
             System.out.println("--- Geometries are not equal!");
             failcount++;
+        } else if (geom.getSRID() != regeom.getSRID()) {
+            System.out.println("--- Geometriy SRIDs are not equal!");
+            failcount++;
         } else if (!reparsed.equals(parsed)) {
             System.out.println("--- Text Reps are not equal!");
             failcount++;
@@ -157,7 +148,7 @@
             System.out.println("Equals:    yes");
         }
 
-        String hexNWKT = bw.writeHexed(regeom, ValueSetter.NDR.NUMBER);
+        String hexNWKT = bw.writeHexed(geom, ValueSetter.NDR.NUMBER);
         System.out.println("NDRHex:    " + hexNWKT);
         regeom = JtsGeometry.geomFromString(hexNWKT);
         System.out.println("ReNDRHex:  " + regeom.toString());
@@ -168,7 +159,7 @@
             System.out.println("Equals:    yes");
         }
 
-        String hexXWKT = bw.writeHexed(regeom, ValueSetter.XDR.NUMBER);
+        String hexXWKT = bw.writeHexed(geom, ValueSetter.XDR.NUMBER);
         System.out.println("XDRHex:    " + hexXWKT);
         regeom = JtsGeometry.geomFromString(hexXWKT);
         System.out.println("ReXDRHex:  " + regeom.toString());
@@ -179,7 +170,7 @@
             System.out.println("Equals:    yes");
         }
 
-        byte[] NWKT = bw.writeBinary(regeom, ValueSetter.NDR.NUMBER);
+        byte[] NWKT = bw.writeBinary(geom, ValueSetter.NDR.NUMBER);
         regeom = bp.parse(NWKT);
         System.out.println("NDR:       " + regeom.toString());
         if (!geom.equalsExact(regeom)) {
@@ -189,7 +180,7 @@
             System.out.println("Equals:    yes");
         }
 
-        byte[] XWKT = bw.writeBinary(regeom, ValueSetter.XDR.NUMBER);
+        byte[] XWKT = bw.writeBinary(geom, ValueSetter.XDR.NUMBER);
         regeom = bp.parse(XWKT);
         System.out.println("XDR:       " + regeom.toString());
         if (!geom.equalsExact(regeom)) {
@@ -199,14 +190,32 @@
             System.out.println("Equals:    yes");
         }
 
+        Geometry coordArrayGeom = rebuildCS(geom);
+        System.out.println("CoordArray:" + regeom.toString());
+        if (!geom.equalsExact(coordArrayGeom)) {
+            System.out.println("--- Geometries are not equal!");
+            failcount++;
+        } else {
+            System.out.println("Equals:    yes");
+        }
+
+        String coordArrayWKT = bw.writeHexed(coordArrayGeom, ValueSetter.NDR.NUMBER);
+        System.out.println("HexCArray: " + coordArrayWKT);
+        if (!coordArrayWKT.equals(hexNWKT)) {
+            System.out.println("--- CoordArray HexWKT is not equal: "+bp.parse(coordArrayWKT));
+            failcount++;
+        } else {
+            System.out.println("HexEquals: yes");
+        }
+
         for (int i = 0; i < conns.length; i++) {
             Connection connection = conns[i];
             Statement statement = connection.createStatement();
             int serverPostgisMajor = TestAutoregister.getPostgisMajor(statement);
 
             if ((flags == ONLY10) && serverPostgisMajor < 1) {
-                System.out.println("PostGIS server too old, skipping test on connection " + i
-                        + ": " + connection.getCatalog());
+                System.out.println("PostGIS server too old, skipping test on connection " + i + ": "
+                        + connection.getCatalog());
             } else {
                 System.out.println("Testing on connection " + i + ": " + connection.getCatalog());
                 try {
@@ -215,8 +224,7 @@
                     if (!geom.equalsExact(sqlGeom)) {
                         System.out.println("--- Geometries after SQL are not equal!");
                         if (flags == EQUAL10 && serverPostgisMajor < 1) {
-                            System.out.println("--- This is expected with PostGIS "
-                                    + serverPostgisMajor + ".X");
+                            System.out.println("--- This is expected with PostGIS " + serverPostgisMajor + ".X");
                         } else {
                             failcount++;
                         }
@@ -234,8 +242,7 @@
                     if (!geom.equalsExact(sqlreGeom)) {
                         System.out.println("--- reparsed Geometries after SQL are not equal!");
                         if (flags == EQUAL10 && serverPostgisMajor < 1) {
-                            System.out.println("--- This is expected with PostGIS "
-                                    + serverPostgisMajor + ".X");
+                            System.out.println("--- This is expected with PostGIS " + serverPostgisMajor + ".X");
                         } else {
                             failcount++;
                         }
@@ -253,8 +260,7 @@
                     if (!geom.equalsExact(sqlreGeom)) {
                         System.out.println("--- reparsed Geometries after prepared StatementSQL are not equal!");
                         if (flags == EQUAL10 && serverPostgisMajor < 1) {
-                            System.out.println("--- This is expected with PostGIS "
-                                    + serverPostgisMajor + ".X");
+                            System.out.println("--- This is expected with PostGIS " + serverPostgisMajor + ".X");
                         } else {
                             failcount++;
                         }
@@ -372,6 +378,97 @@
         System.out.println("***");
     }
 
+    // Rebuild given Geometry with a CoordinateArraySequence implementation. 
+    public static Geometry rebuildCS(Geometry geom) {        
+        if (geom instanceof Point) {
+            return rebuildCSPoint((Point)geom);
+        } else if (geom instanceof MultiPoint) {
+            return rebuildCSMP((MultiPoint)geom);
+        } else if (geom instanceof LineString) {
+            return rebuildCSLS((LineString)geom);
+        } else if (geom instanceof MultiLineString) {
+            return rebuildCSMLS((MultiLineString)geom);
+        } else if (geom instanceof Polygon) {
+            return rebuildCSP((Polygon)geom);
+        } else if (geom instanceof MultiPolygon) {
+            return rebuildCSMP((MultiPolygon)geom);
+        } else if (geom instanceof GeometryCollection) {
+            return rebuildCSGC((GeometryCollection)geom);
+        } else {
+            throw new AssertionError();
+        }
+    }
+
+    private static Geometry rebuildCSGC(GeometryCollection coll) {
+        Geometry[] geoms = new Geometry[coll.getNumGeometries()];
+        for (int i = 0; i < coll.getNumGeometries(); i++) {
+            geoms[i] = rebuildCS(coll.getGeometryN(i));
+        }
+        Geometry result = coll.getFactory().createGeometryCollection(geoms);
+        result.setSRID(coll.getSRID());
+        return result;
+    }
+
+    private static MultiPolygon rebuildCSMP(MultiPolygon multipoly) {
+        Polygon[] polygons = new Polygon[multipoly.getNumGeometries()];
+        for (int i=0; i < polygons.length; i++) {
+            polygons[i] = rebuildCSP((Polygon)multipoly.getGeometryN(i));
+        }
+        MultiPolygon result = multipoly.getFactory().createMultiPolygon(polygons);
+        result.setSRID(multipoly.getSRID());
+        return result;
+    }
+
+    private static Polygon rebuildCSP(Polygon polygon) {
+        LinearRing outer = rebuildLR(polygon.getExteriorRing());
+        LinearRing[] holes = new LinearRing[polygon.getNumInteriorRing()];
+        for (int i=0; i < holes.length; i++) {
+            holes[i] = rebuildLR(polygon.getInteriorRingN(i));
+        }
+        Polygon result = polygon.getFactory().createPolygon(outer, holes);
+        result.setSRID(polygon.getSRID());
+        return result;
+    }
+
+    private static LinearRing rebuildLR(LineString ring) {
+        LinearRing result = ring.getFactory().createLinearRing(ring.getCoordinates());
+        result.setSRID(ring.getSRID());
+        return result;
+    }
+
+    private static MultiLineString rebuildCSMLS(MultiLineString multiline) {
+        LineString[] polygons = new LineString[multiline.getNumGeometries()];
+        for (int i=0; i < polygons.length; i++) {
+            polygons[i] = rebuildCSLS((LineString)multiline.getGeometryN(i));
+        }
+        MultiLineString result = multiline.getFactory().createMultiLineString(polygons);
+        result.setSRID(multiline.getSRID());
+        return result;
+        
+    }
+
+    private static LineString rebuildCSLS(LineString line) {
+        LineString result = line.getFactory().createLineString(line.getCoordinates());
+        result.setSRID(line.getSRID());
+        return result; 
+    }
+
+    private static MultiPoint rebuildCSMP(MultiPoint mp) {
+        Point[] points = new Point[mp.getNumGeometries()];
+        for (int i=0; i < points.length; i++) {
+            points[i] = rebuildCSPoint((Point) mp.getGeometryN(i));
+        }
+        MultiPoint result = mp.getFactory().createMultiPoint(points);
+        result.setSRID(mp.getSRID());
+        return result;
+    }
+
+    private static Point rebuildCSPoint(Point point) {
+        Point result = point.getFactory().createPoint(point.getCoordinate());
+        result.setSRID(point.getSRID());
+        return result;       
+    }
+
     /** Pass a geometry representation through the SQL server */
     private static Geometry viaSQL(String rep, Statement stat) throws SQLException {
         ResultSet rs = stat.executeQuery("SELECT geometry_in('" + rep + "')");

Added: packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JTSShape.java
===================================================================
--- packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JTSShape.java	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JTSShape.java	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,279 @@
+package org.postgis.jts;
+
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.PathIterator;
+import java.awt.geom.Point2D;
+import java.awt.geom.Rectangle2D;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.CoordinateSequence;
+import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.GeometryCollection;
+import com.vividsolutions.jts.geom.GeometryFactory;
+import com.vividsolutions.jts.geom.LineString;
+import com.vividsolutions.jts.geom.LinearRing;
+import com.vividsolutions.jts.geom.Point;
+import com.vividsolutions.jts.geom.Polygon;
+import com.vividsolutions.jts.geom.impl.PackedCoordinateSequence;
+
+public class JTSShape implements Shape {
+    static GeometryFactory fac = new GeometryFactory();
+
+    Geometry geom;
+
+    final static LinearRing[] NOSHELLS = {};
+
+    public JTSShape(Geometry _geom) {
+        this.geom = _geom;
+    }
+    
+    public JTSShape(JtsGeometry _geom) {
+        this(_geom.getGeometry());
+    }
+    
+    public boolean contains(Point2D p) {
+        return contains(p.getX(), p.getY());
+    }
+
+    public boolean contains(double x, double y) {
+        Coordinate c = new Coordinate(x, y);
+        Point p = fac.createPoint(c);
+        return geom.contains(p);
+    }
+
+    public boolean contains(Rectangle2D r) {
+        return contains(r.getMinX(), r.getMinY(), r.getWidth(), r.getHeight());
+    }
+
+    public boolean contains(double x, double y, double w, double h) {
+        Polygon p = createRect(x, y, w, h);
+        return geom.contains(p);
+    }
+
+    protected Polygon createRect(double x, double y, double w, double h) {
+        double[] arr = { x, y, x + w, y, x + w, y + h, x, y + h, x, y };
+        PackedCoordinateSequence shell = new PackedCoordinateSequence.Double(arr, 2);
+        Polygon p = fac.createPolygon(fac.createLinearRing(shell), NOSHELLS);
+        return p;
+    }
+
+    public Rectangle2D getBounds2D() {
+        Envelope env = geom.getEnvelopeInternal();
+        return new Rectangle2D.Double(env.getMinX(), env.getMaxX(), env.getWidth(), env.getHeight());
+    }
+
+    public Rectangle getBounds() {
+        // We deal simple code for efficiency here, the getBounds() rounding
+        // rules are ugly...
+        return getBounds2D().getBounds();
+    }
+
+    public PathIterator getPathIterator(AffineTransform at) {
+        return getPathIterator(geom, at);
+    }
+
+    public PathIterator getPathIterator(AffineTransform at, double flatness) {
+        // we don't have much work here, as we only have linear segments, no
+        // "flattening" necessary.
+        return getPathIterator(at);
+    }
+
+    public boolean intersects(Rectangle2D r) {
+        return intersects(r.getMinX(), r.getMinY(), r.getWidth(), r.getHeight());
+    }
+
+    public boolean intersects(double x, double y, double w, double h) {
+        Polygon p = createRect(x, y, w, h);
+        return geom.intersects(p);
+    }
+
+    public static GeometryPathIterator getPathIterator(Geometry geometry, AffineTransform _at) {
+        if (geometry instanceof Point) {
+            return new PointPathIterator((Point) geometry, _at);
+        } else if (geometry instanceof LineString) {
+            return new LineStringPathIterator((LineString) geometry, _at);
+        } else if (geometry instanceof Polygon) {
+            return new PolygonPathIterator((Polygon) geometry, _at);
+        } else {
+            return new GeometryCollectionPathIterator((GeometryCollection) geometry, _at);
+        }
+    }
+
+    public static abstract class GeometryPathIterator implements PathIterator {
+
+        protected final AffineTransform at;
+        protected int index=0;
+
+        GeometryPathIterator(AffineTransform _at) {
+            this.at = _at;
+        }
+
+        public final int getWindingRule() {
+            return PathIterator.WIND_EVEN_ODD;
+        }
+
+        public void next() {
+            index++;
+        }
+    }
+    
+    public static class PointPathIterator extends GeometryPathIterator {
+        final Point p;
+
+        public PointPathIterator(Point _p, AffineTransform _at) {
+            super(_at);
+            p = _p;
+        }
+
+        public int currentSegment(float[] coords) {
+            switch (index) {
+            case 0:
+                coords[0] = (float) p.getX();
+                coords[1] = (float) p.getY();
+                at.transform(coords, 0, coords, 0, 1);
+                return PathIterator.SEG_MOVETO;
+            case 1:
+                return PathIterator.SEG_CLOSE;
+            default:
+                throw new IllegalStateException();
+            }
+        }
+
+        public int currentSegment(double[] coords) {
+            switch (index) {
+            case 0:
+                coords[0] = p.getX();
+                coords[1] = p.getY();
+                at.transform(coords, 0, coords, 0, 1);
+                return PathIterator.SEG_MOVETO;
+            case 1:
+                return PathIterator.SEG_CLOSE;
+            default:
+                throw new IllegalStateException();
+            }
+        }
+
+        public boolean isDone() {
+            return index > 1;
+        }
+    }
+
+    public static class LineStringPathIterator extends GeometryPathIterator {
+        CoordinateSequence cs;
+
+        final boolean isRing;
+
+        public LineStringPathIterator(LineString ls, AffineTransform _at) {
+            super(_at);
+            cs = ls.getCoordinateSequence();
+            isRing = ls instanceof LinearRing;
+        }
+
+        /** only to be called from PolygonPathIterator subclass */
+        protected void reInit(CoordinateSequence _cs) {
+            cs = _cs;
+            index=0;
+        }
+        
+        public int currentSegment(float[] coords) {
+            if (index == 0) {
+                coords[0] = (float) cs.getOrdinate(index, 0);
+                coords[1] = (float) cs.getOrdinate(index, 1);
+                at.transform(coords, 0, coords, 0, 1);
+                return PathIterator.SEG_MOVETO;
+            } else if (index < cs.size()) {
+                coords[0] = (float) cs.getOrdinate(index, 0);
+                coords[1] = (float) cs.getOrdinate(index, 1);
+                at.transform(coords, 0, coords, 0, 1);
+                return PathIterator.SEG_LINETO;
+            } else if (isRing && index == cs.size()) {
+                return PathIterator.SEG_CLOSE;
+            } else {
+                throw new IllegalStateException();
+            }
+        }
+
+        public int currentSegment(double[] coords) {
+            if (index == 0) {
+                coords[0] = cs.getOrdinate(index, 0);
+                coords[1] = cs.getOrdinate(index, 1);
+                at.transform(coords, 0, coords, 0, 1);
+                return PathIterator.SEG_MOVETO;
+            } else if (index < cs.size()) {
+                coords[0] = cs.getOrdinate(index, 0);
+                coords[1] = cs.getOrdinate(index, 1);
+                at.transform(coords, 0, coords, 0, 1);
+                return PathIterator.SEG_LINETO;
+            } else if (isRing && index == cs.size()) {
+                return PathIterator.SEG_CLOSE;
+            } else {
+                throw new IllegalStateException();
+            }
+        }
+
+        public boolean isDone() {
+            return isRing ? index > cs.size() : index >= cs.size();
+        }
+    }
+    
+    public static class PolygonPathIterator extends LineStringPathIterator {
+        final Polygon pg;
+        int outerindex=-1;
+        
+        public PolygonPathIterator(Polygon _pg, AffineTransform _at) {
+            super(_pg.getExteriorRing() ,_at);
+            pg=_pg;
+            index = -1;
+        }
+
+        public boolean isDone() {
+            return outerindex >= pg.getNumInteriorRing();
+        }
+        
+        public void next() {
+            super.next();
+            if (super.isDone()) {
+                outerindex++;
+                if (outerindex < pg.getNumInteriorRing()) {
+                    super.reInit(pg.getInteriorRingN(outerindex).getCoordinateSequence());
+                }
+            }
+        }
+    }
+
+    public static class GeometryCollectionPathIterator extends GeometryPathIterator {
+        final GeometryCollection coll;
+        GeometryPathIterator current;
+
+        public GeometryCollectionPathIterator(GeometryCollection _coll, AffineTransform _at) {
+            super(_at);
+            coll = _coll;
+            current = getPathIterator(coll.getGeometryN(index), _at);
+        }
+
+        public boolean isDone() {
+            return index > coll.getNumGeometries();
+        }
+        
+        public void next() {
+            current.next();
+            if (current.isDone()) {
+                index++;
+                if (index < coll.getNumGeometries()) {
+                    current = getPathIterator(coll.getGeometryN(index), at);
+                }
+            }
+        }
+
+        public int currentSegment(float[] coords) {
+            return current.currentSegment(coords);
+        }
+
+        public int currentSegment(double[] coords) {
+            return current.currentSegment(coords);
+        }
+    }
+}

Modified: packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JtsBinaryWriter.java
===================================================================
--- packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JtsBinaryWriter.java	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JtsBinaryWriter.java	2007-04-13 07:15:27 UTC (rev 758)
@@ -19,7 +19,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
  * http://www.gnu.org.
  * 
- * $Id: JtsBinaryWriter.java 2497 2006-10-02 23:26:34Z mschaber $
+ * $Id: JtsBinaryWriter.java 2555 2006-12-18 12:58:49Z mschaber $
  */
 package org.postgis.jts;
 
@@ -107,9 +107,17 @@
 
     /** Parse a geometry starting at offset. */
     protected void writeGeometry(Geometry geom, ValueSetter dest) {
-        final int dimension = getCoordDim(geom);
-        if (dimension < 2 || dimension > 4) {
-            throw new IllegalArgumentException("Unsupported geometry dimensionality: " + dimension);
+        final int dimension;
+        if (geom == null) {
+            throw new NullPointerException();
+        } else if (geom.isEmpty()) {
+            // don't set any flag bits
+            dimension = 0;
+        } else {
+            dimension = getCoordDim(geom);
+            if (dimension < 2 || dimension > 4) {
+                throw new IllegalArgumentException("Unsupported geometry dimensionality: " + dimension);
+            }
         }
         // write endian flag
         dest.setByte(dest.endian);
@@ -123,13 +131,15 @@
         if (dimension == 4) {
             typeword |= 0x40000000;
         }
-        if (checkSrid(geom)) {
+
+        final boolean haveSrid = checkSrid(geom);
+        if (haveSrid) {
             typeword |= 0x20000000;
         }
 
         dest.setInt(typeword);
 
-        if (checkSrid(geom)) {
+        if (haveSrid) {
             dest.setInt(geom.getSRID());
         }
 
@@ -161,7 +171,11 @@
     }
 
     public static int getWKBType(Geometry geom) {
-        if (geom instanceof Point) {
+        // We always write emtpy geometries as emtpy collections - for OpenGIS
+        // conformance
+        if (geom.isEmpty()) {
+            return org.postgis.Geometry.GEOMETRYCOLLECTION;
+        } else if (geom instanceof Point) {
             return org.postgis.Geometry.POINT;
         } else if (geom instanceof com.vividsolutions.jts.geom.LineString) {
             return org.postgis.Geometry.LINESTRING;
@@ -173,7 +187,7 @@
             return org.postgis.Geometry.MULTILINESTRING;
         } else if (geom instanceof com.vividsolutions.jts.geom.MultiPolygon) {
             return org.postgis.Geometry.MULTIPOLYGON;
-        } else if (geom instanceof com.vividsolutions.jts.geom.GeometryCollection) {
+        } if (geom instanceof com.vividsolutions.jts.geom.GeometryCollection) {
             return org.postgis.Geometry.GEOMETRYCOLLECTION;
         } else {
             throw new IllegalArgumentException("Unknown Geometry Type: " + geom.getClass().getName());
@@ -300,22 +314,6 @@
         return result;
     }
 
-    /**
-     * Estimate an Array of "slim" Points (without endianness and type, part of
-     * LinearRing and Linestring, but not MultiPoint!
-     */
-    private int estimatePointArray(int length, Point example) {
-        // number of points
-        int result = 4;
-
-        // And the amount of the points itsself, in consistent geometries
-        // all points have equal size.
-        if (length > 0) {
-            result += length * estimatePoint(example);
-        }
-        return result;
-    }
-
     /** Estimate an array of "fat" Points */
     private int estimateMultiPoint(MultiPoint geom) {
         // int size
@@ -332,7 +330,7 @@
         if (geom == null || geom.getNumGeometries() == 0) {
             return 0;
         } else {
-            return estimatePointArray(geom.getNumPoints(), geom.getStartPoint());
+            return 4 + 8 * getCoordSequenceDim(geom.getCoordinateSequence()) * geom.getCoordinateSequence().size();
         }
     }
 
@@ -362,12 +360,35 @@
     }
 
     public static final int getCoordDim(Geometry geom) {
-        // TODO: Fix geometries with more dimensions
-        // geom.getFactory().getCoordinateSequenceFactory()
-        if (geom == null) {
+        if (geom.isEmpty()) {
             return 0;
+        }
+        if (geom instanceof Point) {
+            return getCoordSequenceDim(((Point) geom).getCoordinateSequence());
+        } else if (geom instanceof LineString) {
+            return getCoordSequenceDim(((LineString) geom).getCoordinateSequence());
+        } else if (geom instanceof Polygon) {
+            return getCoordSequenceDim(((Polygon) geom).getExteriorRing().getCoordinateSequence());
         } else {
-            return 2;
+            return getCoordDim(geom.getGeometryN(0));
         }
     }
+
+    public static final int getCoordSequenceDim(CoordinateSequence coords) {
+        if (coords == null || coords.size() == 0)
+            return 0;
+        // JTS has a really strange way to handle dimensions!
+        // Just have a look at PackedCoordinateSequence and
+        // CoordinateArraySequence
+        int dimensions = coords.getDimension();
+        if (dimensions == 3) {
+            // CoordinateArraySequence will always return 3, so we have to
+            // check, if
+            // the third ordinate contains NaN, then the geom is actually
+            // 2-dimensional
+            return Double.isNaN(coords.getOrdinate(0, CoordinateSequence.Z)) ? 2 : 3;
+        } else {
+            return dimensions;
+        }
+    }
 }

Modified: packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JtsWrapper.java
===================================================================
--- packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JtsWrapper.java	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/java/jdbc/jtssrc/org/postgis/jts/JtsWrapper.java	2007-04-13 07:15:27 UTC (rev 758)
@@ -20,18 +20,20 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
  * http://www.gnu.org.
  * 
- * $Id: JtsWrapper.java 1977 2005-10-20 15:58:52Z mschaber $
+ * $Id: JtsWrapper.java 2570 2007-01-08 10:48:31Z mschaber $
  */
 
 package org.postgis.jts;
 
-import org.postgresql.Driver;
-import org.postgresql.PGConnection;
-
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
+import org.postgresql.Driver;
+import org.postgresql.PGConnection;
+
 /**
  * DriverWrapper
  * 
@@ -55,9 +57,11 @@
  */
 public class JtsWrapper extends Driver {
 
+    protected static final Logger logger = Logger.getLogger("org.postgis.DriverWrapper");
+
     private static final String POSTGRES_PROTOCOL = "jdbc:postgresql:";
     private static final String POSTGIS_PROTOCOL = "jdbc:postgres_jts:";
-    public static final String REVISION = "$Revision: 1977 $";
+    public static final String REVISION = "$Revision: 2570 $";
 
     public JtsWrapper() {
         super();
@@ -68,7 +72,7 @@
             // Try to register ourself to the DriverManager
             java.sql.DriverManager.registerDriver(new JtsWrapper());
         } catch (SQLException e) {
-            Driver.info("Error registering PostgreSQL Jts Wrapper Driver", e);
+            logger.log(Level.WARNING, "Error registering PostgreSQL Jts Wrapper Driver", e);
         }
     }
 

Modified: packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapper.java
===================================================================
--- packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapper.java	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapper.java	2007-04-13 07:15:27 UTC (rev 758)
@@ -19,18 +19,20 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
  * http://www.gnu.org.
  * 
- * $Id: DriverWrapper.java 1978 2005-10-20 16:04:03Z mschaber $
+ * $Id: DriverWrapper.java 2570 2007-01-08 10:48:31Z mschaber $
  */
 
 package org.postgis;
 
-import org.postgresql.Driver;
-import org.postgresql.PGConnection;
-
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
+import org.postgresql.Driver;
+import org.postgresql.PGConnection;
+
 /**
  * DriverWrapper
  * 
@@ -69,9 +71,11 @@
  */
 public class DriverWrapper extends Driver {
 
+    protected static final Logger logger = Logger.getLogger("org.postgis.DriverWrapper");
+    
     public static final String POSTGRES_PROTOCOL = "jdbc:postgresql:";
     public static final String POSTGIS_PROTOCOL = "jdbc:postgresql_postGIS:";
-    public static final String REVISION = "$Revision: 1978 $";
+    public static final String REVISION = "$Revision: 2570 $";
     protected static TypesAdder ta72 = null;
     protected static TypesAdder ta74 = null;
     protected static TypesAdder ta80 = null;
@@ -90,7 +94,7 @@
         typesAdder = getTypesAdder(this);
         // The debug method is @since 7.2
         if (super.getMajorVersion() > 8 || super.getMinorVersion() > 1) {
-            Driver.debug(this.getClass().getName() + " loaded TypesAdder: "
+            logger.fine(this.getClass().getName() + " loaded TypesAdder: "
                     + typesAdder.getClass().getName());
         }
     }
@@ -130,7 +134,7 @@
             // Try to register ourself to the DriverManager
             java.sql.DriverManager.registerDriver(new DriverWrapper());
         } catch (SQLException e) {
-            Driver.info("Error registering PostGIS Wrapper Driver", e);
+            logger.log(Level.WARNING, "Error registering PostGIS Wrapper Driver", e);
         }
     }
 

Modified: packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapperAutoprobe.java
===================================================================
--- packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapperAutoprobe.java	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapperAutoprobe.java	2007-04-13 07:15:27 UTC (rev 758)
@@ -19,7 +19,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
  * http://www.gnu.org.
  * 
- * $Id: DriverWrapperAutoprobe.java 1622 2005-04-15 14:04:34Z mschaber $
+ * $Id: DriverWrapperAutoprobe.java 2570 2007-01-08 10:48:31Z mschaber $
  */
 
 package org.postgis;
@@ -30,6 +30,7 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.logging.Level;
 
 /**
  * DriverWrapperAutoprobe
@@ -53,7 +54,7 @@
 public class DriverWrapperAutoprobe extends DriverWrapper {
 
     public static final String POSTGIS_AUTOPROTOCOL = "jdbc:postgresql_autogis:";
-    public static final String REVISIONAUTO = "$Revision: 1622 $";
+    public static final String REVISIONAUTO = "$Revision: 2570 $";
 
     /**
      * Default constructor.
@@ -67,7 +68,7 @@
             // Try to register ourself to the DriverManager
             java.sql.DriverManager.registerDriver(new DriverWrapperAutoprobe());
         } catch (SQLException e) {
-            Driver.info("Error registering PostGIS LW Wrapper Driver", e);
+            logger.log(Level.WARNING, "Error registering PostGIS LW Wrapper Driver", e);
         }
     }
 

Modified: packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapperLW.java
===================================================================
--- packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapperLW.java	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/java/jdbc/src/org/postgis/DriverWrapperLW.java	2007-04-13 07:15:27 UTC (rev 758)
@@ -19,7 +19,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit the web at
  * http://www.gnu.org.
  * 
- * $Id: DriverWrapperLW.java 1622 2005-04-15 14:04:34Z mschaber $
+ * $Id: DriverWrapperLW.java 2570 2007-01-08 10:48:31Z mschaber $
  */
 
 package org.postgis;
@@ -28,6 +28,7 @@
 
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.util.logging.Level;
 
 /**
  * DriverWrapperLW
@@ -48,7 +49,7 @@
 public class DriverWrapperLW extends DriverWrapper {
 
     public static final String POSTGIS_LWPROTOCOL = "jdbc:postgresql_lwgis:";
-    public static final String REVISIONLW = "$Revision: 1622 $";
+    public static final String REVISIONLW = "$Revision: 2570 $";
 
     /**
      * Default constructor.
@@ -62,7 +63,7 @@
             // Try to register ourself to the DriverManager
             java.sql.DriverManager.registerDriver(new DriverWrapperLW());
         } catch (SQLException e) {
-            Driver.info("Error registering PostGIS LW Wrapper Driver", e);
+            logger.log(Level.WARNING, "Error registering PostGIS LW Wrapper Driver", e);
         }
     }
 

Modified: packages/postgis/upstream/lwgeom/Makefile
===================================================================
--- packages/postgis/upstream/lwgeom/Makefile	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/Makefile	2007-04-13 07:15:27 UTC (rev 758)
@@ -84,7 +84,7 @@
 
 SA_OBJS=measures.o box2d.o ptarray.o lwgeom_api.o lwgeom.o lwpoint.o lwline.o lwpoly.o lwmpoint.o lwmline.o lwmpoly.o lwcollection.o $(GEOS_WRAPPER) $(JTS_WRAPPER) wktunparse.o lwgparse.o wktparse.tab.o lex.yy.o vsprintf.o
 
-OBJS=$(SA_OBJS) liblwgeom.o lwgeom_pg.o lwgeom_debug.o lwgeom_spheroid.o lwgeom_ogc.o lwgeom_functions_analytic.o $(JTS_OBJ) lwgeom_inout.o lwgeom_estimate.o lwgeom_functions_basic.o lwgeom_gist.o lwgeom_btree.o lwgeom_transform.o stringBuffer.o lwgeom_box.o lwgeom_box3d.o lwgeom_box2dfloat4.o lwgeom_chip.o lwgeom_svg.o lwgeom_gml.o lwgeom_triggers.o lwgeom_dump.o lwgeom_functions_lrs.o long_xact.o
+OBJS=$(SA_OBJS) liblwgeom.o lwgeom_pg.o lwgeom_debug.o lwgeom_spheroid.o lwgeom_ogc.o lwgeom_functions_analytic.o $(JTS_OBJ) lwgeom_inout.o lwgeom_estimate.o lwgeom_functions_basic.o lwgeom_gist.o lwgeom_btree.o lwgeom_transform.o stringBuffer.o lwgeom_box.o lwgeom_box3d.o lwgeom_box2dfloat4.o lwgeom_chip.o lwgeom_svg.o lwgeom_gml.o lwgeom_kml.o lwgeom_triggers.o lwgeom_dump.o lwgeom_functions_lrs.o long_xact.o lwcurve.o lwcompound.o lwcurvepoly.o lwmcurve.o lwmsurface.o lwgeom_sqlmm.o
 
 #OTHERS=y.output lex.yy.c wktparse.tab.c wktparse.tab.h lwpostgis.sql
 OTHERS=y.output postgis_geos_version.h
@@ -128,10 +128,10 @@
 ../lwpostgis_upgrade.sql: ../lwpostgis.sql ../utils/postgis_proc_upgrade.pl
 	$(PERL) ../utils/postgis_proc_upgrade.pl ../lwpostgis.sql > ../lwpostgis_upgrade.sql
 
-../lwpostgis.sql: lwpostgis.sql.in long_xact.sql
+../lwpostgis.sql: lwpostgis.sql.in long_xact.sql.in sqlmm.sql.in sqldefines.h 
 	cpp -P -traditional-cpp -DUSE_VERSION=$(USE_VERSION) $< | sed -e 's:@MODULE_FILENAME@:$(MODULE_FILENAME):g;s:@POSTGIS_VERSION@:$(POSTGIS_VERSION):g;s:@POSTGIS_SCRIPTS_VERSION@:$(SCRIPTS_VERSION):g;s/@POSTGIS_BUILD_DATE@/$(POSTGIS_BUILD_DATE)/g' | grep -v '^#' > $@
 
-../regress/lwpostgis.sql: lwpostgis.sql.in long_xact.sql
+../regress/lwpostgis.sql: lwpostgis.sql.in long_xact.sql.in sqlmm.sql.in sqldefines.h
 	cpp -P -traditional-cpp -DUSE_VERSION=$(USE_VERSION) $< | sed -e 's#@MODULE_FILENAME@#$(REGRESS_MODULE_FILENAME)#g;s#@POSTGIS_VERSION@#$(POSTGIS_VERSION)#g;s#@POSTGIS_SCRIPTS_VERSION@#$(SCRIPTS_VERSION)#g;s/@POSTGIS_BUILD_DATE@/$(POSTGIS_BUILD_DATE)/g' | grep -v '^#' > $@
 
 install: all install-lib-shared install-lwgeom-scripts
@@ -157,7 +157,7 @@
 clean-lwgeom-lib: clean-lib
 
 clean distclean: clean-lwgeom-lib
-	rm -f *.o *.so *.a test $(OTHERS)
+	rm -f *.o *.so *.a ../lwpostgis.sql ../lwpostgis_upgrade.sql test $(OTHERS)
 
 maintainer-clean: clean
 	rm  -f lex.yy.c wktparse.tab.c wktparse.tab.h

Modified: packages/postgis/upstream/lwgeom/SERIALIZED_FORM
===================================================================
--- packages/postgis/upstream/lwgeom/SERIALIZED_FORM	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/SERIALIZED_FORM	2007-04-13 07:15:27 UTC (rev 758)
@@ -55,6 +55,12 @@
       wkbMultiPolygon = 6
       wkbGeometryCollection = 7
 
+* Note that the following values do not correspond to wkb type values.
+      CircularString = 8
+      CompoundCurve = 9
+      CurvePolygon = 13
+      MultiCurve = 14
+      MultiSurface = 15
 
 ==Bounding box and SRID==
 
@@ -119,6 +125,24 @@
 	<UINT32> -- number of elements in following ORDINATE_ARRAY
 	<ORDINATE_ARRAY>
 
+=CircularString=
+
+A CircularString geometry is as follows:
+
+        <COMMON_HEADER>
+        <UINT32> -- number of elements in following ORDINATE_ARRAY
+        <ORDINATE_ARRAY>
+
+=CompoundString=
+
+A CompoundString geometry is as follows:
+
+        <COMMON_HEADER>
+        <UINT32> -- number of segments
+        One or more geometries as specified by previous uint32:
+                <SERIALIZED_GEOMETRY> -- Must be some combination of 
+                                         LineStrings and CircularStrings.
+
 =Polygon=
 
 A Polygon geometry is as follows:
@@ -132,6 +156,17 @@
 		<UINT32> -- number of elements in following ORDINATE_ARRAY
 		<ORDINATE_ARRAY> -- single element
 
+=CurvePolygon=                
+
+A CurvePolygon geometry is as follows:
+
+        <COMMON_HEADER>
+        <UINT32> -- number of rings
+        One or more geometries as specified by previous uint32:
+                <SERIALIZED_GEOMETRY> -- Must be some combination of 
+                                         LineStrings and CircularStrings.
+                                         CompoundString are not yet supported.
+
 =Collections=
 
 All collection types (MultiPoint, MultiLineString, MultiPolygon,

Modified: packages/postgis/upstream/lwgeom/lex.yy.c
===================================================================
--- packages/postgis/upstream/lwgeom/lex.yy.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lex.yy.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -20,7 +20,7 @@
 /* A lexical scanner generated by flex */
 
 /* Scanner skeleton version:
- * $Header$
+ * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
  */
 
 #define FLEX_SCANNER
@@ -28,8 +28,9 @@
 #define YY_FLEX_MINOR_VERSION 5
 
 #include <stdio.h>
-#include <errno.h>
+#include <unistd.h>
 
+
 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
 #ifdef c_plusplus
 #ifndef __cplusplus
@@ -41,15 +42,6 @@
 #ifdef __cplusplus
 
 #include <stdlib.h>
-#ifndef _WIN32
-#include <unistd.h>
-#else
-#ifndef YY_ALWAYS_INTERACTIVE
-#ifndef YY_NEVER_INTERACTIVE
-extern int isatty YY_PROTO(( int ));
-#endif
-#endif
-#endif
 
 /* Use prototypes in function declarations. */
 #define YY_USE_PROTOS
@@ -319,13 +311,13 @@
         6,    6,    7,    6,    6,    6,    6,    6,    6,    6,
         9,   10,    6,    6,   11,    6,    6,    6,   12,    6,
         6,    6,    6,    6,    6,    6,    6,    6,    6,   13,
-        6,   14,    6,    6,    6,    6,    6,    6,    6,   15,
+        6,   14,    6,    6,    6,    6,    6,   15,    6,   16,
 
-        6,   16,    6,    6,    6,    6,   17,   18,    6,    6,
-       19,    6,    6,   20,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,   15,    6,   16,    6,    6,    6,    6,   17,   18,
-        6,    6,   19,    6,    6,   20,    6,    6,    6,    6,
+        6,   17,    6,    6,    6,    6,   18,   19,    6,    6,
+       20,    6,    6,   21,    6,    6,    6,    6,    6,    6,
+        6,    6,    6,    6,    6,    6,    6,    6,    6,   15,
+        6,   16,    6,   17,    6,    6,    6,    6,   18,   19,
+        6,    6,   20,    6,    6,   21,    6,    6,    6,    6,
         6,    6,    6,    6,    6,    6,    6,    6
     },
 
@@ -337,12 +329,12 @@
 
         9,   10,    6,    6,   11,    6,    6,    6,   12,    6,
         6,    6,    6,    6,    6,    6,    6,    6,    6,   13,
-        6,   14,    6,    6,    6,    6,    6,    6,    6,   15,
-        6,   16,    6,    6,    6,    6,   17,   18,    6,    6,
-       19,    6,    6,   20,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,   15,    6,   16,    6,    6,    6,    6,   17,   18,
-        6,    6,   19,    6,    6,   20,    6,    6,    6,    6,
+        6,   14,    6,    6,    6,    6,    6,   15,    6,   16,
+        6,   17,    6,    6,    6,    6,   18,   19,    6,    6,
+       20,    6,    6,   21,    6,    6,    6,    6,    6,    6,
+        6,    6,    6,    6,    6,    6,    6,    6,    6,   15,
+        6,   16,    6,   17,    6,    6,    6,    6,   18,   19,
+        6,    6,   20,    6,    6,   21,    6,    6,    6,    6,
         6,    6,    6,    6,    6,    6,    6,    6
     },
 
@@ -352,16 +344,16 @@
         8,    6,    6,    7,    6,    6,    6,    6,    6,    6,
         6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
         6,    6,    7,    6,    6,    6,    6,    6,    6,    6,
-        9,   10,    6,   21,   11,   21,   22,    6,   23,   23,
-       23,   23,   23,   23,   23,   23,   23,   23,    6,   13,
-        6,   14,    6,    6,    6,    6,    6,    6,    6,   15,
-        6,   16,    6,    6,    6,    6,   17,   18,    6,    6,
-       19,    6,    6,   20,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,   15,    6,   16,    6,    6,    6,    6,   17,   18,
+        9,   10,    6,   22,   11,   22,   23,    6,   24,   24,
+       24,   24,   24,   24,   24,   24,   24,   24,    6,   13,
+        6,   14,    6,    6,    6,    6,    6,   15,    6,   16,
+        6,   17,    6,    6,    6,    6,   18,   19,    6,    6,
+       20,    6,    6,   21,    6,    6,    6,    6,    6,    6,
+        6,    6,    6,    6,    6,    6,    6,    6,    6,   15,
+        6,   16,    6,   17,    6,    6,    6,    6,   18,   19,
 
-        6,    6,   19,    6,    6,   20,    6,    6,    6,    6,
-        6,    6,    6,    6,   21,    6,    6,    6
+        6,    6,   20,    6,    6,   21,    6,    6,    6,    6,
+        6,    6,    6,    6,   22,    6,    6,    6
     },
 
     {
@@ -369,16 +361,16 @@
         8,    6,    6,    7,    6,    6,    6,    6,    6,    6,
         6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
         6,    6,    7,    6,    6,    6,    6,    6,    6,    6,
-        9,   10,    6,   21,   11,   21,   22,    6,   23,   23,
-       23,   23,   23,   23,   23,   23,   23,   23,    6,   13,
-        6,   14,    6,    6,    6,    6,    6,    6,    6,   15,
-        6,   16,    6,    6,    6,    6,   17,   18,    6,    6,
+        9,   10,    6,   22,   11,   22,   23,    6,   24,   24,
+       24,   24,   24,   24,   24,   24,   24,   24,    6,   13,
+        6,   14,    6,    6,    6,    6,    6,   15,    6,   16,
+        6,   17,    6,    6,    6,    6,   18,   19,    6,    6,
 
-       19,    6,    6,   20,    6,    6,    6,    6,    6,    6,
-        6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
-        6,   15,    6,   16,    6,    6,    6,    6,   17,   18,
-        6,    6,   19,    6,    6,   20,    6,    6,    6,    6,
-        6,    6,    6,    6,   21,    6,    6,    6
+       20,    6,    6,   21,    6,    6,    6,    6,    6,    6,
+        6,    6,    6,    6,    6,    6,    6,    6,    6,   15,
+        6,   16,    6,   17,    6,    6,    6,    6,   18,   19,
+        6,    6,   20,    6,    6,   21,    6,    6,    6,    6,
+        6,    6,    6,    6,   22,    6,    6,    6
     },
 
     {
@@ -417,10 +409,10 @@
     },
 
     {
-        5,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   24,
-       24,   -7,   -7,   24,   -7,   -7,   -7,   -7,   -7,   -7,
+        5,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   25,
+       25,   -7,   -7,   25,   -7,   -7,   -7,   -7,   -7,   -7,
        -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,
-       -7,   -7,   24,   -7,   -7,   -7,   -7,   -7,   -7,   -7,
+       -7,   -7,   25,   -7,   -7,   -7,   -7,   -7,   -7,   -7,
        -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,
        -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,
        -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,   -7,
@@ -434,10 +426,10 @@
     },
 
     {
-        5,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   24,
-       24,   -8,   -8,   24,   -8,   -8,   -8,   -8,   -8,   -8,
+        5,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   25,
+       25,   -8,   -8,   25,   -8,   -8,   -8,   -8,   -8,   -8,
        -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,
-       -8,   -8,   24,   -8,   -8,   -8,   -8,   -8,   -8,   -8,
+       -8,   -8,   25,   -8,   -8,   -8,   -8,   -8,   -8,   -8,
        -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,
        -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,   -8,
 
@@ -508,7 +500,7 @@
       -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,
       -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,
 
-      -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,   25,   26,
+      -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,   26,   27,
       -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,
       -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,
       -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,  -12,
@@ -563,11 +555,11 @@
 
       -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,
       -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,
-      -15,  -15,  -15,  -15,  -15,  -15,  -15,   27,  -15,  -15,
+      -15,  -15,  -15,   28,  -15,  -15,  -15,  -15,  -15,   29,
+      -15,  -15,  -15,  -15,  -15,   30,  -15,  -15,  -15,  -15,
       -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,
-      -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,
-      -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,   27,
-      -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15,
+      -15,  -15,  -15,  -15,  -15,   28,  -15,  -15,  -15,  -15,
+      -15,   29,  -15,  -15,  -15,  -15,  -15,   30,  -15,  -15,
       -15,  -15,  -15,  -15,  -15,  -15,  -15,  -15
     },
 
@@ -579,11 +571,11 @@
       -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,
       -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,
       -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,
-      -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,   28,
       -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,
+      -16,  -16,  -16,  -16,  -16,  -16,  -16,   31,  -16,  -16,
       -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,
       -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,
-      -16,   28,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,
+      -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,   31,
       -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16,
 
       -16,  -16,  -16,  -16,  -16,  -16,  -16,  -16
@@ -596,12 +588,12 @@
       -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,
       -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,
       -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,
+      -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,   32,
       -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,
-      -17,  -17,  -17,   29,  -17,  -17,  -17,  -17,  -17,  -17,
       -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,
 
       -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,
-      -17,  -17,  -17,  -17,  -17,   29,  -17,  -17,  -17,  -17,
+      -17,   32,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,
       -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17,
       -17,  -17,  -17,  -17,  -17,  -17,  -17,  -17
     },
@@ -615,11 +607,11 @@
       -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,
 
       -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,
+      -18,  -18,  -18,   33,  -18,  -18,  -18,  -18,  -18,  -18,
       -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,
-      -18,  -18,  -18,  -18,  -18,   30,  -18,  -18,  -18,  -18,
       -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,
+      -18,  -18,  -18,  -18,  -18,   33,  -18,  -18,  -18,  -18,
       -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18,
-      -18,  -18,  -18,  -18,  -18,  -18,  -18,   30,  -18,  -18,
       -18,  -18,  -18,  -18,  -18,  -18,  -18,  -18
     },
 
@@ -632,11 +624,11 @@
       -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
       -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
       -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
-      -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,   31,
       -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
+      -19,  -19,  -19,  -19,  -19,   34,  -19,  -19,  -19,  -19,
       -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
       -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
-      -19,   31,  -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19,
+      -19,  -19,  -19,  -19,  -19,  -19,  -19,   34,  -19,  -19,
       -19,  -19,  -19,  -19,  -19,  -19,  -19,  -19
 
     },
@@ -649,12 +641,12 @@
       -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
       -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
       -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
+      -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,   35,
       -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
-      -20,  -20,   32,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
       -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
 
       -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
-      -20,  -20,  -20,  -20,   32,  -20,  -20,  -20,  -20,  -20,
+      -20,   35,  -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20,
       -20,  -20,  -20,  -20,  -20,  -20,  -20,  -20
     },
 
@@ -663,15 +655,15 @@
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
-      -21,  -21,  -21,  -21,  -21,  -21,   33,  -21,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   34,  -21,  -21,
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
-
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
+
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
+      -21,  -21,   36,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21,
+      -21,  -21,  -21,  -21,   36,  -21,  -21,  -21,  -21,  -21,
       -21,  -21,  -21,  -21,  -21,  -21,  -21,  -21
     },
 
@@ -681,8 +673,8 @@
       -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,
       -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,
 
-      -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,   35,   35,
-       35,   35,   35,   35,   35,   35,   35,   35,  -22,  -22,
+      -22,  -22,  -22,  -22,  -22,  -22,   37,  -22,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,  -22,  -22,
       -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,
       -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,
       -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,  -22,
@@ -698,49 +690,49 @@
       -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
       -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
       -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
-      -23,  -23,  -23,  -23,  -23,  -23,   36,  -23,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   34,  -23,  -23,
-      -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,   37,
+      -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,   39,   39,
+       39,   39,   39,   39,   39,   39,   39,   39,  -23,  -23,
       -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
       -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
       -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
-      -23,   37,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
+      -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
+      -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
 
       -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23,
       -23,  -23,  -23,  -23,  -23,  -23,  -23,  -23
     },
 
     {
-        5,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,   24,
-       24,  -24,  -24,   24,  -24,  -24,  -24,  -24,  -24,  -24,
+        5,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
       -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
-      -24,  -24,   24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
       -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
       -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
+      -24,  -24,  -24,  -24,  -24,  -24,   40,  -24,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,  -24,  -24,
+      -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,   41,
       -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
-      -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
 
       -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
       -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
+      -24,   41,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
       -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
-      -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24,
       -24,  -24,  -24,  -24,  -24,  -24,  -24,  -24
     },
 
     {
-        5,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
+        5,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,   25,
+       25,  -25,  -25,   25,  -25,  -25,  -25,  -25,  -25,  -25,
       -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
+      -25,  -25,   25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
       -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
-      -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
-      -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,   38,   38,
 
-       38,   38,   38,   38,   38,   38,   38,   38,  -25,  -25,
-      -25,  -25,  -25,  -25,  -25,   38,   38,   38,   38,   38,
-       38,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
       -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
-      -25,  -25,  -25,  -25,  -25,  -25,  -25,   38,   38,   38,
-       38,   38,   38,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
       -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
+      -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
+      -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
+      -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
+      -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
+      -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25,
       -25,  -25,  -25,  -25,  -25,  -25,  -25,  -25
     },
 
@@ -750,13 +742,13 @@
 
       -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
       -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
-      -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,   39,   39,
-       39,   39,   39,   39,   39,   39,   39,   39,  -26,  -26,
-      -26,  -26,  -26,  -26,  -26,   39,   39,   39,   39,   39,
-       39,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
+      -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,   42,   42,
+       42,   42,   42,   42,   42,   42,   42,   42,  -26,  -26,
+      -26,  -26,  -26,  -26,  -26,   42,   42,   42,   42,   42,
+       42,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
       -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
-      -26,  -26,  -26,  -26,  -26,  -26,  -26,   39,   39,   39,
-       39,   39,   39,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
+      -26,  -26,  -26,  -26,  -26,  -26,  -26,   42,   42,   42,
+       42,   42,   42,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
       -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26,
 
       -26,  -26,  -26,  -26,  -26,  -26,  -26,  -26
@@ -767,15 +759,15 @@
       -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
       -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
       -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
+      -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,   43,   43,
+       43,   43,   43,   43,   43,   43,   43,   43,  -27,  -27,
+      -27,  -27,  -27,  -27,  -27,   43,   43,   43,   43,   43,
+       43,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
       -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
-      -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
-      -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
-      -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
-       40,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
 
+      -27,  -27,  -27,  -27,  -27,  -27,  -27,   43,   43,   43,
+       43,   43,   43,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
       -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
-      -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
-      -27,  -27,   40,  -27,  -27,  -27,  -27,  -27,  -27,  -27,
       -27,  -27,  -27,  -27,  -27,  -27,  -27,  -27
     },
 
@@ -788,11 +780,11 @@
       -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
 
       -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
-      -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,   41,
       -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
+      -28,  -28,   44,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
       -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
       -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
-      -28,   41,  -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28,
+      -28,  -28,  -28,  -28,   44,  -28,  -28,  -28,  -28,  -28,
       -28,  -28,  -28,  -28,  -28,  -28,  -28,  -28
     },
 
@@ -805,11 +797,11 @@
       -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
       -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
       -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
-      -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,   42,  -29,
+      -29,  -29,  -29,  -29,  -29,  -29,  -29,   45,  -29,  -29,
       -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
       -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
+      -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,   45,
       -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
-       42,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29,
       -29,  -29,  -29,  -29,  -29,  -29,  -29,  -29
 
     },
@@ -822,12 +814,12 @@
       -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
       -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
       -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
-      -30,  -30,  -30,  -30,  -30,  -30,   43,  -30,  -30,  -30,
       -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
+      -30,  -30,   46,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
       -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
 
-      -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,   43,  -30,
       -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30,
+      -30,  -30,  -30,  -30,   46,  -30,  -30,  -30,  -30,  -30,
       -30,  -30,  -30,  -30,  -30,  -30,  -30,  -30
     },
 
@@ -840,11 +832,11 @@
       -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
       -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
 
-      -31,  -31,  -31,   44,  -31,  -31,   45,  -31,  -31,  -31,
       -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
+       47,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
       -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
-      -31,  -31,  -31,  -31,  -31,   44,  -31,  -31,   45,  -31,
       -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
+      -31,  -31,   47,  -31,  -31,  -31,  -31,  -31,  -31,  -31,
       -31,  -31,  -31,  -31,  -31,  -31,  -31,  -31
     },
 
@@ -857,11 +849,11 @@
       -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
       -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
       -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
-      -32,  -32,  -32,   46,  -32,  -32,  -32,  -32,  -32,  -32,
+      -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,   48,
       -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
       -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
-      -32,  -32,  -32,  -32,  -32,   46,  -32,  -32,  -32,  -32,
       -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
+      -32,   48,  -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32,
       -32,  -32,  -32,  -32,  -32,  -32,  -32,  -32
     },
 
@@ -871,15 +863,15 @@
       -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
       -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
       -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
-      -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,   35,   35,
-       35,   35,   35,   35,   35,   35,   35,   35,  -33,  -33,
       -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
       -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
       -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
+      -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,   49,  -33,
       -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
       -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
+      -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
 
-      -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
+       49,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33,
       -33,  -33,  -33,  -33,  -33,  -33,  -33,  -33
     },
 
@@ -888,14 +880,14 @@
       -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
       -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
       -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
-      -34,  -34,  -34,  -34,  -34,  -34,   36,  -34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   34,  -34,  -34,
-      -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,   37,
       -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
+      -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
+      -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
+      -34,  -34,  -34,  -34,  -34,  -34,   50,  -34,  -34,  -34,
 
       -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
       -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
-      -34,   37,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
+      -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,   50,  -34,
       -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34,
       -34,  -34,  -34,  -34,  -34,  -34,  -34,  -34
     },
@@ -905,15 +897,15 @@
       -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
       -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
       -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
-      -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,   35,   35,
+      -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
 
-       35,   35,   35,   35,   35,   35,   35,   35,  -35,  -35,
-      -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,   47,
       -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
       -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
+      -35,  -35,  -35,   51,  -35,  -35,   52,  -35,  -35,  -35,
       -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
-      -35,   47,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
       -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
+      -35,  -35,  -35,  -35,  -35,   51,  -35,  -35,   52,  -35,
+      -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35,
       -35,  -35,  -35,  -35,  -35,  -35,  -35,  -35
     },
 
@@ -923,13 +915,13 @@
 
       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
-      -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,   48,   48,
-       48,   48,   48,   48,   48,   48,   48,   48,  -36,  -36,
       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
+      -36,  -36,  -36,   53,  -36,  -36,  -36,  -36,  -36,  -36,
       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
+      -36,  -36,  -36,  -36,  -36,   53,  -36,  -36,  -36,  -36,
       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36,
 
       -36,  -36,  -36,  -36,  -36,  -36,  -36,  -36
@@ -940,8 +932,8 @@
       -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,
       -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,
       -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,
-      -37,  -37,  -37,   49,  -37,   49,  -37,  -37,   50,   50,
-       50,   50,   50,   50,   50,   50,   50,   50,  -37,  -37,
+      -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,   39,   39,
+       39,   39,   39,   39,   39,   39,   39,   39,  -37,  -37,
       -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,
       -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,
       -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,  -37,
@@ -957,15 +949,15 @@
       -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
       -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
       -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
-      -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,   38,   38,
+      -38,  -38,  -38,  -38,  -38,  -38,   40,  -38,   38,   38,
        38,   38,   38,   38,   38,   38,   38,   38,  -38,  -38,
 
-      -38,  -38,  -38,  -38,  -38,   38,   38,   38,   38,   38,
-       38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
+      -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,   41,
       -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
-      -38,  -38,  -38,  -38,  -38,  -38,  -38,   38,   38,   38,
-       38,   38,   38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
       -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
+      -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
+      -38,   41,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
+      -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38,
       -38,  -38,  -38,  -38,  -38,  -38,  -38,  -38
     },
 
@@ -977,12 +969,12 @@
       -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,
       -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,   39,   39,
        39,   39,   39,   39,   39,   39,   39,   39,  -39,  -39,
-      -39,  -39,  -39,  -39,  -39,   39,   39,   39,   39,   39,
-       39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,
+      -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,   54,
       -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,
-      -39,  -39,  -39,  -39,  -39,  -39,  -39,   39,   39,   39,
-       39,   39,   39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,
       -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,
+      -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,
+      -39,   54,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,
+      -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39,
       -39,  -39,  -39,  -39,  -39,  -39,  -39,  -39
 
     },
@@ -992,15 +984,15 @@
       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
+      -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,   55,   55,
+       55,   55,   55,   55,   55,   55,   55,   55,  -40,  -40,
       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
-      -40,  -40,  -40,  -40,   51,  -40,  -40,  -40,  -40,  -40,
-      -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
 
       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
-      -40,  -40,  -40,  -40,  -40,  -40,   51,  -40,  -40,  -40,
+      -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40,
       -40,  -40,  -40,  -40,  -40,  -40,  -40,  -40
     },
 
@@ -1009,14 +1001,14 @@
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
+      -41,  -41,  -41,   56,  -41,   56,  -41,  -41,   57,   57,
+       57,   57,   57,   57,   57,   57,   57,   57,  -41,  -41,
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
+
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
-
-      -41,  -41,  -41,  -41,  -41,  -41,  -41,   52,  -41,  -41,
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
-      -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,   52,
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41,
       -41,  -41,  -41,  -41,  -41,  -41,  -41,  -41
     },
@@ -1027,14 +1019,14 @@
       -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
       -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
 
+      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,   42,   42,
+       42,   42,   42,   42,   42,   42,   42,   42,  -42,  -42,
+      -42,  -42,  -42,  -42,  -42,   42,   42,   42,   42,   42,
+       42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
       -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
+      -42,  -42,  -42,  -42,  -42,  -42,  -42,   42,   42,   42,
+       42,   42,   42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
       -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
-      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,   53,
-      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
-      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
-      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
-      -42,   53,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
-      -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42,
       -42,  -42,  -42,  -42,  -42,  -42,  -42,  -42
     },
 
@@ -1044,15 +1036,15 @@
       -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
       -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
       -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
+      -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,   43,   43,
+       43,   43,   43,   43,   43,   43,   43,   43,  -43,  -43,
+      -43,  -43,  -43,  -43,  -43,   43,   43,   43,   43,   43,
+       43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
       -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
+      -43,  -43,  -43,  -43,  -43,  -43,  -43,   43,   43,   43,
+       43,   43,   43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
+
       -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
-      -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
-      -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
-      -43,  -43,  -43,  -43,   54,  -43,  -43,  -43,  -43,  -43,
-      -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
-      -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43,
-
-      -43,  -43,  -43,  -43,  -43,  -43,   54,  -43,  -43,  -43,
       -43,  -43,  -43,  -43,  -43,  -43,  -43,  -43
     },
 
@@ -1063,13 +1055,13 @@
       -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
       -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
       -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
+      -44,  -44,  -44,  -44,  -44,  -44,  -44,   58,  -44,  -44,
       -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
-      -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,   55,  -44,
 
       -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
+      -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,   58,
       -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
       -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
-       55,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44,
       -44,  -44,  -44,  -44,  -44,  -44,  -44,  -44
     },
 
@@ -1083,11 +1075,11 @@
       -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
       -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
       -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
-      -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,   56,
+       59,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
       -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
       -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
-      -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
-      -45,   56,  -45,  -45,  -45,  -45,  -45,  -45
+      -45,  -45,   59,  -45,  -45,  -45,  -45,  -45,  -45,  -45,
+      -45,  -45,  -45,  -45,  -45,  -45,  -45,  -45
     },
 
     {
@@ -1098,12 +1090,12 @@
       -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
       -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
       -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
-      -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,   57,  -46,
       -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
       -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
+      -46,  -46,  -46,  -46,  -46,  -46,   60,  -46,  -46,  -46,
       -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
-       57,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
       -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,
+      -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46,   60,  -46,
 
       -46,  -46,  -46,  -46,  -46,  -46,  -46,  -46
     },
@@ -1113,15 +1105,15 @@
       -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
       -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
       -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
-      -47,  -47,  -47,   58,  -47,   58,  -47,  -47,   59,   59,
-       59,   59,   59,   59,   59,   59,   59,   59,  -47,  -47,
       -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
       -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
       -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
+      -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
+      -47,  -47,  -47,  -47,   61,  -47,  -47,  -47,  -47,  -47,
 
       -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
       -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
-      -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47,
+      -47,  -47,  -47,  -47,  -47,  -47,   61,  -47,  -47,  -47,
       -47,  -47,  -47,  -47,  -47,  -47,  -47,  -47
     },
 
@@ -1130,14 +1122,14 @@
       -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
       -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
       -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
-      -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,   48,   48,
-       48,   48,   48,   48,   48,   48,   48,   48,  -48,  -48,
+      -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
+      -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
 
-      -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,   37,
       -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
+      -48,  -48,  -48,  -48,  -48,  -48,  -48,   62,  -48,  -48,
       -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
       -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
-      -48,   37,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
+      -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,   62,
       -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48,
       -48,  -48,  -48,  -48,  -48,  -48,  -48,  -48
     },
@@ -1148,13 +1140,13 @@
       -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
 
       -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
-      -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,   50,   50,
-       50,   50,   50,   50,   50,   50,   50,   50,  -49,  -49,
       -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
       -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
+      -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,   63,
       -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
       -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
       -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
+      -49,   63,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
       -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49,
       -49,  -49,  -49,  -49,  -49,  -49,  -49,  -49
 
@@ -1165,15 +1157,15 @@
       -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
       -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
       -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
-      -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,   50,   50,
-       50,   50,   50,   50,   50,   50,   50,   50,  -50,  -50,
       -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
       -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
       -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
       -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
+      -50,  -50,  -50,  -50,   64,  -50,  -50,  -50,  -50,  -50,
+      -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
 
       -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
-      -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50,
+      -50,  -50,  -50,  -50,  -50,  -50,   64,  -50,  -50,  -50,
       -50,  -50,  -50,  -50,  -50,  -50,  -50,  -50
     },
 
@@ -1186,12 +1178,12 @@
       -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,
       -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,
 
+      -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,   65,  -51,
       -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,
-      -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,   60,
       -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,
       -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,
-      -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,
-      -51,   60,  -51,  -51,  -51,  -51,  -51,  -51
+       65,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51,
+      -51,  -51,  -51,  -51,  -51,  -51,  -51,  -51
     },
 
     {
@@ -1202,13 +1194,13 @@
 
       -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
       -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
-      -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,   61,
       -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
       -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
+      -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,   66,
       -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
-      -52,   61,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
       -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
-      -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52
+      -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,  -52,
+      -52,   66,  -52,  -52,  -52,  -52,  -52,  -52
     },
 
     {
@@ -1219,13 +1211,13 @@
       -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
       -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
       -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
+      -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,   67,  -53,
       -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
       -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
-      -53,  -53,  -53,   62,  -53,  -53,  -53,  -53,  -53,  -53,
       -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
+       67,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
+
       -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53,
-
-      -53,  -53,  -53,  -53,  -53,   62,  -53,  -53,  -53,  -53,
       -53,  -53,  -53,  -53,  -53,  -53,  -53,  -53
     },
 
@@ -1234,15 +1226,15 @@
       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
+      -54,  -54,  -54,   68,  -54,   68,  -54,  -54,   69,   69,
+       69,   69,   69,   69,   69,   69,   69,   69,  -54,  -54,
       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
-      -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
-      -54,  -54,  -54,   63,  -54,  -54,  -54,  -54,  -54,  -54,
 
       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
-      -54,  -54,  -54,  -54,  -54,   63,  -54,  -54,  -54,  -54,
       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
+      -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54,
       -54,  -54,  -54,  -54,  -54,  -54,  -54,  -54
     },
 
@@ -1251,15 +1243,15 @@
       -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
       -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
       -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
-      -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
+      -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,   55,   55,
 
+       55,   55,   55,   55,   55,   55,   55,   55,  -55,  -55,
+      -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,   41,
       -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
       -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
       -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
-      -55,  -55,  -55,  -55,   64,  -55,  -55,  -55,  -55,  -55,
+      -55,   41,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
       -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
-      -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55,
-      -55,  -55,  -55,  -55,  -55,  -55,   64,  -55,  -55,  -55,
       -55,  -55,  -55,  -55,  -55,  -55,  -55,  -55
     },
 
@@ -1269,13 +1261,13 @@
 
       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
+      -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,   57,   57,
+       57,   57,   57,   57,   57,   57,   57,   57,  -56,  -56,
       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
-      -56,   65,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
-      -56,  -56,  -56,   65,  -56,  -56,  -56,  -56,  -56,  -56,
       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56,
 
       -56,  -56,  -56,  -56,  -56,  -56,  -56,  -56
@@ -1286,11 +1278,11 @@
       -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
       -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
       -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
+      -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,   57,   57,
+       57,   57,   57,   57,   57,   57,   57,   57,  -57,  -57,
       -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
       -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
       -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
-      -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
-      -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
 
       -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
       -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,  -57,
@@ -1303,15 +1295,15 @@
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
-      -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,   59,   59,
-       59,   59,   59,   59,   59,   59,   59,   59,  -58,  -58,
-
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
+
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
+      -58,  -58,  -58,  -58,  -58,   70,  -58,  -58,  -58,  -58,
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58,
+      -58,  -58,  -58,  -58,  -58,  -58,  -58,   70,  -58,  -58,
       -58,  -58,  -58,  -58,  -58,  -58,  -58,  -58
     },
 
@@ -1321,14 +1313,14 @@
       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
 
       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
-      -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,   59,   59,
-       59,   59,   59,   59,   59,   59,   59,   59,  -59,  -59,
       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
+      -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,   71,
       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
+      -59,   71,  -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59,
       -59,  -59,  -59,  -59,  -59,  -59,  -59,  -59
 
     },
@@ -1340,13 +1332,13 @@
       -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
       -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
       -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
+      -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,   72,
       -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
       -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
       -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
-      -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
 
+      -60,   72,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
       -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
-      -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60,
       -60,  -60,  -60,  -60,  -60,  -60,  -60,  -60
     },
 
@@ -1360,11 +1352,11 @@
       -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,
 
       -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,
-      -61,  -61,  -61,  -61,   66,  -61,  -61,  -61,  -61,  -61,
+      -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,   73,
       -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,
       -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,
-      -61,  -61,  -61,  -61,  -61,  -61,   66,  -61,  -61,  -61,
-      -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61
+      -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,  -61,
+      -61,   73,  -61,  -61,  -61,  -61,  -61,  -61
     },
 
     {
@@ -1375,12 +1367,12 @@
 
       -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,
       -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,
+      -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,   74,
       -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,
       -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,
-      -62,  -62,  -62,  -62,   67,  -62,  -62,  -62,  -62,  -62,
       -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,
+      -62,   74,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,
       -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62,
-      -62,  -62,  -62,  -62,  -62,  -62,   67,  -62,  -62,  -62,
       -62,  -62,  -62,  -62,  -62,  -62,  -62,  -62
     },
 
@@ -1393,12 +1385,12 @@
       -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,
       -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,
       -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,
-      -63,  -63,  -63,  -63,  -63,  -63,   68,  -63,  -63,  -63,
-       69,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,
       -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,
-      -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,   68,  -63,
+      -63,  -63,  -63,   75,  -63,  -63,  -63,  -63,  -63,  -63,
+      -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,
+      -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63,
 
-      -63,  -63,   69,  -63,  -63,  -63,  -63,  -63,  -63,  -63,
+      -63,  -63,  -63,  -63,  -63,   75,  -63,  -63,  -63,  -63,
       -63,  -63,  -63,  -63,  -63,  -63,  -63,  -63
     },
 
@@ -1410,11 +1402,11 @@
       -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
       -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
       -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
-      -64,  -64,  -64,  -64,  -64,  -64,  -64,   70,  -64,  -64,
+      -64,  -64,  -64,   76,  -64,  -64,  -64,  -64,  -64,  -64,
 
       -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
       -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
-      -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,   70,
+      -64,  -64,  -64,  -64,  -64,   76,  -64,  -64,  -64,  -64,
       -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64,
       -64,  -64,  -64,  -64,  -64,  -64,  -64,  -64
     },
@@ -1428,11 +1420,11 @@
 
       -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
       -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
-      -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,   71,
       -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
+      -65,  -65,  -65,  -65,   77,  -65,  -65,  -65,  -65,  -65,
       -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
       -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
-      -65,   71,  -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65,
+      -65,  -65,  -65,  -65,  -65,  -65,   77,  -65,  -65,  -65,
       -65,  -65,  -65,  -65,  -65,  -65,  -65,  -65
     },
 
@@ -1445,11 +1437,11 @@
       -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,
       -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,
       -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,
+      -66,   78,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,
       -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,
-      -66,  -66,   72,  -66,  -66,  -66,  -66,  -66,  -66,  -66,
       -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,
+      -66,  -66,  -66,   78,  -66,  -66,  -66,  -66,  -66,  -66,
       -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66,
-      -66,  -66,  -66,  -66,   72,  -66,  -66,  -66,  -66,  -66,
 
       -66,  -66,  -66,  -66,  -66,  -66,  -66,  -66
     },
@@ -1463,11 +1455,11 @@
       -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,
       -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,
       -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,
-      -67,  -67,   73,  -67,  -67,  -67,  -67,  -67,  -67,  -67,
+      -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,
 
       -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,
       -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,
-      -67,  -67,  -67,  -67,   73,  -67,  -67,  -67,  -67,  -67,
+      -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67,
       -67,  -67,  -67,  -67,  -67,  -67,  -67,  -67
     },
 
@@ -1476,14 +1468,14 @@
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,
+      -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,   69,   69,
+       69,   69,   69,   69,   69,   69,   69,   69,  -68,  -68,
+
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,
-
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,
-      -68,  -68,  -68,   74,  -68,  -68,  -68,  -68,  -68,  -68,
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,
-      -68,  -68,  -68,  -68,  -68,   74,  -68,  -68,  -68,  -68,
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68,
       -68,  -68,  -68,  -68,  -68,  -68,  -68,  -68
     },
@@ -1494,14 +1486,14 @@
       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
 
       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
+      -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,   69,   69,
+       69,   69,   69,   69,   69,   69,   69,   69,  -69,  -69,
       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
-      -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,   75,
       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
-      -69,   75,  -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69,
       -69,  -69,  -69,  -69,  -69,  -69,  -69,  -69
 
     },
@@ -1514,12 +1506,12 @@
       -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,
       -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,
       -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,
+      -70,  -70,  -70,  -70,  -70,  -70,   79,  -70,  -70,  -70,
       -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,
       -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,
-      -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,
 
+      -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,   79,  -70,
       -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,
-      -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70,
       -70,  -70,  -70,  -70,  -70,  -70,  -70,  -70
     },
 
@@ -1532,11 +1524,11 @@
       -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,
       -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,
 
-      -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,   76,  -71,
       -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,
+      -71,  -71,  -71,  -71,  -71,   80,  -71,  -71,  -71,  -71,
       -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,
       -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,
-       76,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71,
+      -71,  -71,  -71,  -71,  -71,  -71,  -71,   80,  -71,  -71,
       -71,  -71,  -71,  -71,  -71,  -71,  -71,  -71
     },
 
@@ -1550,11 +1542,11 @@
       -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
       -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
       -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
-      -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,   77,
+       81,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
       -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
       -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
-      -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
-      -72,   77,  -72,  -72,  -72,  -72,  -72,  -72
+      -72,  -72,   81,  -72,  -72,  -72,  -72,  -72,  -72,  -72,
+      -72,  -72,  -72,  -72,  -72,  -72,  -72,  -72
     },
 
     {
@@ -1566,10 +1558,10 @@
       -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
       -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
       -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
-      -73,  -73,  -73,   78,  -73,  -73,  -73,  -73,  -73,  -73,
       -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
       -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
-      -73,  -73,  -73,  -73,  -73,   78,  -73,  -73,  -73,  -73,
+      -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
+      -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
 
       -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73,
       -73,  -73,  -73,  -73,  -73,  -73,  -73,  -73
@@ -1583,12 +1575,12 @@
       -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,
       -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,
       -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,
-      -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,   79,  -74,
+      -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,
 
+      -74,  -74,  -74,  -74,   82,  -74,  -74,  -74,  -74,  -74,
       -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,
       -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,
-      -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,
-       79,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74,
+      -74,  -74,  -74,  -74,  -74,  -74,   82,  -74,  -74,  -74,
       -74,  -74,  -74,  -74,  -74,  -74,  -74,  -74
     },
 
@@ -1601,11 +1593,11 @@
 
       -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
       -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
-      -75,  -75,  -75,   80,  -75,  -75,   81,  -75,  -75,  -75,
       -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
+      -75,  -75,  -75,  -75,   83,  -75,  -75,  -75,  -75,  -75,
       -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
-      -75,  -75,  -75,  -75,  -75,   80,  -75,  -75,   81,  -75,
       -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75,
+      -75,  -75,  -75,  -75,  -75,  -75,   83,  -75,  -75,  -75,
       -75,  -75,  -75,  -75,  -75,  -75,  -75,  -75
     },
 
@@ -1617,12 +1609,12 @@
       -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
       -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
       -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
-      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
-      -76,  -76,  -76,  -76,  -76,  -76,  -76,   82,  -76,  -76,
-      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
-      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
-      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,   82,
-      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,
+      -76,  -76,  -76,  -76,  -76,  -76,  -76,   84,  -76,  -76,
+      -76,  -76,  -76,  -76,  -76,  -76,   85,  -76,  -76,  -76,
+       86,  -76,  -76,   87,  -76,  -76,  -76,  -76,  -76,  -76,
+      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,   84,
+      -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76,   85,  -76,
+      -76,  -76,   86,  -76,  -76,   87,  -76,  -76,  -76,  -76,
 
       -76,  -76,  -76,  -76,  -76,  -76,  -76,  -76
     },
@@ -1634,12 +1626,12 @@
       -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
       -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
       -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
-      -77,  -77,  -77,  -77,  -77,  -77,  -77,   83,  -77,  -77,
       -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
+      -77,  -77,  -77,  -77,  -77,  -77,  -77,   88,  -77,  -77,
       -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
 
-      -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,   83,
       -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
+      -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,   88,
       -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77,
       -77,  -77,  -77,  -77,  -77,  -77,  -77,  -77
     },
@@ -1653,11 +1645,11 @@
       -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
 
       -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
-      -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,   84,  -78,
+      -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,   89,
       -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
       -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
       -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
-       84,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
+      -78,   89,  -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78,
       -78,  -78,  -78,  -78,  -78,  -78,  -78,  -78
     },
 
@@ -1669,11 +1661,11 @@
       -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
       -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
       -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
-      -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,   85,
+      -79,  -79,  -79,  -79,  -79,   90,  -79,  -79,  -79,  -79,
       -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
       -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
+      -79,  -79,  -79,  -79,  -79,  -79,  -79,   90,  -79,  -79,
       -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
-      -79,   85,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
       -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79,
       -79,  -79,  -79,  -79,  -79,  -79,  -79,  -79
 
@@ -1687,12 +1679,12 @@
       -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
       -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
       -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
-      -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,   86,  -80,
+      -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,   91,  -80,
       -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
       -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
 
       -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
-       86,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
+       91,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80,
       -80,  -80,  -80,  -80,  -80,  -80,  -80,  -80
     },
 
@@ -1705,12 +1697,12 @@
       -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,
       -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,
 
+      -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,   92,
       -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,
-      -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,   87,
       -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,
       -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,
-      -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,
-      -81,   87,  -81,  -81,  -81,  -81,  -81,  -81
+      -81,   92,  -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81,
+      -81,  -81,  -81,  -81,  -81,  -81,  -81,  -81
     },
 
     {
@@ -1723,10 +1715,10 @@
       -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
       -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
       -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
+      -82,  -82,   93,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
       -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
       -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
-      -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
-      -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82,
+      -82,  -82,  -82,  -82,   93,  -82,  -82,  -82,  -82,  -82,
       -82,  -82,  -82,  -82,  -82,  -82,  -82,  -82
     },
 
@@ -1739,12 +1731,12 @@
       -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
       -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
       -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
-      -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,   88,
       -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
+      -83,  -83,   94,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
       -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
       -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
 
-      -83,   88,  -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83,
+      -83,  -83,  -83,  -83,   94,  -83,  -83,  -83,  -83,  -83,
       -83,  -83,  -83,  -83,  -83,  -83,  -83,  -83
     },
 
@@ -1756,12 +1748,12 @@
       -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,
       -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,
       -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,
-      -84,   89,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,
+      -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,
 
+      -84,  -84,  -84,  -84,  -84,   95,  -84,  -84,  -84,  -84,
       -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,
       -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,
-      -84,  -84,  -84,   89,  -84,  -84,  -84,  -84,  -84,  -84,
-      -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84,
+      -84,  -84,  -84,  -84,  -84,  -84,  -84,   95,  -84,  -84,
       -84,  -84,  -84,  -84,  -84,  -84,  -84,  -84
     },
 
@@ -1774,11 +1766,11 @@
 
       -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,
       -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,
+      -85,  -85,  -85,   96,  -85,  -85,  -85,  -85,  -85,  -85,
       -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,
-      -85,  -85,  -85,   90,  -85,  -85,  -85,  -85,  -85,  -85,
       -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,
+      -85,  -85,  -85,  -85,  -85,   96,  -85,  -85,  -85,  -85,
       -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85,
-      -85,  -85,  -85,  -85,  -85,   90,  -85,  -85,  -85,  -85,
       -85,  -85,  -85,  -85,  -85,  -85,  -85,  -85
     },
 
@@ -1791,11 +1783,11 @@
       -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
       -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
       -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
+      -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,   97,
       -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
-      -86,  -86,  -86,  -86,   91,  -86,  -86,  -86,  -86,  -86,
       -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
       -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
-      -86,  -86,  -86,  -86,  -86,  -86,   91,  -86,  -86,  -86,
+      -86,   97,  -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86,
 
       -86,  -86,  -86,  -86,  -86,  -86,  -86,  -86
     },
@@ -1808,12 +1800,12 @@
       -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,
       -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,
       -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,
-      -87,   92,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,
       -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,
+      -87,  -87,  -87,  -87,  -87,   98,  -87,  -87,  -87,  -87,
 
       -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,
-      -87,  -87,  -87,   92,  -87,  -87,  -87,  -87,  -87,  -87,
       -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87,
+      -87,  -87,  -87,  -87,  -87,  -87,  -87,   98,  -87,  -87,
       -87,  -87,  -87,  -87,  -87,  -87,  -87,  -87
     },
 
@@ -1826,11 +1818,11 @@
       -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
 
       -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
-      -88,  -88,  -88,  -88,  -88,  -88,   93,  -88,  -88,  -88,
       -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
       -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
-      -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,   93,  -88,
       -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
+      -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
+      -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88,
       -88,  -88,  -88,  -88,  -88,  -88,  -88,  -88
     },
 
@@ -1843,11 +1835,11 @@
       -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,
       -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,
       -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,
-      -89,  -89,  -89,  -89,  -89,  -89,  -89,   94,  -89,  -89,
+      -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,   99,  -89,
       -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,
       -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,
-      -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,   94,
       -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,
+       99,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89,
       -89,  -89,  -89,  -89,  -89,  -89,  -89,  -89
 
     },
@@ -1861,11 +1853,11 @@
       -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,
       -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,
       -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,
-      -90,  -90,  -90,  -90,   95,  -90,  -90,  -90,  -90,  -90,
+      -90,  -90,  100,  -90,  -90,  -90,  -90,  -90,  -90,  -90,
       -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,
 
       -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90,
-      -90,  -90,  -90,  -90,  -90,  -90,   95,  -90,  -90,  -90,
+      -90,  -90,  -90,  -90,  100,  -90,  -90,  -90,  -90,  -90,
       -90,  -90,  -90,  -90,  -90,  -90,  -90,  -90
     },
 
@@ -1876,13 +1868,13 @@
       -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
       -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
       -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
-      -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
+      -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  101,  -91,
 
-      -91,  -91,  -91,  -91,  -91,  -91,  -91,   96,  -91,  -91,
       -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
       -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
-      -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,   96,
       -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
+      101,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
+      -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91,
       -91,  -91,  -91,  -91,  -91,  -91,  -91,  -91
     },
 
@@ -1895,11 +1887,11 @@
       -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,
       -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,
       -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,
-      -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,   97,
+      -92,  -92,  -92,  -92,  -92,  -92,  102,  -92,  -92,  -92,
       -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,
       -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,
+      -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  102,  -92,
       -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,
-      -92,   97,  -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92,
       -92,  -92,  -92,  -92,  -92,  -92,  -92,  -92
     },
 
@@ -1912,13 +1904,13 @@
       -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
       -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
       -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
-      -93,  -93,  -93,  -93,  -93,  -93,   98,  -93,  -93,  -93,
       -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
+      -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  103,
       -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
-      -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,   98,  -93,
+      -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
 
       -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93,
-      -93,  -93,  -93,  -93,  -93,  -93,  -93,  -93
+      -93,  103,  -93,  -93,  -93,  -93,  -93,  -93
     },
 
     {
@@ -1929,12 +1921,12 @@
       -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
       -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
       -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
-      -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
+      -94,  -94,  -94,  104,  -94,  -94,  -94,  -94,  -94,  -94,
 
       -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
       -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
+      -94,  -94,  -94,  -94,  -94,  104,  -94,  -94,  -94,  -94,
       -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
-      -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94,
       -94,  -94,  -94,  -94,  -94,  -94,  -94,  -94
     },
 
@@ -1948,10 +1940,10 @@
       -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
       -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
       -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
-      -95,  -95,   99,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
+      -95,  -95,  105,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
       -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
       -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95,
-      -95,  -95,  -95,  -95,   99,  -95,  -95,  -95,  -95,  -95,
+      -95,  -95,  -95,  -95,  105,  -95,  -95,  -95,  -95,  -95,
       -95,  -95,  -95,  -95,  -95,  -95,  -95,  -95
     },
 
@@ -1964,11 +1956,11 @@
       -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
       -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
       -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
+      -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  106,  -96,
       -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
       -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
       -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
-      -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
-      -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
+      106,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96,
 
       -96,  -96,  -96,  -96,  -96,  -96,  -96,  -96
     },
@@ -1981,12 +1973,12 @@
       -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,
       -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,
       -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,
-      -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  100,  -97,
+      -97,  -97,  -97,  107,  -97,  -97,  108,  -97,  -97,  -97,
       -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,
 
       -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,
+      -97,  -97,  -97,  -97,  -97,  107,  -97,  -97,  108,  -97,
       -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,
-      100,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97,
       -97,  -97,  -97,  -97,  -97,  -97,  -97,  -97
     },
 
@@ -1998,12 +1990,12 @@
       -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
       -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
 
-      -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  101,
       -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
       -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
+      -98,  -98,  109,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
       -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
-      -98,  101,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
       -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98,
+      -98,  -98,  -98,  -98,  109,  -98,  -98,  -98,  -98,  -98,
       -98,  -98,  -98,  -98,  -98,  -98,  -98,  -98
     },
 
@@ -2016,10 +2008,10 @@
       -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,
       -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,
       -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,
-      -99,  -99,  -99,  102,  -99,  -99,  -99,  -99,  -99,  -99,
+      -99,  -99,  -99,  -99,  -99,  -99,  -99,  110,  -99,  -99,
       -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,
       -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,
-      -99,  -99,  -99,  -99,  -99,  102,  -99,  -99,  -99,  -99,
+      -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  110,
       -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99,
       -99,  -99,  -99,  -99,  -99,  -99,  -99,  -99
 
@@ -2033,12 +2025,12 @@
      -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
      -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
      -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
-     -100, -100, -100, -100, -100, -100, -100,  103, -100, -100,
      -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
+     -100, -100, -100,  111, -100, -100, -100, -100, -100, -100,
      -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
 
-     -100, -100, -100, -100, -100, -100, -100, -100, -100,  103,
      -100, -100, -100, -100, -100, -100, -100, -100, -100, -100,
+     -100, -100, -100, -100, -100,  111, -100, -100, -100, -100,
      -100, -100, -100, -100, -100, -100, -100, -100
     },
 
@@ -2049,11 +2041,11 @@
      -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
      -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
      -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
-     -101, -101, -101, -101, -101, -101, -101,  104, -101, -101,
+     -101, -101, -101, -101, -101, -101, -101,  112, -101, -101,
 
      -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
      -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
-     -101, -101, -101, -101, -101, -101, -101, -101, -101,  104,
+     -101, -101, -101, -101, -101, -101, -101, -101, -101,  112,
      -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
      -101, -101, -101, -101, -101, -101, -101, -101, -101, -101,
      -101, -101, -101, -101, -101, -101, -101, -101
@@ -2068,12 +2060,12 @@
      -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
      -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
      -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
-     -102, -102, -102, -102, -102, -102, -102, -102,  105, -102,
      -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
+     -102, -102, -102, -102, -102, -102, -102, -102, -102,  113,
      -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
      -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
-      105, -102, -102, -102, -102, -102, -102, -102, -102, -102,
-     -102, -102, -102, -102, -102, -102, -102, -102
+     -102, -102, -102, -102, -102, -102, -102, -102, -102, -102,
+     -102,  113, -102, -102, -102, -102, -102, -102
     },
 
     {
@@ -2084,11 +2076,11 @@
      -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
      -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
      -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
+     -103, -103, -103, -103, -103, -103, -103,  114, -103, -103,
      -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
      -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
+     -103, -103, -103, -103, -103, -103, -103, -103, -103,  114,
      -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
-     -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
-     -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
 
      -103, -103, -103, -103, -103, -103, -103, -103, -103, -103,
      -103, -103, -103, -103, -103, -103, -103, -103
@@ -2102,12 +2094,12 @@
      -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
      -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
      -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
-     -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
+     -104, -104, -104, -104, -104, -104, -104, -104,  115, -104,
 
-     -104, -104, -104, -104,  106, -104, -104, -104, -104, -104,
      -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
      -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
-     -104, -104, -104, -104, -104, -104,  106, -104, -104, -104,
+     -104, -104, -104, -104, -104, -104, -104, -104, -104, -104,
+      115, -104, -104, -104, -104, -104, -104, -104, -104, -104,
      -104, -104, -104, -104, -104, -104, -104, -104
     },
 
@@ -2120,11 +2112,11 @@
 
      -105, -105, -105, -105, -105, -105, -105, -105, -105, -105,
      -105, -105, -105, -105, -105, -105, -105, -105, -105, -105,
-     -105,  107, -105, -105, -105, -105, -105, -105, -105, -105,
      -105, -105, -105, -105, -105, -105, -105, -105, -105, -105,
+     -105, -105, -105, -105, -105, -105,  116, -105, -105, -105,
      -105, -105, -105, -105, -105, -105, -105, -105, -105, -105,
-     -105, -105, -105,  107, -105, -105, -105, -105, -105, -105,
      -105, -105, -105, -105, -105, -105, -105, -105, -105, -105,
+     -105, -105, -105, -105, -105, -105, -105, -105,  116, -105,
      -105, -105, -105, -105, -105, -105, -105, -105
     },
 
@@ -2136,11 +2128,11 @@
      -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
      -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
      -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
+     -106, -106, -106, -106, -106, -106, -106, -106, -106,  117,
      -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
-     -106, -106, -106,  108, -106, -106, -106, -106, -106, -106,
      -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
      -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
-     -106, -106, -106, -106, -106,  108, -106, -106, -106, -106,
+     -106,  117, -106, -106, -106, -106, -106, -106, -106, -106,
      -106, -106, -106, -106, -106, -106, -106, -106, -106, -106,
 
      -106, -106, -106, -106, -106, -106, -106, -106
@@ -2154,12 +2146,12 @@
      -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
      -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
      -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
-     -107, -107, -107, -107, -107, -107, -107,  109, -107, -107,
+     -107, -107, -107, -107, -107, -107, -107, -107,  118, -107,
      -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
 
      -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
-     -107, -107, -107, -107, -107, -107, -107, -107, -107,  109,
      -107, -107, -107, -107, -107, -107, -107, -107, -107, -107,
+      118, -107, -107, -107, -107, -107, -107, -107, -107, -107,
      -107, -107, -107, -107, -107, -107, -107, -107
     },
 
@@ -2172,12 +2164,12 @@
      -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
 
      -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
-     -108, -108, -108, -108, -108, -108, -108, -108, -108,  110,
      -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
+     -108, -108, -108, -108, -108, -108, -108, -108, -108,  119,
      -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
      -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
-     -108,  110, -108, -108, -108, -108, -108, -108, -108, -108,
-     -108, -108, -108, -108, -108, -108, -108, -108
+     -108, -108, -108, -108, -108, -108, -108, -108, -108, -108,
+     -108,  119, -108, -108, -108, -108, -108, -108
     },
 
     {
@@ -2189,11 +2181,11 @@
      -109, -109, -109, -109, -109, -109, -109, -109, -109, -109,
      -109, -109, -109, -109, -109, -109, -109, -109, -109, -109,
      -109, -109, -109, -109, -109, -109, -109, -109, -109, -109,
+      120, -109, -109, -109, -109, -109, -109, -109, -109, -109,
      -109, -109, -109, -109, -109, -109, -109, -109, -109, -109,
      -109, -109, -109, -109, -109, -109, -109, -109, -109, -109,
+     -109, -109,  120, -109, -109, -109, -109, -109, -109, -109,
      -109, -109, -109, -109, -109, -109, -109, -109, -109, -109,
-     -109, -109, -109, -109, -109, -109, -109, -109, -109, -109,
-     -109, -109, -109, -109, -109, -109, -109, -109, -109, -109,
      -109, -109, -109, -109, -109, -109, -109, -109
 
     },
@@ -2206,12 +2198,12 @@
      -110, -110, -110, -110, -110, -110, -110, -110, -110, -110,
      -110, -110, -110, -110, -110, -110, -110, -110, -110, -110,
      -110, -110, -110, -110, -110, -110, -110, -110, -110, -110,
-     -110, -110, -110, -110, -110, -110, -110, -110,  111, -110,
      -110, -110, -110, -110, -110, -110, -110, -110, -110, -110,
      -110, -110, -110, -110, -110, -110, -110, -110, -110, -110,
+     -110, -110, -110, -110, -110, -110, -110, -110, -110, -110,
 
      -110, -110, -110, -110, -110, -110, -110, -110, -110, -110,
-      111, -110, -110, -110, -110, -110, -110, -110, -110, -110,
+     -110, -110, -110, -110, -110, -110, -110, -110, -110, -110,
      -110, -110, -110, -110, -110, -110, -110, -110
     },
 
@@ -2224,11 +2216,11 @@
      -111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
      -111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
 
-     -111, -111, -111, -111, -111, -111, -111,  112, -111, -111,
      -111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
+     -111, -111, -111, -111,  121, -111, -111, -111, -111, -111,
      -111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
-     -111, -111, -111, -111, -111, -111, -111, -111, -111,  112,
      -111, -111, -111, -111, -111, -111, -111, -111, -111, -111,
+     -111, -111, -111, -111, -111, -111,  121, -111, -111, -111,
      -111, -111, -111, -111, -111, -111, -111, -111
     },
 
@@ -2242,13 +2234,948 @@
      -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
      -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
      -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
+     -112, -112, -112, -112, -112,  122, -112, -112, -112, -112,
      -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
      -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
-     -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
-     -112, -112, -112, -112, -112, -112, -112, -112, -112, -112,
+     -112, -112, -112, -112, -112, -112, -112,  122, -112, -112,
      -112, -112, -112, -112, -112, -112, -112, -112
     },
 
+    {
+        5, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+
+     -113, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113,  123, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113, -113, -113,  123, -113, -113, -113, -113, -113, -113,
+
+     -113, -113, -113, -113, -113, -113, -113, -113, -113, -113,
+     -113, -113, -113, -113, -113, -113, -113, -113
+    },
+
+    {
+        5, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114, -114,  124,
+
+     -114, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114,  124, -114, -114, -114, -114, -114, -114, -114, -114,
+     -114, -114, -114, -114, -114, -114, -114, -114
+    },
+
+    {
+        5, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+
+     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115,  125, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115,  125, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115, -115, -115, -115, -115, -115, -115, -115,
+     -115, -115, -115, -115, -115, -115, -115, -115
+    },
+
+    {
+        5, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+     -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+
+     -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+     -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+     -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+     -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+     -116, -116, -116, -116, -116, -116, -116, -116, -116,  126,
+     -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+     -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+     -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+     -116,  126, -116, -116, -116, -116, -116, -116, -116, -116,
+     -116, -116, -116, -116, -116, -116, -116, -116, -116, -116,
+
+     -116, -116, -116, -116, -116, -116, -116, -116
+    },
+
+    {
+        5, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117,  127, -117, -117, -117, -117, -117, -117,
+
+     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117, -117, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117,  127, -117, -117, -117, -117,
+     -117, -117, -117, -117, -117, -117, -117, -117
+    },
+
+    {
+        5, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+
+     -118, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118,  128, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118, -118, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118,  128, -118, -118, -118,
+     -118, -118, -118, -118, -118, -118, -118, -118
+    },
+
+    {
+        5, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+
+     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119,  129, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119,  129, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119, -119, -119, -119, -119, -119, -119, -119,
+     -119, -119, -119, -119, -119, -119, -119, -119
+
+    },
+
+    {
+        5, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120,  130, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120,  130, -120, -120,
+
+     -120, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120, -120, -120, -120,
+     -120, -120, -120, -120, -120, -120, -120, -120
+    },
+
+    {
+        5, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+
+     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121,  131, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121, -121, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121,  131, -121, -121, -121, -121, -121,
+     -121, -121, -121, -121, -121, -121, -121, -121
+    },
+
+    {
+        5, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+
+     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122,  132, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122, -122, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122,  132, -122, -122, -122, -122, -122,
+     -122, -122, -122, -122, -122, -122, -122, -122
+    },
+
+    {
+        5, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+
+     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+     -123, -123, -123, -123, -123, -123, -123, -123, -123,  133,
+     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+     -123, -123, -123, -123, -123, -123, -123, -123, -123, -123,
+
+     -123,  133, -123, -123, -123, -123, -123, -123, -123, -123,
+     -123, -123, -123, -123, -123, -123, -123, -123
+    },
+
+    {
+        5, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124,  134, -124, -124, -124,
+
+     -124, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124,  134, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124, -124, -124,
+     -124, -124, -124, -124, -124, -124, -124, -124
+    },
+
+    {
+        5, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+
+     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125,  135, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125, -125, -125,  135,
+     -125, -125, -125, -125, -125, -125, -125, -125, -125, -125,
+     -125, -125, -125, -125, -125, -125, -125, -125
+    },
+
+    {
+        5, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+
+     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+     -126, -126, -126, -126, -126, -126, -126,  136, -126, -126,
+     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+     -126, -126, -126, -126, -126, -126, -126, -126, -126,  136,
+     -126, -126, -126, -126, -126, -126, -126, -126, -126, -126,
+
+     -126, -126, -126, -126, -126, -126, -126, -126
+    },
+
+    {
+        5, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127,  137, -127, -127, -127, -127, -127,
+
+     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127, -127, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127,  137, -127, -127, -127,
+     -127, -127, -127, -127, -127, -127, -127, -127
+    },
+
+    {
+        5, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+
+     -128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128,  138, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128, -128, -128,  138,
+     -128, -128, -128, -128, -128, -128, -128, -128, -128, -128,
+     -128, -128, -128, -128, -128, -128, -128, -128
+    },
+
+    {
+        5, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+
+     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129, -129, -129, -129, -129, -129, -129, -129, -129,  139,
+     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129, -129, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129,  139, -129, -129, -129, -129, -129, -129, -129, -129,
+     -129, -129, -129, -129, -129, -129, -129, -129
+
+    },
+
+    {
+        5, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130,  140, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130, -130,  140,
+
+     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130, -130, -130,
+     -130, -130, -130, -130, -130, -130, -130, -130
+    },
+
+    {
+        5, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+
+     -131, -131, -131,  141, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131,  141, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131, -131, -131,
+     -131, -131, -131, -131, -131, -131, -131, -131
+    },
+
+    {
+        5, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+
+     -132, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132,  142, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132, -132, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132,  142, -132,
+     -132, -132, -132, -132, -132, -132, -132, -132
+    },
+
+    {
+        5, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+
+     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133,  143, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+
+      143, -133, -133, -133, -133, -133, -133, -133, -133, -133,
+     -133, -133, -133, -133, -133, -133, -133, -133
+    },
+
+    {
+        5, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134,  144, -134, -134, -134,
+
+     -134, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134,  144, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134, -134, -134,
+     -134, -134, -134, -134, -134, -134, -134, -134
+    },
+
+    {
+        5, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135, -135, -135,
+     -135, -135, -135, -135, -135, -135, -135, -135
+    },
+
+    {
+        5, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+     -136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
+
+     -136, -136, -136, -136, -136, -136, -136, -136
+    },
+
+    {
+        5, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137,  145, -137, -137, -137, -137, -137, -137, -137,
+
+     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137, -137, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137,  145, -137, -137, -137, -137, -137,
+     -137, -137, -137, -137, -137, -137, -137, -137
+    },
+
+    {
+        5, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138, -138, -138,
+     -138, -138, -138, -138, -138, -138, -138, -138
+    },
+
+    {
+        5, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+
+     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139,  146, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+      146, -139, -139, -139, -139, -139, -139, -139, -139, -139,
+     -139, -139, -139, -139, -139, -139, -139, -139
+
+    },
+
+    {
+        5, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140,  147,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+
+     -140,  147, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140, -140, -140,
+     -140, -140, -140, -140, -140, -140, -140, -140
+    },
+
+    {
+        5, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+
+     -141, -141, -141, -141, -141, -141, -141, -141,  148, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+      148, -141, -141, -141, -141, -141, -141, -141, -141, -141,
+     -141, -141, -141, -141, -141, -141, -141, -141
+    },
+
+    {
+        5, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+
+     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142, -142, -142, -142, -142, -142, -142, -142, -142,  149,
+     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142,  149, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
+     -142, -142, -142, -142, -142, -142, -142, -142
+    },
+
+    {
+        5, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+
+     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143,  150, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143, -143, -143,  150,
+
+     -143, -143, -143, -143, -143, -143, -143, -143, -143, -143,
+     -143, -143, -143, -143, -143, -143, -143, -143
+    },
+
+    {
+        5, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144, -144, -144, -144, -144, -144, -144, -144, -144,  151,
+     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+
+     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144,  151, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144, -144, -144, -144, -144, -144, -144, -144, -144, -144,
+     -144, -144, -144, -144, -144, -144, -144, -144
+    },
+
+    {
+        5, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+
+     -145, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145,  152, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145,  152, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145, -145, -145, -145, -145, -145,
+     -145, -145, -145, -145, -145, -145, -145, -145
+    },
+
+    {
+        5, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+     -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+
+     -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+     -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+     -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+     -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+     -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+     -146, -146, -146, -146, -146, -146, -146,  153, -146, -146,
+     -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+     -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+     -146, -146, -146, -146, -146, -146, -146, -146, -146,  153,
+     -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
+
+     -146, -146, -146, -146, -146, -146, -146, -146
+    },
+
+    {
+        5, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147,  154, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+
+     -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147, -147, -147,  154,
+     -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
+     -147, -147, -147, -147, -147, -147, -147, -147
+    },
+
+    {
+        5, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+
+     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148,  155, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148,  155, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
+     -148, -148, -148, -148, -148, -148, -148, -148
+    },
+
+    {
+        5, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+
+     -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149,  156, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149, -149, -149,  156,
+     -149, -149, -149, -149, -149, -149, -149, -149, -149, -149,
+     -149, -149, -149, -149, -149, -149, -149, -149
+
+    },
+
+    {
+        5, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150, -150, -150,
+     -150, -150, -150, -150, -150, -150, -150, -150
+    },
+
+    {
+        5, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151,  157, -151, -151,
+
+     -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151, -151, -151,  157,
+     -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151, -151, -151, -151,
+     -151, -151, -151, -151, -151, -151, -151, -151
+    },
+
+    {
+        5, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+
+     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152,  158, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+      158, -152, -152, -152, -152, -152, -152, -152, -152, -152,
+     -152, -152, -152, -152, -152, -152, -152, -152
+    },
+
+    {
+        5, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+
+     -153, -153, -153, -153, -153, -153, -153, -153, -153, -153,
+     -153, -153, -153, -153, -153, -153, -153, -153
+    },
+
+    {
+        5, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154, -154, -154,
+     -154, -154, -154, -154, -154, -154, -154, -154
+    },
+
+    {
+        5, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+
+     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155,  159, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155, -155, -155,  159,
+     -155, -155, -155, -155, -155, -155, -155, -155, -155, -155,
+     -155, -155, -155, -155, -155, -155, -155, -155
+    },
+
+    {
+        5, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+     -156, -156, -156, -156, -156, -156, -156, -156, -156, -156,
+
+     -156, -156, -156, -156, -156, -156, -156, -156
+    },
+
+    {
+        5, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157,  160, -157, -157, -157, -157, -157,
+
+     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157, -157, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157,  160, -157, -157, -157,
+     -157, -157, -157, -157, -157, -157, -157, -157
+    },
+
+    {
+        5, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+
+     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158,  161, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158,  161, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158, -158, -158, -158, -158, -158, -158, -158,
+     -158, -158, -158, -158, -158, -158, -158, -158
+    },
+
+    {
+        5, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159, -159, -159,
+     -159, -159, -159, -159, -159, -159, -159, -159
+
+    },
+
+    {
+        5, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160,  162, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+
+     -160, -160, -160, -160, -160,  162, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160, -160, -160,
+     -160, -160, -160, -160, -160, -160, -160, -160
+    },
+
+    {
+        5, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+
+     -161, -161, -161, -161, -161, -161, -161,  163, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161,  163,
+     -161, -161, -161, -161, -161, -161, -161, -161, -161, -161,
+     -161, -161, -161, -161, -161, -161, -161, -161
+    },
+
+    {
+        5, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+
+     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162, -162, -162, -162, -162, -162, -162, -162, -162,  164,
+     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162, -162, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162,  164, -162, -162, -162, -162, -162, -162, -162, -162,
+     -162, -162, -162, -162, -162, -162, -162, -162
+    },
+
+    {
+        5, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+
+     -163, -163, -163, -163, -163, -163, -163, -163, -163, -163,
+     -163, -163, -163, -163, -163, -163, -163, -163
+    },
+
+    {
+        5, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164,  165, -164,
+
+     -164, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+      165, -164, -164, -164, -164, -164, -164, -164, -164, -164,
+     -164, -164, -164, -164, -164, -164, -164, -164
+    },
+
+    {
+        5, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+
+     -165, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165,  166, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165, -165, -165,  166,
+     -165, -165, -165, -165, -165, -165, -165, -165, -165, -165,
+     -165, -165, -165, -165, -165, -165, -165, -165
+    },
+
+    {
+        5, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+     -166, -166, -166, -166, -166, -166, -166, -166, -166, -166,
+
+     -166, -166, -166, -166, -166, -166, -166, -166
+    },
+
     } ;
 
 
@@ -2267,29 +3194,34 @@
 	*yy_cp = '\0'; \
 	yy_c_buf_p = yy_cp;
 
-#define YY_NUM_RULES 28
-#define YY_END_OF_BUFFER 29
-static yyconst short int yy_accept[113] =
+#define YY_NUM_RULES 38
+#define YY_END_OF_BUFFER 39
+static yyconst short int yy_accept[167] =
     {   0,
-        0,    0,    0,    0,   29,   27,   26,   26,   21,   22,
-       23,   27,   25,   24,   27,   27,   27,   27,   27,   27,
-       27,   27,    1,   26,    3,    4,    0,    0,    0,    0,
-        0,    0,    0,    1,    2,    0,    0,    3,    4,    0,
-        0,    0,    0,    0,    0,    0,    0,    1,    0,    1,
-        0,    0,    0,    0,    0,    0,   19,    0,    2,   20,
-        0,    0,    0,    5,    0,    0,    0,    0,    0,    6,
-        0,    0,    0,    0,    0,    9,    0,    0,    0,    0,
-        0,   10,    0,    0,    0,    0,    0,    0,    7,    0,
-       11,    0,    0,    8,    0,   12,    0,    0,    0,   15,
+        0,    0,    0,    0,   39,   37,   36,   36,   31,   32,
+       33,   37,   35,   34,   37,   37,   37,   37,   37,   37,
+       37,   37,   37,    1,   36,    3,    4,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,    1,    2,    0,
+        0,    3,    4,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    1,    0,    1,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,   29,    0,    2,    0,
+        0,    0,   30,    0,    0,    0,    5,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,    6,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,    0,   11,    0,
 
-        0,    0,   16,    0,    0,    0,   13,    0,   14,    0,
-       17,   18
+        0,    0,    0,    0,    0,    0,    0,    0,    0,   12,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    7,   21,    0,   17,    0,    0,
+        0,    0,    0,    0,    8,   22,    0,   18,    0,    0,
+        0,    0,   15,    0,    0,   23,   25,    0,   13,   16,
+        0,    0,   24,   26,    9,   14,    0,    0,   10,    0,
+       19,    0,   20,    0,   27,   28
     } ;
 
 static yy_state_type yy_last_accepting_state;
 static char *yy_last_accepting_cpos;
 
-static yyconst yy_state_type yy_NUL_trans[113] =
+static yyconst yy_state_type yy_NUL_trans[167] =
     {   0,
         6,    6,    6,    6,    0,    0,    0,    0,    0,    0,
         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
@@ -2303,7 +3235,12 @@
         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
 
         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
-        0,    0
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0
     } ;
 
 /* The intent behind this definition is that it'll catch
@@ -2340,7 +3277,7 @@
    void close_parser() { lwg_parse_yy_delete_buffer(buf_state); }
    int lwg_parse_yywrap(void){ return 1; }
 
-#line 2344 "lex.yy.c"
+#line 3281 "lex.yy.c"
 
 /* Macros after this point can all be overridden by user definitions in
  * section 1.
@@ -2428,17 +3365,8 @@
  */
 #ifndef YY_INPUT
 #define YY_INPUT(buf,result,max_size) \
-	errno=0; \
-	while ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
-	{ \
-		if( errno != EINTR) \
-		{ \
-			YY_FATAL_ERROR( "input in flex scanner failed" ); \
-			break; \
-		} \
-		errno=0; \
-		clearerr(yyin); \
-	}
+	if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \
+		YY_FATAL_ERROR( "input in flex scanner failed" );
 #endif
 
 /* No semi-colon after return; correct usage is to write "yyterminate();" -
@@ -2484,13 +3412,13 @@
 YY_DECL
 	{
 	register yy_state_type yy_current_state;
-	register char *yy_cp, *yy_bp;
+	register char *yy_cp = NULL, *yy_bp = NULL;
 	register int yy_act;
 
 #line 27 "wktparse.lex"
 
 
-#line 2494 "lex.yy.c"
+#line 3422 "lex.yy.c"
 
 	if ( yy_init )
 		{
@@ -2604,104 +3532,154 @@
 case 9:
 YY_RULE_SETUP
 #line 39 "wktparse.lex"
-{ return POLYGON; }
+{ return CIRCULARSTRING; }
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
 #line 40 "wktparse.lex"
-{ return POLYGONM; }
+{ return CIRCULARSTRINGM; }
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
 #line 41 "wktparse.lex"
-{ return MULTIPOINT; }
+{ return POLYGON; }
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
 #line 42 "wktparse.lex"
-{ return MULTIPOINTM; }
+{ return POLYGONM; }
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
 #line 43 "wktparse.lex"
-{ return MULTILINESTRING; }
+{ return COMPOUNDCURVE; }
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
 #line 44 "wktparse.lex"
-{ return MULTILINESTRINGM; }
+{ return COMPOUNDCURVEM; }
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
 #line 45 "wktparse.lex"
-{ return MULTIPOLYGON; }
+{ return CURVEPOLYGON; }
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
 #line 46 "wktparse.lex"
-{ return MULTIPOLYGONM; }
+{ return CURVEPOLYGONM; }
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
 #line 47 "wktparse.lex"
-{ return GEOMETRYCOLLECTION; }
+{ return MULTIPOINT; }
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
 #line 48 "wktparse.lex"
-{ return GEOMETRYCOLLECTIONM; }
+{ return MULTIPOINTM; }
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
 #line 49 "wktparse.lex"
-{ BEGIN(vals_ok); return SRID; }
+{ return MULTILINESTRING; }
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
 #line 50 "wktparse.lex"
-{ return EMPTY; }
+{ return MULTILINESTRINGM; }
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
+#line 51 "wktparse.lex"
+{ return MULTICURVE; }
+	YY_BREAK
+case 22:
+YY_RULE_SETUP
 #line 52 "wktparse.lex"
+{ return MULTICURVEM; }
+	YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 53 "wktparse.lex"
+{ return MULTIPOLYGON; }
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 54 "wktparse.lex"
+{ return MULTIPOLYGONM; }
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 55 "wktparse.lex"
+{ return MULTISURFACE; }
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 56 "wktparse.lex"
+{ return MULTISURFACEM; }
+	YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 57 "wktparse.lex"
+{ return GEOMETRYCOLLECTION; }
+	YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 58 "wktparse.lex"
+{ return GEOMETRYCOLLECTIONM; }
+	YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 59 "wktparse.lex"
+{ BEGIN(vals_ok); return SRID; }
+	YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 60 "wktparse.lex"
+{ return EMPTY; }
+	YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 62 "wktparse.lex"
 { BEGIN(vals_ok); return LPAREN; }
 	YY_BREAK
-case 22:
+case 32:
 YY_RULE_SETUP
-#line 53 "wktparse.lex"
+#line 63 "wktparse.lex"
 { return RPAREN; }
 	YY_BREAK
-case 23:
+case 33:
 YY_RULE_SETUP
-#line 54 "wktparse.lex"
+#line 64 "wktparse.lex"
 { return COMMA ; }
 	YY_BREAK
-case 24:
+case 34:
 YY_RULE_SETUP
-#line 55 "wktparse.lex"
+#line 65 "wktparse.lex"
 { return EQUALS ; }
 	YY_BREAK
-case 25:
+case 35:
 YY_RULE_SETUP
-#line 56 "wktparse.lex"
+#line 66 "wktparse.lex"
 { BEGIN(0); return SEMICOLON; }
 	YY_BREAK
-case 26:
+case 36:
 YY_RULE_SETUP
-#line 57 "wktparse.lex"
+#line 67 "wktparse.lex"
 /*eat whitespace*/
 	YY_BREAK
-case 27:
+case 37:
 YY_RULE_SETUP
-#line 58 "wktparse.lex"
+#line 68 "wktparse.lex"
 { return lwg_parse_yytext[0]; }
 	YY_BREAK
-case 28:
+case 38:
 YY_RULE_SETUP
-#line 60 "wktparse.lex"
+#line 70 "wktparse.lex"
 ECHO;
 	YY_BREAK
-#line 2705 "lex.yy.c"
+#line 3683 "lex.yy.c"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(vals_ok):
 	yyterminate();
@@ -3079,6 +4057,7 @@
 #endif	/* ifndef YY_NO_UNPUT */
 
 
+#ifndef YY_NO_INPUT
 #ifdef __cplusplus
 static int yyinput()
 #else
@@ -3150,8 +4129,8 @@
 
 	return c;
 	}
+#endif /* YY_NO_INPUT */
 
-
 #ifdef YY_USE_PROTOS
 void yyrestart( FILE *input_file )
 #else
@@ -3261,15 +4240,6 @@
 	}
 
 
-#ifndef _WIN32
-#include <unistd.h>
-#else
-#ifndef YY_ALWAYS_INTERACTIVE
-#ifndef YY_NEVER_INTERACTIVE
-extern int isatty YY_PROTO(( int ));
-#endif
-#endif
-#endif
 
 #ifdef YY_USE_PROTOS
 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
@@ -3587,6 +4557,6 @@
 	return 0;
 	}
 #endif
-#line 60 "wktparse.lex"
+#line 70 "wktparse.lex"
 
 

Modified: packages/postgis/upstream/lwgeom/liblwgeom.c
===================================================================
--- packages/postgis/upstream/lwgeom/liblwgeom.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/liblwgeom.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -41,7 +41,15 @@
 	"MultiPoint",
 	"MultiLine",
 	"MultiPolygon",
-	"GeometryCollection"
+	"GeometryCollection",
+        "Curve",
+        "CompoundString",
+        "Invalid Type",  /* POINTTYPEI */
+        "Invalid Type",  /* LINETYPEI */
+        "Invalid Type",  /* POLYTYPEI */
+        "CurvePolygon",
+        "MultiCurve",
+        "MultiSurface"
 };
 
 void *
@@ -113,7 +121,7 @@
 lwgeom_typename(int type)
 {
 	// something went wrong somewhere
-	if ( type < 0 || type > 7 ) {
+	if ( type < 0 || type > 12 ) {
 		// assert(0);
 		return "Invalid type";
 	}

Modified: packages/postgis/upstream/lwgeom/liblwgeom.h
===================================================================
--- packages/postgis/upstream/lwgeom/liblwgeom.h	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/liblwgeom.h	2007-04-13 07:15:27 UTC (rev 758)
@@ -6,7 +6,8 @@
 
 #define INTEGRITY_CHECKS 1
 /* #define DEBUG_ALLOCS 1 */
-/* #define PGIS_DEBUG 1 */
+/*#define PGIS_DEBUG 1
+#define PGIS_DEBUG_CALLS 1*/
 /* #define DEBUG_CALLS 1 */
 
 /*
@@ -250,7 +251,7 @@
 /* MULTIPOINTTYPE */
 typedef struct
 {
-	uchar type; 
+	uchar type;  
 	BOX2DFLOAT4 *bbox;
    	uint32 SRID;	
 	int  ngeoms;
@@ -521,6 +522,7 @@
 extern size_t lwgeom_size(const uchar *serialized_form);
 extern size_t lwgeom_size_subgeom(const uchar *serialized_form, int geom_number);
 extern size_t lwgeom_size_line(const uchar *serialized_line);
+extern size_t lwgeom_size_curve(const uchar *serialized_curve);
 extern size_t lwgeom_size_point(const uchar *serialized_point);
 extern size_t lwgeom_size_poly(const uchar *serialized_line);
 
@@ -742,6 +744,8 @@
 extern LWPOLY *lwgeom_getpoly(uchar *serialized_form, int geom_number);
 extern LWPOLY *lwgeom_getpoly_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
 
+extern LWGEOM *lwgeom_getgeom_inspected(LWGEOM_INSPECTED *inspected, int geom_number);
+
 /*
  * this gets the serialized form of a sub-geometry
  * 1st geometry has geom_number = 0
@@ -1073,4 +1077,116 @@
 
 void errorIfSRIDMismatch(int srid1, int srid2);
 
+
+/* CURVETYPE */
+typedef struct
+{
+        uchar type; /* CURVETYPE */
+        BOX2DFLOAT4 *bbox;
+        uint32 SRID;
+        POINTARRAY *points; /* array of POINT(3D/3DM) */
+} LWCURVE; /* "light-weight arcline" */
+
+/* COMPOUNDTYPE */
+typedef struct
+{
+        uchar type; /* COMPOUNDTYPE */
+        BOX2DFLOAT4 *bbox;
+        uint32 SRID;
+        int ngeoms;
+        LWGEOM **geoms;
+} LWCOMPOUND; /* "light-weight compound line" */
+
+/* CURVEPOLYTYPE */
+typedef struct
+{
+        uchar type; /* CURVEPOLYTYPE */
+        BOX2DFLOAT4 *bbox;
+        uint32 SRID;
+        int nrings;
+        LWGEOM **rings; /* list of rings (list of points) */
+} LWCURVEPOLY; /* "light-weight polygon" */
+
+/* MULTICURVE */
+typedef struct
+{
+        uchar type;
+        BOX2DFLOAT4 *bbox;
+        uint32 SRID;
+        int ngeoms;
+        LWGEOM **geoms;
+} LWMCURVE;
+
+/* MULTISURFACETYPE */
+typedef struct
+{
+        uchar type;
+        BOX2DFLOAT4 *bbox;
+        uint32 SRID;
+        int ngeoms;
+        LWGEOM **geoms;
+} LWMSURFACE;
+
+#define CURVETYPE       8
+#define COMPOUNDTYPE    9
+#define CURVEPOLYTYPE   13
+#define MULTICURVETYPE          14
+#define MULTISURFACETYPE        15
+
+/******************************************************************
+ * LWCURVE functions
+ ******************************************************************/
+
+/*
+ * given the LWGEOM serialized form (or a pointer into a muli* one)
+ * construct a proper LWCURVE.
+ * serialized_form should point to the 8bit type format (with type = 2)
+ * See SERIALIZED_FORM doc
+ */
+extern LWCURVE *lwcurve_deserialize(uchar *serialized_form);
+
+/* find the size this curve would get when serialized */
+extern size_t lwcurve_serialize_size(LWCURVE *curve);
+
+/*
+ * convert this curve into its serialize form
+ * result's first char will be the 8bit type.  See serialized form doc
+ * copies data.
+ */
+extern uchar *lwcurve_serialize(LWCURVE *curve);
+
+/* same as above, writes to buf */
+extern void lwcurve_serialize_buf(LWCURVE *curve, uchar *buf, size_t *size);
+
+/*
+ * find bounding box (standard one)  zmin=zmax=0 if 2d (might change to NaN)
+ */
+extern BOX3D *lwcurve_compute_box3d(LWCURVE *curve);
+
+LWGEOM *lwcurve_add(const LWCURVE *to, uint32 where, const LWGEOM *what);
+extern int lwcurve_compute_box2d_p(LWCURVE *curve, BOX2DFLOAT4 *box);
+extern BOX3D *lwcurve_compute_box3d(LWCURVE *curve);
+extern void pfree_curve(LWCURVE  *curve);
+
+/******************************************************************
+ * LWMULTIx and LWCOLLECTION functions
+ ******************************************************************/
+
+LWCOMPOUND *lwcompound_deserialize(uchar *serialized_form);
+
+LWGEOM *lwcompound_add(const LWCOMPOUND *to, uint32 where, const LWGEOM *what);
+
+LWCURVEPOLY *lwcurvepoly_deserialize(uchar *serialized_form);
+
+LWGEOM *lwcurvepoly_add(const LWCURVEPOLY *to, uint32 where, const LWGEOM *what);
+
+LWMCURVE *lwmcurve_deserialize(uchar *serialized_form);
+
+LWGEOM *lwmcurve_add(const LWMCURVE *to, uint32 where, const LWGEOM *what);
+
+LWMSURFACE *lwmsurface_deserialize(uchar *serialized_form);
+
+LWGEOM *lwmsurface_add(const LWMSURFACE *to, uint32 where, const LWGEOM *what);
 #endif /* !defined _LIBLWGEOM_H  */
+
+double lwcircle_center(POINT4D *p1, POINT4D *p2, POINT4D *p3, POINT4D **result);

Added: packages/postgis/upstream/lwgeom/long_xact.sql.in
===================================================================
--- packages/postgis/upstream/lwgeom/long_xact.sql.in	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/long_xact.sql.in	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,355 @@
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+-- 
+-- $Id: long_xact.sql.in 2535 2006-12-05 19:05:25Z kneufeld $
+--
+-- PostGIS - Spatial Types for PostgreSQL
+-- http://postgis.refractions.net
+-- Copyright 2001-2003 Refractions Research Inc.
+--
+-- This is free software; you can redistribute and/or modify it under
+-- the terms of the GNU General Public Licence. See the COPYING file.
+--  
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+
+#include "sqldefines.h"
+
+
+-----------------------------------------------------------------------
+-- LONG TERM LOCKING
+-----------------------------------------------------------------------
+
+-- UnlockRows(authid)
+-- removes all locks held by the given auth
+-- returns the number of locks released
+CREATEFUNCTION UnlockRows(text)
+	RETURNS int
+	AS '
+DECLARE
+	ret int;
+BEGIN
+
+	IF NOT LongTransactionsEnabled() THEN
+		RAISE EXCEPTION ''Long transaction support disabled, use EnableLongTransaction() to enable.'';
+	END IF;
+
+	EXECUTE ''DELETE FROM authorization_table where authid = '' ||
+		quote_literal($1);
+
+	GET DIAGNOSTICS ret = ROW_COUNT;
+
+	RETURN ret;
+END;
+'
+LANGUAGE 'plpgsql' _VOLATILE_STRICT;
+
+-- LockRow([schema], table, rowid, auth, [expires]) 
+-- Returns 1 if successfully obtained the lock, 0 otherwise
+CREATEFUNCTION LockRow(text, text, text, text, timestamp)
+	RETURNS int
+	AS '
+DECLARE
+	myschema alias for $1;
+	mytable alias for $2;
+	myrid   alias for $3;
+	authid alias for $4;
+	expires alias for $5;
+	ret int;
+	mytoid oid;
+	myrec RECORD;
+	
+BEGIN
+
+	IF NOT LongTransactionsEnabled() THEN
+		RAISE EXCEPTION ''Long transaction support disabled, use EnableLongTransaction() to enable.'';
+	END IF;
+
+	EXECUTE ''DELETE FROM authorization_table WHERE expires < now()''; 
+
+#ifdef HAS_SCHEMAS
+	SELECT c.oid INTO mytoid FROM pg_class c, pg_namespace n
+		WHERE c.relname = mytable
+		AND c.relnamespace = n.oid
+		AND n.nspname = myschema;
+#else
+	SELECT c.oid INTO mytoid FROM pg_class c
+		WHERE c.relname = mytable;
+#endif
+
+	-- RAISE NOTICE ''toid: %'', mytoid;
+
+	FOR myrec IN SELECT * FROM authorization_table WHERE 
+		toid = mytoid AND rid = myrid
+	LOOP
+		IF myrec.authid != authid THEN
+			RETURN 0;
+		ELSE
+			RETURN 1;
+		END IF;
+	END LOOP;
+
+	EXECUTE ''INSERT INTO authorization_table VALUES (''||
+		quote_literal(mytoid)||'',''||quote_literal(myrid)||
+		'',''||quote_literal(expires)||
+		'',''||quote_literal(authid) ||'')'';
+
+	GET DIAGNOSTICS ret = ROW_COUNT;
+
+	RETURN ret;
+END;'
+LANGUAGE 'plpgsql' _VOLATILE_STRICT;
+
+-- LockRow(schema, table, rid, authid);
+CREATEFUNCTION LockRow(text, text, text, text)
+	RETURNS int
+	AS
+'SELECT LockRow($1, $2, $3, $4, now()::timestamp+''1:00'');'
+	LANGUAGE 'sql' _VOLATILE_STRICT;
+
+-- LockRow(table, rid, authid);
+CREATEFUNCTION LockRow(text, text, text)
+	RETURNS int
+	AS
+#ifdef HAS_SCHEMAS
+'SELECT LockRow(current_schema(), $1, $2, $3, now()::timestamp+''1:00'');'
+#else
+'SELECT LockRow('''', $1, $2, $3, now()::timestamp+''1:00'');'
+#endif
+	LANGUAGE 'sql' _VOLATILE_STRICT;
+
+-- LockRow(schema, table, rid, expires);
+CREATEFUNCTION LockRow(text, text, text, timestamp)
+	RETURNS int
+	AS
+#ifdef HAS_SCHEMAS
+'SELECT LockRow(current_schema(), $1, $2, $3, $4);'
+#else
+'SELECT LockRow('''', $1, $2, $3, $4);'
+#endif
+	LANGUAGE 'sql' _VOLATILE_STRICT;
+
+
+CREATEFUNCTION AddAuth(text)
+	RETURNS BOOLEAN
+	AS '
+DECLARE
+	lockid alias for $1;
+	okay boolean;
+	myrec record;
+BEGIN
+	-- check to see if table exists
+	--  if not, CREATE TEMP TABLE mylock (transid xid, lockcode text)
+	okay := ''f'';
+	FOR myrec IN SELECT * FROM pg_class WHERE relname = ''temp_lock_have_table'' LOOP
+		okay := ''t'';
+	END LOOP; 
+	IF (okay <> ''t'') THEN 
+		CREATE TEMP TABLE temp_lock_have_table (transid xid, lockcode text);
+			-- this will only work from pgsql7.4 up
+			-- ON COMMIT DELETE ROWS;
+	END IF;
+
+	--  INSERT INTO mylock VALUES ( $1)
+--	EXECUTE ''INSERT INTO temp_lock_have_table VALUES ( ''||
+--		quote_literal(getTransactionID()) || '','' ||
+--		quote_literal(lockid) ||'')'';
+
+	INSERT INTO temp_lock_have_table VALUES (getTransactionID(), lockid);
+
+	RETURN true::boolean;
+END;
+'
+LANGUAGE PLPGSQL;
+ 
+
+-- CheckAuth( <schema>, <table>, <ridcolumn> )
+--
+-- Returns 0
+--
+CREATEFUNCTION CheckAuth(text, text, text)
+	RETURNS INT
+	AS '
+DECLARE
+#ifdef HAS_SCHEMAS
+	schema text;
+#endif
+BEGIN
+	IF NOT LongTransactionsEnabled() THEN
+		RAISE EXCEPTION ''Long transaction support disabled, use EnableLongTransaction() to enable.'';
+	END IF;
+
+#ifdef HAS_SCHEMAS
+	if ( $1 != '''' ) THEN
+		schema = $1;
+	ELSE
+		SELECT current_schema() into schema;
+	END IF;
+#endif
+
+	-- TODO: check for an already existing trigger ?
+
+	EXECUTE ''CREATE TRIGGER check_auth BEFORE UPDATE OR DELETE ON '' 
+#ifdef HAS_SCHEMAS
+		|| quote_ident(schema) || ''.'' || quote_ident($2)
+#else
+		|| quote_ident($2)
+#endif
+		||'' FOR EACH ROW EXECUTE PROCEDURE CheckAuthTrigger(''
+		|| quote_literal($3) || '')'';
+
+	RETURN 0;
+END;
+'
+LANGUAGE 'plpgsql';
+
+-- CheckAuth(<table>, <ridcolumn>)
+CREATEFUNCTION CheckAuth(text, text)
+	RETURNS INT
+	AS
+	'SELECT CheckAuth('''', $1, $2)'
+	LANGUAGE 'SQL';
+
+CREATEFUNCTION CheckAuthTrigger()
+	RETURNS trigger AS 
+	'@MODULE_FILENAME@', 'check_authorization'
+	LANGUAGE C;
+
+CREATEFUNCTION GetTransactionID()
+	RETURNS xid AS 
+	'@MODULE_FILENAME@', 'getTransactionID'
+	LANGUAGE C;
+
+
+--
+-- Enable Long transactions support
+--
+--  Creates the authorization_table if not already existing
+--
+CREATEFUNCTION EnableLongTransactions()
+	RETURNS TEXT
+	AS '
+DECLARE
+	query text;
+	exists bool;
+	rec RECORD;
+
+BEGIN
+
+	exists = ''f'';
+	FOR rec IN SELECT * FROM pg_class WHERE relname = ''authorization_table''
+	LOOP
+		exists = ''t'';
+	END LOOP;
+
+	IF NOT exists
+	THEN
+		query = ''CREATE TABLE authorization_table (
+			toid oid, -- table oid
+			rid text, -- row id
+			expires timestamp,
+			authid text
+		)'';
+		EXECUTE query;
+	END IF;
+
+	exists = ''f'';
+	FOR rec IN SELECT * FROM pg_class WHERE relname = ''authorized_tables''
+	LOOP
+		exists = ''t'';
+	END LOOP;
+
+	IF NOT exists THEN
+		query = ''CREATE VIEW authorized_tables AS '' ||
+			''SELECT '' ||
+#ifdef HAS_SCHEMAS
+			''n.nspname as schema, '' ||
+#endif
+			''c.relname as table, trim('' ||
+			quote_literal(chr(92) || ''000'') ||
+			'' from t.tgargs) as id_column '' ||
+			''FROM pg_trigger t, pg_class c, pg_proc p '' ||
+#ifdef HAS_SCHEMAS
+			'', pg_namespace n '' ||
+#endif
+			''WHERE p.proname = '' || quote_literal(''checkauthtrigger'') ||
+#ifdef HAS_SCHEMAS
+			'' AND c.relnamespace = n.oid'' ||
+#endif
+			'' AND t.tgfoid = p.oid and t.tgrelid = c.oid'';
+		EXECUTE query;
+	END IF;
+
+	RETURN ''Long transactions support enabled'';
+END;
+'
+LANGUAGE 'plpgsql';
+
+--
+-- Check if Long transactions support is enabled
+--
+CREATEFUNCTION LongTransactionsEnabled()
+	RETURNS bool
+AS '
+DECLARE
+	rec RECORD;
+BEGIN
+	FOR rec IN SELECT oid FROM pg_class WHERE relname = ''authorized_tables''
+	LOOP
+		return ''t'';
+	END LOOP;
+	return ''f'';
+END;
+'
+LANGUAGE 'plpgsql';
+
+--
+-- Disable Long transactions support
+--
+--  (1) Drop any long_xact trigger 
+--  (2) Drop the authorization_table
+--  (3) KEEP the authorized_tables view
+--
+CREATEFUNCTION DisableLongTransactions()
+	RETURNS TEXT
+	AS '
+DECLARE
+	query text;
+	exists bool;
+	rec RECORD;
+
+BEGIN
+
+	--
+	-- Drop all triggers applied by CheckAuth()
+	--
+	FOR rec IN
+		SELECT c.relname, t.tgname, t.tgargs FROM pg_trigger t, pg_class c, pg_proc p
+		WHERE p.proname = ''checkauthtrigger'' and t.tgfoid = p.oid and t.tgrelid = c.oid
+	LOOP
+		EXECUTE ''DROP TRIGGER '' || quote_ident(rec.tgname) ||
+			'' ON '' || quote_ident(rec.relname);
+	END LOOP;
+
+	--
+	-- Drop the authorization_table table
+	--
+	FOR rec IN SELECT * FROM pg_class WHERE relname = ''authorization_table'' LOOP
+		DROP TABLE authorization_table;
+	END LOOP;
+
+	--
+	-- Drop the authorized_tables view
+	--
+	FOR rec IN SELECT * FROM pg_class WHERE relname = ''authorized_tables'' LOOP
+		DROP VIEW authorized_tables;
+	END LOOP;
+
+	RETURN ''Long transactions support disabled'';
+END;
+'
+LANGUAGE 'plpgsql';
+
+---------------------------------------------------------------
+-- END
+---------------------------------------------------------------
+

Modified: packages/postgis/upstream/lwgeom/lwcollection.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwcollection.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwcollection.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwcollection.c 2369 2006-05-30 08:38:58Z strk $
+ * $Id: lwcollection.c 2532 2006-12-01 22:16:44Z mleslie $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -30,6 +30,10 @@
 	unsigned int i;
 #endif
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcollection_construct called.");
+#endif        
+
 	hasz = 0;
 	hasm = 0;
 	if ( ngeoms > 0 )
@@ -38,10 +42,16 @@
 		hasm = TYPE_HASM(geoms[0]->type);
 #ifdef CHECK_LWGEOM_ZM
 		zm = TYPE_GETZM(geoms[0]->type);
+#ifdef PGIS_DEBUG
+                lwnotice("lwcollection_construct type[0]=%d", geoms[0]->type);
+#endif
 		for (i=1; i<ngeoms; i++)
 		{
+#ifdef PGIS_DEBUG
+                        lwnotice("lwcollection_construct type=[%d]=%d", i, geoms[i]->type);
+#endif
 			if ( zm != TYPE_GETZM(geoms[i]->type) )
-				lwerror("lwcollection_construct: mixed dimension geometries");
+				lwerror("lwcollection_construct: mixed dimension geometries: %d/%d", zm, TYPE_GETZM(geoms[i]->type));
 		}
 #endif
 	}

Added: packages/postgis/upstream/lwgeom/lwcompound.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwcompound.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwcompound.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,120 @@
+/**********************************************************************
+ * $Id$
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2001-2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ * 
+ **********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "liblwgeom.h"
+
+LWCOMPOUND *
+lwcompound_deserialize(uchar *serialized)
+{
+        LWCOMPOUND *result;
+        LWGEOM_INSPECTED *insp;
+        int type = lwgeom_getType(serialized[0]);
+        int i;
+
+        if(type != COMPOUNDTYPE)
+        {
+                lwerror("lwcompound_deserialize called on non compound: %d", type);
+                return NULL;
+        }
+
+        insp = lwgeom_inspect(serialized);
+
+        result = lwalloc(sizeof(LWCOMPOUND));
+        result->type = insp->type;
+        result->SRID = insp->SRID;
+        result->ngeoms = insp->ngeometries;
+        result->geoms = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
+
+        if(lwgeom_hasBBOX(serialized[0]))
+        {
+                result->bbox = lwalloc(sizeof(BOX2DFLOAT4));
+                memcpy(result->bbox, serialized + 1, sizeof(BOX2DFLOAT4));
+        }
+        else result->bbox = NULL;
+
+        for(i = 0; i < insp->ngeometries; i++)
+        {
+                if(lwgeom_getType(insp->sub_geoms[i][0]) == LINETYPE)
+                        result->geoms[i] = (LWGEOM *)lwline_deserialize(insp->sub_geoms[i]);
+                else
+                        result->geoms[i] = (LWGEOM *)lwcurve_deserialize(insp->sub_geoms[i]);
+                if(TYPE_NDIMS(result->geoms[i]->type) != TYPE_NDIMS(result->type))
+                {
+                        lwerror("Mixed dimensions (compound:%d, line/curve%d:%d)",
+                            TYPE_NDIMS(result->type), i,
+                            TYPE_NDIMS(result->geoms[i]->type)
+                        );
+                        lwfree(result);
+                        return NULL;
+                }
+        }
+        return result;
+}
+
+/*
+ * Add 'what' to this string at position 'where'
+ * where=0 == prepend
+ * where=-1 == append
+ * Returns a COMPOUND or a GEOMETRYCOLLECTION
+ */
+LWGEOM *
+lwcompound_add(const LWCOMPOUND *to, uint32 where, const LWGEOM *what)
+{
+        LWCOLLECTION *col;
+        LWGEOM **geoms;
+        int newtype;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcompound_add called.");
+#endif
+
+        if(where != -1 && where != 0)
+        {
+                lwerror("lwcompound_add only supports 0 or -1 as a second argument, not %d", where);
+                return NULL;
+        }
+
+        /* dimensions compatibility are checked by caller */
+
+        /* Construct geoms array */
+        geoms = lwalloc(sizeof(LWGEOM *)*2);
+        if(where == -1) /* append */
+        {
+                geoms[0] = lwgeom_clone((LWGEOM *)to);
+                geoms[1] = lwgeom_clone(what);
+        }
+        else /* prepend */
+        {
+                geoms[0] = lwgeom_clone(what);
+                geoms[1] = lwgeom_clone((LWGEOM *)to);
+        }
+
+        /* reset SRID and wantbbox flag from component types */
+        geoms[0]->SRID = geoms[1]->SRID = -1;
+        TYPE_SETHASSRID(geoms[0]->type, 0);
+        TYPE_SETHASSRID(geoms[1]->type, 0);
+        TYPE_SETHASBBOX(geoms[0]->type, 0);
+        TYPE_SETHASBBOX(geoms[1]->type, 0);
+
+        /* Find appropriate geom type */
+        if(TYPE_GETTYPE(what->type) == LINETYPE || TYPE_GETTYPE(what->type) == CURVETYPE) newtype = COMPOUNDTYPE;
+        else newtype = COLLECTIONTYPE;
+
+        col = lwcollection_construct(newtype,
+                to->SRID, NULL, 2, geoms);
+
+        return (LWGEOM *)col;
+}
+

Added: packages/postgis/upstream/lwgeom/lwcurve.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwcurve.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwcurve.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,749 @@
+/**********************************************************************
+ * $Id$
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2001-2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ * 
+ **********************************************************************/
+
+/* basic LWCURVE functions */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include "liblwgeom.h"
+
+/*#define PGIS_DEBUG_CALLS 1 */
+/*#define PGIS_DEBUG 1 */
+
+#ifndef MAXFLOAT
+  #define MAXFLOAT      3.40282347e+38F
+#endif
+
+/*
+ * Construct a new LWCURVE.  points will *NOT* be copied
+ * use SRID=-1 for unknown SRID (will have 8bit type's S = 0)
+ */
+LWCURVE *
+lwcurve_construct(int SRID, BOX2DFLOAT4 *bbox, POINTARRAY *points)
+{
+        /*
+         * The first arc requires three points.  Each additional
+         * arc requires two more points.  Thus the minimum point count
+         * is three, and the count must be odd.
+         */
+        if(points->npoints % 2 != 1 || points->npoints < 3) 
+        {
+                lwerror("lwcurve_construct: invalid point count %d", points->npoints);
+                return NULL;
+        }
+        
+        LWCURVE *result;
+        result = (LWCURVE*) lwalloc(sizeof(LWCURVE));
+
+        result->type = lwgeom_makeType_full(
+                TYPE_HASZ(points->dims),
+                TYPE_HASM(points->dims),
+                (SRID!=-1), CURVETYPE, 0);
+        result->SRID = SRID;
+        result->points = points;
+        result->bbox = bbox;
+         
+        return result;
+}
+
+/*
+ * given the LWGEOM serialized form (or a point into a multi* one)
+ * construct a propert LWCURVE.
+ * serialized_form should point to the 8bit type format (with type = 8)
+ * See serialized form doc
+ */
+LWCURVE *
+lwcurve_deserialize(uchar *serialized_form)
+{
+        uchar type;
+        LWCURVE *result;
+        uchar *loc=NULL;
+        uint32 npoints;
+        POINTARRAY *pa;
+
+        type = (uchar)serialized_form[0];
+        if(lwgeom_getType(type) != CURVETYPE)
+        {
+                lwerror("lwcurve_deserialize: attempt to deserialize a curve which is really a %s", lwgeom_typename(type));
+                return NULL;
+        }
+
+        result = (LWCURVE*) lwalloc(sizeof(LWCURVE));
+        result->type = type;
+
+        loc = serialized_form + 1;
+
+        if(lwgeom_hasBBOX(type))
+        {
+#ifdef PGIS_DEBUG
+                lwnotice("lwcurve_deserialize: input has bbox");
+#endif
+                result->bbox = lwalloc(sizeof(BOX2DFLOAT4));
+                memcpy(result->bbox, loc, sizeof(BOX2DFLOAT4));
+                loc += sizeof(BOX2DFLOAT4);               
+         }
+         else
+         {
+#ifdef PGIS_DEBUG
+                lwnotice("lwcurve_deserialize: input lacks bbox");           
+#endif               
+                result->bbox = NULL;
+         }
+
+         if(lwgeom_hasSRID(type))
+         {
+#ifdef PGIS_DEBUG
+                lwnotice("lwcurve_deserialize: input has srid");
+#endif
+                result->SRID = get_int32(loc);               
+                loc += 4; /* type + SRID */
+         }
+         else
+         {
+#ifdef PGIS_DEBUG
+                lwnotice("lwcurve_deserialize: input lacks srid");
+#endif
+                result->SRID = -1;                
+         }
+
+         /* we've read the type (1 byte) and SRID (4 bytes, if present) */
+
+         npoints = get_uint32(loc);
+#ifdef PGIS_DEBUG
+         lwnotice("curve npoints = %d", npoints);
+#endif         
+         loc += 4;
+         pa = pointArray_construct(loc, TYPE_HASZ(type), TYPE_HASM(type), npoints);
+         result->points = pa;
+         return result;
+}
+
+/*
+ * convert this curve into its serialized form
+ * result's first char will be the 8bit type. See serialized form doc
+ */
+uchar *
+lwcurve_serialize(LWCURVE *curve)
+{
+        size_t size, retsize;
+        uchar * result;
+
+        if(curve == NULL) {
+                lwerror("lwcurve_serialize:: given null curve");
+                return NULL;
+        }
+
+        size = lwcurve_serialize_size(curve);
+        result = lwalloc(size);
+        lwcurve_serialize_buf(curve, result, &retsize);
+        if(retsize != size)
+                lwerror("lwcurve_serialize_size returned %d, ..selialize_buf returned %d", size, retsize);
+        return result;
+}
+
+/*
+ * convert this curve into its serialized form writing it into 
+ * the given buffer, and returning number of bytes written into 
+ * the given int pointer.
+ * result's first char will be the 8bit type.  See serialized form doc
+ */
+void lwcurve_serialize_buf(LWCURVE *curve, uchar *buf, size_t *retsize)
+{
+        char hasSRID;
+        uchar *loc;
+        int ptsize;
+        size_t size;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcurve_serialize_buf(%p, %p, %p) called",
+                curve, buf, retsize);
+#endif
+
+        if(curve == NULL) 
+        {
+                lwerror("lwcurve_serialize:: given null curve");
+                return;
+        }
+
+        if(TYPE_GETZM(curve->type) != TYPE_GETZM(curve->points->dims))
+        {
+                lwerror("Dimensions mismatch in lwcurve");
+                return;
+        }
+
+        ptsize = pointArray_ptsize(curve->points);
+
+        hasSRID = (curve->SRID != -1);
+
+        buf[0] = (uchar)lwgeom_makeType_full(
+                TYPE_HASZ(curve->type), TYPE_HASM(curve->type),
+                hasSRID, CURVETYPE, curve->bbox ? 1 : 0);
+        loc = buf+1;
+
+#ifdef PGIS_DEBUG
+        lwnotice("lwcurve_serialize_buf added type (%d)", curve->type);
+#endif
+
+        if(curve->bbox)
+        {
+                memcpy(loc, curve->bbox, sizeof(BOX2DFLOAT4));
+                loc += sizeof(BOX2DFLOAT4);
+
+#ifdef PGIS_DEBUG
+                lwnotice("lwcurve_serialize_buf added BBOX");
+#endif
+
+        }                
+
+        if(hasSRID)
+        {
+                memcpy(loc, &curve->SRID, sizeof(int32));
+                loc += sizeof(int32);
+
+#ifdef PGIS_DEBUG
+                lwnotice("lwcurve_serialize_buf added SRID");
+#endif
+
+        }
+
+        memcpy(loc, &curve->points->npoints, sizeof(uint32));
+        loc += sizeof(uint32);
+
+#ifdef PGIS_DEBUG
+        lwnotice("lwcurve_serialize_buf added npoints (%d)",
+            curve->points->npoints);
+#endif
+
+        /* copy in points */
+        size = curve->points->npoints * ptsize;
+        memcpy(loc, getPoint_internal(curve->points, 0), size);
+        loc += size;
+
+#ifdef PGIS_DEBUG
+        lwnotice("lwcurve_serialize_buf copied serialized_pointlist (%d bytes)",
+                ptsize * curve->points->npoints);        
+#endif
+
+        if(retsize) *retsize = loc-buf;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcurve_serialize_buf returning (loc: %p, size: %d)",
+                loc, loc-buf);
+#endif
+}
+
+/* find length of this deserialized curve */
+size_t
+lwcurve_serialize_size(LWCURVE *curve)
+{
+        size_t size = 1; /* type */
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcurve_serialize_size called");        
+#endif
+
+        if(curve->SRID != -1) size += 4; /* SRID */
+        if(curve->bbox) size += sizeof(BOX2DFLOAT4);
+
+        size += 4; /* npoints */
+        size += pointArray_ptsize(curve->points) * curve->points->npoints;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcurve_serialize_size returning %d", size);
+#endif
+
+        return size;
+}
+
+BOX3D *
+lwcircle_compute_box3d(POINT4D *p1, POINT4D *p2, POINT4D *p3)
+{
+        double x1, x2, y1, y2, z1, z2;
+        double angle, radius, sweep;
+        /*
+        double top, left;
+        */
+        double a1, a2, a3;
+        double xe = 0.0, ye = 0.0;
+        POINT4D *center;
+        int i;
+        BOX3D *box;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcircle_compute_box3d called.");
+#endif
+
+        center = lwalloc(sizeof(POINT4D));
+        radius = lwcircle_center(p1, p2, p3, &center);
+        if(radius < 0.0) return NULL;
+
+        /*
+        top = center->y + radius;
+        left = center->x - radius;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcircle_compute_box3d: top=%.16f, left=%.16f", top, left);
+#endif
+        */
+
+        x1 = MAXFLOAT;
+        x2 = -1 * MAXFLOAT;
+        y1 = MAXFLOAT;
+        y2 = -1 * MAXFLOAT;
+
+        a1 = atan2(p1->y - center->y, p1->x - center->x);
+        a2 = atan2(p2->y - center->y, p2->x - center->x);
+        a3 = atan2(p3->y - center->y, p3->x - center->x);
+
+        /* Determine sweep angle */
+        if(a1 > a2 && a2 > a3) 
+        {
+                sweep = a3 - a1;
+        }
+        /* Counter-clockwise */
+        else if(a1 < a2 && a2 < a3)
+        {
+                sweep = a3 - a1;
+        }
+        /* Clockwise, wrap */
+        else if((a1 < a2 && a1 > a3) || (a2 < a3 && a1 > a3))
+        {
+                sweep = a3 - a1 + 2*M_PI;
+        }
+        /* Counter-clockwise, wrap */
+        else if((a1 > a2 && a1 < a3) || (a2 > a3 && a1 < a3))
+        {
+                sweep = a3 - a1 - 2*M_PI;
+        } 
+        else 
+        {
+                sweep = 0.0;
+        }
+
+#ifdef PGIS_DEBUG
+        lwnotice("a1 %.16f, a2 %.16f, a3 %.16f, sweep %.16f", a1, a2, a3, sweep);
+#endif
+
+        angle = 0.0;
+        for(i=0; i < 6; i++)
+        {
+                switch(i) {
+                case 0:
+                        angle = 0.0;
+                        xe = center->x + radius;
+                        ye = center->y;
+                        break;
+                case 1:
+                        angle = M_PI_2;
+                        xe = center->x;
+                        ye = center->y + radius;
+                        break;
+                case 2:
+                        angle = M_PI;
+                        xe = center->x - radius;
+                        ye = center->y;
+                        break;
+                case 3:
+                        angle = -1 * M_PI_2;
+                        xe = center->x;
+                        ye = center->y - radius;
+                        break;
+                case 4:
+                        angle = a1;
+                        xe = p1->x;
+                        ye = p1->y;
+                        break;
+                case 5:
+                        angle = a3;
+                        xe = p3->x;
+                        ye = p3->y;
+                        break;
+                }
+                if(i < 4) 
+                {
+                        if(sweep > 0.0 && (angle > a3 || angle < a1)) continue;
+                        if(sweep < 0.0 && (angle < a3 || angle > a1)) continue;
+                }
+
+#ifdef PGIS_DEBUG
+                lwnotice("lwcircle_compute_box3d: potential extreame %d (%.16f, %.16f)", i, xe, ye);
+#endif
+                x1 = (x1 < xe) ? x1 : xe;
+                y1 = (y1 < ye) ? y1 : ye;
+                x2 = (x2 > xe) ? x2 : xe;
+                y2 = (y2 > ye) ? y2 : ye;
+        }
+#ifdef PGIS_DEBUG
+        lwnotice("lwcircle_compute_box3d: extreames found (%.16f %.16f, %.16f %.16f)", x1, y1, x2, y2);
+#endif
+
+        /*
+        x1 = center->x + x1 * radius;
+        x2 = center->x + x2 * radius;
+        y1 = center->y + y1 * radius;
+        y2 = center->y + y2 * radius;
+        */
+        z1 = (p1->z < p2->z) ? p1->z : p2->z;
+        z1 = (z1 < p3->z) ? z1 : p3->z;
+        z2 = (p1->z > p2->z) ? p1->z : p2->z;
+        z2 = (z2 > p3->z) ? z2 : p3->z;
+
+        box = lwalloc(sizeof(BOX3D));
+        box->xmin = x1; box->xmax = x2;
+        box->ymin = y1; box->ymax = y2;
+        box->zmin = z1; box->zmax = z2;
+
+        lwfree(center);
+
+        return box;
+}
+
+/*
+ * Find bounding box (standard one)
+ * zmin=zmax=NO_Z_VALUE if 2d
+ * TODO: This ignores curvature, which should be taken into account.
+ */
+BOX3D *
+lwcurve_compute_box3d(LWCURVE *curve)
+{
+        BOX3D *box, *tmp; 
+        int i;
+        POINT4D *p1 = lwalloc(sizeof(POINT4D));
+        POINT4D *p2 = lwalloc(sizeof(POINT4D));
+        POINT4D *p3 = lwalloc(sizeof(POINT4D));
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcurve_compute_box3d called.");
+#endif
+
+        /* initialize box values */
+        box = lwalloc(sizeof(BOX3D));
+        box->xmin = MAXFLOAT; box->xmax = -1 * MAXFLOAT;
+        box->ymin = MAXFLOAT; box->ymax = -1 * MAXFLOAT;
+        box->zmin = MAXFLOAT; box->zmax = -1 * MAXFLOAT;
+        
+        for(i = 2; i < curve->points->npoints; i+=2)
+        {
+                getPoint4d_p(curve->points, i-2, p1);
+                getPoint4d_p(curve->points, i-1, p2);
+                getPoint4d_p(curve->points, i, p3);
+                tmp = lwcircle_compute_box3d(p1, p2, p3);
+                if(tmp == NULL) continue;
+                box->xmin = (box->xmin < tmp->xmin) ? box->xmin : tmp->xmin;
+                box->xmax = (box->xmax > tmp->xmax) ? box->xmax : tmp->xmax;
+                box->ymin = (box->ymin < tmp->ymin) ? box->ymin : tmp->ymin;
+                box->ymax = (box->ymax > tmp->ymax) ? box->ymax : tmp->ymax;
+                box->zmin = (box->zmin < tmp->zmin) ? box->zmin : tmp->zmin;
+                box->zmax = (box->zmax > tmp->zmax) ? box->zmax : tmp->zmax;
+#ifdef PGIS_DEBUG_CALLS
+                lwnotice("curve %d x=(%.16f,%.16f) y=(%.16f,%.16f) z=(%.16f,%.16f)", i/2, box->xmin, box->xmax, box->ymin, box->ymax, box->zmin, box->zmax);
+#endif
+        }
+
+        
+        return box;
+}
+
+int
+lwcurve_compute_box2d_p(LWCURVE *curve, BOX2DFLOAT4 *result)
+{
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcurve_compute_box2d_p called.");
+#endif
+
+        BOX3D *box = lwcurve_compute_box3d(curve);
+        if(box == NULL) return 0;
+        box3d_to_box2df_p(box, result);
+        return 1;
+}
+
+void pfree_curve(LWCURVE *curve)
+{
+        lwfree(curve->points);
+        lwfree(curve);
+}
+
+/* find length of this serialized curve */
+size_t
+lwgeom_size_curve(const uchar *serialized_curve)
+{
+        int type = (uchar)serialized_curve[0];
+        uint32 result = 1; /* type */
+        const uchar *loc;
+        uint32 npoints;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwgeom_size_curve called");
+#endif
+        if(lwgeom_getType(type) != CURVETYPE)
+                lwerror("lwgeom_size_curve::attempt to find the length of a non-curve");
+
+        loc = serialized_curve + 1;
+        if(lwgeom_hasBBOX(type))
+        {
+                loc += sizeof(BOX2DFLOAT4);
+                result += sizeof(BOX2DFLOAT4);
+        }
+
+        if(lwgeom_hasSRID(type))
+        {
+                loc += 4; /* type + SRID */
+                result += 4;
+        }
+
+        /* we've read the type (1 byte) and SRID (4 bytes, if present) */
+        npoints = get_uint32(loc);
+        result += sizeof(uint32); /* npoints */
+
+        result += TYPE_NDIMS(type) * sizeof(double) * npoints;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwgeom_size_curve returning %d", result);
+#endif        
+
+        return result;
+}
+
+void printLWCURVE(LWCURVE *curve)
+{
+        lwnotice("LWCURVE {");
+        lwnotice("    ndims = %i", (int)TYPE_NDIMS(curve->type));
+        lwnotice("    SRID = %i", (int)curve->SRID);
+        printPA(curve->points);
+        lwnotice("}");
+}
+
+/* Clone LWCURVE object.  POINTARRAY is not copied. */
+LWCURVE *
+lwcurve_clone(const LWCURVE *g)
+{
+        LWCURVE *ret = lwalloc(sizeof(LWCURVE));
+        memcpy(ret, g, sizeof(LWCURVE));
+        if(g->bbox) ret->bbox = box2d_clone(g->bbox);
+        return ret;
+}
+
+/*
+ * Add 'what' to this curve at position 'where'.
+ * where=0 == prepend
+ * where=-1 == append
+ * Returns a MULTICURVE or a GEOMETRYCOLLECTION
+ */
+LWGEOM *
+lwcurve_add(const LWCURVE *to, uint32 where, const LWGEOM *what)
+{
+        LWCOLLECTION *col;
+        LWGEOM **geoms;
+        int newtype;
+        
+        if(where != -1 && where != 0)
+        {
+                lwerror("lwcurve_add only supports 0 or -1 as second argument %d", where);
+                return NULL;
+        }
+
+        /* dimensions compatibility are checked by caller */
+
+        /* Construct geoms array */
+        geoms = lwalloc(sizeof(LWGEOM *)*2);
+        if(where == -1) /* append */
+        {
+                geoms[0] = lwgeom_clone((LWGEOM *)to);
+                geoms[1] = lwgeom_clone(what);
+        }
+        else /* prepend */
+        {
+                geoms[0] = lwgeom_clone(what);
+                geoms[1] = lwgeom_clone((LWGEOM *)to);
+        }
+        
+        /* reset SRID and wantbbox flag from component types */
+        geoms[0]->SRID = geoms[1]->SRID = -1;
+        TYPE_SETHASSRID(geoms[0]->type, 0);
+        TYPE_SETHASSRID(geoms[1]->type, 0);
+        TYPE_SETHASBBOX(geoms[0]->type, 0);
+        TYPE_SETHASBBOX(geoms[1]->type, 0);
+
+        /* Find appropriate geom type */
+        if(TYPE_GETTYPE(what->type) == CURVETYPE || TYPE_GETTYPE(what->type) == LINETYPE) newtype = MULTICURVETYPE;
+        else newtype = COLLECTIONTYPE;
+
+        col = lwcollection_construct(newtype, 
+                to->SRID, NULL, 
+                2, geoms);
+
+        return (LWGEOM *)col;
+}
+
+void lwcurve_reverse(LWCURVE *curve)
+{
+        ptarray_reverse(curve->points);
+}
+
+/*
+ * TODO: Invalid segmentization.  This should accomodate the curvature.
+ */
+LWCURVE *
+lwcurve_segmentize2d(LWCURVE *curve, double dist)
+{
+        return lwcurve_construct(curve->SRID, NULL,
+                ptarray_segmentize2d(curve->points, dist));
+}
+                    
+/* check coordinate equality */
+char
+lwcurve_same(const LWCURVE *me, const LWCURVE *you)
+{
+        return ptarray_same(me->points, you->points);
+}
+
+/*
+ * Construct a LWCURVE from an array of LWPOINTs
+ * LWCURVE dimensions are large enough to host all input dimensions.
+ */
+LWCURVE *
+lwcurve_from_lwpointarray(int SRID, unsigned int npoints, LWPOINT **points)
+{
+        int zmflag=0;
+        unsigned int i;
+        POINTARRAY *pa;
+        uchar *newpoints, *ptr;
+        size_t ptsize, size;
+
+        /*
+         * Find output dimensions, check integrity
+         */
+        for(i = 0; i < npoints; i++)
+        {
+                if(TYPE_GETTYPE(points[i]->type) != POINTTYPE)
+                {
+                        lwerror("lwcurve_from_lwpointarray: invalid input type: %s",
+                            lwgeom_typename(TYPE_GETTYPE(points[i]->type)));
+                        return NULL;
+                }
+                if(TYPE_HASZ(points[i]->type)) zmflag |= 2;
+                if(TYPE_HASM(points[i]->type)) zmflag |=1;
+                if(zmflag == 3) break;
+        }
+
+        if(zmflag == 0) ptsize = 2 * sizeof(double);
+        else if(zmflag == 3) ptsize = 4 * sizeof(double);
+        else ptsize = 3 * sizeof(double);
+
+        /*
+         * Allocate output points array
+         */
+        size = ptsize * npoints;
+        newpoints = lwalloc(size);
+        memset(newpoints, 0, size);
+
+        ptr = newpoints;
+        for(i = 0; i < npoints; i++)
+        {
+                size = pointArray_ptsize(points[i]->point);
+                memcpy(ptr, getPoint_internal(points[i]->point, 0), size);
+                ptr += ptsize;
+        }
+        pa = pointArray_construct(newpoints, zmflag&2, zmflag&1, npoints);
+
+        return lwcurve_construct(SRID, NULL, pa);
+}
+
+/*
+ * Construct a LWCURVE from a LWMPOINT
+ */
+LWCURVE *
+lwcurve_from_lwmpoint(int SRID, LWMPOINT *mpoint)
+{
+        unsigned int i;
+        POINTARRAY *pa;
+        char zmflag = TYPE_GETZM(mpoint->type);
+        size_t ptsize, size;
+        uchar *newpoints, *ptr;
+
+        if(zmflag == 0) ptsize = 2 * sizeof(double);
+        else if(zmflag == 3) ptsize = 4 * sizeof(double);
+        else ptsize = 3 * sizeof(double);
+
+        /* Allocate space for output points */
+        size = ptsize * mpoint->ngeoms;
+        newpoints = lwalloc(size);
+        memset(newpoints, 0, size);
+
+        ptr = newpoints;
+        for(i = 0; i < mpoint->ngeoms; i++)
+        {
+                memcpy(ptr,
+                        getPoint_internal(mpoint->geoms[i]->point, 0),
+                        ptsize);
+                ptr += ptsize;
+        }
+
+        pa = pointArray_construct(newpoints, zmflag&2, zmflag&1,
+                mpoint->ngeoms);
+
+#ifdef PGIS_DEBUG
+        lwnotice("lwcurve_from_lwmpoint: constructed pointarray for %d points, %d zmflag", mpoint->ngeoms, zmflag);
+#endif
+        
+        return lwcurve_construct(SRID, NULL, pa);
+}
+
+LWCURVE *
+lwcurve_addpoint(LWCURVE *curve, LWPOINT *point, unsigned int where)
+{
+        POINTARRAY *newpa;
+        LWCURVE *ret;
+
+        newpa = ptarray_addPoint(curve->points, 
+                getPoint_internal(point->point, 0),
+                TYPE_NDIMS(point->type), where);
+        ret = lwcurve_construct(curve->SRID, NULL, newpa);
+
+        return ret;
+}
+
+LWCURVE *
+lwcurve_removepoint(LWCURVE *curve, unsigned int index)
+{
+        POINTARRAY *newpa;
+        LWCURVE *ret;
+
+        newpa = ptarray_removePoint(curve->points, index);
+        ret = lwcurve_construct(curve->SRID, NULL, newpa);
+
+        return ret;
+}
+
+/*
+ * Note: input will be changed, make sure you have permissions for this.
+ * */
+void
+lwcurve_setPoint4d(LWCURVE *curve, unsigned int index, POINT4D *newpoint)
+{
+        setPoint4d(curve->points, index, newpoint);
+}
+
+
+
+
+
+
+
+
+
+
+
+

Added: packages/postgis/upstream/lwgeom/lwcurvepoly.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwcurvepoly.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwcurvepoly.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,89 @@
+/**********************************************************************
+ * $Id$
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2001-2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ * 
+ **********************************************************************/
+
+/* basic LWCURVEPOLY manipulation */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "liblwgeom.h"
+
+/*#define PGIS_DEBUG_CALLS 1 */
+
+LWCURVEPOLY *
+lwcurvepoly_deserialize(uchar *srl)
+{
+        LWCURVEPOLY *result;
+        LWGEOM_INSPECTED *insp;
+        int type = lwgeom_getType(srl[0]);
+        int i;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcurvepoly_deserialize called.");
+#endif
+
+        if(type != CURVEPOLYTYPE)
+        {
+                lwerror("lwcurvepoly_deserialize called on NON curvepoly: %d",
+                        type);
+                return NULL;
+        }
+
+        insp = lwgeom_inspect(srl);
+
+        result = lwalloc(sizeof(LWCURVEPOLY));
+        result->type = insp->type;
+        result->SRID = insp->SRID;
+        result->nrings = insp->ngeometries;
+        result->rings = lwalloc(sizeof(LWGEOM *)*insp->ngeometries);
+
+        if(lwgeom_hasBBOX(srl[0]))
+        {
+                result->bbox = lwalloc(sizeof(BOX2DFLOAT4));
+                memcpy(result->bbox, srl + 1, sizeof(BOX2DFLOAT4));
+        }
+        else result->bbox = NULL;
+
+        for(i = 0; i < insp->ngeometries; i++)
+        {
+                result->rings[i] = lwgeom_deserialize(insp->sub_geoms[i]);
+                if(lwgeom_getType(result->rings[i]->type) != CURVETYPE 
+                        && lwgeom_getType(result->rings[i]->type) != LINETYPE)
+                {
+                        lwerror("Only Circular curves and Linestrings are currently supported as rings, not %s (%d)", lwgeom_typename(result->rings[i]->type), result->rings[i]->type);
+                        lwfree(result);
+                        lwfree(insp);
+                        return NULL;
+                }
+                if(TYPE_NDIMS(result->rings[i]->type) != TYPE_NDIMS(result->type))
+                {
+                        lwerror("Mixed dimensions (curvepoly %d, ring %d)",
+                                TYPE_NDIMS(result->type), i, 
+                                TYPE_NDIMS(result->rings[i]->type));
+                        lwfree(result);
+                        lwfree(insp);
+                        return NULL;
+                }
+        }
+        return result;
+}
+
+LWGEOM *
+lwcurvepoly_add(const LWCURVEPOLY *to, uint32 where, const LWGEOM *what)
+{
+        /* TODO */
+        lwerror("lwcurvepoly_add not yet implemented.");
+        return NULL;
+}
+
+
+

Modified: packages/postgis/upstream/lwgeom/lwgeom.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom.c 2370 2006-05-30 08:47:00Z strk $
+ * $Id: lwgeom.c 2532 2006-12-01 22:16:44Z mleslie $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -27,7 +27,7 @@
 	int type = lwgeom_getType(srl[0]);
 
 #ifdef PGIS_DEBUG_CALLS
-	lwnotice("lwgeom_deserialize got %s", lwgeom_typename(type));
+	lwnotice("lwgeom_deserialize got %d - %s", type, lwgeom_typename(type));
 #endif
 
 	switch (type)
@@ -36,6 +36,8 @@
 			return (LWGEOM *)lwpoint_deserialize(srl);
 		case LINETYPE:
 			return (LWGEOM *)lwline_deserialize(srl);
+                case CURVETYPE:
+                        return (LWGEOM *)lwcurve_deserialize(srl);
 		case POLYGONTYPE:
 			return (LWGEOM *)lwpoly_deserialize(srl);
 		case MULTIPOINTTYPE:
@@ -46,8 +48,20 @@
 			return (LWGEOM *)lwmpoly_deserialize(srl);
 		case COLLECTIONTYPE:
 			return (LWGEOM *)lwcollection_deserialize(srl);
+                case COMPOUNDTYPE:
+                        return (LWGEOM *)lwcompound_deserialize(srl);
+                case CURVEPOLYTYPE:
+                        return (LWGEOM *)lwcurvepoly_deserialize(srl);
+                case MULTICURVETYPE:
+                        return (LWGEOM *)lwmcurve_deserialize(srl);
+                case MULTISURFACETYPE:
+                        return (LWGEOM *)lwmsurface_deserialize(srl);
 		default:
+#ifdef PGIS_DEBUG
+                        lwerror("lwgeom_deserialize: Unknown geometry type: %d", type);
+#else
 			lwerror("Unknown geometry type: %d", type);
+#endif
 			return NULL;
 	}
 
@@ -70,13 +84,23 @@
 			return lwline_serialize_size((LWLINE *)lwgeom);
 		case POLYGONTYPE:
 			return lwpoly_serialize_size((LWPOLY *)lwgeom);
+                case CURVETYPE:
+                        return lwcurve_serialize_size((LWCURVE *)lwgeom);
+                case CURVEPOLYTYPE:
+                case COMPOUNDTYPE:
 		case MULTIPOINTTYPE:
 		case MULTILINETYPE:
+                case MULTICURVETYPE:
 		case MULTIPOLYGONTYPE:
+                case MULTISURFACETYPE:
 		case COLLECTIONTYPE:
 			return lwcollection_serialize_size((LWCOLLECTION *)lwgeom);
 		default:
+#ifdef PGIS_DEBUG
+                        lwerror("lwgeom_serialize_size: Unknown geometry type: %d", type);
+#else
 			lwerror("Unknown geometry type: %d", type);
+#endif
 			return 0;
 	}
 }
@@ -101,15 +125,26 @@
 		case POLYGONTYPE:
 			lwpoly_serialize_buf((LWPOLY *)lwgeom, buf, retsize);
 			break;
+                case CURVETYPE:
+                        lwcurve_serialize_buf((LWCURVE *)lwgeom, buf, retsize);
+                        break;
+                case CURVEPOLYTYPE:
+                case COMPOUNDTYPE:
 		case MULTIPOINTTYPE:
 		case MULTILINETYPE:
+                case MULTICURVETYPE:
 		case MULTIPOLYGONTYPE:
+                case MULTISURFACETYPE:
 		case COLLECTIONTYPE:
 			lwcollection_serialize_buf((LWCOLLECTION *)lwgeom, buf,
 				retsize);
 			break;
 		default:
+#ifdef PGIS_DEBUG
+                        lwerror("lwgeom_serialize_buf: Unknown geometry type: %d", type);
+#else
 			lwerror("Unknown geometry type: %d", type);
+#endif
 			return;
 	}
 	return;
@@ -191,11 +226,17 @@
 			return lwpoint_compute_box2d_p((LWPOINT *)lwgeom, buf);
 		case LINETYPE:
 			return lwline_compute_box2d_p((LWLINE *)lwgeom, buf);
+                case CURVETYPE:
+                        return lwcurve_compute_box2d_p((LWCURVE *)lwgeom, buf);
 		case POLYGONTYPE:
 			return lwpoly_compute_box2d_p((LWPOLY *)lwgeom, buf);
+                case COMPOUNDTYPE:
+                case CURVEPOLYTYPE:
 		case MULTIPOINTTYPE:
 		case MULTILINETYPE:
+                case MULTICURVETYPE:
 		case MULTIPOLYGONTYPE:
+                case MULTISURFACETYPE:
 		case COLLECTIONTYPE:
 			return lwcollection_compute_box2d_p((LWCOLLECTION *)lwgeom, buf);
 	}
@@ -232,6 +273,14 @@
 	else return NULL;
 }
 
+LWCURVE *
+lwgeom_as_lwcurve(LWGEOM *lwgeom)
+{
+        if( TYPE_GETTYPE(lwgeom->type) == CURVETYPE )
+                return (LWCURVE *)lwgeom;
+        else return NULL;
+}
+
 LWPOLY *
 lwgeom_as_lwpoly(LWGEOM *lwgeom)
 {
@@ -243,7 +292,8 @@
 LWCOLLECTION *
 lwgeom_as_lwcollection(LWGEOM *lwgeom)
 {
-	if ( TYPE_GETTYPE(lwgeom->type) >= MULTIPOINTTYPE )
+	if ( TYPE_GETTYPE(lwgeom->type) >= MULTIPOINTTYPE 
+            && TYPE_GETTYPE(lwgeom->type) <= COLLECTIONTYPE)
 		return (LWCOLLECTION *)lwgeom;
 	else return NULL;
 }
@@ -292,11 +342,21 @@
 #endif
 
 	/* Drop bounding box (always a copy) */
-	if ( lwgeom->bbox ) lwfree(lwgeom->bbox);
+	if ( lwgeom->bbox ) {
+#ifdef PGIS_DEBUG
+                lwnotice("lwgeom_release: releasing bbox.");
+#endif
+                lwfree(lwgeom->bbox);
+        }
 
 	/* Collection */
 	if ( (col=lwgeom_as_lwcollection(lwgeom)) )
 	{
+
+#ifdef PGIS_DEBUG
+                lwnotice("lwgeom_release: Releasing collection.");
+#endif
+
 		for (i=0; i<col->ngeoms; i++)
 		{
 			lwgeom_release(col->geoms[i]);
@@ -361,9 +421,19 @@
 			return (LWGEOM *)lwpoint_add((const LWPOINT *)to, where, what);
 		case LINETYPE:
 			return (LWGEOM *)lwline_add((const LWLINE *)to, where, what);
+
+                case CURVETYPE:
+                        return (LWGEOM *)lwcurve_add((const LWCURVE *)to, where, what);
+
 		case POLYGONTYPE:
 			return (LWGEOM *)lwpoly_add((const LWPOLY *)to, where, what);
 
+                case COMPOUNDTYPE:
+                        return (LWGEOM *)lwcompound_add((const LWCOMPOUND *)to, where, what);
+
+                case CURVEPOLYTYPE:
+                        return (LWGEOM *)lwcurvepoly_add((const LWCURVEPOLY *)to, where, what);
+
 		case MULTIPOINTTYPE:
 			return (LWGEOM *)lwmpoint_add((const LWMPOINT *)to,
 				where, what);
@@ -372,10 +442,18 @@
 			return (LWGEOM *)lwmline_add((const LWMLINE *)to,
 				where, what);
 
+                case MULTICURVETYPE:
+                        return (LWGEOM *)lwmcurve_add((const LWMCURVE *)to,
+                                where, what);
+
 		case MULTIPOLYGONTYPE:
 			return (LWGEOM *)lwmpoly_add((const LWMPOLY *)to,
 				where, what);
 
+                case MULTISURFACETYPE:
+                        return (LWGEOM *)lwmsurface_add((const LWMSURFACE *)to,
+                                where, what);
+
 		case COLLECTIONTYPE:
 			return (LWGEOM *)lwcollection_add(
 				(const LWCOLLECTION *)to, where, what);

Modified: packages/postgis/upstream/lwgeom/lwgeom_api.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_api.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_api.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -330,6 +330,13 @@
 int
 box3d_union_p(BOX3D *b1, BOX3D *b2, BOX3D *ubox)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("box3d_union_p called: (xmin, xmax), (ymin, ymax), (zmin, zmax)");
+        lwnotice("b1: (%.16f, %.16f),(%.16f, %.16f),(%.16f, %.16f)", b1->xmin, b1->xmax, b1->ymin, b1->ymax, b1->zmin, b1->zmax);
+        lwnotice("b2: (%.16f, %.16f),(%.16f, %.16f),(%.16f, %.16f)", b2->xmin, b2->xmax, b2->ymin, b2->ymax, b2->zmin, b2->zmax);
+#endif
+
 	if ( (b1 == NULL) && (b2 == NULL) )
 	{
 		return 0;
@@ -372,7 +379,7 @@
 	else
 		ubox->zmax = b2->zmax;
 
-	if (b1->zmin > b2->zmin)
+	if (b1->zmin < b2->zmin)
 		ubox->zmin = b1->zmin;
 	else
 		ubox->zmin = b2->zmin;
@@ -403,7 +410,7 @@
 	uchar *loc;
 	BOX3D box3d;
 
-#ifdef PGIS_DEBUG
+#ifdef PGIS_DEBUG_CALLS
 	lwnotice("getbox2d_p call");
 #endif
 
@@ -483,10 +490,18 @@
 	}
 #endif
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("getPoint4d_p called.");
+#endif
+
 	/* Get a pointer to nth point offset and zmflag */
 	ptr=getPoint_internal(pa, n);
 	zmflag=TYPE_GETZM(pa->dims);
 
+#ifdef PGIS_DEBUG
+        lwnotice("ptr %p, zmflag %d", ptr, zmflag);
+#endif
+
 	switch (zmflag)
 	{
 		case 0: /* 2d  */
@@ -513,7 +528,6 @@
 		default:
 			lwerror("Unknown ZM flag ??");
 	}
-
 	return 1;
 
 }
@@ -797,9 +811,9 @@
 int
 pointArray_ptsize(const POINTARRAY *pa)
 {
-#ifdef PGIS_DEBUG
-	lwnotice("pointArray_ptsize: TYPE_NDIMS(pa->dims)=%x\n",
-		TYPE_NDIMS(pa->dims));
+#ifdef PGIS_DEBUG_CALLS
+	/*lwnotice("pointArray_ptsize: TYPE_NDIMS(pa->dims)=%x\n",
+		TYPE_NDIMS(pa->dims));*/
 #endif
 	return sizeof(double)*TYPE_NDIMS(pa->dims);
 }
@@ -841,6 +855,11 @@
 int
 lwgeom_getType(uchar type)
 {
+
+#ifdef PGIS_DEBUG
+        lwnotice("lwgeom_getType %d", type);
+#endif
+
 	return (type & 0x0F);
 }
 
@@ -953,7 +972,7 @@
 		loc += 4;
 	}
 
-	if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) )
+	if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) || (type == CURVETYPE))
 	{
 		/* simple geometry (point/line/polygon)-- not multi! */
 		result->ngeometries = 1;
@@ -967,6 +986,7 @@
 
 	result->ngeometries = get_uint32(loc);
 	loc +=4;
+
 #ifdef PGIS_DEBUG
 	lwnotice("lwgeom_inspect: geometry is a collection of %d elements",
 		result->ngeometries);
@@ -977,18 +997,22 @@
 	sub_geoms = lwalloc(sizeof(uchar*) * result->ngeometries );
 	result->sub_geoms = sub_geoms;
 	sub_geoms[0] = (uchar *)loc;
+
 #ifdef PGIS_DEBUG
 	lwnotice("subgeom[0] @ %p (+%d)", sub_geoms[0], sub_geoms[0]-serialized_form);
 #endif
+
 	for (t=1;t<result->ngeometries; t++)
 	{
 		/* -1 = entire object */
 		int sub_length = lwgeom_size_subgeom(sub_geoms[t-1], -1);
 		sub_geoms[t] = sub_geoms[t-1] + sub_length;
+                
 #ifdef PGIS_DEBUG
 		lwnotice("subgeom[%d] @ %p (+%d)",
 			t, sub_geoms[t], sub_geoms[0]-serialized_form);
 #endif
+
 	}
 
 	return result;
@@ -1157,6 +1181,25 @@
 }
 
 /*
+ * 1st geometry has geom_number = 0
+ * if there arent enough geometries, return null.
+ */
+LWGEOM *lwgeom_getgeom_inspected(LWGEOM_INSPECTED *inspected, int geom_number)
+{
+	uchar *sub_geom;
+	uchar type;
+
+	sub_geom = lwgeom_getsubgeometry_inspected(inspected, geom_number);
+
+	if (sub_geom == NULL) return NULL;
+
+	type = lwgeom_getType(sub_geom[0]);
+
+	return lwgeom_deserialize(sub_geom);
+}
+
+
+/*
  * This gets the serialized form of a sub-geometry
  *
  * 1st geometry has geom_number = 0
@@ -1240,7 +1283,8 @@
 	uchar type = lwgeom_getType((uchar)serialized_form[0]);
 	uchar *loc;
 
-	if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) )
+	if ( (type==POINTTYPE) || (type==LINETYPE) || (type==POLYGONTYPE) ||
+            (type==CURVETYPE) || (type==COMPOUNDTYPE) || (type==CURVEPOLYTYPE) )
 	{
 		return 1;
 	}
@@ -1480,13 +1524,26 @@
 #endif
 		return lwgeom_size_line(serialized_form);
 	}
+        else if(type == CURVETYPE)
+        {
+#ifdef PGIS_DEBUG
+                lwnotice("lwgeom_size: is a curve");
+#endif
+                return lwgeom_size_curve(serialized_form);
+        }
 	else if (type == POLYGONTYPE)
 	{
 #ifdef PGIS_DEBUG
 		lwnotice("lwgeom_size: is a polygon");
 #endif
 		return lwgeom_size_poly(serialized_form);
-	}
+	} 
+        else if (type == COMPOUNDTYPE)
+        {
+#ifdef PGIS_DEBUG
+                lwnotice("lwgeom_size: is a compound curve");
+#endif
+        }
 
 	if ( type == 0 )
 	{
@@ -1646,6 +1703,13 @@
 		return result;
 
 	}
+        else if (type == CURVETYPE)
+        {
+                LWCURVE *curve = lwcurve_deserialize(srl);
+                result = lwcurve_compute_box3d(curve);
+                pfree_curve(curve);
+                return result;
+        }
 	else if (type == POLYGONTYPE)
 	{
 		LWPOLY *poly = lwpoly_deserialize(srl);
@@ -1655,7 +1719,9 @@
 	}
 
 	if ( ! ( type == MULTIPOINTTYPE || type == MULTILINETYPE ||
-		type == MULTIPOLYGONTYPE || type == COLLECTIONTYPE ) )
+		type == MULTIPOLYGONTYPE || type == COLLECTIONTYPE ||
+                type == COMPOUNDTYPE || type == CURVEPOLYTYPE ||
+                type == MULTICURVETYPE || type == MULTISURFACETYPE) )
 	{
 		lwnotice("compute_serialized_box3d called on unknown type %d", type);
 		return NULL;
@@ -1747,6 +1813,7 @@
 	POINT4D pt;
 	char *mflag;
 
+
 	if ( TYPE_HASM(pa->dims) ) mflag = "M";
 	else mflag = "";
 
@@ -2121,7 +2188,7 @@
 		lwalloc, lwerror);
 
 
-#ifdef PGIS_DEBUG
+#ifdef PGIS_DEBUG_CALLS
 	lwnotice("parse_lwgeom_wkt with %s",wkt_input);
 #endif
 

Modified: packages/postgis/upstream/lwgeom/lwgeom_functions_analytic.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_functions_analytic.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_functions_analytic.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_functions_analytic.c 2298 2006-01-29 13:54:38Z strk $
+ * $Id: lwgeom_functions_analytic.c 2580 2007-01-11 01:40:56Z mleslie $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -1055,3 +1055,130 @@
 
 	PG_RETURN_FLOAT8(ret);
 }
+
+/*******************************************************************************
+ * The following is based on the "Fast Winding Number Inclusion of a Point 
+ * in a Polygon" algorithm by Dan Sunday.
+ * http://www.geometryalgorithms.com/Archive/algorithm_0103/algorithm_0103.htm
+ ******************************************************************************/
+
+/*
+ * returns: >0 for a point to the left of the segment, 
+ *          <0 for a point to the right of the segment,
+ *          0 for a point on the segment
+ */
+double determineSide(POINT2D *seg1, POINT2D *seg2, POINT2D *point)
+{
+        return ((seg2->x-seg1->x)*(point->y-seg1->y)-(point->x-seg1->x)*(seg2->y-seg1->y));
+}
+
+/*
+ * return 0 iff point is outside ring pts
+ */
+int point_in_ring(POINTARRAY *pts, POINT2D *point)
+{
+        int wn = 0;
+        int i;
+        double side;
+        POINT2D seg1;
+        POINT2D seg2;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("point_in_ring called.");
+#endif
+
+        for(i=0; i<pts->npoints-1; i++)
+        {
+                getPoint2d_p(pts, i, &seg1);
+                getPoint2d_p(pts, i+1, &seg2);
+                side = determineSide(&seg1, &seg2, point);
+                /* zero length segments are ignored. */
+                if(((seg2.x-seg1.x)*(seg2.x-seg1.x)+(seg2.y-seg1.y)*(seg2.y-seg1.y)) < 1e-12*1e-12) 
+                {
+#ifdef PGIS_DEBUG
+                        lwnotice("segment is zero length... ignoring.");
+#endif
+                        continue;
+                }
+
+                /* a point on the boundary of a ring is not contained. */
+                if(fabs(side) < 1e-12) 
+                {
+#ifdef PGIS_DEBUG
+                        lwnotice("point on ring boundary between points %d, %d", i, i+1);
+#endif
+                        return 0;
+                }
+                else if(seg1.y < point->y && seg2.y > point->y && side > 0)
+                        ++wn;
+                else if(seg1.y > point->y && seg2.y < point->y && side < 0)
+                        --wn;
+        }
+#ifdef PGIS_DEBUG
+        lwnotice("returning %d", wn);
+#endif
+        return wn;
+}
+
+/*
+ * return 0 iff point outside polygon
+ */
+int point_in_polygon(LWPOLY *polygon, LWPOINT *point)
+{
+        int i;
+        POINTARRAY *ring;
+        POINT2D pt;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("point_in_polygon called.");
+#endif
+
+        getPoint2d_p(point->point, 0, &pt);
+        /* assume bbox short-circuit has already been attempted */
+        
+        ring = polygon->rings[0];
+        if(point_in_ring(ring, &pt) == 0) 
+        {
+#ifdef PGIS_DEBUG
+                lwnotice("point_in_polygon: outside exterior ring.");
+#endif
+                return 0;
+        }
+
+        for(i=1; i<polygon->nrings; i++)
+        {
+                ring = polygon->rings[i];
+                if(point_in_ring(ring, &pt) != 0) 
+                {
+#ifdef PGIS_DEBUG
+                        lwnotice("point_in_polygon: within hole %d.", i);
+#endif
+                        return 0;
+                }
+        }
+        return 1;
+}
+
+/*
+ * return 0 iff point is outside every polygon
+ */
+int point_in_multipolygon(LWMPOLY *mpolygon, LWPOINT *point)
+{
+        int i;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("point_in_multipolygon called.");
+#endif
+
+        for(i=1; i<mpolygon->ngeoms; i++)
+        {
+                if(point_in_polygon((LWPOLY *)mpolygon->geoms[i], point)!=0) return 1;
+        }
+        return 0;
+}
+
+
+/*******************************************************************************
+ * End of "Fast Winding Number Inclusion of a Point in a Polygon" derivative.
+ ******************************************************************************/
+

Modified: packages/postgis/upstream/lwgeom/lwgeom_functions_basic.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_functions_basic.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_functions_basic.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_functions_basic.c 2461 2006-07-28 13:07:06Z strk $
+ * $Id: lwgeom_functions_basic.c 2532 2006-12-01 22:16:44Z mleslie $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -470,7 +470,7 @@
 /*
  * Write to already allocated memory 'optr' a 2d version of
  * the given serialized form. 
- * Higher dimensions in input geometry are discarder.
+ * Higher dimensions in input geometry are discarded.
  * Return number bytes written in given int pointer.
  */
 void
@@ -484,6 +484,7 @@
 	uchar newtypefl;
 	LWPOINT *point = NULL;
 	LWLINE *line = NULL;
+        LWCURVE *curve = NULL;
 	LWPOLY *poly = NULL;
 	POINTARRAY newpts;
 	POINTARRAY **nrings;
@@ -550,6 +551,34 @@
 		return;
 	}
 
+        if( type == CURVETYPE )
+        {
+                curve = lwcurve_deserialize(serialized);
+#ifdef PGIS_DEBUG
+                elog(NOTICE, "lwgeom_force2d_recursize: it's a curve with %d points", curve->points->npoints);
+#endif
+                TYPE_SETZM(newpts.dims, 0, 0);
+                newpts.npoints = curve->points->npoints;
+                newpts.serialized_pointlist = lwalloc(sizeof(POINT2D)*curve->points->npoints);
+#ifdef PGIS_DEBUG
+elog(NOTICE, "lwgeom_force2d_recursive: %d bytes pointlist allocated", sizeof(POINT2D)*curve->points->npoints);
+#endif
+
+                loc = newpts.serialized_pointlist;
+                for (j=0; j<curve->points->npoints; j++)
+                {
+                        getPoint2d_p(curve->points, j, &p2d);
+                        memcpy(loc, &p2d, sizeof(POINT2D));
+                        loc += sizeof(POINT2D);
+                }
+                curve->points = &newpts;
+                TYPE_SETZM(curve->type, 0, 0);
+                lwcurve_serialize_buf(curve, optr, retsize);
+                lwfree(newpts.serialized_pointlist);
+                lwfree(curve);
+                return;
+        }
+
 	if ( type == POLYGONTYPE )
 	{
 		poly = lwpoly_deserialize(serialized);
@@ -588,7 +617,9 @@
 	}
 
 	if ( type != MULTIPOINTTYPE && type != MULTIPOLYGONTYPE &&
-		type != MULTILINETYPE && type != COLLECTIONTYPE )
+		type != MULTILINETYPE && type != COLLECTIONTYPE &&
+                type != COMPOUNDTYPE && type != CURVEPOLYTYPE &&
+                type != MULTICURVETYPE && type != MULTISURFACETYPE)
 	{
 		lwerror("lwgeom_force2d_recursive: unknown geometry: %d",
 			type);
@@ -696,6 +727,7 @@
 	int type;
 	LWPOINT *point = NULL;
 	LWLINE *line = NULL;
+        LWCURVE *curve = NULL;
 	LWPOLY *poly = NULL;
 	POINTARRAY newpts;
 	POINTARRAY **nrings;
@@ -752,6 +784,31 @@
 		return;
 	}
 
+        if ( type == CURVETYPE )
+        {
+                curve = lwcurve_deserialize(serialized);
+#ifdef PGIS_DEBUG
+                elog(NOTICE, "lwgeom_force3dz_recursize: it's a curve");
+#endif
+                TYPE_SETZM(newpts.dims, 1, 0);
+                newpts.npoints = curve->points->npoints;
+                newpts.serialized_pointlist = lwalloc(sizeof(POINT3DZ)*curve->points->npoints);
+                loc = newpts.serialized_pointlist;
+                for (j=0; j<curve->points->npoints; j++)
+                {
+                        getPoint3dz_p(curve->points, j, &point3dz);
+                        memcpy(loc, &point3dz, sizeof(POINT3DZ));
+                        loc+=sizeof(POINT3DZ);
+                }
+                curve->points = &newpts;
+                TYPE_SETZM(curve->type, 1, 0);
+                lwcurve_serialize_buf(curve, optr, retsize);
+#ifdef PGIS_DEBUG
+                elog(NOTICE, "lwgeom_force3dz_recursive: it's a curve, size:%d", *retsize);
+#endif
+                return;
+        }
+
 	if ( type == POLYGONTYPE )
 	{
 		poly = lwpoly_deserialize(serialized);
@@ -864,6 +921,7 @@
 	uchar newtypefl;
 	LWPOINT *point = NULL;
 	LWLINE *line = NULL;
+        LWCURVE *curve = NULL;
 	LWPOLY *poly = NULL;
 	POINTARRAY newpts;
 	POINTARRAY **nrings;
@@ -930,6 +988,31 @@
 		return;
 	}
 
+        if ( type == CURVETYPE )
+        {
+                curve = lwcurve_deserialize(serialized);
+#ifdef PGIS_DEBUG
+                elog(NOTICE, "lwgeom_force3dm_recursize: it's a curve with %d points", curve->points->npoints);
+#endif
+                TYPE_SETZM(newpts.dims, 0, 1);
+                newpts.npoints = curve->points->npoints;
+                newpts.serialized_pointlist = lwalloc(sizeof(POINT3DM)*curve->points->npoints);
+
+                loc = newpts.serialized_pointlist;
+                for (j=0; j<curve->points->npoints; j++)
+                {
+                        getPoint3dm_p(curve->points, j, &p3dm);
+                        memcpy(loc, &p3dm, sizeof(POINT3DM));
+                        loc+=sizeof(POINT3DM);
+                }
+                curve->points = &newpts;
+                TYPE_SETZM(curve->type, 0, 1);
+                lwcurve_serialize_buf(curve, optr, retsize);
+                lwfree(newpts.serialized_pointlist);
+                lwfree(curve);
+                return;
+        }
+
 	if ( type == POLYGONTYPE )
 	{
 		poly = lwpoly_deserialize(serialized);
@@ -968,7 +1051,9 @@
 	}
 
 	if ( type != MULTIPOINTTYPE && type != MULTIPOLYGONTYPE &&
-		type != MULTILINETYPE && type != COLLECTIONTYPE )
+		type != MULTILINETYPE && type != COLLECTIONTYPE &&
+                type != COMPOUNDTYPE && type != CURVEPOLYTYPE &&
+                type != MULTICURVETYPE && type != MULTISURFACETYPE)
 	{
 		lwerror("lwgeom_force3dm_recursive: unknown geometry: %d",
 			type);
@@ -1076,6 +1161,7 @@
 	int type;
 	LWPOINT *point = NULL;
 	LWLINE *line = NULL;
+        LWCURVE *curve = NULL;
 	LWPOLY *poly = NULL;
 	POINTARRAY newpts;
 	POINTARRAY **nrings;
@@ -1132,6 +1218,28 @@
 		return;
 	}
 
+        if ( type == CURVETYPE )
+        {
+                curve = lwcurve_deserialize(serialized);
+                TYPE_SETZM(newpts.dims, 1, 1);
+                newpts.npoints = curve->points->npoints;
+                newpts.serialized_pointlist = lwalloc(sizeof(POINT4D)*curve->points->npoints);
+                loc = newpts.serialized_pointlist;
+                for (j=0; j<curve->points->npoints; j++)
+                {
+                        getPoint4d_p(curve->points, j, &p4d);
+                        memcpy(loc, &p4d, sizeof(POINT4D));
+                        loc+=sizeof(POINT4D);
+                }
+                curve->points = &newpts;
+                TYPE_SETZM(curve->type, 1, 1);
+                lwcurve_serialize_buf(curve, optr, retsize);
+#ifdef PGIS_DEBUG
+                elog(NOTICE, "lwgeom_force4d_recursive: it's a curve, size:%d", *retsize);
+#endif
+                return;
+        }
+
 	if ( type == POLYGONTYPE )
 	{
 		poly = lwpoly_deserialize(serialized);
@@ -1367,6 +1475,10 @@
 	int SRID;
 	BOX2DFLOAT4 *bbox;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_force_collection called");
+#endif
+
 	/*
 	 * This funx is a no-op only if a bbox cache is already present
 	 * in input. If bbox cache is not there we'll need to handle
@@ -1421,6 +1533,10 @@
 	int SRID=-1;
 	BOX2DFLOAT4 *box;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_force_multi called");
+#endif
+
 	/*
 	 * This funx is a no-op only if a bbox cache is already present
 	 * in input. If bbox cache is not there we'll need to handle
@@ -1561,6 +1677,10 @@
 	LWGEOM *lwgeom;
 	PG_LWGEOM *ret;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_longitude_shift called.");
+#endif
+
 	geom = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
 	lwgeom = pglwgeom_deserialize(geom);
 
@@ -1624,6 +1744,10 @@
 	BOX2DFLOAT4 *box=NULL;
 	int SRID;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_collect called.");
+#endif
+
 	/* return null if both geoms are null */
 	if ( (geom1_ptr == NULL) && (geom2_ptr == NULL) )
 	{
@@ -1867,6 +1991,10 @@
 	size_t offset;
 	BOX2DFLOAT4 *box=NULL;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_collect_garray called.");
+#endif
+
 #ifdef PGIS_DEBUG
 	elog(NOTICE, "LWGEOM_collect_garray called");
 #endif
@@ -2006,6 +2134,10 @@
 	LWLINE *lwline;
 	LWMPOINT *mpoint;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_line_from_mpoint called.");
+#endif
+
 #ifdef PGIS_DEBUG
 	elog(NOTICE, "LWGEOM_line_from_mpoint called");
 #endif
@@ -2055,6 +2187,10 @@
 	size_t offset;
 	int SRID=-1;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_makeline_garray called.");
+#endif
+
 #ifdef PGIS_DEBUG
 	elog(NOTICE, "LWGEOM_makeline_garray called");
 #endif
@@ -2159,6 +2295,10 @@
 	LWPOINT *lwpoints[2];
 	LWLINE *outline;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_makeline called.");
+#endif
+
 #ifdef PGIS_DEBUG
 	elog(NOTICE, "LWGEOM_makeline called");
 #endif
@@ -2208,6 +2348,10 @@
 	unsigned int i;
 	size_t offset=0;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_makepoly called.");
+#endif
+
 #ifdef PGIS_DEBUG
 	elog(NOTICE, "LWGEOM_makepoly called");
 #endif
@@ -2269,6 +2413,10 @@
 	int SRID;
 	PG_LWGEOM *result;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_expand called.");
+#endif
+
 	/* get geometry box  */
 	if ( ! getbox2d_p(SERIALIZED_FORM(geom), &box) )
 	{
@@ -2407,6 +2555,10 @@
 	double dist;
 	LWGEOM *inlwgeom, *outlwgeom;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_segmentize2d called");
+#endif
+
 	ingeom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	dist = PG_GETARG_FLOAT8(1);
 
@@ -2438,6 +2590,10 @@
 	PG_LWGEOM *geom;
 	LWGEOM *lwgeom;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_reverse called");
+#endif
+
 	geom = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
 
 	lwgeom = lwgeom_deserialize(SERIALIZED_FORM(geom));
@@ -2455,6 +2611,10 @@
 	PG_LWGEOM *ingeom, *outgeom;
 	LWGEOM *lwgeom;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_forceRHR_poly called");
+#endif
+
 	ingeom = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
 
 	lwgeom = lwgeom_deserialize(SERIALIZED_FORM(ingeom));
@@ -2475,6 +2635,10 @@
 	PG_LWGEOM *in, *out;
 	LWGEOM *lwgeom;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_noop called");
+#endif
+
 	in = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
 	lwgeom = lwgeom_deserialize(SERIALIZED_FORM(in));
@@ -2585,6 +2749,10 @@
 	LWPOINT *point;
 	PG_LWGEOM *result;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_makepoint called");
+#endif
+
 	x = PG_GETARG_FLOAT8(0);
 	y = PG_GETARG_FLOAT8(1);
 
@@ -2616,6 +2784,10 @@
 	LWPOINT *point;
 	PG_LWGEOM *result;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_makepoint3dm called.");
+#endif
+
 	x = PG_GETARG_FLOAT8(0);
 	y = PG_GETARG_FLOAT8(1);
 	m = PG_GETARG_FLOAT8(2);
@@ -2634,6 +2806,10 @@
 	LWLINE *line, *outline;
 	int where = -1;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_addpoint called.");
+#endif
+
 	pglwg1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	pglwg2 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
 
@@ -2686,6 +2862,10 @@
 	LWLINE *line, *outline;
 	unsigned int which;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_removepoint called.");
+#endif
+
 	pglwg1 = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 	which = PG_GETARG_INT32(1);
 
@@ -2732,6 +2912,10 @@
 	POINT4D newpoint;
 	unsigned int which;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_setpoint_linestring called.");
+#endif
+
 	/* we copy input as we're going to modify it */
 	pglwg1 = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
 
@@ -3102,6 +3286,10 @@
 	LWGEOM *tmp;
 	uchar *srl = SERIALIZED_FORM(geom);
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("LWGEOM_affine called.");
+#endif
+
 	double afac =  PG_GETARG_FLOAT8(1);
 	double bfac =  PG_GETARG_FLOAT8(2);
 	double cfac =  PG_GETARG_FLOAT8(3);

Modified: packages/postgis/upstream/lwgeom/lwgeom_geos.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_geos.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_geos.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1241,6 +1241,10 @@
 	bool result;
 	Geometry *g1;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("isvalid called.");
+#endif
+
 #ifdef PROFILE
 	profstart(PROF_QRUN);
 #endif
@@ -2162,7 +2166,9 @@
 
 	geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
 
-	if (lwgeom_getType(geom->type) != LINETYPE)
+	if (lwgeom_getType(geom->type) != LINETYPE &&
+            lwgeom_getType(geom->type) != CURVETYPE &&
+            lwgeom_getType(geom->type) != COMPOUNDTYPE)
 	{
 		elog(ERROR,"isring() should only be called on a LINE");
 	}
@@ -2470,6 +2476,7 @@
 {
 	uint32 i;
 	Geometry **collected;
+        LWGEOM *tmp;
 	LWCOLLECTION *col;
 	if ( ! lwgeom ) return NULL;
 
@@ -2477,6 +2484,16 @@
 	lwnotice("LWGEOM2GEOS: got lwgeom[%p]", lwgeom);
 #endif
 
+        if(has_arc(lwgeom))
+        {
+#ifdef PGIS_DEBUG_CALLS
+                lwnotice("LWGEOM2GEOS: arced geometry found.");
+#endif
+                tmp = lwgeom;
+                lwgeom = lwgeom_segmentize(tmp, 32);
+                lwgeom_release(tmp);
+        }
+
 	switch (TYPE_GETTYPE(lwgeom->type))
 	{
 		case POINTTYPE:
@@ -2515,8 +2532,12 @@
 				TYPE_HASZ(col->type));
 
 		default:
+#ifdef PGIS_DEBUG
+                        lwerror("LWGEOM2GEOS: Unknown geometry type: %d", TYPE_GETTYPE(lwgeom->type));
+#else
 			lwerror("Unknown geometry type: %d",
 				TYPE_GETTYPE(lwgeom->type));
+#endif
 			return NULL;
 	}
 

Modified: packages/postgis/upstream/lwgeom/lwgeom_geos_c.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_geos_c.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_geos_c.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1339,8 +1339,9 @@
 	PG_RETURN_BOOL(result);
 }
 
+int point_in_polygon(LWPOLY *polygon, LWPOINT *point);
+int point_in_multipolygon(LWMPOLY *mpolygon, LWPOINT *point);
 
-
 PG_FUNCTION_INFO_V1(contains);
 Datum contains(PG_FUNCTION_ARGS)
 {
@@ -1349,6 +1350,10 @@
 	GEOSGeom g1,g2;
 	bool result;
 	BOX2DFLOAT4 box1, box2;
+        int type1, type2;
+        LWPOLY *poly;
+        /* LWMPOLY *mpoly; */
+        LWPOINT *point;
 
 #ifdef PROFILE
 	profstart(PROF_QRUN);
@@ -1373,7 +1378,72 @@
 		if ( box2.ymin < box1.ymin ) PG_RETURN_BOOL(FALSE);
 		if ( box2.ymax > box1.ymax ) PG_RETURN_BOOL(FALSE);
 	}
-
+        /*
+         * short-circuit 2: if geom2 is a point and geom1 is a polygon
+         * call the point-in-polygon function.
+         */
+        type1 = lwgeom_getType((uchar)SERIALIZED_FORM(geom1)[0]);
+        type2 = lwgeom_getType((uchar)SERIALIZED_FORM(geom2)[0]);
+        if(type1 == POLYGONTYPE && type2 == POINTTYPE)
+        {
+#ifdef PGIS_DEBUG
+                lwnotice("Point in Polygon test requested...short-circuiting.");
+#endif
+                poly = lwpoly_deserialize(SERIALIZED_FORM(geom1));
+                point = lwpoint_deserialize(SERIALIZED_FORM(geom2));
+#ifdef PGIS_DEBUG
+                lwnotice("Precall point_in_polygon %p, %p", poly, point);
+#endif
+                if(point_in_polygon(poly, point) == 0)
+                {
+	                PG_FREE_IF_COPY(geom1, 0);
+	                PG_FREE_IF_COPY(geom2, 1);
+                        lwgeom_release((LWGEOM *)poly);
+                        lwgeom_release((LWGEOM *)point);
+                        PG_RETURN_BOOL(FALSE);
+                }
+                else
+                {
+                        PG_FREE_IF_COPY(geom1, 0);
+                        PG_FREE_IF_COPY(geom2, 1);
+                        lwgeom_release((LWGEOM *)poly);
+                        lwgeom_release((LWGEOM *)point);
+                        PG_RETURN_BOOL(TRUE);
+                }
+        } 
+        /* Not yet functional 
+        else if(type1 == MULTIPOLYGONTYPE && type2 == POINTTYPE)
+        {
+#ifdef PGIS_DEBUG
+                lwnotice("Point in MultiPolygon test requested...short-circuiting.");
+#endif
+                mpoly = lwmpoly_deserialize(SERIALIZED_FORM(geom1));
+                point = lwpoint_deserialize(SERIALIZED_FORM(geom2));
+                if(point_in_multipolygon(mpoly, point) == 0)
+                {
+                        PG_FREE_IF_COPY(geom1, 0);
+                        PG_FREE_IF_COPY(geom2, 1);
+                        lwgeom_release((LWGEOM *)mpoly);
+                        lwgeom_release((LWGEOM *)point);
+                        PG_RETURN_BOOL(FALSE);
+                }
+                else
+                {
+                        PG_FREE_IF_COPY(geom1, 0);
+                        PG_FREE_IF_COPY(geom2, 1);
+                        lwgeom_release((LWGEOM *)mpoly);
+                        lwgeom_release((LWGEOM *)point);
+                        PG_RETURN_BOOL(TRUE);
+                }
+        }
+        */
+        else 
+        {
+#ifdef PGIS_DEBUG
+                lwnotice("Contains: type1: %d, type2: %d", type1, type2);
+#endif
+        }
+        
 	initGEOS(lwnotice, lwnotice);
 
 #ifdef PROFILE
@@ -1428,6 +1498,9 @@
 	GEOSGeom g1,g2;
 	bool result;
 	BOX2DFLOAT4 box1, box2;
+        LWPOLY *poly;
+        LWPOINT *point;
+        int type1, type2;
 
 #ifdef PROFILE
 	profstart(PROF_QRUN);
@@ -1452,6 +1525,36 @@
 		if ( box1.ymin < box2.ymin ) PG_RETURN_BOOL(FALSE);
 		if ( box1.ymax > box2.ymax ) PG_RETURN_BOOL(FALSE);
 	}
+        /*
+         * short-circuit 2: if geom1 is a point and geom2 is a polygon
+         * call the point-in-polygon function.
+         */
+        type1 = lwgeom_getType((uchar)SERIALIZED_FORM(geom1)[0]);
+        type2 = lwgeom_getType((uchar)SERIALIZED_FORM(geom2)[0]);
+        if(type1 == POINTTYPE && type2 == POLYGONTYPE)
+        {
+#ifdef PGIS_DEBUG
+                lwnotice("Point in Polygon test requested...short-circuiting.");
+#endif
+                point = lwpoint_deserialize(SERIALIZED_FORM(geom1));
+                poly = lwpoly_deserialize(SERIALIZED_FORM(geom2));
+                if(point_in_polygon(poly, point) == 0)
+                {
+	                PG_FREE_IF_COPY(geom1, 0);
+	                PG_FREE_IF_COPY(geom2, 1);
+                        lwgeom_release((LWGEOM *)poly);
+                        lwgeom_release((LWGEOM *)point);
+                        PG_RETURN_BOOL(FALSE);
+                }
+                else
+                {
+                        PG_FREE_IF_COPY(geom1, 0);
+                        PG_FREE_IF_COPY(geom2, 1);
+                        lwgeom_release((LWGEOM *)poly);
+                        lwgeom_release((LWGEOM *)point);
+                        PG_RETURN_BOOL(TRUE);
+                }
+        }
 
 	initGEOS(lwnotice, lwnotice);
 
@@ -1766,7 +1869,7 @@
 		if ( box2.xmax < box1.xmin ) PG_RETURN_BOOL(TRUE);
 		if ( box2.xmin > box1.xmax ) PG_RETURN_BOOL(TRUE);
 		if ( box2.ymax < box1.ymin ) PG_RETURN_BOOL(TRUE);
-		if ( box2.ymin > box2.ymax ) PG_RETURN_BOOL(TRUE);
+		if ( box2.ymin > box1.ymax ) PG_RETURN_BOOL(TRUE);
 	}
 
 	initGEOS(lwnotice, lwnotice);

Modified: packages/postgis/upstream/lwgeom/lwgeom_gist.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_gist.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_gist.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -542,27 +542,34 @@
 			if (in != (PG_LWGEOM*)DatumGetPointer(entry->key))
 				pfree(in);  /* PG_FREE_IF_COPY */
 
+#if USE_VERSION >= 82
 			gistentryinit(*retval, PointerGetDatum(rr),
 				entry->rel, entry->page,
-#if USE_VERSION >= 82
 				entry->offset,
+				FALSE);
 #else
+			gistentryinit(*retval, PointerGetDatum(rr),
+				entry->rel, entry->page,
 				entry->offset, sizeof(BOX2DFLOAT4),
+				FALSE);
 #endif
-				FALSE);
 
+
 		}
 		else
 		{
 #ifdef PGIS_DEBUG_GIST4
 		elog(NOTICE,"GIST: LWGEOM_gist_compress got a NULL key");
 #endif
+
+#if USE_VERSION >= 82
 			gistentryinit(*retval, (Datum) 0, entry->rel,
-#if USE_VERSION >= 82
 				entry->page, entry->offset, FALSE);
 #else
+			gistentryinit(*retval, (Datum) 0, entry->rel,
 				entry->page, entry->offset, 0, FALSE);
 #endif
+
 		}
 
 	}
@@ -951,15 +958,24 @@
 	elog(NOTICE,"GIST: LWGEOM_gist_penalty called");
 #endif
 
+	if (DatumGetPointer(origentry->key) == NULL && DatumGetPointer(newentry->key) == NULL)
+	{
+#ifdef PGIS_DEBUG_GIST6
+		elog(NOTICE,"GIST: LWGEOM_gist_penalty called with both inputs NULL");
+#endif
+		*result = 0;
+	}
+	else
+	{
+		ud = DirectFunctionCall2(BOX2D_union, origentry->key, newentry->key);
+		/*ud = BOX2D_union(origentry->key, newentry->key); */
+		tmp1 = size_box2d_double(ud);
+		if (DatumGetPointer(ud) != NULL)
+			pfree(DatumGetPointer(ud));
+		*result = tmp1 - size_box2d_double(origentry->key);
+	}
 
-	ud = DirectFunctionCall2(BOX2D_union, origentry->key, newentry->key);
-	/*ud = BOX2D_union(origentry->key, newentry->key); */
-	tmp1 = size_box2d_double(ud);
-	if (DatumGetPointer(ud) != NULL)
-		pfree(DatumGetPointer(ud));
 
-	*result = tmp1 - size_box2d_double(origentry->key);
-
 #ifdef PGIS_DEBUG_GIST6
 	elog(NOTICE,"GIST: LWGEOM_gist_penalty called and returning %.15g", *result);
 #endif

Added: packages/postgis/upstream/lwgeom/lwgeom_kml.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_kml.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_kml.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,494 @@
+/**********************************************************************
+ * $Id$
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2001-2003 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of hte GNU General Public Licence. See the COPYING file.
+ *
+ **********************************************************************
+ *
+ * KML output routines.
+ *
+ **********************************************************************/
+
+
+#include "postgres.h"
+#include "executor/spi.h"
+
+#include "lwgeom_pg.h"
+#include "liblwgeom.h"
+
+Datum LWGEOM_asKML(PG_FUNCTION_ARGS);
+char *geometry_to_kml(uchar *srl, char *srs);
+
+static size_t askml_point_size(LWPOINT *point, char *srs);
+static char *askml_point(LWPOINT *point, char *srs);
+static size_t askml_line_size(LWLINE *line, char *srs);
+static char *askml_line(LWLINE *line, char *srs);
+static size_t askml_poly_size(LWPOLY *poly, char *srs);
+static char *askml_poly(LWPOLY *poly, char *srs);
+static size_t askml_inspected_size(LWGEOM_INSPECTED *geom, char *srs);
+static char *askml_inspected(LWGEOM_INSPECTED *geom, char *srs);
+static size_t pointArray_KMLsize(POINTARRAY *pa);
+static size_t pointArray_toKML(POINTARRAY *pa, char *buf);
+static char *getSRSbySRID(int SRID);
+
+#define DEF_PRECISION 15
+/* Add dot, sign, exponent sign, 'e', exponent digits */
+#define SHOW_DIGS (precision + 8)
+
+/* Globals */
+int precision;
+
+
+/**
+ * Encode feature in KML 
+ */
+PG_FUNCTION_INFO_V1(LWGEOM_asKML);
+Datum LWGEOM_asKML(PG_FUNCTION_ARGS)
+{
+	PG_LWGEOM *geom;
+	char *kml;
+	text *result;
+	int len;
+	int version = 2;
+	char *srs;
+	int SRID;
+
+	precision = DEF_PRECISION;
+
+	if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
+
+	geom = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
+
+	/* Get precision (if provided)  */
+	if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
+			precision = PG_GETARG_INT32(1);
+	
+	if ( precision < 1 || precision > 15 )
+	{
+		elog(ERROR, "Precision out of range 1..15");
+		PG_RETURN_NULL();
+	}
+
+	/* Get version (if provided)  */
+	if ( PG_NARGS() > 2 && ! PG_ARGISNULL(2) )
+			version = PG_GETARG_INT32(2);
+
+	
+	if ( version != 2 )
+	{
+		elog(ERROR, "Only KML 2 is supported");
+		PG_RETURN_NULL();
+	}
+
+	SRID = lwgeom_getsrid(SERIALIZED_FORM(geom));
+	if ( SRID != -1 ) {
+	  srs = getSRSbySRID(SRID);
+	} else {
+		PG_FREE_IF_COPY(geom, 0);
+		elog(ERROR,"Input geometry has unknown (-1) SRID");
+		PG_RETURN_NULL();
+	}
+
+	/*elog(NOTICE, "srs=%s", srs); */
+
+	kml = geometry_to_kml(SERIALIZED_FORM(geom), srs);
+	PG_FREE_IF_COPY(geom, 0);
+
+	len = strlen(kml) + VARHDRSZ;
+
+	result = palloc(len);
+	VARATT_SIZEP(result) = len;
+
+	memcpy(VARDATA(result), kml, len-VARHDRSZ);
+
+	pfree(kml);
+
+	PG_RETURN_POINTER(result);
+}
+
+/* takes a GEOMETRY and returns a KML representation */
+char *
+geometry_to_kml(uchar *geom, char *srs)
+{
+	int type;
+	LWPOINT *point;
+	LWLINE *line;
+	LWPOLY *poly;
+	LWGEOM_INSPECTED *inspected;
+
+	type = lwgeom_getType(geom[0]);
+
+	switch (type)
+	{
+
+		case POINTTYPE:
+			point = lwpoint_deserialize(geom);
+			return askml_point(point, srs);
+
+		case LINETYPE:
+			line = lwline_deserialize(geom);
+			return askml_line(line, srs);
+
+		case POLYGONTYPE:
+			poly = lwpoly_deserialize(geom);
+			return askml_poly(poly, srs);
+
+		case MULTIPOINTTYPE:
+		case MULTILINETYPE:
+		case MULTIPOLYGONTYPE:
+			inspected = lwgeom_inspect(geom);
+			return askml_inspected(inspected, srs);
+		
+		default:
+			lwerror("geometry_to_kml: '%s' geometry type not supported by Google Earth", lwgeom_typename(type));
+			return NULL;
+	}
+}
+
+static size_t
+askml_point_size(LWPOINT *point, char *srs)
+{
+	int size;
+	size = pointArray_KMLsize(point->point);
+	size += sizeof("<point><coordinates>/") * 2;
+	return size;
+}
+
+static size_t
+askml_point_buf(LWPOINT *point, char *srs, char *output)
+{
+	char *ptr = output;
+
+	ptr += sprintf(ptr, "<Point>");
+	ptr += sprintf(ptr, "<coordinates>");
+	ptr += pointArray_toKML(point->point, ptr);
+	ptr += sprintf(ptr, "</coordinates></Point>");
+
+	return (ptr-output);
+}
+
+static char *
+askml_point(LWPOINT *point, char *srs)
+{
+	char *output;
+	int size;
+	
+	size = askml_point_size(point, srs);
+	output = palloc(size);
+	askml_point_buf(point, srs, output);
+	return output;
+}
+
+static size_t
+askml_line_size(LWLINE *line, char *srs)
+{
+	int size;
+	size = pointArray_KMLsize(line->points);
+	size += sizeof("<linestring><coordinates>/") * 2;
+	return size;
+}
+
+static size_t
+askml_line_buf(LWLINE *line, char *srs, char *output)
+{
+	char *ptr=output;
+
+	ptr += sprintf(ptr, "<LineString>");
+	ptr += sprintf(ptr, "<coordinates>");
+	ptr += pointArray_toKML(line->points, ptr);
+	ptr += sprintf(ptr, "</coordinates></LineString>");
+
+	return (ptr-output);
+}
+
+static char *
+askml_line(LWLINE *line, char *srs)
+{
+	char *output;
+	int size;
+
+	size = askml_line_size(line, srs);
+	output = palloc(size);
+	askml_line_buf(line, srs, output);
+	return output;
+}
+
+static size_t
+askml_poly_size(LWPOLY *poly, char *srs)
+{
+	size_t size;
+	int i;
+
+	size = sizeof("<polygon></polygon>");
+	size += sizeof("<outerboundaryis><linearring><coordinates>/") * 2;
+	size += sizeof("<innerboundaryis><linearring><coordinates>/") * 2 *
+		poly->nrings;
+
+	for (i=0; i<poly->nrings; i++)
+		size += pointArray_KMLsize(poly->rings[i]);
+
+	return size;
+}
+
+static size_t
+askml_poly_buf(LWPOLY *poly, char *srs, char *output)
+{
+	int i;
+	char *ptr=output;
+
+	ptr += sprintf(ptr, "<Polygon>");
+	ptr += sprintf(ptr, "<outerBoundaryIs><LinearRing><coordinates>");
+	ptr += pointArray_toKML(poly->rings[0], ptr);
+	ptr += sprintf(ptr, "</coordinates></LinearRing></outerBoundaryIs>");
+	for (i=1; i<poly->nrings; i++)
+	{
+		ptr += sprintf(ptr, "<innerBoundaryIs><LinearRing><coordinates>");
+		ptr += pointArray_toKML(poly->rings[i], ptr);
+		ptr += sprintf(ptr, "</coordinates></LinearRing></innerBoundaryIs>");
+	}
+	ptr += sprintf(ptr, "</Polygon>");
+
+	return (ptr-output);
+}
+
+static char *
+askml_poly(LWPOLY *poly, char *srs)
+{
+	char *output;
+	int size;
+
+	size = askml_poly_size(poly, srs);
+	output = palloc(size);
+	askml_poly_buf(poly, srs, output);
+	return output;
+}
+
+/*
+ * Compute max size required for KML version of this 
+ * inspected geometry. Will recurse when needed.
+ * Don't call this with single-geoms inspected.
+ */
+static size_t
+askml_inspected_size(LWGEOM_INSPECTED *insp, char *srs)
+{
+	int i;
+	size_t size;
+
+	/* the longest possible multi version */
+	size = sizeof("<MultiGeometry></MultiGeometry>");
+
+	for (i=0; i<insp->ngeometries; i++)
+	{
+		LWPOINT *point;
+		LWLINE *line;
+		LWPOLY *poly;
+		LWGEOM_INSPECTED *subinsp;
+		uchar *subgeom;
+
+		if ((point=lwgeom_getpoint_inspected(insp, i)))
+		{
+			size += askml_point_size(point, 0);
+			pfree_point(point);
+		}
+		else if ((line=lwgeom_getline_inspected(insp, i)))
+		{
+			size += askml_line_size(line, 0);
+			pfree_line(line);
+		}
+		else if ((poly=lwgeom_getpoly_inspected(insp, i)))
+		{
+			size += askml_poly_size(poly, 0);
+			pfree_polygon(poly);
+		}
+		else
+		{
+			subgeom = lwgeom_getsubgeometry_inspected(insp, i);
+			subinsp = lwgeom_inspect(subgeom);
+			size += askml_inspected_size(subinsp, 0);
+			pfree_inspected(subinsp);
+		}
+	}
+
+	return size;
+}
+
+/*
+ * Don't call this with single-geoms inspected!
+ */
+static size_t
+askml_inspected_buf(LWGEOM_INSPECTED *insp, char *srs, char *output)
+{
+	char *ptr, *kmltype;
+	int i;
+
+	ptr = output;
+	kmltype = "MultiGeometry";
+
+	ptr += sprintf(ptr, "<%s>", kmltype);
+
+	for (i=0; i<insp->ngeometries; i++)
+	{
+		LWPOINT *point;
+		LWLINE *line;
+		LWPOLY *poly;
+		LWGEOM_INSPECTED *subinsp;
+		uchar *subgeom;
+
+		if ((point=lwgeom_getpoint_inspected(insp, i)))
+		{
+			ptr += askml_point_buf(point, 0, ptr);
+			pfree_point(point);
+		}
+		else if ((line=lwgeom_getline_inspected(insp, i)))
+		{
+			ptr += askml_line_buf(line, 0, ptr);
+			pfree_line(line);
+		}
+		else if ((poly=lwgeom_getpoly_inspected(insp, i)))
+		{
+			ptr += askml_poly_buf(poly, 0, ptr);
+			pfree_polygon(poly);
+		}
+		else
+		{
+			subgeom = lwgeom_getsubgeometry_inspected(insp, i);
+			subinsp = lwgeom_inspect(subgeom);
+			ptr += askml_inspected_buf(subinsp, 0, ptr);
+			pfree_inspected(subinsp);
+		}
+	}
+
+	/* Close outmost tag */
+	ptr += sprintf(ptr, "</%s>", kmltype);
+
+	return (ptr-output);
+}
+
+/*
+ * Don't call this with single-geoms inspected!
+ */
+static char *
+askml_inspected(LWGEOM_INSPECTED *insp, char *srs)
+{
+	char *kml;
+	size_t size;
+
+	size = askml_inspected_size(insp, srs);
+	kml = palloc(size);
+	askml_inspected_buf(insp, srs, kml);
+	return kml;
+}
+
+/*
+ * Returns maximum size of rendered pointarray in bytes.
+ */
+static size_t
+pointArray_KMLsize(POINTARRAY *pa)
+{
+	return TYPE_NDIMS(pa->dims) * pa->npoints * (SHOW_DIGS+(TYPE_NDIMS(pa->dims)-1));
+}
+
+static size_t
+pointArray_toKML(POINTARRAY *pa, char *output)
+{
+	int i;
+	char *ptr;
+
+	ptr = output;
+
+	if ( ! TYPE_HASZ(pa->dims) )
+	{
+		for (i=0; i<pa->npoints; i++)
+		{
+			POINT2D pt;
+			getPoint2d_p(pa, i, &pt);
+			if ( i ) ptr += sprintf(ptr, " ");
+			ptr += sprintf(ptr, "%.*g,%.*g,0",
+				precision, pt.x,
+				precision, pt.y);
+		}
+	}
+	else 
+	{
+		for (i=0; i<pa->npoints; i++)
+		{
+			POINT4D pt;
+			getPoint4d_p(pa, i, &pt);
+			if ( i ) ptr += sprintf(ptr, " ");
+			ptr += sprintf(ptr, "%.*g,%.*g,%.*g",
+				precision, pt.x,
+				precision, pt.y,
+				precision, pt.z);
+		}
+	}
+
+	return ptr-output;
+}
+
+static char *
+getSRSbySRID(int SRID)
+{
+	char query[128];
+	char *srs, *srscopy;
+	int size, err;
+
+	/* connect to SPI */
+	if (SPI_OK_CONNECT != SPI_connect ()) {
+		elog(NOTICE, "getSRSbySRID: could not connect to SPI manager");
+		SPI_finish();
+		return NULL;
+	}
+
+	/* write query */
+	sprintf(query, "SELECT textcat(auth_name, textcat(':', auth_srid)) \
+		FROM spatial_ref_sys WHERE srid = '%d'", SRID);
+#ifdef PGIS_DEBUG
+	elog(NOTICE, "Query: %s", query);
+#endif
+
+	/* execute query */
+	err = SPI_exec(query, 1);
+	if ( err < 0 ) {
+		elog(NOTICE, "getSRSbySRID: error executing query %d", err);
+		SPI_finish();
+		return NULL;
+	}
+
+	/* no entry in spatial_ref_sys */
+	if (SPI_processed <= 0) {
+		/*elog(NOTICE, "getSRSbySRID: no record for SRID %d", SRID); */
+		SPI_finish();
+		return NULL;
+	}
+
+	/* get result  */
+	srs = SPI_getvalue(SPI_tuptable->vals[0],
+		SPI_tuptable->tupdesc, 1);
+	
+	/* NULL result */
+	if ( ! srs ) {
+		/*elog(NOTICE, "getSRSbySRID: null result"); */
+		SPI_finish();
+		return NULL;
+	}
+
+	/* copy result to upper executor context */
+	size = strlen(srs)+1;
+	srscopy = SPI_palloc(size);
+	memcpy(srscopy, srs, size);
+
+	/* disconnect from SPI */
+	SPI_finish();
+
+	return srscopy;
+}
+
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+

Modified: packages/postgis/upstream/lwgeom/lwgeom_pg.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_pg.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_pg.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -122,11 +122,19 @@
 #endif
 
 	size = lwgeom_serialize_size(in) + VARHDRSZ;
-	/* lwnotice("lwgeom_serialize_size returned %d", size-VARHDRSZ); */
+
+#ifdef PGIS_DEBUG
+	lwnotice("lwgeom_serialize_size returned %d", size-VARHDRSZ);
+#endif
+
 	result = palloc(size);
 	result->size = (size);
 	lwgeom_serialize_buf(in, SERIALIZED_FORM(result), &size);
 
+#ifdef PGIS_DEBUG
+        lwnotice("pglwgeom_serialize: serialized size: %d, computed size: %d", size, result->size-VARHDRSZ);
+#endif
+
 #if PARANOIA_LEVEL > 0
 	if ( size != result->size-VARHDRSZ )
 	{

Modified: packages/postgis/upstream/lwgeom/lwgeom_spheroid.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_spheroid.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_spheroid.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_spheroid.c 2272 2006-01-09 15:12:02Z strk $
+ * $Id: lwgeom_spheroid.c 2532 2006-12-01 22:16:44Z mleslie $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -205,9 +205,9 @@
 	/*result2 =  distance_sphere_method(lat1, long1,lat2,long2, sphere);*/
 
 #ifdef PGIS_DEBUG
-	elog(NOTICE, "delta = %lf, skae says: %.15lf,2 circle says: %.15lf",
+	/*elog(NOTICE, "delta = %lf, skae says: %.15lf,2 circle says: %.15lf",
 		(result2-result),result,result2);
-	elog(NOTICE,"2 circle says: %.15lf",result2);
+	elog(NOTICE,"2 circle says: %.15lf",result2);*/
 #endif
 
 	if (result != result)  /* NaN check

Added: packages/postgis/upstream/lwgeom/lwgeom_sqlmm.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_sqlmm.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_sqlmm.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,87 @@
+/**********************************************************************
+ * $Id$
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2001-2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ * 
+ **********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <math.h>
+
+#include "postgres.h"
+#include "liblwgeom.h"
+#include "fmgr.h"
+#include "wktparse.h"
+#include "lwgeom_pg.h"
+
+/*
+ * Tolerance used to determine equality.
+ */
+#define EPSILON_SQLMM 1e-8
+
+/*
+ * Determines the center of the circle defined by the three given points.
+ * In the event the circle is complete, the midpoint of the segment defined
+ * by the first and second points is returned.  If the points are colinear,
+ * as determined by equal slopes, then NULL is returned.  If the interior
+ * point is coincident with either end point, they are taken as colinear.
+ */
+double
+lwcircle_center(POINT4D *p1, POINT4D *p2, POINT4D *p3, POINT4D **result)
+{
+        POINT4D *c;
+        double cx, cy, cr;
+        double temp, bc, cd, det;
+        
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwcircle_center called (%.16f, %.16f), (%.16f, %.16f), (%.16f, %.16f).", p1->x, p1->y, p2->x, p2->y, p3->x, p3->y);
+#endif
+
+        /* Closed circle */
+        if(fabs(p1->x - p3->x) < EPSILON_SQLMM
+                        && fabs(p1->y - p3->y) < EPSILON_SQLMM)
+        {
+                cx = p1->x + (p2->x - p1->x) / 2.0;
+                cy = p1->y + (p2->y - p1->y) / 2.0;
+                c = lwalloc(sizeof(POINT2D));
+                c->x = cx;
+                c->y = cy;
+                *result = c;
+                cr = sqrt((cx-p1->x)*(cx-p1->x)+(cy-p1->y)*(cy-p1->y));
+                return cr;
+        }
+
+        temp = p2->x*p2->x + p2->y*p2->y;
+        bc = (p1->x*p1->x + p1->y*p1->y - temp) / 2.0;
+        cd = (temp - p3->x*p3->x - p3->y*p3->y) / 2.0;
+        det = (p1->x - p2->x)*(p2->y - p3->y)-(p2->x - p3->x)*(p1->y - p2->y);
+
+        /* Check colinearity */
+        if(fabs(det) < EPSILON_SQLMM)
+        {
+                *result = NULL;
+                return -1.0;
+        }
+
+        det = 1.0 / det;
+        cx = (bc*(p2->y - p3->y)-cd*(p1->y - p2->y))*det;
+        cy = ((p1->x - p2->x)*cd-(p2->x - p3->x)*bc)*det;
+        c = lwalloc(sizeof(POINT4D));
+        c->x = cx;
+        c->y = cy;
+        *result = c;
+        cr = sqrt((cx-p1->x)*(cx-p1->x)+(cy-p1->y)*(cy-p1->y));
+        return cr;
+}
+
+/*******************************************************************************
+ * End PG_FUNCTIONs
+ ******************************************************************************/

Modified: packages/postgis/upstream/lwgeom/lwgeom_transform.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgeom_transform.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgeom_transform.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwgeom_transform.c 2515 2006-10-24 12:35:00Z strk $
+ * $Id: lwgeom_transform.c 2553 2006-12-15 11:00:50Z strk $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -760,12 +760,22 @@
 	geom = (PG_LWGEOM *)PG_DETOAST_DATUM_COPY(PG_GETARG_DATUM(0));
 	if (pglwgeom_getSRID(geom) == -1)
 	{
-		pfree(geom);
+		PG_FREE_IF_COPY(geom, 0);
 		elog(ERROR,"Input geometry has unknown (-1) SRID");
 		PG_RETURN_NULL();
 	}
 
 	/*
+	 * If input SRID and output SRID are equal, return geometry
+	 * without transform it
+	 */
+	if (pglwgeom_getSRID(geom) == result_srid)
+	{
+		pfree(geom);
+		PG_RETURN_POINTER(PG_GETARG_DATUM(0));
+	}
+
+	/*
 	 * If we have not already created PROJ4 cache for this portal
 	 * then create it
 	 */

Modified: packages/postgis/upstream/lwgeom/lwgparse.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwgparse.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwgparse.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -93,6 +93,12 @@
 tuple* free_list=0;
 int minpoints;
 int checkclosed;
+
+/*
+ * This inicates if the number of points in the geometry is required to
+ * be odd (one) or even (zero, currently not enforced) or whatever (-one)
+ */
+int isodd;
 double *first_point=NULL;
 double *last_point=NULL;
 
@@ -126,10 +132,15 @@
 void write_type_count(tuple* this,output_state* out);
 void alloc_point(void);
 void alloc_linestring(void);
+void alloc_linestring_closed(void);
+void alloc_circularstring(void);
+void alloc_circularstring_closed(void);
 void alloc_polygon(void);
 void alloc_multipoint(void);
 void alloc_multilinestring(void);
+void alloc_multicurve(void);
 void alloc_multipolygon(void);
+void alloc_multisurface(void);
 void alloc_geomertycollection(void);
 void alloc_counter(void);
 void alloc_empty(void);
@@ -194,7 +205,6 @@
 	}
 
 	the_geom.alloc_size += size;
-
 	return ret;
 }
 
@@ -234,6 +244,11 @@
 void
 alloc_stack_tuple(int type,output_func of,size_t size)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_stack_tuple %d, %d", type, size);
+#endif
+
 	tuple*	p;
 	inc_num();
 
@@ -257,6 +272,9 @@
 	if ( the_geom.stack->uu.nn.num < minpoints){
 		error("geometry requires more points");
 	}
+        if(isodd != -1 && the_geom.stack->uu.nn.num % 2 != isodd) {
+                error("geometry must have an odd number of points");
+        }
 	if ( checkclosed && first_point && last_point) {
 		if ( memcmp(first_point, last_point,
 			sizeof(double)*the_geom.ndims) )
@@ -271,10 +289,20 @@
 void
 check_dims(int num)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("check_dims the_geom.ndims = %d, num = %d", the_geom.ndims, num);
+#endif
+
 	if( the_geom.ndims != num){
 		if (the_geom.ndims) {
 			error("Can not mix dimensionality in a geometry");
 		} else {
+
+#ifdef PGIS_DEBUG
+                        lwnotice("check_dims: setting dim %d", num);
+#endif
+
 			the_geom.ndims = num;
 			if ( num > 2 ) the_geom.hasZ = 1;
 			if ( num > 3 ) the_geom.hasM = 1;
@@ -342,12 +370,22 @@
 void
 write_size(tuple* this,output_state* out)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("write_size");
+#endif
+
 	WRITE_INT4_REAL(out,the_geom.alloc_size);
 }
 
 void
 alloc_lwgeom(int srid)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_lwgeom %d", srid);
+#endif
+
 	the_geom.srid=srid;
 	the_geom.alloc_size=0;
 	the_geom.stack=NULL;
@@ -407,6 +445,11 @@
 void
 alloc_point_2d(double x,double y)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_point_2d %f,%f", x, y);
+#endif
+
 	tuple* p = alloc_tuple(write_point_2,the_geom.lwgi?8:16);
 	p->uu.points[0] = x;
 	p->uu.points[1] = y;
@@ -425,6 +468,11 @@
 void
 alloc_point_3d(double x,double y,double z)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_point_3d %f, %f, %f", x, y, z);
+#endif
+
 	tuple* p = alloc_tuple(write_point_3,the_geom.lwgi?12:24);
 	p->uu.points[0] = x;
 	p->uu.points[1] = y;
@@ -444,6 +492,11 @@
 void
 alloc_point_4d(double x,double y,double z,double m)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_point_4d %f, %f, %f, %f", x, y, z, m);
+#endif
+
 	tuple* p = alloc_tuple(write_point_4,the_geom.lwgi?16:32);
 	p->uu.points[0] = x;
 	p->uu.points[1] = y;
@@ -508,6 +561,11 @@
 void
 alloc_point(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_point");
+#endif
+
 	if( the_geom.lwgi)
 		alloc_stack_tuple(POINTTYPEI,write_type,1);
 	else
@@ -515,11 +573,17 @@
 
 	minpoints=1;
 	checkclosed=0;
+        isodd=-1;
 }
 
 void
 alloc_linestring(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_linestring");
+#endif
+
 	if( the_geom.lwgi)
 		alloc_stack_tuple(LINETYPEI,write_type,1);
 	else
@@ -527,11 +591,53 @@
 
 	minpoints=2;
 	checkclosed=0;
+        isodd=-1;
 }
 
+void alloc_linestring_closed(void)
+{
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_linestring_closed called.");
+#endif
+
+        alloc_linestring();
+        checkclosed=1;
+}
+
 void
+alloc_circularstring(void)
+{
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_circularstring");
+#endif
+
+        alloc_stack_tuple(CURVETYPE,write_type,1);
+        minpoints=3;
+        checkclosed=0;
+        isodd=1;
+}
+
+void alloc_circularstring_closed(void)
+{
+      
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_circularstring_closed");
+#endif
+
+        alloc_circularstring();
+        checkclosed=1;
+}
+
+void
 alloc_polygon(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_polygon");
+#endif
+
 	if( the_geom.lwgi)
 		alloc_stack_tuple(POLYGONTYPEI, write_type,1);
 	else
@@ -539,41 +645,120 @@
 
 	minpoints=3;
 	checkclosed=1;
+        isodd=-1;
+
 }
 
 void
+alloc_curvepolygon(void)
+{
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_curvepolygon called.");
+#endif
+
+        alloc_stack_tuple(CURVEPOLYTYPE, write_type, 1);
+        minpoints=3;
+        checkclosed=1;
+        isodd=-1;
+}
+
+void
+alloc_compoundcurve(void)
+{
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_compoundcurve called.");
+#endif
+
+        alloc_stack_tuple(COMPOUNDTYPE, write_type, 1);
+}
+
+void
 alloc_multipoint(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_multipoint");
+#endif 
+
 	alloc_stack_tuple(MULTIPOINTTYPE,write_type,1);
 }
 
 void
 alloc_multilinestring(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_multilinestring");
+#endif
+
 	alloc_stack_tuple(MULTILINETYPE,write_type,1);
 }
 
 void
+alloc_multicurve(void)
+{
+       
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_multicurve");
+#endif
+
+        alloc_stack_tuple(MULTICURVETYPE,write_type,1);
+}
+
+void
 alloc_multipolygon(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_multipolygon");
+#endif
+
 	alloc_stack_tuple(MULTIPOLYGONTYPE,write_type,1);
 }
 
 void
+alloc_multisurface(void)
+{
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_multisurface called");
+#endif
+
+        alloc_stack_tuple(MULTISURFACETYPE,write_type,1);
+}
+
+void
 alloc_geomertycollection(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_geometrycollection");
+#endif
+
 	alloc_stack_tuple(COLLECTIONTYPE,write_type,1);
 }
 
 void
 alloc_counter(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_counter");
+#endif
+
 	alloc_stack_tuple(0,write_count,4);
 }
 
 void
 alloc_empty(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_empty");
+#endif
+
 	tuple* st = the_geom.stack;
 	/* Find the last geometry */
 	while(st->uu.nn.type == 0){
@@ -597,12 +782,16 @@
 	}
 
 	st->uu.nn.num=0;
-
 }
 
 uchar *
 make_lwgeom(void)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("make_lwgeom");
+#endif
+
 	uchar* out_c;
 	output_state out;
 	tuple* cur;
@@ -622,6 +811,12 @@
 	return out_c;
 }
 
+void
+lwg_parse_yynotice(char* s)
+{
+        lwnotice(s);
+}
+
 int
 lwg_parse_yyerror(char* s)
 {
@@ -776,6 +971,11 @@
 void
 parse_wkb(const char **b)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("parse_wkb");
+#endif
+
 	int4 type;
 	uchar xdr = read_wkb_byte(b);
 	int4 localsrid;
@@ -829,7 +1029,7 @@
 	else{
 		/* If we are writing lwg and are reading wbki */
 		int4 towrite=type;
-		if (towrite > COLLECTIONTYPE ){
+		if (towrite >= POINTTYPEI && towrite <= POLYGONTYPEI){
 			towrite-=9;
 		}
 		alloc_stack_tuple(towrite,write_type,1);
@@ -844,13 +1044,27 @@
 			read_collection(b,read_wkb_point);
 			break;
 
+                case    CURVETYPE:
+                        read_collection(b,read_wkb_point);
+                        break;
+
 		case	POLYGONTYPE:
 			read_collection(b,read_collection2);
 			break;
 
+                case    COMPOUNDTYPE:
+                        read_collection(b,parse_wkb);
+                        break;
+
+                case    CURVEPOLYTYPE:
+                        read_collection(b,parse_wkb);
+                        break;
+
 		case	MULTIPOINTTYPE:
 		case	MULTILINETYPE:
+                case    MULTICURVETYPE:
 		case	MULTIPOLYGONTYPE:
+                case    MULTISURFACETYPE:
 		case	COLLECTIONTYPE:
 			read_collection(b,parse_wkb);
 			break;
@@ -883,6 +1097,11 @@
 void
 alloc_wkb(const char *parser)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("alloc_wkb");
+#endif
+
 	parse_wkb(&parser);
 }
 
@@ -893,13 +1112,19 @@
 parse_it(const char *geometry, allocator allocfunc, report_error errfunc)
 {
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("parse_it: %s", geometry);
+#endif
+
 	local_malloc = allocfunc;
 	error_func=errfunc;
 
 	ferror_occured = 0;
 
 	init_parser(geometry);
+
 	lwg_parse_yyparse();
+
 	close_parser();
 
 	if (ferror_occured)
@@ -925,7 +1150,13 @@
 void
 set_zm(char z, char m)
 {
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("set_zm %d, %d", z, m);
+#endif
+
 	the_geom.hasZ = z;
 	the_geom.hasM = m;
 	the_geom.ndims = 2+z+m;
 }
+

Modified: packages/postgis/upstream/lwgeom/lwline.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwline.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwline.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: lwline.c 2369 2006-05-30 08:38:58Z strk $
+ * $Id: lwline.c 2532 2006-12-01 22:16:44Z mleslie $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -31,11 +31,20 @@
 	LWLINE *result;
 	result = (LWLINE*) lwalloc(sizeof(LWLINE));
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwline_construct called.");
+#endif
+
 	result->type = lwgeom_makeType_full(
 		TYPE_HASZ(points->dims),
 		TYPE_HASM(points->dims),
 		(SRID!=-1), LINETYPE,
 		0);
+
+#ifdef PGIS_DEBUG
+        lwnotice("lwline_construct type=%d", result->type);
+#endif
+
 	result->SRID = SRID;
 	result->points = points;
 	result->bbox = bbox;

Added: packages/postgis/upstream/lwgeom/lwmcurve.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwmcurve.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwmcurve.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,125 @@
+/**********************************************************************
+ * $Id$
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2001-2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ * 
+ **********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "liblwgeom.h"
+
+LWMCURVE *
+lwmcurve_deserialize(uchar *srl)
+{
+        LWMCURVE *result;
+        LWGEOM_INSPECTED *insp;
+        int stype;
+        int type = lwgeom_getType(srl[0]);
+        int i;
+
+        if(type != MULTICURVETYPE)
+        {
+                lwerror("lwmcurve_deserialize called on NON multicurve: %d", type);
+                return NULL;
+        }
+
+        insp = lwgeom_inspect(srl);
+
+        result = lwalloc(sizeof(LWMCURVE));
+        result->type = insp->type;
+        result->SRID = insp->SRID;
+        result->ngeoms = insp->ngeometries;
+        result->geoms = lwalloc(sizeof(LWCURVE *)*insp->ngeometries);
+
+        if(lwgeom_hasBBOX(srl[0]))
+        {
+                result->bbox = lwalloc(sizeof(BOX2DFLOAT4));
+                memcpy(result->bbox, srl+1, sizeof(BOX2DFLOAT4));
+        }
+        else result->bbox = NULL;
+
+        for(i = 0; i < insp->ngeometries; i++)
+        {
+                stype = lwgeom_getType(insp->sub_geoms[i][0]);
+                if(stype == CURVETYPE)
+                {
+                        result->geoms[i] = (LWGEOM *)lwcurve_deserialize(insp->sub_geoms[i]);
+                }
+                else if(stype == LINETYPE)
+                {
+                        result->geoms[i] = (LWGEOM *)lwline_deserialize(insp->sub_geoms[i]);
+                }
+                else
+                {
+                        lwerror("Only Circular and Line strings are currenly permitted in a MultiCurve.");
+                        free(result);
+                        free(insp);
+                        return NULL;
+                }
+                        
+                if(TYPE_NDIMS(result->geoms[i]->type) != TYPE_NDIMS(result->type))
+                {
+                        lwerror("Mixed diminsions (multicurve: %d, curve %d:%d)",
+                                TYPE_NDIMS(result->type), i,
+                                TYPE_NDIMS(result->geoms[i]->type));
+                        free(result);
+                        free(insp);
+                        return NULL;
+                }
+        }
+        return result;
+}
+
+/*
+ * Add 'what' to this multicurve at position 'where'.
+ * where=0 == prepend
+ * where=-1 == append
+ * Returns a MULTICURVE or a COLLECTION
+ */
+LWGEOM *
+lwmcurve_add(const LWMCURVE *to, uint32 where, const LWGEOM *what)
+{
+        LWCOLLECTION *col;
+        LWGEOM **geoms;
+        int newtype;
+        uint32 i;
+
+        if(where == -1) where = to->ngeoms;
+        else if(where < -1 || where > to->ngeoms)
+        {
+                lwerror("lwmcurve_add: add position out of range %d..%d",
+                        -1, to->ngeoms);
+                return NULL;
+        }
+
+        /* dimensions compatibility are checked by caller */
+
+        /* Construct geoms array */
+        geoms = lwalloc(sizeof(LWGEOM *)*(to->ngeoms+1));
+        for(i = 0; i < where; i++)
+        {
+                geoms[i] = lwgeom_clone((LWGEOM *)to->geoms[i]);
+        }
+        geoms[where] = lwgeom_clone(what);
+        for(i = where; i < to->ngeoms; i++) 
+        {
+                geoms[i+1] = lwgeom_clone((LWGEOM *)to->geoms[i]);
+        }
+
+        if(TYPE_GETTYPE(what->type) == CURVETYPE) newtype = MULTICURVETYPE;
+        else newtype = COLLECTIONTYPE;
+
+        col = lwcollection_construct(newtype,
+                to->SRID, NULL,
+                to->ngeoms + 1, geoms);
+
+        return (LWGEOM *)col;
+}
+        

Added: packages/postgis/upstream/lwgeom/lwmsurface.c
===================================================================
--- packages/postgis/upstream/lwgeom/lwmsurface.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwmsurface.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,132 @@
+/**********************************************************************
+ * $Id$
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2001-2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ * 
+ **********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "liblwgeom.h"
+
+/*#define PGIS_DEBUG_CALLS 1 */
+
+LWMSURFACE *
+lwmsurface_deserialize(uchar *srl)
+{
+        LWMSURFACE *result;
+        LWGEOM_INSPECTED *insp;
+        int stype;
+        int type = lwgeom_getType(srl[0]);
+        int i;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("lwmsurface_deserialize called");
+#endif
+
+        if(type != MULTISURFACETYPE)
+        {
+                lwerror("lwmsurface_deserialize called on a non-multisurface: %d", type);
+                return NULL;
+        }
+
+        insp = lwgeom_inspect(srl);
+
+        result = lwalloc(sizeof(LWMSURFACE));
+        result->type = insp->type;
+        result->SRID = insp->SRID;
+        result->ngeoms = insp->ngeometries;
+        result->geoms = lwalloc(sizeof(LWPOLY *)*insp->ngeometries);
+
+        if(lwgeom_hasBBOX(srl[0]))
+        {
+                result->bbox = lwalloc(sizeof(BOX2DFLOAT4));
+                memcpy(result->bbox, srl + 1, sizeof(BOX2DFLOAT4));
+        }
+        else result->bbox = NULL;
+
+        for(i = 0; i < insp->ngeometries; i++)
+        {
+                stype = lwgeom_getType(insp->sub_geoms[i][0]);
+                if(stype == POLYGONTYPE) 
+                {
+                        result->geoms[i] = (LWGEOM *)lwpoly_deserialize(insp->sub_geoms[i]);
+                }
+                else if(stype == CURVEPOLYTYPE)
+                {
+                        result->geoms[i] = (LWGEOM *)lwcurvepoly_deserialize(insp->sub_geoms[i]);
+                }
+                else
+                {
+                        lwerror("Only Polygons and Curved Polygons are supported in a MultiSurface.");
+                        lwfree(result);
+                        lwfree(insp);
+                        return NULL;
+                }
+
+                if(TYPE_NDIMS(result->geoms[i]->type) != TYPE_NDIMS(result->type))
+                {
+                        lwerror("Mixed dimensions (multisurface: %d, surface %d:%d", 
+                                TYPE_NDIMS(result->type), i, 
+                                TYPE_NDIMS(result->geoms[i]->type));
+                        lwfree(result);
+                        lwfree(insp);
+                        return NULL;
+                }
+        }
+        return result;
+}
+
+/*
+ * Add 'what' to this multisurface at position 'where'
+ * where=0 == prepend
+ * where=-1 == append
+ * Returns a MULTISURFACE or a COLLECTION
+ */
+LWGEOM *
+lwmsurface_add(const LWMSURFACE *to, uint32 where, const LWGEOM *what)
+{
+        LWCOLLECTION *col;
+        LWGEOM **geoms;
+        int newtype;
+        uint32 i;
+        
+        if(where == -1) where = to->ngeoms;
+        else if(where < -1 || where > to->ngeoms)
+        {
+                lwerror("lwmsurface_add: add position out of range %d..%d",
+                        -1, to->ngeoms);
+                return NULL;
+        }
+
+        /* dimensions compatibility are checked by caller */
+
+        /* Construct geoms array */
+        geoms = lwalloc(sizeof(LWGEOM *)*(to->ngeoms+1));
+        for(i = 0; i < where; i++)
+        {
+                geoms[i] = lwgeom_clone((LWGEOM *)to->geoms[i]);
+        }
+        geoms[where] = lwgeom_clone(what);
+        for(i = where; i < to->ngeoms; i++)
+        {
+                geoms[i+1] = lwgeom_clone((LWGEOM *)to->geoms[i]);
+        }
+
+        if(TYPE_GETTYPE(what->type) == POLYGONTYPE 
+                || TYPE_GETTYPE(what->type) == CURVEPOLYTYPE) 
+            newtype = MULTISURFACETYPE;
+        else newtype = COLLECTIONTYPE;
+
+        col = lwcollection_construct(newtype,
+            to->SRID, NULL, to->ngeoms + 1, geoms);
+
+        return (LWGEOM *)col;
+}
+

Modified: packages/postgis/upstream/lwgeom/lwpostgis.sql.in
===================================================================
--- packages/postgis/upstream/lwgeom/lwpostgis.sql.in	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/lwpostgis.sql.in	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,6 +1,6 @@
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -- 
--- $Id: lwpostgis.sql.in 2406 2006-07-07 13:56:52Z strk $
+-- $Id: lwpostgis.sql.in 2550 2006-12-15 10:48:56Z strk $
 --
 -- PostGIS - Spatial Types for PostgreSQL
 -- http://postgis.refractions.net
@@ -19,33 +19,8 @@
 --
 -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 
+#include "sqldefines.h"
 
-#define CREATEFUNCTION CREATE OR REPLACE FUNCTION
-
-#if USE_VERSION > 72
-# define _IMMUTABLE_STRICT IMMUTABLE STRICT
-# define _IMMUTABLE IMMUTABLE
-# define _STABLE_STRICT STABLE STRICT
-# define _STABLE STABLE
-# define _VOLATILE_STRICT VOLATILE STRICT
-# define _VOLATILE VOLATILE
-# define _STRICT STRICT
-# define _SECURITY_DEFINER SECURITY DEFINER
-#else 
-# define _IMMUTABLE_STRICT  with(iscachable,isstrict)
-# define _IMMUTABLE with(iscachable)
-# define _STABLE_STRICT with(isstrict)
-# define _STABLE 
-# define _VOLATILE_STRICT with(isstrict)
-# define _VOLATILE 
-# define _STRICT with(isstrict)
-# define _SECURITY_DEFINER 
-#endif 
-
-#if USE_VERSION >= 73
-# define HAS_SCHEMAS 1
-#endif
-
 BEGIN;
 
 -------------------------------------------------------------------
@@ -1912,15 +1887,29 @@
 		   (new_type =''POLYGONM'') or
 		   (new_type =''MULTIPOLYGONM'') or
 		   (new_type =''LINESTRINGM'') or
-		   (new_type =''MULTILINESTRINGM'')) )
+		   (new_type =''MULTILINESTRINGM'') or
+                   (new_type = ''CIRCULARSTRING'') or
+                   (new_type = ''CIRCULARSTRINGM'') or
+                   (new_type = ''COMPOUNDCURVE'') or
+                   (new_type = ''COMPOUNDCURVEM'') or
+                   (new_type = ''CURVEPOLYGON'') or
+                   (new_type = ''CURVEPOLYGONM'') or
+                   (new_type = ''MULTICURVE'') or
+                   (new_type = ''MULTICURVEM'') or
+                   (new_type = ''MULTISURFACE'') or
+                   (new_type = ''MULTISURFACEM'')) )
 	THEN
 		RAISE EXCEPTION ''Invalid type name - valid ones are: 
 			GEOMETRY, GEOMETRYCOLLECTION, POINT, 
 			MULTIPOINT, POLYGON, MULTIPOLYGON, 
 			LINESTRING, MULTILINESTRING,
+                        CIRCULARSTRING, COMPOUNDCURVE,
+                        CURVEPOLYGON, MULTICURVE, MULTISURFACE,
 			GEOMETRYCOLLECTIONM, POINTM, 
 			MULTIPOINTM, POLYGONM, MULTIPOLYGONM, 
-			LINESTRINGM, or MULTILINESTRINGM '';
+			LINESTRINGM, MULTILINESTRINGM 
+                        CIRCULARSTRINGM, COMPOUNDCURVEM,
+                        CURVEPOLYGONM, MULTICURVEM or MULTISURFACEM'';
 		return ''fail'';
 	END IF;
 
@@ -3068,6 +3057,45 @@
 	AS '@MODULE_FILENAME@','LWGEOM_asGML'
 	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
 
+-----------------------------------------------------------------------
+-- KML OUTPUT
+-----------------------------------------------------------------------
+-- AsUKML(geom, precision, version)
+CREATEFUNCTION AsUKML(geometry, int4, int4)
+	RETURNS TEXT
+	AS '@MODULE_FILENAME@','LWGEOM_asKML'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- AsUKML(geom, precision) / version=2
+CREATEFUNCTION AsUKML(geometry, int4)
+	RETURNS TEXT
+	AS '@MODULE_FILENAME@','LWGEOM_asKML'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- AsUKML(geom) / precision=15 version=2
+CREATEFUNCTION AsUKML(geometry)
+	RETURNS TEXT
+	AS '@MODULE_FILENAME@','LWGEOM_asKML'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- AsKML(geom, precision, version)
+CREATE OR REPLACE FUNCTION AsKML(geometry, int4, int4)
+	RETURNS TEXT
+	AS 'SELECT AsUKML(transform($1,4326),$2,$3)' 
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- AsKML(geom, precision) / version=2
+CREATE OR REPLACE FUNCTION AsKML(geometry, int4) 
+	RETURNS TEXT
+	AS 'SELECT AsUKML(transform($1,4326),$2)' 
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- AsKML(geom) / precision=15 version=2
+CREATE OR REPLACE FUNCTION AsKML(geometry) 
+	RETURNS TEXT
+	AS 'SELECT AsUKML(transform($1,4326))' 
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
 ------------------------------------------------------------------------
 -- OGC defined
 ------------------------------------------------------------------------
@@ -3689,7 +3717,8 @@
 '
 LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; 
 
-#include "long_xact.sql"
+#include "long_xact.sql.in"
+#include "sqlmm.sql.in"
 
 ---------------------------------------------------------------
 -- END

Modified: packages/postgis/upstream/lwgeom/ptarray.c
===================================================================
--- packages/postgis/upstream/lwgeom/ptarray.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/ptarray.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,5 +1,5 @@
 /**********************************************************************
- * $Id: ptarray.c 2369 2006-05-30 08:38:58Z strk $
+ * $Id: ptarray.c 2532 2006-12-01 22:16:44Z mleslie $
  *
  * PostGIS - Spatial Types for PostgreSQL
  * http://postgis.refractions.net
@@ -307,8 +307,8 @@
 	size_t ptsize = pointArray_ptsize(pa);
 
 #ifdef PGIS_DEBUG_CALLS
-	lwnotice("ptarray_removePoint: pa %x p %x size %d where %d",
-		pa, p, pdims, where);
+	lwnotice("ptarray_removePoint: pa %x which %d",
+		pa, which);
 #endif
 
 #if PARANOIA_LEVEL > 0
@@ -353,6 +353,10 @@
 	POINTARRAY *out = lwalloc(sizeof(POINTARRAY));
 	size_t size;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("ptarray_clone called.");
+#endif
+
 	out->dims = in->dims;
 	out->npoints = in->npoints;
 
@@ -802,6 +806,10 @@
 {
 	DYNPTARRAY *ret=lwalloc(sizeof(DYNPTARRAY));
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("dynptarray_create called, dims=%d.", dims);
+#endif
+
 	if ( initial_capacity < 1 ) initial_capacity=1;
 
 	ret->pa=lwalloc(sizeof(POINTARRAY));
@@ -832,6 +840,10 @@
 	POINTARRAY *pa=dpa->pa;
 	POINT4D tmp;
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("dynptarray_addPoint4d called.");
+#endif
+
 	if ( ! allow_duplicates && pa->npoints > 0 )
 	{
 		getPoint4d_p(pa, pa->npoints-1, &tmp);
@@ -856,3 +868,4 @@
 
 	return 1;
 }
+

Added: packages/postgis/upstream/lwgeom/sqldefines.h
===================================================================
--- packages/postgis/upstream/lwgeom/sqldefines.h	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/sqldefines.h	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,30 @@
+#ifndef _LWPGIS_DEFINES
+#define _LWPGIS_DEFINES
+
+#define CREATEFUNCTION CREATE OR REPLACE FUNCTION
+
+#if USE_VERSION > 72
+# define _IMMUTABLE_STRICT IMMUTABLE STRICT
+# define _IMMUTABLE IMMUTABLE
+# define _STABLE_STRICT STABLE STRICT
+# define _STABLE STABLE
+# define _VOLATILE_STRICT VOLATILE STRICT
+# define _VOLATILE VOLATILE
+# define _STRICT STRICT
+# define _SECURITY_DEFINER SECURITY DEFINER
+#else 
+# define _IMMUTABLE_STRICT  with(iscachable,isstrict)
+# define _IMMUTABLE with(iscachable)
+# define _STABLE_STRICT with(isstrict)
+# define _STABLE 
+# define _VOLATILE_STRICT with(isstrict)
+# define _VOLATILE 
+# define _STRICT with(isstrict)
+# define _SECURITY_DEFINER 
+#endif 
+
+#if USE_VERSION >= 73
+# define HAS_SCHEMAS 1
+#endif
+
+#endif /* _LWPGIS_DEFINES */

Added: packages/postgis/upstream/lwgeom/sqlmm.sql.in
===================================================================
--- packages/postgis/upstream/lwgeom/sqlmm.sql.in	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/sqlmm.sql.in	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,756 @@
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+-- 
+-- $Id: sqlmm.sql.in 2406 2006-11-02 13:56:52Z kneufeld $
+--
+-- PostGIS - Spatial Types for PostgreSQL
+-- http://postgis.refractions.net
+-- Copyright 2001-2003 Refractions Research Inc.
+--
+-- This is free software; you can redistribute and/or modify it under
+-- the terms of the GNU General Public Licence. See the COPYING file.
+--  
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+-- This file defines a subset of SQL/MM functions (that is, only those
+-- currently defined by ESRI's ArcSDE). Since these functions already exist
+-- in PostGIS (for the most part), these functions simply expose the current
+-- functions. Although mostly complying with SQL/MM standards, these prototypes
+-- follow ESRI's ArcSDE SQL Specifications and not SQL/MM standards where 
+-- disparities exist.
+--
+-- Specification Disparity Notes:
+--   * ST_OrderingEquals(geometry, geometry) is implemented as per
+--     ESRI's ArcSDE SQL specifications, not SQL/MM specifications.
+--     (http://edndoc.esri.com/arcsde/9.1/sql_api/sqlapi3.htm#ST_OrderingEquals)
+--   * Geometry constructors default to an SRID of -1, not 0 as per SQL/MM specs.
+--   * Boolean return type methods (ie. ST_IsValid, ST_IsEmpty, ...)
+--      * SQL/MM           : RETURNS 1 if TRUE, 0 if (FALSE, NULL)
+--      * ESRI in Informix : RETURNS 1 if (TRUE, NULL), 0 if FALSE
+--      * ESRI in DB2      : RETURNS 1 if TRUE, 0 if FALSE, NULL if NULL 
+--      * PostGIS          : RETURNS 1 if TRUE, 0 if FALSE, NULL if NULL 
+--
+-- TODO: Implement ESRI's Shape constructors
+--   * SE_AsShape(geometry)
+--   * SE_ShapeToSQL
+--   * SE_GeomFromShape
+--   * SE_PointFromShape
+--   * SE_LineFromShape
+--   * SE_PolyFromShape
+--   * SE_MPointFromShape
+--   * SE_MLineFromShape
+--   * SE_MPolyFromShape
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+#include "sqldefines.h"
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions for constructing an ST_Geometry
+--     value given its WTK representation
+-- (http://edndoc.esri.com/arcsde/9.1/general_topics/storing_geo_in_rdbms.html)
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: GeometryFromText(text)
+-- Note: Defaults to an SRID=-1, not 0 as per SQL/MM specs.
+CREATEFUNCTION ST_WKTToSQL(text)
+	RETURNS geometry AS 'SELECT geometryfromtext($1)'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: GeometryFromText(text, int4)
+CREATEFUNCTION ST_GeomFromText(text, int4)
+	RETURNS geometry AS 'SELECT geometryfromtext($1, $2)'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: PointFromText(text, int4)
+-- TODO: improve this ... by not duplicating constructor time.
+CREATEFUNCTION ST_PointFromText(text, int4)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''POINT''
+	THEN GeomFromText($1, $2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: LineFromText(text, int4)
+CREATEFUNCTION ST_LineFromText(text, int4)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''LINESTRING''
+	THEN GeomFromText($1,$2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: PolyFromText(text, int4)
+CREATEFUNCTION ST_PolyFromText(text, int4)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''POLYGON''
+	THEN GeomFromText($1, $2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: MPointFromText(text, int4)
+CREATEFUNCTION ST_MPointFromText(text, int4)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''MULTIPOINT''
+	THEN GeomFromText($1, $2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: MLineFromText(text, int4)
+CREATEFUNCTION ST_MLineFromText(text, int4)
+	RETURNS geometry
+	AS '
+	SELECT CASE
+	WHEN geometrytype(GeomFromText($1, $2)) = ''MULTILINESTRING''
+	THEN GeomFromText($1,$2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: MPolyFromText(text, int4)
+CREATEFUNCTION ST_MPolyFromText(text, int4)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''MULTIPOLYGON''
+	THEN GeomFromText($1,$2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions for constructing an ST_Geometry
+--     value given its WKB representation
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: GeomFromWKB(bytea))
+-- Note: Defaults to an SRID=-1, not 0 as per SQL/MM specs.
+CREATEFUNCTION ST_WKBToSQL(bytea)
+	RETURNS geometry
+	AS 'SELECT GeomFromWKB($1)'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: GeomFromWKB(bytea, int)
+CREATEFUNCTION ST_GeomFromWKB(bytea, int)
+	RETURNS geometry
+	AS 'SELECT setSRID(GeomFromWKB($1), $2)'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: PointFromWKB(bytea, int)
+CREATEFUNCTION ST_PointFromWKB(bytea, int)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''POINT''
+	THEN GeomFromWKB($1, $2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: LineFromWKB(text, int)
+CREATEFUNCTION ST_LineFromWKB(bytea, int)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''LINESTRING''
+	THEN GeomFromWKB($1, $2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: PolyFromWKB(text, int)
+CREATEFUNCTION ST_PolyFromWKB(bytea, int)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''POLYGON''
+	THEN GeomFromWKB($1, $2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: MPointFromWKB(text, int)
+CREATEFUNCTION ST_MPointFromWKB(bytea, int)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTIPOINT''
+	THEN GeomFromWKB($1, $2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: MLineFromWKB(text, int)
+CREATEFUNCTION ST_MLineFromWKB(bytea, int)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTILINESTRING''
+	THEN GeomFromWKB($1, $2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: MPolyFromWKB(text, int)
+CREATEFUNCTION ST_MPolyFromWKB(bytea, int)
+	RETURNS geometry
+	AS '
+	SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTIPOLYGON''
+	THEN GeomFromWKB($1, $2)
+	ELSE NULL END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions for constructing an ST_Geometry
+--     value given an ESRI Shape representation
+-------------------------------------------------------------------------------
+
+-- TODO: SE_ShapeToSQL
+-- TODO: SE_GeomFromShape
+-- TODO: SE_PointFromShape
+-- TODO: SE_LineFromShape
+-- TODO: SE_PolyFromShape
+-- TODO: SE_MPointFromShape
+-- TODO: SE_MLineFromShape
+-- TODO: SE_MPolyFromShape
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions for obtaining the WKT representation
+--     of an ST_Geometry
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: AsText(geometry)
+CREATEFUNCTION ST_AsText(geometry)
+    RETURNS TEXT
+    AS '@MODULE_FILENAME@','LWGEOM_asText'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions for obtaining the WKB representation
+--     of an ST_Geometry
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: AsBinary(geometry)
+CREATEFUNCTION ST_AsBinary(geometry)
+    RETURNS bytea
+    AS '@MODULE_FILENAME@','LWGEOM_asBinary'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions for obtaining the ESRI Shape representation
+--     of an ST_Geometry
+-------------------------------------------------------------------------------
+
+-- TODO: SE_AsShape(geometry)
+--CREATEFUNCTION SE_AsShape(geometry)
+--    RETURNS bytea
+--    AS '@MODULE_FILENAME@','LWGEOM_AsShape'
+--    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions on type ST_Geometry
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: Dimension(geometry)
+CREATEFUNCTION ST_Dimension(geometry)
+    RETURNS int4
+    AS '@MODULE_FILENAME@', 'LWGEOM_dimension'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: ndims(geometry)
+CREATEFUNCTION ST_CoordDim(geometry)
+    RETURNS smallint
+    AS '@MODULE_FILENAME@', 'LWGEOM_ndims'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (iscachable,isstrict);
+
+-- PostGIS equivalent function: GeometryType(geometry)
+CREATEFUNCTION ST_GeometryType(geometry)
+    RETURNS text
+    AS '
+    DECLARE
+        gtype text := geometrytype($1);
+    BEGIN
+        IF (gtype IN (''POINT'', ''POINTM'')) THEN
+            gtype := ''Point'';
+        ELSIF (gtype IN (''LINESTRING'', ''LINESTRINGM'')) THEN
+            gtype := ''LineString'';
+        ELSIF (gtype IN (''POLYGON'', ''POLYGONM'')) THEN
+            gtype := ''Polygon'';
+        ELSIF (gtype IN (''MULTIPOINT'', ''MULTIPOINTM'')) THEN
+            gtype := ''MultiPoint'';
+        ELSIF (gtype IN (''MULTILINESTRING'', ''MULTILINESTRINGM'')) THEN
+            gtype := ''MultiLineString'';
+        ELSIF (gtype IN (''MULTIPOLYGON'', ''MULTIPOLYGONM'')) THEN
+            gtype := ''MultiPolygon'';
+        ELSE
+            gtype := ''Geometry'';
+        END IF;
+        RETURN ''ST_'' || gtype;
+    END
+	'
+	LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- ST_AsText(geometry) - already defined.
+-- ST_AsBinary(geometry) - already defined.
+-- SE_AsShape(geometry) - already defined.
+
+-- PostGIS equivalent function: getSRID(geometry)
+CREATEFUNCTION ST_SRID(geometry) 
+    RETURNS int4
+    AS '@MODULE_FILENAME@','LWGEOM_getSRID'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: IsEmpty(geometry)
+CREATEFUNCTION ST_IsEmpty(geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@', 'LWGEOM_isempty'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: IsSimple(geometry)	
+CREATEFUNCTION ST_IsSimple(geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@', 'issimple'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: IsValid(geometry)
+-- TODO: change null returns to true
+CREATEFUNCTION ST_IsValid(geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@', 'isvalid'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: boundary(geometry)
+CREATEFUNCTION ST_Boundary(geometry)
+    RETURNS geometry
+    AS '@MODULE_FILENAME@','boundary'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: envelope(geometry)
+CREATEFUNCTION ST_Envelope(geometry)
+    RETURNS geometry
+    AS '@MODULE_FILENAME@', 'LWGEOM_envelope'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (iscachable,isstrict);
+
+-- PostGIS equivalent function: transform(geometry,integer)
+CREATEFUNCTION ST_Transform(geometry,integer)
+    RETURNS geometry
+    AS '@MODULE_FILENAME@','transform'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: ~= 
+CREATEFUNCTION ST_OrderingEquals(geometry, geometry)
+    RETURNS boolean
+    AS '
+    SELECT $1 && $2 AND $1 ~= $2
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: zmflag(geometry)
+CREATEFUNCTION SE_Is3D(geometry)
+    RETURNS boolean
+    AS '
+    SELECT CASE zmflag($1)
+               WHEN 0 THEN false
+               WHEN 1 THEN false
+               WHEN 2 THEN true
+               WHEN 3 THEN true
+               ELSE false
+           END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: zmflag(geometry)
+CREATEFUNCTION SE_IsMeasured(geometry)
+    RETURNS boolean
+    AS '
+    SELECT CASE zmflag($1)
+               WHEN 0 THEN false
+               WHEN 1 THEN true
+               WHEN 2 THEN false
+               WHEN 3 THEN true
+               ELSE false
+           END
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions on type ST_Point
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: makePoint(float8,float8)
+CREATEFUNCTION ST_Point(float8, float8)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@', 'LWGEOM_makepoint'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (iscachable,isstrict);
+
+-- PostGIS equivalent function: X(geometry)
+CREATEFUNCTION ST_X(geometry)
+	RETURNS float8
+	AS '@MODULE_FILENAME@','LWGEOM_x_point'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: Y(geometry)
+CREATEFUNCTION ST_Y(geometry)
+	RETURNS float8
+	AS '@MODULE_FILENAME@','LWGEOM_y_point'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: Z(geometry)
+CREATEFUNCTION SE_Z(geometry)
+	RETURNS float8
+	AS '@MODULE_FILENAME@','LWGEOM_z_point'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: M(geometry)
+CREATEFUNCTION SE_M(geometry)
+	RETURNS float8
+	AS '@MODULE_FILENAME@','LWGEOM_m_point'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions on type ST_Curve
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: StartPoint(geometry))
+CREATEFUNCTION ST_StartPoint(geometry)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@', 'LWGEOM_startpoint_linestring'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: EndPoint(geometry))
+CREATEFUNCTION ST_EndPoint(geometry)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@', 'LWGEOM_endpoint_linestring'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: IsClosed(geometry)
+CREATEFUNCTION ST_IsClosed(geometry)
+	RETURNS boolean
+	AS '@MODULE_FILENAME@', 'LWGEOM_isclosed_linestring'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: IsRing(geometry)
+CREATEFUNCTION ST_IsRing(geometry)
+	RETURNS boolean
+	AS '@MODULE_FILENAME@', 'isring'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: length2d(geometry)
+CREATEFUNCTION ST_Length(geometry)
+	RETURNS FLOAT8
+	AS '@MODULE_FILENAME@', 'LWGEOM_length2d_linestring'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions on type ST_LineString
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: NumPoints(geometry)
+CREATEFUNCTION ST_NumPoints(geometry)
+	RETURNS int4
+	AS '@MODULE_FILENAME@', 'LWGEOM_numpoints_linestring'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: PointN(geometry)
+CREATEFUNCTION ST_PointN(geometry)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@','LWGEOM_pointn_linestring'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions on type ST_Surface
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: Centroid(geometry)
+CREATEFUNCTION ST_Centroid(geometry)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@', 'centroid'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: PointOnSurface(geometry)
+CREATEFUNCTION ST_PointOnSurface(geometry)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@', 'pointonsurface'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: area(geometry)
+CREATEFUNCTION ST_Area(geometry)
+	RETURNS FLOAT8
+	AS '@MODULE_FILENAME@','LWGEOM_area_polygon'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: perimeter2d(geometry)
+CREATEFUNCTION ST_Perimeter(geometry)
+	RETURNS FLOAT8
+	AS '@MODULE_FILENAME@', 'LWGEOM_perimeter2d_poly'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions on type ST_Polygon
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: MakePolygon(geometry)
+CREATEFUNCTION ST_Polygon(geometry, int)
+	RETURNS geometry
+	AS '
+	SELECT setSRID(makepolygon($1), $2)
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: ExteriorRing(geometry)
+CREATEFUNCTION ST_ExteriorRing(geometry)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@','LWGEOM_exteriorring_polygon'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: NumInteriorRings(geometry)
+CREATEFUNCTION ST_NumInteriorRing(geometry)
+	RETURNS integer
+	AS '@MODULE_FILENAME@','LWGEOM_numinteriorrings_polygon'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: InteriorRingN(geometry)
+CREATEFUNCTION ST_InteriorRingN(geometry,integer)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@','LWGEOM_interiorringn_polygon'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions on type ST_GeomCollection
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: NumGeometries(geometry)
+CREATEFUNCTION ST_NumGeometries(geometry)
+	RETURNS int4
+	AS '@MODULE_FILENAME@', 'LWGEOM_numgeometries_collection'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+-- PostGIS equivalent function: GeometryN(geometry)
+CREATEFUNCTION ST_GeometryN(geometry,integer)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@', 'LWGEOM_geometryn_collection'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions on type ST_MultiCurve
+-------------------------------------------------------------------------------
+
+-- ST_IsClosed(geometry) - already defined.
+-- ST_Length(geometry) - already defined.
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions on type ST_MultiSurface
+-------------------------------------------------------------------------------
+
+-- ST_Centroid(geometry) - already defined.
+-- ST_PointOnSurface(geometry) - already defined.
+-- ST_Area(geometry) - already defined.
+-- ST_Perimeter(geometry) - already defined.
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions that test spatial relationships
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: Equals(geometry,geometry)
+CREATEFUNCTION ST_Equals(geometry,geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@','geomequals'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: disjoint(geometry,geometry)
+CREATEFUNCTION ST_Disjoint(geometry,geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@','disjoint'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: touches(geometry,geometry)
+CREATEFUNCTION ST_Touches(geometry,geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@','touches'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: within(geometry,geometry)
+CREATEFUNCTION ST_Within(geometry,geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@','within'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: overlaps(geometry,geometry)
+CREATEFUNCTION ST_Overlaps(geometry,geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@','overlaps'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: crosses(geometry,geometry)
+CREATEFUNCTION ST_Crosses(geometry,geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@','crosses'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: intersects(geometry,geometry)
+CREATEFUNCTION ST_Intersects(geometry,geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@','intersects'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: contains(geometry,geometry)
+CREATEFUNCTION ST_Contains(geometry,geometry)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@','contains'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: none
+CREATEFUNCTION SE_EnvelopesIntersect(geometry,geometry)
+    RETURNS boolean
+	AS '
+	SELECT $1 && $2
+	'
+	LANGUAGE 'SQL' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: relate(geometry,geometry,text)
+CREATEFUNCTION ST_Relate(geometry,geometry,text)
+    RETURNS boolean
+    AS '@MODULE_FILENAME@','relate_pattern'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions for distance relationships
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: distance(geometry,geometry)
+CREATEFUNCTION ST_Distance(geometry,geometry)
+    RETURNS float8
+    AS '@MODULE_FILENAME@', 'LWGEOM_mindistance2d'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+
+
+
+
+
+-------------------------------------------------------------------------------
+-- SQL/MM (ArcSDE subset) - SQL Functions that implement spatial operators
+-------------------------------------------------------------------------------
+
+-- PostGIS equivalent function: intersection(geometry,geometry)
+CREATEFUNCTION ST_Intersection(geometry,geometry)
+    RETURNS geometry
+    AS '@MODULE_FILENAME@','intersection'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: difference(geometry,geometry)
+CREATEFUNCTION ST_Difference(geometry,geometry)
+    RETURNS geometry
+    AS '@MODULE_FILENAME@','difference'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: GeomUnion(geometry,geometry)
+CREATEFUNCTION ST_Union(geometry,geometry)
+    RETURNS geometry
+    AS '@MODULE_FILENAME@','geomunion'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: symdifference(geometry,geometry)
+CREATEFUNCTION ST_SymDifference(geometry,geometry)
+    RETURNS geometry
+    AS '@MODULE_FILENAME@','symdifference'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: buffer(geometry,float8)
+CREATEFUNCTION ST_Buffer(geometry,float8)
+    RETURNS geometry
+    AS '@MODULE_FILENAME@','buffer'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: convexhull(geometry)
+CREATEFUNCTION ST_ConvexHull(geometry)
+    RETURNS geometry
+    AS '@MODULE_FILENAME@','convexhull'
+    LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+
+-- PostGIS equivalent function: locate_along_measure(geometry, float8)
+CREATEFUNCTION SE_LocateAlong(geometry, float8)
+	RETURNS geometry
+	AS 'SELECT locate_between_measures($1, $2, $2)'
+	LANGUAGE 'sql' _IMMUTABLE_STRICT;
+
+-- PostGIS equivalent function: locate_between_measures(geometry, float8, float8)
+CREATEFUNCTION SE_LocateBetween(geometry, float8, float8)
+	RETURNS geometry
+	AS '@MODULE_FILENAME@', 'LWGEOM_locate_between_m'
+	LANGUAGE 'C' _IMMUTABLE_STRICT;
+
+
+
+-------------------------------------------------------------------------------
+-- END
+-------------------------------------------------------------------------------
+

Modified: packages/postgis/upstream/lwgeom/wktparse.h
===================================================================
--- packages/postgis/upstream/lwgeom/wktparse.h	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/wktparse.h	2007-04-13 07:15:27 UTC (rev 758)
@@ -40,6 +40,12 @@
 #define LINETYPEI     11
 #define POLYGONTYPEI  12
 
+#define CURVETYPE       8
+#define COMPOUNDTYPE    9
+#define CURVEPOLYTYPE   13
+#define MULTICURVETYPE          14
+#define MULTISURFACETYPE        15
+
 extern int srid;
 
 /*
@@ -59,10 +65,17 @@
 
 void alloc_point(void);
 void alloc_linestring(void);
+void alloc_linestring_closed(void);
+void alloc_circularstring(void);
+void alloc_circularstring_closed(void);
 void alloc_polygon(void);
+void alloc_compoundcurve(void);
+void alloc_curvepolygon(void);
 void alloc_multipoint(void);
 void alloc_multilinestring(void);
+void alloc_multicurve(void);
 void alloc_multipolygon(void);
+void alloc_multisurface(void);
 void alloc_geomertycollection(void);
 void alloc_empty();
 void alloc_counter(void);

Modified: packages/postgis/upstream/lwgeom/wktparse.lex
===================================================================
--- packages/postgis/upstream/lwgeom/wktparse.lex	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/wktparse.lex	2007-04-13 07:15:27 UTC (rev 758)
@@ -36,14 +36,24 @@
 <*>POINTM 	{ return POINTM; }
 <*>LINESTRING { return LINESTRING; }
 <*>LINESTRINGM { return LINESTRINGM; }
+<*>CIRCULARSTRING { return CIRCULARSTRING; }
+<*>CIRCULARSTRINGM { return CIRCULARSTRINGM; }
 <*>POLYGON { return POLYGON; }
 <*>POLYGONM { return POLYGONM; }
+<*>COMPOUNDCURVE { return COMPOUNDCURVE; }
+<*>COMPOUNDCURVEM { return COMPOUNDCURVEM; }
+<*>CURVEPOLYGON { return CURVEPOLYGON; }
+<*>CURVEPOLYGONM { return CURVEPOLYGONM; }
 <*>MULTIPOINT { return MULTIPOINT; }
 <*>MULTIPOINTM { return MULTIPOINTM; }
 <*>MULTILINESTRING { return MULTILINESTRING; }
 <*>MULTILINESTRINGM { return MULTILINESTRINGM; }
+<*>MULTICURVE { return MULTICURVE; }
+<*>MULTICURVEM { return MULTICURVEM; }
 <*>MULTIPOLYGON { return MULTIPOLYGON; }
 <*>MULTIPOLYGONM { return MULTIPOLYGONM; }
+<*>MULTISURFACE { return MULTISURFACE; }
+<*>MULTISURFACEM { return MULTISURFACEM; }
 <*>GEOMETRYCOLLECTION { return GEOMETRYCOLLECTION; }
 <*>GEOMETRYCOLLECTIONM { return GEOMETRYCOLLECTIONM; }
 <*>SRID { BEGIN(vals_ok); return SRID; }

Modified: packages/postgis/upstream/lwgeom/wktparse.tab.c
===================================================================
--- packages/postgis/upstream/lwgeom/wktparse.tab.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/wktparse.tab.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,7 +1,7 @@
-/* A Bison parser, made by GNU Bison 1.875.  */
+/* A Bison parser, made by GNU Bison 1.875c.  */
 
 /* Skeleton parser for Yacc-like parsing with Bison,
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -69,22 +69,32 @@
      MULTILINESTRING = 262,
      MULTIPOLYGON = 263,
      GEOMETRYCOLLECTION = 264,
-     POINTM = 265,
-     LINESTRINGM = 266,
-     POLYGONM = 267,
-     MULTIPOINTM = 268,
-     MULTILINESTRINGM = 269,
-     MULTIPOLYGONM = 270,
-     GEOMETRYCOLLECTIONM = 271,
-     SRID = 272,
-     EMPTY = 273,
-     VALUE = 274,
-     LPAREN = 275,
-     RPAREN = 276,
-     COMMA = 277,
-     EQUALS = 278,
-     SEMICOLON = 279,
-     WKB = 280
+     CIRCULARSTRING = 265,
+     COMPOUNDCURVE = 266,
+     CURVEPOLYGON = 267,
+     MULTICURVE = 268,
+     MULTISURFACE = 269,
+     POINTM = 270,
+     LINESTRINGM = 271,
+     POLYGONM = 272,
+     MULTIPOINTM = 273,
+     MULTILINESTRINGM = 274,
+     MULTIPOLYGONM = 275,
+     GEOMETRYCOLLECTIONM = 276,
+     CIRCULARSTRINGM = 277,
+     COMPOUNDCURVEM = 278,
+     CURVEPOLYGONM = 279,
+     MULTICURVEM = 280,
+     MULTISURFACEM = 281,
+     SRID = 282,
+     EMPTY = 283,
+     VALUE = 284,
+     LPAREN = 285,
+     RPAREN = 286,
+     COMMA = 287,
+     EQUALS = 288,
+     SEMICOLON = 289,
+     WKB = 290
    };
 #endif
 #define POINT 258
@@ -94,22 +104,32 @@
 #define MULTILINESTRING 262
 #define MULTIPOLYGON 263
 #define GEOMETRYCOLLECTION 264
-#define POINTM 265
-#define LINESTRINGM 266
-#define POLYGONM 267
-#define MULTIPOINTM 268
-#define MULTILINESTRINGM 269
-#define MULTIPOLYGONM 270
-#define GEOMETRYCOLLECTIONM 271
-#define SRID 272
-#define EMPTY 273
-#define VALUE 274
-#define LPAREN 275
-#define RPAREN 276
-#define COMMA 277
-#define EQUALS 278
-#define SEMICOLON 279
-#define WKB 280
+#define CIRCULARSTRING 265
+#define COMPOUNDCURVE 266
+#define CURVEPOLYGON 267
+#define MULTICURVE 268
+#define MULTISURFACE 269
+#define POINTM 270
+#define LINESTRINGM 271
+#define POLYGONM 272
+#define MULTIPOINTM 273
+#define MULTILINESTRINGM 274
+#define MULTIPOLYGONM 275
+#define GEOMETRYCOLLECTIONM 276
+#define CIRCULARSTRINGM 277
+#define COMPOUNDCURVEM 278
+#define CURVEPOLYGONM 279
+#define MULTICURVEM 280
+#define MULTISURFACEM 281
+#define SRID 282
+#define EMPTY 283
+#define VALUE 284
+#define LPAREN 285
+#define RPAREN 286
+#define COMMA 287
+#define EQUALS 288
+#define SEMICOLON 289
+#define WKB 290
 
 
 
@@ -145,7 +165,7 @@
 	const char* wkb;
 } YYSTYPE;
 /* Line 191 of yacc.c.  */
-#line 148 "y.tab.c"
+#line 169 "y.tab.c"
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
 # define YYSTYPE_IS_TRIVIAL 1
@@ -157,22 +177,29 @@
 
 
 /* Line 214 of yacc.c.  */
-#line 160 "y.tab.c"
+#line 181 "y.tab.c"
 
 #if ! defined (yyoverflow) || YYERROR_VERBOSE
 
+# ifndef YYFREE
+#  define YYFREE free
+# endif
+# ifndef YYMALLOC
+#  define YYMALLOC malloc
+# endif
+
 /* The parser invokes alloca or malloc; define the necessary symbols.  */
 
-# if YYSTACK_USE_ALLOCA
-#  define YYSTACK_ALLOC alloca
+# ifdef YYSTACK_USE_ALLOCA
+#  if YYSTACK_USE_ALLOCA
+#   define YYSTACK_ALLOC alloca
+#  endif
 # else
-#  ifndef YYSTACK_USE_ALLOCA
-#   if defined (alloca) || defined (_ALLOCA_H)
-#    define YYSTACK_ALLOC alloca
-#   else
-#    ifdef __GNUC__
-#     define YYSTACK_ALLOC __builtin_alloca
-#    endif
+#  if defined (alloca) || defined (_ALLOCA_H)
+#   define YYSTACK_ALLOC alloca
+#  else
+#   ifdef __GNUC__
+#    define YYSTACK_ALLOC __builtin_alloca
 #   endif
 #  endif
 # endif
@@ -185,15 +212,15 @@
 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
 #   define YYSIZE_T size_t
 #  endif
-#  define YYSTACK_ALLOC malloc
-#  define YYSTACK_FREE free
+#  define YYSTACK_ALLOC YYMALLOC
+#  define YYSTACK_FREE YYFREE
 # endif
 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
 
 
 #if (! defined (yyoverflow) \
      && (! defined (__cplusplus) \
-	 || (YYSTYPE_IS_TRIVIAL)))
+	 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
 
 /* A type that is properly aligned for any stack member.  */
 union yyalloc
@@ -214,7 +241,7 @@
 /* Copy COUNT objects from FROM to TO.  The source and destination do
    not overlap.  */
 # ifndef YYCOPY
-#  if 1 < __GNUC__
+#  if defined (__GNUC__) && 1 < __GNUC__
 #   define YYCOPY(To, From, Count) \
       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
 #  else
@@ -256,20 +283,20 @@
 /* YYFINAL -- State number of the termination state. */
 #define YYFINAL  6
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   104
+#define YYLAST   180
 
 /* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS  26
+#define YYNTOKENS  36
 /* YYNNTS -- Number of nonterminals. */
-#define YYNNTS  66
+#define YYNNTS  107
 /* YYNRULES -- Number of rules. */
-#define YYNRULES  98
+#define YYNRULES  169
 /* YYNRULES -- Number of states. */
-#define YYNSTATES  139
+#define YYNSTATES  237
 
 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   280
+#define YYMAXUTOK   290
 
 #define YYTRANSLATE(YYX) 						\
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -305,69 +332,102 @@
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
-      25
+      25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+      35
 };
 
 #if YYDEBUG
 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
    YYRHS.  */
-static const unsigned char yyprhs[] =
+static const unsigned short yyprhs[] =
 {
        0,     0,     3,     4,     9,    10,    13,    15,    17,    19,
-      21,    23,    25,    27,    29,    33,    35,    38,    39,    43,
-      45,    47,    48,    51,    52,    55,    59,    60,    64,    65,
-      69,    71,    72,    77,    79,    83,    85,    86,    89,    92,
-      93,    97,    99,   101,   102,   105,   106,   109,   110,   115,
-     117,   121,   122,   126,   127,   131,   133,   134,   139,   141,
-     145,   148,   149,   153,   155,   157,   158,   161,   162,   165,
-     166,   171,   173,   177,   178,   182,   183,   187,   189,   190,
-     195,   197,   201,   202,   206,   207,   211,   213,   214,   219,
-     221,   223,   227,   229,   231,   233,   236,   240,   245
+      21,    23,    25,    27,    29,    31,    33,    35,    37,    39,
+      43,    45,    48,    49,    53,    55,    57,    58,    61,    62,
+      65,    69,    70,    74,    75,    79,    81,    82,    87,    89,
+      93,    95,    96,    99,   102,   103,   107,   109,   111,   112,
+     115,   116,   119,   120,   123,   124,   129,   131,   135,   138,
+     139,   143,   146,   147,   151,   153,   155,   157,   159,   160,
+     163,   164,   167,   168,   171,   172,   177,   179,   183,   184,
+     188,   189,   193,   195,   196,   201,   203,   205,   209,   213,
+     214,   218,   219,   223,   225,   226,   231,   233,   237,   238,
+     242,   243,   247,   249,   250,   255,   257,   259,   263,   267,
+     270,   271,   275,   277,   279,   280,   283,   284,   287,   288,
+     293,   295,   299,   300,   304,   305,   309,   311,   312,   317,
+     319,   321,   325,   329,   330,   334,   335,   339,   341,   342,
+     347,   349,   353,   354,   358,   359,   363,   365,   366,   371,
+     373,   375,   379,   383,   384,   388,   389,   393,   395,   396,
+     401,   403,   405,   409,   411,   413,   415,   418,   422,   427
 };
 
 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
-static const yysigned_char yyrhs[] =
+static const short yyrhs[] =
 {
-      27,     0,    -1,    -1,    31,    24,    28,    30,    -1,    -1,
-      29,    30,    -1,    32,    -1,    33,    -1,    49,    -1,    65,
-      -1,    41,    -1,    59,    -1,    75,    -1,    81,    -1,    17,
-      23,    19,    -1,    25,    -1,     3,    35,    -1,    -1,    10,
-      34,    35,    -1,    36,    -1,    38,    -1,    -1,    37,    91,
-      -1,    -1,    39,    40,    -1,    20,    87,    21,    -1,    -1,
-       6,    42,    44,    -1,    -1,    13,    43,    44,    -1,    91,
-      -1,    -1,    45,    20,    46,    21,    -1,    47,    -1,    46,
-      22,    47,    -1,    38,    -1,    -1,    48,    87,    -1,     4,
-      51,    -1,    -1,    11,    50,    51,    -1,    52,    -1,    54,
-      -1,    -1,    53,    91,    -1,    -1,    55,    56,    -1,    -1,
-      57,    20,    58,    21,    -1,    87,    -1,    58,    22,    87,
-      -1,    -1,     7,    60,    62,    -1,    -1,    14,    61,    62,
-      -1,    91,    -1,    -1,    63,    20,    64,    21,    -1,    54,
-      -1,    64,    22,    54,    -1,     5,    67,    -1,    -1,    12,
-      66,    67,    -1,    68,    -1,    70,    -1,    -1,    69,    91,
-      -1,    -1,    71,    72,    -1,    -1,    73,    20,    74,    21,
-      -1,    56,    -1,    74,    22,    56,    -1,    -1,     8,    76,
-      78,    -1,    -1,    15,    77,    78,    -1,    91,    -1,    -1,
-      79,    20,    80,    21,    -1,    70,    -1,    80,    22,    70,
-      -1,    -1,     9,    82,    84,    -1,    -1,    16,    83,    84,
-      -1,    91,    -1,    -1,    85,    20,    86,    21,    -1,    91,
-      -1,    30,    -1,    86,    22,    30,    -1,    88,    -1,    89,
-      -1,    90,    -1,    19,    19,    -1,    19,    19,    19,    -1,
-      19,    19,    19,    19,    -1,    18,    -1
+      37,     0,    -1,    -1,    41,    34,    38,    40,    -1,    -1,
+      39,    40,    -1,    42,    -1,    43,    -1,    59,    -1,    71,
+      -1,   104,    -1,    86,    -1,   114,    -1,    51,    -1,    92,
+      -1,    98,    -1,   120,    -1,   126,    -1,   132,    -1,    27,
+      33,    29,    -1,    35,    -1,     3,    45,    -1,    -1,    15,
+      44,    45,    -1,    46,    -1,    48,    -1,    -1,    47,   142,
+      -1,    -1,    49,    50,    -1,    30,   138,    31,    -1,    -1,
+       6,    52,    54,    -1,    -1,    18,    53,    54,    -1,   142,
+      -1,    -1,    55,    30,    56,    31,    -1,    57,    -1,    56,
+      32,    57,    -1,    48,    -1,    -1,    58,   138,    -1,     4,
+      61,    -1,    -1,    16,    60,    61,    -1,    62,    -1,    64,
+      -1,    -1,    63,   142,    -1,    -1,    65,    68,    -1,    -1,
+      67,    68,    -1,    -1,    69,    30,    70,    31,    -1,   138,
+      -1,    70,    32,   138,    -1,    10,    75,    -1,    -1,    22,
+      72,    75,    -1,    10,    76,    -1,    -1,    22,    74,    76,
+      -1,    77,    -1,    79,    -1,    77,    -1,    81,    -1,    -1,
+      78,   142,    -1,    -1,    80,    83,    -1,    -1,    82,    83,
+      -1,    -1,    84,    30,    85,    31,    -1,   138,    -1,    85,
+      32,   138,    -1,    -1,    11,    87,    89,    -1,    -1,    23,
+      88,    89,    -1,   142,    -1,    -1,    90,    30,    91,    31,
+      -1,    64,    -1,    71,    -1,    91,    32,    64,    -1,    91,
+      32,    71,    -1,    -1,     7,    93,    95,    -1,    -1,    19,
+      94,    95,    -1,   142,    -1,    -1,    96,    30,    97,    31,
+      -1,    64,    -1,    97,    32,    64,    -1,    -1,    13,    99,
+     101,    -1,    -1,    25,   100,   101,    -1,   142,    -1,    -1,
+     102,    30,   103,    31,    -1,    64,    -1,    71,    -1,   103,
+      32,    64,    -1,   103,    32,    71,    -1,     5,   106,    -1,
+      -1,    17,   105,   106,    -1,   107,    -1,   109,    -1,    -1,
+     108,   142,    -1,    -1,   110,   111,    -1,    -1,   112,    30,
+     113,    31,    -1,    68,    -1,   113,    32,    68,    -1,    -1,
+      12,   115,   117,    -1,    -1,    24,   116,   117,    -1,   142,
+      -1,    -1,   118,    30,   119,    31,    -1,    66,    -1,    73,
+      -1,   119,    32,    66,    -1,   119,    32,    73,    -1,    -1,
+       8,   121,   123,    -1,    -1,    20,   122,   123,    -1,   142,
+      -1,    -1,   124,    30,   125,    31,    -1,   109,    -1,   125,
+      32,   109,    -1,    -1,    14,   127,   129,    -1,    -1,    26,
+     128,   129,    -1,   142,    -1,    -1,   130,    30,   131,    31,
+      -1,   109,    -1,   114,    -1,   131,    32,   109,    -1,   131,
+      32,   114,    -1,    -1,     9,   133,   135,    -1,    -1,    21,
+     134,   135,    -1,   142,    -1,    -1,   136,    30,   137,    31,
+      -1,   142,    -1,    40,    -1,   137,    32,    40,    -1,   139,
+      -1,   140,    -1,   141,    -1,    29,    29,    -1,    29,    29,
+      29,    -1,    29,    29,    29,    29,    -1,    28,    -1
 };
 
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
-static const unsigned char yyrline[] =
+static const unsigned short yyrline[] =
 {
        0,    36,    36,    36,    38,    38,    41,    43,    45,    47,
-      49,    51,    53,    55,    58,    61,    67,    69,    69,    72,
-      74,    77,    77,    80,    80,    84,    89,    89,    91,    91,
-      94,    96,    96,    99,   101,   104,   107,   107,   113,   115,
-     115,   118,   120,   123,   123,   126,   126,   129,   129,   132,
-     134,   139,   139,   142,   142,   146,   148,   148,   151,   153,
-     159,   161,   161,   164,   166,   169,   169,   172,   172,   175,
-     175,   178,   180,   185,   185,   187,   187,   191,   193,   193,
-     196,   198,   204,   204,   207,   207,   211,   213,   213,   217,
-     219,   221,   225,   227,   229,   232,   235,   238,   241
+      49,    51,    53,    55,    57,    59,    61,    63,    65,    68,
+      71,    77,    79,    79,    82,    84,    87,    87,    90,    90,
+      93,    98,    98,   100,   100,   103,   105,   105,   108,   110,
+     113,   116,   116,   122,   124,   124,   127,   129,   132,   132,
+     135,   135,   138,   138,   141,   141,   144,   146,   151,   153,
+     153,   156,   158,   158,   161,   163,   166,   168,   171,   171,
+     174,   174,   177,   177,   180,   180,   183,   185,   190,   190,
+     192,   192,   195,   197,   197,   200,   202,   204,   206,   211,
+     211,   214,   214,   218,   220,   220,   223,   225,   230,   230,
+     233,   233,   237,   239,   239,   242,   244,   246,   248,   253,
+     255,   255,   258,   260,   263,   263,   266,   266,   269,   269,
+     272,   274,   279,   279,   281,   281,   285,   287,   287,   290,
+     292,   294,   296,   301,   301,   303,   303,   307,   309,   309,
+     312,   314,   319,   319,   321,   321,   325,   327,   327,   330,
+     332,   334,   336,   341,   341,   344,   344,   348,   350,   350,
+     354,   356,   358,   362,   364,   366,   369,   372,   375,   378
 };
 #endif
 
@@ -376,23 +436,37 @@
    First, the terminals, then, starting at YYNTOKENS, nonterminals. */
 static const char *const yytname[] =
 {
-  "$end", "error", "$undefined", "POINT", "LINESTRING", "POLYGON", 
-  "MULTIPOINT", "MULTILINESTRING", "MULTIPOLYGON", "GEOMETRYCOLLECTION", 
-  "POINTM", "LINESTRINGM", "POLYGONM", "MULTIPOINTM", "MULTILINESTRINGM", 
-  "MULTIPOLYGONM", "GEOMETRYCOLLECTIONM", "SRID", "EMPTY", "VALUE", 
-  "LPAREN", "RPAREN", "COMMA", "EQUALS", "SEMICOLON", "WKB", "$accept", 
-  "geometry", "@1", "@2", "geometry_int", "srid", "geom_wkb", 
-  "geom_point", "@3", "point", "empty_point", "@4", "nonempty_point", 
-  "@5", "point_int", "geom_multipoint", "@6", "@7", "multipoint", "@8", 
-  "multipoint_int", "mpoint_element", "@9", "geom_linestring", "@10", 
-  "linestring", "empty_linestring", "@11", "nonempty_linestring", "@12", 
-  "linestring_1", "@13", "linestring_int", "geom_multilinestring", "@14", 
-  "@15", "multilinestring", "@16", "multilinestring_int", "geom_polygon", 
-  "@17", "polygon", "empty_polygon", "@18", "nonempty_polygon", "@19", 
-  "polygon_1", "@20", "polygon_int", "geom_multipolygon", "@21", "@22", 
-  "multipolygon", "@23", "multipolygon_int", "geom_geometrycollection", 
-  "@24", "@25", "geometrycollection", "@26", "geometrycollection_int", 
-  "a_point", "point_2d", "point_3d", "point_4d", "empty", 0
+  "$end", "error", "$undefined", "POINT", "LINESTRING", "POLYGON",
+  "MULTIPOINT", "MULTILINESTRING", "MULTIPOLYGON", "GEOMETRYCOLLECTION",
+  "CIRCULARSTRING", "COMPOUNDCURVE", "CURVEPOLYGON", "MULTICURVE",
+  "MULTISURFACE", "POINTM", "LINESTRINGM", "POLYGONM", "MULTIPOINTM",
+  "MULTILINESTRINGM", "MULTIPOLYGONM", "GEOMETRYCOLLECTIONM",
+  "CIRCULARSTRINGM", "COMPOUNDCURVEM", "CURVEPOLYGONM", "MULTICURVEM",
+  "MULTISURFACEM", "SRID", "EMPTY", "VALUE", "LPAREN", "RPAREN", "COMMA",
+  "EQUALS", "SEMICOLON", "WKB", "$accept", "geometry", "@1", "@2",
+  "geometry_int", "srid", "geom_wkb", "geom_point", "@3", "point",
+  "empty_point", "@4", "nonempty_point", "@5", "point_int",
+  "geom_multipoint", "@6", "@7", "multipoint", "@8", "multipoint_int",
+  "mpoint_element", "@9", "geom_linestring", "@10", "linestring",
+  "empty_linestring", "@11", "nonempty_linestring", "@12",
+  "nonempty_linestring_closed", "@13", "linestring_1", "@14",
+  "linestring_int", "geom_circularstring", "@15",
+  "geom_circularstring_closed", "@16", "circularstring",
+  "circularstring_closed", "empty_circularstring", "@17",
+  "nonempty_circularstring", "@18", "nonempty_circularstring_closed",
+  "@19", "circularstring_1", "@20", "circularstring_int",
+  "geom_compoundcurve", "@21", "@22", "compoundcurve", "@23",
+  "compoundcurve_int", "geom_multilinestring", "@24", "@25",
+  "multilinestring", "@26", "multilinestring_int", "geom_multicurve",
+  "@27", "@28", "multicurve", "@29", "multicurve_int", "geom_polygon",
+  "@30", "polygon", "empty_polygon", "@31", "nonempty_polygon", "@32",
+  "polygon_1", "@33", "polygon_int", "geom_curvepolygon", "@34", "@35",
+  "curvepolygon", "@36", "curvepolygon_int", "geom_multipolygon", "@37",
+  "@38", "multipolygon", "@39", "multipolygon_int", "geom_multisurface",
+  "@40", "@41", "multisurface", "@42", "multisurface_int",
+  "geom_geometrycollection", "@43", "@44", "geometrycollection", "@45",
+  "geometrycollection_int", "a_point", "point_2d", "point_3d", "point_4d",
+  "empty", 0
 };
 #endif
 
@@ -403,38 +477,53 @@
 {
        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
-     275,   276,   277,   278,   279,   280
+     275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
+     285,   286,   287,   288,   289,   290
 };
 # endif
 
 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const unsigned char yyr1[] =
 {
-       0,    26,    28,    27,    29,    27,    30,    30,    30,    30,
-      30,    30,    30,    30,    31,    32,    33,    34,    33,    35,
-      35,    37,    36,    39,    38,    40,    42,    41,    43,    41,
-      44,    45,    44,    46,    46,    47,    48,    47,    49,    50,
-      49,    51,    51,    53,    52,    55,    54,    57,    56,    58,
-      58,    60,    59,    61,    59,    62,    63,    62,    64,    64,
-      65,    66,    65,    67,    67,    69,    68,    71,    70,    73,
-      72,    74,    74,    76,    75,    77,    75,    78,    79,    78,
-      80,    80,    82,    81,    83,    81,    84,    85,    84,    86,
-      86,    86,    87,    87,    87,    88,    89,    90,    91
+       0,    36,    38,    37,    39,    37,    40,    40,    40,    40,
+      40,    40,    40,    40,    40,    40,    40,    40,    40,    41,
+      42,    43,    44,    43,    45,    45,    47,    46,    49,    48,
+      50,    52,    51,    53,    51,    54,    55,    54,    56,    56,
+      57,    58,    57,    59,    60,    59,    61,    61,    63,    62,
+      65,    64,    67,    66,    69,    68,    70,    70,    71,    72,
+      71,    73,    74,    73,    75,    75,    76,    76,    78,    77,
+      80,    79,    82,    81,    84,    83,    85,    85,    87,    86,
+      88,    86,    89,    90,    89,    91,    91,    91,    91,    93,
+      92,    94,    92,    95,    96,    95,    97,    97,    99,    98,
+     100,    98,   101,   102,   101,   103,   103,   103,   103,   104,
+     105,   104,   106,   106,   108,   107,   110,   109,   112,   111,
+     113,   113,   115,   114,   116,   114,   117,   118,   117,   119,
+     119,   119,   119,   121,   120,   122,   120,   123,   124,   123,
+     125,   125,   127,   126,   128,   126,   129,   130,   129,   131,
+     131,   131,   131,   133,   132,   134,   132,   135,   136,   135,
+     137,   137,   137,   138,   138,   138,   139,   140,   141,   142
 };
 
 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 static const unsigned char yyr2[] =
 {
        0,     2,     0,     4,     0,     2,     1,     1,     1,     1,
-       1,     1,     1,     1,     3,     1,     2,     0,     3,     1,
-       1,     0,     2,     0,     2,     3,     0,     3,     0,     3,
-       1,     0,     4,     1,     3,     1,     0,     2,     2,     0,
-       3,     1,     1,     0,     2,     0,     2,     0,     4,     1,
+       1,     1,     1,     1,     1,     1,     1,     1,     1,     3,
+       1,     2,     0,     3,     1,     1,     0,     2,     0,     2,
        3,     0,     3,     0,     3,     1,     0,     4,     1,     3,
-       2,     0,     3,     1,     1,     0,     2,     0,     2,     0,
-       4,     1,     3,     0,     3,     0,     3,     1,     0,     4,
+       1,     0,     2,     2,     0,     3,     1,     1,     0,     2,
+       0,     2,     0,     2,     0,     4,     1,     3,     2,     0,
+       3,     2,     0,     3,     1,     1,     1,     1,     0,     2,
+       0,     2,     0,     2,     0,     4,     1,     3,     0,     3,
+       0,     3,     1,     0,     4,     1,     1,     3,     3,     0,
+       3,     0,     3,     1,     0,     4,     1,     3,     0,     3,
+       0,     3,     1,     0,     4,     1,     1,     3,     3,     2,
+       0,     3,     1,     1,     0,     2,     0,     2,     0,     4,
        1,     3,     0,     3,     0,     3,     1,     0,     4,     1,
-       1,     3,     1,     1,     1,     2,     3,     4,     1
+       1,     3,     3,     0,     3,     0,     3,     1,     0,     4,
+       1,     3,     0,     3,     0,     3,     1,     0,     4,     1,
+       1,     3,     3,     0,     3,     0,     3,     1,     0,     4,
+       1,     1,     3,     1,     1,     1,     2,     3,     4,     1
 };
 
 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
@@ -442,120 +531,174 @@
    means the default is an error.  */
 static const unsigned char yydefact[] =
 {
-       4,     0,     0,     0,     0,     0,     1,    21,    43,    65,
-      26,    51,    73,    82,    17,    39,    61,    28,    53,    75,
-      84,    15,     5,     6,     7,    10,     8,    11,     9,    12,
-      13,     2,    14,    16,    19,     0,    20,     0,    38,    41,
-       0,    42,    47,    60,    63,     0,    64,    69,    31,    56,
-      78,    87,    21,    43,    65,    31,    56,    78,    87,     0,
-      98,    22,     0,    24,    44,    46,     0,    66,    68,     0,
-      27,     0,    30,    52,     0,    55,    74,     0,    77,    83,
-       0,    86,    18,    40,    62,    29,    54,    76,    85,     3,
-       0,     0,    92,    93,    94,     0,    47,    23,    45,    67,
-       0,    95,    25,     0,    49,    71,     0,    35,     0,    33,
-       0,    58,     0,    80,     0,    90,     0,    89,    96,    48,
-       0,    70,    47,    32,    23,    37,    57,    45,    79,    67,
-      88,     0,    97,    50,    72,    34,    59,    81,    91
+       4,     0,     0,     0,     0,     0,     1,    26,    48,   114,
+      31,    89,   133,   153,    68,    78,   122,    98,   142,    22,
+      44,   110,    33,    91,   135,   155,    59,    80,   124,   100,
+     144,    20,     5,     6,     7,    13,     8,     9,    11,    14,
+      15,    10,    12,    16,    17,    18,     2,    19,    21,    24,
+       0,    25,     0,    43,    46,     0,    47,    54,   109,   112,
+       0,   113,   118,    36,    94,   138,   158,    58,    64,     0,
+      65,    74,    83,   127,   103,   147,    26,    48,   114,    36,
+      94,   138,   158,    68,    83,   127,   103,   147,     0,   169,
+      27,     0,    29,    49,    51,     0,   115,   117,     0,    32,
+       0,    35,    90,     0,    93,   134,     0,   137,   154,     0,
+     157,    69,    71,     0,    79,     0,    82,   123,     0,   126,
+      99,     0,   102,   143,     0,   146,    23,    45,   111,    34,
+      92,   136,   156,    60,    81,   125,   101,   145,     3,     0,
+       0,   163,   164,   165,     0,    54,    28,    50,   116,     0,
+       0,    50,    52,    50,   116,   166,    30,     0,    56,   120,
+       0,    40,     0,    38,     0,    96,     0,   140,     0,   161,
+       0,   160,     0,    76,    85,    86,     0,    68,    62,   129,
+      54,   130,     0,   105,   106,     0,   149,   150,     0,   167,
+      55,     0,   119,    54,    37,    28,    42,    95,    50,   139,
+     116,   159,     0,    75,     0,    84,    50,    61,    66,    67,
+      74,    68,    53,   128,    52,   104,    50,   148,   116,   168,
+      57,   121,    39,    97,   141,   162,    77,    87,    88,    73,
+      63,   131,   132,   107,   108,   151,   152
 };
 
 /* YYDEFGOTO[NTERM-NUM]. */
-static const yysigned_char yydefgoto[] =
+static const short yydefgoto[] =
 {
-      -1,     2,    59,     3,    22,     4,    23,    24,    52,    33,
-      34,    35,    36,    37,    63,    25,    48,    55,    70,    71,
-     108,   109,   110,    26,    53,    38,    39,    40,    41,    42,
-      65,    66,   103,    27,    49,    56,    73,    74,   112,    28,
-      54,    43,    44,    45,    46,    47,    68,    69,   106,    29,
-      50,    57,    76,    77,   114,    30,    51,    58,    79,    80,
-     116,    91,    92,    93,    94,    72
+      -1,     2,    88,     3,    32,     4,    33,    34,    76,    48,
+      49,    50,    51,    52,    92,    35,    63,    79,    99,   100,
+     162,   163,   164,    36,    77,    53,    54,    55,    56,    57,
+     179,   180,    94,    95,   157,    37,    83,   181,   211,    67,
+     207,    68,    69,    70,    71,   209,   210,   112,   113,   172,
+      38,    72,    84,   114,   115,   176,    39,    64,    80,   102,
+     103,   166,    40,    74,    86,   120,   121,   185,    41,    78,
+      58,    59,    60,    61,    62,    97,    98,   160,    42,    73,
+      85,   117,   118,   182,    43,    65,    81,   105,   106,   168,
+      44,    75,    87,   123,   124,   188,    45,    66,    82,   108,
+     109,   170,   140,   141,   142,   143,   101
 };
 
 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
    STATE-NUM.  */
-#define YYPACT_NINF -98
-static const yysigned_char yypact[] =
+#define YYPACT_NINF -166
+static const short yypact[] =
 {
-     -12,    13,    14,    70,     4,    18,   -98,    19,    20,    36,
-     -98,   -98,   -98,   -98,   -98,   -98,   -98,   -98,   -98,   -98,
-     -98,   -98,   -98,   -98,   -98,   -98,   -98,   -98,   -98,   -98,
-     -98,   -98,   -98,   -98,   -98,    40,   -98,    41,   -98,   -98,
-      40,   -98,   -98,   -98,   -98,    40,   -98,   -98,    40,    40,
-      40,    40,    19,    20,    36,    40,    40,    40,    40,    70,
-     -98,   -98,    43,   -98,   -98,   -98,    45,   -98,   -98,    47,
-     -98,    48,   -98,   -98,    49,   -98,   -98,    50,   -98,   -98,
-      51,   -98,   -98,   -98,   -98,   -98,   -98,   -98,   -98,   -98,
-      44,    17,   -98,   -98,   -98,    43,   -98,    68,   -98,   -98,
-      39,    69,   -98,   -13,   -98,   -98,    -9,   -98,    -3,   -98,
-      43,   -98,    -1,   -98,     5,   -98,     9,   -98,    71,   -98,
-      43,   -98,   -98,   -98,    68,   -98,   -98,   -98,   -98,   -98,
-     -98,    70,   -98,   -98,   -98,   -98,   -98,   -98,   -98
+     -17,   -14,    21,   145,    -7,     5,  -166,    29,    30,    40,
+    -166,  -166,  -166,  -166,    51,  -166,  -166,  -166,  -166,  -166,
+    -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,
+    -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,
+    -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,
+      23,  -166,    53,  -166,  -166,    23,  -166,  -166,  -166,  -166,
+      23,  -166,  -166,    23,    23,    23,    23,  -166,  -166,    23,
+    -166,  -166,    23,    23,    23,    23,    29,    30,    40,    23,
+      23,    23,    23,    51,    23,    23,    23,    23,   145,  -166,
+    -166,    55,  -166,  -166,  -166,    56,  -166,  -166,    57,  -166,
+      58,  -166,  -166,    59,  -166,  -166,    61,  -166,  -166,    62,
+    -166,  -166,  -166,    63,  -166,    64,  -166,  -166,    65,  -166,
+    -166,    66,  -166,  -166,    67,  -166,  -166,  -166,  -166,  -166,
+    -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,    70,
+      54,  -166,  -166,  -166,    55,  -166,    72,  -166,  -166,   112,
+      55,     8,    19,     8,    28,    73,  -166,   -18,  -166,  -166,
+      16,  -166,    18,  -166,    55,  -166,    24,  -166,    31,  -166,
+      33,  -166,    35,  -166,  -166,  -166,    42,    74,  -166,  -166,
+    -166,  -166,    44,  -166,  -166,    46,  -166,  -166,    48,    76,
+    -166,    55,  -166,  -166,  -166,    72,  -166,  -166,  -166,  -166,
+    -166,  -166,   145,  -166,    55,  -166,     8,  -166,  -166,  -166,
+    -166,    74,  -166,  -166,    19,  -166,     8,  -166,    28,  -166,
+    -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,  -166,
+    -166,  -166,  -166,  -166,  -166,  -166,  -166
 };
 
 /* YYPGOTO[NTERM-NUM].  */
-static const yysigned_char yypgoto[] =
+static const short yypgoto[] =
 {
-     -98,   -98,   -98,   -98,   -59,   -98,   -98,   -98,   -98,     7,
-     -98,   -98,   -90,   -98,   -98,   -98,   -98,   -98,    34,   -98,
-     -98,   -64,   -98,   -98,   -98,    38,   -98,   -98,   -94,   -98,
-     -93,   -98,   -98,   -98,   -98,   -98,    37,   -98,   -98,   -98,
-     -98,    42,   -98,   -98,   -97,   -98,   -98,   -98,   -98,   -98,
-     -98,   -98,    35,   -98,   -98,   -98,   -98,   -98,    46,   -98,
-     -98,   -85,   -98,   -98,   -98,   -34
+    -166,  -166,  -166,  -166,   -88,  -166,  -166,  -166,  -166,    27,
+    -166,  -166,  -142,  -166,  -166,  -166,  -166,  -166,    32,  -166,
+    -166,   -89,  -166,  -166,  -166,    36,  -166,  -166,  -108,  -166,
+    -107,  -166,  -136,  -166,  -166,  -148,  -166,  -105,  -166,    60,
+    -101,  -165,  -166,  -166,  -166,  -166,  -166,   -98,  -166,  -166,
+    -166,  -166,  -166,    88,  -166,  -166,  -166,  -166,  -166,    93,
+    -166,  -166,  -166,  -166,  -166,    89,  -166,  -166,  -166,  -166,
+      68,  -166,  -166,  -146,  -166,  -166,  -166,  -166,  -147,  -166,
+    -166,    91,  -166,  -166,  -166,  -166,  -166,    96,  -166,  -166,
+    -166,  -166,  -166,    52,  -166,  -166,  -166,  -166,  -166,    92,
+    -166,  -166,  -122,  -166,  -166,  -166,   -49
 };
 
 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    positive, shift that token.  If negative, reduce the rule which
    number is the opposite.  If zero, do what YYDEFACT says.
    If YYTABLE_NINF, syntax error.  */
-#define YYTABLE_NINF -68
+#define YYTABLE_NINF -117
 static const short yytable[] =
 {
-      89,    61,   113,   105,   111,     1,    64,   107,   119,   120,
-     104,    67,   121,   122,     6,    75,    78,    81,   123,   124,
-     126,   127,    75,    78,    81,   125,   128,   129,    31,   134,
-     130,   131,   137,   136,   107,   133,     5,    32,   102,   -23,
-     -45,   115,     7,     8,     9,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    20,   -67,    60,    60,    82,
-     135,    62,    90,   101,    21,    95,   117,    96,    97,    98,
-      99,   100,   138,     7,     8,     9,    10,    11,    12,    13,
-      14,    15,    16,    17,    18,    19,    20,   -36,   118,    85,
-     132,    83,    87,    86,     0,    21,    84,     0,     0,     0,
-       0,     0,     0,     0,    88
+     138,    90,   167,   175,   161,   184,    93,   187,   186,   159,
+       1,    96,   208,   190,   191,   104,   107,   110,    14,     5,
+     111,     6,   158,   116,   119,   122,   125,    46,   173,   177,
+      26,   104,   107,   110,    47,   116,   119,   122,   125,   165,
+      16,   178,   196,   174,   212,   183,   208,   192,   193,   194,
+     195,    89,    28,   161,   224,   197,   198,   221,   228,   -28,
+     -50,   169,   199,   200,   201,   202,   203,   204,   234,   220,
+    -116,   236,   235,   205,   206,   213,   214,   215,   216,   217,
+     218,   -70,   226,    91,   139,   156,   144,   145,   146,   147,
+     223,   148,   149,   150,   151,   152,   153,   154,   227,   155,
+     171,   -41,   189,   126,   -72,   219,   222,   231,   233,   232,
+     230,   129,   229,   127,   225,     7,     8,     9,    10,    11,
+      12,    13,    14,    15,    16,    17,    18,    19,    20,    21,
+      22,    23,    24,    25,    26,    27,    28,    29,    30,   137,
+      89,     0,     0,   133,     0,     0,   128,    31,     7,     8,
+       9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
+      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
+      29,    30,   134,   130,   132,   136,   135,   131,     0,     0,
+      31
 };
 
 static const short yycheck[] =
 {
-      59,    35,    99,    96,    98,    17,    40,    97,    21,    22,
-      95,    45,    21,    22,     0,    49,    50,    51,    21,    22,
-      21,    22,    56,    57,    58,   110,    21,    22,    24,   122,
-      21,    22,   129,   127,   124,   120,    23,    19,    21,    20,
-      20,   100,     3,     4,     5,     6,     7,     8,     9,    10,
-      11,    12,    13,    14,    15,    16,    20,    18,    18,    52,
-     124,    20,    19,    19,    25,    20,   100,    20,    20,    20,
-      20,    20,   131,     3,     4,     5,     6,     7,     8,     9,
-      10,    11,    12,    13,    14,    15,    16,    19,    19,    55,
-      19,    53,    57,    56,    -1,    25,    54,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    58
+      88,    50,   148,   151,   146,   153,    55,   154,   154,   145,
+      27,    60,   177,    31,    32,    64,    65,    66,    10,    33,
+      69,     0,   144,    72,    73,    74,    75,    34,   150,    10,
+      22,    80,    81,    82,    29,    84,    85,    86,    87,   147,
+      12,    22,   164,   151,   180,   153,   211,    31,    32,    31,
+      32,    28,    24,   195,   200,    31,    32,   193,   206,    30,
+      30,   149,    31,    32,    31,    32,    31,    32,   216,   191,
+      30,   218,   218,    31,    32,    31,    32,    31,    32,    31,
+      32,    30,   204,    30,    29,    31,    30,    30,    30,    30,
+     198,    30,    30,    30,    30,    30,    30,    30,   206,    29,
+     149,    29,    29,    76,    30,    29,   195,   214,   216,   214,
+     211,    79,   210,    77,   202,     3,     4,     5,     6,     7,
+       8,     9,    10,    11,    12,    13,    14,    15,    16,    17,
+      18,    19,    20,    21,    22,    23,    24,    25,    26,    87,
+      28,    -1,    -1,    83,    -1,    -1,    78,    35,     3,     4,
+       5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
+      15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
+      25,    26,    84,    80,    82,    86,    85,    81,    -1,    -1,
+      35
 };
 
 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
    symbol of state STATE-NUM.  */
 static const unsigned char yystos[] =
 {
-       0,    17,    27,    29,    31,    23,     0,     3,     4,     5,
+       0,    27,    37,    39,    41,    33,     0,     3,     4,     5,
        6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
-      16,    25,    30,    32,    33,    41,    49,    59,    65,    75,
-      81,    24,    19,    35,    36,    37,    38,    39,    51,    52,
-      53,    54,    55,    67,    68,    69,    70,    71,    42,    60,
-      76,    82,    34,    50,    66,    43,    61,    77,    83,    28,
-      18,    91,    20,    40,    91,    56,    57,    91,    72,    73,
-      44,    45,    91,    62,    63,    91,    78,    79,    91,    84,
-      85,    91,    35,    51,    67,    44,    62,    78,    84,    30,
-      19,    87,    88,    89,    90,    20,    20,    20,    20,    20,
-      20,    19,    21,    58,    87,    56,    74,    38,    46,    47,
-      48,    54,    64,    70,    80,    30,    86,    91,    19,    21,
-      22,    21,    22,    21,    22,    87,    21,    22,    21,    22,
-      21,    22,    19,    87,    56,    47,    54,    70,    30
+      16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
+      26,    35,    40,    42,    43,    51,    59,    71,    86,    92,
+      98,   104,   114,   120,   126,   132,    34,    29,    45,    46,
+      47,    48,    49,    61,    62,    63,    64,    65,   106,   107,
+     108,   109,   110,    52,    93,   121,   133,    75,    77,    78,
+      79,    80,    87,   115,    99,   127,    44,    60,   105,    53,
+      94,   122,   134,    72,    88,   116,   100,   128,    38,    28,
+     142,    30,    50,   142,    68,    69,   142,   111,   112,    54,
+      55,   142,    95,    96,   142,   123,   124,   142,   135,   136,
+     142,   142,    83,    84,    89,    90,   142,   117,   118,   142,
+     101,   102,   142,   129,   130,   142,    45,    61,   106,    54,
+      95,   123,   135,    75,    89,   117,   101,   129,    40,    29,
+     138,   139,   140,   141,    30,    30,    30,    30,    30,    30,
+      30,    30,    30,    30,    30,    29,    31,    70,   138,    68,
+     113,    48,    56,    57,    58,    64,    97,   109,   125,    40,
+     137,   142,    85,   138,    64,    71,    91,    10,    22,    66,
+      67,    73,   119,    64,    71,   103,   109,   114,   131,    29,
+      31,    32,    31,    32,    31,    32,   138,    31,    32,    31,
+      32,    31,    32,    31,    32,    31,    32,    76,    77,    81,
+      82,    74,    68,    31,    32,    31,    32,    31,    32,    29,
+     138,    68,    57,    64,   109,    40,   138,    64,    71,    83,
+      76,    66,    73,    64,    71,   109,   114
 };
 
 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
@@ -581,8 +724,9 @@
 
 #define YYACCEPT	goto yyacceptlab
 #define YYABORT		goto yyabortlab
-#define YYERROR		goto yyerrlab1
+#define YYERROR		goto yyerrorlab
 
+
 /* Like YYERROR except do call yyerror.  This remains here temporarily
    to ease the transition to the new meaning of YYERROR, for GCC.
    Once GCC version 2 has supplanted version 1, this can go.  */
@@ -615,11 +759,11 @@
    are run).  */
 
 #ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N)         \
-  Current.first_line   = Rhs[1].first_line;      \
-  Current.first_column = Rhs[1].first_column;    \
-  Current.last_line    = Rhs[N].last_line;       \
-  Current.last_column  = Rhs[N].last_column;
+# define YYLLOC_DEFAULT(Current, Rhs, N)		\
+   ((Current).first_line   = (Rhs)[1].first_line,	\
+    (Current).first_column = (Rhs)[1].first_column,	\
+    (Current).last_line    = (Rhs)[N].last_line,	\
+    (Current).last_column  = (Rhs)[N].last_column)
 #endif
 
 /* YYLEX -- calling `yylex' with the right arguments.  */
@@ -663,7 +807,7 @@
 
 /*------------------------------------------------------------------.
 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
-| TOP (cinluded).                                                   |
+| TOP (included).                                                   |
 `------------------------------------------------------------------*/
 
 #if defined (__STDC__) || defined (__cplusplus)
@@ -703,9 +847,9 @@
 #endif
 {
   int yyi;
-  unsigned int yylineno = yyrline[yyrule];
+  unsigned int yylno = yyrline[yyrule];
   YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
-             yyrule - 1, yylineno);
+             yyrule - 1, yylno);
   /* Print the symbols being reduced, and their result.  */
   for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
     YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
@@ -742,7 +886,7 @@
    SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
    evaluated with infinite-precision integer arithmetic.  */
 
-#if YYMAXDEPTH == 0
+#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
 # undef YYMAXDEPTH
 #endif
 
@@ -1174,266 +1318,446 @@
     { alloc_lwgeom(-1); }
     break;
 
-  case 14:
-#line 58 "wktparse.y"
+  case 19:
+#line 68 "wktparse.y"
     { set_srid(yyvsp[0].value); }
     break;
 
-  case 15:
-#line 61 "wktparse.y"
+  case 20:
+#line 71 "wktparse.y"
     { alloc_wkb(yyvsp[0].wkb); }
     break;
 
-  case 17:
-#line 69 "wktparse.y"
+  case 22:
+#line 79 "wktparse.y"
     { set_zm(0, 1); }
     break;
 
-  case 21:
-#line 77 "wktparse.y"
+  case 26:
+#line 87 "wktparse.y"
     { alloc_point(); }
     break;
 
-  case 22:
-#line 77 "wktparse.y"
+  case 27:
+#line 87 "wktparse.y"
     { pop(); }
     break;
 
-  case 23:
-#line 80 "wktparse.y"
+  case 28:
+#line 90 "wktparse.y"
     { alloc_point(); }
     break;
 
-  case 24:
-#line 80 "wktparse.y"
+  case 29:
+#line 90 "wktparse.y"
     { pop(); }
     break;
 
-  case 26:
-#line 89 "wktparse.y"
+  case 31:
+#line 98 "wktparse.y"
     { alloc_multipoint(); }
     break;
 
-  case 27:
-#line 89 "wktparse.y"
+  case 32:
+#line 98 "wktparse.y"
     { pop(); }
     break;
 
-  case 28:
-#line 91 "wktparse.y"
+  case 33:
+#line 100 "wktparse.y"
     { set_zm(0, 1); alloc_multipoint(); }
     break;
 
-  case 29:
-#line 91 "wktparse.y"
+  case 34:
+#line 100 "wktparse.y"
     {pop(); }
     break;
 
-  case 31:
-#line 96 "wktparse.y"
+  case 36:
+#line 105 "wktparse.y"
     { alloc_counter(); }
     break;
 
-  case 32:
-#line 96 "wktparse.y"
+  case 37:
+#line 105 "wktparse.y"
     { pop(); }
     break;
 
-  case 36:
-#line 107 "wktparse.y"
+  case 41:
+#line 116 "wktparse.y"
     { alloc_point(); }
     break;
 
-  case 37:
-#line 107 "wktparse.y"
+  case 42:
+#line 116 "wktparse.y"
     { pop(); }
     break;
 
-  case 39:
-#line 115 "wktparse.y"
+  case 44:
+#line 124 "wktparse.y"
     { set_zm(0, 1); }
     break;
 
-  case 43:
-#line 123 "wktparse.y"
+  case 48:
+#line 132 "wktparse.y"
     { alloc_linestring(); }
     break;
 
-  case 44:
-#line 123 "wktparse.y"
+  case 49:
+#line 132 "wktparse.y"
     { pop(); }
     break;
 
-  case 45:
-#line 126 "wktparse.y"
+  case 50:
+#line 135 "wktparse.y"
     { alloc_linestring(); }
     break;
 
-  case 46:
-#line 126 "wktparse.y"
+  case 51:
+#line 135 "wktparse.y"
     { pop(); }
     break;
 
-  case 47:
-#line 129 "wktparse.y"
+  case 52:
+#line 138 "wktparse.y"
+    { alloc_linestring_closed(); }
+    break;
+
+  case 53:
+#line 138 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 54:
+#line 141 "wktparse.y"
     { alloc_counter(); }
     break;
 
-  case 48:
-#line 129 "wktparse.y"
+  case 55:
+#line 141 "wktparse.y"
     { popc(); }
     break;
 
-  case 51:
-#line 139 "wktparse.y"
+  case 59:
+#line 153 "wktparse.y"
+    {set_zm(0, 1); }
+    break;
+
+  case 62:
+#line 158 "wktparse.y"
+    {set_zm(0, 1); }
+    break;
+
+  case 68:
+#line 171 "wktparse.y"
+    { alloc_circularstring(); }
+    break;
+
+  case 69:
+#line 171 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 70:
+#line 174 "wktparse.y"
+    { alloc_circularstring(); }
+    break;
+
+  case 71:
+#line 174 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 72:
+#line 177 "wktparse.y"
+    { alloc_circularstring_closed(); }
+    break;
+
+  case 73:
+#line 177 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 74:
+#line 180 "wktparse.y"
+    { alloc_counter(); }
+    break;
+
+  case 75:
+#line 180 "wktparse.y"
+    { popc(); }
+    break;
+
+  case 78:
+#line 190 "wktparse.y"
+    { alloc_compoundcurve(); }
+    break;
+
+  case 79:
+#line 190 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 80:
+#line 192 "wktparse.y"
+    {set_zm(0, 1); alloc_compoundcurve(); }
+    break;
+
+  case 81:
+#line 192 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 83:
+#line 197 "wktparse.y"
+    { alloc_counter(); }
+    break;
+
+  case 84:
+#line 197 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 89:
+#line 211 "wktparse.y"
     { alloc_multilinestring(); }
     break;
 
-  case 52:
-#line 140 "wktparse.y"
+  case 90:
+#line 212 "wktparse.y"
     { pop(); }
     break;
 
-  case 53:
-#line 142 "wktparse.y"
+  case 91:
+#line 214 "wktparse.y"
     { set_zm(0, 1); alloc_multilinestring(); }
     break;
 
-  case 54:
-#line 143 "wktparse.y"
+  case 92:
+#line 215 "wktparse.y"
     { pop(); }
     break;
 
-  case 56:
-#line 148 "wktparse.y"
+  case 94:
+#line 220 "wktparse.y"
     { alloc_counter(); }
     break;
 
-  case 57:
-#line 148 "wktparse.y"
+  case 95:
+#line 220 "wktparse.y"
     { pop();}
     break;
 
-  case 61:
-#line 161 "wktparse.y"
+  case 98:
+#line 230 "wktparse.y"
+    { alloc_multicurve(); }
+    break;
+
+  case 99:
+#line 231 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 100:
+#line 233 "wktparse.y"
+    { set_zm(0, 1); alloc_multicurve(); }
+    break;
+
+  case 101:
+#line 234 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 103:
+#line 239 "wktparse.y"
+    { alloc_counter(); }
+    break;
+
+  case 104:
+#line 239 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 110:
+#line 255 "wktparse.y"
     { set_zm(0, 1); }
     break;
 
-  case 65:
-#line 169 "wktparse.y"
+  case 114:
+#line 263 "wktparse.y"
     { alloc_polygon(); }
     break;
 
-  case 66:
-#line 169 "wktparse.y"
+  case 115:
+#line 263 "wktparse.y"
     { pop(); }
     break;
 
-  case 67:
-#line 172 "wktparse.y"
+  case 116:
+#line 266 "wktparse.y"
     { alloc_polygon(); }
     break;
 
-  case 68:
-#line 172 "wktparse.y"
+  case 117:
+#line 266 "wktparse.y"
     { pop(); }
     break;
 
-  case 69:
-#line 175 "wktparse.y"
+  case 118:
+#line 269 "wktparse.y"
     { alloc_counter(); }
     break;
 
-  case 70:
-#line 175 "wktparse.y"
+  case 119:
+#line 269 "wktparse.y"
     { pop();}
     break;
 
-  case 73:
-#line 185 "wktparse.y"
+  case 122:
+#line 279 "wktparse.y"
+    { alloc_curvepolygon(); }
+    break;
+
+  case 123:
+#line 279 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 124:
+#line 281 "wktparse.y"
+    { set_zm(0, 1); alloc_curvepolygon(); }
+    break;
+
+  case 125:
+#line 282 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 127:
+#line 287 "wktparse.y"
+    { alloc_counter(); }
+    break;
+
+  case 128:
+#line 287 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 133:
+#line 301 "wktparse.y"
     { alloc_multipolygon(); }
     break;
 
-  case 74:
-#line 185 "wktparse.y"
+  case 134:
+#line 301 "wktparse.y"
     { pop(); }
     break;
 
-  case 75:
-#line 187 "wktparse.y"
+  case 135:
+#line 303 "wktparse.y"
     { set_zm(0, 1); alloc_multipolygon(); }
     break;
 
-  case 76:
-#line 188 "wktparse.y"
+  case 136:
+#line 304 "wktparse.y"
     { pop();}
     break;
 
-  case 78:
-#line 193 "wktparse.y"
+  case 138:
+#line 309 "wktparse.y"
     { alloc_counter(); }
     break;
 
-  case 79:
-#line 193 "wktparse.y"
+  case 139:
+#line 309 "wktparse.y"
     { pop(); }
     break;
 
-  case 82:
-#line 204 "wktparse.y"
+  case 142:
+#line 319 "wktparse.y"
+    {alloc_multisurface(); }
+    break;
+
+  case 143:
+#line 319 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 144:
+#line 321 "wktparse.y"
+    { set_zm(0, 1); alloc_multisurface(); }
+    break;
+
+  case 145:
+#line 322 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 147:
+#line 327 "wktparse.y"
+    { alloc_counter(); }
+    break;
+
+  case 148:
+#line 327 "wktparse.y"
+    { pop(); }
+    break;
+
+  case 153:
+#line 341 "wktparse.y"
     { alloc_geomertycollection(); }
     break;
 
-  case 83:
-#line 205 "wktparse.y"
+  case 154:
+#line 342 "wktparse.y"
     { pop(); }
     break;
 
-  case 84:
-#line 207 "wktparse.y"
+  case 155:
+#line 344 "wktparse.y"
     { set_zm(0, 1); alloc_geomertycollection(); }
     break;
 
-  case 85:
-#line 208 "wktparse.y"
+  case 156:
+#line 345 "wktparse.y"
     { pop();}
     break;
 
-  case 87:
-#line 213 "wktparse.y"
+  case 158:
+#line 350 "wktparse.y"
     { alloc_counter(); }
     break;
 
-  case 88:
-#line 213 "wktparse.y"
+  case 159:
+#line 350 "wktparse.y"
     { pop(); }
     break;
 
-  case 95:
-#line 232 "wktparse.y"
+  case 166:
+#line 369 "wktparse.y"
     {alloc_point_2d(yyvsp[-1].value,yyvsp[0].value); }
     break;
 
-  case 96:
-#line 235 "wktparse.y"
+  case 167:
+#line 372 "wktparse.y"
     {alloc_point_3d(yyvsp[-2].value,yyvsp[-1].value,yyvsp[0].value); }
     break;
 
-  case 97:
-#line 238 "wktparse.y"
+  case 168:
+#line 375 "wktparse.y"
     {alloc_point_4d(yyvsp[-3].value,yyvsp[-2].value,yyvsp[-1].value,yyvsp[0].value); }
     break;
 
-  case 98:
-#line 241 "wktparse.y"
+  case 169:
+#line 378 "wktparse.y"
     { alloc_empty(); }
     break;
 
 
     }
 
-/* Line 991 of yacc.c.  */
-#line 1436 "y.tab.c"
+/* Line 1000 of yacc.c.  */
+#line 1761 "y.tab.c"
 
   yyvsp -= yylen;
   yyssp -= yylen;
@@ -1474,18 +1798,33 @@
 	{
 	  YYSIZE_T yysize = 0;
 	  int yytype = YYTRANSLATE (yychar);
+	  const char* yyprefix;
 	  char *yymsg;
-	  int yyx, yycount;
+	  int yyx;
 
-	  yycount = 0;
 	  /* Start YYX at -YYN if negative to avoid negative indexes in
 	     YYCHECK.  */
-	  for (yyx = yyn < 0 ? -yyn : 0;
-	       yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
+	  int yyxbegin = yyn < 0 ? -yyn : 0;
+
+	  /* Stay within bounds of both yycheck and yytname.  */
+	  int yychecklim = YYLAST - yyn;
+	  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+	  int yycount = 0;
+
+	  yyprefix = ", expecting ";
+	  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
 	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
-	      yysize += yystrlen (yytname[yyx]) + 15, yycount++;
-	  yysize += yystrlen ("syntax error, unexpected ") + 1;
-	  yysize += yystrlen (yytname[yytype]);
+	      {
+		yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
+		yycount += 1;
+		if (yycount == 5)
+		  {
+		    yysize = 0;
+		    break;
+		  }
+	      }
+	  yysize += (sizeof ("syntax error, unexpected ")
+		     + yystrlen (yytname[yytype]));
 	  yymsg = (char *) YYSTACK_ALLOC (yysize);
 	  if (yymsg != 0)
 	    {
@@ -1494,16 +1833,13 @@
 
 	      if (yycount < 5)
 		{
-		  yycount = 0;
-		  for (yyx = yyn < 0 ? -yyn : 0;
-		       yyx < (int) (sizeof (yytname) / sizeof (char *));
-		       yyx++)
+		  yyprefix = ", expecting ";
+		  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
 		    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
 		      {
-			const char *yyq = ! yycount ? ", expecting " : " or ";
-			yyp = yystpcpy (yyp, yyq);
+			yyp = yystpcpy (yyp, yyprefix);
 			yyp = yystpcpy (yyp, yytname[yyx]);
-			yycount++;
+			yyprefix = " or ";
 		      }
 		}
 	      yyerror (yymsg);
@@ -1524,51 +1860,56 @@
       /* If just tried and failed to reuse lookahead token after an
 	 error, discard it.  */
 
-      /* Return failure if at end of input.  */
-      if (yychar == YYEOF)
+      if (yychar <= YYEOF)
         {
-	  /* Pop the error token.  */
-          YYPOPSTACK;
-	  /* Pop the rest of the stack.  */
-	  while (yyss < yyssp)
-	    {
-	      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
-	      yydestruct (yystos[*yyssp], yyvsp);
-	      YYPOPSTACK;
-	    }
-	  YYABORT;
+          /* If at end of input, pop the error token,
+	     then the rest of the stack, then return failure.  */
+	  if (yychar == YYEOF)
+	     for (;;)
+	       {
+		 YYPOPSTACK;
+		 if (yyssp == yyss)
+		   YYABORT;
+		 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
+		 yydestruct (yystos[*yyssp], yyvsp);
+	       }
         }
+      else
+	{
+	  YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
+	  yydestruct (yytoken, &yylval);
+	  yychar = YYEMPTY;
 
-      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
-      yydestruct (yytoken, &yylval);
-      yychar = YYEMPTY;
-
+	}
     }
 
   /* Else will try to reuse lookahead token after shifting the error
      token.  */
-  goto yyerrlab2;
+  goto yyerrlab1;
 
 
-/*----------------------------------------------------.
-| yyerrlab1 -- error raised explicitly by an action.  |
-`----------------------------------------------------*/
-yyerrlab1:
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR.  |
+`---------------------------------------------------*/
+yyerrorlab:
 
-  /* Suppress GCC warning that yyerrlab1 is unused when no action
-     invokes YYERROR.  */
-#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
-  __attribute__ ((__unused__))
+#ifdef __GNUC__
+  /* Pacify GCC when the user code never invokes YYERROR and the label
+     yyerrorlab therefore never appears in user code.  */
+  if (0)
+     goto yyerrorlab;
 #endif
 
+  yyvsp -= yylen;
+  yyssp -= yylen;
+  yystate = *yyssp;
+  goto yyerrlab1;
 
-  goto yyerrlab2;
 
-
-/*---------------------------------------------------------------.
-| yyerrlab2 -- pop states until the error token can be shifted.  |
-`---------------------------------------------------------------*/
-yyerrlab2:
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR.  |
+`-------------------------------------------------------------*/
+yyerrlab1:
   yyerrstatus = 3;	/* Each real token shifted decrements this.  */
 
   for (;;)
@@ -1591,9 +1932,8 @@
 
       YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
       yydestruct (yystos[yystate], yyvsp);
-      yyvsp--;
-      yystate = *--yyssp;
-
+      YYPOPSTACK;
+      yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
     }
 
@@ -1642,7 +1982,7 @@
 }
 
 
-#line 35 "wktparse.y"
+#line 379 "wktparse.y"
 
 
 

Modified: packages/postgis/upstream/lwgeom/wktparse.tab.h
===================================================================
--- packages/postgis/upstream/lwgeom/wktparse.tab.h	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/wktparse.tab.h	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,7 +1,7 @@
-/* A Bison parser, made by GNU Bison 1.875.  */
+/* A Bison parser, made by GNU Bison 1.875c.  */
 
 /* Skeleton parser for Yacc-like parsing with Bison,
-   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -36,22 +36,32 @@
      MULTILINESTRING = 262,
      MULTIPOLYGON = 263,
      GEOMETRYCOLLECTION = 264,
-     POINTM = 265,
-     LINESTRINGM = 266,
-     POLYGONM = 267,
-     MULTIPOINTM = 268,
-     MULTILINESTRINGM = 269,
-     MULTIPOLYGONM = 270,
-     GEOMETRYCOLLECTIONM = 271,
-     SRID = 272,
-     EMPTY = 273,
-     VALUE = 274,
-     LPAREN = 275,
-     RPAREN = 276,
-     COMMA = 277,
-     EQUALS = 278,
-     SEMICOLON = 279,
-     WKB = 280
+     CIRCULARSTRING = 265,
+     COMPOUNDCURVE = 266,
+     CURVEPOLYGON = 267,
+     MULTICURVE = 268,
+     MULTISURFACE = 269,
+     POINTM = 270,
+     LINESTRINGM = 271,
+     POLYGONM = 272,
+     MULTIPOINTM = 273,
+     MULTILINESTRINGM = 274,
+     MULTIPOLYGONM = 275,
+     GEOMETRYCOLLECTIONM = 276,
+     CIRCULARSTRINGM = 277,
+     COMPOUNDCURVEM = 278,
+     CURVEPOLYGONM = 279,
+     MULTICURVEM = 280,
+     MULTISURFACEM = 281,
+     SRID = 282,
+     EMPTY = 283,
+     VALUE = 284,
+     LPAREN = 285,
+     RPAREN = 286,
+     COMMA = 287,
+     EQUALS = 288,
+     SEMICOLON = 289,
+     WKB = 290
    };
 #endif
 #define POINT 258
@@ -61,22 +71,32 @@
 #define MULTILINESTRING 262
 #define MULTIPOLYGON 263
 #define GEOMETRYCOLLECTION 264
-#define POINTM 265
-#define LINESTRINGM 266
-#define POLYGONM 267
-#define MULTIPOINTM 268
-#define MULTILINESTRINGM 269
-#define MULTIPOLYGONM 270
-#define GEOMETRYCOLLECTIONM 271
-#define SRID 272
-#define EMPTY 273
-#define VALUE 274
-#define LPAREN 275
-#define RPAREN 276
-#define COMMA 277
-#define EQUALS 278
-#define SEMICOLON 279
-#define WKB 280
+#define CIRCULARSTRING 265
+#define COMPOUNDCURVE 266
+#define CURVEPOLYGON 267
+#define MULTICURVE 268
+#define MULTISURFACE 269
+#define POINTM 270
+#define LINESTRINGM 271
+#define POLYGONM 272
+#define MULTIPOINTM 273
+#define MULTILINESTRINGM 274
+#define MULTIPOLYGONM 275
+#define GEOMETRYCOLLECTIONM 276
+#define CIRCULARSTRINGM 277
+#define COMPOUNDCURVEM 278
+#define CURVEPOLYGONM 279
+#define MULTICURVEM 280
+#define MULTISURFACEM 281
+#define SRID 282
+#define EMPTY 283
+#define VALUE 284
+#define LPAREN 285
+#define RPAREN 286
+#define COMMA 287
+#define EQUALS 288
+#define SEMICOLON 289
+#define WKB 290
 
 
 
@@ -87,8 +107,8 @@
 	double value;
 	const char* wkb;
 } YYSTYPE;
-/* Line 1248 of yacc.c.  */
-#line 91 "y.tab.h"
+/* Line 1275 of yacc.c.  */
+#line 112 "y.tab.h"
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
 # define YYSTYPE_IS_TRIVIAL 1

Modified: packages/postgis/upstream/lwgeom/wktparse.y
===================================================================
--- packages/postgis/upstream/lwgeom/wktparse.y	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/wktparse.y	2007-04-13 07:15:27 UTC (rev 758)
@@ -22,8 +22,8 @@
 	const char* wkb;
 }
 
-%token POINT LINESTRING POLYGON MULTIPOINT MULTILINESTRING MULTIPOLYGON GEOMETRYCOLLECTION
-%token POINTM LINESTRINGM POLYGONM MULTIPOINTM MULTILINESTRINGM MULTIPOLYGONM GEOMETRYCOLLECTIONM
+%token POINT LINESTRING POLYGON MULTIPOINT MULTILINESTRING MULTIPOLYGON GEOMETRYCOLLECTION CIRCULARSTRING COMPOUNDCURVE CURVEPOLYGON MULTICURVE MULTISURFACE
+%token POINTM LINESTRINGM POLYGONM MULTIPOINTM MULTILINESTRINGM MULTIPOLYGONM GEOMETRYCOLLECTIONM CIRCULARSTRINGM COMPOUNDCURVEM CURVEPOLYGONM  MULTICURVEM MULTISURFACEM
 %token SRID      
 %token EMPTY
 %token <value> VALUE
@@ -44,14 +44,24 @@
 	|
 	geom_linestring
 	|
+        geom_circularstring
+        |
 	geom_polygon
 	|
+        geom_compoundcurve
+        |
+        geom_curvepolygon
+        |
 	geom_multipoint 
 	|
 	geom_multilinestring
+        |
+        geom_multicurve
 	|
 	geom_multipolygon
 	|
+        geom_multisurface
+        |
 	geom_geometrycollection
 
 srid :
@@ -79,7 +89,6 @@
 nonempty_point :
 	{ alloc_point(); } point_int { pop(); } 
 
-
 point_int :
 	LPAREN a_point RPAREN
 
@@ -125,6 +134,9 @@
 nonempty_linestring :
 	{ alloc_linestring(); } linestring_1 { pop(); } 
 
+nonempty_linestring_closed :
+        { alloc_linestring_closed(); } linestring_1 { pop(); }
+
 linestring_1 :
 	{ alloc_counter(); } LPAREN linestring_int RPAREN { popc(); }
 
@@ -133,6 +145,66 @@
 	|
 	linestring_int COMMA a_point;
 
+/* CIRCULARSTRING */
+
+geom_circularstring :
+        CIRCULARSTRING circularstring
+        |
+        CIRCULARSTRINGM {set_zm(0, 1); } circularstring
+
+geom_circularstring_closed :
+        CIRCULARSTRING circularstring_closed
+        |
+        CIRCULARSTRINGM {set_zm(0, 1); } circularstring_closed
+
+circularstring :
+        empty_circularstring
+        |
+        nonempty_circularstring
+
+circularstring_closed :
+        empty_circularstring
+        |
+        nonempty_circularstring_closed
+
+empty_circularstring :
+        { alloc_circularstring(); } empty { pop(); }
+
+nonempty_circularstring :
+        { alloc_circularstring(); } circularstring_1 { pop(); }
+
+nonempty_circularstring_closed :
+        { alloc_circularstring_closed(); } circularstring_1 { pop(); }
+
+circularstring_1 :
+        { alloc_counter(); } LPAREN circularstring_int RPAREN { popc(); }
+
+circularstring_int :
+        a_point
+        |
+        circularstring_int COMMA a_point;
+
+/* COMPOUNDCURVE */
+
+geom_compoundcurve:
+        COMPOUNDCURVE { alloc_compoundcurve(); } compoundcurve { pop(); }
+        |
+        COMPOUNDCURVEM {set_zm(0, 1); alloc_compoundcurve(); } compoundcurve { pop(); }
+
+compoundcurve:
+        empty
+        |
+        { alloc_counter(); } LPAREN compoundcurve_int RPAREN { pop(); }
+
+compoundcurve_int:
+        nonempty_linestring
+        |
+        geom_circularstring
+        |
+        compoundcurve_int COMMA nonempty_linestring
+        |
+        compoundcurve_int COMMA geom_circularstring
+
 /* MULTILINESTRING */
 
 geom_multilinestring :
@@ -152,7 +224,29 @@
 	|
 	multilinestring_int COMMA nonempty_linestring
 
+/* MULTICURVESTRING */
 
+geom_multicurve :
+        MULTICURVE { alloc_multicurve(); }
+                multicurve { pop(); }
+        |
+        MULTICURVEM { set_zm(0, 1); alloc_multicurve(); }
+                multicurve { pop(); }
+
+multicurve :
+        empty
+        |
+        { alloc_counter(); } LPAREN multicurve_int RPAREN { pop(); }
+
+multicurve_int :
+        nonempty_linestring
+        |
+        geom_circularstring
+        |
+        multicurve_int COMMA nonempty_linestring
+        |
+        multicurve_int COMMA geom_circularstring
+
 /* POLYGON */
 
 geom_polygon :
@@ -178,7 +272,29 @@
 	linestring_1
 	|
 	polygon_int COMMA linestring_1
-                                                                                                          
+
+/* CURVEPOLYGON */
+
+geom_curvepolygon :
+        CURVEPOLYGON { alloc_curvepolygon(); } curvepolygon { pop(); }
+        |
+        CURVEPOLYGONM { set_zm(0, 1); alloc_curvepolygon(); } 
+                        curvepolygon { pop(); }
+
+curvepolygon :
+        empty
+        |
+        { alloc_counter(); } LPAREN curvepolygon_int RPAREN { pop(); }
+
+curvepolygon_int :
+        nonempty_linestring_closed
+        |
+        geom_circularstring_closed
+        |
+        curvepolygon_int COMMA nonempty_linestring_closed
+        |
+        curvepolygon_int COMMA geom_circularstring_closed
+
 /* MULTIPOLYGON */
 
 geom_multipolygon :
@@ -197,7 +313,28 @@
 	|
 	multipolygon_int COMMA nonempty_polygon
 
+/* MULTISURFACE */
 
+geom_multisurface :
+        MULTISURFACE {alloc_multisurface(); } multisurface { pop(); }
+        |
+        MULTISURFACEM { set_zm(0, 1); alloc_multisurface(); }
+                multisurface { pop(); }
+
+multisurface :
+        empty
+        |
+        { alloc_counter(); } LPAREN multisurface_int RPAREN { pop(); }
+
+multisurface_int :
+        nonempty_polygon
+        |
+        geom_curvepolygon
+        |
+        multisurface_int COMMA nonempty_polygon
+        |
+        multisurface_int COMMA geom_curvepolygon
+
 /* GEOMETRYCOLLECTION */
 
 geom_geometrycollection :

Modified: packages/postgis/upstream/lwgeom/wktunparse.c
===================================================================
--- packages/postgis/upstream/lwgeom/wktunparse.c	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/lwgeom/wktunparse.c	2007-04-13 07:15:27 UTC (rev 758)
@@ -4,7 +4,7 @@
  * Copyright Telogis 2004
  * www.telogis.com
  *
- * $Id: wktunparse.c 2521 2006-11-02 07:55:32Z strk $
+ * $Id: wktunparse.c 2532 2006-12-01 22:16:44Z mleslie $
  */
 
 
@@ -237,6 +237,49 @@
 	return output_wkt(geom,suppress);
 }
 
+/* special case for compound to suppress linestring but not circularstring */
+uchar *output_compound(uchar* geom, int suppress) {
+        unsigned type;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("output_compound called.");
+#endif
+
+        type=*geom++;
+        switch(TYPE_GETTYPE(type)) 
+        {
+                case LINETYPE:
+                        geom = output_collection(geom,output_point,0);
+                        break;
+                case CURVETYPE:
+                        write_str("CIRCULARSTRING");
+                        geom = output_collection(geom,output_point,1);
+                        break;
+        }
+	return geom;
+}
+
+uchar *output_multisurface(uchar* geom, int suppress) {
+        unsigned type;
+
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("output_multisurface called.");
+#endif
+
+        type=*geom++;
+        switch(TYPE_GETTYPE(type))
+        {
+                case POLYGONTYPE:
+                        geom = output_collection(geom, output_collection_2,0);
+                        break;
+                case CURVEPOLYTYPE:
+                        write_str("CURVEPOLYGON");
+                        geom = output_collection(geom, output_compound,1);
+                        break;
+        }
+        return geom;
+}
+
 /*
  * Suppress=0 -- write TYPE, M, coords
  * Suppress=1 -- write TYPE, coords 
@@ -250,6 +293,10 @@
 	char writeM=0;
 	dims = TYPE_NDIMS(type); /* ((type & 0x30) >> 4)+2; */
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("output_wkt called.");
+#endif
+
 	if ( ! supress && !TYPE_HASZ(type) && TYPE_HASM(type) ) writeM=1;
 
 
@@ -280,6 +327,14 @@
 			}
 			geom = output_collection(geom,output_point,0);
 			break;
+                case CURVETYPE:
+                        if ( supress < 2 )
+                        {
+                                if(writeM) write_str("CIRCULARSTRINGM");
+                                else write_str("CIRCULARSTRING");
+                        }
+                        geom = output_collection(geom,output_point,0);
+                        break;
 		case POLYGONTYPE:
 			if ( supress < 2 )
 			{
@@ -288,6 +343,22 @@
 			}
 			geom = output_collection(geom,output_collection_2,0);
 			break;
+                case COMPOUNDTYPE:
+                        if ( supress < 2 )
+                        {
+                                if (writeM) write_str("COMPOUNDCURVEM");
+                                else write_str("COMPOUNDCURVE");
+                        }
+                        geom = output_collection(geom, output_compound,1);
+                        break;
+                case CURVEPOLYTYPE:
+                        if (supress < 2)
+                        {
+                                if(writeM) write_str("CURVEPOLYGONM");
+                                else write_str("CURVEPOLYGON");
+                        }
+                        geom = output_collection(geom, output_compound,0);
+                        break;
 		case MULTIPOINTTYPE:
 			if ( supress < 2 )
 			{
@@ -304,6 +375,14 @@
 			}
 			geom = output_collection(geom,output_wkt,2);
 			break;
+                case MULTICURVETYPE:
+                        if ( supress < 2 )
+                        {
+                                if (writeM) write_str("MULTICURVEM");
+                                else write_str("MULTICURVE");
+                        }
+                        geom = output_collection(geom,output_compound,2);
+                        break;
 		case MULTIPOLYGONTYPE:
 			if ( supress < 2 )
 			{
@@ -312,6 +391,14 @@
 			}
 			geom = output_collection(geom,output_wkt,2);
 			break;
+                case MULTISURFACETYPE:
+                        if ( supress < 2)
+                        {
+                                if (writeM) write_str("MULTISURFACEM");
+                                else write_str("MULTISURFACE");
+                        } 
+                        geom = output_collection(geom,output_multisurface,2);
+                        break;
 		case COLLECTIONTYPE:
 			if ( supress < 2 )
 			{
@@ -359,6 +446,10 @@
 unparse_WKT(uchar* serialized, allocator alloc, freeor free)
 {
 
+#ifdef PGIS_DEBUG_CALLS
+        lwnotice("unparse_WKT called.");
+#endif
+
 	if (serialized==NULL)
 		return NULL;
 
@@ -480,7 +571,6 @@
 	return output_wkb_collection(geom,output_wkb_point);
 }
 
-
 uchar *
 output_wkb(uchar* geom)
 {
@@ -524,9 +614,20 @@
 		case LINETYPE:
 			geom=output_wkb_collection(geom,output_wkb_point);
 			break;
+                case CURVETYPE:
+                        geom=output_wkb_collection(geom,output_wkb_point);
+                        break;
 		case POLYGONTYPE:
 			geom=output_wkb_collection(geom,output_wkb_collection_2);
 			break;
+                case COMPOUNDTYPE:
+                        geom=output_wkb_collection(geom,output_wkb);
+                        break;
+                case CURVEPOLYTYPE:
+                        geom=output_wkb_collection(geom,output_wkb);
+                        break;
+                case MULTICURVETYPE:
+                case MULTISURFACETYPE:
 		case MULTIPOINTTYPE:
 		case MULTILINETYPE:
 		case MULTIPOLYGONTYPE:

Modified: packages/postgis/upstream/regress/Makefile
===================================================================
--- packages/postgis/upstream/regress/Makefile	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/regress/Makefile	2007-04-13 07:15:27 UTC (rev 758)
@@ -17,6 +17,7 @@
 	loader/PolygonZ \
 	regress \
 	regress_index \
+	regress_index_nulls \
 	lwgeom_regress \
 	regress_lrs \
 	removepoint \
@@ -27,7 +28,8 @@
 	wkt \
 	measures \
 	long_xact \
-	ctors
+	ctors \
+	sql-mm-serialize
 
 ifeq ($(USE_GEOS),1)
 	TESTS += regress_ogc regress_bdpoly

Modified: packages/postgis/upstream/regress/README
===================================================================
--- packages/postgis/upstream/regress/README	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/regress/README	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,3 +1,13 @@
+How to add a regression test
+----------------------------
+
+1. Write a /regress/<testname>.sql file with data and sql queries for testing
+2. Write a /regress/<testname>_expected file with expected results per query
+3. Edit regress/Makefile adding <testname> to the TESTS variable.
+
+Notes about changes in regression tests introduces with PostGIS 1.1.0
+---------------------------------------------------------------------
+
 - Mixed-dimensioned geometries are no longer supported
   (previous behaviour was to fill Z with a 0 value)
   [ updated to use new behaviour ]

Modified: packages/postgis/upstream/regress/lwgeom_regress_expected
===================================================================
--- packages/postgis/upstream/regress/lwgeom_regress_expected	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/regress/lwgeom_regress_expected	2007-04-13 07:15:27 UTC (rev 758)
@@ -1,5 +1,5 @@
 BOX(0 0.0999999940395355,11 12)
-BOX3D(0 0.1 -3,11 12 12)
+BOX3D(0 0.1 -55,11 12 12)
 10431
 15063
 19695

Added: packages/postgis/upstream/regress/regress_index_nulls.sql
===================================================================
--- packages/postgis/upstream/regress/regress_index_nulls.sql	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/regress/regress_index_nulls.sql	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,6 @@
+\i regress_lots_of_nulls.sql
+
+
+CREATE INDEX "test_geom_idx" ON "test" using gist (the_geom);
+
+DROP TABLE "test";

Added: packages/postgis/upstream/regress/regress_index_nulls_expected
===================================================================

Added: packages/postgis/upstream/regress/regress_lots_of_nulls.sql
===================================================================
--- packages/postgis/upstream/regress/regress_lots_of_nulls.sql	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/regress/regress_lots_of_nulls.sql	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,510 @@
+-- Test index creation on null geometries
+-- An index on more than 459 null geometries (with or without actual geometires)
+--   used to fail on PostgreSQL 8.2.
+
+CREATE TABLE "test" (
+	"num" integer,
+	"the_geom" geometry
+);
+
+INSERT INTO "test" ("num", "the_geom") VALUES (	1	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	2	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	3	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	4	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	5	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	6	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	7	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	8	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	9	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	10	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	11	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	12	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	13	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	14	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	15	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	16	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	17	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	18	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	19	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	20	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	21	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	22	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	23	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	24	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	25	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	26	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	27	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	28	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	29	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	30	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	31	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	32	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	33	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	34	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	35	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	36	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	37	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	38	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	39	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	40	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	41	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	42	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	43	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	44	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	45	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	46	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	47	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	48	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	49	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	50	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	51	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	52	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	53	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	54	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	55	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	56	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	57	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	58	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	59	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	60	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	61	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	62	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	63	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	64	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	65	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	66	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	67	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	68	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	69	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	70	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	71	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	72	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	73	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	74	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	75	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	76	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	77	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	78	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	79	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	80	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	81	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	82	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	83	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	84	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	85	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	86	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	87	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	88	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	89	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	90	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	91	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	92	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	93	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	94	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	95	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	96	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	97	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	98	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	99	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	100	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	101	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	102	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	103	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	104	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	105	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	106	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	107	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	108	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	109	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	110	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	111	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	112	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	113	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	114	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	115	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	116	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	117	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	118	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	119	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	120	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	121	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	122	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	123	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	124	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	125	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	126	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	127	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	128	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	129	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	130	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	131	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	132	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	133	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	134	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	135	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	136	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	137	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	138	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	139	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	140	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	141	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	142	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	143	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	144	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	145	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	146	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	147	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	148	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	149	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	150	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	151	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	152	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	153	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	154	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	155	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	156	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	157	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	158	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	159	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	160	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	161	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	162	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	163	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	164	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	165	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	166	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	167	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	168	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	169	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	170	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	171	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	172	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	173	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	174	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	175	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	176	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	177	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	178	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	179	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	180	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	181	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	182	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	183	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	184	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	185	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	186	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	187	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	188	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	189	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	190	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	191	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	192	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	193	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	194	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	195	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	196	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	197	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	198	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	199	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	200	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	201	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	202	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	203	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	204	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	205	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	206	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	207	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	208	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	209	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	210	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	211	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	212	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	213	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	214	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	215	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	216	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	217	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	218	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	219	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	220	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	221	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	222	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	223	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	224	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	225	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	226	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	227	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	228	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	229	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	230	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	231	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	232	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	233	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	234	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	235	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	236	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	237	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	238	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	239	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	240	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	241	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	242	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	243	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	244	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	245	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	246	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	247	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	248	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	249	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	250	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	251	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	252	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	253	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	254	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	255	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	256	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	257	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	258	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	259	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	260	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	261	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	262	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	263	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	264	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	265	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	266	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	267	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	268	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	269	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	270	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	271	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	272	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	273	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	274	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	275	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	276	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	277	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	278	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	279	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	280	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	281	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	282	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	283	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	284	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	285	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	286	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	287	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	288	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	289	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	290	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	291	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	292	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	293	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	294	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	295	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	296	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	297	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	298	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	299	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	300	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	301	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	302	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	303	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	304	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	305	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	306	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	307	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	308	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	309	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	310	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	311	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	312	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	313	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	314	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	315	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	316	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	317	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	318	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	319	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	320	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	321	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	322	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	323	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	324	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	325	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	326	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	327	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	328	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	329	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	330	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	331	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	332	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	333	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	334	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	335	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	336	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	337	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	338	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	339	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	340	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	341	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	342	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	343	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	344	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	345	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	346	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	347	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	348	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	349	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	350	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	351	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	352	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	353	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	354	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	355	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	356	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	357	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	358	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	359	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	360	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	361	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	362	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	363	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	364	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	365	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	366	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	367	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	368	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	369	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	370	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	371	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	372	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	373	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	374	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	375	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	376	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	377	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	378	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	379	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	380	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	381	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	382	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	383	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	384	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	385	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	386	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	387	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	388	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	389	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	390	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	391	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	392	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	393	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	394	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	395	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	396	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	397	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	398	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	399	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	400	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	401	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	402	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	403	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	404	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	405	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	406	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	407	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	408	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	409	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	410	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	411	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	412	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	413	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	414	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	415	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	416	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	417	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	418	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	419	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	420	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	421	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	422	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	423	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	424	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	425	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	426	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	427	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	428	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	429	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	430	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	431	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	432	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	433	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	434	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	435	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	436	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	437	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	438	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	439	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	440	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	441	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	442	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	443	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	444	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	445	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	446	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	447	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	448	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	449	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	450	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	451	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	452	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	453	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	454	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	455	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	456	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	457	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	458	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	459	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	460	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	461	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	462	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	463	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	464	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	465	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	466	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	467	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	468	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	469	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	470	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	471	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	472	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	473	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	474	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	475	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	476	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	477	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	478	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	479	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	480	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	481	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	482	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	483	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	484	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	485	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	486	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	487	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	488	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	489	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	490	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	491	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	492	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	493	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	494	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	495	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	496	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	497	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	498	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	499	, NULL);
+INSERT INTO "test" ("num", "the_geom") VALUES (	500	, NULL);
+

Added: packages/postgis/upstream/regress/sql-mm-serialize.sql
===================================================================
--- packages/postgis/upstream/regress/sql-mm-serialize.sql	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/regress/sql-mm-serialize.sql	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,164 @@
+
+CREATE TABLE serialize_test (
+        id INTEGER,
+        description VARCHAR,
+        ewkt VARCHAR,
+        serialized TEXT);
+
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        1, 'Circular String',
+        'CIRCULARSTRING(-2 0,0 2,2 0,0 2,2 4)',
+        '01080000000500000000000000000000C0000000000000000000000000000000000000000000000040000000000000004000000000000000000000000000000000000000000000004000000000000000400000000000001040');
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        2, 'Circular String, SRID=4326',
+        'SRID=4326;CIRCULARSTRING(-2 0,0 2,2 0,0 2,2 4)',
+        '0108000020E61000000500000000000000000000C0000000000000000000000000000000000000000000000040000000000000004000000000000000000000000000000000000000000000004000000000000000400000000000001040');
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        3, 'Circular String 3dz, SRID=4326',
+        'SRID=4326;CIRCULARSTRING(-2 0 1,0 2 1,2 0 1,0 2 1,2 4 1)',
+        '01080000A0E61000000500000000000000000000C00000000000000000000000000000F03F00000000000000000000000000000040000000000000F03F00000000000000400000000000000000000000000000F03F00000000000000000000000000000040000000000000F03F00000000000000400000000000001040000000000000F03F');
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        4, 'Circular String 3dm, SRID=4326',
+        'SRID=4326;CIRCULARSTRINGM(-2 0 1,0 2 1,2 0 1,0 2 1,2 4 1)',
+        '0108000060E61000000500000000000000000000C00000000000000000000000000000F03F00000000000000000000000000000040000000000000F03F00000000000000400000000000000000000000000000F03F00000000000000000000000000000040000000000000F03F00000000000000400000000000001040000000000000F03F');
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        5, 'Circular String 4d, SRID=4326',
+        'SRID=4326;CIRCULARSTRING(-2 0 1 0,0 2 1 0,2 0 1 0,0 2 1 0,2 4 1 0)',
+        '01080000E0E61000000500000000000000000000C00000000000000000000000000000F03F000000000000000000000000000000000000000000000040000000000000F03F000000000000000000000000000000400000000000000000000000000000F03F000000000000000000000000000000000000000000000040000000000000F03F000000000000000000000000000000400000000000001040000000000000F03F0000000000000000');
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        6, 'Circular String',
+        'COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))',
+        '01090000000200000001080000000300000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000000010200000002000000000000000000F03F00000000000000000000000000000000000000000000F03F');
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        7, 'Compound Curve, SRID=4326',
+        'SRID=4326;COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))',
+        '0109000020E61000000200000001080000000300000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000000010200000002000000000000000000F03F00000000000000000000000000000000000000000000F03F');
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        8, 'Compound Curve 3dz, SRID=4326',
+        'SRID=4326;COMPOUNDCURVE(CIRCULARSTRING(0 0 2,1 1 2,1 0 2),(1 0 2,0 1 2))',
+        '01090000A0E610000002000000010800008003000000000000000000000000000000000000000000000000000040000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000000000000000000040010200008002000000000000000000F03F000000000000000000000000000000400000000000000000000000000000F03F0000000000000040');
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        9, 'Circular String 3dm, SRID=4326',
+        'SRID=4326;COMPOUNDCURVEM(CIRCULARSTRING(0 0 2,1 1 2,1 0 2),(1 0 2,0 1 2))',
+        '0109000060E610000002000000010800004003000000000000000000000000000000000000000000000000000040000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000000000000000000040010200004002000000000000000000F03F000000000000000000000000000000400000000000000000000000000000F03F0000000000000040');
+INSERT INTO serialize_test (
+        id, description, ewkt, serialized
+      ) VALUES (
+        10, 'Circular String 4d, SRID=4326',
+        'SRID=4326;COMPOUNDCURVE(CIRCULARSTRING(0 0 2 5,1 1 2 5,1 0 2 5),(1 0 2 5,0 1 2 2))',
+        '01090000E0E61000000200000001080000C0030000000000000000000000000000000000000000000000000000400000000000001440000000000000F03F000000000000F03F00000000000000400000000000001440000000000000F03F00000000000000000000000000000040000000000000144001020000C002000000000000000000F03F0000000000000000000000000000004000000000000014400000000000000000000000000000F03F00000000000000400000000000000040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        11, 'Curve Polygon',
+        'CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))',
+        '010D0000000200000001080000000700000000000000000000C00000000000000000000000000000F0BF000000000000F0BF00000000000000000000000000000000000000000000F03F000000000000F0BF000000000000004000000000000000000000000000000000000000000000004000000000000000C00000000000000000010200000005000000000000000000F0BF00000000000000000000000000000000000000000000E03F000000000000F03F00000000000000000000000000000000000000000000F03F000000000000F0BF0000000000000000');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        12, 'Curve Polygon, SRID=4326',
+        'SRID=4326;CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))',
+        '010D000020E61000000200000001080000000700000000000000000000C00000000000000000000000000000F0BF000000000000F0BF00000000000000000000000000000000000000000000F03F000000000000F0BF000000000000004000000000000000000000000000000000000000000000004000000000000000C00000000000000000010200000005000000000000000000F0BF00000000000000000000000000000000000000000000E03F000000000000F03F00000000000000000000000000000000000000000000F03F000000000000F0BF0000000000000000');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        13, 'Curve Polygon 3dz, SRID=4326',
+        'SRID=4326;CURVEPOLYGON(CIRCULARSTRING(-2 0 0,-1 -1 1,0 0 2,1 -1 3,2 0 4,0 2 2,-2 0 0),(-1 0 1,0 0.5 2,1 0 3,0 1 3,-1 0 1))',
+        '010D0000A0E61000000200000001080000800700000000000000000000C000000000000000000000000000000000000000000000F0BF000000000000F0BF000000000000F03F000000000000000000000000000000000000000000000040000000000000F03F000000000000F0BF000000000000084000000000000000400000000000000000000000000000104000000000000000000000000000000040000000000000004000000000000000C000000000000000000000000000000000010200008005000000000000000000F0BF0000000000000000000000000000F03F0000000000000000000000000000E03F0000000000000040000000000000F03F000000000000000000000000000008400000000000000000000000000000F03F0000000000000840000000000000F0BF0000000000000000000000000000F03F');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        14, 'Curve Polygon 3dm, SRID=4326',
+        'SRID=4326;CURVEPOLYGONM(CIRCULARSTRING(-2 0 0,-1 -1 2,0 0 4,1 -1 6,2 0 8,0 2 4,-2 0 0),(-1 0 2,0 0.5 4,1 0 6,0 1 4,-1 0 2))',
+        '010D000060E61000000200000001080000400700000000000000000000C000000000000000000000000000000000000000000000F0BF000000000000F0BF0000000000000040000000000000000000000000000000000000000000001040000000000000F03F000000000000F0BF000000000000184000000000000000400000000000000000000000000000204000000000000000000000000000000040000000000000104000000000000000C000000000000000000000000000000000010200004005000000000000000000F0BF000000000000000000000000000000400000000000000000000000000000E03F0000000000001040000000000000F03F000000000000000000000000000018400000000000000000000000000000F03F0000000000001040000000000000F0BF00000000000000000000000000000040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        15, 'Curve Polygon 4d, SRID=4326',
+        'SRID=4326;CURVEPOLYGON(CIRCULARSTRING(-2 0 0 0,-1 -1 1 2,0 0 2 4,1 -1 3 6,2 0 4 8,0 2 2 4,-2 0 0 0),(-1 0 1 2,0 0.5 2 4,1 0 3 6,0 1 3 4,-1 0 1 2))',
+        '010D0000E0E61000000200000001080000C00700000000000000000000C0000000000000000000000000000000000000000000000000000000000000F0BF000000000000F0BF000000000000F03F00000000000000400000000000000000000000000000000000000000000000400000000000001040000000000000F03F000000000000F0BF000000000000084000000000000018400000000000000040000000000000000000000000000010400000000000002040000000000000000000000000000000400000000000000040000000000000104000000000000000C000000000000000000000000000000000000000000000000001020000C005000000000000000000F0BF0000000000000000000000000000F03F00000000000000400000000000000000000000000000E03F00000000000000400000000000001040000000000000F03F0000000000000000000000000000084000000000000018400000000000000000000000000000F03F00000000000008400000000000001040000000000000F0BF0000000000000000000000000000F03F0000000000000040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        16, 'Multi Curve',
+        'MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 2))',
+        '010E0000000200000001020000000400000000000000000014400000000000001440000000000000084000000000000014400000000000000840000000000000084000000000000000000000000000000840010800000003000000000000000000000000000000000000000000000000000040000000000000F03F00000000000000400000000000000040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        17, 'Multi Curve, SRID=4326',
+        'SRID=4326;MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 2))',
+        '010E000020E61000000200000001020000000400000000000000000014400000000000001440000000000000084000000000000014400000000000000840000000000000084000000000000000000000000000000840010800000003000000000000000000000000000000000000000000000000000040000000000000F03F00000000000000400000000000000040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        18, 'Multi Curve 3dz, SRID=4326',
+        'SRID=4326;MULTICURVE((5 5 1,3 5 2,3 3 3,0 3 1),CIRCULARSTRING(0 0 0,2 1 3,2 2 1))',
+        '010E0000A0E61000000200000001020000800400000000000000000014400000000000001440000000000000F03F00000000000008400000000000001440000000000000004000000000000008400000000000000840000000000000084000000000000000000000000000000840000000000000F03F0108000080030000000000000000000000000000000000000000000000000000000000000000000040000000000000F03F000000000000084000000000000000400000000000000040000000000000F03F');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        19, 'Multi Curve 3dm, SRID=4326',
+        'SRID=4326;MULTICURVEM((5 5 3,3 5 2,3 3 1,0 3 1),CIRCULARSTRING(0 0 0,2 1 -2,2 2 2))',
+        '010E000060E61000000200000001020000400400000000000000000014400000000000001440000000000000084000000000000008400000000000001440000000000000004000000000000008400000000000000840000000000000F03F00000000000000000000000000000840000000000000F03F0108000040030000000000000000000000000000000000000000000000000000000000000000000040000000000000F03F00000000000000C0000000000000004000000000000000400000000000000040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        20, 'Multi Curve 4d, SRID=4326',
+        'SRID=4326;MULTICURVE((5 5 1 3,3 5 2 2,3 3 3 1,0 3 1 1),CIRCULARSTRING(0 0 0 0,2 1 3 -2,2 2 1 2))',
+        '010E0000E0E61000000200000001020000C00400000000000000000014400000000000001440000000000000F03F00000000000008400000000000000840000000000000144000000000000000400000000000000040000000000000084000000000000008400000000000000840000000000000F03F00000000000000000000000000000840000000000000F03F000000000000F03F01080000C00300000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000F03F000000000000084000000000000000C000000000000000400000000000000040000000000000F03F0000000000000040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        21, 'Multi Surface',
+        'MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))',
+        '010F00000002000000010D0000000200000001080000000700000000000000000000C00000000000000000000000000000F0BF000000000000F0BF00000000000000000000000000000000000000000000F03F000000000000F0BF000000000000004000000000000000000000000000000000000000000000004000000000000000C00000000000000000010200000005000000000000000000F0BF00000000000000000000000000000000000000000000E03F000000000000F03F00000000000000000000000000000000000000000000F03F000000000000F0BF0000000000000000010300000001000000050000000000000000001C4000000000000020400000000000002440000000000000244000000000000018400000000000002C40000000000000104000000000000026400000000000001C400000000000002040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        22, 'Multi Surface, SRID=4326',
+        'SRID=4326;MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))',
+        '010F000020E610000002000000010D0000000200000001080000000700000000000000000000C00000000000000000000000000000F0BF000000000000F0BF00000000000000000000000000000000000000000000F03F000000000000F0BF000000000000004000000000000000000000000000000000000000000000004000000000000000C00000000000000000010200000005000000000000000000F0BF00000000000000000000000000000000000000000000E03F000000000000F03F00000000000000000000000000000000000000000000F03F000000000000F0BF0000000000000000010300000001000000050000000000000000001C4000000000000020400000000000002440000000000000244000000000000018400000000000002C40000000000000104000000000000026400000000000001C400000000000002040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        23, 'Multi Surface 3dz, SRID=4326',
+        'SRID=4326;MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0 0,-1 -1 1,0 0 2,1 -1 3,2 0 4,0 2 2,-2 0 0),(-1 0 1,0 0.5 2,1 0 3,0 1 3,-1 0 1)),((7 8 7,10 10 5,6 14 3,4 11 4,7 8 7)))',
+        '010F0000A0E610000002000000010D0000800200000001080000800700000000000000000000C000000000000000000000000000000000000000000000F0BF000000000000F0BF000000000000F03F000000000000000000000000000000000000000000000040000000000000F03F000000000000F0BF000000000000084000000000000000400000000000000000000000000000104000000000000000000000000000000040000000000000004000000000000000C000000000000000000000000000000000010200008005000000000000000000F0BF0000000000000000000000000000F03F0000000000000000000000000000E03F0000000000000040000000000000F03F000000000000000000000000000008400000000000000000000000000000F03F0000000000000840000000000000F0BF0000000000000000000000000000F03F010300008001000000050000000000000000001C4000000000000020400000000000001C4000000000000024400000000000002440000000000000144000000000000018400000000000002C4000000000000008400000000000001040000000000000264000000000000010400000000000001C4000000000000020400000000000001C40');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        24, 'Multi Surface 3dm, SRID=4326',
+        'SRID=4326;MULTISURFACEM(CURVEPOLYGON(CIRCULARSTRING(-2 0 0,-1 -1 2,0 0 4,1 -1 6,2 0 8,0 2 4,-2 0 0),(-1 0 2,0 0.5 4,1 0 6,0 1 4,-1 0 2)),((7 8 8,10 10 5,6 14 1,4 11 6,7 8 8)))',
+        '010F000060E610000002000000010D0000400200000001080000400700000000000000000000C000000000000000000000000000000000000000000000F0BF000000000000F0BF0000000000000040000000000000000000000000000000000000000000001040000000000000F03F000000000000F0BF000000000000184000000000000000400000000000000000000000000000204000000000000000000000000000000040000000000000104000000000000000C000000000000000000000000000000000010200004005000000000000000000F0BF000000000000000000000000000000400000000000000000000000000000E03F0000000000001040000000000000F03F000000000000000000000000000018400000000000000000000000000000F03F0000000000001040000000000000F0BF00000000000000000000000000000040010300004001000000050000000000000000001C400000000000002040000000000000204000000000000024400000000000002440000000000000144000000000000018400000000000002C40000000000000F03F0000000000001040000000000000264000000000000018400000000000001C4000000000000020400000000000002040');
+INSERT INTO serialize_test(
+        id, description, ewkt, serialized
+      ) VALUES (
+        25, 'Multi Surface 4d, SRID=4326',
+        'SRID=4326;MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0 0 0,-1 -1 1 2,0 0 2 4,1 -1 3 6,2 0 4 8,0 2 2 4,-2 0 0 0),(-1 0 1 2,0 0.5 2 4,1 0 3 6,0 1 3 4,-1 0 1 2)),((7 8 7 8,10 10 5 5,6 14 3 1,4 11 4 6,7 8 7 8)))',
+        '010F0000E0E610000002000000010D0000C00200000001080000C00700000000000000000000C0000000000000000000000000000000000000000000000000000000000000F0BF000000000000F0BF000000000000F03F00000000000000400000000000000000000000000000000000000000000000400000000000001040000000000000F03F000000000000F0BF000000000000084000000000000018400000000000000040000000000000000000000000000010400000000000002040000000000000000000000000000000400000000000000040000000000000104000000000000000C000000000000000000000000000000000000000000000000001020000C005000000000000000000F0BF0000000000000000000000000000F03F00000000000000400000000000000000000000000000E03F00000000000000400000000000001040000000000000F03F0000000000000000000000000000084000000000000018400000000000000000000000000000F03F00000000000008400000000000001040000000000000F0BF0000000000000000000000000000F03F000000000000004001030000C001000000050000000000000000001C4000000000000020400000000000001C400000000000002040000000000000244000000000000024400000000000001440000000000000144000000000000018400000000000002C400000000000000840000000000000F03F00000000000010400000000000002640000000000000104000000000000018400000000000001C4000000000000020400000000000001C400000000000002040');
+
+
+    
+SELECT id, CASE WHEN ewkt = asEWKT(serialized::geometry) THEN 'pass' ELSE 'fail' END AS result FROM serialize_test ORDER BY id;
+SELECT id, CASE WHEN asEWKB(geomFromEWKT(ewkt)) = serialized THEN 'pass' ELSE 'fail' END AS result FROM serialize_test ORDER BY id;
+
+DROP TABLE serialize_test;

Added: packages/postgis/upstream/regress/sql-mm-serialize_expected
===================================================================
--- packages/postgis/upstream/regress/sql-mm-serialize_expected	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/regress/sql-mm-serialize_expected	2007-04-13 07:15:27 UTC (rev 758)
@@ -0,0 +1,50 @@
+1|pass
+2|pass
+3|pass
+4|pass
+5|pass
+6|pass
+7|pass
+8|pass
+9|pass
+10|pass
+11|pass
+12|pass
+13|pass
+14|pass
+15|pass
+16|pass
+17|pass
+18|pass
+19|pass
+20|pass
+21|pass
+22|pass
+23|pass
+24|pass
+25|pass
+1|pass
+2|pass
+3|pass
+4|pass
+5|pass
+6|pass
+7|pass
+8|pass
+9|pass
+10|pass
+11|pass
+12|pass
+13|pass
+14|pass
+15|pass
+16|pass
+17|pass
+18|pass
+19|pass
+20|pass
+21|pass
+22|pass
+23|pass
+24|pass
+25|pass

Modified: packages/postgis/upstream/utils/postgis_restore.pl
===================================================================
--- packages/postgis/upstream/utils/postgis_restore.pl	2007-04-13 07:11:53 UTC (rev 757)
+++ packages/postgis/upstream/utils/postgis_restore.pl	2007-04-13 07:15:27 UTC (rev 758)
@@ -184,6 +184,11 @@
 		$arg = 'geometry';
 	}
 
+	# Timestamp with or without time zone
+	if ( $arg =~ /timestamp .* time zone/ ) {
+		$arg = 'timestamp';
+	}
+
 	return $arg;
 }
 
@@ -677,7 +682,7 @@
 # Create the new db and install plpgsql language
 #
 print "Creating db ($dbname)\n";
-`createdb $dbname $createdb_opt`;
+`createdb $createdb_opt $dbname`;
 die "Database creation failed\n" if ($?);
 print "Adding plpgsql\n";
 `createlang plpgsql $dbname`;




More information about the Pkg-grass-devel mailing list