PHP/MapScript msQueryByPoint

Didrik Pinte dpinte at ITAE.BE
Wed May 10 03:55:12 EDT 2006


Le mardi 09 mai 2006 à 08:53 -0700, DjwStone a écrit :
> Thanks for the tip, Didrik. However, I'm still befogged. My query has
> returned 1 result (according to $mylayer->getNumResults()). I can use
> $mylayer->getResult() to give me a resultCacheMemberObj apparently, but what
> can I do with that? What are these shape, tile, and class indexes?
> 
> Should I be using queryByPoint in the first place?
> 
> I need a cold compress (or a stiff whisky).
> 
> Dave

It will be easier with some code. It's python but should be clear
enough :

if layer.queryByPoint(self.map, map_point, mode, buffer) ==
mapscript.MS_FAILURE:
 logging.error('Error while querying the layer')
else:
 results = layer.getResults()
 feat_atts  = []
 layer.open()
 num_res = results.numresults
 logging.debug("Query successful with %u results" % num_res)
 # get the headers
 headers = []
 for j in xrange(layer.numitems):
  headers.append(layer.getItem(j))

 # get the dataset
 for i in xrange(num_res):
  att = []
  qresult = results.getResult(i)
  afeat = layer.getFeature(qresult.shapeindex, qresult.tileindex)
  if afeat is not None:
   for j in xrange(layer.numitems):
    att.append(afeat.getValue(j))
   feat_atts.append(att)
  qresult = None
 layer.close()

The getFeature method gives you the feature, meaning the shapeObj, in
the layer.

I hope this helps

Didrik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Ceci est une partie de message
	=?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=
Url : http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060510/c6e702f5/attachment.bin


More information about the mapserver-users mailing list