v.in.ascii (bug #5209) [was Re: [GRASS-dev] ps.map: scale wrong
and no output]
Paul Kelly
paul-grass at stjohnspoint.co.uk
Tue Nov 21 05:59:07 EST 2006
Hello Martin,
Sorry to take the lazy approach instead of changing it myself - but the
way you have done it there is code repetition between G_message() and
G__message(). Code repetition (clones) is always bad because it means more
places to change things if you're fixing a bug or changing something.
You should really write it so G_message() is actually a really short
function that calls G__message() to do most of the work. If possible!
If you look at some of the other examples of pairs of G_xxx() and G__xxx()
functions in gislib you will see this is how they work.
Paul
On Tue, 21 Nov 2006, Martin Landa wrote:
> Hi,
>
> sorry, the diff package does not contain gisdefs.h ... correction attached.
>
> Best regards, Martin
>
> 2006/11/21, Martin Landa <landa.martin at gmail.com>:
>> Hi,
>>
>> 2006/11/21, Hamish <hamish_nospam at yahoo.com>:
>> > Martin Landa wrote:
>> > > > https://intevation.de/rt/webrt?serial_num=5209
>> > >
>> > > I have tried to fix this bug (the attached patch). Is it OK? -- then I
>> > > will commit it to CVS...
>> >
>> >
>> > re. "column type" text, it is probably not a good idea to mix
>> > fprintf(stderr, and G_message(). I can see why you kept the first bit
>> > with fprintf (no newline), but the module output will look really weird
>> > if called with the --quiet flag as only G_message() part would disappear.
>>
>> ou, sorry, ... you are absolutely right...
>>
>> > What seems to be needed is a G__message() or G_message_no_newline() or
>> > somesuch fn that doesn't terminate with a newline.
>>
>> I have tried to modify error.c, there is the new G__message () fn.
>>
>> Best regards, Martin
>>
>> > This could be used for "Percent complete:"+G_percent() as well.
>> > Then both msgs get switched on/off together with quiet/verbose.
>> >
>> >
>> >
>> > The following looks good to me, but to preserve precision should "%lf"
>> > be used instead of "%f", perhaps combined with G_trim_decimal()?
>> >
>> >
>> > Index: vector/v.in.ascii/points.c
>> > ===================================================================
>> > RCS file: /home/grass/grassrepository/grass6/vector/v.in.ascii/points.c,v
>> > retrieving revision 1.21
>> > diff -u -r1.21 points.c
>> > --- vector/v.in.ascii/points.c 18 Oct 2006 05:09:22 -0000 1.21
>> > +++ vector/v.in.ascii/points.c 19 Nov 2006 16:45:25 -0000
>> > @@ -368,7 +368,15 @@
>> > if (strlen(tokens[i]) > 0) {
>> > if (coltype[i] == DB_C_TYPE_INT ||
>> > coltype[i] == DB_C_TYPE_DOUBLE) {
>> > - sprintf(buf2, "%s", tokens[i]);
>> > + if (G_projection() == PROJECTION_LL &&
>> > + (i == xcol || i == ycol)) {
>> > + if (i == xcol)
>> > + sprintf(buf2, "%f", x);
>> > + else
>> > + sprintf(buf2, "%f", y);
>> > + }
>> > + else
>> > + sprintf(buf2, "%s", tokens[i]);
>> > }
>> > else {
>> > db_set_string(&val, tokens[i]);
>> >
>> >
>> >
>> > thanks,
>> > Hamish
>> >
>>
>>
>> --
>> Martin Landa <landa.martin at gmail.com> * http://gama.fsv.cvut.cz/~landa *
>>
>>
>>
>
>
> --
> Martin Landa <landa.martin at gmail.com> * http://gama.fsv.cvut.cz/~landa *
>
More information about the grass-dev
mailing list