RE: [Spam/Pourriel] [GRASS-dev] Re: query vector points x,y

True enough. I'm not sure why v.to.db only prints a few decimal places. I'm
assuming there must be some print statement within one of the c programs of
v.to.db that determines this.

~ Eric.

-----Original Message-----
From: Damiano Triglione
To: Patton, Eric; 'Maciej Sieczka '
Cc: grass-dev@grass.itc.it
Sent: 9/27/2006 9:18 AM
Subject: Re: [Spam/Pourriel] [GRASS-dev] Re: query vector points x,y

You're perfectly right about practical meaning, but I have a theoretical

interest;
another issue is that for a strange reason I may want to use kilometers
as
units, so meaningful centimeters are at distant decimal places!
What do you think?
Damiano

----- Original Message -----
From: "Patton, Eric" <epatton@nrcan.gc.ca>
To: "'Damiano Triglione '" <damiano.triglione@polimi.it>; "'Maciej
Sieczka
'" <tutey@o2.pl>
Cc: <grass-dev@grass.itc.it>
Sent: Wednesday, September 27, 2006 2:50 PM
Subject: RE: [Spam/Pourriel] [GRASS-dev] Re: query vector points x,y

I'm not sure why, but how much precision do you need? If your

projection

units are in meters, you can't get meaningful precision greater than a
decimeter anyway. Does it make sense to give coordinates for a

position to

6
decimal places if the units are meters? Is your input data that

precise?

Keep in mind that 6 decimal places is giving a precision of 1/10,000th

of

a
millimeter!

~ Eric.

-----Original Message-----
From: grass-dev-bounces@grass.itc.it
To: Maciej Sieczka
Cc: grass-dev@grass.itc.it
Sent: 9/27/2006 8:16 AM
Subject: [Spam/Pourriel] [GRASS-dev] Re: query vector points x,y

(...)

OK, but then I think it is better to use v.out.ascii for this purpose!
v.out.ascii print coordinates with high precision, while v.to.db -p

gives

only
a couple of decimals after floating point. Why?
Damiano

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

Patton, Eric wrote:

True enough. I'm not sure why v.to.db only prints a few decimal
places. I'm assuming there must be some print statement within one of
the c programs of v.to.db that determines this.

probably lib/db/dbmi_base/valuefmt.c

For GRASS 6.1 I changed db_convert_value_to_string() there to do:
        case DB_C_TYPE_DOUBLE:
            sprintf (buf, "%lf",db_get_value_double(value));
            G_trim_decimal(buf);
            break;

which helps.

Damiano: are you using 6.1+? 6.0 will trim decimals as "%f" or so.
Maybe there are more places that need the above fix.

%lf prints with double precision and G_trim_decimal() removes trailing
zeros.

Hamish

----- Original Message ----- From: "Hamish" <hamish_nospam@yahoo.com>
To: "Patton, Eric" <epatton@nrcan.gc.ca>
Cc: <damiano.triglione@polimi.it>; <tutey@o2.pl>; <grass-dev@grass.itc.it>
Sent: Wednesday, September 27, 2006 5:56 PM
Subject: Re: [Spam/Pourriel] [GRASS-dev] Re: query vector points x,y

Patton, Eric wrote:

True enough. I'm not sure why v.to.db only prints a few decimal
places. I'm assuming there must be some print statement within one of
the c programs of v.to.db that determines this.

probably lib/db/dbmi_base/valuefmt.c

For GRASS 6.1 I changed db_convert_value_to_string() there to do:
       case DB_C_TYPE_DOUBLE:
           sprintf (buf, "%lf",db_get_value_double(value));
           G_trim_decimal(buf);
           break;

which helps.

Damiano: are you using 6.1+? 6.0 will trim decimals as "%f" or so.
Maybe there are more places that need the above fix.

%lf prints with double precision and G_trim_decimal() removes trailing
zeros.

Hamish

Actually I am using 6.0. So: "%f", instead of "%lf", causes the single (rather than double) precision in sprintf, right?
Damiano

Damiano Triglione wrote:

> Patton, Eric wrote:
>> True enough. I'm not sure why v.to.db only prints a few decimal
>> places. I'm assuming there must be some print statement within one
>of > the c programs of v.to.db that determines this.

Hamish:

> probably lib/db/dbmi_base/valuefmt.c
>
> For GRASS 6.1 I changed db_convert_value_to_string() there to do:
> case DB_C_TYPE_DOUBLE:
> sprintf (buf, "%lf",db_get_value_double(value));
> G_trim_decimal(buf);
> break;
>
> which helps.
>
> Damiano: are you using 6.1+? 6.0 will trim decimals as "%f" or so.
> Maybe there are more places that need the above fix.
>
> %lf prints with double precision and G_trim_decimal() removes
> trailing zeros.

Damiano:

Actually I am using 6.0. So: "%f", instead of "%lf", causes the single
(rather than double) precision in sprintf, right?

yup. So this problem should be fixed already in newer versions. (!)
%f is usually 6 numbers after the decimal place. %lf is like 28 or 32 or
something like that (too long to quickly count).

%.15g was used for a time as well.

The idea is to let easting & northing coords like 5000000.000 display
with mm precision instead of being converted to 5.000000e+06.

Hamish