getFeature problem
Didrik Pinte
dpinte at ITAE.BE
Wed May 3 13:24:04 PDT 2006
Le samedi 22 avril 2006 à 22:58 -0500, Myunghwa Hwang a écrit :
> I'm trying to retrieve attributed values for selected polygon.
> By using python mapscript and postgis layer, I tried to get a feature by querybypoint.
> In the following code, a feature by getFeature has no bounding box.
> The minimum x, y and the maximum x, y are all -1.
> So any attribute was not retrieved.
> Anybody has any idea of this problem?
>
>
> def getNearFeat(qpoint, map):
> # get query layer
> qlayer = map.getLayerByName('blockgroup')
> qlayer.template = 'query_result.html'
> qlayer.tolerance = 1000 # Unit is meter
> # query the query layer
> qlayer.queryByPoint(map, qpoint, ms.MS_MULTIPLE, 1000)
> numResults = qlayer.getNumResults()
> results = qlayer.getResults()
> # retrieve shape index for selected features
> if (numResults > 0):
> featAtts = []
> qlayer.open()
> for i in range(numResults):
> att = []
> query_result = results.getResult(i)
> afeat = qlayer.getFeature(query_result.shapeindex, query_result.tileindex)
> if afeat:
> for j in range(qlayer.numitems):
> att.append(afeat.getValue(j))
> featAtts.append(att)
> qlayer.close()
> return featAtts
FYI, i've tested your code. It's working fine with MapServer 4.4 but it
does not with MapServer 4.8 ( 4.8.3-2 debian version).
With the 4.8.2 version, the method getValue always return None, the
query_result.shapeindex always return 0. The number of results only
seems to work fine.
It seems to be a bug but maybe i'm not aware of some new things in the
api.
Didrik
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Ceci est une partie de message num?riquement sign?e
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060503/fb7ae1da/attachment.sig>
More information about the MapServer-users
mailing list