getFeature problem
Myunghwa Hwang
mhwang4 at UIUC.EDU
Sat Apr 22 20:58:44 PDT 2006
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
More information about the MapServer-users
mailing list