[GRASS5] Why does v.label require an x display?

IR17;m working with creating a TclTk version of d.label to make postscript text labels (rather than raster text labels) available in the GIS Manager.

I just tried v.label to make a new set of labels and found that it won’t run unless an x display is open. No need to have anything showing in the x display, it just has to be open.

Is this really necessary? If not, can it be changed?

Michael


Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

I¹m working with creating a TclTk version of d.label to make postscript text
labels (rather than raster text labels) available in the GIS Manager.

I just tried v.label to make a new set of labels and found that it won't run
unless an x display is open. No need to have anything showing in the x
display, it just has to be open.

Is this really necessary? If not, can it be changed?

my fault, I'll see if I can change it.

    if(FontSize->answer) {
        fontsize = atoi(FontSize->answer);

        /* figure out space param dynamically from current dispay */
        if(Along_flag->answer) {
            if (R_open_driver() != 0) /* connect to the driver */
                G_fatal_error(_("No graphics device selected"));

            /* Read in the map region associated with graphics window */
            D_setup(0);
            space = fontsize / D_get_u_to_d_xconv(); /* in earth units */

            R_close_driver();
        }
    }
    else
        fontsize = 0;

Hamish

Thanks mucho.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Hamish <hamish_nospam@yahoo.com>
Date: Sun, 16 Apr 2006 13:00:41 +1200
To: Michael Barton <michael.barton@asu.edu>
Cc: <grass5@grass.itc.it>
Subject: Re: [GRASS5] Why does v.label require an x display?

I¹m working with creating a TclTk version of d.label to make postscript text
labels (rather than raster text labels) available in the GIS Manager.

I just tried v.label to make a new set of labels and found that it won't run
unless an x display is open. No need to have anything showing in the x
display, it just has to be open.

Is this really necessary? If not, can it be changed?

my fault, I'll see if I can change it.

    if(FontSize->answer) {
        fontsize = atoi(FontSize->answer);

        /* figure out space param dynamically from current dispay */
        if(Along_flag->answer) {
            if (R_open_driver() != 0) /* connect to the driver */
                G_fatal_error(_("No graphics device selected"));

            /* Read in the map region associated with graphics window */
            D_setup(0);
            space = fontsize / D_get_u_to_d_xconv(); /* in earth units */

            R_close_driver();
        }
    }
    else
        fontsize = 0;

Hamish

I just tried v.label to make a new set of labels and found that it
won't run unless an x display is open. No need to have anything
showing in the x display, it just has to be open.

This is only true if you use both the fontsize= and the -a or -c flags
together. (rotate and/or curl labels to align with lines)

It is used to dynamically set the space= option:
  space Space between letters for curled labels (in map-units)

Is this really necessary? If not, can it be changed?

It is needed as fontsize is given in points but positioned using
easting, northing units. When labels are curled along vector lines, each
letter of the label is positioned and rotated individually. If just
rotated along the line we need to know where the center-tie of the text
will be in space. As fixed point size and x,y are totally independent
variables, the current display monitor zoom is used to translate between
the two so it knows how far to spread out the letters and the resulting
text will be readable. If you want curled labels to survive zooming, you
have to use size= to keep everything in map units (zooming issues still
remain as the font size gets tiny or huge in this case -- this is the
reason for the max and min options in d.labels). This is less of an
issue if just using the -a flag, but it still matters.

from the 6.1 help page:
"NOTES
If the fontsize option is given then the space option is determined
automatically from the current display window, otherwise the space
option should be set roughly the same as the size option."
(enough truth in that to cover the case in which it matters)

It's a similar problem trying to scale a 1:50,000 map to the monitor.
Everyone's monitor size and resolution is slightly different, so it
is rather hard for the GIS to translate map units into "1 inch
viewable". We _can_ set scale* in ps.map as we know how big the printed
page will be in earth units. On the monitor we can only guess and, at
least, hope that the X windows settings are roughly correct. e.g.
gpsdrive uses map scale to pick a map, but was written when 800x600 was
popular so is generally wrong today both for hi-res desktops and iPaq
handhelds.

[*] ps.map's scale is still broken for lat/lon locations.

work around:

I've modified v.label to skip the dynamic space setting if it was
explicitly given on the command line.
If you can have the GUI figure out the conversion coeff between the
monitor and the ground* (i.e. 1 pixel = xxxxx meters) you can feed a
number to the space= option and the display code will be bypassed.
Something like: space = fontsize * (meters/pixel) is probably
close enough. The problem of each letter being tied to the ground
and overlapping/streching on zoom out/in remains of course.

[*] from "g.region -e" and canvas width?

Hamish