Opened 18 years ago

Closed 18 years ago

#1767 closed defect (duplicate)

python resultCacheObj.getResult() method does not work

Reported by: dpinte@… Owned by: sgillies@…
Priority: high Milestone:
Component: MapScript-SWIG Version: 4.8
Severity: normal Keywords:
Cc:

Description

Hi,

The following code works perfectly well with MapServer 4.4 but it does not with
Mapserver 4.8 (debian 4.8.3-2 package). 
------------------------------------------------------------------------------
    layer = self.map.getLayerByName(layern)
    layer.status = mapscript.MS_ON
    map_point = pixel_to_geo(self.map, x, y)
    if layer.queryByPoint(self.map, map_point, mode, buffer) ==
mapscript.MS_FAILURE:
      raise QueryException('No results found or error while executing the query')
    else:
      # query successfull
      results = layer.getResults()
      featAtts  = []
      layer.open()
      num_res = results.numresults

      # 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))         
          featAtts.append(att)
        qresult = None
      layer.close()
------------------------------------------------------------------------------

When processing this with MapServer 4.8, the results.numresults give a correct
information. The results.getResult(i) returns and object with a shapeindex
always equal to 0. Then the getFeature method gives an object with features
values always equal to None.

The queried layer is a PostGIS layer. The debug of the query gives the following :
[Thu May  4 09:38:13 2006].692982 msPOSTGISLayerGetShape called for record = 0
[Thu May  4 09:38:13 2006].693009 msPOSTGISLayerRetrievePGVersion(): query =
select substring(version() from 12 for (position('on' in version()) - 13))
[Thu May  4 09:38:13 2006].693259 msPOSTGISLayerRetrievePGVersion: Version
String: 8.1.3
[Thu May  4 09:38:13 2006].693273 msPOSTGISLayerRetrievePGVersion(): Found
version 8, 1, 3
[Thu May  4 09:38:13 2006].693284 msPOSTGISLayerRetrievePK: query = select
attname from pg_attribute, pg_constraint, pg_class where pg_constraint.conrelid
= pg_class.oid and pg_class.oid = pg_attribute.attrelid and
pg_constraint.contype = 'p' and pg_constraint.conkey[1] = pg_attribute.attnum
and pg_class.relname = 'tblgeomapping' and pg_constraint.conkey[2] is null
[Thu May  4 09:38:13 2006].694386 msPOSTGISLayerParseData: unique column =
clientid, srid='', geom_column_name = cartopoint, table_name=tblgeomapping
[Thu May  4 09:38:13 2006].694416 msPOSTGISLayerGetShape: DECLARE mycursor2
BINARY CURSOR FOR SELECT
clientid::text,level::text,x::text,y::text,varied::text,moved::text,gps::text,senddtg::text,latitude::text,longitude::text,asbinary(force_collection(force_2d(cartopoint)),'NDR')
from tblgeomapping WHERE clientid = 0

I can provide more information if needed.

Didrik

Change History (1)

comment:1 by dpinte@…, 18 years ago

Resolution: duplicate
Status: newclosed

*** This bug has been marked as a duplicate of 1766 ***
Note: See TracTickets for help on using tickets.