[postgis-users] Querying MapServer PostGIS layer

Dave Stone D.Stone at ed.ac.uk
Thu Apr 13 07:46:29 PDT 2006


Please excuse if this post has been asked before; I'm new to the list 
and finding it difficult to locate all the hidden gems of wisdom!

I'm having a problem with querying a MapServer layer consisting of 
points stored in a PostGIS table. The plan is simple enough: I'm 
displaying the dots together with a boundary and an annotation layer, 
and I want to click on a dot and have a page come up showing non-spatial 
attributes from the PostGIS record for that location.

What happens when I click a dot is I get a completely blank page titled 
'MapServer Message' (but no message). The relevant bit of the MapServer 
.map file is:

   LAYER # query layer using the loccoords PostgreSQL table
     CONNECTIONTYPE postgis
     NAME          saint_locations
     CONNECTION    "user=erdb13 dbname=stdraft"
     DATA          "geom from loccoords using unique locationref using 
srid=27700"
     STATUS        ON
     DEBUG         ON
     TYPE          POINT
     TOLERANCE     25
     CLASS
       NAME        "Locations"
       MINSCALE    2000000
       TEMPLATE    "result.html"
       DEBUG       ON
       STYLE
         SYMBOL      "circle"
         SIZE        5
         COLOR       255 0 0
         OUTLINECOLOR 0 0 0
       END
     END

This whole idea is based on an example in the MapServer tutorial 
(http://hypnos.cbs.umn.edu/tutorial/section3.html, choose Ex.3.1). The 
example works fine, so why doesn't my version?  The answer seems to be 
that the layer being queried in the example is a shapefile whereas mine 
is in PostGIS.  To test this suspicion, I amended the layer definition 
in the .map file as follows:

   LAYER # query layer using the loccoords PostgreSQL table
#   CONNECTIONTYPE postgis
     NAME          saint_locations
#   CONNECTION    "user=erdb13 dbname=stdraft"
     DATA          "/var/www/html/saints/data/parish/locs"
     STATUS        ON

'locs' is a shapefile produced by dumping (with pgsql2shp) the 
'loccoords' table in the first DATA statement above.

With only this trivial change, the query template 'result.html' works as 
intended. But since I want to use the PostGIS functionality, I need to 
find out what's wrong with the first LAYER spec. above.

Any suggestions most gratefully received,

Dave



More information about the postgis-users mailing list