Python Mapscript QueryByPoint
Jon Saints
saintsjd at YAHOO.COM
Wed Mar 9 07:53:22 PST 2005
this may be useful documentation for others:
I can see the layer.getFeature(integer shapeindex,
integer tileindex) function.
I assume that the shapeindex is the index of a row in
my shapefiles dbf.
What does the tileindex represent? is it required for
every shapefile query or just those that are raster
tile indexes?
Thanks
--- Sean Gillies <sgillies at FRII.COM> wrote:
> Jon,
>
> Check the querying howto under mapscript/doc. I am
> hosting an HTML
> version of the same doc at
>
>
>
http://users.frii.com/sgillies/projects/mapscript/querying-HOWTO.html
>
> cheers,
> Sean
>
> On Mar 9, 2005, at 7:52 AM, Jon Saints wrote:
>
> > 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
> >>
> >
> >
> --
> Sean Gillies
> sgillies at frii dot com
> http://users.frii.com/sgillies
>
More information about the MapServer-users
mailing list