[mapserver-users] Patch to mappostgis.c (mapserver <-> PostGIS connector)
Dave Blasby
dblasby at refractions.net
Fri May 17 14:29:21 PDT 2002
I've added Sean Gillies (<sgillies at i3.com>)'s earlier patch that made
working with SQL views and complex sub-selects easy.
I've also added support for defining the spatial reference system of
arbitrary queries.
Everyone's map files should work as they did before - this just adds
better functionality!
Your DATA line can have a 'using unique <column name>' tag. This column
will be used by queries to retrieve a single feature - if its
unspecified, the system column "OID" will be used. This was required
because postgreSQL views do not have an OID.
Here's the functionality for the DATA line (this is Sean's patch):
DATA "the_geom from ftab"
DATA "the_geom from ftab using unique ftab_id"
DATA "the_geom from (select * from ftab) as foo using unique ftab_id"
DATA "the_geom from (select ftab_id[,table2_attributes,],bounds from
ftab natural join table2) as foo using unique ftab_id"
Your DATA line can also have a 'using SRID=#' tag (note the capitals in
SRID). You will need to use this if you're executing arbitrary SQL
statements. PostGIS enforces bounding box searches to have the same
spatial referencing system as the data you're querying. This new tag
tells the mapserver<->PostGIS connector the spatial reference system of
the query's resulting geometry. If you dont have this tag, the
connector will attempt to guess the referencing system. If you're using
DATA "<geom column> from <table>" you dont need to have this tag.
DATA "lineargeometry from (select transform(lineargeometry,1) as
lineargeometry,rd_segment_id from geom) as foo using unique
rd_segment_id using SRID=1"
This will tell the connector that you want to use rd_segment_id to
uniquely identify a feature, and that the geometry resulting from the
query will have a SRID of 1.
Its in the CVS archive now.
dave
More information about the MapServer-users
mailing list