source: branches/geomap/gui/scripts/geomapdataproviderwms.tcl @ 5949

Last change on this file since 5949 was 5949, checked in by dkearney, 7 years ago

adding data provider and layer objects, updating mapviewer to remove layers from client and server.

File size: 4.4 KB
Line 
1# -*- mode: tcl; indent-tabs-mode: nil -*-
2# ----------------------------------------------------------------------
3#  COMPONENT: geomapdataproviderwms -
4#               holds data source information for a geomap
5#               raster wms layer
6#
7# ======================================================================
8#  AUTHOR:  Derrick Kearney, Purdue University
9#  Copyright (c) 2004-2015  HUBzero Foundation, LLC
10#
11#  See the file "license.terms" for information on usage and
12#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13# ======================================================================
14package require Itcl
15package require BLT
16
17namespace eval Rappture {
18    # forward declaration
19}
20
21
22itcl::class Rappture::GeoMapDataProviderWMS {
23    inherit Rappture::GeoMapDataProvider
24
25    constructor {url layers format args} {
26        Rappture::GeoMapDataProvider::constructor "image" "wms" $url
27    } {
28        # defined below
29    }
30    destructor {
31        # defined below
32    }
33
34    private variable _layers ""
35    private variable _format ""
36
37    public variable transparent "false"
38
39    public method layers { args }
40    public method format { args }
41
42    public method exportToBltTree { tree }
43}
44
45# ----------------------------------------------------------------------
46# CONSTRUCTOR
47# ----------------------------------------------------------------------
48itcl::body Rappture::GeoMapDataProviderWMS::constructor {url layers format args} {
49
50    layers $layers
51    format $format
52
53    eval configure $args
54}
55
56
57# ----------------------------------------------------------------------
58# DESTRUCTOR
59# ----------------------------------------------------------------------
60itcl::body Rappture::GeoMapDataProviderWMS::destructor {} {
61
62}
63
64
65# ----------------------------------------------------------------------
66# layers: set/get the layer names to be requested from this data source
67# ----------------------------------------------------------------------
68itcl::body Rappture::GeoMapDataProviderWMS::layers { args } {
69
70    if {[llength $args] > 1} {
71        error "wrong # of arguments: should be ?layers?"
72    }
73
74    if {[llength $args] == 1} {
75
76        set value [lindex $args 0]
77
78        # layers should be non-empty list
79        if {[llength $value] == 0} {
80            error "bad value \"$value\": should be a non-empty list of strings"
81        }
82
83        set _layers $value
84    }
85
86    return $_layers
87}
88
89
90# ----------------------------------------------------------------------
91# format: set/get the image format that will be returned from the WMS server
92# ----------------------------------------------------------------------
93itcl::body Rappture::GeoMapDataProviderWMS::format { args } {
94
95    set valids {png jpeg}
96
97    if {[llength $args] > 1} {
98        error "wrong # of arguments: should be ?format?"
99    }
100
101    if {[llength $args] == 1} {
102
103        set value [lindex $args 0]
104
105        if {[string compare "" $value] == 0} {
106            error "bad value \"$value\": should be a non-empty string"
107        }
108
109        if {[lsearch $valids $value] < 0} {
110            error "bad value \"$value\": should be one of \"$valids\""
111        }
112
113        set _format $value
114    }
115
116    return $_format
117}
118
119
120# ----------------------------------------------------------------------
121# ExportToBltTree: export object to a blt::tree
122#
123# ExportToBltTree $tree
124#
125# ----------------------------------------------------------------------
126itcl::body Rappture::GeoMapDataProviderWMS::exportToBltTree {tree} {
127
128    Rappture::GeoMapDataProvider::exportToBltTree $tree
129
130    $tree set root \
131        wms.url [url] \
132        wms.layers $_layers \
133        wms.format $_format \
134        wms.transparent $transparent \
135}
136
137
138# ----------------------------------------------------------------------
139# transparent: get/set the transparent flag for the layer
140#
141# Tells the geovis server whether or not to request a transparent image
142# from the WMS server, which allows for lower layers to show through
143# this layer where no data exists. Only works for PNG image format.
144# ----------------------------------------------------------------------
145itcl::configbody Rappture::GeoMapDataProviderWMS::transparent {
146
147    if {[string compare "" $transparent] == 0} {
148        error "bad value \"$transparent\": should be a non-empty boolean"
149    }
150
151    if {[string is bool $transparent] == 0} {
152        error "bad value \"$transparent\": should be a boolean"
153    }
154}
155
156
Note: See TracBrowser for help on using the repository browser.