I've just installed MapServer on a linux server and I am trying to understand how to display a basic map using a PostGIS database. I have displayed a shapefile in the browser, so I know that the mapserver setup works. My mapfile is as follows:
MAP
NAME "sample"
EXTENT -180 -90 180 90 # Geographic
SIZE 800 400
LAYER
CONNECTIONTYPE postgis
NAME "roads"
CONNECTION "user=username password=**** dbname=databasename host=hostdb.com port=5432"
DATA "geom from public."MLSOA""
STATUS ON
TYPE LINE
CLASS
STYLE
COLOR 0 0 0
END
END
END
END # end of map file
I then call this by using a url string:
http://mysite.com/mapserv.cgi?map=/home/user/webapps/htdocs/mapfile_pg.map&layer=roads&mode=map
However, I get the error:
loadLayer(): Unknown identifier. Parsing error near (MLSOA_London):(line 11)
I have also tried calling my database just MLSOA
and 'MLSOA'
. If I use the line DATA "geom from MLSOA"
I get the following error:
msDrawMap(): Image handling error. Failed to draw layer named 'roads'. msPostGISLayerWhichShapes(): Query error. Error (ERROR: relation "mlsoa" does not exist ) executing query: select encode(ST_AsBinary(ST_Force_2D("geom"),'NDR'),'hex') as geom,"gid" from MLSOA where geom && GeomFromText('POLYGON((-180.225563909774 -90,-180.225563909774 90,180.225563909774 90,180.225563909774 -90,-180.225563909774 -90))',find_srid('','MLSOA','geom'))
I think that the problem is with the table name, but I'm not sure how it should be named. Using pgAdminIII, if I want to run a query on this table I use the following syntax:
select getsrid(the_geom) from public."MLSOA" limit 10
What is the correct syntax for my mapfile?
Answer
Postgres naming is case sentitive (it's the only one db that I'm aware of that has this feature) that is why you have to use the double quotes in your query in pgAdmin.
In the .map file Unix-style escaping should work:
DATA "geom from public.\"MLSOA\""
Manual registration of the geometry column(s) can be performed as documented here:
http://postgis.refractions.net/docs/ch04.html#Manual_Register_Spatial_Column
No comments:
Post a Comment