[Mapserver-users] shape extent

Ryan, Adam ARyan at co.linn.or.us
Wed Apr 7 16:22:20 EDT 2004


>Does anyone know how to either extract the shape extent for multiple
returns?

There's probably a more elegant/better way to do this, but here's my
function.  If anyone can help simply/enhance this that'd be great.  $l is a
layer object.  $b is the desired buffer as a decimal, ie 0.10.  This assumes
a layer in not tiled.

function getLayerResultExtent($l,$b){
	$l->open();
	$r1 = $l->getResult(0);
	$s1 = $l->getShape(-1,$r1->shapeindex);
	$minx=$s1->bounds->minx;
	$miny=$s1->bounds->miny;
	$maxx=$s1->bounds->maxx;
	$maxy=$s1->bounds->maxy;
	for ($li=1;$li<($l->getNumResults());$li++){
    		$r = $l->getResult($li);
    		$s = $l->getShape(-1,$r->shapeindex);
    		$minx=min($s->bounds->minx,$minx);
		$miny=min($s->bounds->miny,$miny);
		$maxx=max($s->bounds->maxx,$maxx);
		$maxy=max($s->bounds->maxy,$maxy);
	}
	if ($b!=0){
		$dx=($maxx-$minx)*($b);
		$dy=($maxy-$miny)*($b);
		$minx-=$dx;
		$miny-=$dy;	
		$maxx+=$dx;	
		$maxy+=$dy;
	}
	return array($minx,$miny,$maxx,$maxy);
}

Hope it helps,

Adam 
 

-----Original Message-----
From: leo.olivieri at tin.it [mailto:leo.olivieri at tin.it] 
Sent: Wednesday, April 07, 2004 7:47 AM
To: mapserver-users at lists.gis.umn.edu
Subject: [Mapserver-users] shape extent


Hello list,
I use PHP mapscript
I am doing an queryByRect and trying to get the shape extent for all the
polygons returned so I can set a new mapextent for the map.      
Does anyone know how to either extract the shape extent for multiple
returns?

Thanks in advance.
Leonardo Olivieri



_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users



More information about the mapserver-users mailing list