[mapserver-users] Problems getting started with POSTGIS

Jeff Dege jeff.dege at korterra.com
Fri Mar 18 18:25:26 EDT 2011


I'm not seeing the query - I don't think I'm getting that far.

msPostGISWhichShapes called.
msPostGISParseData called.
msPostGISParseData(): Query error. Error parsing PostGIS DATA variable. Must contain 'geometry from table' or geometry from (subselect) as Foo'. County

But playing around, I saw that I was getting the same error regardless of what I put in the DATA variable.  Which made no sense.  I tried stuff that should not have worked at all, and saw no difference.

So I looked beyond my problematic DATA variable - and found another DATA variable, later in the LAYER definition.

If you remember, I started this by copying a mapfile that had been working with shapefiles.  I'd changed the CONNECTIONTYPE, added a CONNECTION, and a new DATA - but I hadn't deleted the old DATA.

Oops.




-----Original Message-----
From: mapserver-users-bounces at lists.osgeo.org [mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Stephen Woodbridge
Sent: Friday, March 18, 2011 4:44 PM
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] Problems getting started with POSTGIS

On 3/18/2011 3:41 PM, Andy Colson wrote:
> On 3/18/2011 11:52 AM, Jeff Dege wrote:
>> I've been using MapServer with shapefiles for some time. I'm trying 
>> to convert a site to PostGIS, and I'm having problems.
>>
>> I've successfully installed PostGIS on my Ubunto 10.04 box, and 
>> copied a number of shapefiles into it, using shp2pgsql. I can view 
>> the new tables using qGIS, so I'm sure the data is right.
>>
>> So now I've copies a mapfile that was working against the original 
>> shapefiles, and I'm trying to convert it to use PostGIS. I'm working 
>> on just one layer, and I'm trying to test that layer with shp2img.
>>
>> I've added to the LAYER definition:
>>
>> LAYER
>>
>> NAME "countyboundaries"
>>
>> CONNECTIONTYPE postgis
>>
>> CONNECTION "host=localhost dbname=test_db user=gis password=xxxxx"
>>
>> DATA "the_geom from gis_schema.county"
>>
>> [...]
>>
>> END
>>
>> As I said, I know the data is in the database, because I can load it 
>> as a PostGIS layer from qGIS. Column and table names are right, 
>> because when I run "select the_geom from gis_schema.county" in the 
>> query tool I get the data.
>>
>> But when I run shp2img from the commandline, I get an error:
>>
>> $ shp2img -m test.map -o test.gif -i GIF -l countyboundaries
>>
>> msDrawMap(): Image handling error. Failed to draw layer named 
>> 'countyboundaries'.
>>
>> msPostGISParseData(): Query error. Error parsing PostGIS DATA variable.
>> Must contain 'geometry
>>
>> from table' or 'geometry from (subselect) as foo'. County
>>
>> shp2img is MapServer version 5.6.6, and the output from -v does 
>> contain "INPUT=POSTGIS".
>>
>> Any ideas? I'm trying to keep things simple, and it's frustrating 
>> when simple doesn't work.
>
> I cant see anything really wrong. I'm doing mostly the same thing.
>
> however:
>
>  > CONNECTION "dbname=test_db user=gis password=xxxxx"
>
> because mapserver and PG run on the same box, I left off the 
> host=localhost... not sure if its important.

Yes, it might be, it depends on how postgresql is configured. You can test it with:

psql -U gis test_db
vs:
psql -U gis -h localhost test_db

>  > DATA "the_geom from gis_schema.county using unique gid using srid=-1"
>
> I also have the unique and srid things, again not sure if there'd be a 
> difference.

This also might be a problem. In general you should not use srid=-1 in the database of in the mapfile. When you load your data you should specify the correct srid and reference in the mapfile.

in your mapfile add:

MAP
   CONFIG MS_ERRORFILE "stderr"
   DEBUG 10

then run your shp2img again and you might get more debug info. You can also add the DEBUG 10 to you LAYER and I think it will spit out the SQL it is trying to execute so you can try it in psql and maybe get helpful messages there.

-Steve W

>
> And as a last hint, you can try bumping up the debug:
>
> MAP
> CONFIG "MS_ERRORFILE" "/tmp/mapserver.log"
> ...
> LAYER
> DEBUG 4
> ...
> END
>
> -Andy
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users


More information about the mapserver-users mailing list