From: Sandro Santilli Date: Fri, 8 Oct 2004 10:48:59 +0000 (+0000) Subject: Some updates X-Git-Tag: pgis_1_0_0RC1~315 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=445563a9386ef4b4b32d8a1d35b78c8fcf02eb52;p=postgis Some updates git-svn-id: http://svn.osgeo.org/postgis/trunk@963 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/doc/postgis.xml b/doc/postgis.xml index 77a27a0fd..0836d038c 100644 --- a/doc/postgis.xml +++ b/doc/postgis.xml @@ -462,7 +462,7 @@ You can store point, line, polygon, multipoint, multiline, multipolygon, and geometrycollections. These are specified in the - Open GIS Well Known Text Format (with 3d extentions). + Open GIS Well Known Text Format (with XYZ,XYM,XYZM extentions). @@ -477,7 +477,7 @@ psql and try the following SQL: CREATE TABLE gtest ( ID int4, NAME varchar(20) ); -SELECT AddGeometryColumn('dbname','gtest','geom',-1,'LINESTRING',2); +SELECT AddGeometryColumn('gtest','geom',-1,'LINESTRING',2); If the geometry column addition fails, you probably have not loaded the PostGIS functions and objects into this database. See the @@ -706,7 +706,19 @@ AND - POINT(0 0 0) + POINT(0 0) -- XY + + + + POINT(0 0 0) -- XYZ + + + + POINTM(0 0 0) -- XYM + + + + POINT(0 0 0 0) -- XYZM @@ -738,14 +750,16 @@ AND - Note that in the examples above there are features with both - 2-dimensional and 3-dimensional coordinates. PostGIS supports both 2D - and 3D coordinates -- if you describe a feature with 2D coordinates when - you insert it, the database will return that feature to you with 2D - coordinates when you extract it. See the sections on the force_2d() and force_3d() functions for information on - converting features to a particular coordinate dimension + Note that in the examples above there are features with + 2-dimensional, 3-dimensional (XYZ,XYM) and 4-dimensional coordinates. + PostGIS supports 2D,3DZ,3DM and 4D coordinates -- if you describe a + feature with 2D coordinates when you insert it, the database will + return that feature to you with 2D coordinates when you extract it. + See the sections on the force_2d(), + force_3dz(), + force_3dm() and + force_4d() functions for information + on converting features to a particular coordinate dimension representation. @@ -780,20 +794,22 @@ VALUES ( text representation which includes all the information necessary to construct the object. Unlike the OpenGIS standard forms, it includes the type, coordinate, and SRID information. The - canonical form is the default form returned from a SELECT query. The - example below shows the difference between the OGC standard and + canonical form is the default form returned from a SELECT query. + Since version 1.0.0 the canonical form is an HEX-encoded WKB with + an optional SRID=#; prefix. + The example below shows the difference between the OGC standard and PostGIS canonical forms: - db=> SELECT AsText(geom) AS OGCGeom FROM thetable; + db=> SELECT AsText(geom) AS OGCGeom FROM SPATIALTABLE; OGCGeom ------------------------------------------------- -LINESTRING(-123.741378393049 48.9124018962261,-123.741587115639 48.9123981907507) +POINT(-126.4 45.32) (1 row) db=> SELECT geom AS PostGISGeom FROM thetable; PostGISGeom ------------------------------------------------- -SRID=123;LINESTRING(-123.741378393049 48.9124018962261,-123.741587115639 48.9123981907507) +SRID=312;01010000009A99999999995FC0295C8FC2F5A84640 (1 row) @@ -964,7 +980,7 @@ SRID=123;LINESTRING(-123.741378393049 48.9124018962261,-123.741587115639 48.9123 COORD_DIMENSION - The spatial dimension (2 or 3 dimensional) of the + The spatial dimension (2, 3 or 4 dimensional) of the column. @@ -985,7 +1001,9 @@ SRID=123;LINESTRING(-123.741378393049 48.9124018962261,-123.741587115639 48.9123 The type of the spatial object. To restrict the spatial column to a single type, use one of: POINT, LINESTRING, POLYGON, - MULTPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION. + MULTPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION or + corresponding XYM versions POINTM, LINESTRINGM, POLYGONM, + MULTPOINTM, MULTILINESTRINGM, MULTIPOLYGONM, GEOMETRYCOLLECTIONM. For heterogeneous (mixed-type) collections, you can use "GEOMETRY" as the type. @@ -1014,28 +1032,38 @@ SRID=123;LINESTRING(-123.741378393049 48.9124018962261,-123.741587115639 48.9123 Add a spatial column to the table using the OpenGIS - "AddGeometryColumn" function. The syntax is: - AddGeometryColumn(<db_name>, <table_name>, + "AddGeometryColumn" function. + + The syntax is: + AddGeometryColumn(<schema_name>, <table_name>, + <column_name>, <srid>, <type>, + <dimension>) + + Or, using current schema: + AddGeometryColumn(<table_name>, <column_name>, <srid>, <type>, - <dimension>). + <dimension>) + - For example: SELECT AddGeometryColumn('roads_db', + Example1: SELECT AddGeometryColumn('public', + 'roads_geom', 'geom', 423, 'LINESTRING', 2) + Example2: SELECT AddGeometryColumn( 'roads_geom', 'geom', 423, 'LINESTRING', 2) Here is an example of SQL used to create a table and add a - spatial column (assuming the db is "parks_db" and that an SRID of 128 + spatial column (assuming that an SRID of 128 exists already): - CREATE TABLE PARKS ( PARK_ID int4, PARK_NAME varchar(128), PARK_DATE date, PARK_TYPE varchar(2) ); -SELECT AddGeometryColumn('parks_db', 'parks', 'park_geom', 128, 'MULTIPOLYGON', 2 ); + 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 ); Here is another example, using the generic "geometry" type and the undefined SRID value of -1: - CREATE TABLE ROADS ( ROAD_ID int4, ROAD_NAME varchar(128) ); -SELECT AddGeometryColumn( 'roads_db', 'roads', 'roads_geom', -1, 'GEOMETRY', 3 ); + CREATE TABLE roads ( ROAD_ID int4, ROAD_NAME varchar(128) ); +SELECT AddGeometryColumn( 'roads', 'roads_geom', -1, 'GEOMETRY', 3 ); @@ -1135,7 +1163,7 @@ COMMIT; -k - Keep column names upper case. + Keep idendifiers case (column, schema and attributes). Note that attributes in Shapefile are all UPPERCASE. @@ -1153,13 +1181,13 @@ COMMIT; An example session using the loader to create an input file and uploading it might look like this: - # shp2pgsql shaperoads roadstable roadsdb > roads.sql + # shp2pgsql shaperoads myschema.roadstable > roads.sql # psql -d roadsdb -f roads.sql A conversion and upload can be done all in one step using UNIX pipes: - # shp2pgsql shaperoads roadstable roadsdb | psql -d roadsdb + # shp2pgsql shaperoads myschema.roadstable | psql -d roadsdb