[mapserver-users] Problems getting started with POSTGIS

Andy Colson andy at squeakycode.net
Fri Mar 18 15:41:19 EDT 2011


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.

 > 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.


And as a last hint, you can try bumping up the debug:

MAP
	CONFIG "MS_ERRORFILE" "/tmp/mapserver.log"
...
	LAYER
		DEBUG 4
		...
	END

-Andy


More information about the mapserver-users mailing list