[mapserver-users] SQL for Point-Centroid

Jochen Wagner jochen.wagner8 at googlemail.com
Tue Nov 25 02:55:22 PST 2008


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



More information about the MapServer-users mailing list