getFeature problem
Frederico Lucca
fredlucca at GMAIL.COM
Tue May 2 11:31:43 PDT 2006
Myunghwa,
try this...
qlayer.queryByPoint(map, qpoint, ms.MS_MULTIPLE, -1)
-1 allows to use the layer tolerance value
Best regards,
Fred
On 4/23/06, Myunghwa Hwang <mhwang4 at uiuc.edu> wrote:
>
> 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
>
--
"Everything under the sun is in tune
But the sun is eclipsed by the moon"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20060502/48f2e95b/attachment.htm>
More information about the MapServer-users
mailing list