QueryByRect problem in PHPmapscript

Steve Lime Steve.Lime at DNR.STATE.MN.US
Wed Oct 31 14:38:03 PDT 2007


getFeature is the method to use to retreive a feature from a layer. It is a layer method and
exists for both PHP and the SWIG-based bindings. It replaces the getShape method which
I created with stupid parameter orderings that made it impossible to not pass a tile index.

I see that it is missing from the PHP/MapScript docs but is present in the Swig docs. I'll file
a ticket on that one... There's already a note at the bottom of the page but it hasn't been
noticed.

Steve

>>> On 10/31/2007 at 4:14 PM, in message <4728F046.8030702 at gisnet.com>, Bill Thoen
<bthoen at GISNET.COM> wrote:
> 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