Changeset 5909 for trunk/gui/scripts/map.tcl
- Timestamp:
- Oct 13, 2015, 3:38:06 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/map.tcl
r5883 r5909 23 23 24 24 itcl::class Rappture::Map { 25 constructor { xmlobj path} {25 constructor {args} { 26 26 # defined below 27 27 } … … 30 30 } 31 31 32 public method addViewpoint { name props } 32 33 public method earthfile {} 33 34 public method hints { args } … … 40 41 public method selectors { layerName } 41 42 public method selector { layerName selectorName } 43 public method setAttribution { attribution } 44 public method setCamera { camera } 45 public method setExtents { xmin ymin xmax ymax } 46 public method setLabel { label } 47 public method setProjection { projection } 48 public method setStyle { style } 49 public method setToolInfo { id name command title revision } 50 public method setType { type } 42 51 public method type { layerName } 43 52 public method viewpoint { viewpointName } … … 74 83 # CONSTRUCTOR 75 84 # ---------------------------------------------------------------------- 76 itcl::body Rappture::Map::constructor {xmlobj path} { 77 if {![Rappture::library isvalid $xmlobj]} { 78 error "bad value \"$xmlobj\": should be LibraryObj" 79 } 80 Parse $xmlobj $path 85 itcl::body Rappture::Map::constructor {args} { 86 if {$args == ""} { 87 set _tree [blt::tree create] 88 set parent [$_tree insert root -label "layers"] 89 setLabel "Map" 90 setType "projected" 91 setProjection "global-mercator" 92 setExtents "" 93 setStyle "" 94 setCamera "" 95 set _isValid 1 96 } else { 97 set xmlobj [lindex $args 0] 98 set path [lindex $args 1] 99 if {![Rappture::library isvalid $xmlobj]} { 100 error "bad value \"$xmlobj\": should be LibraryObj" 101 } 102 Parse $xmlobj $path 103 } 81 104 } 82 105 … … 368 391 } 369 392 393 itcl::body Rappture::Map::setToolInfo { id name command title revision } { 394 foreach key [list id name command title revision] { 395 set str [set $key] 396 if { "" != $str } { 397 $_tree set root "tool$key" $str 398 } 399 } 400 } 401 402 itcl::body Rappture::Map::setType { type } { 403 if { ![info exists _mapTypes($type)] } { 404 error "unknown map type \"$mapType\": should be one of [array names _mapTypes]" 405 } 406 $_tree set root "type" $type 407 } 408 409 itcl::body Rappture::Map::setProjection { projection } { 410 $_tree set root "projection" $projection 411 } 412 413 itcl::body Rappture::Map::setExtents { xmin ymin xmax ymax } { 414 $_tree set root "extents" "$xmin $ymin $xmax $ymax" 415 } 416 417 itcl::body Rappture::Map::setLabel { label } { 418 $_tree set root "label" $label 419 } 420 421 itcl::body Rappture::Map::setAttribution { attribution } { 422 $_tree set root "attribution" $attribution 423 } 424 425 itcl::body Rappture::Map::setStyle { style } { 426 $_tree set root "style" $style 427 } 428 429 itcl::body Rappture::Map::setCamera { camera } { 430 $_tree set root "camera" $camera 431 } 432 370 433 # ---------------------------------------------------------------------- 371 434 # USAGE: layers … … 445 508 } 446 509 return [$_tree get $id] 510 } 511 512 itcl::body Rappture::Map::addViewpoint { name props } { 513 set nodeid "viewpoint[incr _nextViewpoint]" 514 set child [$_tree insert $parent -label $nodeid] 515 $_tree set $child "name" $name 516 set haveX 0 517 set haveZ 0 518 set haveSRS 0 519 set haveVertDatum 0 520 array set info $props 521 foreach key { label description x y z distance heading pitch srs verticalDatum } { 522 if {[info exists info($key)]} { 523 set val $info($key) 524 if {$key == "x"} { 525 set haveX 1 526 } elseif {$key == "z"} { 527 set haveZ 1 528 } elseif {$key == "srs"} { 529 set haveSRS 1 530 } elseif {$key == "verticalDatum"} { 531 set haveVertDatum 1 532 } 533 $_tree set $child $key $val 534 } 535 } 536 if {!$haveX} { 537 set lat $info(latitude) 538 set long $info(longitude) 539 $_tree set $child x $long 540 $_tree set $child y $lat 541 if {!$haveSRS} { 542 $_tree set $child srs wgs84 543 } 544 if {!$haveVertDatum} { 545 $_tree set $child verticalDatum "" 546 } 547 } 548 if {!$haveZ && [info exists info(altitude)]} { 549 $_tree set $child z $info(altitude) 550 } 447 551 } 448 552
Note: See TracChangeset
for help on using the changeset viewer.