Python Mapscript QueryByPoint

Jon Saints saintsjd at YAHOO.COM
Wed Mar 9 06:52:50 PST 2005


Thanks to the list,

adding a blank template to my mapfile worked like a
charm. Now I can access the resultset and call the
function results.getResult(0).  this object appears to
only have a memeber variable called shapeindex.

how can I use this information to get the other
attribute fields from the dbf information in the shape
file?

thanks in advance
Jon


--- Eric Bridger <eric at GOMOOS.ORG> wrote:
> 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