From: Regina Obe Date: Thu, 22 Mar 2012 13:29:25 +0000 (+0000) Subject: explain geometry_columns is now a view and that spatial tables can be created in... X-Git-Tag: 2.0.0rc1~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3dd2db8a79d73159a37ab7db31bdcda4414c649;p=postgis explain geometry_columns is now a view and that spatial tables can be created in 1 step. git-svn-id: http://svn.osgeo.org/postgis/trunk@9525 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/using_postgis_dataman.xml b/doc/using_postgis_dataman.xml index 6553654c2..b71e3ed00 100644 --- a/doc/using_postgis_dataman.xml +++ b/doc/using_postgis_dataman.xml @@ -595,22 +595,25 @@ The GEOMETRY type calculates a meaningless cartesian distance between Reykjavik - The GEOMETRY_COLUMNS Table - - The GEOMETRY_COLUMNS table definition is as - follows: - - CREATE TABLE geometry_columns ( - f_table_catalog VARRCHAR(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 -) - - The columns are as follows: + The GEOMETRY_COLUMNS VIEW + + In versions of PostGIS prior to 2.0.0, geometry_columns was a table that could be directly edited, and sometimes got out of synch with the actual definition of the geometry columns. + In PostGIS 2.0.0, GEOMETRY_COLUMNS became a view with the same front-facing structure as prior versions, but not reading from database system catalogs + It's structure is as follows: + + \d geometry_columns + View "public.geometry_columns" + Column | Type | Modifiers +-------------------+------------------------+----------- + f_table_catalog | character varying(256) | + f_table_schema | character varying(256) | + f_table_name | character varying(256) | + f_geometry_column | character varying(256) | + coord_dimension | integer | + srid | integer | + type | character varying(30) | + + The column meanings have not changed from prior versions and are: @@ -677,19 +680,27 @@ The GEOMETRY type calculates a meaningless cartesian distance between Reykjavik Creating a Spatial Table - Creating a table with spatial data is done in two stages: + Creating a table with spatial data, can be done in one step. As shown in the following example + which creates a roads table with a 2D linestring geometry column in WGS84 long lat + CREATE TABLE ROADS ( ID int4 + , ROAD_NAME varchar(25), geom geometry(LINESTRING,4326) ); + + We can add additional columns using standard ALTER TABLE command as we do in this next example where we add a 3-D linestring. + ALTER TABLE roads ADD COLUMN geom2 geometry(LINESTRINGZ,4326); + + For backwards compability, you can still create a spatial table in two stages using the management functions. Create a normal non-spatial table. - For example: CREATE TABLE ROADS_GEOM ( ID int4, NAME + For example: CREATE TABLE ROADS ( ID int4, ROAD_NAME varchar(25) ) Add a spatial column to the table using the OpenGIS - "AddGeometryColumn" function. + "AddGeometryColumn" function. Refer to for more details. The syntax is: AddGeometryColumn( <schema_name>, @@ -707,9 +718,9 @@ The GEOMETRY type calculates a meaningless cartesian distance between Reykjavik ) Example1: SELECT AddGeometryColumn('public', - 'roads_geom', 'geom', 423, 'LINESTRING', 2) + 'roads', 'geom', 423, 'LINESTRING', 2) - Example2: SELECT AddGeometryColumn( 'roads_geom', + Example2: SELECT AddGeometryColumn( 'roads', 'geom', 423, 'LINESTRING', 2) @@ -726,13 +737,13 @@ The GEOMETRY type calculates a meaningless cartesian distance between Reykjavik SELECT AddGeometryColumn('parks', 'park_geom', 128, 'MULTIPOLYGON', 2 ); Here is another example, using the generic "geometry" type and the - undefined SRID value of -1: + undefined SRID value of 0: CREATE TABLE roads ( road_id INTEGER, road_name VARCHAR ); -SELECT AddGeometryColumn( 'roads', 'roads_geom', -1, 'GEOMETRY', 3 ); +SELECT AddGeometryColumn( 'roads', 'roads_geom', 0, 'GEOMETRY', 3 );