[mapserver-users] SQL for Point-Centroid

Sture Dingsøyr candalt at online.no
Tue Nov 25 06:20:48 EST 2008


Hi...

What you have to do is make shure that your SQL returns a valid geometry..

Your SQL returns 2 colummns containing x and y coordinate...

Try something like this:

the_geom FROM (SELECT gid, GeometryFromText('POINT(' || x(Centroid(the_geom)) || ' ' || y(Centroid(the_geom)) || ')', 32633) AS the_geom FROM mytable) AS mytable USING UNIQUE GID

Where , 32633 = the EPSG code (coordinate system)

Sture



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
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users



More information about the mapserver-users mailing list