[mapserver-users] POSTGIS/Mapscript DB connection is not closing
Richard Greenwood
Rich at GreenwoodMap.com
Mon Feb 4 20:14:25 PST 2002
Are you referring to the postmaster or psql? Nobody should shut down
postmaster except the postgres user or the OS, but if you have the psql
monitor running, you will see a bunch of stuff. You can ignore it, hit
<enter> to get back to the psql prompt, or just don't run psql.
>After I use mapscript to query my postgis layer in my map, the
>postmaster that got run never dies/closes?
>
>Anyone have any idea on why this might be happening?
>Hhere is an exerpt of the offending mapscript code...
>
> //turn the point where the user clicked on the image into a lat/long
>co-ordinate
> $pt = ms_newPointObj();
> $lat = get_lat($map->extent->minx, $map->extent->maxx, $img_x,
>700);
> $long = get_long($map->extent->miny, $map->extent->maxy, $img_y,
>350);
> $pt->setXY($lat, $long);
> //query the postgis layer
> $layer = $map->getLayer(5);
> $err = @$layer->queryByPoint($pt, MS_MULTIPLE, $missby);
>
> if($err == MS_FAILURE){
> echo "<font size=4 color=red>There were no results found, try
>zooming in closer.</font>";
> }else if( $err == MS_SUCCESS){
> $layer->open($img->shapepath);
> //save the query results into an array
> $i=0;
> $result = $layer->getResult($i);
> while($result != FALSE && $i < 5){
> $shape = $layer->getShape($result->tileindex,
>$result->shapeindex);
> $value = $shape->values;
> $val[$i] = $value;
> $i++;
> $result = $layer->getResult($i);
> }
> $results_found =1;
> }
> $layer->close;
>
>
>
>As well as the postgid layer in the mapfile:
>LAYER
> CONNECTIONTYPE postgis
> NAME "mypostgis"
> DATA "point from usage_points"
> CONNECTION "host=ox user=postgres port=5555 dbname=postgis_usage"
> STATUS DEFAULT
> TYPE POINT
> CLASS
> TEMPLATE query.html
> MINSIZE 10
> SYMBOL star
> COLOR 250 0 25
> END
> END
>
>,thanks
>-Jeff
Richard W. Greenwood, PLS
Greenwood Mapping, Inc.
Rich at GreenwoodMap.com
(307) 733-0203
http://www.GreenwoodMap.com
More information about the MapServer-users
mailing list