The tkgeomap package contains the tclgeomap package. It also adds two item types to Tk's canvas widget: geomap_lnarr and geomap_place, that display linearrays and places, respectively. The cartographic characteristics of these items are determined by the item coords, which is a single {x y} coordinate pair, and by the following configuration options:
Canvas geomap_lnarr items have the following additional configuration options:
Canvas geomap_place items have the following additional configuration options:
Here is a sample wish session showing the items in a canvas.
Notes:
wish$ package require tkgeomap 2
2.0
wish$ package require tclgeomap_procs 2
2.0
wish$ set proj [geomap::projection Orthographic {0.0 0.0}]
proj0
wish$ pack [canvas .c -width 540 -height 540 -background #666666]
wish$ geomap::lnarr fmlist lines::ocean [geomap::ocean_list]
lines::ocean
wish$ geomap::lnarr fmlist lines::grid [geomap::grid_list]
lines::grid
wish$ geomap::lnarr fmascii lines::land xearth.asc -descrlen 1l
lines::land
wish$ .c create geomap_lnarr 270 270 -lnarr ::lines::ocean -refpoint {0.0 0.0} -projection $proj -scale [geomap::cartg 1:90000000] -fill Blue4 -outline "" -tags [list geomap ocean]
1
wish$ .c create geomap_lnarr 270 270 -lnarr ::lines::land -refpoint {0.0 0.0} -projection $proj -scale [geomap::cartg 1:90000000] -fill #006600 -tags geomap
2
wish$ .c create geomap_lnarr 270 270 -lnarr ::lines::grid -refpoint {0.0 0.0} -projection $proj -scale [geomap::cartg 1:90000000] -outline #999999 -dash 2 -tags [list geomap grid]
3
wish$ set in [open cities]
file4
wish$ namespace eval places {
>set nmspc [namespace current]
>while {[gets $in line] >= 0} {
>set name [lindex $line 0]
>set latLon [lindex $line 1]
>geomap::place new ${nmspc}::$name $latLon
>.c create geomap_place 270 270 -place ${nmspc}::$name -refpoint {0.0 0.0} -projection $proj -scale [geomap::cartg 1:90000000] -dotsize 2 -dotcolor yellow -text $name -textcolor yellow -anchor s -tags [list geomap $name]
> }
>}
wish$ close $in
|
The resulting map should look like this:
The map can be adjusted by adjusting reconfiguring the items in it. The projection can be adjusted with the projection set command, or by creating a new projection and using its identifier in the configuration.
In this case, we adjust the refpoint (map center) and scale for all items with the geomap tag, and modify the projection via its command.
wish$ $proj set Mercator 0.0
wish$ .c itemconfigure geomap -refpoint {35 -97} -scale [geomap::cartg 1:60000000]
|
Now the map looks like:
Creating, configuring, and reconfiguring individual items can become tedious and complicated on real maps. Some of the repetitive tasks are consolidated with the wdgeomap procedure in the tkgeomap_procs package. The following block of code creates the same map as above using the wdgeomap procedure.
wish$ package require tkgeomap 2
2.0
wish$ package require tkgeomap_procs 2
2
wish$ geomap::wdgeomap::create map .c -width 540 -height 540 -background #666666 -refpoint {0.0 0.0} -projname Orthographic -scale [geomap::cartg 1:90000000]
wish$ geomap::lnarr fmlist lines::ocean [geomap::ocean_list]
lines::ocean
wish$ geomap::lnarr fmlist lines::grid [geomap::grid_list]
lines::grid
wish$ geomap::lnarr fmascii lines::land xearth.asc -descrlen 1l
lines::land
wish$ ::geomap::wdgeomap::draw map lnarr ::lines::ocean -fill Blue4 -outline ""
3
wish$ ::geomap::wdgeomap::draw map lnarr ::lines::land -fill #006600
4
wish$ ::geomap::wdgeomap::draw map lnarr ::lines::grid -outline #999999 -dash 2
5
wish$ set in [open cities]
file4
wish$ namespace eval places {
>set nmspc [namespace current]
>while {[gets $in line] >= 0} {
>if {[llength $line] == 2} {
>set name [lindex $line 0]
>set latLon [lindex $line 1]
>geomap::place new ${nmspc}::$name $latLon
>::geomap::wdgeomap::draw map place ${nmspc}::$name -dotsize 2 -dotcolor yellow -text $name -textcolor yellow -anchor s
>}
>}
>}
wish$ close $in
wish$ pack $::geomap::wdgeomap::map_canvas map
|
These procedures are demonstated in the ptiger demo.