[Geomoose-users] query.php problem

Jim Klassen klassen.js at gmail.com
Wed Oct 17 09:53:53 PDT 2012


Yep... I'm on it.



On Oct 17, 2012, at 9:46, Brian Fischer <bfischer at houstoneng.com> wrote:

> Jim or Dan, do you think this should be a patch that goes in?  Seems like it to me.
> 
> Brian Fischer, CFM
> Principal | GIS Project Manager 
> Houston Engineering, Inc.
> O 763.493.4522 | D 763.493.6664 | M 763.229.2734
> 
> -----Original Message-----
> From: geomoose-users-bounces at lists.osgeo.org [mailto:geomoose-users-bounces at lists.osgeo.org] On Behalf Of Matej Mailing
> Sent: Wednesday, October 17, 2012 4:58 AM
> To: Jim Klassen
> Cc: GeoMOOSE Users List
> Subject: Re: [Geomoose-users] query.php problem
> 
> I have changed it this way and it works when there are no results and when there are results, without the need for the nextShape() call:
> 
>                                        for($i = 0; $i < $queryLayer->getNumResults(); $i++) {
>                                                $shape = $queryLayer->getShape($queryLayer->getResult($i));
>                                                if($projection) {
> 
> $shape->project($projection, $LATLONG_PROJ);
>                                                }
>                                                $resultFeatures[] = $shape;
>                                                $numResults += 1;
>                                        }
> 
> In my understanding there must be a loop to fill the $resultFeatures since in mode 'map' they are drawn from it.
> 
> Regards,
> Matej
> 
> 
> 2012/10/16 Jim Klassen <klassen.js at gmail.com>:
>> Ok... looking at the MapServer code, it looks like msQueryByRect eventually calls msLayerWhichShapes, but then steps through all the results using msLayerNextShape and populates the layer's result cache.
>> 
>> So either we need to call whichShapes (instead of queryByRect) before our nextShapes while loop, and then call $map->queryByRect before our processTemplate (which is already there), or we need to call queryByRect and then loop through the result cache.
>> 
>> while($shape = $queryLayer->nextShape()) {
>>        ...
>> }
>> 
>> to
>> 
>> for($i = 0; i < $queryLayer->getNumResults(); i++) {
>>        $shape = $queryLayer->getResult(i);
>>        ...
>> }
>> 
>> Although, since I'm not convinced that the shape re-projection code 
>> will work (it is re-projecting shapes it doesn't "own" and so is 
>> either re-projecting a copy and then throwing out the result or it is 
>> modifying the layer's result cache, which I'm not sure is "legal"), 
>> just setting
>> 
>> $numResults = $queryLayer->getNumResults();
>> 
>> and dropping the while(nextShape) loop may be cleaner.
>> 
>> Thoughts???
>> 
>> On Oct 16, 2012, at 7:07 AM, Matej Mailing wrote:
>> 
>>> Hi,
>>> 
>>> it seems that nextShape() requires a whichShapes() call before. So 
>>> after adding $status = 
>>> $queryLayer->whichShapes($queryLayer->getExtent()); before 
>>> while($shape = $queryLayer->nextShape()) {
>>> 
>>> it works.
>>> 
>>> I don't know how it could work for anyone - perhaps older Mapserver 
>>> didn't have this requirement?
>>> 
>>> Regards,
>>> Matej
>>> 
>>> 2012/10/15 Jim Klassen <klassen.js at gmail.com>:
>>>> The only thing I see is that they may be running different queries.
>>>> 
>>>> The first one (with the while loop) querying a single *layer* (although in theory the loop above that would loop through all the layers).  The second one is querying *map* and returning the processed template.
>>>> 
>>>> 
>>>> On Oct 15, 2012, at 9:02 AM, Matej Mailing wrote:
>>>> 
>>>>> Hi,
>>>>> 
>>>>> we have a problem when using Search with the query.php. The problem 
>>>>> is that we always get a message: "No results found for your query! 
>>>>> " even though I am sure that the item with such an attribute 
>>>>> exists. When turning on the debug mode in query.php the output is:
>>>>> "...
>>>>> queryLayer iterated through
>>>>> Total Results: 0
>>>>> Results from MS: <a id="data-shape="coords"
>>>>> href="javascript:GeoMOOSE.zoomToPointsList(dojo.byId('data-[ID]').g
>>>>> etAttribute("data-shape'),
>>>>> 'EPSG...');">data<br/>\n"
>>>>> 
>>>>> It's strange that the result from MS includes the result with the 
>>>>> correct attributes from the DB, but Total Results is 0.
>>>>> 
>>>>> I have found out that "while($shape = $queryLayer->nextShape()) {"
>>>>> line is never true, therefore the code inside (which does the
>>>>> counting) never executes.
>>>>> 
>>>>> Since we are getting the data back from the Mapserver I suppose the 
>>>>> Mapfile and the Mapbook.xml contents are correct.
>>>>> 
>>>>> What could be wrong here?
>>>>> 
>>>>> Thanks,
>>>>> Matej
>>>>> _______________________________________________
>>>>> Geomoose-users mailing list
>>>>> Geomoose-users at lists.osgeo.org
>>>>> http://lists.osgeo.org/mailman/listinfo/geomoose-users
>>>> 
>> 
> _______________________________________________
> Geomoose-users mailing list
> Geomoose-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geomoose-users


More information about the Geomoose-users mailing list