Find a file
Sandro Santilli 0b18670619 initial import
git-svn-id: http://svn.osgeo.org/postgis/trunk@454 b70326c6-7e19-0410-871a-916f4a2858ee
2004-02-28 14:43:39 +00:00
Attic added skeleton functions for pg75 stats integration 2004-02-23 12:18:55 +00:00
doc Added line_interpolate_point entry 2004-01-21 19:11:54 +00:00
examples Fixed syntax error in execution example. 2003-11-25 02:38:23 +00:00
jdbc Change absolute classpath reference to relative. 2004-01-15 00:23:08 +00:00
loader byte endiannes detected empirically 2004-02-09 18:49:23 +00:00
regress Added transaction begin and end. 2003-06-12 22:25:04 +00:00
.cvsignore more cvsignore 2003-11-12 20:59:06 +00:00
CHANGES Updates for 0.8.1 release. 2004-01-12 19:12:01 +00:00
COPYING Initial revision 2001-06-22 17:39:29 +00:00
create_undef.pl Support for 7.3 undefinition. 2002-12-10 04:37:03 +00:00
CREDITS Updates for 0.8.0 release. 2003-11-25 03:03:01 +00:00
Makefile Added detection code for PG75 2004-02-04 22:21:11 +00:00
postgis.h added skeleton functions for pg75 stats integration 2004-02-23 12:18:55 +00:00
postgis.sql.in initial import 2004-02-28 14:43:39 +00:00
postgis_algo.c Added line_interpolate_point function by jsunday@rochgrp.com 2004-01-21 19:04:03 +00:00
postgis_chip.c Added CVS revision headers. 2003-07-01 18:30:55 +00:00
postgis_debug.c Added useless PG_RETURN_NULL() call to make compiler happy 2004-01-13 20:30:19 +00:00
postgis_estimate.c Fixed bugs reported by Mark Cave-Ayland <m.cave-ayland@webbased.co.uk>. 2004-02-26 16:42:59 +00:00
postgis_fn.c changed USE_GEOS check from ifdef / ifndef to if / if ! 2004-02-12 10:34:49 +00:00
postgis_geos.c changed USE_GEOS check from ifdef / ifndef to if / if ! 2004-02-12 10:34:49 +00:00
postgis_geos_wrapper.cpp added missing 'const' in prototypes 2003-12-12 13:34:20 +00:00
postgis_gist_71.c Conformance changes. 2003-08-08 18:19:20 +00:00
postgis_gist_72.c RTContainedBy and RTOverlap strategries implemented locally with a pgbox_overlap function 2004-02-25 13:17:31 +00:00
postgis_inout.c Changed getint and getdouble used by WKB so that it plays nice with 2004-01-13 22:14:25 +00:00
postgis_ops.c expected in-transaction memory release for btree operators 2003-11-20 15:34:02 +00:00
postgis_proj.c moved forward declarations from postgis.h to postgis_proj.c 2004-02-06 00:42:25 +00:00
postgis_transform.c Fix solaris alignment problem in transformations. 2004-01-14 01:52:53 +00:00
README.postgis Updates for 0.8.1 release. 2004-01-12 19:12:01 +00:00
spatial_ref_sys.sql Added BC Albers parameterization (epsg 42102) 2003-08-01 17:44:00 +00:00
TODO Updates for 0.8.0 release. 2003-11-25 03:03:01 +00:00

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

VERSION: 0.8.1 (2004/01/12)

MORE INFORMATION: http://postgis.refractions.net

INTRODUCTION:
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:

  ./      Core source code, makefiles and install directions.
  ./jdbc  Extensions to the PostgreSQL JDBC drivers to support
          the GIS objects. 
  ./doc   Documentation on the code, objects and functions 
          provided. 
  ./loader  A program to convert ESRI Shape files into SQL text
          suitable for uploading into a PostGIS/PostgreSQL database.
  ./examples  Small programs which demonstrate ways of accessing 
          GIS data.
	        

INSTALLATION:

PostGIS is compatible with PostgreSQL 7.1 and above.

To install the module, move this directory to the "contrib" directory of your
PostgreSQL source installation. Alternately, edit the "top_buildir" in the 
Makefile and point it at your PostgreSQL source tree. You must have a 
PostgreSQL source tree, and you must have run succesfully built and installed
it for this to work. 

SEE THE NOTE ON GEOS SUPPORT BELOW FOR SPECIAL COMPILATION INSTRUCTIONS


* PROJ4 SUPPORT: 
  The Proj4 reprojection library is required if you want to use the 
  transform() function to reproject features within the database.
  Install Proj4 in the default location.
  Edit the postgis Makefile and change the USE_PROJ variable to 1
  and ensure that the PROJ_DIR variable points to your Proj4 
  installation location (/usr/local is the default).

* SPATIAL PREDICATE / GEOS SUPPORT:
  The GEOS library provides support for exact topological tests
  such as Touches(), Contains(), Disjoint() and spatial operations
  such as Intersection(), Union() and Buffer(). 
  You can download GEOS from http://geos.refractions.net
  In order to use the GEOS support, you *must* 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

  The initial LDFLAGS variable is passed through to the Makefile and
  adds the C++ library to the linking stage. 
  Once you have compiled PgSQL with C++ support, you can enable GEOS
  support in PostGIS by setting the USE_GEOS variable in the PostGIS
  Makefile to 1, and ensure that the GEOS_DIR variable points to your
  GEOS installation location (/usr/local is the default).
  

To compile PostGIS, as root run:
	
  make
  make install

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

As postgres run:

  createlang plpgsql yourdatabase
  psql -f postgis.sql -d yourdatabase

Installation should now be complete.


UPGRADING:

Upgrading PostGIS can be tricky, because the underlying C libraries which 
support the object types and geometries may have changed between versions.
To avoid problems when upgrading, you will have to dump all the tables
in your database, destroy the database, create a new one, add the PL/pgSQL
language, upload the new postgis.sql file, then upload your database dump:

  pg_dump -t "*" -f dumpfile.sql yourdatabase
  dropdb yourdatabase
  createdb yourdatabase
  createlang plpgsql yourdatabase
  psql -f postgis.sql -d yourdatabase
  psql -f dumpfile.sql -d yourdatabase
  vacuumdb -z yourdatabase

When upgrading to 0.6+, all your geometries will be created with an SRID
of -1. To create valid OpenGIS geometries, you will have to create a 
valid SRID in the SPATIAL_REF_SYS table, and then update your geometries
to reference the SRID with the following SQL (with the appropriate
substitutions:

  UPDATE <table> SET <geocolumn> = SetSRID(<geocolumn>,<SRID>);


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> gist_geometry_ops );

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.

Note that PostgreSQL may occasionally not use the GiST indexes when 
performing searches. If you find your system is not using the 
indexes automatically (use 'EXPLAIN' to see the query plan)
you can force index use with the command: 

  SET ENABLE_SEQSCAN = OFF

Try doing an EXPLAIN on your query before and after the 'enable_seqscan'
command to see the different query plans.