QueryByRect problem in PHPmapscript

Steve Lime Steve.Lime at DNR.STATE.MN.US
Wed Oct 31 14:10:52 PDT 2007


What does the corresponding layer definition look like? Are you sure you're grabbing the states
layer - I mean, have you tried getLayerByName instead?

Steve

>>> On 10/31/2007 at 2:58 PM, in message <4728DE56.3010906 at gisnet.com>, Bill Thoen
<bthoen at GISNET.COM> wrote:
> I'm trying to understand how to do querying via PHP mapscript, and I 
> don't understand the results I'm getting. Basically I'm querying a 
> polygon layer of US States with a rectangle that intersects 8 states in 
> the upper midwest. It fully encloses two of these. The following script 
> seems to find only one result and it says the shapeindex is 42. Now I 
> know this is the answer to the meaning of life, the universe and 
> everything, but how do I use this to get a list of the state names that 
> were found (and why is it only returning 1 found?)
> 
> What I want to do eventually is display these states on the map in a 
> highlighting color to show they were selected. If I'm going about this 
> all wrong, could somebody clue me in?
> 
>    $rect = ms_newRectObj();
>    $rect->setextent(-50000, -50000, 50000, 50000);
>    $lyr = $map->getLayer(1);  // states layer
>    $results = $lyr->queryByRect($rect);
>    if ($results == MS_FAILURE) {
>       echo "Nothing found.<br />";
>    } else {
>       echo "Found " . $lyr->getNumResults()."<br />";
>       for ($i=0; $i<$lyr->getNumResults(); $i++) {
>          $rcache = $lyr->getResult($i);
>          echo "   shapeindex: ".$rcache->shapeindex;
>       }
>    }
>    $rect->free();



More information about the MapServer-users mailing list