Revision 3377 branches/gvSIG_WMSv2/extensions/extWMS/src/com/iver/cit/gvsig/fmap/drivers/wms/FMapWMSDriver.java
FMapWMSDriver.java | ||
---|---|---|
49 | 49 |
|
50 | 50 |
import javax.imageio.ImageIO; |
51 | 51 |
|
52 |
import org.exolab.castor.xml.ValidationException; |
|
52 |
import org.gvsig.remoteClient.wms.WMSClient; |
|
53 |
import org.gvsig.remoteClient.wms.WMSStatus; |
|
53 | 54 |
|
54 | 55 |
import com.iver.cit.gvsig.fmap.drivers.WMSDriver; |
55 | 56 |
import com.iver.cit.gvsig.fmap.drivers.WMSException; |
56 |
import com.iver.wmsclient.Capabilities; |
|
57 |
import com.iver.wmsclient.FeatureInfoQuery; |
|
58 |
import com.iver.wmsclient.MapQuery; |
|
59 |
import com.iver.wmsclient.UnsupportedVersionException; |
|
60 |
import com.iver.wmsclient.WMSClient; |
|
61 |
import com.iver.wmsclient.WMSClientFactory; |
|
57 |
//import com.iver.wmsclient.Capabilities;
|
|
58 |
//import com.iver.wmsclient.FeatureInfoQuery;
|
|
59 |
//import com.iver.wmsclient.MapQuery;
|
|
60 |
//import com.iver.wmsclient.UnsupportedVersionException;
|
|
61 |
//import com.iver.wmsclient.WMSClient;
|
|
62 |
//import com.iver.wmsclient.WMSClientFactory;
|
|
62 | 63 |
|
63 | 64 |
|
64 | 65 |
/** |
... | ... | |
67 | 68 |
* @author Vicente Caballero Navarro |
68 | 69 |
*/ |
69 | 70 |
public class FMapWMSDriver implements WMSDriver { |
70 |
private MapQuery lastMapQuery; |
|
71 |
//private MapQuery lastMapQuery; |
|
72 |
//private WMSClient client; |
|
73 |
|
|
74 |
private WMSStatus wmsStatus; |
|
71 | 75 |
private WMSClient client; |
72 |
|
|
73 | 76 |
/** |
74 | 77 |
* @see com.iver.cit.gvsig.fmap.drivers.WMSDriver#getCapabilities(java.net.URL) |
75 | 78 |
*/ |
76 | 79 |
public void getCapabilities(URL servidor) |
77 | 80 |
throws WMSException, IOException, ProtocolException { |
78 | 81 |
try { |
79 |
Capabilities c = getClient(servidor).getCapabilities(servidor); |
|
80 |
} catch (UnsupportedVersionException e) { |
|
82 |
//Capabilities c = getClient(servidor).getCapabilities(servidor); |
|
83 |
getClient(servidor).connect(); |
|
84 |
//} catch (UnsupportedVersionException e) { |
|
85 |
} catch (Exception e) { |
|
81 | 86 |
throw new WMSException(e); |
82 | 87 |
} |
83 | 88 |
} |
... | ... | |
85 | 90 |
/** |
86 | 91 |
* @see com.iver.cit.gvsig.fmap.drivers.WMSDriver#getMap(com.iver.cit.gvsig.fmap.drivers.wms.MapQuery) |
87 | 92 |
*/ |
88 |
public Image getMap(MapQuery mapQuery)
|
|
93 |
public Image getMap(WMSStatus wmsstatus)
|
|
89 | 94 |
throws WMSException, IOException, ProtocolException { |
90 |
BufferedImage image = new BufferedImage(mapQuery.getWidth(),
|
|
91 |
mapQuery.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
|
95 |
BufferedImage image = new BufferedImage(wmsstatus.getWidth(),
|
|
96 |
wmsstatus.getHeight(), BufferedImage.TYPE_INT_ARGB);
|
|
92 | 97 |
|
93 | 98 |
try { |
94 |
byte[] res = client.doMapQuery(mapQuery);
|
|
99 |
byte[] res = client.getMap(wmsstatus);
|
|
95 | 100 |
ByteArrayInputStream inbytes = new ByteArrayInputStream(res); |
96 | 101 |
image = ImageIO.read(inbytes); |
97 | 102 |
|
98 | 103 |
return image; |
99 |
} catch (ValidationException e) { |
|
100 |
throw new ProtocolException(); |
|
101 |
} catch (com.iver.wmsclient.WMSException e) {
|
|
104 |
// } catch (ValidationException e) {
|
|
105 |
// throw new ProtocolException();
|
|
106 |
} catch (org.gvsig.remoteClient.exceptions.WMSException e) {
|
|
102 | 107 |
throw new WMSException(e); |
103 |
} catch (NoSuchFieldException e) { |
|
104 |
throw new RuntimeException( |
|
105 |
"No se incluyeron todos los campos necesarios de la petici?n"); |
|
108 |
// } catch (NoSuchFieldException e) {
|
|
109 |
// throw new RuntimeException(
|
|
110 |
// "No se incluyeron todos los campos necesarios de la petici?n");
|
|
106 | 111 |
} |
107 | 112 |
} |
108 | 113 |
|
109 | 114 |
/** |
110 | 115 |
* @see com.iver.cit.gvsig.fmap.drivers.WMSDriver#getFeatureInfo(com.iver.cit.gvsig.fmap.drivers.wms.InfoQuery) |
111 | 116 |
*/ |
112 |
public String getFeatureInfo(FeatureInfoQuery infoQuery) |
|
117 |
//public String getFeatureInfo(FeatureInfoQuery infoQuery) |
|
118 |
public String getFeatureInfo(WMSStatus wmsStatus) |
|
113 | 119 |
throws WMSException, IOException, ProtocolException { |
114 | 120 |
return null; |
115 | 121 |
} |
... | ... | |
125 | 131 |
* @throws IOException |
126 | 132 |
*/ |
127 | 133 |
private WMSClient getClient(URL url) |
128 |
throws UnsupportedVersionException, IOException {
|
|
134 |
throws IOException { |
|
129 | 135 |
if (client == null) { |
130 |
client = WMSClientFactory.getClient(url); |
|
136 |
//client = WMSClientFactory.getClient(url); |
|
137 |
client = new WMSClient(url.toString()); |
|
131 | 138 |
} |
132 | 139 |
|
133 | 140 |
return client; |
Also available in: Unified diff