- Timestamp:
- Mar 31, 2014 2:58:41 AM (10 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/map.tcl
r4300 r4303 31 31 private common _mapTypes 32 32 array set _layerTypes { 33 " raster"033 "image" 0 34 34 "elevation" 1 35 35 "polygon" 2 36 36 "points" 3 37 " circle"437 "icon" 4 38 38 "line" 5 39 "label" 6 39 40 } 40 41 array set _mapTypes { … … 128 129 $_tree set $child $key [$layers get $layer.$key] 129 130 } 130 131 foreach {key defval} { opacity 1.0 visible true style ""} {131 # Common settings (for all layer types) with defaults 132 foreach {key defval} { visible true } { 132 133 $_tree set $child $key $defval 134 set val [$layers get $layer.$key] 135 if {$val != ""} { 136 $_tree set $child $key $val 137 } 138 } 139 # These are settings for which there should be no default 140 # We want to know if they have been set by the user or not 141 # Not all layer types use these 142 foreach key { opacity content priority style } { 133 143 set val [$layers get $layer.$key] 134 144 if {$val != ""} { … … 223 233 # USAGE: isGeocentric 224 234 # 225 # Returns (like a bad penny)if the map is geocentric (1) or projected (0)235 # Returns if the map is geocentric (1) or projected (0) 226 236 # ---------------------------------------------------------------------- 227 237 itcl::body Rappture::Map::isGeocentric {} { … … 236 246 append out " version=\"2\"" 237 247 append out ">\n" 238 append out " <profile" 239 append out " srs=\"$info(projection)\"" 240 if { $info(extents) != "" } { 241 foreach {x1 y1 x2 y2} $extents break 242 append out " xmin=\"$x1\"" 243 append out " ymin=\"$y1\"" 244 append out " xmax=\"$x2\"" 245 append out " ymax=\"$y2\"" 246 } 247 append out " >\n" 248 append out " </profile>" 248 # Profile is optional 249 if { [info exists info(projection)] } { 250 append out " <options>\n" 251 append out " <profile" 252 append out " srs=\"$info(projection)\"" 253 if { [info exists info(extents)] && $info(extents) != "" } { 254 foreach {x1 y1 x2 y2} $info(extents) break 255 append out " xmin=\"$x1\"" 256 append out " ymin=\"$y1\"" 257 append out " xmax=\"$x2\"" 258 append out " ymax=\"$y2\"" 259 } 260 append out "/>\n" 261 append out " </options>\n" 262 } 249 263 foreach node [$_tree children root->"layers"] { 250 264 array unset info 251 265 array set info [$_tree get $node] 252 266 set label [$_tree label $node] 253 append out " <image" 254 append out " name=\"$label\"" 255 append out " driver=\"gdal\"" 256 append out " opacity=\"$info(opacity)\"" 257 append out " visible=\"$info(visible)\"" 258 append out " >\n" 259 append out " <url>$info(url)<url>\n" 260 append out " </image>" 267 switch -- $info(type) { 268 "image" { 269 append out " <image" 270 append out " name=\"$label\"" 271 append out " driver=\"gdal\"" 272 if { [info exists info(opacity)] } { 273 append out " opacity=\"$info(opacity)\"" 274 } 275 if { $info(visible) } { 276 append out " visible=\"true\"" 277 } else { 278 append out " visible=\"false\"" 279 } 280 append out ">\n" 281 append out " <url>$info(url)</url>\n" 282 append out " </image>\n" 283 } 284 "elevation" { 285 append out " <elevation" 286 append out " name=\"$label\"" 287 append out " driver=\"gdal\"" 288 if { $info(visible) } { 289 append out " visible=\"true\"" 290 } else { 291 append out " visible=\"false\"" 292 } 293 append out ">\n" 294 append out " <url>$info(url)</url>\n" 295 append out " </elevation>\n" 296 } 297 default { 298 puts stderr "Type $info(type) not implemented in earthfile" 299 } 300 } 261 301 } 262 302 append out "</map>\n" 263 303 } 264 -
trunk/gui/scripts/mapviewer.tcl
r4300 r4303 135 135 private variable _rotateDelay 150 136 136 private variable _motion 137 private variable _sendEarthFile 1 137 138 } 138 139 … … 628 629 } 629 630 if { ![info exists _mapsettings(y2)] || $y2 > $_mapsettings(y2) } { 630 set _mapsettings(y2) $y 1631 set _mapsettings(y2) $y2 631 632 } 632 633 } … … 854 855 # The map must be reset once before any layers are added This 855 856 # should not be done more than once as it is very expensive. 856 set bytes [EarthFile] 857 set f [open "/tmp/earth.txt" "w"] 858 puts $f $bytes 859 close $f 860 set length [string length $bytes] 861 SendCmd "map load data follows $length" 862 append _outbuf $bytes 863 864 # FIXME: do I still need to delete the base layer? 865 SendCmd "map layer delete base" 866 867 if { $_haveTerrain } { 868 if { [info exists _mapsettings(style)] } { 869 SetTerrianStyle $_mapsettings(style) 870 } else { 871 FixSettings terrain-edges terrain-lighting \ 872 terrain-vertscale terrain-wireframe 873 } 857 if {$_sendEarthFile} { 858 set bytes [EarthFile] 859 if {0} { 860 set f [open "/tmp/map.earth" "w"] 861 puts $f $bytes 862 close $f 863 } 864 set length [string length $bytes] 865 SendCmd "map load data follows $length" 866 append _outbuf $bytes 867 } else { 868 if { $_mapsettings(type) == "geocentric" } { 869 SendCmd "map reset geocentric" 870 } else { 871 set proj $_mapsettings(projection) 872 if { $proj == "" } { 873 SendCmd "map reset projected global-mercator" 874 } elseif { ![info exists _mapsettings(extents)] || $_mapsettings(extents) == "" } { 875 SendCmd [list map reset "projected" $proj] 876 } else { 877 #foreach {x1 y1 x2 y2} $_mapsettings(extents) break 878 foreach key "x1 y1 x2 y2" { 879 set $key $_mapsettings($key) 880 } 881 SendCmd [list map reset "projected" $proj $x1 $y1 $x2 $y2] 882 } 883 } 884 SendCmd "map layer delete base" 885 } 886 887 # Most terrain settings are global to the map and apply even 888 # if there is no elevation layer. The exception is the 889 # vertical scale, which only applies if there is an elevation 890 # layer 891 if { [info exists _mapsettings(style)] } { 892 SetTerrainStyle $_mapsettings(style) 893 } else { 894 FixSettings terrain-edges terrain-lighting \ 895 terrain-vertscale terrain-wireframe 874 896 } 875 897 SendCmd "imgflush" … … 890 912 if { ![info exists info(url)] } { 891 913 continue 892 }893 # FIXME: wms, tms layers have additional options894 switch -- $info(type) {895 "raster" {896 set type "image"897 }898 default {899 set type "$info(type)"900 }901 914 } 902 915 if { $_reportClientInfo } { … … 910 923 SendCmd [list "clientinfo" $cinfo] 911 924 } 912 SendCmd [list map layer add $type $info(url) $layer]913 925 set _layers($layer) 1 914 926 SetLayerStyle $dataobj $layer 915 927 } 916 928 lappend _obj2datasets($dataobj) $layer 929 # FIXME: This is overriding all layers' initial visibility setting 917 930 if { [info exists _obj2ovride($dataobj-raise)] } { 918 931 SendCmd "map layer visible 1 $layer" … … 1590 1603 array set info [$dataobj layer $layer] 1591 1604 set _visibility($layer) 1 1592 if { [info exists info(status)] } {1593 if { $info(status) == "hidden" } {1594 set _visibility($layer) 01595 SendCmd "map layer visible 0 $layer"1596 }1597 }1598 1605 1599 1606 switch -- $info(type) { 1600 " raster" {1607 "image" { 1601 1608 array set settings { 1602 1609 -min_level 0 … … 1610 1617 set settings(-opacity) $info(opacity) 1611 1618 } 1619 if {!$_sendEarthFile} { 1620 SendCmd [list map layer add image $info(url) $layer] 1621 } 1612 1622 SendCmd "map layer opacity $settings(-opacity) $layer" 1613 1623 } … … 1619 1629 if { [info exists info(style)] } { 1620 1630 array set settings $info(style) 1631 } 1632 if {!$_sendEarthFile} { 1633 SendCmd [list map layer add elevation $info(url) $layer] 1621 1634 } 1622 1635 } … … 1634 1647 set settings(-opacity) $info(opacity) 1635 1648 } 1649 SendCmd [list map layer add line $info(url) $layer] 1636 1650 SendCmd "map layer opacity $settings(-opacity) $layer" 1637 1651 } … … 1648 1662 set settings(-opacity) $info(opacity) 1649 1663 } 1664 SendCmd [list map layer add polygon $info(url) $layer] 1650 1665 SendCmd "map layer opacity $settings(-opacity) $layer" 1666 } 1667 "label" { 1668 array set settings { 1669 -align "center-center" 1670 -color black 1671 -declutter 1 1672 -font Arial 1673 -fontsize 16.0 1674 -halocolor white 1675 -halowidth 2.0 1676 -layout "ltr" 1677 -minbias 1000 1678 -opacity 1.0 1679 -removedupe 1 1680 } 1681 if { [info exists info(style)] } { 1682 array set settings $info(style) 1683 } 1684 if { [info exists info(opacity)] } { 1685 set settings(-opacity) $info(opacity) 1686 } 1687 set contentExpr $info(content) 1688 if {[info exists info(priority)]} { 1689 set priorityExpr $info(priority) 1690 } else { 1691 set priorityExpr "" 1692 } 1693 SendCmd [list map layer add text $info(url) $contentExpr $priorityExpr $layer] 1694 SendCmd "map layer opacity $settings(-opacity) $layer" 1695 } 1696 } 1697 1698 if { [info exists info(visible)] } { 1699 if { !$info(visible) } { 1700 set _visibility($layer) 0 1701 SendCmd "map layer visible 0 $layer" 1651 1702 } 1652 1703 } … … 1721 1772 } 1722 1773 1774 # 1775 # Generate an OSG Earth file to send to server. This is inteneded 1776 # as a stopgap and testing tool until the protocol is fleshed out. 1777 # 1778 # Note that the lighting settings are required to be "hard-coded" 1779 # as below for the runtime control to work. Don't make those user 1780 # configurable. 1781 # 1782 # Also note: Use "true"/"false" for boolean settings. Not sure if 1783 # the parser in OSG Earth accepts all of Tcl's forms of boolean vals. 1784 # 1723 1785 itcl::body Rappture::MapViewer::EarthFile {} { 1724 1786 append out "<map" … … 1727 1789 append out " version=\"2\"" 1728 1790 append out ">\n" 1729 append out " <options" 1730 append out " lighting=\"true\"" 1731 #append out " elevation_interpolation=\"bilinear\"" 1732 #append out " elevation_tile_size=\"8\"" 1733 #append out " overlay_texture_size=\"4096\"" 1734 #append out " overlay_blending=\"true\"" 1735 #append out " overlay_resolution_ratio=\"3.0\"" 1736 append out ">\n" 1737 append out " <profile" 1738 append out " srs=\"$_mapsettings(projection)\"" 1739 if { [info exists _mapsettings(extents)] } { 1740 append out " xmin=\"$_mapsettings(x1)\"" 1741 append out " ymin=\"$_mapsettings(y1)\"" 1742 append out " xmax=\"$_mapsettings(x2)\"" 1743 append out " ymax=\"$_mapsettings(y2)\"" 1744 } 1745 append out "/>\n" 1746 if { $_haveTerrain } { 1747 array set terrain { 1748 -color white 1749 -lighting 0 1750 } 1751 array set terrain $_mapsettings(style) 1752 append out " <terrain" 1753 append out " lighting=\"$terrain(-lighting)\"" 1754 append out " color=\"$terrain(-color)\"" 1755 #append out " min_tile_range_factor=\"$terrain(-mintile)\"" 1756 #append out " min_lod=\"$terrain(-minlod)\"" 1757 #append out " max_lod=\"$terrain(-maxlod)\"" 1758 #append out " first_lod=\"$terrain(-firstlod)\"" 1759 #append out " cluster_culling=\"$terrain(-clusterculling)\"" 1760 #append out " mercator_fast_path=\"$terrain(-mercatorfastpath)\"" 1761 #append out " blending=\"$terrain(-blending)\"" 1791 append out " <options lighting=\"true\">\n" 1792 # FIXME: convert color setting to hex 1793 # array set style $_mapsettings(style) 1794 # if {[info exists style(-color)]} { 1795 # set color "?" 1796 # } 1797 set color "#ffffffff" 1798 append out " <terrain lighting=\"false\" color=\"$color\"/>\n" 1799 if { [info exists _mapsettings(projection)] } { 1800 append out " <profile" 1801 append out " srs=\"$_mapsettings(projection)\"" 1802 if { [info exists _mapsettings(extents)] } { 1803 append out " xmin=\"$_mapsettings(x1)\"" 1804 append out " ymin=\"$_mapsettings(y1)\"" 1805 append out " xmax=\"$_mapsettings(x2)\"" 1806 append out " ymax=\"$_mapsettings(y2)\"" 1807 } 1762 1808 append out "/>\n" 1763 1809 } … … 1769 1815 array unset info 1770 1816 array set info [$dataobj layer $layer] 1771 append out " <image" 1772 append out " name=\"$layer\"" 1773 append out " driver=\"gdal\"" 1774 append out " opacity=\"$info(opacity)\"" 1775 append out " visible=\"true\"" 1776 append out ">\n" 1777 append out " <url>$info(url)</url>\n" 1778 append out " </image>\n" 1817 switch -- $info(type) { 1818 "image" { 1819 append out " <image" 1820 append out " name=\"$layer\"" 1821 append out " driver=\"gdal\"" 1822 if { [info exists info(opacity)] } { 1823 append out " opacity=\"$info(opacity)\"" 1824 } 1825 if { $info(visible) } { 1826 append out " visible=\"true\"" 1827 } else { 1828 append out " visible=\"false\"" 1829 } 1830 append out ">\n" 1831 append out " <url>$info(url)</url>\n" 1832 append out " </image>\n" 1833 } 1834 "elevation" { 1835 append out " <elevation" 1836 append out " name=\"$layer\"" 1837 append out " driver=\"gdal\"" 1838 if { $info(visible) } { 1839 append out " visible=\"true\"" 1840 } else { 1841 append out " visible=\"false\"" 1842 } 1843 append out ">\n" 1844 append out " <url>$info(url)</url>\n" 1845 append out " </elevation>\n" 1846 } 1847 default { 1848 puts stderr "Type $info(type) not implemented in earthfile" 1849 } 1850 } 1779 1851 } 1780 1852 }
Note: See TracChangeset
for help on using the changeset viewer.