Find a file
Sandro Santilli f76e0c45c3 Drop spurious empty line
git-svn-id: http://svn.osgeo.org/postgis/trunk@5795 b70326c6-7e19-0410-871a-916f4a2858ee
2010-08-08 22:20:24 +00:00
doc flag more ps functions 2010-08-06 16:17:27 +00:00
extras make astyle session 2010-02-21 12:36:27 +00:00
java - removed a few compile errors from the javadoc build 2009-04-28 17:04:30 +00:00
liblwgeom Improve printLWPSURFACE to also print each rings if any 2010-08-08 20:36:42 +00:00
loader Remove crash when dbf file is missing / unloadable 2010-06-03 19:10:00 +00:00
macros Add support for command-q shutdown in Mac GTK build 2010-04-06 23:37:07 +00:00
postgis Add function aliases for ST_NumPatches and ST_PatchN (both SFS 1.2 and SQL/MM). Add PolyhedralSurface for ST_IsClosed (surface vs volume). Update ST_Dimension support to be consistent. Add unit tests. 2010-08-08 20:41:17 +00:00
regress Drop spurious empty line 2010-08-08 22:20:24 +00:00
topology Add 7.3+ CAST (wasn't needed up to 7.2, against which this topology implementation was coded) 2010-07-07 21:52:15 +00:00
utils Include 'geography_columns' defn when upgrading from <= 1.4 (#414) 2010-03-09 00:31:26 +00:00
astyle.sh Check astyle version prior to do anything. 'blessed' version is 1.23. Related to #433 and postgis-devel discussions 2010-02-23 15:21:45 +00:00
authors.svn Add ChangeLog.svn rule, and auxiliary authors file 2009-08-11 16:38:32 +00:00
autogen.sh Can't put backslash-commands in 'echo' parameter in a standard way 2009-09-30 14:10:25 +00:00
ChangeLog Some function renaming: lwgeom_typename => lwtype_name. The internal float/up/down functions get slightly better names. Make collection types re-sizable: added maxgeoms to all collections, and created lwcollection_add_lwgeom() function. Remove all *_add functions. Revized homogenize function to use the new _add_lwgeom and variants. 2010-03-16 03:13:33 +00:00
configure.ac Make use of iconvctl conditional on it existing 2010-05-27 14:02:07 +00:00
COPYING Initial revision 2001-06-22 17:39:29 +00:00
CREDITS Bring this up to date. 2009-07-01 16:56:36 +00:00
GNUmakefile Fix 'clean' rule to descend in cunit 2010-03-17 07:32:59 +00:00
HOWTO_RELEASE Grammar fix. 2010-03-11 14:34:19 +00:00
install-sh Fix missing prototypes warnings 2010-02-22 19:31:43 +00:00
make_dist.sh Add comment about postgis_comments.sql handling in 'clean' target of docs 2010-01-12 01:01:36 +00:00
Makefile Aliased 'test' rule as 'check', to conform to common practice. 2006-06-16 14:18:28 +00:00
NEWS Document ST_isCollection (see #549) 2010-07-06 08:28:36 +00:00
postgis_config.h.in Libxml become mandatory. Cf #344. Modify configure step, remove all HAVE_LIBXML2 from code, sql and unit tests. Update documentation 2009-12-18 19:08:20 +00:00
README.postgis Add in micro commit to see if email hook is running 2010-07-04 16:34:25 +00:00
spatial_ref_sys.sql Add towgs84 line into proj4text for srid = 28992 (#387) 2010-01-18 19:40:20 +00:00
STYLE forgot to save last change 2009-07-06 07:37:47 +00:00
TODO remove ST_Maxdistance from TODO and note that C-version is still TODO for ST_DumpPoints 2010-01-23 23:29:07 +00:00
Version.config Push version numbers on trunk forward to next release. 2010-02-04 17:43:47 +00:00

PostGIS - Geographic Information Systems Extensions to PostgreSQL
~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

VERSION: 2.0.0 (YYYY/MM/DD)

MORE INFORMATION: http://postgis.org

This distribution contains a module which implements GIS simple 
features, ties the features to rtree indexing, and provides some 
spatial functions for accessing and analyzing geographic data.

Directory structure:

  ./            Build scripts and install directions.
  ./liblwgeom   LWGEOM access library.
  ./postgis     PostGIS 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 8.3 and above.

You *must* have the full PostgreSQL - including server headers - installed
for this to work. 

* PROJ4 SUPPORT (Required, Version 4.5.0 or better): 

  The Proj4 reprojection library is required if you want to use the 
  transform() function to reproject features within the database.

    http://trac.osgeo.org/proj/

* SPATIAL PREDICATE / GEOS SUPPORT (Required, Version 3.1.1 or better):

  The GEOS library provides support for exact topological tests
  such as Touches(), Contains(), Disjoint() and spatial operations
  such as Intersection(), Union() and Buffer().  

    http://trac.osgeo.org/geos/

* XML SUPPORT (Required): 

  The LibXML2 library is required to use the ST_GeomFromGML() and 
  ST_GeomFromKML() functionality.

    http://xmlsoft.org/


CONFIGURATION
-------------

To configure PostGIS, run:
	
  ./configure

The results of the configuration can be easily seen within the
postgis_config.h file.

If pg_config can't be found in your $PATH configure will complain
and refuse to proceed. You can specify it using the 
--with-pgconfig=/path/to/pg_config flag.

If PROJ4 has been installed (but cannot be found), configure will
complain and refuse to proceed. You can specify an alternative 
installation directory using the --with-projdir=DIR option.

If GEOS has been installed (but cannot be found), configure will 
complain and refuse to proceed. You can specify an alternative 
geos-config file using the --with-geosconfig=/path/to/geos-config 
option.

See ./configure --help for more options.

BUILD
-----

PostGIS uses the GNU make (aka gmake) for building. 
To build PostGIS library and utilities, as postgres run:

  make

TESTING
-------

You want to run regress tests before installation.
To do so, as postgres run:  

	make check

The above will create a test database with postgis extensions,
run tests and then drop the db.

Final lines of output contain a summary of test results:
run, succeeded, failed. If you have any failure please
file a bug report using the online bug tracker:
http://trac.osgeo.org/postgis/report/3.

  
INSTALLATION
------------

To install PostGIS library and utilities, as postgres run:

  make install


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
	- Manual pages in [prefix]/man
	- Documentation in in [prefix]/share/doc

Where [prefix] above is extracted by `pg_config --configure`.

You can change them using ./configure switches.
See CONFIGURATION section.

CREATING NEW SPATIAL DATABASES
------------------------------

PostGIS support must be enabled for each database that requires
its usage. This is done by feeding the postgis.sql (the enabler script)
file to the target database. 

The enabler script requires the PL/pgSQL procedural language in order
to operate correctly, you can use the 'createlang' program from the
PostgreSQL installation.
(The PostgreSQL Programmer's Guide has details if you want to do this
manually for some reason.)

So, as postgres run:

  createlang plpgsql <yourdatabase>
  psql -f postgis/postgis.sql -d <your_database>

Your database should now be spatially enabled.

UPGRADING EXISTING SPATIAL DATABASES
------------------------------------

Upgrading existing spatial databases can be tricky as it requires
replacement or introduction of new PostGIS object definitions.

Unfortunately not all definitions can be easily replaced in 
a live database, so sometimes your best bet is a dump/reload
process. 

PostGIS provides a SOFT UPGRADE procedure for minor or bugfix
releases, and an HARD UPGRADE procedure for major releases.

--- SOFT UPGRADE ---


Soft upgrade consists of sourcing the postgis_upgrade_*.sql
script in your spatial database:

 * postgis_upgrade_13_to_15.sql, upgrade a 1.3.x database
   to 1.5
 * postgis_upgrade_15_to_15.sql, upgrade a 1.4.x database 
   to 1.5
 * postgis_upgrade_16_minor.sql, upgrade a 1.5.x database
   to the latest minor release

If a soft upgrade is not possible the script will abort and 
no harm will be done. You can then move on to the 
HARD UPGRADE process. Always try a soft upgrade first, they 
are much simpler.

--- HARD UPGRADE ---

Hard upgrade is a PostgreSQL dump/restore procedure combined 
with a filter to selectively update PostGIS functions and 
objects to point to a new library version.

Hard upgrades are required when object definitions have changed,
aggregates have changed or been added, and when the underlying
PostgreSQL database itself has undergone a major update.

For this purpose, PostGIS provides a utility script to restore a dump
in "custom" format. The hard upgrade procedure is as follows:

	# Create a "custom-format" dump of the database you want
	# to upgrade (let's call it "olddb")
	$ pg_dump -Fc olddb olddb.dump

	# Restore the dump while upgrading postgis into
	# a new database. 
        # Note: The new database does NOT have to exist.
	# Let's call it "newdb"
	$ sh utils/postgis_restore.pl postgis.sql newdb olddb.dump > restore.log

	# Check that all restored dump objects really had to be 
        # restored from dump and do not conflict with the 
        # ones defined in postgis.sql
	$ grep ^KEEPING restore.log | less

	# If upgrading from PostgreSQL < 8.0 to >= 8.0 you will 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 HARM !!!!
	$ 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"

	# The spatial_ref_sys table is restored 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 it with the new like this:
	$ psql newdb
	newdb=> DELETE FROM spatial_ref_sys;
	DROP
	newdb=> \i spatial_ref_sys.sql


USAGE
-----

Try the following example SQL statements to create non-OpenGIS tables and 
geometries:

  CREATE TABLE geom_test ( gid int4, geom geometry,name varchar(25) );
  INSERT INTO geom_test ( gid, geom, name ) 
    VALUES ( 1, 'POLYGON((0 0 0,0 5 0,5 5 0,5 0 0,0 0 0))', '3D Square');
  INSERT INTO geom_test ( gid, geom, name ) 
    VALUES ( 2, 'LINESTRING(1 1 1,5 5 5,7 7 5)', '3D Line' );
  INSERT INTO geom_test ( gid, geom, name )
    VALUES ( 3, 'MULTIPOINT(3 4,8 9)', '2D Aggregate Point' );
  SELECT * from geom_test WHERE geom && 'BOX3D(2 2 0,3 3 0)'::box3d;

The following SQL creates proper OpenGIS entries in the SPATIAL_REF_SYS
and GEOMETRY_COLUMNS tables, and ensures that all geometries are created
with an SRID.

  INSERT INTO SPATIAL_REF_SYS
    ( SRID, AUTH_NAME, AUTH_SRID, SRTEXT ) VALUES
    ( 1, 'EPSG', 4269,
      'GEOGCS["NAD83",
        DATUM[
          "North_American_Datum_1983",
          SPHEROID[
          "GRS 1980",
          6378137,
          298.257222101
        ]
      ],
      PRIMEM["Greenwich",0],
      UNIT["degree",0.0174532925199433]]'
    );

  CREATE TABLE geotest (
    id INT4,
    name VARCHAR(32)
    );

  SELECT AddGeometryColumn('db','geotest','geopoint',1,'POINT',2);

  INSERT INTO geotest (id, name, geopoint)
    VALUES (1, 'Olympia', GeometryFromText('POINT(-122.90 46.97)',1));
  INSERT INTO geotest (id, name, geopoint)
    VALUES (2, 'Renton', GeometryFromText('POINT(-122.22 47.50)',1));

  SELECT name,AsText(geopoint) FROM geotest;


--- Spatial Indexes ---

PostgreSQL provides support for GiST spatial indexing. The GiST scheme offers 
indexing even on large objects, using a system of "lossy" indexing where 
a large object is proxied by a smaller one in the index.  In the case 
of the PostGIS indexing system, all objects are proxied in the index by 
their bounding boxes.

You can build a GiST index with:

  CREATE INDEX <indexname> 
    ON <tablename> 
    USING GIST ( <geometryfield> );

Always run the "VACUUM ANALYZE <tablename>" on your tables after
creating an index. This gathers statistics which the query planner
uses to optimize index usage.