[mapserver-users] Python Mapscript MS 3.6.1

Michael Schulz mschulz at webgis.de
Fri Jul 12 02:03:13 PDT 2002


Dear Sean, Vinko, Norman,

thanks for your patient help. it is working! i got a little bit confused with the php mapscript
calls, so ...

I hope i can step in and provide in the future to those who are interested also some information
with this mapscript dialect.

Thanks again, Michael


Sean Gillies schrieb:

> Michael Schulz wrote:
> > Hi,
> >
> > thanks for the hint to the setup script of Norman Vine. Find it here:
> > http://www.vso.cape.com/~nhv/files/python/mapscript/setup.py )
> > You may need to change some things (paths, libs, etc. ).
> >
> > It works well and python gets swigged and compiled and installed automatically. Yipiie!
> >
> > 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)
> >
> > Perhaps someone who has an overview of mapscript/compiling/swig/python can give some advice
> > where to look for the problem.
> >
> > Thanks, Michael
> >
>
> Michael,
>
> If your module builds and installs using setup.py, it should be
> all together and ready to use.
>
> Try this from the Python (python2) prompt:
>
>     from mapscript import *
>     m = mapObj('/path/to/mapfile')
>     print m.name
>     proj = map.getProjection()
>     print proj
>     layer = map.getLayer(0)
>     print layer.name
>
> Use the Python interface, not the underlying C functions.  The Python
> interface is not well documented, you'll need to adapt the Perl
> Mapscript documentation and feel your way along.  The Python attributes
> and methods have the same names as in the Perl documentation, but you
> will need to call them in the proper Python manner.
>
> One thing to keep in mind is the use of the symbol 'map'.  As in
> Perl, 'map' is a Python function.  A very useful function.  So I'd
> warn against using 'map' as a name for any of your mapObjs.
>
> I just looked through the webgis.de website and it seems that you
> have a lot of interesting mapping work.  How are you going to
> use Python mapscript?
>
> cheers,
> Sean

--
-----------------------------------------------------------
Michael Schulz                                in medias res
Dipl.-Geologe                              Gesellschaft für
                                Informationstechnologie mbH
                             Sautierstr. 38, 79104 Freiburg
                                     0761 55695-95 (Fax 96)
mschulz at webgis.de                             www.webgis.de







More information about the MapServer-users mailing list