root / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClientOld / wms / WMSLayer.java @ 3321
History | View | Annotate | Download (2.97 KB)
1 |
package org.gvsig.remoteClientOld.wms; |
---|---|
2 |
|
3 |
import java.awt.geom.Rectangle2D; |
4 |
import java.util.TreeMap; |
5 |
|
6 |
import org.gvsig.remoteClientOld.descriptor.Layer; |
7 |
|
8 |
public class WMSLayer extends Layer |
9 |
{ |
10 |
//private WMSClient wms;
|
11 |
private TreeMap styles = new TreeMap(); |
12 |
private TreeMap srsBBox = new TreeMap(); |
13 |
private String defaultSRS = null; |
14 |
|
15 |
public WMSLayer()
|
16 |
{ |
17 |
} |
18 |
|
19 |
// public WMSLayer(WMSClient wms) {
|
20 |
// super();
|
21 |
// this.wms = wms;
|
22 |
// }
|
23 |
|
24 |
public Rectangle2D getBoundingBox() { |
25 |
Rectangle2D bBox = null; |
26 |
String srs = getBoundingBoxSRS();
|
27 |
if (srs != null){ |
28 |
bBox = (Rectangle2D) srsBBox.get(srs);
|
29 |
if (bBox == null){ |
30 |
WMSLayer parentLayer = (WMSLayer) getParent(); |
31 |
if (parentLayer != null){ |
32 |
bBox = parentLayer.getBoundingBox(); |
33 |
} |
34 |
} |
35 |
} |
36 |
return bBox;
|
37 |
} |
38 |
|
39 |
public String getBoundingBoxSRS(){ |
40 |
String srs = getDefaultSRS();
|
41 |
if (srs == null) { |
42 |
Object [] keys = srsBBox.keySet().toArray(); |
43 |
if (keys.length > 0) { |
44 |
srs = (String) keys[0]; |
45 |
} else {
|
46 |
WMSLayer parentLayer = (WMSLayer) getParent(); |
47 |
if (parentLayer != null){ |
48 |
srs = parentLayer.getBoundingBoxSRS(); |
49 |
} |
50 |
} |
51 |
} |
52 |
return srs;
|
53 |
} |
54 |
|
55 |
public Rectangle2D getLatLonBoundingBox() { |
56 |
Rectangle2D bBox = super.getLatLonBoundingBox(); |
57 |
if (bBox == null) { |
58 |
WMSLayer parentLayer = (WMSLayer) getParent(); |
59 |
if (parentLayer != null){ |
60 |
bBox = parentLayer.getLatLonBoundingBox(); |
61 |
} |
62 |
} |
63 |
// if (wms.isXYSwapped()) {
|
64 |
// return new Rectangle2D.Double(
|
65 |
// bBox.getMinY(), bBox.getMinX(), bBox.getHeight(), bBox.getWidth());
|
66 |
// }
|
67 |
return bBox;
|
68 |
} |
69 |
|
70 |
public Rectangle2D getBoundingBox(String srs) { |
71 |
Rectangle2D bBox = (Rectangle2D) srsBBox.get(srs); |
72 |
if (bBox == null) { |
73 |
WMSLayer parentLayer = (WMSLayer) getParent(); |
74 |
if (parentLayer != null){ |
75 |
bBox = parentLayer.getBoundingBox(srs); |
76 |
} |
77 |
} |
78 |
// if (wms.isXYSwapped()) {
|
79 |
// return new Rectangle2D.Double(
|
80 |
// bBox.getMinY(), bBox.getMinX(), bBox.getHeight(), bBox.getWidth());
|
81 |
// }
|
82 |
return bBox;
|
83 |
} |
84 |
|
85 |
public void addBoundingBox(String srs, Rectangle2D bBox) { |
86 |
srsBBox.put(srs, bBox); |
87 |
} |
88 |
/**
|
89 |
* @return Returns the styles.
|
90 |
*/
|
91 |
public TreeMap getStyles() { |
92 |
return styles;
|
93 |
} |
94 |
|
95 |
/**
|
96 |
* @param styles The styles to set.
|
97 |
*/
|
98 |
public void addStyle(WMSStyle style) { |
99 |
styles.put(style.getName(), style); |
100 |
} |
101 |
|
102 |
public WMSStyle getStyle(String styleName) { |
103 |
return (WMSStyle) styles.get(styleName);
|
104 |
} |
105 |
/**
|
106 |
* @return Returns the defaultSRS.
|
107 |
*/
|
108 |
public String getDefaultSRS() { |
109 |
if (defaultSRS == null) { |
110 |
WMSLayer parentLayer = (WMSLayer) getParent(); |
111 |
if (parentLayer != null){ |
112 |
return parentLayer.getDefaultSRS();
|
113 |
} |
114 |
} |
115 |
return defaultSRS;
|
116 |
} |
117 |
/**
|
118 |
* @param defaultSRS The defaultSRS to set.
|
119 |
*/
|
120 |
public void setDefaultSRS(String defaultSRS) { |
121 |
this.defaultSRS = defaultSRS;
|
122 |
} |
123 |
} |
124 |
|