Changeset 6008 for trunk


Ignore:
Timestamp:
Feb 12, 2016 5:22:38 PM (8 years ago)
Author:
ldelgass
Message:

Remove unused earth file functions

Location:
trunk/gui/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/map.tcl

    r5997 r6008  
    3434    public method deleteLayer { layerName }
    3535    public method deleteViewpoint { viewpointName }
    36     public method earthfile {}
    3736    public method getPlacardConfig { layerName }
    3837    public method hasLayer { layerName }
     
    865864    return [expr {[hints "type"] eq "geocentric"}]
    866865}
    867 
    868 itcl::body Rappture::Map::earthfile {} {
    869     array set info [$_tree get root]
    870     append out "<map"
    871     append out " name=\"$info(label)\""
    872     append out " type=\"$info(type)\""
    873     append out " version=\"2\""
    874     append out ">\n"
    875     # Profile is optional
    876     if { [info exists info(projection)] } {
    877         append out " <options>\n"
    878         append out "  <profile"
    879         append out " srs=\"$info(projection)\""
    880         if { [info exists info(extents)] && $info(extents) != "" } {
    881             foreach {x1 y1 x2 y2} $info(extents) break
    882             append out " xmin=\"$x1\""
    883             append out " ymin=\"$y1\""
    884             append out " xmax=\"$x2\""
    885             append out " ymax=\"$y2\""
    886         }
    887         append out "/>\n"
    888         append out " </options>\n"
    889     }
    890     foreach node [$_tree children root->"layers"] {
    891         array unset info
    892         array set info [$_tree get $node]
    893         set label [$_tree label $node]
    894         switch -- $info(type) {
    895             "image" {
    896                 append out " <image"
    897                 append out " name=\"$label\""
    898                 append out " driver=\"gdal\""
    899                 if { [info exists info(opacity)] } {
    900                     append out " opacity=\"$info(opacity)\""
    901                 }
    902                 if { $info(visible) } {
    903                     append out " visible=\"true\""
    904                 } else {
    905                     append out " visible=\"false\""
    906                 }
    907                 append out ">\n"
    908                 append out "  <url>$info(url)</url>\n"
    909                 append out " </image>\n"
    910             }
    911             "elevation" {
    912                 append out " <elevation"
    913                 append out " name=\"$label\""
    914                 append out " driver=\"gdal\""
    915                 if { $info(visible) } {
    916                     append out " visible=\"true\""
    917                 } else {
    918                     append out " visible=\"false\""
    919                 }
    920                 append out ">\n"
    921                 append out "  <url>$info(url)</url>\n"
    922                 append out " </elevation>\n"
    923             }
    924             default {
    925                 puts stderr "Type $info(type) not implemented in earthfile"
    926             }
    927         }
    928     }
    929     append out "</map>\n"
    930 }
  • trunk/gui/scripts/mapviewer.tcl

    r6007 r6008  
    9494    private method DoSelectCallback {option {args ""}}
    9595    private method DrawLegend { colormap min max }
    96     private method EarthFile {}
    9796    private method EnablePanningMouseBindings {}
    9897    private method EnableRotationMouseBindings {}
     
    164163    private variable _height 0
    165164    private variable _resizePending 0
    166     private variable _sendEarthFile 0
    167165    private variable _useServerManip 0
    168166    private variable _labelCount 0
     
    12201218            # The map must be reset once before any layers are added This
    12211219            # should not be done more than once as it is very expensive.
    1222             if {$_sendEarthFile} {
    1223                 set bytes [EarthFile]
    1224                 if {0} {
    1225                     set f [open "/tmp/map.earth" "w"]
    1226                     puts $f $bytes
    1227                     close $f
    1228                 }
    1229                 set length [string length $bytes]
    1230                 SendCmd "map load data follows $length"
    1231                 SendData $bytes
    1232             } else {
    1233                 if { [info exists _mapsettings(style)] } {
    1234                     array set settings {
    1235                         -color white
    1236                     }
    1237                     array set settings $_mapsettings(style)
    1238                 }
    1239                 set bgcolor [Color2RGB $settings(-color)]
    1240                 if { $_mapsettings(type) == "geocentric" } {
    1241                     $itk_component(grid) configure -state normal
    1242                     $itk_component(time_l) configure -state normal
    1243                     $itk_component(time) configure -state normal
    1244                     $itk_component(pitch_slider_l) configure -state normal
    1245                     $itk_component(pitch_slider) configure -state normal
    1246                     EnableRotationMouseBindings
    1247                     SendCmd "map reset geocentric $bgcolor"
    1248                 }  else {
    1249                     $itk_component(grid) configure -state disabled
    1250                     $itk_component(time_l) configure -state disabled
    1251                     $itk_component(time) configure -state disabled
    1252                     $itk_component(pitch_slider_l) configure -state disabled
    1253                     $itk_component(pitch_slider) configure -state disabled
    1254                     DisableRotationMouseBindings
    1255                     set proj $_mapsettings(projection)
    1256                     SendCmd "screen bgcolor $bgcolor"
    1257                     if { $proj == "" } {
    1258                         SendCmd "map reset projected $bgcolor global-mercator"
    1259                     } elseif { ![info exists _mapsettings(extents)] || $_mapsettings(extents) == "" } {
    1260                         SendCmd "map reset projected $bgcolor [list $proj]"
    1261                     } else {
    1262                         #foreach {x1 y1 x2 y2} $_mapsettings(extents) break
    1263                         foreach key "x1 y1 x2 y2" {
    1264                             set $key $_mapsettings($key)
    1265                         }
    1266                         SendCmd "map reset projected $bgcolor [list $proj] $x1 $y1 $x2 $y2"
    1267                     }
    1268                 }
    1269                 # XXX: Remove these after implementing batch load of layers with reset
    1270                 SendCmd "map layer delete base"
    1271             }
     1220            if { [info exists _mapsettings(style)] } {
     1221                array set settings {
     1222                    -color white
     1223                }
     1224                array set settings $_mapsettings(style)
     1225            }
     1226            set bgcolor [Color2RGB $settings(-color)]
     1227            if { $_mapsettings(type) == "geocentric" } {
     1228                $itk_component(grid) configure -state normal
     1229                $itk_component(time_l) configure -state normal
     1230                $itk_component(time) configure -state normal
     1231                $itk_component(pitch_slider_l) configure -state normal
     1232                $itk_component(pitch_slider) configure -state normal
     1233                EnableRotationMouseBindings
     1234                SendCmd "map reset geocentric $bgcolor"
     1235            }  else {
     1236                $itk_component(grid) configure -state disabled
     1237                $itk_component(time_l) configure -state disabled
     1238                $itk_component(time) configure -state disabled
     1239                $itk_component(pitch_slider_l) configure -state disabled
     1240                $itk_component(pitch_slider) configure -state disabled
     1241                DisableRotationMouseBindings
     1242                set proj $_mapsettings(projection)
     1243                SendCmd "screen bgcolor $bgcolor"
     1244                if { $proj == "" } {
     1245                    SendCmd "map reset projected $bgcolor global-mercator"
     1246                } elseif { ![info exists _mapsettings(extents)] || $_mapsettings(extents) == "" } {
     1247                    SendCmd "map reset projected $bgcolor [list $proj]"
     1248                } else {
     1249                    #foreach {x1 y1 x2 y2} $_mapsettings(extents) break
     1250                    foreach key "x1 y1 x2 y2" {
     1251                        set $key $_mapsettings($key)
     1252                    }
     1253                    SendCmd "map reset projected $bgcolor [list $proj] $x1 $y1 $x2 $y2"
     1254                }
     1255            }
     1256            # XXX: Remove these after implementing batch load of layers with reset
     1257            SendCmd "map layer delete base"
    12721258
    12731259            # Most terrain settings are global to the map and apply even
     
    24282414                set coverage $info(coverage)
    24292415            }
    2430             if {!$_sendEarthFile} {
    2431                 switch -- $info(driver)  {
    2432                     "arcgis" {
    2433                         SendCmd [list map layer add $layer image arcgis \
    2434                                      $info(arcgis.url) $info(cache) $coverage $info(arcgis.token)]
    2435                     }
    2436                     "colorramp" {
    2437                         set cmapName $layer
    2438                         SendFiles $info(colorramp.url)
    2439                         SendCmd [list colormap define $cmapName $info(colorramp.colormap)]
    2440                         SendCmd [list map layer add $layer image colorramp \
    2441                                      $info(colorramp.url) $info(cache) $coverage $info(colorramp.elevdriver) $info(profile)  \
    2442                                      $cmapName]
    2443                     }
    2444                     "debug" {
    2445                         SendCmd [list map layer add $layer image debug]
    2446                     }
    2447                     "gdal" {
    2448                         SendFiles $info(gdal.url)
    2449                         SendCmd [list map layer add $layer image gdal \
    2450                                      $info(gdal.url) $info(cache) $coverage]
    2451                     }
    2452                     "tms" {
    2453                         SendCmd [list map layer add $layer image tms \
    2454                                      $info(tms.url) $info(cache) $coverage]
    2455                     }
    2456                     "wms" {
    2457                         SendCmd [list map layer add $layer image wms \
    2458                                      $info(wms.url) $info(cache) $coverage \
    2459                                      $info(wms.layers) \
    2460                                      $info(wms.format) \
    2461                                      $info(wms.transparent)]
    2462                     }
    2463                     "xyz" {
    2464                         SendCmd [list map layer add $layer image xyz \
    2465                                      $info(xyz.url) $info(cache) $coverage]
    2466                     }
     2416            switch -- $info(driver)  {
     2417                "arcgis" {
     2418                    SendCmd [list map layer add $layer image arcgis \
     2419                                 $info(arcgis.url) $info(cache) $coverage $info(arcgis.token)]
     2420                }
     2421                "colorramp" {
     2422                    set cmapName $layer
     2423                    SendFiles $info(colorramp.url)
     2424                    SendCmd [list colormap define $cmapName $info(colorramp.colormap)]
     2425                    SendCmd [list map layer add $layer image colorramp \
     2426                                 $info(colorramp.url) $info(cache) $coverage $info(colorramp.elevdriver) $info(profile)  \
     2427                                 $cmapName]
     2428                }
     2429                "debug" {
     2430                    SendCmd [list map layer add $layer image debug]
     2431                }
     2432                "gdal" {
     2433                    SendFiles $info(gdal.url)
     2434                    SendCmd [list map layer add $layer image gdal \
     2435                                 $info(gdal.url) $info(cache) $coverage]
     2436                }
     2437                "tms" {
     2438                    SendCmd [list map layer add $layer image tms \
     2439                                 $info(tms.url) $info(cache) $coverage]
     2440                }
     2441                "wms" {
     2442                    SendCmd [list map layer add $layer image wms \
     2443                                 $info(wms.url) $info(cache) $coverage \
     2444                                 $info(wms.layers) \
     2445                                 $info(wms.format) \
     2446                                 $info(wms.transparent)]
     2447                }
     2448                "xyz" {
     2449                    SendCmd [list map layer add $layer image xyz \
     2450                                 $info(xyz.url) $info(cache) $coverage]
    24672451                }
    24682452            }
     
    24772461                array set style $info(style)
    24782462            }
    2479             if {!$_sendEarthFile} {
    2480                 switch -- $info(driver)  {
    2481                     "gdal" {
    2482                         SendFiles $info(gdal.url)
    2483                         SendCmd [list map layer add $layer elevation gdal \
    2484                                      $info(gdal.url) $info(cache)]
    2485                     }
    2486                     "tms" {
    2487                         SendCmd [list map layer add $layer elevation tms \
    2488                                      $info(tms.url) $info(cache)]
    2489                     }
    2490                     "wcs" {
    2491                         SendCmd [list map layer add $layer elevation wcs \
    2492                                      $info(wcs.url) $info(cache) $info(wcs.identifier)]
    2493                     }
     2463            switch -- $info(driver)  {
     2464                "gdal" {
     2465                    SendFiles $info(gdal.url)
     2466                    SendCmd [list map layer add $layer elevation gdal \
     2467                                 $info(gdal.url) $info(cache)]
     2468                }
     2469                "tms" {
     2470                    SendCmd [list map layer add $layer elevation tms \
     2471                                 $info(tms.url) $info(cache)]
     2472                }
     2473                "wcs" {
     2474                    SendCmd [list map layer add $layer elevation wcs \
     2475                                 $info(wcs.url) $info(cache) $info(wcs.identifier)]
    24942476                }
    24952477            }
     
    29542936    }
    29552937}
    2956 
    2957 #
    2958 # Generate an OSG Earth file to send to server.  This is inteneded
    2959 # as a stopgap and testing tool until the protocol is fleshed out.
    2960 #
    2961 # Note that the lighting settings are required to be "hard-coded"
    2962 # as below for the runtime control to work.  Don't make those user
    2963 # configurable.
    2964 #
    2965 # Also note: Use "true"/"false" for boolean settings.  Not sure if
    2966 # the parser in OSG Earth accepts all of Tcl's forms of boolean vals.
    2967 #
    2968 itcl::body Rappture::MapViewer::EarthFile {} {
    2969     append out "<map"
    2970     append out " name=\"$_mapsettings(label)\""
    2971     append out " type=\"$_mapsettings(type)\""
    2972     append out " version=\"2\""
    2973     append out ">\n"
    2974     append out " <options lighting=\"true\">\n"
    2975     # FIXME: convert color setting to hex
    2976     # array set style $_mapsettings(style)
    2977     # if {[info exists style(-color)]} {
    2978     #     set color "?"
    2979     # }
    2980     set color "#ffffffff"
    2981     append out "  <terrain lighting=\"false\" color=\"$color\"/>\n"
    2982     if { [info exists _mapsettings(projection)] } {
    2983         append out "  <profile"
    2984         append out " srs=\"$_mapsettings(projection)\""
    2985         if { [info exists _mapsettings(extents)] } {
    2986             append out " xmin=\"$_mapsettings(x1)\""
    2987             append out " ymin=\"$_mapsettings(y1)\""
    2988             append out " xmax=\"$_mapsettings(x2)\""
    2989             append out " ymax=\"$_mapsettings(y2)\""
    2990         }
    2991         append out "/>\n"
    2992     }
    2993     append out " </options>\n"
    2994 
    2995     foreach dataobj [get -objects] {
    2996         foreach layer [$dataobj layers] {
    2997             set _layers($layer) 1
    2998             array unset info
    2999             array set info [$dataobj layer $layer]
    3000             switch -- $info(type) {
    3001                 "image" {
    3002                     append out " <image"
    3003                     append out " name=\"$layer\""
    3004                     append out " driver=\"gdal\""
    3005                     if { [info exists info(opacity)] } {
    3006                         append out " opacity=\"$info(opacity)\""
    3007                     }
    3008                     if { $info(visible) } {
    3009                         append out " visible=\"true\""
    3010                     } else {
    3011                         append out " visible=\"false\""
    3012                     }
    3013                     append out ">\n"
    3014                     append out "  <url>$info(url)</url>\n"
    3015                     append out " </image>\n"
    3016                 }
    3017                 "elevation" {
    3018                     append out " <elevation"
    3019                     append out " name=\"$layer\""
    3020                     append out " driver=\"gdal\""
    3021                     if { $info(visible) } {
    3022                         append out " visible=\"true\""
    3023                     } else {
    3024                         append out " visible=\"false\""
    3025                     }
    3026                     append out ">\n"
    3027                     append out "  <url>$info(url)</url>\n"
    3028                     append out " </elevation>\n"
    3029                 }
    3030                 default {
    3031                     puts stderr "Type $info(type) not implemented in MapViewer::EarthFile"
    3032                 }
    3033             }
    3034         }
    3035     }
    3036     append out "</map>\n"
    3037     return $out
    3038 }
Note: See TracChangeset for help on using the changeset viewer.