[postgis-users] connecting to postgis form mapserver

Vishal Mehta vishal.mehta at sei-us.org
Thu Aug 18 11:16:35 PDT 2011


David,

I enabled debugging (pl see map file) and got the following error log:
[Thu Aug 18 11:05:26 2011].929000 msPostGISLayerWhichShapes(): Query error. Error (ERROR:  function force_2d(geometry) does not exist

Where should I go from here?
Thanks for the error logging how-to,
V

----------------------
LINE 1: select encode(AsBinary(force_collection(force_2d("geom")),'N...
                                                ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
) executing query: select encode(AsBinary(force_collection(force_2d("geom")),'NDR'),'hex') as geom,"gid" from "wardscleanattributes" where geom && GeomFromText('POLYGON((77.5 12.8982149362477,77.5 13.0617850637523,77.7 13.0617850637523,77.7 12.8982149362477,77.5 12.8982149362477))',4326)
[Thu Aug 18 11:05:26 2011].930000 msDrawMap(): Image handling error. Failed to draw layer named 'wards'.
[Thu Aug 18 11:11:27 2011].929000 msDrawMap(): WMS/WFS set-up and query, 0.000s
[Thu Aug 18 11:11:27 2011].980000 msPostGISLayerWhichShapes(): Query error. Error (ERROR:  function force_2d(geometry) does not exist
LINE 1: select encode(AsBinary(force_collection(force_2d("geom")),'N...
                                                ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
) executing query: select encode(AsBinary(force_collection(force_2d("geom")),'NDR'),'hex') as geom,"gid" from "wardscleanattributes" where geom && GeomFromText('POLYGON((77.5 12.8982149362477,77.5 13.0617850637523,77.7 13.0617850637523,77.7 12.8982149362477,77.5 12.8982149362477))',4326)
[Thu Aug 18 11:11:27 2011].981000 msDrawMap(): Image handling error. Failed to draw layer named 'wards'.
[Thu Aug 18 11:11:27 2011].981000 msFreeMap(): freeing map at 0165CE90.
---------------------------------
MAP
  IMAGETYPE   PNG
  EXTENT	77.5 12.95 77.7 13.01
  SIZE        550 450
  IMAGECOLOR  255 255 255
  SHAPEPATH   "../data"
  CONFIG "MS_ERRORFILE" "../ms_error.txt"
  DEBUG 5
  # Start of LAYER DEFINITIONS-------------------------------
  LAYER 
    CONNECTIONTYPE POSTGIS
	NAME "wards"
    # Connect to a remote spatial database
	CONNECTION "host=localhost port=5432 dbname=bangalore user=postgres password=xxx"
	# Get the lines from the 'geom' column of the 'wards' table 
	DATA 'geom from "wardscleanattributes" using srid=4326 using unique gid'
	STATUS DEFAULT
	TYPE POLYGON 
    CLASS
      NAME "wards"    
      STYLE
        OUTLINECOLOR 255 0 0
      END
    END
  END 
   # End of LAYER DEFINITIONS -------------------------------
END
---------------------------------
-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of David Fawcett
Sent: Wednesday, August 17, 2011 7:33 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] connecting to postgis form mapserver

Vishal,

As Ben said, enabling debugging is the best way to figure out what is going on.

There is some pretty good documentation on how to do that at:
http://mapserver.org/optimization/debugging.html

If that doesn't help you, it is probably time to move this over to the MapServer list.  (Where Ben and I will also be likely hanging out...)

David.


On Wed, Aug 17, 2011 at 7:44 PM, Ben Madin <lists at remoteinformation.com.au> wrote:
> Vishal,
> David has probably nailed this one, but if not or otherwise you might 
> also want to put DEBUG ON into your map and the LAYER definitions (you 
> need both)
> - the debug output from postgis connections is comprehensive if a 
> little complex initially, but very useful for learning.
> It doesn't hurt to explicitly set projections as well, to make sure 
> they match.
> cheers
> Ben
>
>
> On 18/08/2011, at 4:09 AM, Vishal Mehta wrote:
>
> Hi all,
>
> I am testing out mapserver-postgis and a simple test is returning an 
> empty map. Here is my  map file
>
> MAP
>   IMAGETYPE   PNG
>   EXTENT 77.5 12.95 77.7 13.01
>   SIZE        550 450
>   IMAGECOLOR  255 255 255
>   SHAPEPATH   "../data"
>     # Start of LAYER DEFINITIONS-------------------------------
>   LAYER
>     CONNECTIONTYPE POSTGIS
>                 NAME "wards"
>     # Connect to a remote spatial database
>                 CONNECTION "host=localhost port=5432 dbname=empty 
> user=postgres password=xxx"
>                   # Get the lines from the 'geom' column of the 'wards'
> table
>                   DATA 'geom from "myschema.wards198" using srid=4326 
> using unique gid'
>                   STATUS ON
>                   TYPE POLYGON
>
>     CLASS
>       NAME "wards"
>       STYLE
>         OUTLINECOLOR 255 0 0
>       END
>     END
>   END
>
>   # End of LAYER DEFINITIONS ------------------------------- END
> -------------------
> And the html that calls it
> --------------
> <html>
> <head>
> <title>my postgis map</title>
> </head>
> <body bgcolor=white>
> <center>
> <br>
> <table width=570>
> <tr>
>    <td>
>      <br>
>      <img width=550 height=450
>
> src=/cgi-bin/mapserv.exe?map=C:\OSGeo4W/apps/mapserver-tutorial/mytest
> s/example.map&mode=map
>      border=1>
>    </td>
> </tr>
> </table>
> <br>
> </body>
> </html>
> ----------------------------------------------------
> Other info:
> Platform:
> -          Windows 7, postgresql9 , postgis 2.0
> -          I installed Mapserver separately through the OSGEO4 installer.
> -          I can connect to the same database through php
> -          I can create simple mapserver apps using shapefiles etc 
> alright (e.g. same map file above, calling a shapefile, works fine)
> -          Mapserv.exe -v shows that it was installed with postgis support.
> -          Also can Mapserver handle postgis Mulipolygon geometry ok?
>
> I did check most of the points here which seemed ok ( i did not check 
> those in this list that I don't really know how to in Windows ).
> http://trac.osgeo.org/mapserver/wiki/PostGIS
>
> I realize this might be a mapserver mailing list qn, but thought that 
> some of you might know the answer.it might be a simple syntax problem 
> that I've missed.
>
> Thanks,
> Vishal
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list