queryUsingPoint problems
Stephen Lime
steve.lime at dnr.state.mn.us
Fri Sep 8 13:05:54 PDT 2000
To clarify, the layer must have STATUS ON, DEFAULT or QUERYONLY and
yes must have a single QUERY object defined. The following will work (QUERYITEM
is not required)
QUERY
TEMPLATE "foo"
END
That's it.
Steve
Stephen Lime
Internet Applications Analyst
Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937
>>> Daniel Morissette <danmo at videotron.ca> 09/08/00 02:40PM >>>
Hi,
I have used the $map->queryUsingPoint() for quite a while and I know it
works for sure.
However, for a layer to be queryable, its status must be ON or
QUERYONLY, and it must have a QUERYITEM and at least one QUERY object,
otherwise it appears to be ignored in the query:
LAYER
...
QUERYITEM "anyfield"
QUERY
EXPRESION /./
TEMPLATE "ttt"
END
END
BTW, there is a mistake in the PHP documentation, I'll fix it. The
method does indeed return a queryResultObj, and the pointObj (query
location) should be specified in georeferenced map coordinates, not
pixels.
I hope that helps,
--
------------------------------------------------------------
Daniel Morissette danmo at videotron.ca
http://pages.infinit.net/danmo/
------------------------------------------------------------
Don't put for tomorrow what you can do today, because if
you enjoy it today you can do it again tomorrow.
"Doyon, Jean-Francois" wrote:
>
> Hello,
>
> I too seem to be having problems ... using the PHP/Mapscript, the querying
> methods
> don't seem to be returning an object (queryResultObj, I would expect) ... I
> don't get any
> errors from the query method (
> $layername->queryusingpoint($point,MS_SINGLE,-1) )
> either ... $point IS a pointObj with X and Y in the projection cooridnate
> system (i.e. not
> in pixels).
>
> And so far, whether I query the map or the layer, the result is allways "0"
> (the number zero).
>
> The docs say the method queryUsingPoint should return void, is that right ?
> Seems to me
> it should return a queryResultObj ...
>
> I'm stumped ... Anybody ?
>
> J.F.
>
> > ----------
> > From: Sean O'Hagan[SMTP:seano at metavera.com]
> > Reply To: Sean O'Hagan
> > Sent: Wednesday, September 06, 2000 2:55 PM
> > To: MapServer List
> > Subject: queryUsingPoint problems
> >
> > Hello:
> >
> > I'm having some problems with queryUsingPoint. The 'numresults' and
> > 'numquerylayers' members of the returned qryResultObj seem to be
> > undefined.
> > My print statements in the code below show no values. Is my syntax
> > incorrect? Thanks very much in advance.
> >
> > Sean.
> >
> >
> > #!perl
> > use mapscript;
> >
> > # getShapesNear( map_file, x_coord, y_coord, layer_number, max_shapes )
> > sub getShapesNear {
> >
> > my @shapes;
> > my $point = new pointObj();
> > my $qryResult;
> > my $mapfile = new mapObj($_[0]);
> > $point->{x} = $_[1];
> > $point->{y} = $_[2];
> > my $layerNum = $_[3];
> > my $numShapes = $_[4];
> >
> > $qryResult = $mapfile->queryUsingPoint($point, MS_MULTIPLE, -1);
> > $j = 0;
> >
> > print "Number of shapes on all layers: $qryResult->{numresults}\n";
> > print "Number of layers searched: $qryResult->{numquerylayers}\n";
> >
> > for (my $i=0; $i<$qryResult->{numresults}; $i++) {
> > my $shpResult = $qryResult->next();
> > if ($layerNum == $shpResult->{layer}) {
> > @shapes[$j++] = $shpResult->{shape};
> > }
> > }
> > $qryResult->{free};
> > return @shapes;
> > }
> > @closeStops = getShapesNear( 'mapfile.map', 923072.8083, 523859.9862, 2,
> > 0 );
> > print "RecNum: @closeStops[0]\n";
> > exit;
> >
> >
More information about the MapServer-users
mailing list