Opened 17 years ago
Last modified 9 years ago
#87 new task
GIS.m: Fancy Map Display statusbar coords in Lat/Lon
Reported by: | hamish | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 6.4.6 |
Component: | Tcl/Tk | Version: | svn-develbranch6 |
Keywords: | gis.m, LL | Cc: | |
CPU: | All | Platform: | All |
Description
This was code request # 401 over at the old Gforge bug tracker. Moving it here. http://wald.intevation.org/tracker/index.php?func=detail&aid=401&group_id=21&atid=188
Hi,
I would love for Lat/Lon locations to format the Map Display statusbar x,y string into 45°59.9999'S 170°59.9999'W.
Hamish:
>>> set mapunits [MapCanvas::get_mapunits] >>> if { [string first "degree" $mapunits ] >= 0 } { >>> set outfmt_coords {%.6f} >>> } else { >>> set outfmt_coords {%.3f} >>> }
Michael:
This is a procedure I didn't know about. Did you write it? Seems handy. I might write something similar in wxgrass.
H:
Yes, I wrote it to stabilize the x,y coords in the bottom right corner of the GIS.m Map Display window. I would love for Lat/Lon locations to munge the string into 45°59.9999'S 170°59.9999'W.
M:
Why can't this just be built into your get_mapunits procedure? I can add it to the statusbar easily enough.
because that calls g.proj to get the units. You only need to do that once at init to set a global variable. You really don't want to be calling a module twice every time the mouse moves 1 pixel.
Python/SWIG:
# test the string made by (eg "degrees") python_grass6.G_database_unit_name(int plural) # ie 0 or 1
BUT is there a way to get the degree symbol that works on all platforms?
Does this show a degree symbol on the Mac?
$ echo "puts \xB0; exit" | wish
here is some non-functional demo Tcl code:
init { global is_ll set mapunits [MapCanvas::get_mapunits] if {string first "degree" $mapunits ] >= 0 } { set is_ll 1 } else { set is_ll 0 } if { is_ll } { # failsafe, will try for fancy fmt later set outfmt_coords {%.6f} } else { set outfmt_coords {%.3f} } } ..... bind $can($mon) <Motion> { global mon global is_ll set scrxmov %x set scrymov %y if { is_ll } { set eastcoord [fmt_latlon [eval MapCanvas::scrx2mape $mon %x] 0] set northcoord [fmt_latlon [eval MapCanvas::scry2mapn $mon %y] 1] } else { set eastcoord [format $outfmt_coords [eval MapCanvas::scrx2mape $mon %x] ] set northcoord [format $outfmt_coords [eval MapCanvas::scry2mapn $mon %y] ] } set coords($mon) "$eastcoord $northcoord" } ...... proc fmt_latlon { num, is_latitude } { global is_ll # units are degrees # _d means integer, _f means float set deg_d [expr num - (num%1) ] set min_f [expr (num%1)*60 ] set min_d [expr min_d - (min_d%1) ] set sec_f [expr (min_f%1)*60 ] if { is_latitude } { if { num > 0 } { set hem_str "N" } elif { num == 0 } { set hem_str "" } else { set hem_str "S" } } else { if { num > 0 } { set hem_str "E" } elif { num == 0 } { set hem_str "" } else { set hem_str "W" } } set num_fmt [concat [format {%3d} deg] "\xB0" \ [format {%02d} min_d] {'} \ [format {%.5} sec_f] {"" } $hem_str ] return num_fmt }
Hamish
Date: 2007-05-22
Sender: Hamish B
slight adjustment:
set coords($mon) "$eastcoord $northcoord"
move that into the {is_ll} bit and if LL put $northcoord first.
Hamish
I guess if the degree symbol is not portable for display a "d " or just a space could be used, but its not as nice.
Hamish
Change History (5)
comment:1 by , 16 years ago
CPU: | → All |
---|---|
Platform: | → All |
Priority: | minor → major |
Type: | enhancement → task |
Version: | unspecified → svn-develbranch6 |
comment:2 by , 16 years ago
note the wxPython GUI includes this feature, so only relevant to the Tcl/Tk GUI.
Hamish
comment:3 by , 16 years ago
Keywords: | gis.m LL added |
---|
committed to devbr6 in r37710.
TODO:
- add a UI control to switch between DMS, DMM.MMM, and D.DDD (all there in the code now, just modify the dms_format setting to change)
- learn via feedback how portable ° symbol is.
Hamish
comment:4 by , 16 years ago
Priority: | major → minor |
---|
comment:5 by , 9 years ago
Milestone: | 6.4.0 → 6.4.6 |
---|
I'd like to see this happen for the 6.4.0 release.
Hamish