1 | # -*- mode: tcl; indent-tabs-mode: nil -*- |
---|
2 | # ---------------------------------------------------------------------- |
---|
3 | # COMPONENT: geomapdataproviderwfs - |
---|
4 | # holds data source information for a geomap |
---|
5 | # vector wfs 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 | # ====================================================================== |
---|
14 | package require Itcl |
---|
15 | package require BLT |
---|
16 | |
---|
17 | namespace eval Rappture { |
---|
18 | # forward declaration |
---|
19 | } |
---|
20 | |
---|
21 | |
---|
22 | itcl::class Rappture::GeoMapDataProviderWFS { |
---|
23 | inherit Rappture::GeoMapDataProvider |
---|
24 | |
---|
25 | constructor {type url typename format args} { |
---|
26 | Rappture::GeoMapDataProvider::constructor $type "wfs" $url |
---|
27 | } { |
---|
28 | # defined below |
---|
29 | } |
---|
30 | destructor { |
---|
31 | # defined below |
---|
32 | } |
---|
33 | |
---|
34 | private variable _format "json" |
---|
35 | private variable _typename "" |
---|
36 | |
---|
37 | protected method Type { args } |
---|
38 | |
---|
39 | public method exportToBltTree { tree } |
---|
40 | public method format { args } |
---|
41 | public method typename { args } |
---|
42 | } |
---|
43 | |
---|
44 | # ---------------------------------------------------------------------- |
---|
45 | # CONSTRUCTOR |
---|
46 | # ---------------------------------------------------------------------- |
---|
47 | itcl::body Rappture::GeoMapDataProviderWFS::constructor {type url typename format args} { |
---|
48 | |
---|
49 | Type $type |
---|
50 | typename $typename |
---|
51 | format $format |
---|
52 | eval configure $args |
---|
53 | } |
---|
54 | |
---|
55 | |
---|
56 | # ---------------------------------------------------------------------- |
---|
57 | # DESTRUCTOR |
---|
58 | # ---------------------------------------------------------------------- |
---|
59 | itcl::body Rappture::GeoMapDataProviderWFS::destructor {} { |
---|
60 | |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | # ---------------------------------------------------------------------- |
---|
65 | # Type: get/set type of layer |
---|
66 | # ---------------------------------------------------------------------- |
---|
67 | itcl::body Rappture::GeoMapDataProviderWFS::Type {args} { |
---|
68 | |
---|
69 | set valids {icon line point polygon text} |
---|
70 | |
---|
71 | |
---|
72 | if {[llength $args] > 1} { |
---|
73 | error "wrong # of arguments: should be ?type?" |
---|
74 | } |
---|
75 | |
---|
76 | set value [Rappture::GeoMapDataProvider::Type] |
---|
77 | |
---|
78 | if {[llength $args] == 1} { |
---|
79 | |
---|
80 | set value [lindex $args 0] |
---|
81 | |
---|
82 | if {[string compare "" $value] == 0} { |
---|
83 | error "bad value \"$value\": should be a non-empty string" |
---|
84 | } |
---|
85 | |
---|
86 | if {[lsearch $valids $value] < 0} { |
---|
87 | error "bad value \"$value\": should be one of \"$valids\"" |
---|
88 | } |
---|
89 | |
---|
90 | Rappture::GeoMapDataProvider::Type $value |
---|
91 | } |
---|
92 | |
---|
93 | return $value |
---|
94 | } |
---|
95 | |
---|
96 | |
---|
97 | # ---------------------------------------------------------------------- |
---|
98 | # format: get/set format that the WFS server should return |
---|
99 | # ---------------------------------------------------------------------- |
---|
100 | itcl::body Rappture::GeoMapDataProviderWFS::format {args} { |
---|
101 | |
---|
102 | set valids {json gml} |
---|
103 | |
---|
104 | |
---|
105 | if {[llength $args] > 1} { |
---|
106 | error "wrong # of arguments: should be ?format?" |
---|
107 | } |
---|
108 | |
---|
109 | if {[llength $args] == 1} { |
---|
110 | |
---|
111 | set value [lindex $args 0] |
---|
112 | |
---|
113 | if {[string compare "" $value] == 0} { |
---|
114 | error "bad value \"$value\": should be a non-empty string" |
---|
115 | } |
---|
116 | |
---|
117 | if {[lsearch $valids $value] < 0} { |
---|
118 | error "bad value \"$value\": should be one of \"$valids\"" |
---|
119 | } |
---|
120 | |
---|
121 | set _format $value |
---|
122 | } |
---|
123 | |
---|
124 | return $_format |
---|
125 | } |
---|
126 | |
---|
127 | |
---|
128 | # ---------------------------------------------------------------------- |
---|
129 | # typename: set/get the feature name to be requested from this data source |
---|
130 | # ---------------------------------------------------------------------- |
---|
131 | itcl::body Rappture::GeoMapDataProviderWFS::typename { args } { |
---|
132 | |
---|
133 | if {[llength $args] > 1} { |
---|
134 | error "wrong # of arguments: should be ?typename?" |
---|
135 | } |
---|
136 | |
---|
137 | if {[llength $args] == 1} { |
---|
138 | |
---|
139 | set value [lindex $args 0] |
---|
140 | |
---|
141 | if {[string compare "" $value] == 0} { |
---|
142 | error "bad value \"$value\": should be a non-empty string" |
---|
143 | } |
---|
144 | |
---|
145 | set _typename $value |
---|
146 | } |
---|
147 | |
---|
148 | return $_typename |
---|
149 | } |
---|
150 | |
---|
151 | |
---|
152 | # ---------------------------------------------------------------------- |
---|
153 | # ExportToBltTree: export object to a blt::tree |
---|
154 | # |
---|
155 | # ExportToBltTree $tree |
---|
156 | # |
---|
157 | # ---------------------------------------------------------------------- |
---|
158 | itcl::body Rappture::GeoMapDataProviderWFS::exportToBltTree {tree} { |
---|
159 | |
---|
160 | Rappture::GeoMapDataProvider::exportToBltTree $tree |
---|
161 | |
---|
162 | $tree set root \ |
---|
163 | wfs.url [url] \ |
---|
164 | wfs.typename $_typename \ |
---|
165 | wfs.format $_format |
---|
166 | } |
---|
167 | |
---|