Revision 3483
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/utils/CapabilitiesTags.java | ||
---|---|---|
87 | 87 |
public final static String DIMENSION_NAME ="name"; |
88 | 88 |
public final static String DIMENSION_UNITS ="units"; |
89 | 89 |
public final static String DIMENSION_DEFAULT ="default"; |
90 |
public static final String WCS_CONTENTMETADATA = "ContentMetadata"; |
|
91 |
public static final String WCS_LABEL = "label"; |
|
92 |
public static final String WCS_KEYWORDS = "keywords"; |
|
90 | 93 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/utils/DescribeCoverageTags.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
/** |
|
42 |
* |
|
43 |
*/ |
|
44 |
package org.gvsig.remoteClient.utils; |
|
45 |
|
|
46 |
/** |
|
47 |
* @author jaume |
|
48 |
* |
|
49 |
*/ |
|
50 |
public class DescribeCoverageTags { |
|
51 |
|
|
52 |
public static final String COVERAGE_DESCRIPTION = "CoverageDesription"; |
|
53 |
public static final String COVERAGE_OFFERING = "CoverageOffering"; |
|
54 |
public static final String NAME = "name"; |
|
55 |
public static final String LABEL = "label"; |
|
56 |
public static final String LONLAT_ENVELOPE = "lonLatEnvelope"; |
|
57 |
|
|
58 |
} |
|
0 | 59 |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/utils/BoundaryBox.java | ||
---|---|---|
1 | 1 |
|
2 | 2 |
package org.gvsig.remoteClient.utils; |
3 | 3 |
|
4 |
import java.awt.geom.Rectangle2D; |
|
5 |
|
|
4 | 6 |
/** |
5 | 7 |
* <p></p> |
6 | 8 |
* |
7 | 9 |
*/ |
8 | 10 |
public class BoundaryBox { |
9 |
|
|
11 |
|
|
10 | 12 |
/** |
11 | 13 |
* <p>Represents ...</p> |
12 | 14 |
* |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSLayer.java | ||
---|---|---|
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
public abstract class WMSLayer implements org.gvsig.remoteClient.ILayer { |
19 |
|
|
20 |
protected ArrayList children;
|
|
21 |
protected WMSLayer1_1_1 parent;
|
|
22 |
|
|
23 |
/** |
|
24 |
* <p>Layer Abstract field in the capabilities document </p> |
|
25 |
*/ |
|
19 |
|
|
20 |
protected ArrayList children;
|
|
21 |
protected WMSLayer1_1_1 parent;
|
|
22 |
|
|
23 |
/**
|
|
24 |
* <p>Layer Abstract field in the capabilities document </p>
|
|
25 |
*/
|
|
26 | 26 |
private String layerAbstract; |
27 |
|
|
28 |
/** |
|
29 |
* <p>Themes provided by the WMS for the layer</p> |
|
30 |
*/ |
|
27 |
|
|
28 |
/**
|
|
29 |
* <p>Themes provided by the WMS for the layer</p>
|
|
30 |
*/
|
|
31 | 31 |
public Hashtable styles = new Hashtable(); |
32 | 32 |
|
33 |
/** |
|
34 |
* <p>Layer name</p> |
|
35 |
*/ |
|
33 |
/**
|
|
34 |
* <p>Layer name</p>
|
|
35 |
*/
|
|
36 | 36 |
private String name; |
37 |
|
|
38 |
/** |
|
39 |
* <p>Layer title</p> |
|
40 |
*/ |
|
37 |
|
|
38 |
/**
|
|
39 |
* <p>Layer title</p>
|
|
40 |
*/
|
|
41 | 41 |
private String title; |
42 |
|
|
43 |
/** |
|
44 |
* <p>Layer srs.</p> |
|
45 |
*/ |
|
42 |
|
|
43 |
/**
|
|
44 |
* <p>Layer srs.</p>
|
|
45 |
*/
|
|
46 | 46 |
private Vector srs = new Vector(); |
47 |
|
|
48 |
/** |
|
49 |
* <p>extents for each srs the layer can be reproyected to</p> |
|
50 |
*/ |
|
47 |
|
|
48 |
/**
|
|
49 |
* <p>extents for each srs the layer can be reproyected to</p>
|
|
50 |
*/
|
|
51 | 51 |
private Hashtable bBoxes = new Hashtable(); |
52 | 52 |
|
53 |
/** |
|
54 |
* <p>extents that defines the bbox for the LatLon projection |
|
55 |
* It can be included in the bBoxes vector as well, because it is the most used, we keep it separeted too, according |
|
56 |
* with the OGC WMSCapabilities specifications... |
|
57 |
*/ |
|
53 |
/**
|
|
54 |
* <p>extents that defines the bbox for the LatLon projection
|
|
55 |
* It can be included in the bBoxes vector as well, because it is the most used, we keep it separeted too, according
|
|
56 |
* with the OGC WMSCapabilities specifications...
|
|
57 |
*/
|
|
58 | 58 |
private org.gvsig.remoteClient.utils.BoundaryBox latLonBbox; |
59 |
|
|
60 |
/** |
|
61 |
* <p>min scale for the layer to be visible</p> |
|
62 |
*/ |
|
59 |
|
|
60 |
/**
|
|
61 |
* <p>min scale for the layer to be visible</p>
|
|
62 |
*/
|
|
63 | 63 |
private double scaleMin; |
64 |
|
|
65 |
/** |
|
66 |
* <p>max scale for the layer to be visible</p> |
|
67 |
*/ |
|
64 |
|
|
65 |
/**
|
|
66 |
* <p>max scale for the layer to be visible</p>
|
|
67 |
*/
|
|
68 | 68 |
private double scaleMax; |
69 |
|
|
70 |
/** |
|
71 |
* <p>Dimensions defined for the layer in the capabilities doc</p> |
|
72 |
*/ |
|
69 |
|
|
70 |
/**
|
|
71 |
* <p>Dimensions defined for the layer in the capabilities doc</p>
|
|
72 |
*/
|
|
73 | 73 |
private java.util.Hashtable dimensions = new Hashtable(); |
74 |
|
|
74 |
/** |
|
75 |
* <p>NamedStyles defined for this layer in the capabilities document</p> |
|
76 |
*/ |
|
77 |
private ArrayList namedStyles = new ArrayList(); |
|
78 |
/** |
|
79 |
* Tells if this layer accepts getFeatureInfo requests. |
|
80 |
*/ |
|
75 | 81 |
private boolean queryable; |
76 | 82 |
|
77 | 83 |
/** |
... | ... | |
79 | 85 |
* loading the data in memory to be easily accesed</p> |
80 | 86 |
* |
81 | 87 |
*/ |
82 |
public abstract void parse(KXmlParser parser, TreeMap layerTreeMap ) |
|
83 |
throws IOException, XmlPullParserException; |
|
84 |
|
|
85 |
|
|
86 |
public void setQueryable(boolean isQueryable) |
|
87 |
{ |
|
88 |
queryable = isQueryable; |
|
89 |
} |
|
90 |
public boolean isQueryable() |
|
91 |
{ |
|
92 |
return queryable; |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* <p>Adds a style to the styles vector</p> |
|
97 |
* @param _style |
|
98 |
*/ |
|
88 |
public abstract void parse(KXmlParser parser, TreeMap layerTreeMap) |
|
89 |
throws IOException, XmlPullParserException; |
|
90 |
|
|
91 |
|
|
92 |
/** |
|
93 |
* <p>Adds a style to the styles vector</p> |
|
94 |
* @param _style |
|
95 |
*/ |
|
99 | 96 |
public void addStyle(org.gvsig.remoteClient.wms.WMSStyle _style) { |
100 | 97 |
styles.put( _style.getName(), _style ); |
101 | 98 |
} |
102 |
|
|
103 |
/** |
|
104 |
* <p>returns the style with that name in the styles vector</p> |
|
105 |
* @param _name |
|
106 |
*/ |
|
99 |
|
|
100 |
/**
|
|
101 |
* <p>returns the style with that name in the styles vector</p>
|
|
102 |
* @param _name
|
|
103 |
*/
|
|
107 | 104 |
public WMSStyle getStyle(String _name) { |
108 | 105 |
return (WMSStyle)styles.get(_name); |
109 | 106 |
} |
110 |
|
|
111 |
/** |
|
112 |
* <p>Gets the style vector</p> |
|
113 |
* @return |
|
114 |
*/ |
|
107 |
|
|
108 |
/**
|
|
109 |
* <p>Gets the style vector</p>
|
|
110 |
* @return
|
|
111 |
*/
|
|
115 | 112 |
public Hashtable getStyles() { |
116 | 113 |
return styles; |
117 | 114 |
} |
118 |
|
|
115 |
|
|
119 | 116 |
/** |
120 | 117 |
* <p>Adds a bbox to the Bboxes vector</p> |
121 | 118 |
* @param bbox |
122 | 119 |
*/ |
123 |
public void addBBox(BoundaryBox bbox) {
|
|
124 |
bBoxes.put(bbox.getSrs(), bbox);
|
|
125 |
}
|
|
126 |
|
|
120 |
public void addBBox(BoundaryBox bbox) { |
|
121 |
bBoxes.put(bbox.getSrs(), bbox); |
|
122 |
} |
|
123 |
|
|
127 | 124 |
/** |
128 | 125 |
* <p>returns the bbox with that id in the Bboxes vector</p> |
129 | 126 |
* @param id |
130 | 127 |
*/ |
131 |
public BoundaryBox getBbox(String id) {
|
|
132 |
return (BoundaryBox)bBoxes.get(id);
|
|
133 |
}
|
|
134 |
|
|
128 |
public BoundaryBox getBbox(String id) { |
|
129 |
return (BoundaryBox)bBoxes.get(id); |
|
130 |
} |
|
131 |
|
|
135 | 132 |
/** |
136 | 133 |
* <p>Gets the bBoxes vector</p> |
137 | 134 |
* @return |
138 | 135 |
*/ |
139 |
public Hashtable getBboxes() { |
|
140 |
return bBoxes; |
|
141 |
} |
|
142 |
|
|
136 |
public Hashtable getBboxes() { |
|
137 |
return bBoxes; |
|
138 |
} |
|
143 | 139 |
|
140 |
|
|
144 | 141 |
//Methods to manipulate the box that defines the layer extent in LatLon SRS. |
145 |
public BoundaryBox getLatLonBox() |
|
146 |
{ |
|
147 |
return latLonBbox;
|
|
148 |
} |
|
149 |
public void setLatLonBox(BoundaryBox box) |
|
150 |
{ |
|
151 |
latLonBbox = box;
|
|
152 |
} |
|
142 |
public BoundaryBox getLatLonBox()
|
|
143 |
{
|
|
144 |
return latLonBbox;
|
|
145 |
}
|
|
146 |
public void setLatLonBox(BoundaryBox box)
|
|
147 |
{
|
|
148 |
latLonBbox = box;
|
|
149 |
}
|
|
153 | 150 |
/** |
154 | 151 |
* <p>adds a new srs to the srs vector</p> |
155 | 152 |
*/ |
156 | 153 |
public void addSrs(String srs) |
157 | 154 |
{ |
158 |
this.srs.add(srs);
|
|
155 |
this.srs.add(srs);
|
|
159 | 156 |
} |
160 | 157 |
|
161 | 158 |
public Vector getAllSrs() |
162 | 159 |
{ |
163 |
return (Vector)this.srs.clone();
|
|
160 |
return (Vector)this.srs.clone();
|
|
164 | 161 |
} |
165 |
/** |
|
166 |
* <p>gets the maximum scale for this layer</p> |
|
167 |
* @return |
|
168 |
*/ |
|
162 |
/**
|
|
163 |
* <p>gets the maximum scale for this layer</p>
|
|
164 |
* @return
|
|
165 |
*/
|
|
169 | 166 |
public double getScaleMax() { |
170 | 167 |
return scaleMax; |
171 | 168 |
} |
172 |
|
|
173 |
/** |
|
174 |
* <p>gets the minimum scale for this layer</p> |
|
175 |
* @return |
|
176 |
*/ |
|
169 |
|
|
170 |
/**
|
|
171 |
* <p>gets the minimum scale for this layer</p>
|
|
172 |
* @return
|
|
173 |
*/
|
|
177 | 174 |
public double getScaleMin() { |
178 | 175 |
return scaleMin; |
179 | 176 |
} |
180 |
|
|
181 |
/** |
|
182 |
* <p>sets the minimum scale for this layer to be visible.</p> |
|
183 |
* |
|
184 |
* @param scale |
|
185 |
*/ |
|
177 |
|
|
178 |
/**
|
|
179 |
* <p>sets the minimum scale for this layer to be visible.</p>
|
|
180 |
*
|
|
181 |
* @param scale
|
|
182 |
*/
|
|
186 | 183 |
public void setScaleMin(double scale) { |
187 | 184 |
scaleMin = scale; |
188 | 185 |
} |
189 |
|
|
190 |
/** |
|
191 |
* <p>sets the maximum scale for this layer to be visible</p> |
|
192 |
* @param scale |
|
193 |
*/ |
|
186 |
|
|
187 |
/**
|
|
188 |
* <p>sets the maximum scale for this layer to be visible</p>
|
|
189 |
* @param scale
|
|
190 |
*/
|
|
194 | 191 |
public void setScaleMax(double scale) { |
195 | 192 |
scaleMax = scale; |
196 | 193 |
} |
197 |
|
|
198 |
/** |
|
199 |
* <p> gets the dimension vector defined in this layer</p> |
|
200 |
* @return |
|
201 |
*/ |
|
194 |
|
|
195 |
/**
|
|
196 |
* <p> gets the dimension vector defined in this layer</p>
|
|
197 |
* @return
|
|
198 |
*/
|
|
202 | 199 |
public Hashtable getDimensions() { |
203 | 200 |
return dimensions; |
204 | 201 |
} |
205 |
|
|
206 |
/** |
|
207 |
* <p>Sets the dimension vector defined for this layer</p> |
|
208 |
* @param v |
|
209 |
*/ |
|
202 |
|
|
203 |
/**
|
|
204 |
* <p>Sets the dimension vector defined for this layer</p>
|
|
205 |
* @param v
|
|
206 |
*/
|
|
210 | 207 |
public void setDimensions(Hashtable v) { |
211 | 208 |
dimensions = (Hashtable)v.clone(); |
212 | 209 |
} |
213 |
|
|
214 |
/** |
|
215 |
* <p>Adds a dimension to the dimension vector </p> |
|
216 |
* @param dimension |
|
217 |
*/ |
|
210 |
|
|
211 |
/**
|
|
212 |
* <p>Adds a dimension to the dimension vector </p>
|
|
213 |
* @param dimension
|
|
214 |
*/
|
|
218 | 215 |
public void addDimension(org.gvsig.remoteClient.wms.Dimension dimension) { |
219 | 216 |
dimensions.put(dimension.getName(), dimension); |
220 | 217 |
} |
221 |
|
|
222 |
/** |
|
223 |
* <p>Gets layer name</p> |
|
224 |
* @return |
|
225 |
*/ |
|
218 |
|
|
219 |
/**
|
|
220 |
* <p>Gets layer name</p>
|
|
221 |
* @return
|
|
222 |
*/
|
|
226 | 223 |
public String getName() { |
227 | 224 |
return this.name; |
228 | 225 |
} |
229 |
|
|
230 |
/** |
|
231 |
* <p>Sets layer name</p> |
|
232 |
* @param _name |
|
233 |
*/ |
|
226 |
|
|
227 |
/**
|
|
228 |
* <p>Sets layer name</p>
|
|
229 |
* @param _name
|
|
230 |
*/
|
|
234 | 231 |
public void setName(String name) { |
235 | 232 |
this.name = name; |
236 | 233 |
} |
237 |
|
|
238 |
/** |
|
239 |
* <p>Gets layer title</p> |
|
240 |
* @return |
|
241 |
*/ |
|
234 |
|
|
235 |
/**
|
|
236 |
* <p>Gets layer title</p>
|
|
237 |
* @return
|
|
238 |
*/
|
|
242 | 239 |
public String getTitle() { |
243 | 240 |
return title; |
244 | 241 |
} |
245 |
|
|
246 |
/** |
|
247 |
* <p>Sets the layer title</p> |
|
248 |
* @param _title |
|
249 |
*/ |
|
242 |
|
|
243 |
/**
|
|
244 |
* <p>Sets the layer title</p>
|
|
245 |
* @param _title
|
|
246 |
*/
|
|
250 | 247 |
public void setTitle(String title) { |
251 | 248 |
this.title = title; |
252 | 249 |
} |
253 |
|
|
254 |
/** |
|
255 |
* <p>Gets the layer abstract</p> |
|
256 |
* @return |
|
257 |
*/ |
|
250 |
|
|
251 |
/**
|
|
252 |
* <p>Gets the layer abstract</p>
|
|
253 |
* @return
|
|
254 |
*/
|
|
258 | 255 |
public String getAbstract() { |
259 | 256 |
return layerAbstract; |
260 | 257 |
} |
261 |
|
|
262 |
/** |
|
263 |
* <p>Sets the layer abstract</p> |
|
264 |
* @param m_abstract |
|
265 |
*/ |
|
258 |
|
|
259 |
/**
|
|
260 |
* <p>Sets the layer abstract</p>
|
|
261 |
* @param m_abstract
|
|
262 |
*/
|
|
266 | 263 |
public void setAbstract(String _abstract) { |
267 | 264 |
layerAbstract = _abstract; |
268 | 265 |
} |
269 | 266 |
|
270 | 267 |
|
271 | 268 |
public ArrayList getChildren() { |
272 |
return children;
|
|
269 |
return children;
|
|
273 | 270 |
} |
274 | 271 |
|
275 | 272 |
|
276 | 273 |
public void setChildren(ArrayList children) { |
277 |
this.children = children;
|
|
274 |
this.children = children;
|
|
278 | 275 |
} |
279 | 276 |
|
280 | 277 |
|
281 | 278 |
public WMSLayer1_1_1 getParent() { |
282 |
return parent;
|
|
279 |
return parent;
|
|
283 | 280 |
} |
284 | 281 |
|
285 | 282 |
|
286 | 283 |
public void setParent(WMSLayer1_1_1 parent) { |
287 |
this.parent = parent;
|
|
284 |
this.parent = parent;
|
|
288 | 285 |
} |
289 | 286 |
|
290 | 287 |
public String toString(){ |
291 |
return this.getTitle();
|
|
288 |
return this.getTitle();
|
|
292 | 289 |
} |
290 |
|
|
291 |
/** |
|
292 |
* Adds a new named style to the named styles list of this layer. |
|
293 |
* |
|
294 |
* @param namedStyle the new named style to be added. |
|
295 |
*/ |
|
296 |
public void addNamedStyle(String namedStyle) { |
|
297 |
String[] stylesArray = namedStyle.split(" "); |
|
298 |
for (int i = 0; i < stylesArray.length; i++){ |
|
299 |
this.namedStyles.add(stylesArray[i]); |
|
300 |
} |
|
301 |
} |
|
302 |
|
|
303 |
/** |
|
304 |
* Gets the list of named styles of this layer |
|
305 |
* |
|
306 |
* @return ArrayList containing those styles |
|
307 |
*/ |
|
308 |
public ArrayList getNamedStyles() { |
|
309 |
ArrayList ret = new ArrayList(); |
|
310 |
ret.addAll(namedStyles); |
|
311 |
|
|
312 |
if (parent != null) { |
|
313 |
ret.addAll(parent.getNamedStyles()); |
|
314 |
} |
|
315 |
|
|
316 |
return ret; |
|
317 |
} |
|
318 |
|
|
319 |
|
|
320 |
/** |
|
321 |
* Tells if this layer accepts getFeatureInfo requests. |
|
322 |
*/ |
|
323 |
public boolean isQueryable() { |
|
324 |
return queryable; |
|
325 |
} |
|
326 |
|
|
327 |
|
|
328 |
/** |
|
329 |
* @param queryable The queryable to set. |
|
330 |
*/ |
|
331 |
public void setQueryable(boolean queryable) { |
|
332 |
this.queryable = queryable; |
|
333 |
} |
|
293 | 334 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSClient.java | ||
---|---|---|
4 | 4 |
import java.awt.geom.Rectangle2D; |
5 | 5 |
import java.util.TreeMap; |
6 | 6 |
import java.util.Vector; |
7 |
|
|
7 | 8 |
import org.gvsig.remoteClient.exceptions.WMSException; |
8 | 9 |
import org.gvsig.remoteClient.utils.BoundaryBox; |
9 | 10 |
import org.gvsig.remoteClient.wms.wms_1_1_1.WMSProtocolHandler1_1_1; |
... | ... | |
14 | 15 |
* |
15 | 16 |
*/ |
16 | 17 |
public class WMSClient extends org.gvsig.remoteClient.RasterClient { |
17 |
|
|
18 |
|
|
18 | 19 |
private org.gvsig.remoteClient.wms.WMSProtocolHandler handler; |
19 | 20 |
private TreeMap layers = new TreeMap(); |
20 |
|
|
21 |
private WMSLayer rootLayer; |
|
21 | 22 |
|
22 | 23 |
/** |
24 |
* @return Returns the rootLayer. |
|
25 |
*/ |
|
26 |
public WMSLayer getRootLayer() { |
|
27 |
return rootLayer; |
|
28 |
} |
|
29 |
|
|
30 |
/** |
|
31 |
* @param rootLayer The rootLayer to set. |
|
32 |
*/ |
|
33 |
public void setRootLayer(WMSLayer rootLayer) { |
|
34 |
this.rootLayer = rootLayer; |
|
35 |
} |
|
36 |
|
|
37 |
/** |
|
23 | 38 |
* Constructor. |
24 | 39 |
* the parameter host, indicates the WMS host to connect. |
25 | 40 |
* */ |
26 |
public WMSClient(String host) |
|
27 |
{ |
|
28 |
//m_log = LogManager.getLogManager().getLogger(getClass().getName()); |
|
29 |
setHost(host); |
|
30 |
try |
|
31 |
{ |
|
32 |
//TODO: implement a correct negotiation algorithm |
|
33 |
//handler = WMSProtocolHandlerFactory.negotiate(new URL(host)); |
|
34 |
handler = new WMSProtocolHandler1_1_1(); |
|
35 |
handler.setHost(host); |
|
36 |
} |
|
37 |
catch(Exception e) |
|
38 |
{ |
|
39 |
e.printStackTrace(); |
|
40 |
} |
|
41 |
} |
|
42 |
|
|
43 |
public String getVersion() |
|
44 |
{ |
|
45 |
return handler.getVersion(); |
|
46 |
} |
|
47 |
/** |
|
48 |
* <p>One of the three interfaces that OGC WMS defines. Request a map.</p> |
|
49 |
*/ |
|
41 |
public WMSClient(String host) |
|
42 |
{ |
|
43 |
//m_log = LogManager.getLogManager().getLogger(getClass().getName()); |
|
44 |
setHost(host); |
|
45 |
/* |
|
46 |
|
|
47 |
The negotiation is performed in the connect method. |
|
48 |
|
|
49 |
try |
|
50 |
{ |
|
51 |
//TODO: implement a correct negotiation algorithm |
|
52 |
//handler = WMSProtocolHandlerFactory.negotiate(new URL(host)); |
|
53 |
handler = new WMSProtocolHandler1_1_1(); |
|
54 |
handler.setHost(host); |
|
55 |
} |
|
56 |
catch(Exception e) |
|
57 |
{ |
|
58 |
e.printStackTrace(); |
|
59 |
} |
|
60 |
*/ |
|
61 |
handler = new WMSProtocolHandler1_1_1(); |
|
62 |
handler.setHost(host); |
|
63 |
} |
|
64 |
|
|
65 |
public String getVersion() |
|
66 |
{ |
|
67 |
return handler.getVersion(); |
|
68 |
} |
|
69 |
/** |
|
70 |
* <p>One of the three interfaces that OGC WMS defines. Request a map.</p> |
|
71 |
*/ |
|
50 | 72 |
public byte[] getMap(WMSStatus status) throws WMSException{ |
51 | 73 |
return handler.getMap(status); |
52 | 74 |
} |
53 |
|
|
54 |
/** |
|
55 |
* <p>One of the three interfaces defined by OGC WMS, it gets the service capabilities</p> |
|
56 |
* |
|
57 |
*/ |
|
75 |
|
|
76 |
/**
|
|
77 |
* <p>One of the three interfaces defined by OGC WMS, it gets the service capabilities</p>
|
|
78 |
*
|
|
79 |
*/
|
|
58 | 80 |
public void getCapabilities() { |
59 | 81 |
handler.getCapabilities(); |
60 | 82 |
layers = handler.layers; |
83 |
rootLayer = handler.rootLayer; |
|
61 | 84 |
} |
62 |
|
|
63 |
/** |
|
64 |
* <p>One of the three interfaces defined by the OGC WMS, it gets the information about a feature requested</p> |
|
65 |
* @return |
|
66 |
*/ |
|
85 |
|
|
86 |
/**
|
|
87 |
* <p>One of the three interfaces defined by the OGC WMS, it gets the information about a feature requested</p>
|
|
88 |
* @return
|
|
89 |
*/
|
|
67 | 90 |
public String getFeatureInfo(WMSStatus status, int x, int y, int featureCount) throws WMSException{ |
68 | 91 |
return handler.getFeatureInfo(status, x, y, featureCount); |
69 | 92 |
} |
70 |
|
|
71 |
/** |
|
72 |
* <p> Reads from the WMS Capabilities, the layers available in the service</p> |
|
73 |
* @return a TreeMap with the available layers in the WMS |
|
74 |
*/ |
|
93 |
|
|
94 |
/**
|
|
95 |
* <p> Reads from the WMS Capabilities, the layers available in the service</p>
|
|
96 |
* @return a TreeMap with the available layers in the WMS
|
|
97 |
*/
|
|
75 | 98 |
public TreeMap getLayers() { |
76 | 99 |
return layers; |
77 | 100 |
} |
78 |
|
|
79 |
/** |
|
80 |
* <p>Reads from the WMS Capabilities the number if layers available in the service</p> |
|
81 |
* @return, number of layers available |
|
82 |
*/ |
|
101 |
|
|
102 |
/**
|
|
103 |
* <p>Reads from the WMS Capabilities the number if layers available in the service</p>
|
|
104 |
* @return, number of layers available
|
|
105 |
*/
|
|
83 | 106 |
public int getNumberOfLayers() { |
84 |
if (layers != null) |
|
85 |
{ |
|
86 |
return layers.size(); |
|
87 |
} |
|
88 |
else |
|
89 |
{ |
|
90 |
return 0; |
|
91 |
} |
|
107 |
if (layers != null) |
|
108 |
{ |
|
109 |
return layers.size(); |
|
110 |
} |
|
111 |
return 0; |
|
92 | 112 |
} |
93 |
|
|
94 |
/** |
|
95 |
* <p>Gets the WMSLayer with this name</p> |
|
96 |
* |
|
97 |
* @param _name, layer name |
|
98 |
* @return the layer with this name |
|
99 |
*/ |
|
113 |
|
|
114 |
/**
|
|
115 |
* <p>Gets the WMSLayer with this name</p>
|
|
116 |
*
|
|
117 |
* @param _name, layer name
|
|
118 |
* @return the layer with this name
|
|
119 |
*/
|
|
100 | 120 |
public WMSLayer getLayer(String _name) { |
101 |
if (layers.get(_name) != null)
|
|
102 |
{
|
|
103 |
return (WMSLayer)layers.get(_name); |
|
104 |
}
|
|
105 |
|
|
121 |
if (layers.get(_name) != null)
|
|
122 |
{
|
|
123 |
return (WMSLayer)layers.get(_name);
|
|
124 |
}
|
|
125 |
|
|
106 | 126 |
return null; |
107 | 127 |
} |
108 |
|
|
128 |
|
|
109 | 129 |
public String[] getLayerNames() |
110 | 130 |
{ |
111 |
WMSLayer[] lyrs;
|
|
112 |
|
|
113 |
lyrs = (WMSLayer[])layers.values().toArray(new WMSLayer[0]);
|
|
114 |
|
|
115 |
String[] names = new String[lyrs.length];
|
|
116 |
|
|
117 |
for(int i = 0; i<lyrs.length; i++)
|
|
118 |
{
|
|
119 |
names[i] = ((WMSLayer)lyrs[i]).getName();
|
|
120 |
}
|
|
121 |
return names;
|
|
131 |
WMSLayer[] lyrs;
|
|
132 |
|
|
133 |
lyrs = (WMSLayer[])layers.values().toArray(new WMSLayer[0]);
|
|
134 |
|
|
135 |
String[] names = new String[lyrs.length];
|
|
136 |
|
|
137 |
for(int i = 0; i<lyrs.length; i++)
|
|
138 |
{
|
|
139 |
names[i] = ((WMSLayer)lyrs[i]).getName();
|
|
140 |
}
|
|
141 |
return names;
|
|
122 | 142 |
} |
123 | 143 |
|
124 |
// /**
|
|
125 |
// * Adds a Layer object to the vector of layers of this LayerSet
|
|
126 |
// */
|
|
127 |
// public void addLayer(WMSLayer layer)
|
|
128 |
// {
|
|
129 |
// String layerName = layer.getName();
|
|
130 |
// |
|
131 |
// if (layerName == null)
|
|
132 |
// {
|
|
133 |
// throw new RuntimeException("Error: attempt to add a nameless layer");
|
|
134 |
// }
|
|
135 |
// |
|
136 |
// // We use the lower case version of the name as a key for the hash map.
|
|
137 |
// layerName = layerName.toLowerCase();
|
|
138 |
// if (layers == null)
|
|
139 |
// {
|
|
140 |
// layers = new TreeMap();
|
|
141 |
// }
|
|
142 |
// layers.put(layerName, layer);
|
|
143 |
// }
|
|
144 |
// /** |
|
145 |
// * Adds a Layer object to the vector of layers of this LayerSet |
|
146 |
// */ |
|
147 |
// public void addLayer(WMSLayer layer) |
|
148 |
// { |
|
149 |
// String layerName = layer.getName(); |
|
150 |
//
|
|
151 |
// if (layerName == null) |
|
152 |
// { |
|
153 |
// throw new RuntimeException("Error: attempt to add a nameless layer"); |
|
154 |
// } |
|
155 |
//
|
|
156 |
// // We use the lower case version of the name as a key for the hash map. |
|
157 |
// layerName = layerName.toLowerCase(); |
|
158 |
// if (layers == null) |
|
159 |
// { |
|
160 |
// layers = new TreeMap(); |
|
161 |
// } |
|
162 |
// layers.put(layerName, layer); |
|
163 |
// } |
|
144 | 164 |
|
145 |
/** |
|
146 |
* <p>Gets the image formats available in the Service to retrieve the maps</p> |
|
147 |
* @return a vector with all the available formats |
|
148 |
*/ |
|
165 |
/**
|
|
166 |
* <p>Gets the image formats available in the Service to retrieve the maps</p>
|
|
167 |
* @return a vector with all the available formats
|
|
168 |
*/
|
|
149 | 169 |
public Vector getFormats() { |
150 | 170 |
return handler.getServiceInformation().formats; |
151 | 171 |
} |
152 |
|
|
153 |
/** |
|
154 |
* <p>Gets the SRS availables in the Service, all the SRS the Service can reproject to.</p> |
|
155 |
* @return vector with all the available SRS. |
|
156 |
*/ |
|
172 |
|
|
173 |
/**
|
|
174 |
* <p>Gets the SRS availables in the Service, all the SRS the Service can reproject to.</p>
|
|
175 |
* @return vector with all the available SRS.
|
|
176 |
*/
|
|
157 | 177 |
public Vector getSrs() { |
158 |
return handler.srs; |
|
178 |
return handler.srs;
|
|
159 | 179 |
} |
160 |
|
|
180 |
|
|
161 | 181 |
public void close() { |
162 | 182 |
// your code here |
163 | 183 |
} |
164 | 184 |
|
165 | 185 |
|
166 |
/** |
|
167 |
* Returns the max extent that envolves the requested layers |
|
168 |
* */ |
|
169 |
public Rectangle2D getLayersExtent(String[]layerNames, String srs) |
|
170 |
{ |
|
171 |
try |
|
172 |
{ |
|
173 |
BoundaryBox bbox; |
|
174 |
WMSLayer layer = getLayer(layerNames[0]); |
|
175 |
|
|
176 |
bbox = layer.getBbox(srs); |
|
177 |
double xmin = bbox.getXmin(); |
|
178 |
double xmax = bbox.getXmax(); |
|
179 |
double ymin = bbox.getYmin(); |
|
180 |
double ymax = bbox.getYmax(); |
|
181 |
|
|
182 |
for(int i=1; i<layerNames.length; i++) |
|
183 |
{ |
|
184 |
layer = getLayer(layerNames[i]); |
|
185 |
bbox = layer.getBbox(srs); |
|
186 |
|
|
187 |
if (bbox.getXmin() < xmin) |
|
188 |
{ |
|
189 |
xmin = bbox.getXmin(); |
|
190 |
} |
|
191 |
if (bbox.getYmin() < ymin) |
|
192 |
{ |
|
193 |
ymin = bbox.getYmin(); |
|
194 |
} |
|
195 |
if (bbox.getXmax() > xmax) |
|
196 |
{ |
|
197 |
xmax = bbox.getXmax(); |
|
198 |
} |
|
199 |
if (bbox.getYmax() > ymax) |
|
200 |
{ |
|
201 |
ymax = bbox.getYmax(); |
|
202 |
} |
|
203 |
} |
|
204 |
Rectangle2D extent = new Rectangle2D.Double(xmin,ymin,Math.abs(xmax-xmin),Math.abs(ymax-ymin)); |
|
205 |
return extent; |
|
206 |
} |
|
207 |
catch(Exception e) |
|
208 |
{ |
|
209 |
//TODO: |
|
210 |
//Implement logic to handle all the exceptions |
|
211 |
return null; |
|
212 |
} |
|
213 |
} |
|
214 |
|
|
215 |
|
|
216 |
/** |
|
217 |
* Gets the Service information included in the Capabilities |
|
218 |
* */ |
|
219 |
|
|
220 |
public WMSProtocolHandler.ServiceInformation getServiceInformation() |
|
221 |
{ |
|
222 |
return handler.getServiceInformation(); |
|
223 |
} |
|
224 |
/** |
|
225 |
* <p>Checks the connection to de remote WMS and requests its capabilities.</p> |
|
226 |
* |
|
227 |
*/ |
|
186 |
/** |
|
187 |
* Returns the max extent that envolves the requested layers |
|
188 |
* */ |
|
189 |
public Rectangle2D getLayersExtent(String[]layerNames, String srs) |
|
190 |
{ |
|
191 |
try |
|
192 |
{ |
|
193 |
BoundaryBox bbox; |
|
194 |
WMSLayer layer = getLayer(layerNames[0]); |
|
195 |
|
|
196 |
bbox = layer.getBbox(srs); |
|
197 |
double xmin = bbox.getXmin(); |
|
198 |
double xmax = bbox.getXmax(); |
|
199 |
double ymin = bbox.getYmin(); |
|
200 |
double ymax = bbox.getYmax(); |
|
201 |
|
|
202 |
for(int i=1; i<layerNames.length; i++) |
|
203 |
{ |
|
204 |
layer = getLayer(layerNames[i]); |
|
205 |
bbox = layer.getBbox(srs); |
|
206 |
|
|
207 |
if (bbox.getXmin() < xmin) |
|
208 |
{ |
|
209 |
xmin = bbox.getXmin(); |
|
210 |
} |
|
211 |
if (bbox.getYmin() < ymin) |
|
212 |
{ |
|
213 |
ymin = bbox.getYmin(); |
|
214 |
} |
|
215 |
if (bbox.getXmax() > xmax) |
|
216 |
{ |
|
217 |
xmax = bbox.getXmax(); |
|
218 |
} |
|
219 |
if (bbox.getYmax() > ymax) |
|
220 |
{ |
|
221 |
ymax = bbox.getYmax(); |
|
222 |
} |
|
223 |
} |
|
224 |
Rectangle2D extent = new Rectangle2D.Double(xmin,ymin,Math.abs(xmax-xmin),Math.abs(ymax-ymin)); |
|
225 |
return extent; |
|
226 |
} |
|
227 |
catch(Exception e) |
|
228 |
{ |
|
229 |
e.printStackTrace(); |
|
230 |
return null; |
|
231 |
} |
|
232 |
} |
|
233 |
|
|
234 |
|
|
235 |
/** |
|
236 |
* Gets the Service information included in the Capabilities |
|
237 |
* */ |
|
238 |
|
|
239 |
public WMSProtocolHandler.ServiceInformation getServiceInformation() |
|
240 |
{ |
|
241 |
return handler.getServiceInformation(); |
|
242 |
} |
|
243 |
/** |
|
244 |
* <p>Checks the connection to de remote WMS and requests its capabilities.</p> |
|
245 |
* |
|
246 |
*/ |
|
228 | 247 |
public boolean connect() |
229 |
{
|
|
230 |
try {
|
|
231 |
getCapabilities();
|
|
232 |
if (handler == null)
|
|
233 |
{
|
|
234 |
if (getHost().trim().length() > 0)
|
|
235 |
{
|
|
236 |
//TODO: Implement correctly the negotiate algorithm
|
|
237 |
//handler = WMSProtocolHandlerFactory.negotiate(new URL(getHost()));
|
|
238 |
handler = new WMSProtocolHandler1_1_1();
|
|
239 |
handler.setHost(getHost());
|
|
240 |
}
|
|
241 |
else
|
|
242 |
{
|
|
243 |
//must to specify host first!!!!
|
|
244 |
return false;
|
|
245 |
}
|
|
246 |
}
|
|
247 |
return true;
|
|
248 |
|
|
249 |
} catch (Exception e) {
|
|
250 |
e.printStackTrace();
|
|
251 |
return false;
|
|
252 |
}
|
|
253 |
}
|
|
254 |
|
|
248 |
{
|
|
249 |
try {
|
|
250 |
getCapabilities();
|
|
251 |
if (handler == null)
|
|
252 |
{
|
|
253 |
if (getHost().trim().length() > 0)
|
|
254 |
{
|
|
255 |
//TODO: Implement correctly the negotiate algorithm
|
|
256 |
//handler = WMSProtocolHandlerFactory.negotiate(new URL(getHost()));
|
|
257 |
handler = new WMSProtocolHandler1_1_1();
|
|
258 |
handler.setHost(getHost());
|
|
259 |
}
|
|
260 |
else
|
|
261 |
{
|
|
262 |
//must to specify host first!!!!
|
|
263 |
return false;
|
|
264 |
}
|
|
265 |
}
|
|
266 |
return true;
|
|
267 |
|
|
268 |
} catch (Exception e) {
|
|
269 |
e.printStackTrace();
|
|
270 |
return false;
|
|
271 |
}
|
|
272 |
}
|
|
273 |
|
|
255 | 274 |
//TODO Check this out: Always 1 layer at first level... |
256 | 275 |
public WMSLayer getLayersRoot() { |
257 |
return (WMSLayer)layers.values().toArray()[0];
|
|
276 |
return rootLayer;
|
|
258 | 277 |
} |
259 | 278 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/WMSProtocolHandler.java | ||
---|---|---|
25 | 25 |
*/ |
26 | 26 |
public abstract class WMSProtocolHandler { |
27 | 27 |
|
28 |
// procotol handler name |
|
28 |
/** |
|
29 |
* procotol handler name |
|
30 |
*/ |
|
29 | 31 |
protected String name; |
30 |
// protocol handler version |
|
32 |
/** |
|
33 |
* protocol handler version |
|
34 |
*/ |
|
31 | 35 |
protected String version; |
32 |
//host of the WMS to conenct |
|
36 |
/** |
|
37 |
* host of the WMS to connect |
|
38 |
*/ |
|
33 | 39 |
protected String host; |
34 |
// port number of the comunication channel of the WMS to connect |
|
40 |
/** |
|
41 |
* port number of the comunication channel of the WMS to connect |
|
42 |
*/ |
|
35 | 43 |
protected String port; |
36 |
//WMS metadata |
|
44 |
/** |
|
45 |
* WMS metadata |
|
46 |
*/ |
|
37 | 47 |
protected ServiceInformation serviceInfo; |
38 | 48 |
public TreeMap layers; |
49 |
public WMSLayer rootLayer; |
|
39 | 50 |
public Vector srs; |
40 | 51 |
|
41 | 52 |
|
... | ... | |
100 | 111 |
int readed = 0; |
101 | 112 |
|
102 | 113 |
for (int i = is.read(buffer); i>0; i = is.read(buffer)){ |
114 |
// Creates a new buffer to contain the previous readed bytes and the next bunch of bytes |
|
103 | 115 |
byte[] buffered = new byte[readed+i]; |
104 | 116 |
for (int j = 0; j < buffered.length; j++) { |
105 | 117 |
if (j<readed){ |
118 |
// puts the previously downloaded bytes into the image buffer |
|
106 | 119 |
buffered[j] = imageBytes[j]; |
107 | 120 |
} |
108 | 121 |
else { |
122 |
// appends the recently downloaded bytes to the image buffer. |
|
109 | 123 |
buffered[j] = buffer[j-readed]; |
110 | 124 |
} |
111 | 125 |
} |
... | ... | |
213 | 227 |
} |
214 | 228 |
catch(Exception e) |
215 | 229 |
{ |
216 |
//TODO |
|
217 |
//Implement the correct logic to handle all the exceptions. |
|
218 |
return null; |
|
230 |
e.printStackTrace(); |
|
231 |
return null; |
|
219 | 232 |
} |
220 | 233 |
} |
221 | 234 |
|
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/wms_1_1_1/WMSLayer1_1_1.java | ||
---|---|---|
17 | 17 |
* |
18 | 18 |
*/ |
19 | 19 |
public class WMSLayer1_1_1 extends org.gvsig.remoteClient.wms.WMSLayer { |
20 |
|
|
21 |
|
|
22 |
public WMSLayer1_1_1() |
|
23 |
{ |
|
24 |
children = new ArrayList(); |
|
25 |
} |
|
26 |
/** |
|
27 |
* <p>Parses the contents of the parser(WMSCapabilities) |
|
28 |
* to extract the information about an WMSLayer</p> |
|
29 |
* |
|
30 |
*/ |
|
31 |
public void parse(KXmlParser parser, TreeMap layerTreeMap) |
|
32 |
throws IOException, XmlPullParserException |
|
20 |
|
|
21 |
|
|
22 |
public WMSLayer1_1_1() |
|
33 | 23 |
{ |
34 |
int currentTag; |
|
35 |
boolean end = false; |
|
36 |
String value; |
|
37 |
BoundaryBox bbox; |
|
38 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.LAYER); |
|
39 |
|
|
40 |
//First of all set whether the layer is Queryable reading the attribute. |
|
41 |
value = parser.getAttributeValue("", CapabilitiesTags.QUERYABLE); |
|
42 |
if (value != null) |
|
43 |
{ |
|
44 |
if (value.compareTo("0")==0) |
|
45 |
setQueryable(false); |
|
46 |
else |
|
47 |
setQueryable(true); |
|
48 |
} |
|
49 |
|
|
50 |
currentTag = parser.nextTag(); |
|
51 |
|
|
52 |
while (!end) |
|
53 |
{ |
|
54 |
switch(currentTag) |
|
55 |
{ |
|
56 |
case KXmlParser.START_TAG: |
|
57 |
if (parser.getName().compareTo(CapabilitiesTags.LAYER)==0) |
|
58 |
{ |
|
59 |
WMSLayer1_1_1 lyr = new WMSLayer1_1_1(); |
|
60 |
//parser.next(); |
|
61 |
lyr.parse(parser, layerTreeMap); |
|
62 |
lyr.setParent(this); |
|
63 |
getChildren().add(lyr); |
|
64 |
layerTreeMap.put(lyr.getName(), lyr); |
|
65 |
} |
|
66 |
else if (parser.getName().compareTo(CapabilitiesTags.NAME)==0) |
|
67 |
{ |
|
68 |
value = parser.nextText(); |
|
69 |
if (value != null) setName(value); |
|
70 |
} |
|
71 |
else if (parser.getName().compareTo(CapabilitiesTags.TITLE)==0) |
|
72 |
{ |
|
73 |
value = parser.nextText(); |
|
74 |
if (value != null) setTitle(value); |
|
75 |
} |
|
76 |
else if (parser.getName().compareTo(CapabilitiesTags.ABSTRACT)==0) |
|
77 |
{ |
|
78 |
value = parser.nextText(); |
|
79 |
if (value != null) setAbstract(value); |
|
80 |
} |
|
81 |
else if (parser.getName().compareTo(CapabilitiesTags.SRS)==0) |
|
82 |
{ |
|
83 |
value = parser.nextText(); |
|
84 |
if (value != null) addSrs(value); |
|
85 |
} |
|
86 |
else if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0) |
|
87 |
{ |
|
88 |
bbox = new BoundaryBox(); |
|
89 |
value = parser.getAttributeValue("",CapabilitiesTags.SRS); |
|
90 |
if (value != null) |
|
91 |
bbox.setSrs(value); |
|
92 |
value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
|
93 |
if ((value != null) && (Utilities.isNumber(value))) |
|
94 |
bbox.setXmin(Double.parseDouble(value)); |
|
95 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY); |
|
96 |
if ((value != null) && (Utilities.isNumber(value))) |
|
97 |
bbox.setYmin(Double.parseDouble(value)); |
|
98 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX); |
|
99 |
if ((value != null) && (Utilities.isNumber(value))) |
|
100 |
bbox.setXmax(Double.parseDouble(value)); |
|
101 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY); |
|
102 |
if ((value != null) && (Utilities.isNumber(value))) |
|
103 |
bbox.setYmax(Double.parseDouble(value)); |
|
104 |
addBBox(bbox); |
|
105 |
} |
|
106 |
else if (parser.getName().compareTo(CapabilitiesTags.LATLONBOUNDINGBOX)==0) |
|
107 |
{ |
|
108 |
bbox = new BoundaryBox(); |
|
109 |
bbox.setSrs("4326"); |
|
110 |
value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
|
111 |
if ((value != null) && (Utilities.isNumber(value))) |
|
112 |
bbox.setXmin(Double.parseDouble(value)); |
|
113 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY); |
|
114 |
if ((value != null) && (Utilities.isNumber(value))) |
|
115 |
bbox.setYmin(Double.parseDouble(value)); |
|
116 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX); |
|
117 |
if ((value != null) && (Utilities.isNumber(value))) |
|
118 |
bbox.setXmax(Double.parseDouble(value)); |
|
119 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY); |
|
120 |
if ((value != null) && (Utilities.isNumber(value))) |
|
121 |
bbox.setYmax(Double.parseDouble(value)); |
|
122 |
setLatLonBox(bbox); |
|
123 |
} |
|
124 |
else if (parser.getName().compareTo(CapabilitiesTags.SCALEHINT)==0) |
|
125 |
{ |
|
126 |
value = parser.getAttributeValue("",CapabilitiesTags.MIN); |
|
127 |
if ((value != null) && (Utilities.isNumber(value))) |
|
128 |
setScaleMin(Double.parseDouble(value)); |
|
129 |
value = parser.getAttributeValue("",CapabilitiesTags.MAX); |
|
130 |
if ((value != null) && (Utilities.isNumber(value))) |
|
131 |
setScaleMax(Double.parseDouble(value)); |
|
132 |
} |
|
133 |
else if (parser.getName().compareTo(CapabilitiesTags.STYLE)==0) |
|
134 |
{ |
|
135 |
WMSStyle1_1_1 style = new WMSStyle1_1_1(); |
|
136 |
style.parse(parser); |
|
137 |
if((style != null) && (style.getName() != null)) |
|
138 |
{ |
|
139 |
styles.put(style.getName(),style); |
|
140 |
} |
|
141 |
} |
|
142 |
break; |
|
143 |
case KXmlParser.END_TAG: |
|
144 |
if (parser.getName().compareTo(CapabilitiesTags.LAYER) == 0) |
|
145 |
end = true; |
|
146 |
break; |
|
147 |
case KXmlParser.TEXT: |
|
148 |
break; |
|
149 |
} |
|
150 |
//if (!end) |
|
151 |
//{ |
|
152 |
currentTag = parser.next(); |
|
153 |
//} |
|
154 |
} |
|
155 |
//parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.LAYER); |
|
24 |
children = new ArrayList(); |
|
25 |
} |
|
26 |
/** |
|
27 |
* <p>Parses the contents of the parser(WMSCapabilities) |
|
28 |
* to extract the information about an WMSLayer</p> |
|
29 |
* |
|
30 |
*/ |
|
31 |
public void parse(KXmlParser parser, TreeMap layerTreeMap) |
|
32 |
throws IOException, XmlPullParserException |
|
33 |
{ |
|
34 |
int currentTag; |
|
35 |
boolean end = false; |
|
36 |
String value; |
|
37 |
BoundaryBox bbox; |
|
38 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.LAYER); |
|
39 |
|
|
40 |
//First of all set whether the layer is Queryable reading the attribute. |
|
41 |
value = parser.getAttributeValue("", CapabilitiesTags.QUERYABLE); |
|
42 |
if (value != null) |
|
43 |
{ |
|
44 |
if (value.compareTo("0")==0) |
|
45 |
setQueryable(false); |
|
46 |
else |
|
47 |
setQueryable(true); |
|
48 |
} |
|
49 |
|
|
50 |
currentTag = parser.nextTag(); |
|
51 |
|
|
52 |
while (!end) |
|
53 |
{ |
|
54 |
switch(currentTag) |
|
55 |
{ |
|
56 |
case KXmlParser.START_TAG: |
|
57 |
if (parser.getName().compareTo(CapabilitiesTags.LAYER)==0) |
|
58 |
{ |
|
59 |
WMSLayer1_1_1 lyr = new WMSLayer1_1_1(); |
|
60 |
//parser.next(); |
|
61 |
lyr.parse(parser, layerTreeMap); |
|
62 |
lyr.setParent(this); |
|
63 |
getChildren().add(lyr); |
|
64 |
layerTreeMap.put(lyr.getName(), lyr); |
|
65 |
} |
|
66 |
else if (parser.getName().compareTo(CapabilitiesTags.NAME)==0) |
|
67 |
{ |
|
68 |
value = parser.nextText(); |
|
69 |
if (value != null) setName(value); |
|
70 |
} |
|
71 |
else if (parser.getName().compareTo(CapabilitiesTags.TITLE)==0) |
|
72 |
{ |
|
73 |
value = parser.nextText(); |
|
74 |
if (value != null) setTitle(value); |
|
75 |
} |
|
76 |
else if (parser.getName().compareTo(CapabilitiesTags.ABSTRACT)==0) |
|
77 |
{ |
|
78 |
value = parser.nextText(); |
|
79 |
if (value != null) setAbstract(value); |
|
80 |
} |
|
81 |
else if (parser.getName().compareTo(CapabilitiesTags.SRS)==0) |
|
82 |
{ |
|
83 |
value = parser.nextText(); |
|
84 |
if (value != null) addSrs(value); |
|
85 |
} |
|
86 |
else if (parser.getName().compareTo(CapabilitiesTags.BOUNDINGBOX)==0) |
|
87 |
{ |
|
88 |
bbox = new BoundaryBox(); |
|
89 |
value = parser.getAttributeValue("",CapabilitiesTags.SRS); |
|
90 |
if (value != null) |
|
91 |
bbox.setSrs(value); |
|
92 |
value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
|
93 |
if ((value != null) && (Utilities.isNumber(value))) |
|
94 |
bbox.setXmin(Double.parseDouble(value)); |
|
95 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY); |
|
96 |
if ((value != null) && (Utilities.isNumber(value))) |
|
97 |
bbox.setYmin(Double.parseDouble(value)); |
|
98 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX); |
|
99 |
if ((value != null) && (Utilities.isNumber(value))) |
|
100 |
bbox.setXmax(Double.parseDouble(value)); |
|
101 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY); |
|
102 |
if ((value != null) && (Utilities.isNumber(value))) |
|
103 |
bbox.setYmax(Double.parseDouble(value)); |
|
104 |
addBBox(bbox); |
|
105 |
} |
|
106 |
else if (parser.getName().compareTo(CapabilitiesTags.LATLONBOUNDINGBOX)==0) |
|
107 |
{ |
|
108 |
bbox = new BoundaryBox(); |
|
109 |
bbox.setSrs("EPSG:4326"); |
|
110 |
value = parser.getAttributeValue("",CapabilitiesTags.MINX); |
|
111 |
if ((value != null) && (Utilities.isNumber(value))) |
|
112 |
bbox.setXmin(Double.parseDouble(value)); |
|
113 |
value = parser.getAttributeValue("",CapabilitiesTags.MINY); |
|
114 |
if ((value != null) && (Utilities.isNumber(value))) |
|
115 |
bbox.setYmin(Double.parseDouble(value)); |
|
116 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXX); |
|
117 |
if ((value != null) && (Utilities.isNumber(value))) |
|
118 |
bbox.setXmax(Double.parseDouble(value)); |
|
119 |
value = parser.getAttributeValue("",CapabilitiesTags.MAXY); |
|
120 |
if ((value != null) && (Utilities.isNumber(value))) |
|
121 |
bbox.setYmax(Double.parseDouble(value)); |
|
122 |
addBBox(bbox); |
|
123 |
setLatLonBox(bbox); |
|
124 |
} |
|
125 |
else if (parser.getName().compareTo(CapabilitiesTags.SCALEHINT)==0) |
|
126 |
{ |
|
127 |
value = parser.getAttributeValue("",CapabilitiesTags.MIN); |
|
128 |
if ((value != null) && (Utilities.isNumber(value))) |
|
129 |
setScaleMin(Double.parseDouble(value)); |
|
130 |
value = parser.getAttributeValue("",CapabilitiesTags.MAX); |
|
131 |
if ((value != null) && (Utilities.isNumber(value))) |
|
132 |
setScaleMax(Double.parseDouble(value)); |
|
133 |
} |
|
134 |
else if (parser.getName().compareTo(CapabilitiesTags.STYLE)==0) |
|
135 |
{ |
|
136 |
WMSStyle1_1_1 style = new WMSStyle1_1_1(); |
|
137 |
style.parse(parser); |
|
138 |
if((style != null) && (style.getName() != null)) |
|
139 |
{ |
|
140 |
styles.put(style.getName(),style); |
|
141 |
} |
|
142 |
} |
|
143 |
break; |
|
144 |
case KXmlParser.END_TAG: |
|
145 |
if (parser.getName().compareTo(CapabilitiesTags.LAYER) == 0) |
|
146 |
end = true; |
|
147 |
break; |
|
148 |
case KXmlParser.TEXT: |
|
149 |
break; |
|
150 |
} |
|
151 |
//if (!end) |
|
152 |
//{ |
|
153 |
currentTag = parser.next(); |
|
154 |
//} |
|
155 |
} |
|
156 |
//parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.LAYER); |
|
156 | 157 |
} |
157 |
} |
|
158 |
|
|
159 |
public String toString(){ |
|
160 |
return super.toString(); |
|
161 |
} |
|
162 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/wms_1_1_1/WMSProtocolHandler1_1_1.java | ||
---|---|---|
172 | 172 |
else if (parser.getName().compareTo(CapabilitiesTags.LAYER)==0) |
173 | 173 |
{ |
174 | 174 |
WMSLayer1_1_1 lyr = new WMSLayer1_1_1(); |
175 |
lyr.parse(parser,layers); |
|
175 |
rootLayer = lyr; |
|
176 |
lyr.parse(parser, layers); |
|
176 | 177 |
//if((lyr != null) && (lyr.getName() != null)) |
177 | 178 |
//{ |
179 |
if (lyr.getName()!=null) |
|
178 | 180 |
layers.put(lyr.getName(), lyr); |
179 | 181 |
//Add all the SRS that the layer supports to the WMSProtocolHandler if they dont exist already |
180 | 182 |
for (i=0;i<lyr.getAllSrs().size();i++) |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/OGCProtocolHandler.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.remoteClient; |
|
42 |
|
|
43 |
import java.io.BufferedOutputStream; |
|
44 |
import java.io.DataOutputStream; |
|
45 |
import java.io.File; |
|
46 |
import java.io.FileOutputStream; |
|
47 |
import java.io.IOException; |
|
48 |
import java.io.InputStream; |
|
49 |
import java.net.ConnectException; |
|
50 |
import java.net.URL; |
|
51 |
import java.net.UnknownHostException; |
|
52 |
|
|
53 |
import com.devx.io.TempFileManager; |
|
54 |
|
|
55 |
public abstract class OGCProtocolHandler { |
|
56 |
/** |
|
57 |
* procotol handler name |
|
58 |
*/ |
|
59 |
protected String name; |
|
60 |
/** |
Also available in: Unified diff