[mapserver-users] Trouble connecting to PostGIS

Bistrais, Bob Bob.Bistrais at maine.gov
Mon Feb 13 14:38:51 PST 2012


I changed my Data statement similar to what you did here, Brent, and it
still comes up with an error, but the message shows that there is
something wrong with the select statement, so maybe this is another
clue:

 

prepare_database(): Query error. Error declaring cursor: ERROR:  syntax
error at or near "select"

LINE 1: ..._2d(the_geom)),'NDR'),gid::text from Metwp100Poly(select *
f...

                                                             ^

 

With query string: DECLARE mycursor BINARY CURSOR FOR SELECT
asbinary(force_collection(force_2d(the_geom)),'NDR'),gid::text from
Metwp100Poly(select * from Metwp100Poly where land='y') as foo WHERE
the_geom && setSRID('BOX3D(134000 4692598.18523154,890900
5307401.81476846)'::BOX3D, 26919 )

 

________________________________

From: pcreso at pcreso.com [mailto:pcreso at pcreso.com] 
Sent: Monday, February 13, 2012 5:01 PM
To: mapserver-users at lists.osgeo.org; Bistrais, Bob
Subject: Re: [mapserver-users] Trouble connecting to PostGIS

 

Hi Bob,


I suggest you try testing with QGIS.

Easy to open the native postgis table & a mapserver WFS/WMS layer
concurrently to ensure it is all working as it should.

Also ensure you have configured your Postgis (Postgres) database to
allow applications such as mapserver to connect. For testing purposes,
set access to the database to trusted for all in pb_hba.conf, & enable
external connections in postgresql.conf, then restart the server to
ensure the changes are activated.

You can also enable mapserver debugging & specify a log file to see what
error is reported.
http://mapserver.org/optimization/debugging.html

You may also need to specify the unique ID column name & the SRID you
are using in your DATA string, much like this one:
DATA "track_line from (select * from trip_track where trip_code =
'ind0701') as foo using unique id using srid 4326"

HTH,

   Brent Wood

--- On Tue, 2/14/12, Bistrais, Bob <Bob.Bistrais at maine.gov> wrote:


From: Bistrais, Bob <Bob.Bistrais at maine.gov>
Subject: [mapserver-users] Trouble connecting to PostGIS
To: mapserver-users at lists.osgeo.org
Date: Tuesday, February 14, 2012, 10:11 AM

First of all, let me state that I am brand new to PostGIS and don't know
much about what I'm doing with it.  That being said, I am having trouble
displaying a PostGIS layer through MapServer.

 

Right now I'm just experimenting with PostGIS and simply trying to get a
layer to display.  I installed the Postgre and PostGIS 1.5.  I used the
shapefile loader to convert a couple shapefiles to PostGIS data.
Looking in pgAdmin, I see the tables do indeed exist for these layers.

 

So I built a MapServer map file.  Here is my connection strings:

 

DATA "the_geom from MylayerPoly"

CONNECTION "user=postgisuser password=MyPassword! dbname=postgistest
host=localhost port=5432"

CONNECTIONTYPE postgis

 

But the layer does not display.  Incidentally, I'm using GeoMoose as a
front end for testing, but that shouldn't matter here.

 

I did a mapserv -v at commandline, and I see the parameter
INPUT=POSTGIS.

 

So as far as I know it should work. Can anyone offer suggestions as to
what I'm doing wrong?

 

Thanks,

Bob


-----Inline Attachment Follows-----

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

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20120213/2ecda5d3/attachment.htm>


More information about the MapServer-users mailing list