[GRASS-dev] Re: single-click zoom doesn't preserve aspect ratio

Maciej Sieczka wrote:

Trying to switch to "Map fills display window" mode, I get an error:

can't read "nsres": no such variable
    while executing
"expr round(abs($n-$s)/$nsres)"
    (procedure "MapCanvas::currentzoom" line 27)
    invoked from within
"MapCanvas::currentzoom $mon"
    (procedure "MapCanvas::runprograms" line 24)
    invoked from within
"MapCanvas::runprograms $mon [expr {$mymodified != 0}]"
    (procedure "MapCanvas::drawmap" line 38)
    invoked from within
"MapCanvas::drawmap $mon"
    (procedure "MapCanvas::display_server" line 9)
    invoked from within
"MapCanvas::display_server"
    ("after" script)

I can confirm this. Changing nsres and ewres (in the next line) to explore_nsres and explore_ewres apparently solves the problem for me, but I'm not sure whether this is the correct way to do it. Michael ?

However, this raises another in my eyes more fundamental issue with gis.m: when such an error happens, the display canvas becomes unresponsive and even if I close it and open another canvas, I still cannot display anything. I have to close gis.m and relaunch it to be able to display again. This seems to be an issue with catching the error. Any ideas on how to solve this ?

Moritz

Moritz Lennert wrote:

Maciej Sieczka wrote:

Trying to switch to "Map fills display window" mode, I get an error:

can't read "nsres": no such variable
    while executing
"expr round(abs($n-$s)/$nsres)"
    (procedure "MapCanvas::currentzoom" line 27)
    invoked from within
"MapCanvas::currentzoom $mon"
    (procedure "MapCanvas::runprograms" line 24)
    invoked from within
"MapCanvas::runprograms $mon [expr {$mymodified != 0}]"
    (procedure "MapCanvas::drawmap" line 38)
    invoked from within
"MapCanvas::drawmap $mon"
    (procedure "MapCanvas::display_server" line 9)
    invoked from within
"MapCanvas::display_server"
    ("after" script)

I can confirm this. Changing nsres and ewres (in the next line) to explore_nsres and explore_ewres apparently solves the problem for me, but I'm not sure whether this is the correct way to do it. Michael ?

Sorry, forgot to include the patch:

Index: mapcanvas.tcl

RCS file: /grassrepository/grass6/gui/tcltk/gis.m/mapcanvas.tcl,v
retrieving revision 1.49
diff -u -r1.49 mapcanvas.tcl
--- mapcanvas.tcl 4 Nov 2006 00:01:43 -0000 1.49
+++ mapcanvas.tcl 7 Nov 2006 15:04:15 -0000
@@ -969,8 +969,8 @@
                 # Calculate the resolutions proportional to the map size
                 set explore_nsres [expr {1.0 * ($n - $s) / $canvas_h($mon)}]
                 set explore_ewres [expr {1.0 * ($e - $w) / $canvas_w($mon)}]
- set explore_rows [expr round(abs($n-$s)/$nsres)]
- set explore_cols [expr round(abs($e-$w)/$ewres)]
+ set explore_rows [expr round(abs($n-$s)/$explore_nsres)]
+ set explore_cols [expr round(abs($e-$w)/$explore_ewres)]
                 lappend expanded_region $explore_nsres $explore_ewres $explore_rows $explore_cols
                 set region $expanded_region
         }

Moritz

This should already be in the cvs, as I sent it in on Saturday (I've been
out of the office). If not either you can fix it or I can do it tomorrow.

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

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

From: Moritz Lennert <mlennert@club.worldonline.be>
Date: Tue, 07 Nov 2006 16:01:08 +0100
To: Maciej Sieczka <tutey@o2.pl>
Cc: Grass Developers List <grass-dev@grass.itc.it>, Michael Barton
<michael.barton@asu.edu>
Subject: Re: single-click zoom doesn't preserve aspect ratio

Maciej Sieczka wrote:

Trying to switch to "Map fills display window" mode, I get an error:

can't read "nsres": no such variable
can't read "nsres": no such variable
    while executing
"expr round(abs($n-$s)/$nsres)"
    (procedure "MapCanvas::currentzoom" line 27)
    invoked from within
"MapCanvas::currentzoom $mon"
    (procedure "MapCanvas::runprograms" line 24)
    invoked from within
"MapCanvas::runprograms $mon [expr {$mymodified != 0}]"
    (procedure "MapCanvas::drawmap" line 38)
    invoked from within
"MapCanvas::drawmap $mon"
    (procedure "MapCanvas::display_server" line 9)
    invoked from within
"MapCanvas::display_server"
    ("after" script)

I can confirm this. Changing nsres and ewres (in the next line) to
explore_nsres and explore_ewres apparently solves the problem for me,
but I'm not sure whether this is the correct way to do it. Michael ?

