[GRASS-dev] [GRASS GIS] #87: GIS.m: Fancy Map Display statusbar
coords in Lat/Lon
GRASS GIS
trac at osgeo.org
Tue Mar 11 07:54:30 EDT 2008
#87: GIS.m: Fancy Map Display statusbar coords in Lat/Lon
-------------------------+--------------------------------------------------
Reporter: hamish | Owner: grass-dev at lists.osgeo.org
Type: enhancement | Status: new
Priority: minor | Milestone: 6.4.0
Component: Tcl | Version: unspecified
Keywords: |
-------------------------+--------------------------------------------------
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
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/87>
GRASS GIS <http://grass.osgeo.org>
GRASS Geographic Information System (GRASS GIS) - http://grass.osgeo.org/
More information about the grass-dev
mailing list