svn-gvsig-desktop / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClient / wms / WMSStatus.java @ 38898
History | View | Annotate | Download (8.33 KB)
1 |
|
---|---|
2 |
package org.gvsig.remoteClient.wms; |
3 |
|
4 |
import java.awt.geom.Rectangle2D; |
5 |
import java.util.Vector; |
6 |
|
7 |
/**
|
8 |
* Describes the status of a WMSclient, so it adds to the Remote client status
|
9 |
* a list of layers, a list of layer styles, the extent of the map.
|
10 |
* Provides the functionality to modify these lists.
|
11 |
*
|
12 |
*/
|
13 |
public class WMSStatus extends org.gvsig.remoteClient.RemoteClientStatus { |
14 |
|
15 |
|
16 |
// list of layer to be retrieved by the WMS
|
17 |
private Vector layers; |
18 |
// List of layer styles
|
19 |
private Vector styles; |
20 |
private Vector dimensions; |
21 |
// extent required by the WMS client
|
22 |
private Rectangle2D extent; |
23 |
private boolean transparency; |
24 |
private String onlineResource; |
25 |
private String infoFormat; |
26 |
/* On WMS 1.3 we need to order the bounding box depending on the defined CRS axis order */
|
27 |
private int crsAxisOrder; |
28 |
|
29 |
public static final int CRS_AXIS_NORTH_EAST = 0; |
30 |
public static final int CRS_AXIS_EAST_NORTH = 1; |
31 |
public static final int CRS_AXIS_SOUTH_WEST = 2; |
32 |
public static final int CRS_AXIS_WEST_SOUTH = 3; |
33 |
public static final int CRS_AXIS_OTHER_OR_UNKNOWN = 4; |
34 |
|
35 |
public String getInfoFormat() { |
36 |
return infoFormat;
|
37 |
} |
38 |
|
39 |
public void setInfoFormat(String infoFormat) { |
40 |
this.infoFormat = infoFormat;
|
41 |
} |
42 |
|
43 |
public WMSStatus()
|
44 |
{ |
45 |
layers = new Vector(); |
46 |
styles = new Vector(); |
47 |
} |
48 |
|
49 |
// sets the list of layers required by the WMS client
|
50 |
public void setLayerNames(Vector _layers) { |
51 |
layers = _layers; |
52 |
} |
53 |
|
54 |
/**
|
55 |
* <p>Retrieves the layer list required by the WMS client</p>
|
56 |
*
|
57 |
*
|
58 |
* @return Vector, the list of layers
|
59 |
*/
|
60 |
public Vector getLayerNames() { |
61 |
return layers;
|
62 |
} |
63 |
|
64 |
/**
|
65 |
* <p> Adds a layer to the list of layers required by the WMS client</p>
|
66 |
*
|
67 |
*
|
68 |
* @param _layerName, name of the layer to be added.
|
69 |
*/
|
70 |
public void addLayerName(String _layerName) { |
71 |
layers.add(_layerName); |
72 |
} |
73 |
|
74 |
/**
|
75 |
* <p>removes a layer from the layer list</p>
|
76 |
*
|
77 |
*
|
78 |
* @param _layerName
|
79 |
* @return true if the layer name has been deleted from the list
|
80 |
*/
|
81 |
public boolean removeLayerName(String _layerName) { |
82 |
return layers.remove(_layerName);
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* <p>gets the styles list required by the WMS client</p>
|
87 |
*
|
88 |
*
|
89 |
* @return Vector with the list of layer styles
|
90 |
*/
|
91 |
public Vector getStyles() { |
92 |
return styles;
|
93 |
} |
94 |
|
95 |
/**
|
96 |
* <p>sets the styles list required by the WMS client</p>
|
97 |
*
|
98 |
*
|
99 |
* @param _styles, list to be set as the required styles.
|
100 |
*/
|
101 |
public void setStyles(Vector _styles) { |
102 |
styles = _styles; |
103 |
} |
104 |
|
105 |
/**
|
106 |
* <p>sets the styles list required by the WMS client</p>
|
107 |
*
|
108 |
*
|
109 |
* @param _styles, list to be set as the required styles.
|
110 |
*/
|
111 |
public void setDimensions(Vector _dimensions) { |
112 |
|
113 |
dimensions = _dimensions; |
114 |
} |
115 |
|
116 |
/**
|
117 |
* <p>Adds a style name to the styles list required by the WMS client</p>
|
118 |
*
|
119 |
*
|
120 |
* @param _name, style name to be added
|
121 |
*/
|
122 |
public void addStyleName(String _name) { |
123 |
styles.add( _name); |
124 |
} |
125 |
|
126 |
/**
|
127 |
* <p>Removes a style from the list of styles required by the WMS client</p>
|
128 |
*
|
129 |
*
|
130 |
* @param _name, style name to be removed
|
131 |
*/
|
132 |
public boolean removeStyleName(String _name) { |
133 |
return styles.remove(_name);
|
134 |
} |
135 |
/**
|
136 |
* <p>Gets the extent defined by the map</p>
|
137 |
*/
|
138 |
public Rectangle2D getExtent() { |
139 |
return extent;
|
140 |
} |
141 |
/**
|
142 |
* <p>Sets the extent defined by the map</p>
|
143 |
*/
|
144 |
public void setExtent(Rectangle2D extent) { |
145 |
this.extent = extent;
|
146 |
} |
147 |
|
148 |
|
149 |
|
150 |
/**
|
151 |
* @return
|
152 |
*/
|
153 |
public boolean getTransparency() { |
154 |
return transparency;
|
155 |
} |
156 |
|
157 |
/**
|
158 |
* @param wmsTransparency
|
159 |
*/
|
160 |
public void setTransparency(boolean wmsTransparency) { |
161 |
transparency = wmsTransparency; |
162 |
} |
163 |
|
164 |
/**
|
165 |
* @return
|
166 |
*/
|
167 |
public Vector getDimensions() { |
168 |
return dimensions;
|
169 |
} |
170 |
|
171 |
public boolean equals(Object obj){ |
172 |
if (!(obj instanceof WMSStatus)) |
173 |
return false; |
174 |
WMSStatus s = (WMSStatus) obj; |
175 |
|
176 |
// Compare layer names
|
177 |
if (!(( s.getLayerNames()==null && this.getLayerNames()==null) || |
178 |
s.getLayerNames().equals(this.getLayerNames())))
|
179 |
return false; |
180 |
|
181 |
// Compare extent
|
182 |
if (!(( s.getExtent()==null && this.getExtent()==null) || |
183 |
s.getExtent().equals(this.getExtent())))
|
184 |
return false; |
185 |
|
186 |
// Compare height
|
187 |
if ( s.getHeight() != this.getHeight()) |
188 |
return false; |
189 |
|
190 |
// Compare width
|
191 |
if ( s.getWidth() != this.getWidth()) |
192 |
return false; |
193 |
|
194 |
// Compare styles
|
195 |
if (!(( s.getStyles()==null && this.getStyles()==null) || |
196 |
s.getStyles().equals(this.getStyles())))
|
197 |
return false; |
198 |
|
199 |
// Compare dimensions
|
200 |
if (!(( s.getDimensions()==null && this.getDimensions()==null) || |
201 |
s.getDimensions().equals(this.getDimensions())))
|
202 |
return false; |
203 |
|
204 |
// Compare transparencies
|
205 |
if ( s.getTransparency() != this.getTransparency()) |
206 |
return false; |
207 |
|
208 |
// Compare srs
|
209 |
if (!(( s.getSrs()==null && this.getSrs()==null) || |
210 |
s.getSrs().equals(this.getSrs())))
|
211 |
return false; |
212 |
|
213 |
// Compare exception formats
|
214 |
if (!(( s.getExceptionFormat()==null && this.getExceptionFormat()==null) || |
215 |
s.getExceptionFormat().equals(this.getExceptionFormat())))
|
216 |
return false; |
217 |
|
218 |
// Compare formats
|
219 |
if (!(( s.getFormat()==null && this.getFormat()==null) || |
220 |
s.getFormat().equals(this.getFormat())))
|
221 |
return false; |
222 |
|
223 |
// Compare online resources
|
224 |
if (!(( s.getOnlineResource()==null && this.getOnlineResource()==null) || |
225 |
s.getOnlineResource().equals(this.getOnlineResource())))
|
226 |
return false; |
227 |
|
228 |
return true; |
229 |
} |
230 |
|
231 |
public Object clone() { |
232 |
WMSStatus newObject = new WMSStatus();
|
233 |
Vector v = this.getLayerNames(); |
234 |
if (v != null) |
235 |
newObject.setLayerNames((Vector)v.clone());
|
236 |
Rectangle2D r = this.getExtent(); |
237 |
if (r != null) |
238 |
newObject.setExtent((Rectangle2D)r.clone());
|
239 |
newObject.setHeight(this.getHeight());
|
240 |
newObject.setWidth(this.getWidth());
|
241 |
v = this.getStyles();
|
242 |
if (v != null) |
243 |
newObject.setStyles((Vector)v.clone());
|
244 |
v = this.getDimensions();
|
245 |
if (v != null) |
246 |
newObject.setDimensions((Vector)v.clone());
|
247 |
newObject.setTransparency(this.getTransparency());
|
248 |
newObject.setSrs(this.getSrs());
|
249 |
newObject.setExceptionFormat(this.getExceptionFormat());
|
250 |
newObject.setFormat(this.getFormat());
|
251 |
newObject.setOnlineResource(this.getOnlineResource());
|
252 |
newObject.setInfoFormat(this.infoFormat);
|
253 |
return newObject;
|
254 |
} |
255 |
|
256 |
/**
|
257 |
* Returns the URL that the server specified for a WMS request if any was described in
|
258 |
* its capabilities document.
|
259 |
* @param operationName, a String containing the name of the operation (case-independent)
|
260 |
* @return <b>String</b> containing the URL for this operationName or <B>null</B> if none was
|
261 |
* specified.
|
262 |
*/
|
263 |
public String getOnlineResource() { |
264 |
return onlineResource;
|
265 |
} |
266 |
|
267 |
/**
|
268 |
* Sets the string literal containing the URL of an online resource for a specific
|
269 |
* WMS request.
|
270 |
* @param operationName, String telling to which request correspond the address
|
271 |
* @param url, String containing the URL for the given WMS request
|
272 |
*/
|
273 |
public void setOnlineResource(String url) { |
274 |
onlineResource = url; |
275 |
} |
276 |
|
277 |
/**
|
278 |
* Returns the axis order as specified by the CRS, as this defines the
|
279 |
* order of the bounding box parameters on WMS 1.3.
|
280 |
*
|
281 |
* Valid values include: {@link #CRS_AXIS_EAST_NORTH},
|
282 |
* {@link #CRS_AXIS_NORTH_EAST}, {@link #CRS_AXIS_SOUTH_WEST},
|
283 |
* {@link #CRS_AXIS_WEST_SOUTH}, {@link #CRS_AXIS_OTHER_OR_UNKNOWN}.
|
284 |
*/
|
285 |
public int getCrsAxisOrder() { |
286 |
return crsAxisOrder;
|
287 |
} |
288 |
|
289 |
/**
|
290 |
* Sets the axis order as specified by the CRS, as this defines the
|
291 |
* order of the bounding box parameters on WMS 1.3.
|
292 |
*
|
293 |
* Valid values include: {@link #CRS_AXIS_EAST_NORTH},
|
294 |
* {@link #CRS_AXIS_NORTH_EAST}, {@link #CRS_AXIS_SOUTH_WEST},
|
295 |
* {@link #CRS_AXIS_WEST_SOUTH}, {@link #CRS_AXIS_OTHER_OR_UNKNOWN}.
|
296 |
*/
|
297 |
public void setCrsAxisOrder(int axisOrder) { |
298 |
this.crsAxisOrder = axisOrder;
|
299 |
} |
300 |
} |