[GRASS5] Re: [bug #3277] (grass) d.vect.thematic fails with DOUBLE
Michael Barton
michael.barton at asu.edu
Wed Jun 1 18:46:38 EDT 2005
Maciek et al.
I just committed these fixes to d.vect.thematic to the cvs:
1. changed column type check. I made 2 columns, area and area2, to test. It
tested them both correctly.
2. added a check for the existence of a column
3. I changed the documentation a bit to make it better explain how thematic
mapping works in the script.
I did not change the column test if clause to the simpler version. Markus
had suggested something similar. However, neither work correctly. They
incorrectly flag double precision and integer columns. Something about the
syntax is not quite right. The slightly more complicated way I have it
works, so I've left it alone.
Thanks for all your input.
Michael
______________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402
USA
voice: 480-965-6262; fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton
> From: Maciek Sieczka <werchowyna at epf.pl>
> Date: Tue, 31 May 2005 23:29:15 +0200
> To: <daniel.calvelo at minag.gob.pe>, grass devel <grass5 at grass.itc.it>
> Cc: <michael.barton at asu.edu>, <hamish_nospam at yahoo.com>
> Subject: Re: [GRASS5] Re: [bug #3277] (grass) d.vect.thematic fails with
> DOUBLE
>
> From: "Daniel Calvelo Aros" <dcalvelo at minag.gob.pe>
>
>> From: Maciek Sieczka <werchowyna at epf.pl>
>> Sent: Tue, 31 May 2005 10:19:49 +0000 (UTC)
>>
>>> Hamish <hamish_nospam <at> yahoo.com> writes:
>>>>
>>>> # check column type
>>>> COLTYPE="`v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | [...]
>>>>
>>>> If you have a column PROD and another column with "PROD" in it, e.g.
>>>> PROD2, the grep step will pick out both.
>>>>
>>>> Try using the regex start of line and end of line markers to refine the
>>>> search:
>>>>
>>>> ... | grep ^"$GIS_OPT_column"$ | ...
>>>
>>> Your proposition didn't do it but after one hour of tough reading
>>>
>>> ^'[$GIS_OPT_column]'
>>>
>>> did. Though I still don't know how.
>>
>> It shouldn't have. That regexp should match a line containing any of the
>> characters 'G','I',... or the end of line. Could you put a debugging line
>> after COLTYPE=... like
>>
>> v.info -c $GIS_OPT_map [...] | grep $GIS_OPT_column | awk '{print
>> "["$0"]"}'
>>
>> and post back the result of that?
>>
>> Daniel
>
> Gentlemen
>
> My first "solution" really shouldn't work like you said Daniel and worked
> only in this particular case.
>
> I think I understood the problem (for real this time) and resolved it.
>
> I have two DOUBLE PRECISSION columns, one is called PROD, the other POPROD.
>
> Hamish's solution ... | grep ^"$GIS_OPT_column"$ | ... couldn't handle that
> due to "|" between the column type and column name printed by "v.info -c",
> e.g. DOUBLE PRECISION|PROD.
>
> In this situation we need either
>
> ... | grep "|"$GIS_OPT_column$ | ...
>
> or
>
> ... | grep -w $GIS_OPT_column | ...
>
> Both work. Which one is better? "grep -w" seems cleaner.
>
> One thing more: there should be another error check for "no such column"
> prior to "# check column type". Let me suggest:
>
> ---
> # check if the column exists
> COLCHECK="`v.info -c $GIS_OPT_map layer=1 2> /dev/null | grep -w
> $GIS_OPT_column
>
> if [ "$COLCHECK" = "$GIS_OPT_column" ]; then
> echo ""
> else
> echo "ERROR: No such column \""$GIS_OPT_column"\""
> exit 1
> fi
> ---
>
> What do you think?
>
> Cheers,
> Maciek
>
> P.S.
> This lesson I enjoyed.
>
More information about the grass-dev
mailing list