Revision 3592 trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wms/wms_1_1_1/WMSProtocolHandler1_1_1.java
WMSProtocolHandler1_1_1.java | ||
---|---|---|
12 | 12 |
import java.util.TreeMap; |
13 | 13 |
import java.util.Vector; |
14 | 14 |
|
15 |
import org.gvsig.remoteClient.exceptions.WMSException; |
|
15 | 16 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
16 | 17 |
import org.gvsig.remoteClient.utils.ExceptionTags; |
17 | 18 |
import org.kxml2.io.KXmlParser; |
... | ... | |
23 | 24 |
* </p> |
24 | 25 |
*/ |
25 | 26 |
public class WMSProtocolHandler1_1_1 extends org.gvsig.remoteClient.wms.WMSProtocolHandler { |
26 |
|
|
27 |
private WMSLayer1_1_1 fakeRootLayer; |
|
28 |
|
|
27 | 29 |
public WMSProtocolHandler1_1_1() |
28 | 30 |
{ |
29 | 31 |
this.version = "1.1.1"; |
... | ... | |
31 | 33 |
this.serviceInfo = new ServiceInformation(); |
32 | 34 |
this.layers = new TreeMap(); |
33 | 35 |
this.srs = new Vector(); |
36 |
|
|
34 | 37 |
} |
35 | 38 |
|
36 | 39 |
//------------------------------------------------------------------------------ |
... | ... | |
100 | 103 |
catch (IOException ioe) { |
101 | 104 |
ioe.printStackTrace(); |
102 | 105 |
// TODO: Implement logic to handle the exceptions |
103 |
} |
|
106 |
} finally { |
|
107 |
|
|
108 |
} |
|
104 | 109 |
// In the parsing process the layer has been filled |
105 | 110 |
} |
106 | 111 |
|
... | ... | |
177 | 182 |
else if (parser.getName().compareTo(CapabilitiesTags.LAYER)==0) |
178 | 183 |
{ |
179 | 184 |
WMSLayer1_1_1 lyr = new WMSLayer1_1_1(); |
180 |
rootLayer = lyr; |
|
185 |
if (rootLayer == null) |
|
186 |
rootLayer = lyr; |
|
187 |
else { |
|
188 |
// Handles when there is no general root layer, will use |
|
189 |
// a fake non-queryable one. |
|
190 |
if (!rootLayer.equals(getFakeRootLayer())){ |
|
191 |
WMSLayer1_1_1 aux = (WMSLayer1_1_1) rootLayer; |
|
192 |
rootLayer = getFakeRootLayer(); |
|
193 |
rootLayer.getChildren().add(aux); |
|
194 |
} |
|
195 |
rootLayer.getChildren().add(lyr); |
|
196 |
} |
|
181 | 197 |
lyr.parse(parser, layers); |
182 |
//if((lyr != null) && (lyr.getName() != null)) |
|
183 |
//{ |
|
198 |
|
|
184 | 199 |
if (lyr.getName()!=null) |
185 |
layers.put(lyr.getName(), lyr); |
|
186 |
//Add all the SRS that the layer supports to the WMSProtocolHandler if they dont exist already |
|
187 |
for (i=0;i<lyr.getAllSrs().size();i++) |
|
188 |
{ |
|
189 |
if (!this.srs.contains(lyr.getAllSrs().elementAt(i))) |
|
190 |
{ |
|
191 |
this.srs.add( lyr.getAllSrs().elementAt(i)); |
|
192 |
} |
|
193 |
} |
|
194 |
//} |
|
195 |
//else |
|
196 |
//TODO: a layer without title is a parent layer.... not queryable |
|
200 |
layers.put(lyr.getName(), lyr); |
|
201 |
//Add all the SRS that the layer supports to the WMSProtocolHandler if they dont exist already |
|
202 |
for (i=0;i<lyr.getAllSrs().size();i++) |
|
203 |
{ |
|
204 |
if (!this.srs.contains(lyr.getAllSrs().elementAt(i))) |
|
205 |
{ |
|
206 |
this.srs.add( lyr.getAllSrs().elementAt(i)); |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
197 | 210 |
} |
198 | 211 |
else if ((parser.getName().compareTo(CapabilitiesTags.VENDORSPECIFICCAPABILITIES)==0) || |
199 | 212 |
(parser.getName().compareTo(CapabilitiesTags.USERDEFINEDSYMBOLIZATION )==0)) |
... | ... | |
262 | 275 |
//parser.require(KXmlParser.END_TAG, null, CapabilitiesTags.REQUEST); |
263 | 276 |
} |
264 | 277 |
|
278 |
private WMSLayer1_1_1 getFakeRootLayer(){ |
|
279 |
if (fakeRootLayer == null){ |
|
280 |
fakeRootLayer = new WMSLayer1_1_1(); |
|
281 |
fakeRootLayer.setTitle(serviceInfo.title); |
|
282 |
fakeRootLayer.setQueryable(false); |
|
283 |
fakeRootLayer.setName(null); |
|
284 |
} |
|
285 |
return fakeRootLayer; |
|
286 |
} |
|
265 | 287 |
/* (non-Javadoc) |
266 | 288 |
* @see org.gvsig.remoteClient.wms.WMSProtocolHandler#parseException(byte[]) |
267 | 289 |
*/ |
Also available in: Unified diff