Find a file
Sandro Santilli 58289f3a92 SnapToGrid: Fixed minor bug in consistency check.
git-svn-id: http://svn.osgeo.org/postgis/trunk@1447 b70326c6-7e19-0410-871a-916f4a2858ee
2005-02-25 13:42:38 +00:00
doc Removed PGSQL7.1 references, clearly stated support starting from 72. 2005-02-09 11:53:20 +00:00
examples Fixed path to lwpostgis.sql script 2005-02-22 09:59:21 +00:00
jdbc Patches from Alex Bodnaru (debian maintainer) 2005-02-22 12:31:31 +00:00
jdbc2 Fixed makefile to allow compilation via kaffe javac - this 2005-02-24 14:13:15 +00:00
loader Added -Wall to CFLAGS 2005-02-10 16:34:26 +00:00
lwgeom SnapToGrid: Fixed minor bug in consistency check. 2005-02-25 13:42:38 +00:00
regress Added a couple of distance() tests. 2005-02-10 17:38:20 +00:00
utils Added wkb_recv and wkb_send obsoleted functions handling 2005-02-17 08:36:54 +00:00
.cvsignore Applied Markus Shaber patches. 2005-01-31 17:17:06 +00:00
CHANGES added force_collection early return 2005-02-25 09:34:07 +00:00
configure.in Changed --with-geos arg to express GEOS_DIR (is more intuitive). 2005-01-28 16:10:10 +00:00
COPYING Initial revision 2001-06-22 17:39:29 +00:00
create_undef.pl Added missing required parameter to usage string 2004-08-08 18:09:01 +00:00
CREDITS Changes in preparation for 1.0.0RC1 2004-12-17 06:53:09 +00:00
geos_version.sh Bug fix in GEOS version extractor. 2004-10-26 16:48:25 +00:00
make_dist.sh Added autoconf invokation 2005-01-25 08:48:44 +00:00
Makefile lwpostgis.sql copy moved from root to lwgeom/Makefile 2004-12-13 13:04:41 +00:00
Makefile.config Moved YACC default value set from inner to config Makefile. 2005-01-24 15:16:25 +00:00
Makefile.config.in Removed ?= construct in FLEX/YACC rules 2005-01-25 13:52:42 +00:00
README.postgis Updated 1.0.0 release date and changed version to 1.0.0RC1 2005-01-13 09:42:40 +00:00
spatial_ref_sys.sql Hand edit paris central meridian definitions. 2005-02-23 19:17:31 +00:00
TODO Updated 1.0.0 release date and changed version to 1.0.0RC1 2005-01-13 09:42:40 +00:00

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

VERSION: 1.0.0 (2005/01/13)

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:

  ./          Build scripts and install directions.
  ./lwgeom    Library source code.
  ./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
              and a program for converting PostGIS spatial tables into
              Shape files..
  ./examples  Small programs which demonstrate ways of accessing 
              GIS data.
	        

INSTALLATION:

PostGIS is compatible with PostgreSQL 7.2 and above.

To install the module, move this directory to the "contrib" directory of your
PostgreSQL source installation. Alternately, point PGSQL_SRC at your
PostgreSQL source tree either in an environment variable or editing 
Makefile.config.

You *must* have a PostgreSQL source tree, and you *must* have succesfully
built and installed it for this to work. 

SEE THE NOTE ON GEOS SUPPORT BELOW FOR SPECIAL COMPILATION INSTRUCTIONS


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

    http://www.remotesensing.org/proj

  Install Proj4 in the default location.
  Edit the postgis Makefile.config 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 (Recommended):
  The GEOS library provides support for exact topological tests
  such as Touches(), Contains(), Disjoint() and spatial operations
  such as Intersection(), Union() and Buffer().  

    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.
  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.config 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 lwpostgis.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 lwpostgis.sql -d yourdatabase
  psql -f dumpfile.sql -d yourdatabase
  vacuumdb -z yourdatabase

You might find the utils/postgis_restore.pl useful. It will
automatically create a new db, feed it the  lwpostgis.sql file
and restore all but postgis objects from a 'custom' dump.
Run with no args to have a usage string printed.


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.