Changeset 4288 for trunk/gui/scripts/map.tcl
- Timestamp:
- Mar 28, 2014, 9:56:19 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/map.tcl
r4281 r4288 25 25 itcl::class Rappture::Map { 26 26 private variable _tree ""; # Tree of information about the map. 27 private variable _isGeocentric 0;28 27 private variable _isValid 0; 29 28 private variable _nextLayer 0; # Counter used to generate unique … … 31 30 private common _layerTypes 32 31 private common _mapTypes 33 32 array set _layerTypes { 33 "raster" 0 34 "elevation" 1 35 "polygon" 2 36 "points" 3 37 "circle" 4 38 "line" 5 39 } 40 array set _mapTypes { 41 "geocentric" 0 42 "projected" 1 43 } 34 44 protected method Parse { xmlobj path } 35 45 … … 40 50 # defined below 41 51 } 42 public method isGeocentric {}43 52 public method layers {} 44 53 public method layer { name } … … 54 63 return [$_tree get $id "type" ""] 55 64 } 56 public method style { name } {57 set id [$_tree findchild root->"layers" $name]58 if { $id < 0 } {59 error "unknown layer \"$name\""60 }61 return [$_tree get $id "style" ""]62 }63 65 } 64 66 … … 70 72 error "bad value \"$xmlobj\": should be LibraryObj" 71 73 } 72 array set _layerTypes {73 "raster" 074 "elevation" 175 "polygon" 276 "points" 377 "circle" 478 "line" 579 }80 array set _mapTypes {81 "geocentric" 082 "projected" 183 }84 85 74 Parse $xmlobj $path 86 75 } … … 149 138 $_tree set root "label" [$map get "about.label"] 150 139 $_tree set root "extents" [$map get "extents"] 151 $_tree set root "projection" [$map get "projection"]152 140 153 set mapType [$map get "type"] 154 if { $mapType == "" } { 155 set mapType "projected" 141 set projection [$map get "projection"] 142 if { $projection == "" } { 143 set projection "global-mercator"; # Default projection. 144 } 145 # FIXME: Verify projection is valid. 146 $_tree set root "projection" $projection 147 148 set type [$map get "type"] 149 if { $type == "" } { 150 set type "projected"; # Default type is "projected". 156 151 } 157 158 if { ![info exists _mapTypes($mapType)] } { 152 if { ![info exists _mapTypes($type)] } { 159 153 error "unknown map type \"$mapType\": should be one of [array names _mapTypes]" 160 } elseif {$mapType == "geocentric"} {161 set _isGeocentric 1162 154 } 163 $_tree set root "type" $ mapType155 $_tree set root "type" $type 164 156 165 157 foreach {key path} { … … 206 198 } 207 199 208 # ----------------------------------------------------------------------209 # Returns if the map is geocentric (1) or projected (0)210 # ----------------------------------------------------------------------211 itcl::body Rappture::Map::isGeocentric {} {212 return $_isGeocentric213 }
Note: See TracChangeset
for help on using the changeset viewer.