Hi,
I'm implementing a model in C++ and I need to call some Grass modules from my code.
Which is the best way to do it? Are there APIs that allow me to use the modules as a library?
Thanks!
Matteo
Hi,
I'm implementing a model in C++ and I need to call some Grass modules from my code.
Which is the best way to do it? Are there APIs that allow me to use the modules as a library?
Thanks!
Matteo
see programmers manual[1]
http://grass.osgeo.org/programming7/
On Fri, Feb 15, 2013 at 7:54 PM, matteo poletti <pollo1_91@yahoo.it> wrote:
Hi,
I’m implementing a model in C++ and I need to call some Grass modules from my code.
Which is the best way to do it? Are there APIs that allow me to use the modules as a library?
Thanks!
Matteo
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
–
Regards,
Rashad
On Fri, Feb 15, 2013 at 5:22 PM, Rashad M <mohammedrashadkm@gmail.com> wrote:
see programmers manual[1]
http://grass.osgeo.org/programming7/
On Fri, Feb 15, 2013 at 7:54 PM, matteo poletti <pollo1_91@yahoo.it> wrote:
Hi,
I'm implementing a model in C++ and I need to call some Grass modules from
my code.Which is the best way to do it? Are there APIs that allow me to use the
modules as a library?
See also here (the page should be expanded):
http://grasswiki.osgeo.org/wiki/GRASS_and_C++
Markus
Da: Rashad M <mohammedrashadkm@gmail.com>
see programmers manual[1]
http://grass.osgeo.org/programming7/
Thanks
for your answer. I've seen the programmer's manual, but it seems to me
that it presents operations at a lower level than the one that I need.
For example if I want to call the module v.in.ogr from my code, what should I do? Maybe I'm missing something...
Thank you for your help!
Matteo
Da: Markus Neteler <neteler@osgeo.org>
See also here (the page should be expanded):
http://grasswiki.osgeo.org/wiki/GRASS_and_C++
Ok, I have understood that I need to put the keyword "extern". But I'm still confused about how to call other Grass module.
I've tried to see the examples linked in the wiki but it's a little bit difficult to understand how they work. Can you please suggest me a file where there is an example of calling another module?
Thank you for your help!
Matteo
matteo wrote:
Ok, I have understood that I need to put the keyword
"extern". But I'm still confused about how to call other
Grass module.I've tried to see the examples linked in the wiki but it's a
little bit difficult to understand how they work. Can you
please suggest me a file where there is an example of
calling another module?
have a look at the functions in lib/gis/spawn.c.
there is also the less portable G_system() to look at in grass6.
you might look at raster/r.topmodel/misc.c in trunk for an example.
Hamish
Da: Hamish <hamish_b@yahoo.com>
have a look at the functions in lib/gis/spawn.c.
Ok, so if I got it right I need to do a sys call exec. What do you usually do for reading the module's output?
I suppose that, doing the things this way, I'll need to run my program inside a grass shell to have it working.
Do I need the "extern" keyword in this case? I guess not since I'm doing a sys call.
Maybe I've misunderstood the example...
Thanks!
Matteo
On 16 February 2013 00:42, matteo poletti <pollo1_91@yahoo.it> wrote:
Da: Hamish <hamish_b@yahoo.com>
have a look at the functions in lib/gis/spawn.c.
Ok, so if I got it right I need to do a sys call exec. What do you usually do for reading the module's output?
I hope this will help:
If you are using some framework such as Qt, you can use the way used
in this framework.
I suppose that, doing the things this way, I'll need to run my program inside a grass shell to have it working.
Yes, you always need to run your program (which uses lib or modules)
in grass session. Your program is in fact a grass module. However,
there is an alternative -- to set up some environment variables (most
recently discussed in thread "Bash aliases in GRASS").
http://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly
Do I need the "extern" keyword in this case? I guess not since I'm doing a sys call.
Exactly, "extern" is necessary to properly include function declarations.
Best,
Vaclav
BTW, I would ask this question on grass-dev. For me, it is more
developer than user question because of C++.
Maybe I've misunderstood the example...
Thanks!
Matteo_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user