However, this raises another in my eyes more fundamental issue with
gis.m: when such an error happens, the display canvas becomes
unresponsive and even if I close it and open another canvas, I still
cannot display anything. I have to close gis.m and relaunch it to be
able to display again. This seems to be an issue with catching the
error. Any ideas on how to solve this ?

Moritz

There are probably ways to trap errors more gracefully. The best way is not
to have them of course, but it would be good if the program continued even
if it encountered one. I can't put a "catch" command on everything in every
script (this is one way to trap), but it would be good to know which kinds
of errors create this kind of freeze (not all do). As I encounter them, I
try to trap them, but I'm not sure what to look for to do this proactively.

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

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

From: Moritz Lennert <mlennert@club.worldonline.be>
Date: Tue, 07 Nov 2006 16:01:08 +0100
To: Maciej Sieczka <tutey@o2.pl>
Cc: Michael Barton <michael.barton@asu.edu>, Grass Developers List
<grass-dev@grass.itc.it>
Subject: [GRASS-dev] Re: single-click zoom doesn't preserve aspect ratio

However, this raises another in my eyes more fundamental issue with
gis.m: when such an error happens, the display canvas becomes
unresponsive and even if I close it and open another canvas, I still
cannot display anything. I have to close gis.m and relaunch it to be
able to display again. This seems to be an issue with catching the
error. Any ideas on how to solve this ?

Michael Barton wrote:

There are probably ways to trap errors more gracefully. The best way is not
to have them of course, but it would be good if the program continued even
if it encountered one. I can't put a "catch" command on everything in every
script (this is one way to trap), but it would be good to know which kinds
of errors create this kind of freeze (not all do). As I encounter them, I
try to trap them, but I'm not sure what to look for to do this proactively.

I would suggest this one as a candidate for catching:
   http://article.gmane.org/gmane.comp.gis.grass.user/16199

GRASS 6.2.0 (Arctic):~ > gis.m
GRASS 6.2.0 (Arctic):~ > Error in startup script: can't read
"parts(n)": no such variable
    while executing
"MapCanvas::zoom_new $mon $parts(n) $parts(s) $parts(e) $parts(w)
$parts(nsres) $parts(ewres)"
    (procedure "MapCanvas::zoom_gregion" line 11)
    invoked from within
"MapCanvas::zoom_gregion $mon"
    (procedure "MapCanvas::create" line 40)

.. and then reword the error to something meaninful ..

Hamish

Moritz Lennert wrote:

Moritz Lennert wrote:

Maciej Sieczka wrote:

Trying to switch to "Map fills display window" mode, I get an error:

can't read "nsres": no such variable
    while executing
"expr round(abs($n-$s)/$nsres)"
    (procedure "MapCanvas::currentzoom" line 27)
    invoked from within
"MapCanvas::currentzoom $mon"
    (procedure "MapCanvas::runprograms" line 24)
    invoked from within
"MapCanvas::runprograms $mon [expr {$mymodified != 0}]"
    (procedure "MapCanvas::drawmap" line 38)
    invoked from within
"MapCanvas::drawmap $mon"
    (procedure "MapCanvas::display_server" line 9)
    invoked from within
"MapCanvas::display_server"
    ("after" script)

I can confirm this. Changing nsres and ewres (in the next line) to explore_nsres and explore_ewres apparently solves the problem for me, but I'm not sure whether this is the correct way to do it. Michael ?

Sorry, forgot to include the patch:

Index: mapcanvas.tcl

RCS file: /grassrepository/grass6/gui/tcltk/gis.m/mapcanvas.tcl,v
retrieving revision 1.49
diff -u -r1.49 mapcanvas.tcl
--- mapcanvas.tcl 4 Nov 2006 00:01:43 -0000 1.49
+++ mapcanvas.tcl 7 Nov 2006 15:04:15 -0000
@@ -969,8 +969,8 @@
                # Calculate the resolutions proportional to the map size
                set explore_nsres [expr {1.0 * ($n - $s) / $canvas_h($mon)}]
                set explore_ewres [expr {1.0 * ($e - $w) / $canvas_w($mon)}]
- set explore_rows [expr round(abs($n-$s)/$nsres)]
- set explore_cols [expr round(abs($e-$w)/$ewres)]
+ set explore_rows [expr round(abs($n-$s)/$explore_nsres)]
+ set explore_cols [expr round(abs($e-$w)/$explore_ewres)]
                lappend expanded_region $explore_nsres $explore_ewres $explore_rows $explore_cols
                set region $expanded_region
        }

Just comitted this fix.

Moritz

Moritz Lennert wrote:

Just comitted this fix.

Hi Moritz,

Nice to see this thing fixed. Thanks.

What about the other issue, single-click zoom not preserving the aspect
ratio, ? Any chances this is fixable?

Best,
Maciek