Friday, 20 October 2017

Error while rendering a layer from postgresql in mapserver


I got a point layer into QGIS from postgresql database. After this I used a plugin to export it to a map file.After exporting the following is the starting of the map file.



 NAME "QGIS-MAP"
# Map image size
EXTENT 59.396660 7.316000 105.983338 35.204001
Imagecolor 255 255 255
SIZE 100 100
UNITS meters
Imagetype jpeg

FONTSET 'C:\ms4w\Apache\htdocs\fontset.txt'


PROJECTION
'proj=longlat'
'datum=WGS84'
'no_defs'

Now when I change the size parameter to 600 400 and the units to dd. It gives me the following error while rendering the layer.


msDrawMap(): Image handling error. Failed to draw layer named 'growth_1'. msPostGISLayerWhichShapes(): Query error. Error executing query: ERROR: column "%growth_1_id%" does not exist LINE 1: ...ary(ST_Force_2D("the_geom"),'NDR'),'hex') as geom,"%growth_1... ^


First of all I am not sure why is it taking units as meter.But if I dont change it to dd , the legends come up but the layer is not rendered. Also the extent which i get is in the range of 100's and not the one which I have defined.


Could someone tell me where is this thing going wrong.


enter image description here




Answer



I assume this relates to Why does Mapserver throw "msQueryByPoint(): Search returned no results."? ? If so and as far as the error you are getting, I suspect its because you have not defined (does not exist?) a pk column in the postgis layer. Your growth_1 layer should include the USING UNIQUE in the DATA keyword e.g.:


CONNECTIONTYPE postgis
CONNECTION "dbname='postgis' host=localhost port=5432 user='postgres' password='xxxxxxx' sslmode=disable"
DATA 'the_geom FROM "growth_1" USING srid=4326 USING unique [your_pk_column]'

I am not sure, but I pressume that if you don't define the unique column mapserver will assume its called [layer_name]_id and this is why you are getting this error.


Also, have a look at the mapserver documentation here and here


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...