Python Mapscript QueryByPoint

Eric Bridger eric at GOMOOS.ORG
Tue Mar 8 06:06:51 PST 2005


On Tue, 2005-03-08 at 07:49, Jon Saints wrote:
> I am having trouble querying a flat shapefile using
> python mapscript with the queryByPoint function.
>
> My getResults always equals None. I believe my trouble
> has something to do with: (from the swig
> documentation) "A query will not set results for a
> layer with a NULL 'template' attribute."
>
> I have tried using both map and pixel coords for the
> point object. Both point objects, I am sure intersect
> a feature of layer 0 on my map.
>
> I receive the error:
> "'NoneType' object has no attribute 'numresults'"
>
> My code:
> ------------------------------------------
> #Map coords
> #click = pointObj()
> #click.x = 77.01
> #click.y = 38.89
>
> #pixel Coords
> click = pointObj()
> click.x = 300
> click.y = 200
>
> myMap.getLayer(0).queryByPoint( myMap, click,
> MS_SINGLE, 10.0 )
> results = myMap.getLayer(0).getResults()
> output = results.numresults
> -------------------------------------------
>
>
> excerpt from My mapfile:
> ------------------------------------------
> LAYER
>   NAME dcdem2000
>   TYPE POLYGON
>   STATUS ON
>   METADATA
>     desc "Census Blocks"
>     logo "test.jpg"
>   END
>   DATA "/home/jons/Data/DC/created/dcdem2000"
>   CLASS
>     NAME "Census Blocks 2000"
>     COLOR 225 225 225
>     OUTLINECOLOR 100 100 100
>   END
> END
> ------------------------------------------

In your LAYER add TEMPLATE "ttt".
That will define a template and allow queries even though you don't use
it.

Eric



More information about the MapServer-users mailing list