[GRASS-dev] g.region print flags combination

Maciej Sieczka tutey at o2.pl
Tue Jan 2 13:41:59 EST 2007


Martin Landa wrote:

> 2007/1/2, Maciej Sieczka <tutey at o2.pl>:
> 
>> "g.region -g" works OK now, but it prints a WARNING message on the top.
>> It also prints few extra lines, compared to before, namely:
>>
>> projection=1
>> zone=34
>> datum=wgs84
>> ellipsoid=wgs84
>>
>> Your WARNING message is correct and desired, as well as the extra info
>>  is usefull, but those several additional lines might brake some user's
>> scripts.
> 
> So should I disable this warning, right?

I guess so. But somebody more knowledgable should decide.

> I think the additional lines would not break any scripts, which parse
> `g.region -g` output in a reasonable way (eval, awk) (?).

Those extra lines might brake all scripts that don't use eval, I
suppose. Eg. parsing with awk by line number will fail now:

# grab the current region settings
g.region -g > $TMP.${PROG}.region

# extract variables from the grabbed region
north=`awk 'BEGIN {FS="="} (NR==1) {print $2}' $TMP.${PROG}.region`
south=`awk 'BEGIN {FS="="} (NR==2) {print $2}' $TMP.${PROG}.region`
west=`awk 'BEGIN {FS="="} (NR==3) {print $2}' $TMP.${PROG}.region`
east=`awk 'BEGIN {FS="="} (NR==4) {print $2}' $TMP.${PROG}.region`
nsres=`awk 'BEGIN {FS="="} (NR==5) {print $2}' $TMP.${PROG}.region`
ewres=`awk 'BEGIN {FS="="} (NR==6) {print $2}' $TMP.${PROG}.region`
rows=`awk 'BEGIN {FS="="} (NR==7) {print $2}' $TMP.${PROG}.region`
cols=`awk 'BEGIN {FS="="} (NR==8) {print $2}' $TMP.${PROG}.region`

Is that "reasonable" I don't know, but it used to work with g.region -g
before your recent changes, and now it fails, because top 4 lines of
g.region -g output are different now.

I personally don't care too much, I have fixed my script to use eval,
but what with other users?

I absolutely agree you are doing a Good Thing fixing g.region -g as you
do, but I'm affraid it should wait till GRASS 7, for legacy reasons.

Maciek




More information about the grass-dev mailing list