[mapserver-users] Python Mapscript MS 3.6.1

Vinko Vrsalovic vinko at cprsig.cl
Thu Jul 11 16:57:09 EDT 2002


On Thu, Jul 11, 2002 at 05:49:36PM +0200, Michael Schulz wrote:
 
> But after that i encountered some problems. After invoking python, i can do:
> 
> >>>import mapscript      (works fine), then i try a test that Norman mentioned in a post:
> >>>mapscript.msGetVersion()      (should give the MS_VERSION string) but i get this error:
> AttributeError: 'mapscript' module has no attribute 'msGetVersion'
> >>>m = mapscript.ms_newmapObj('/path/to/mapfile')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'mapscript' module has no attribute 'ms_newmapObj'
> 
> So, it seems i get mapscript compiled and all, but it is not working properly.
> (I am using MS 3.6.0, Python 2.1.2, Swig 1.3.13)


I strongly recommend you to read the python tutorial from the official
website, it's really useful.

You should type:

map = mapscript.mapObj("/path/to/mapfile")

or, if using 

from mapscript import * 

(That will work for sure on Unix platforms, dunno in Win)

map = mapObj("/path/to/mapfile")

The getVersion function doesn't exist anymore, now you just type
MS_VERSION

>>> import mapscript
>>> mapscript.MS_VERSION
'3.6.1'

use the dir() function to reveal the actual name of the functions and
constants, for instance my module says:

Python 2.2 (#1, Feb 24 2002, 16:21:58) 
[GCC 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)] on linux-i386
Type "help", "copyright", "credits" or "license" for more information.
>>> import mapscript
>>> dir(mapscript)
['DBFInfo', 'DBFInfoPtr', 'FTDouble', 'FTInteger', 'FTInvalid',
'FTString', 'GetMapserverUnitUsingProj', 'MS_AUTO', 'MS_BITMAP',
'MS_CC', 'MS_CJC_BEVEL', 'MS_CJC_BUTT', 'MS_CJC_MITER', 'MS_CJC_NONE',
'MS_CJC_ROUND', 'MS_CJC_SQUARE', 'MS_CJC_TRIANGLE', 'MS_CL', 'MS_CR',
'MS_DD', 'MS_DEFAULT', 'MS_DELETE', 'MS_DONE', 'MS_EMBED', 'MS_FAILURE',
'MS_FALSE', 'MS_FEET', 'MS_FILE_MAP', 'MS_FILE_SYMBOL', 'MS_GIANT',
'MS_GIF', 'MS_GML', 'MS_HILITE', 'MS_INCHES', 'MS_INLINE', 'MS_JPEG',
'MS_KILOMETERS', 'MS_LARGE', 'MS_LAYER_ANNOTATION', 'MS_LAYER_CIRCLE',
'MS_LAYER_LINE', 'MS_LAYER_POINT', 'MS_LAYER_POLYGON', 'MS_LAYER_QUERY',
'MS_LAYER_RASTER', 'MS_LC', 'MS_LL', 'MS_LR', 'MS_MEDIUM', 'MS_METERS',
'MS_MILES', 'MS_MULTIPLE', 'MS_NO', 'MS_NORMAL', 'MS_OFF', 'MS_OGR',
'MS_ON', 'MS_ORACLESPATIAL', 'MS_PIXELS', 'MS_PNG', 'MS_POSTGIS',
'MS_SDE', 'MS_SELECTED', 'MS_SHAPEFILE', 'MS_SHAPEFILE_ARC',
'MS_SHAPEFILE_MULTIPOINT', 'MS_SHAPEFILE_POINT', 'MS_SHAPEFILE_POLYGON',
'MS_SHAPE_LINE', 'MS_SHAPE_NULL', 'MS_SHAPE_POINT', 'MS_SHAPE_POLYGON',
'MS_SHP_ARCM', 'MS_SHP_MULTIPOINTM', 'MS_SHP_POINTM', 'MS_SHP_POLYGONM',
'MS_SINGLE', 'MS_SMALL', 'MS_SUCCESS', 'MS_TILED_SHAPEFILE', 'MS_TINY',
'MS_TRUE', 'MS_TRUETYPE', 'MS_UC', 'MS_UL', 'MS_UNUSED_1', 'MS_UR',
'MS_VERSION', 'MS_WBMP', 'MS_WMS', 'MS_XY', 'MS_YES', '__builtins__',
'__doc__', '__file__', '__name__', '__path__', 'classObj',
'classObjPtr', 'colorObj', 'colorObjPtr', 'imageObj', 'imageObjPtr',
'itemObj', 'itemObjPtr', 'labelCacheMemberObj',
'labelCacheMemberObjPtr', 'labelCacheObj', 'labelCacheObjPtr',
'labelObj', 'labelObjPtr', 'layerObj', 'layerObjPtr', 'legendObj',
'legendObjPtr', 'lineObj', 'lineObjPtr', 'mapObj', 'mapObjPtr',
'mapscript', 'mapscriptc', 'markerCacheMemberObj',
'markerCacheMemberObjPtr', 'msDBFAddField', 'msDBFClose', 'msDBFCreate',
'msDBFGetFieldCount', 'msDBFGetFieldInfo', 'msDBFGetItemIndex',
'msDBFGetItemIndexes', 'msDBFGetItems', 'msDBFGetRecordCount',
'msDBFGetValueList', 'msDBFGetValues', 'msDBFOpen',
'msDBFReadDoubleAttribute', 'msDBFReadIntegerAttribute',
'msDBFReadStringAttribute', 'msDBFWriteDoubleAttribute',
'msDBFWriteIntegerAttribute', 'msDBFWriteStringAttribute',
'msFreeImage', 'msSaveImage', 'pointObj', 'pointObjPtr',
'projectionObj', 'projectionObjPtr', 'queryMapObj', 'queryMapObjPtr',
'rectObj', 'rectObjPtr', 'referenceMapObj', 'referenceMapObjPtr',
'resultCacheMemberObj', 'resultCacheMemberObjPtr', 'resultCacheObj',
'resultCacheObjPtr', 'scalebarObj', 'scalebarObjPtr', 'shapeObj',
'shapeObjPtr', 'shapefileObj', 'shapefileObjPtr', 'styleObj',
'styleObjPtr', 'webObj', 'webObjPtr']

-- 
Vinko Vrsalovic <vinko[|- at -|]cprsig.cl>
http://www.cprsig.cl



More information about the mapserver-users mailing list