Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am attempting to follow the mapscript example described here - http://trac.osgeo.org/mapserver/wiki/RasterQuery

but ran into some trouble with

s = layer.getShape(result.shapeindex, result.tileindex)

It appears that this no longer works

In [63]: s = layer.getShape(result.shapeindex, result.tileindex)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/Users/calvin/work/luc/<ipython-input-63-969295303151> in <module>()
----> 1 s = layer.getShape(result.shapeindex, result.tileindex)

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MapScript-6.0.1-py2.7-macosx-10.7-x86_64.egg/mapscript.pyc in getShape(self, *args)
   1395     def nextShape(self): return _mapscript.layerObj_nextShape(self)
   1396     def close(self): return _mapscript.layerObj_close(self)
-> 1397     def getShape(self, *args): return _mapscript.layerObj_getShape(self, *args)
   1398     def getNumResults(self): return _mapscript.layerObj_getNumResults(self)
   1399     def getResultsBounds(self): return _mapscript.layerObj_getResultsBounds(self)

TypeError: layerObj_getShape() takes exactly 2 arguments (3 given)

What is the argument I ought to supply to getShape method to get it working again?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

EPIC FAIL: I apologize, I just found out that the documentation I mentioned is not up to date.

The correct API (taken from the swig interface file) is the following:

shape=layer.getShape(result)

where result is the resultObj returned by getResult.

Opened ticket and updated documentation (will go live soon).

DOCUMENTATION mentioned in the answer below IS OUTDATED


The mapscript API for layerObj is fully documented here:

http://mapserver.org/mapscript/mapscript.html#layerobj

by reading it one finds out that getShape has been deprecated in favor of getFeature (which takes exactly two arguments, while getShape requires three, the first of them being a shapeObj).

So your code should be:

s = layer.getFeature(result.shapeindex, result.tileindex)
share|improve this answer
    
hello @unicoletti, it appears that I don't have a "getFeature" method in my layer object. And, also, the getShape method is asking for 2 arguments, not 3... –  Calvin Cheng Dec 29 '11 at 3:15
    
you're right I revised the answer (blush) –  unicoletti Dec 29 '11 at 8:04
    
Thanks @unicoletti, nice answer and via your answer, I am also beginning to get an inkling on how to look at the special SWIG interface files to check for required arguments! Appreciate your help! –  Calvin Cheng Dec 29 '11 at 8:29

Same with php

ex. $oRes = $oLayer->getResult($iRes);

$oShape = $oLayer->getShape($oRes); 
//instead of  $oShape = $oLayer->getShape($oRes->tileindex,$oRes->shapeindex);

thanx unicoletti!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.