QueryByRect problem in PHPmapscript

Bill Thoen bthoen at GISNET.COM
Wed Oct 31 17:14:46 EDT 2007


I've solved part of my problem. Apparently the query function works on 
the native SRS of the target layer, not on the map output SRS.

Then I've seen a reference to getFeature(), supposedly a layer method. 
But this doesn't appear to be the case. In fact, I can't find references 
to getFeature() in the docs; just in old emails by people. Is this a 
valid method for MS 4.10?


Bill Thoen 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