Mapscript PostGIS

Stephen Woodbridge woodbri at SWOODBRIDGE.COM
Sat Apr 2 16:36:28 EST 2005


Giridhar Manepalli wrote:
> Hello All,
>
> Usually with Mapserver CGI, we do
> CONNECTIONTYPE POSTGIS
> CONNECTION "blah blah blah"
> Data "<geom> from <table>"
>
> to render onto an image.
>
> How is it possible to create the same thing, but this time the DATA
> should be using Mapscript /PHP
>
> something like :
> $mapObj = ms_newMapObj('<map file>');
> $imageObj = $mapObj->draw();
> $layerObj = $mapObj->getLayerByName('<layer name>');
> $sql = "SELECT <geom> from <TABLE>
> $rs = odbc_exec($conn, $sql);
>
> $polygons = array();
> # use this $rs to create a layer of POLYGONS. It means that <geom> is
> of type POLYGON. Thus $rs has to be populated in $polygons
>
> # something like
> foreach ($polygons => $poly) {
> # Draw the $poly onto the image
> }
>
> In essense, how do I get the shape information of polygons from the
> database using mapscript.
>
> Thanks in advance,.
>
> Giridhar
>

As far as I know you have to "select asText(geom) as geom from <table>"
and then parse the text into arrays to do whatever you want with the it.

-Steve



More information about the mapserver-users mailing list