[mapserver-users] perl mapscript queryByRect() and queryByPoint() in 3.5

Lowell Filak lfilak at medinaco.org
Thu May 9 08:42:42 EDT 2002


I can't answer all your questions but the combination of $result_cache->{numresults} and $layer->getResult(x) performs the same function as before. I would suggest using a loop based on $result_cache->{numresults} as opposed to $layer->{numlayers}.
I will add some additional clarification to the doc.
I know that with the change to 3.5 the result set is kept as part of the layer instead of in a seperate object.
Lowell

The following message was sent by imap at chesapeake.net on Wed, 08 May 2002 17:06:15 -0400.

> 
> 
> Steve(s) + Lowell + list,
> 
> About these perl mapscript 3.5 changes...
> 
> Ok, I understant $results = layer->{resultcache} part, but
> in $layer->getResult(0), I'm having a bit of trouble with the
> lack of documentation..  does 0 represent the first result
> in the resultcache?  If so, I should be able to iterate the
> $layer->getResult() thru numlayers, is that correct?  The
> reason I am asking about this... In the 3.4 results object,
> there was a method called $result->next() that we used to
> fetch the MS_MULTIPLE results in a for loop.  If the next()
> method is gone is mapserver 3.5, I am wondering why?  
> It seemed to be much cleaner that dealing with shapeitems 
> from a $result = getResult(0); $record = $result->{shapeitem};
> 
> Is there a technical reason for losing the $result->next() 
> method?  Was this something that *needed* to change to 
> accomodate OGR, WMT or some other component?  For a minor
> rev, the impact on mapscript is pretty dramatic and not
> too compatible with the previous version.  I dont mind
> rewriting code in lieu of better methods, functions, etc.
> but my opinion, what we got here isnt as elegant as the previous 
> version...   I guess we just gotta code with the flow.
> 
> Regards,
> 
> Chris Stuber (mapsurfer)
> Silicon Mapping Solutions, Inc
> (410)257-3187
> 
> 
> 
> Lowell Filak wrote:
> > 
> > Actually the result is in $layer->getResult(0) . The layer->{resultcache} is for doing things like $result_cache->{numresults}. And you guessed it, the query...() returns a status.
> > I did have a typo in the latest version of the Perl-MapScript docs that may have confused things but an update should be posted very soon.
> > Also an example of a query is due to be posted to the wiki very soon. (Don't let that stop you from posting your example however).
> > Lowell F.
> > 
> > The following message was sent by imap at chesapeake.net on Wed, 08 May 2002 05:39:25 -0400.
> > 
> > >
> > >
> > > Guys, I wanted to contribute some stuff to the Perl MapScript Wiki,
> > > but when I went to test things out, all my query stuff is broken
> > > under version 3.5/3.6.
> > >
> > > Going over some recent emails in the archive,
> > > it is my understanding that queryByRect($rect) now returns
> > > an integer (I am guessing status) and you have to get the
> > > results from the layer->{'resultcache'}.
> > >
> > > $layer = $querymap->getLayerByName("county");
> > > $status = $map->queryByRect($rect);
> > > print "status of query: ".$status."\n";
> > > $results = $layer->{'resultcache'};
> > > print "number of results: ".$results->{'numresults'}."\n";
> > >
> > > status of query: 1
> > > number of results:
> > >
> > >
> > > ------- mapfile ----------
> > >
> > > LAYER
> > >   NAME county
> > >   TYPE LINE
> > >   STATUS ON
> > >   DATA "dtl_cnty"
> > >   TEMPLATE dummy
> > > END
> > >
> > >
> > > bah...  and queryByPoint() is behaving the same way.
> > > Does anybody have an example of queryByRect() and/or
> > > queryByPoint() working in perl mapscript?
> > >
> > > Regards,
> > >
> > > Chris




More information about the mapserver-users mailing list