Try the following:

DATA "centroid(the_geom) as the_geom from mytable"

It seems to work fine for me.

Robert W. Burgholzer
Surface Water Modeler
Office of Water Supply and Planning
Virginia Department of Environmental Quality
[EMAIL PROTECTED]
804-698-4405
Open Source Modeling Tools:
http://sourceforge.net/projects/npsource/

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jochen
Wagner
Sent: Tuesday, November 25, 2008 5:55 AM
To: [email protected]
Subject: [mapserver-users] SQL for Point-Centroid

Hi,
I have a polygon-layer from a postgis-table:

LAYER
  NAME "polylayer"
  TYPE polygon
  STATUS on
  CONNECTIONTYPE postgis
  CONNECTION "user=postgres password=mypass dbname=mydb host=localhost
port=5432"
  DATA "the_geom from mytable using unique gid"
  TEMPLATE "template/query.html"
     CLASS
        NAME "Polylayer"
                STYLE           
                COLOR 0 100 100 
                OUTLINECOLOR 0 50 50
                WIDTH 2
                END
     END  # CLASS
END

I want to add a point-layer in my mapfile with the centroid of the
polygonlayer, this SQL works:
SELECT x(ST_Centroid(the_geom)) AS xvar, y(ST_Centroid(the_geom)) AS
yvar FROM  mytable

My Point-Layer:

LAYER
  NAME "pointlayer"
  TYPE point
  STATUS on
  CONNECTIONTYPE postgis
  CONNECTION "user=postgres password=mypass dbname=mydb host=localhost
port=5432"
  DATA "?????????????????????????????????????????????"
  TEMPLATE "template/query.html"
    CLASS
     NAME "Pointlayer"
        COLOR 255 0 0
        SYMBOL 'circle'
            SIZE 10
     END  # CLASS
END

My Question: How can I use my SQL in Mapserver?

Thanks
Jochen
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to