[Mapserver-users] mapscript: queryByPoint() returns no results
Eric Bridger
eric at gomoos.org
Thu Jan 15 09:47:18 PST 2004
I believe you need to add TEMPLATE "anything.html" in your LAYER or
CLASS to make it queryable. May sure to turn the layer on. Also your
qryPt will need map coordinates not pixel values. You'll need to
translate using something like: (in Perl):
@current_extent = split(' ', $q->param('imgext'));
my $click_x = $q->param('mapimg.x');
my $click_y = $q->param('mapimg.y');
my $x_pct = ($click_x / $map->{width});
my $y_pct = 1 - ($click_y / $map->{height});
$x_map = $current_extent[0] + ( ($current_extent[2] -
$current_extent[0]) * $x_pct);
$y_map = $current_extent[1] + ( ($current_extent[3] -
$current_extent[1]) * $y_pct);
HTH.
Eric
On Thu, 2004-01-15 at 11:37, Christoph Spoerri wrote:
> Hi there,
>
> I'm not sure what I'm doing wrong this time. I'm trying to query a polygon
> layer with a point. Yet, for some reason I only receive a 'No records found
> error', even if I click in the middle of the polygon!
>
> I'm using mapserver 4.0.1 with python scripts
>
> thanks for you help again,
> Christoph
>
> Here's the code I'm using:
>
> lyrCoast = myMap.getLayerByName('Continents')
> try:
> qryPt = pointObj()
> qryPt.x,qryPt.y = xStart,yStart # coords are in pixels
> lyrCoast.queryByPoint(myMap.,qryPt,MS_MULTIPLE,0)
> result = lyrCoast.getResult(0)
> s = shapeObj(lyrCoast.type)
> lyrCoast.open()
> lyrCoast.getShape(s,result.tileindex,result.shapeindex)
> ...
>
>
> Here's the layer in the map file:
>
> LAYER
> NAME "Continents"
> STATUS DEFAULT
> TOLERANCE 5
> TOLERANCEUNITS pixels
> DATA "datalib/global/world_usa_canada"
> TYPE POLYGON
> TRANSPARENCY 0
> CLASS
> COLOR 180 210 170
> OUTLINECOLOR 150 190 140
> END
> END
>
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
>
More information about the MapServer-users
mailing list