[mapserver-users] Error Creating View...

Jan Hartmann jhart at frw.uva.nl
Wed Nov 27 05:29:36 EST 2002


João,

This subject has been discussed several times on the  PostGIS-users 
list. A few days ago it has been added to the PostGIS documentation ( 
http://postgis.refractions.net/docs/x549.html#AEN607 ). The thing to 
remember is that PostGIS uses items that are not available in views (or 
subselects): a unique identifier field (called OID in regular tables) 
and a projection number (SRID). Both are automatically available in 
regular tables, but in a view or a subselect you have to add them 
explicitly. You do this by adding "using UNIQUE=<unique variable> using 
SRID=<srid>" to the MapServer DATA statement. Of course, The <unique 
variable> should be included when creating the view.

Hope this helps,

Jan Hartmann

João Mário wrote:
> Hello to all
> 
> I'm using PostGIS and Mapserver  versions 0.7.3 and  3.6.3.
> 
> I'm tried to create a view  from the main table and call it in the 
> mapfile, but it doesn't work....
> 
> The code is this:
> 
> LAYER
>  CONNECTIONTYPE postgis
>  NAME Roads
>  CONNECTION "user=postgres dbname=dbase"
>  DATA "geometry_field  from table_view"
>  FILTER "id_sec=1"
>  STATUS  ON
>  TYPE LINE
> #  LABELITEM "tile_name"
>  CLASS
>   NAME "Road 1"
>   TEMPLATE "Road_1.html"
>   EXPRESSION ([tipo_log]=2)
>   COLOR 85 85 85
>   SYMBOL 'line'
>   SIZE 10
>   MINSIZE 3
>   MAXSIZE 15
>   OVERLAYCOLOR 168 168 0
>   OVERLAYSYMBOL 0
>   OVERLAYSIZE 3
>   OVERLAYMINSIZE 1
>   OVERLAYMAXSIZE 2
>   SIZE 15
>  # LABEL
>  #  TYPE truetype
>  #  FONT arial-bold
>  #  SIZE 14
>  #  ANTIALIAS
>  #  COLOR 0 0 0
>  #  OUTLINECOLOR 255 255 255
>  #  PARTIALS OFF
>  END
>  CLASS
>    NAME "Road"
>    TEMPLATE "Road_2"
>    EXPRESSION ([tipo_log]=1)
>    COLOR 85 85 85
>    SYMBOL 'line'
>    SIZE 5
>    MINSIZE 3
>    MAXSIZE 15
>    OVERLAYCOLOR 255 255 255
>    OVERLAYSYMBOL 0
>    OVERLAYSIZE 3
>    OVERLAYMINSIZE 1
>    OVERLAYMAXSIZE 2
>    SIZE 15
>  END
> END
> 
> when i execute the following error apears:
> 
> msPOSTGISLayerWhichShapes(): Query error. prep_DB:Error executing 
> POSTGIS DECLARE statement (0.6 failed - retried 0.5 and it failed too). 
> DECLARE mycursor BINARY CURSOR FOR SELECT 
> tipo_log::text,asbinary(force_collection(force_2d(geometry_field)),'NDR'),OID::text 
> from table_view WHERE (id_sec=1) and (geometry_field && setSRID( 
> 'BOX3D(1430.3002 760.3,1730.1002 
> 1120.3)'::BOX3D,find_srid('','table_view','geometry_field') ))
> 
> What could be wrong?
> 
> Thanks
> 
> João
> 
> 

Jan Hartmann
Departmen of Geography
University of Amsterdam
jhart at frw.uva.nl




More information about the mapserver-users mailing list