[mapserver-users] New mappostgis.c commited

Dave Blasby dblasby at refractions.net
Fri Jul 5 14:31:27 PDT 2002


I made a few minor changes to mappostgis.c.

(1) Better error message reporting.
(2) bug fix: you can now specify negative numbers in the 'using SRID=#'
portion of a DATA statement


Two of the most common places where people have problems is (1)
connecting to postgresql (2) getting the correct DATA statement.

Below are the two error message it will give when you make a mistake!

CONNECT
-------


Couldnt make connection to DB with connect string '...'.
Error reported was '...'.

This error occured when trying to make a connection to the specified
postgresql server.  
Most commonly this is caused by 
(1) incorrect connection string 
(2) you didnt specify a 'user=...' in your connection string
(3) the postmaster (postgresql server) isnt running 
(4) you are not allowing TCP/IP connection to the postmaster 
(5) your postmaster is not running on the correct port - if its not on
5432 you must specify a 'port=...' 
(6) the security on your system does not allow the webserver (usually
user 'nobody') to make socket connections to the postmaster
(7) you forgot to specify a 'host=...' if the postmaster is on a
different machine
(8) you made a typo


DATA
----

<postgresql error message>

More Help:

Error parsing POSTGIS data variable. You specified ''.
Standard ways of specifiying are :
(1) 'geometry_column from geometry_table'
(2) 'geometry_column from (<sub query>) as foo using unique <column
name> using SRID=<srid#>'

NOTE: for (2) 'using unique' and 'SRID=' are optional, but its highly
recommended that you use them!!!

The most common problem with (1) is incorrectly uploading your data.
There must be an entry in the geometry_columns table. This will be
automatically done if you used the shp2pgsql program or created your
geometry column with the AddGeometryColumn() postgis function.

If you are using the (2) method, you've probably made a typo.
Example: 'the_geom from (select the_geom,oid from mytable) as foo using
unique oid using SRID=76'
This is very much like the (1) example. The subquery ('select
the_geom,oid from mytable') will be executed, and mapserver will use
'oid' (a postgresql system column) for uniquely specifying a geometry
(for mapserver queries). The geometry (the_geom) must have a SRID of 76.

Example: 'roads from (select
table1.roads,table1.rd_segment_id,table2.rd_name,table2.rd_type from
table1,table2 where table1.rd_segment_id=table2.rd_segment_id) as foo
using unique rd_segment_id using SRID=89'

This is a more complex sub-query involving joining two tables. The
resulting geometry (column 'roads') has SRID=89, and mapserver will use
rd_segment_id to uniquely identify a geometry. The attributes rd_type
and rd_name are useable by other parts of mapserver.

NOTE: for the (2) case, the ' as foo ' is requred. The 'using unique
<column>' and 'using SRID=' are case sensitive.
NOTE: 'using unique <column>' would normally be the system column 'oid',
but for views and joins you'll almost certainly want to use a real
column in one of your tables.
NOTE: you'll want to build a spatial index on your geometric data:
CREATE INDEX <indexname> ON <table> USING GIST (<geometrycolumn>
GIST_GEOMETRY_OPS )
You'll also want to put an index on either oid or whatever you used for
your unique column:
CREATE INDEX <indexname> ON <table> (<uniquecolumn>)



More information about the MapServer-users mailing list