[GRASS-dev] Re: [GRASS-user] How to find out an angle between to points on the map (for r.plane, r.lake)

Glynn Clements glynn at gclements.plus.com
Tue Mar 11 23:50:18 EDT 2008

Martin Landa wrote:

> >  >>  Ignoring geodetic distance for LL projections is simply ignorance
> >  >> (on
> >  >>  my part here) of the equations needed to do it. It's easy to
> >  >>  determine if a location is LL. In that case, it should calculate
> >  >>  geodetic distance rather than (or perhaps in addition to) displaying
> >  >>  distance in map units. Just need to have the functions to do this
> >  >>  added to the measurement methods.
> >  >
> >  > why to code it in Python when it is already available in gislib? We
> >  > should avoid code duplication.
> >
> >
> > Certainly. If a new version of d.measure or a hypothetical g.measure
> >  could be created, we could use that. Until that happens, we'll need
> >  to do it in Python (which is not all that bad). Is there anyway to
> >  access gislib directly from Python? This could be an alternative to
> >  creating a new module or changing an existing one.
> yes, via SWIG interface, see ./swig/python. Anyway the SWIG-Python
> interface for GRASS is a bit limited, need to be improved.

The GUI should avoid using the GRASS libraries.

One reason is that anything which calls G_fatal_error() will end up
terminating the GUI (even if you add a handler to recover, you can't
safely use library functions afterwards). Similarly, any segfault or
abort() will kill the entire GUI.

Another reason is that the libraries maintain a lot of state, much of
which is initialised upon first use and cannot be reset easily (or at
all) thereafter. This creates problems for changing the current
location/mapset or even the current region.

For components such as the digitiser, not using the libraries isn't
really an option. Such components should be run as distinct processes,
rather than being "import"ed into the GUI process. That way, a fatal
error will only the digitiser (etc).

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list