Revision 21099
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.232/org.gvsig.raster.wms.io/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.raster.wms.io.DefaultWMSIOLibrary |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.232/org.gvsig.raster.wms.io/src/main/resources/org/gvsig/raster/wms/io/i18n/text.properties | ||
---|---|---|
1 |
error_connecting=Error conectando con el servidor |
|
2 |
malformed_url=URL mal formada |
|
0 | 3 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.232/org.gvsig.raster.wms.io/src/main/resources/org/gvsig/raster/wms/io/i18n/text_en.properties | ||
---|---|---|
1 |
error_connecting=Error connecting with the server |
|
2 |
malformed_url=Malformed URL |
|
0 | 3 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.232/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/WMSDataParametersImpl.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.raster.wms.io; |
|
24 |
|
|
25 |
import java.awt.Dimension; |
|
26 |
import java.awt.geom.Rectangle2D; |
|
27 |
import java.util.Hashtable; |
|
28 |
import java.util.List; |
|
29 |
import java.util.Map; |
|
30 |
import java.util.Vector; |
|
31 |
|
|
32 |
import org.gvsig.compat.net.ICancellable; |
|
33 |
import org.gvsig.fmap.crs.CRSFactory; |
|
34 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
35 |
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer; |
|
36 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
|
37 |
import org.gvsig.raster.impl.store.AbstractRasterDataParameters; |
|
38 |
import org.gvsig.tools.ToolsLocator; |
|
39 |
import org.gvsig.tools.dynobject.DelegatedDynObject; |
|
40 |
import org.gvsig.tools.dynobject.DynClass; |
|
41 |
import org.gvsig.tools.dynobject.DynStruct; |
|
42 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
43 |
|
|
44 |
/** |
|
45 |
* Parameters for the WMS provider |
|
46 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
47 |
*/ |
|
48 |
public class WMSDataParametersImpl extends AbstractRasterDataParameters implements WMSDataParameters { |
|
49 |
private static final String FIELD_FORMAT = "format"; |
|
50 |
private static final String FIELD_INFOFORMAT = "infoformat"; |
|
51 |
private static final String FIELD_LAYERQUERY = "layer_query"; |
|
52 |
private static final String FIELD_NAME = "name"; |
|
53 |
private static final String FIELD_SRSSTR = "srsstr"; |
|
54 |
private static final String FIELD_TRANSPARENCY = "transparency"; |
|
55 |
private static final String FIELD_INFOLAYERQUERY = "infolayerquery"; |
|
56 |
private static final String FIELD_QUERYABLE = "queryable"; |
|
57 |
private static final String FIELD_OVERRIDE = "override"; |
|
58 |
private static final String FIELD_STYLES = "styles"; |
|
59 |
private static final String FIELD_DIMENSIONS = "dimensions"; |
|
60 |
private static final String FIELD_ONLINERESOURC = "onlineresources"; |
|
61 |
private static final String FIELD_FIXEDSIZE = "fixedsize"; |
|
62 |
private static final String FIELD_EXTENT = "extent"; |
|
63 |
private static final String FIELD_WIDTH = "width"; |
|
64 |
private static final String FIELD_HEIGHT = "height"; |
|
65 |
private static final String FIELD_DELETECACHE = "deletecache"; |
|
66 |
private static final String FIELD_ASSUMEXYAXISORDER = "assumeXY"; |
|
67 |
|
|
68 |
private DelegatedDynObject delegatedDynObject = null; |
|
69 |
protected static DynClass DYNCLASS = null; |
|
70 |
private ICancellable cancel = null; |
|
71 |
|
|
72 |
public WMSDataParametersImpl() { |
|
73 |
super(); |
|
74 |
initialize(); |
|
75 |
} |
|
76 |
|
|
77 |
protected void initialize() { |
|
78 |
this.delegatedDynObject = (DelegatedDynObject) ToolsLocator |
|
79 |
.getDynObjectManager().createDynObject(registerDynClass()); |
|
80 |
} |
|
81 |
|
|
82 |
public static DynStruct registerDynClass() { |
|
83 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
84 |
DynStruct definition = manager.getDefinition("WMSDataParameters_Persistent"); |
|
85 |
if( definition == null ) { |
|
86 |
definition = manager.addDefinition( |
|
87 |
WMSDataParametersImpl.class, |
|
88 |
"WMSDataParameters_Persistent", |
|
89 |
"WMS DataParameters Persistency", |
|
90 |
null, |
|
91 |
null |
|
92 |
); |
|
93 |
} |
|
94 |
|
|
95 |
AbstractRasterDataParameters.registerDynClass(definition); |
|
96 |
|
|
97 |
definition.addDynFieldObject(FIELD_EXTENT) |
|
98 |
.setDescription("Bounding box") |
|
99 |
.setClassOfValue(Rectangle2D.class) |
|
100 |
.setMandatory(false); |
|
101 |
|
|
102 |
definition.addDynFieldInt(FIELD_WIDTH) |
|
103 |
.setDescription("Width") |
|
104 |
.setMandatory(false); |
|
105 |
|
|
106 |
definition.addDynFieldInt(FIELD_HEIGHT) |
|
107 |
.setDescription("Height") |
|
108 |
.setMandatory(false); |
|
109 |
|
|
110 |
definition.addDynFieldString(FIELD_FORMAT) |
|
111 |
.setDescription("Format") |
|
112 |
.setMandatory(false); |
|
113 |
|
|
114 |
definition.addDynFieldString(FIELD_INFOFORMAT) |
|
115 |
.setDescription("Info by point format") |
|
116 |
.setMandatory(false); |
|
117 |
|
|
118 |
definition.addDynFieldString(FIELD_LAYERQUERY) |
|
119 |
.setDescription("Layer Query") |
|
120 |
.setMandatory(false); |
|
121 |
|
|
122 |
definition.addDynFieldString(FIELD_NAME) |
|
123 |
.setDescription("Name") |
|
124 |
.setMandatory(false); |
|
125 |
|
|
126 |
definition.addDynFieldString(FIELD_SRSSTR) |
|
127 |
.setDescription("String that represents the SRS") |
|
128 |
.setMandatory(false); |
|
129 |
|
|
130 |
definition.addDynFieldBoolean(FIELD_TRANSPARENCY) |
|
131 |
.setDescription("Transparency") |
|
132 |
.setMandatory(false); |
|
133 |
|
|
134 |
definition.addDynFieldString(FIELD_INFOLAYERQUERY) |
|
135 |
.setDescription("InfoLayerQuery") |
|
136 |
.setMandatory(false); |
|
137 |
|
|
138 |
definition.addDynFieldBoolean(FIELD_QUERYABLE) |
|
139 |
.setDescription("Queryable") |
|
140 |
.setMandatory(false); |
|
141 |
|
|
142 |
definition.addDynFieldBoolean(FIELD_OVERRIDE) |
|
143 |
.setDescription("Override a host capabilities") |
|
144 |
.setMandatory(false); |
|
145 |
|
|
146 |
definition.addDynFieldList(FIELD_STYLES) |
|
147 |
.setDescription("Styles") |
|
148 |
.setClassOfItems(RemoteWMSStyle.class) |
|
149 |
.setMandatory(false); |
|
150 |
|
|
151 |
definition.addDynFieldList(FIELD_DIMENSIONS) |
|
152 |
.setDescription("Dimensions") |
|
153 |
.setClassOfItems(String.class) |
|
154 |
.setMandatory(false); |
|
155 |
|
|
156 |
definition.addDynFieldMap(FIELD_ONLINERESOURC) |
|
157 |
.setDescription("online resources") |
|
158 |
.setClassOfItems(String.class) |
|
159 |
.setMandatory(false); |
|
160 |
|
|
161 |
definition.addDynFieldObject(FIELD_FIXEDSIZE) |
|
162 |
.setDescription("Fixed size") |
|
163 |
.setClassOfValue(Dimension.class) |
|
164 |
.setMandatory(false); |
|
165 |
|
|
166 |
definition.addDynFieldBoolean(FIELD_DELETECACHE) |
|
167 |
.setDescription("Flag to delete cache the next request") |
|
168 |
.setMandatory(false); |
|
169 |
|
|
170 |
definition.addDynFieldBoolean(FIELD_ASSUMEXYAXISORDER) |
|
171 |
.setDescription("Flag to decide the axis order behaviour") |
|
172 |
.setMandatory(false); |
|
173 |
|
|
174 |
return definition; |
|
175 |
} |
|
176 |
|
|
177 |
/** |
|
178 |
* Gets the format |
|
179 |
* @return |
|
180 |
*/ |
|
181 |
public String getFormat() { |
|
182 |
return (String) this.getDynValue(FIELD_FORMAT); |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* Sets the format |
|
187 |
* @param format |
|
188 |
*/ |
|
189 |
public void setFormat(String format) { |
|
190 |
this.setDynValue(FIELD_FORMAT, format); |
|
191 |
} |
|
192 |
|
|
193 |
/** |
|
194 |
* Gets the info by point format |
|
195 |
* @return |
|
196 |
*/ |
|
197 |
public String getInfoFormat() { |
|
198 |
String o = (String) this.getDynValue(FIELD_INFOFORMAT); |
|
199 |
if(o == null) |
|
200 |
return "text/plain"; |
|
201 |
return o; |
|
202 |
} |
|
203 |
|
|
204 |
/** |
|
205 |
* Sets the info by point format |
|
206 |
*/ |
|
207 |
public void setInfoFormat(String format) { |
|
208 |
this.setDynValue(FIELD_INFOFORMAT, format); |
|
209 |
} |
|
210 |
|
|
211 |
public String getLayerQuery() { |
|
212 |
return (String) this.getDynValue(FIELD_LAYERQUERY); |
|
213 |
} |
|
214 |
|
|
215 |
public void setLayerQuery(String layerQuery) { |
|
216 |
this.setDynValue(FIELD_LAYERQUERY, layerQuery); |
|
217 |
} |
|
218 |
|
|
219 |
/** |
|
220 |
* Devuelve el SRS. |
|
221 |
* @return SRS. |
|
222 |
*/ |
|
223 |
public String getSRSCode() { |
|
224 |
return (String) this.getDynValue(FIELD_SRSSTR); |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* Inserta el SRS. |
|
229 |
* @param m_srs SRS. |
|
230 |
*/ |
|
231 |
public void setSRS(String m_srs) { |
|
232 |
this.setDynValue(FIELD_SRSSTR, m_srs); |
|
233 |
if(m_srs.equals("CRS:84")) |
|
234 |
m_srs = "EPSG:4326"; |
|
235 |
setSRS(CRSFactory.getCRS(m_srs)); |
|
236 |
} |
|
237 |
|
|
238 |
public void setSRSID(String srsid) { |
|
239 |
if (srsid == null) { |
|
240 |
setDynValue(FIELD_SRSSTR, null); |
|
241 |
} else { |
|
242 |
setDynValue(FIELD_SRSSTR, CRSFactory.getCRS(srsid)); |
|
243 |
} |
|
244 |
} |
|
245 |
|
|
246 |
public String getName() { |
|
247 |
return (String) this.getDynValue(FIELD_NAME); |
|
248 |
} |
|
249 |
|
|
250 |
public void setName(String name) { |
|
251 |
this.setDynValue(FIELD_NAME, name); |
|
252 |
} |
|
253 |
|
|
254 |
public boolean isWmsTransparent() { |
|
255 |
Boolean b = (Boolean)getDynValue(FIELD_TRANSPARENCY); |
|
256 |
if(b != null) |
|
257 |
return ((Boolean)b).booleanValue(); |
|
258 |
return false; |
|
259 |
} |
|
260 |
|
|
261 |
/** |
|
262 |
* @param wmsTransparency The wmsTransparency to set. |
|
263 |
*/ |
|
264 |
public void setWmsTransparency(boolean wmsTransparency) { |
|
265 |
this.setDynValue(FIELD_TRANSPARENCY, new Boolean(wmsTransparency)); |
|
266 |
} |
|
267 |
|
|
268 |
public String getInfoLayerQuery() { |
|
269 |
return (String) this.getDynValue(FIELD_INFOLAYERQUERY); |
|
270 |
} |
|
271 |
|
|
272 |
public void setInfoLayerQuery(String infoLayerQuery) { |
|
273 |
this.setDynValue(FIELD_INFOLAYERQUERY, infoLayerQuery); |
|
274 |
} |
|
275 |
|
|
276 |
|
|
277 |
/** |
|
278 |
* If it is true, this layer accepts GetFeatureInfo operations. This WMS operations |
|
279 |
* maps to FMap's infoByPoint(p) operation. |
|
280 |
* @param b |
|
281 |
*/ |
|
282 |
public void setQueryable(boolean b) { |
|
283 |
this.setDynValue(FIELD_QUERYABLE, new Boolean(b)); |
|
284 |
} |
|
285 |
|
|
286 |
public void setCancellable(ICancellable cancel) { |
|
287 |
this.cancel = cancel; |
|
288 |
} |
|
289 |
|
|
290 |
public ICancellable getCancellable() { |
|
291 |
return cancel; |
|
292 |
} |
|
293 |
|
|
294 |
public boolean isQueryable() { |
|
295 |
Boolean b = (Boolean)getDynValue(FIELD_QUERYABLE); |
|
296 |
if(b != null) |
|
297 |
return ((Boolean)b).booleanValue(); |
|
298 |
return false; |
|
299 |
} |
|
300 |
|
|
301 |
public boolean isOverridingHost() { |
|
302 |
Boolean b = (Boolean)getDynValue(FIELD_OVERRIDE); |
|
303 |
if(b != null) |
|
304 |
return ((Boolean)b).booleanValue(); |
|
305 |
return false; |
|
306 |
} |
|
307 |
|
|
308 |
public void setOverrideHost(boolean over) { |
|
309 |
this.setDynValue(FIELD_OVERRIDE, new Boolean(over));; |
|
310 |
} |
|
311 |
|
|
312 |
public void setStyles(List<RemoteWMSStyle> styles) { |
|
313 |
this.setDynValue(FIELD_STYLES, styles); |
|
314 |
} |
|
315 |
|
|
316 |
/** |
|
317 |
* @param styles |
|
318 |
*/ |
|
319 |
@SuppressWarnings("unchecked") |
|
320 |
public List<RemoteWMSStyle> getStyles() { |
|
321 |
return (List<RemoteWMSStyle>) this.getDynValue(FIELD_STYLES); |
|
322 |
} |
|
323 |
|
|
324 |
public void setDimensions(Vector<String> dimensions) { |
|
325 |
this.setDynValue(FIELD_DIMENSIONS, dimensions); |
|
326 |
} |
|
327 |
|
|
328 |
/** |
|
329 |
* Gets the dimension vector that is a list of key-value pairs containing |
|
330 |
* the name of the dimension and the value for it |
|
331 |
* @return |
|
332 |
*/ |
|
333 |
@SuppressWarnings("unchecked") |
|
334 |
public Vector<String> getDimensions() { |
|
335 |
return (Vector<String>) this.getDynValue(FIELD_DIMENSIONS); |
|
336 |
} |
|
337 |
|
|
338 |
public void setOnlineResources(Map<String, String> onlineResources) { |
|
339 |
this.setDynValue(FIELD_ONLINERESOURC, onlineResources); |
|
340 |
} |
|
341 |
|
|
342 |
public String getOnlineResource(String operation) { |
|
343 |
return (String) getOnlineResource().get(operation); |
|
344 |
} |
|
345 |
|
|
346 |
@SuppressWarnings("unchecked") |
|
347 |
public Map<String,String> getOnlineResource() { |
|
348 |
return (Map<String,String>) this.getDynValue(FIELD_ONLINERESOURC); |
|
349 |
} |
|
350 |
|
|
351 |
/** |
|
352 |
* When a server is not fully featured and it only can serve constant map |
|
353 |
* sizes this value must be set. It expresses the size in pixels (width, height) |
|
354 |
* that the map will be requested. |
|
355 |
* @param Dimension sz |
|
356 |
*/ |
|
357 |
public void setFixedSize(Dimension sz) { |
|
358 |
this.setDynValue(FIELD_FIXEDSIZE, sz); |
|
359 |
} |
|
360 |
|
|
361 |
/** |
|
362 |
* Tells whether if this layer must deal with the server with the constant-size |
|
363 |
* limitations or not. |
|
364 |
* @return boolean. |
|
365 |
*/ |
|
366 |
public boolean isSizeFixed() { |
|
367 |
return (getDynValue(FIELD_FIXEDSIZE) != null); |
|
368 |
} |
|
369 |
|
|
370 |
/** |
|
371 |
* Gets the value of the fixed size |
|
372 |
* @return |
|
373 |
*/ |
|
374 |
public Dimension getFixedSize() { |
|
375 |
return (Dimension) this.getDynValue(FIELD_FIXEDSIZE); |
|
376 |
} |
|
377 |
|
|
378 |
/** |
|
379 |
* Assigns the extent. |
|
380 |
* When a provider is initialized this will need to know what is the extent before the request. |
|
381 |
* |
|
382 |
* @param bBox |
|
383 |
*/ |
|
384 |
public void setExtent(Rectangle2D bBox) { |
|
385 |
this.setDynValue(FIELD_EXTENT, bBox); |
|
386 |
} |
|
387 |
|
|
388 |
public void setWidth(int w) { |
|
389 |
this.setDynValue(FIELD_WIDTH, new Integer(w)); |
|
390 |
} |
|
391 |
|
|
392 |
public void setHeight(int h) { |
|
393 |
this.setDynValue(FIELD_HEIGHT, new Integer(h)); |
|
394 |
} |
|
395 |
|
|
396 |
/** |
|
397 |
* Gets the bounding box |
|
398 |
* @return |
|
399 |
*/ |
|
400 |
public Rectangle2D getExtent() { |
|
401 |
return (Rectangle2D)getDynValue(FIELD_EXTENT); |
|
402 |
} |
|
403 |
|
|
404 |
/** |
|
405 |
* Gets the width |
|
406 |
* @return |
|
407 |
*/ |
|
408 |
public int getWidth() { |
|
409 |
Integer b = (Integer)getDynValue(FIELD_WIDTH); |
|
410 |
if(b != null) |
|
411 |
return ((Integer)b).intValue(); |
|
412 |
return 0; |
|
413 |
} |
|
414 |
|
|
415 |
/** |
|
416 |
* Gets the height |
|
417 |
* @return |
|
418 |
*/ |
|
419 |
public int getHeight() { |
|
420 |
Integer b = (Integer)getDynValue(FIELD_HEIGHT); |
|
421 |
if(b != null) |
|
422 |
return ((Integer)b).intValue(); |
|
423 |
return 0; |
|
424 |
} |
|
425 |
|
|
426 |
|
|
427 |
//********************************************** |
|
428 |
|
|
429 |
public String getDataStoreName() { |
|
430 |
return WMSProvider.NAME; |
|
431 |
} |
|
432 |
|
|
433 |
public String getDescription() { |
|
434 |
return WMSProvider.DESCRIPTION; |
|
435 |
} |
|
436 |
|
|
437 |
public String getExplorerName() { |
|
438 |
return WMSServerExplorer.NAME; |
|
439 |
} |
|
440 |
|
|
441 |
public boolean isValid() { |
|
442 |
return (this.getURI() != null); |
|
443 |
} |
|
444 |
|
|
445 |
protected DelegatedDynObject getDelegatedDynObject() { |
|
446 |
return delegatedDynObject; |
|
447 |
} |
|
448 |
|
|
449 |
public void deleteCache(boolean deleteCache) { |
|
450 |
this.setDynValue(FIELD_DELETECACHE, new Boolean(deleteCache)); |
|
451 |
} |
|
452 |
|
|
453 |
public boolean isDeletingCache() { |
|
454 |
return ((Boolean)getDynValue(FIELD_DELETECACHE)).booleanValue(); |
|
455 |
} |
|
456 |
|
|
457 |
@SuppressWarnings("unchecked") |
|
458 |
public WMSDataParameters clone() { |
|
459 |
WMSDataParametersImpl p = new WMSDataParametersImpl(); |
|
460 |
p.setFormat(getFormat()); |
|
461 |
p.setFixedSize(getFixedSize()); |
|
462 |
p.setHeight(getHeight()); |
|
463 |
p.setWidth(getWidth()); |
|
464 |
p.setExtent(getExtent()); |
|
465 |
p.setURI(getURI()); |
|
466 |
p.setInfoLayerQuery(getInfoLayerQuery()); |
|
467 |
p.setLayerQuery(getLayerQuery()); |
|
468 |
p.setName(getName()); |
|
469 |
p.setOnlineResources((Hashtable<String, String>)this.getDynValue(FIELD_ONLINERESOURC)); |
|
470 |
p.setOverrideHost(isOverridingHost()); |
|
471 |
p.setQueryable(isQueryable()); |
|
472 |
p.setSRS(getSRS()); |
|
473 |
p.setSRS(getSRSCode()); |
|
474 |
p.setStyles(getStyles()); |
|
475 |
p.setWmsTransparency(isWmsTransparent()); |
|
476 |
p.setDimensions(getDimensions()); |
|
477 |
p.setCancellable(getCancellable()); |
|
478 |
p.setXyAxisOrder(isXyAxisOrder()); |
|
479 |
return p; |
|
480 |
} |
|
481 |
|
|
482 |
public void assignFields(RasterDataParameters par, RasterDataServerExplorer explorer) { |
|
483 |
super.assignFields(par, explorer); |
|
484 |
WMSDataParametersImpl p = null; |
|
485 |
if(par instanceof WMSDataParametersImpl) |
|
486 |
p = (WMSDataParametersImpl)par; |
|
487 |
else |
|
488 |
return; |
|
489 |
setFormat(p.getFormat()); |
|
490 |
setFixedSize(p.getFixedSize()); |
|
491 |
setHeight(p.getHeight()); |
|
492 |
setWidth(p.getWidth()); |
|
493 |
setExtent(p.getExtent()); |
|
494 |
setURI(p.getURI()); |
|
495 |
setInfoLayerQuery(p.getInfoLayerQuery()); |
|
496 |
setLayerQuery(p.getLayerQuery()); |
|
497 |
setName(getName()); |
|
498 |
setOnlineResources((Map<String, String>)p.getDynValue(FIELD_ONLINERESOURC)); |
|
499 |
setOverrideHost(p.isOverridingHost()); |
|
500 |
setQueryable(p.isQueryable()); |
|
501 |
setSRS(p.getSRSCode()); |
|
502 |
setStyles(p.getStyles()); |
|
503 |
setWmsTransparency(p.isWmsTransparent()); |
|
504 |
setDimensions(p.getDimensions()); |
|
505 |
setCancellable(p.getCancellable()); |
|
506 |
setXyAxisOrder(p.isXyAxisOrder()); |
|
507 |
} |
|
508 |
|
|
509 |
public boolean isXyAxisOrder() { |
|
510 |
Boolean b = (Boolean)getDynValue(FIELD_ASSUMEXYAXISORDER); |
|
511 |
if(b != null) |
|
512 |
return b.booleanValue(); |
|
513 |
return false; |
|
514 |
} |
|
515 |
|
|
516 |
public void setXyAxisOrder(boolean assumeXY) { |
|
517 |
setDynValue(FIELD_ASSUMEXYAXISORDER, assumeXY); |
|
518 |
} |
|
519 |
|
|
520 |
} |
|
0 | 521 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.232/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/DefaultWMSIOLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.wms.io; |
|
23 |
|
|
24 |
import org.gvsig.i18n.Messages; |
|
25 |
import org.gvsig.raster.wms.io.time.DefaultDimension; |
|
26 |
import org.gvsig.raster.wms.io.time.TimeDimension; |
|
27 |
import org.gvsig.tools.library.AbstractLibrary; |
|
28 |
import org.gvsig.tools.library.LibraryException; |
|
29 |
/** |
|
30 |
* |
|
31 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
32 |
*/ |
|
33 |
public class DefaultWMSIOLibrary extends AbstractLibrary { |
|
34 |
|
|
35 |
/*public DefaultWMSIOLibrary() { |
|
36 |
super(DefaultWMSIOLibrary.class,Library.TYPE.IMPL); |
|
37 |
require(ToolsLibrary.class); |
|
38 |
require(DALLibrary.class); |
|
39 |
require(DALFileLibrary.class); |
|
40 |
}*/ |
|
41 |
|
|
42 |
@Override |
|
43 |
protected void doInitialize() throws LibraryException { |
|
44 |
//RasterLibrary.wakeUp(); |
|
45 |
WMSLayerNode.registerPersistent(); |
|
46 |
RemoteWMSStyle.registerPersistent(); |
|
47 |
DefaultDimension.registerPersistent(); |
|
48 |
TimeDimension.registerPersistent(); |
|
49 |
|
|
50 |
Messages.addResourceFamily("org.gvsig.raster.wms.io.i18n.text", |
|
51 |
DefaultWMSIOLibrary.class.getClassLoader(), |
|
52 |
DefaultWMSIOLibrary.class.getClass().getName()); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
protected void doPostInitialize() throws LibraryException { |
|
57 |
WMSServerExplorerParameters.registerDynClass(); |
|
58 |
WMSDataParametersImpl.registerDynClass(); |
|
59 |
WMSProvider.register(); |
|
60 |
} |
|
61 |
} |
|
0 | 62 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.232/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/WMSLayerNode.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.wms.io; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.util.ArrayList; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import org.gvsig.raster.wms.io.time.DefaultDimension; |
|
29 |
import org.gvsig.raster.wms.io.time.RemoteTimeDimension; |
|
30 |
import org.gvsig.raster.wms.io.time.TimeDimension; |
|
31 |
import org.gvsig.tools.ToolsLocator; |
|
32 |
import org.gvsig.tools.dynobject.DynStruct; |
|
33 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
34 |
import org.gvsig.tools.persistence.Persistent; |
|
35 |
import org.gvsig.tools.persistence.PersistentState; |
|
36 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
37 |
|
|
38 |
/** |
|
39 |
* Class defining the node of the layer tree of a common WMS service. |
|
40 |
* @author jaume |
|
41 |
*/ |
|
42 |
@SuppressWarnings("unchecked") |
|
43 |
public class WMSLayerNode implements Persistent { |
|
44 |
private String _name = null; |
|
45 |
private String _title = null; |
|
46 |
private List<String> srs = null; |
|
47 |
private boolean queryable; |
|
48 |
private boolean transparency; |
|
49 |
private String lAbstract = null; |
|
50 |
private String latLonBox = null; |
|
51 |
private int selectedStyleIndex = 0; |
|
52 |
private List<RemoteWMSStyle> styles = new ArrayList<RemoteWMSStyle>(); |
|
53 |
private List<RemoteTimeDimension> dimensions = null; |
|
54 |
private List<String> keywords = null; |
|
55 |
private List<WMSLayerNode> children = new ArrayList<WMSLayerNode>(); |
|
56 |
private WMSLayerNode _parent = null; |
|
57 |
private Dimension fixedSize = null; |
|
58 |
|
|
59 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
60 |
this._name = state.getString("_name"); |
|
61 |
this._title = state.getString("_title"); |
|
62 |
this.srs = state.getList("srs"); |
|
63 |
this.queryable = state.getBoolean("queryable"); |
|
64 |
this.transparency = state.getBoolean("transparency"); |
|
65 |
this.lAbstract = state.getString("lAbstract"); |
|
66 |
this.latLonBox = state.getString("latLonBox"); |
|
67 |
this.selectedStyleIndex = state.getInt("selectedStyleIndex"); |
|
68 |
this.styles = state.getList("styles"); |
|
69 |
this.dimensions = state.getList("dimensions"); |
|
70 |
this.keywords = state.getList("keywords"); |
|
71 |
this.children = state.getList("children"); |
|
72 |
this._parent = (WMSLayerNode)state.get("_parent"); |
|
73 |
this.fixedSize = (Dimension)state.get("fixedSize"); |
|
74 |
} |
|
75 |
|
|
76 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
77 |
state.set("_name", _name); |
|
78 |
state.set("_title", _title); |
|
79 |
state.set("srs", srs); |
|
80 |
state.set("queryable", queryable); |
|
81 |
state.set("transparency", transparency); |
|
82 |
state.set("lAbstract", lAbstract); |
|
83 |
state.set("latLonBox", latLonBox); |
|
84 |
state.set("selectedStyleIndex", selectedStyleIndex); |
|
85 |
state.set("styles", styles); |
|
86 |
state.set("dimensions", dimensions); |
|
87 |
state.set("keywords", keywords); |
|
88 |
state.set("children", children); |
|
89 |
state.set("_parent", _parent); |
|
90 |
state.set("fixedSize", fixedSize); |
|
91 |
} |
|
92 |
|
|
93 |
public static void registerPersistent() { |
|
94 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
95 |
DynStruct definition = manager.getDefinition("WMSLayerNode_Persistent"); |
|
96 |
if( definition == null ) { |
|
97 |
definition = manager.addDefinition( |
|
98 |
WMSLayerNode.class, |
|
99 |
"WMSLayerNode_Persistent", |
|
100 |
"WMSLayerNode Persistence", |
|
101 |
null, |
|
102 |
null |
|
103 |
); |
|
104 |
} |
|
105 |
|
|
106 |
definition.addDynFieldString("_name").setMandatory(false); |
|
107 |
definition.addDynFieldString("_title").setMandatory(false); |
|
108 |
definition.addDynFieldList("srs").setClassOfItems(String.class).setMandatory(false); |
|
109 |
definition.addDynFieldBoolean("queryable").setMandatory(false); |
|
110 |
definition.addDynFieldBoolean("transparency").setMandatory(false); |
|
111 |
definition.addDynFieldString("lAbstract").setMandatory(false); |
|
112 |
definition.addDynFieldString("latLonBox").setMandatory(false); |
|
113 |
definition.addDynFieldInt("selectedStyleIndex").setMandatory(false); |
|
114 |
definition.addDynFieldList("styles").setClassOfItems(RemoteWMSStyle.class).setMandatory(false); |
|
115 |
definition.addDynFieldList("dimensions").setClassOfItems(RemoteTimeDimension.class).setMandatory(false); |
|
116 |
definition.addDynFieldList("keywords").setClassOfItems(String.class).setMandatory(false); |
|
117 |
definition.addDynFieldList("children").setClassOfItems(WMSLayerNode.class).setMandatory(false); |
|
118 |
definition.addDynFieldObject("_parent").setClassOfValue(WMSLayerNode.class).setMandatory(false); |
|
119 |
definition.addDynFieldObject("fixedSize").setClassOfValue(Dimension.class).setMandatory(false); |
|
120 |
} |
|
121 |
|
|
122 |
/** |
|
123 |
* @return Returns the name. |
|
124 |
*/ |
|
125 |
public String getName() { |
|
126 |
return _name; |
|
127 |
} |
|
128 |
|
|
129 |
public List<WMSLayerNode> getChildren() { |
|
130 |
return children; |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* @param name The name to set. |
|
135 |
*/ |
|
136 |
public void setName(String name) { |
|
137 |
this._name = name; |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* @return Returns the namedStyles. |
|
142 |
*/ |
|
143 |
public List<RemoteWMSStyle> getStyles() { |
|
144 |
return styles; |
|
145 |
} |
|
146 |
|
|
147 |
public List<String> getKeywords() { |
|
148 |
return keywords; |
|
149 |
} |
|
150 |
|
|
151 |
/** |
|
152 |
* @return Returns the queryable. |
|
153 |
*/ |
|
154 |
public boolean isQueryable() { |
|
155 |
return queryable; |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* @param queryable The queryable to set. |
|
160 |
*/ |
|
161 |
public void setQueryable(boolean queryable) { |
|
162 |
this.queryable = queryable; |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* @return Returns the srs. |
|
167 |
*/ |
|
168 |
public List<String> getAllSrs() { |
|
169 |
if ((srs.size() == 0) && _parent!=null) |
|
170 |
return _parent.getAllSrs(); |
|
171 |
return srs; |
|
172 |
} |
|
173 |
|
|
174 |
/** |
|
175 |
* @param srs The srs to set. |
|
176 |
*/ |
|
177 |
public void setSrs(List<String> srs) { |
|
178 |
this.srs = srs; |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* @return Returns the title. |
|
183 |
*/ |
|
184 |
public String getTitle() { |
|
185 |
return _title; |
|
186 |
} |
|
187 |
|
|
188 |
public void setTitle(String title) { |
|
189 |
this._title = title.trim(); |
|
190 |
} |
|
191 |
|
|
192 |
/** |
|
193 |
* @return Returns the transparency. |
|
194 |
*/ |
|
195 |
public boolean isTransparent() { |
|
196 |
return transparency; |
|
197 |
} |
|
198 |
|
|
199 |
/** |
|
200 |
* @param transparency The transparency to set. |
|
201 |
*/ |
|
202 |
public void setTransparency(boolean transparency) { |
|
203 |
this.transparency = transparency; |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* Sets the list of sons of this layer. |
|
208 |
* @param children |
|
209 |
*/ |
|
210 |
public void setChildren(List<WMSLayerNode> children) { |
|
211 |
this.children = children; |
|
212 |
} |
|
213 |
|
|
214 |
public WMSLayerNode getParent() { |
|
215 |
return _parent; |
|
216 |
} |
|
217 |
|
|
218 |
public void setParent(WMSLayerNode parentNode) { |
|
219 |
this._parent = parentNode; |
|
220 |
} |
|
221 |
|
|
222 |
public List<RemoteTimeDimension> getDimensions() { |
|
223 |
return dimensions; |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* Gets the layer abstract. |
|
228 |
* |
|
229 |
* @return Returns the abstract. |
|
230 |
*/ |
|
231 |
public String getAbstract() { |
|
232 |
return lAbstract; |
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* Sets the layer abstract. |
|
237 |
* |
|
238 |
* @param abstract The abstract to set. |
|
239 |
*/ |
|
240 |
public void setAbstract(String _abstract) { |
|
241 |
lAbstract = _abstract; |
|
242 |
} |
|
243 |
|
|
244 |
/** |
|
245 |
* @param name |
|
246 |
* @param units |
|
247 |
* @param unitSymbol |
|
248 |
* @param dimensionExpression |
|
249 |
*/ |
|
250 |
public void addDimension(String name, String units, String unitSymbol, String dimExpression) { |
|
251 |
if (dimensions == null) |
|
252 |
dimensions = new ArrayList<RemoteTimeDimension>(); |
|
253 |
if (name.equalsIgnoreCase("time")) { |
|
254 |
try { |
|
255 |
dimensions.add(new TimeDimension(units, unitSymbol, |
|
256 |
dimExpression)); |
|
257 |
} catch (IllegalArgumentException e) { |
|
258 |
// The TIME class does not yet support this kind of time so it |
|
259 |
// will be treated as a DefaultDimension |
|
260 |
dimensions.add(new DefaultDimension(name.toUpperCase(), |
|
261 |
units, unitSymbol, dimExpression)); |
|
262 |
} |
|
263 |
} else if (name.equalsIgnoreCase("sequence")) { |
|
264 |
// TODO Not yet implemented |
|
265 |
return; |
|
266 |
} else { |
|
267 |
dimensions.add(new DefaultDimension(name.toUpperCase(), units, |
|
268 |
unitSymbol, dimExpression)); |
|
269 |
} |
|
270 |
|
|
271 |
} |
|
272 |
|
|
273 |
|
|
274 |
public void setLatLonBox(String _latLonBox) { |
|
275 |
latLonBox = _latLonBox; |
|
276 |
} |
|
277 |
|
|
278 |
public String getLatLonBox() { |
|
279 |
return latLonBox; |
|
280 |
} |
|
281 |
|
|
282 |
/** |
|
283 |
* When a server cannot renderize images but just server them in constant size and |
|
284 |
* BBox, the layer must have this value set in order to correctly work. |
|
285 |
* |
|
286 |
* @param fixedWidth - the constant value for the image width |
|
287 |
* @param fixedHeight - the constant value for the image height |
|
288 |
*/ |
|
289 |
public void setFixedSize(int fixedWidth, int fixedHeight) { |
|
290 |
fixedSize = new Dimension(fixedWidth, fixedHeight); |
|
291 |
} |
|
292 |
|
|
293 |
public Dimension getFixedSize() { |
|
294 |
return fixedSize; |
|
295 |
} |
|
296 |
|
|
297 |
public boolean isSizeFixed() { |
|
298 |
return fixedSize != null && |
|
299 |
fixedSize.getWidth() > 0 && |
|
300 |
fixedSize.getHeight() > 0; |
|
301 |
} |
|
302 |
|
|
303 |
/** |
|
304 |
* |
|
305 |
* @param _name |
|
306 |
* @param _title |
|
307 |
* @param _abstract |
|
308 |
*/ |
|
309 |
public void addStyle(org.gvsig.remoteclient.wms.WMSStyle style) { |
|
310 |
if (style.getName().equalsIgnoreCase("default")) |
|
311 |
selectedStyleIndex = styles.size(); |
|
312 |
if (styles == null) |
|
313 |
styles = new ArrayList<RemoteWMSStyle>(); |
|
314 |
styles.add(new RemoteWMSStyle(style, this)); |
|
315 |
|
|
316 |
} |
|
317 |
|
|
318 |
public RemoteWMSStyle getSelectedStyle() { |
|
319 |
if (styles == null || selectedStyleIndex > styles.size() - 1 || selectedStyleIndex == -1) |
|
320 |
return null; |
|
321 |
return (RemoteWMSStyle) styles.get(selectedStyleIndex); |
|
322 |
} |
|
323 |
|
|
324 |
public void setSelectedStyleByIndex(int index) { |
|
325 |
selectedStyleIndex = index; |
|
326 |
} |
|
327 |
|
|
328 |
public void setSelectedStyleByName(String styName) { |
|
329 |
if (styName == null || styName.equals("")) |
|
330 |
setSelectedStyleByIndex(-1); |
|
331 |
for (int i = 0; i < styles.size(); i++) { |
|
332 |
RemoteWMSStyle sty = (RemoteWMSStyle) styles.get(i); |
|
333 |
if (sty.name.equalsIgnoreCase(styName)) { |
|
334 |
setSelectedStyleByIndex(i); |
|
335 |
return; |
|
336 |
} |
|
337 |
|
|
338 |
} |
|
339 |
setSelectedStyleByIndex(-1); |
|
340 |
} |
|
341 |
|
|
342 |
public void addKeyword(String keyword) { |
|
343 |
if (keywords == null) |
|
344 |
keywords = new ArrayList<String>(); |
|
345 |
keywords.add(keyword); |
|
346 |
} |
|
347 |
|
|
348 |
public String toString(){ |
|
349 |
String str; |
|
350 |
if (getName()==null) |
|
351 |
str = getTitle(); |
|
352 |
else |
|
353 |
str = "["+getName()+"] "+getTitle(); |
|
354 |
return str; |
|
355 |
} |
|
356 |
|
|
357 |
public Object clone() throws CloneNotSupportedException { |
|
358 |
WMSLayerNode clone = new WMSLayerNode(); |
|
359 |
clone._name = this._name; |
|
360 |
clone.queryable = this.queryable; |
|
361 |
clone.srs = this.srs; |
|
362 |
clone._title = this._title; |
|
363 |
clone.transparency = this.transparency; |
|
364 |
clone.styles = new ArrayList<RemoteWMSStyle>(); |
|
365 |
clone.lAbstract = this.lAbstract; |
|
366 |
clone.latLonBox = this.latLonBox; |
|
367 |
clone.selectedStyleIndex = this.selectedStyleIndex; |
|
368 |
|
|
369 |
if (keywords != null) { |
|
370 |
clone.keywords = new ArrayList<String>(keywords.size()); |
|
371 |
for (int i = 0; i < keywords.size(); i++) { |
|
372 |
clone.keywords.add((String) keywords.get(i)); |
|
373 |
} |
|
374 |
} |
|
375 |
if (styles != null) |
|
376 |
for (int i=0; i<styles.size(); i++){ |
|
377 |
RemoteWMSStyle sty = (RemoteWMSStyle) this.styles.get(i).clone(); |
|
378 |
((RemoteWMSStyle)sty).parent = this; |
|
379 |
clone.styles.add(sty); |
|
380 |
} |
|
381 |
|
|
382 |
if (dimensions!=null) |
|
383 |
for (int i = 0; i < dimensions.size(); i++) { |
|
384 |
clone.dimensions = new ArrayList<RemoteTimeDimension>(); |
|
385 |
clone.dimensions.add((RemoteTimeDimension) this.dimensions.get(i)); |
|
386 |
} |
|
387 |
|
|
388 |
return clone; |
|
389 |
} |
|
390 |
|
|
391 |
} |
|
0 | 392 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.232/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/WMSServerExplorer.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 IVER T.I {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.raster.wms.io; |
|
29 |
|
|
30 |
import java.awt.geom.Rectangle2D; |
|
31 |
import java.io.File; |
|
32 |
import java.io.IOException; |
|
33 |
import java.io.InputStream; |
|
34 |
import java.net.MalformedURLException; |
|
35 |
import java.net.URI; |
|
36 |
import java.net.URISyntaxException; |
|
37 |
import java.net.URL; |
|
38 |
import java.net.URLConnection; |
|
39 |
import java.util.ArrayList; |
|
40 |
import java.util.Hashtable; |
|
41 |
import java.util.List; |
|
42 |
import java.util.Vector; |
|
43 |
|
|
44 |
import org.gvsig.compat.net.ICancellable; |
|
45 |
import org.gvsig.fmap.dal.DALLocator; |
|
46 |
import org.gvsig.fmap.dal.DataManager; |
|
47 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
48 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
49 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
50 |
import org.gvsig.fmap.dal.coverage.exception.ConnectException; |
|
51 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
52 |
import org.gvsig.fmap.dal.coverage.store.RasterDataServerExplorer; |
|
53 |
import org.gvsig.fmap.dal.exception.DataException; |
|
54 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
55 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
56 |
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer; |
|
57 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
|
58 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
59 |
import org.gvsig.i18n.Messages; |
|
60 |
import org.gvsig.remoteclient.utils.Utilities; |
|
61 |
import org.gvsig.tools.task.Cancellable; |
|
62 |
|
|
63 |
import org.slf4j.Logger; |
|
64 |
import org.slf4j.LoggerFactory; |
|
65 |
|
|
66 |
/** |
|
67 |
* Explorer for a WMS server |
|
68 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
69 |
*/ |
|
70 |
public class WMSServerExplorer extends AbstractDataServerExplorer implements RasterDataServerExplorer, DataServerExplorerProvider { |
|
71 |
public static final String NAME = WMSProvider.NAME; |
|
72 |
private WMSConnector connector = null; |
|
73 |
// private WMSServerExplorerParameters parameters = null; |
|
74 |
private Logger log = LoggerFactory.getLogger(WMSServerExplorer.class); |
|
75 |
|
|
76 |
public WMSServerExplorer( |
|
77 |
WMSServerExplorerParameters parameters, |
|
78 |
DataServerExplorerProviderServices services) |
|
79 |
throws InitializeException { |
|
80 |
super(parameters, services); |
|
81 |
// this.parameters = parameters; |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Gets the provider's name |
|
86 |
* @return |
|
87 |
*/ |
|
88 |
public String getDataStoreProviderName() { |
|
89 |
return WMSProvider.NAME; |
|
90 |
} |
|
91 |
|
|
92 |
public String getDescription() { |
|
93 |
return WMSProvider.DESCRIPTION; |
|
94 |
} |
|
95 |
|
|
96 |
public boolean add(String provider, NewDataStoreParameters parameters, |
|
97 |
boolean overwrite) throws DataException { |
|
98 |
return false; |
|
99 |
} |
|
100 |
|
|
101 |
public boolean canAdd() { |
|
102 |
return false; |
|
103 |
} |
|
104 |
|
|
105 |
public boolean canAdd(String storeName) throws DataException { |
|
106 |
return false; |
|
107 |
} |
|
108 |
|
|
109 |
public NewDataStoreParameters getAddParameters(String storeName) |
|
110 |
throws DataException { |
|
111 |
return null; |
|
112 |
} |
|
113 |
|
|
114 |
public List<String> getDataStoreProviderNames() { |
|
115 |
return null; |
|
116 |
} |
|
117 |
|
|
118 |
public WMSServerExplorerParameters getParameters() { |
|
119 |
return (WMSServerExplorerParameters) super.getParameters(); |
|
120 |
} |
|
121 |
|
|
122 |
public List<DataStoreParameters> list() throws DataException { |
|
123 |
return null; |
|
124 |
} |
|
125 |
|
|
126 |
public List<DataStoreParameters> list(int mode) throws DataException { |
|
127 |
return null; |
|
128 |
} |
|
129 |
|
|
130 |
public void remove(DataStoreParameters parameters) throws DataException { |
|
131 |
|
|
132 |
} |
|
133 |
|
|
134 |
public String getProviderName() { |
|
135 |
return null; |
|
136 |
} |
|
137 |
|
|
138 |
//********************************************** |
|
139 |
//Connector |
|
140 |
//********************************************** |
|
141 |
|
|
142 |
public DataStoreParameters getStoredParameters() { |
|
143 |
DataManager manager = DALLocator.getDataManager(); |
|
144 |
WMSDataParameters params = null; |
|
145 |
try { |
|
146 |
params = (WMSDataParameters) manager.createStoreParameters(this.getDataStoreProviderName()); |
|
147 |
params.setURI(new URI(getParameters().getHost())); |
|
148 |
|
|
149 |
/*if(WMSProvider.TILED) { |
|
150 |
TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store"); |
|
151 |
tileParams.setDataParameters(params); |
|
152 |
return tileParams; |
|
153 |
} */ |
|
154 |
} catch (InitializeException e) { |
|
155 |
log.debug("Error initializating parameters", e); |
|
156 |
} catch (ProviderNotRegisteredException e) { |
|
157 |
log.debug("Error getting parameters", e); |
|
158 |
} catch (URISyntaxException e) { |
|
159 |
log.debug("Can't create URI from "+getParameters().getHost(), e); |
|
160 |
} |
|
161 |
|
|
162 |
return params; |
|
163 |
} |
|
164 |
|
|
165 |
public void connect(ICancellable cancellable) throws ConnectException { |
|
166 |
connect(cancellable, false); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* Connects to the server and throws a getCapabilities. This loads |
|
171 |
* the basic information to make requests. |
|
172 |
* @throws RemoteServiceException |
|
173 |
*/ |
|
174 |
public void connect(ICancellable cancellable, boolean updateCache) throws ConnectException { |
|
175 |
URL url = null; |
|
176 |
|
|
177 |
try { |
|
178 |
url = new URL(getParameters().getHost()); |
|
179 |
} catch (Exception e) { |
|
180 |
throw new ConnectException(Messages.getText("malformed_url"), e); |
|
181 |
} |
|
182 |
try { |
|
183 |
connector = WMSProvider.getConnectorFromURL(url, updateCache); |
|
184 |
if (!connector.connect(this.getParameters(), updateCache, cancellable)) |
|
185 |
throw new ConnectException(Messages.getText("error_connecting")); |
|
186 |
} catch (IOException e) { |
|
187 |
throw new ConnectException(Messages.getText("error_connecting"), e); |
|
188 |
} |
|
189 |
|
|
190 |
} |
|
191 |
|
|
192 |
/** |
|
193 |
* Checks if the network and host are reachable |
|
194 |
* @param timeout for the host |
|
195 |
* @return true if both are reachable and false if they are not |
|
196 |
*/ |
|
197 |
public boolean isHostReachable(int timeout) { |
|
198 |
URL url = null; |
|
199 |
try { |
|
200 |
url = new URL(getParameters().getHost()); |
|
201 |
File file = Utilities.downloadFile(url, "checkhost.dat", null); |
|
202 |
} catch (Exception e) { |
|
203 |
return false; |
|
204 |
} |
|
205 |
|
|
206 |
return true; |
|
207 |
} |
|
208 |
|
|
209 |
/** |
|
210 |
* Checks if the network and host are reachable |
|
211 |
* @return true if both are reachable and false if they are not |
|
212 |
*/ |
|
213 |
public boolean isHostReachable() { |
|
214 |
int timeout = 10000; |
|
215 |
return isHostReachable(timeout); |
|
216 |
} |
|
217 |
|
|
218 |
/** |
|
219 |
* Returns true if this provider is connected to the server |
|
220 |
* @return |
|
221 |
*/ |
|
222 |
public boolean isConnected() { |
|
223 |
if(connector != null) |
|
224 |
return true; |
|
225 |
return false; |
|
226 |
} |
|
227 |
|
|
228 |
/** |
|
229 |
* Gets the description of this service |
|
230 |
* @return |
|
231 |
*/ |
|
232 |
public String getAbstract() { |
|
233 |
if(connector != null) |
|
234 |
return connector.getAbstract(); |
|
235 |
return null; |
|
236 |
} |
|
237 |
|
|
238 |
/** |
|
239 |
* Gets the list of raster formats supported by the server |
|
240 |
* @return |
|
241 |
*/ |
|
242 |
@SuppressWarnings("unchecked") |
|
243 |
public String[] getFormats() { |
|
244 |
if(connector != null) { |
|
245 |
Vector f = connector.getFormats(); |
|
246 |
ArrayList formatos = new ArrayList(); |
|
247 |
for (int i = 0; i < f.size(); i++) { |
|
248 |
formatos.add(f.elementAt(i)); |
|
249 |
} |
|
250 |
return (String[]) formatos.toArray(new String[0]); |
|
251 |
} |
|
252 |
return null; |
|
253 |
} |
|
254 |
|
|
255 |
/** |
|
256 |
* Gets the list of raster information formats supported by the server |
|
257 |
* @return |
|
258 |
*/ |
|
259 |
@SuppressWarnings("unchecked") |
|
260 |
public String[] getInfoFormats() { |
|
261 |
if(connector != null) { |
|
262 |
Vector f = connector.getInfoFormats(); |
|
263 |
ArrayList formatos = new ArrayList(); |
|
264 |
for (int i = 0; i < f.size(); i++) { |
|
265 |
formatos.add(f.elementAt(i)); |
|
266 |
} |
|
267 |
return (String[]) formatos.toArray(new String[0]); |
|
268 |
} |
|
269 |
return null; |
|
270 |
} |
|
271 |
|
|
272 |
/** |
|
273 |
* Gets a tree of nodes which represents the server information |
|
274 |
* @return |
|
275 |
*/ |
|
276 |
public WMSLayerNode getLayerTree() { |
|
277 |
if(connector != null) { |
|
278 |
return connector.getLayersTree(); |
|
279 |
} |
|
280 |
return null; |
|
281 |
} |
|
282 |
|
|
283 |
/** |
|
284 |
* Gets the server title |
|
285 |
* @return |
|
286 |
*/ |
|
287 |
public String getServerType() { |
|
288 |
if (getVersion() == null) |
|
289 |
return "WMS"; |
|
290 |
return "WMS "+ getVersion(); |
|
291 |
} |
|
292 |
|
|
293 |
/** |
|
294 |
* Gets the online resources |
|
295 |
* @return |
|
296 |
*/ |
|
297 |
public Hashtable getOnlineResources() { |
|
298 |
if(connector != null) { |
|
299 |
return connector.getOnlineResources(); |
|
300 |
} |
|
301 |
return null; |
|
302 |
} |
|
303 |
|
|
304 |
/** |
|
305 |
* Gets the protocol supported by the server |
|
306 |
* @return |
|
307 |
*/ |
|
308 |
public String getVersion() { |
|
309 |
if(connector != null) { |
|
310 |
return (connector.getVersion() == null) ? "" : connector.getVersion(); |
|
311 |
} |
|
312 |
return null; |
|
313 |
} |
|
314 |
|
|
315 |
public Rectangle2D getLayersExtent(String[] layerName, String srs) { |
|
316 |
return connector.getLayersExtent(layerName, srs); |
|
317 |
} |
|
318 |
|
|
319 |
/** |
|
320 |
* Gets a layer using its name |
|
321 |
* @param layerName |
|
322 |
* @return |
|
323 |
*/ |
|
324 |
public WMSLayerNode getLayer(String layerName) { |
|
325 |
return connector.getLayer(layerName); |
|
326 |
} |
|
327 |
|
|
328 |
/** |
|
329 |
* Gets the host URI |
|
330 |
* @return |
|
331 |
*/ |
|
332 |
public String getHost() { |
|
333 |
return getParameters().getHost(); |
|
334 |
} |
|
335 |
|
|
336 |
public Rectangle2D getBoundingBox(String[] layerNames, String srs) { |
|
337 |
return connector.getLayersExtent(layerNames, srs); |
|
338 |
} |
|
339 |
|
|
340 |
public boolean isQueryable() { |
|
341 |
return connector.isQueryable(); |
|
342 |
} |
|
343 |
|
|
344 |
/** |
|
345 |
* Gets the title |
|
346 |
* @return |
|
347 |
*/ |
|
348 |
public String getTitle() { |
|
349 |
return null; |
|
350 |
} |
|
351 |
|
|
352 |
/** |
|
353 |
* @return The title of the service offered by the WMS server. |
|
354 |
*/ |
|
355 |
public String getServiceTitle() { |
|
356 |
return connector.getServiceTitle(); |
|
357 |
} |
|
358 |
|
|
359 |
public DataServerExplorerProviderServices getServerExplorerProviderServices() { |
|
360 |
return null; |
|
361 |
} |
|
362 |
} |
|
0 | 363 |
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.232/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/downloader/TileDownloaderForWMS.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.raster.wms.io.downloader; |
|
23 |
|
|
24 |
import java.awt.geom.Rectangle2D; |
|
25 |
import java.io.File; |
|
26 |
import java.io.IOException; |
|
27 |
import java.util.List; |
|
28 |
import java.util.Vector; |
|
29 |
|
|
30 |
import org.cresques.cts.IProjection; |
|
31 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
32 |
import org.gvsig.fmap.dal.coverage.dataset.Buffer; |
|
33 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
|
34 |
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException; |
|
35 |
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException; |
|
36 |
import org.gvsig.fmap.dal.coverage.exception.QueryException; |
|
37 |
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException; |
|
38 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
|
39 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
|
40 |
import org.gvsig.fmap.dal.coverage.store.RasterQuery; |
|
41 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
42 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
43 |
import org.gvsig.raster.cache.tile.Tile; |
|
44 |
import org.gvsig.raster.cache.tile.exception.TileGettingException; |
|
45 |
import org.gvsig.raster.impl.DefaultRasterManager; |
|
46 |
import org.gvsig.raster.impl.provider.RasterProvider; |
|
47 |
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader; |
|
48 |
import org.gvsig.raster.util.DefaultProviderServices; |
|
49 |
import org.gvsig.raster.wms.io.RemoteWMSStyle; |
|
50 |
import org.gvsig.raster.wms.io.WMSConnector; |
|
51 |
import org.gvsig.raster.wms.io.WMSDataParameters; |
|
52 |
import org.gvsig.raster.wms.io.WMSProvider; |
|
53 |
import org.gvsig.remoteclient.utils.Utilities; |
|
54 |
import org.gvsig.remoteclient.wms.WMSStatus; |
|
55 |
import org.gvsig.tools.locator.LocatorException; |
|
56 |
|
|
57 |
/** |
|
58 |
* Tile getter |
|
59 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
|
60 |
*/ |
|
61 |
public class TileDownloaderForWMS extends BaseTileDownloader { |
|
62 |
private WMSConnector connector = null; |
|
63 |
private Extent lyrExtent = null; |
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
public TileDownloaderForWMS(RasterDataStore store, |
|
68 |
int tilePxWidth, |
|
69 |
int tilePxHeight) throws RemoteServiceException { |
|
70 |
super(store, tilePxWidth, tilePxHeight); |
|
71 |
this.connector = ((WMSProvider)store.getProvider()).getConnector(); |
|
72 |
lyrExtent = store.getExtent(); |
|
73 |
} |
|
74 |
|
|
75 |
public synchronized Tile downloadTile(Tile tile) throws TileGettingException { |
|
76 |
try { |
|
77 |
Rectangle2D r = new Rectangle2D.Double(tile.getExtent().getMinX(), |
|
78 |
tile.getExtent().getMinY() - tile.getExtent().getHeight(), |
|
79 |
tile.getExtent().getWidth(), |
|
80 |
tile.getExtent().getHeight()); |
|
81 |
//Extent tileExtent = RasterLocator.getManager().getDataStructFactory().createExtent(r); |
|
82 |
WMSDataParameters p = (WMSDataParameters)store.getParameters(); |
|
83 |
WMSStatus wmsStatus = new WMSStatus(); |
|
84 |
wmsStatus.setLayerNames(Utilities.createVector(p.getLayerQuery(), ",")); |
|
85 |
wmsStatus.setSrs(p.getSRSCode()); |
Also available in: Unified diff