queryByPoint accuracy/confusion

Armin Burger armin.burger at GMX.NET
Thu Oct 13 15:05:08 PDT 2005


Tim

I made similar experiences with the tolerance settings. I don't know if 
the standard behaviour is intended like this or if it's a bug. I wanted 
to use pixel values because they make more sense to me than absolute 
distance values. With absolute values you will often find nothing for 
very small scales because you rarely come close enough to the point.

After some trials I found out that the pixel tolerances applied by 
queryByPoint() seem to be valid only for the initial extent (and hence 
scale) specified in the map file. If you eg. zoom in, the pixel values 
are not valid any more.

So I set the map extent before queryByPoint() to the extent of the 
current zoom level like

$map->setExtent($minx, $miny, $maxx, $maxy);
$map->queryByPoint(...);

with min/max values taken from the current map extent (I take the values 
from the session id). This way it really takes the tolerances in pixels 
and the query produces the expected results.

Armin

Tim Norris wrote:
> I am trying to query all point objects in a layer within a certain radius.
> The layer is a dynamically loaded OGR (MapInfo) point layer in which I set
> the 'toleranceunits' to MS_MILES and the 'tolerance' to my specific radius.
> Then I simply run a $lyr_myLayer->queryByPoint($point,MS_MULTIPLE,0) and get
> the count of the results $lyr_myLayer->getNumResults (all in PHP MapScript).
> 
> I am having trouble getting correct queryByPoint results. For some reason
> the radius seems to be smaller than it should. I have even drawn the query
> and then manually checked the query radius on a paper map (it is small).
> After a search through the list archives I could not find any similar
> problems . . .
> 
> [I have also tried $lyr_myLayer->queryByPoint($point,MS_MULTIPLE,$radius)
> and I have also tried using meters and simply converting the miles radius to
> meters - all the same results]
> 
> Perhaps I am not using the queryByPoint method correctly? Is there something
> extra I should know about the 'tolerance' parameter in the layer???
> 
> My map projection is:
>   PROJECTION
>     "proj=merc" # Mercator
>     "lat_0=0" # latitude of natural origin
>     "lon_0=0" # longitude of natural origin (central longitude)
>     "x_0=0" # false easting in meters
>     "y_0=0" # false northing in meters
>   END
> 
> and all the MapInfo data is stored in a Lat/Long projection - would this
> configuration cause an error????
> 
> Do I need to draw the layer before performing the query???? (I tried this on
> one layer and there was no noticable difference).
> 
> One solution I have thought of is to manually create a layer with the
> correct circles to use for the radius queries, but this seems clumsy and
> hard to change in the future (for dynamic queries) - or perhaps create a
> circle feature with the correct radius and use queryByShape or
> queryByFeatures . . .
> 
> any help would be greatly appreciated
> thanks
> tim
> tibben at ocf.berkeley.edu
> 
> p.s. as an aside, I can use my radius as (with toleranceunits as meters OR
> miles):
> $int_queryRadius += $int_queryRadius/4.3
> and I get approximately the correct results - but this is really odd!! I
> must be doing something incorrectly . . .
> 
> 



More information about the MapServer-users mailing list