[mapserver-users] Re: [UMN_MAPSERVER-USERS] Mapscript Question

Paul Moen pmoen at nd.gov
Fri Feb 29 10:18:30 EST 2008


It will give you the bounding coordinates of the all the shapes in your
result.  

We use it to dynamically zoom in on the results from our query.  It works
fine for our purposes.

Keep in mind that you can get most everything you need from shape objects
that the loop iterates through.  You can parse out the lines, get the wkt,
centroid or whatever you want.

Check out 
http://mapserver.gis.umn.edu/docs/reference/phpmapscript-class/classes/shape
obj

Hope this helps,

Paul

On 2/29/08 7:54 AM, "Pearson, Gregory" <Gregory.Pearson at baltimorecity.gov>
wrote:

> Thanks, Paul. I was hoping the API provided this function. So, you¹re saying I
> can derive the coordinates from the min/max X and Y points? Have you
> implemented this?
>  
> Greg
>  
> 
> 
> From: Paul Moen [mailto:pmoen at nd.gov]
> Sent: Thursday, February 28, 2008 4:16 PM
> To: Pearson, Gregory; MAPSERVER-USERS at LISTS.UMN.EDU
> Subject: Re: [UMN_MAPSERVER-USERS] Mapscript Question
>  
> You could try to use the bounds and loop through the results.
> 
>     $test=@$qlayer->queryByAttributes($item,$temptest,MS_MULTIPLE);
>     if ($test == MS_SUCCESS) {
>             $minX=-1;
>             $minY=-1;
>             $maxX=-1;
>             $maxY=-1;
>             for ($ind = 0;$ind<$qlayer->getNumResults();$ind++) {
>                 $result = $qlayer->getResult($ind);
>                 $shpindex = $result->shapeindex;
>                 $tilindex = $result->tileindex;
>                 $shptemp = $qlayer->getShape($tilindex,$shpindex);
>                 $rec = $shptemp->bounds;
>                 if ($minX == -1 or $minX > $rec->minx)
> $minX=Round($rec->minx);
>                 if ($minY == -1 or $minY > $rec->miny)
> $minY=Round($rec->miny);
>                 if ($maxX == -1 or $maxX < $rec->maxx)
> $maxX=Round($rec->maxx);
>                 if ($maxY == -1 or $maxY < $rec->maxy)
> $maxY=Round($rec->maxy);
>             }
>     }
> 
> On 2/28/08 2:23 PM, "Pearson, Gregory" <Gregory.Pearson at BALTIMORECITY.GOV>
> wrote:
> I am doing a layer search using the method queryByAttributes and want to know
> if I can get the map coordinates from the result. So far, I haven¹t seen
> anything in the API documentation that supports this. Is this possible?
>  
> Greg
> 
> 
> Paul
> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080229/354ab50c/attachment-0001.html


More information about the mapserver-users mailing list