Sajith VK kirjoitti:
Hello all,
I have done some work on python interface for grass api using swing.
Only few functions are wrapped, but hopes that It may be helpful
for someone.
http://freegis.gnu.org.in/temporary/python_grass6.tar.bz2
Please give your comments.
Hi Sajith,
It's good to see interest in this topic.
My first impression is that there's a lot of stuff. Are all those header
files exact copies (probably not) or what's the story? Did you start
from the current Swig attempt at the CVS? I'd like to hear you describe
your approach in writing.
I posted some time ago about my 2nd stab at this problem. I did some
work after that but sent the results only to Markus. Here's that story:
My current approach is based on _one single_ Perl script, which writes
the swig interface files and builds everything. The perl subdir is not
needed.
My approach requires some small changes into gisdefs.h, basically to
comment out the non-existing API which Swig does not like.
I wrote a script (240 lines) which builds Perl modules for grass and all
raster commands. Adding vector commands is in theory as simple as adding
one line into this script. Building some command modules surely fails,
but I've not looked into that. Building of the command modules happens
in these steps:
1. make copies of source code and patch the main.c to make them
functions, not applications
2. compile the source code and make an archive file (I use Perl's
Makefile.PL based system for this)
3. create the wrapper code with Swig
4. create the dynamic library and the module (again Perl's Makefile.PL
based system -- the 2nd time!). Also makes and runs test code optionally.
This seems to work for many, if not most, raster commands. This is not
Perl only since it uses swig but I've not tried this with Python or others.
I think the biggest problem is the text-based i/o of usage, errors etc.
But that may not be a big problem if one just wants to write scripts.
Also the tight link to Grass database is a problem for me, i.e., to use
Grass analysis, the data needs first to be imported to Grass.
The three files which are needed for my current approach are in
map.hut.fi/PerlForGeoinformatics/grass-swig-perl.zip
Right now I don't have time to look into this more, sorry.
I guess followups should be sent just to the grass list.
Ari
--
Prof. Ari Jolma
Kartografia ja Geoinformatiikka / Cartography and Geoinformatics
Teknillinen Korkeakoulu / Helsinki University of Technology
tel: +358 9 451 3886 address: POBox 1200, 02015 TKK, Finland
Email: ari.jolma at tkk.fi URL: http://www.tkk.fi/~jolma