svn-gvsig-desktop / tmp / trunk / cliente / WorkSpace_WPSClient / extWPSCallejero / src / es / logex / gvsig / wps / client / WPSClient.java @ 26594
History | View | Annotate | Download (3.15 KB)
1 |
package es.logex.gvsig.wps.client; |
---|---|
2 |
|
3 |
import java.awt.geom.Rectangle2D; |
4 |
import java.io.File; |
5 |
import java.io.IOException; |
6 |
import java.net.ConnectException; |
7 |
import java.util.ArrayList; |
8 |
import java.util.Hashtable; |
9 |
import java.util.List; |
10 |
import java.util.Stack; |
11 |
import java.util.Vector; |
12 |
|
13 |
import javax.xml.bind.JAXBException; |
14 |
|
15 |
import org.apache.log4j.Logger; |
16 |
import org.gvsig.remoteClient.RemoteClient; |
17 |
import org.gvsig.remoteClient.wms.ICancellable; |
18 |
import org.gvsig.remoteClient.wms.WMSProtocolHandler; |
19 |
import org.tigris.frogs.OWSException; |
20 |
import org.tigris.frogs.ows.ServiceIdentificationType; |
21 |
import org.tigris.frogs.ows.impl_0_3_20.BoundingBox; |
22 |
import org.w3c.dom.Document; |
23 |
|
24 |
|
25 |
public class WPSClient extends RemoteClient { |
26 |
|
27 |
private static Logger logger = Logger.getLogger(WPSClient.class.getName()); |
28 |
private WPSProtocolHandler handler;
|
29 |
private Stack<String> errorsStack = new Stack<String>(); |
30 |
|
31 |
public WPSClient(String host) { |
32 |
|
33 |
setHost(host); |
34 |
|
35 |
handler = WPSProtocolHandlerFactory.negotiate(getHost()); |
36 |
handler.setHost(getHost()); |
37 |
|
38 |
} |
39 |
|
40 |
@Override
|
41 |
public void close() { |
42 |
// TODO Auto-generated method stub
|
43 |
|
44 |
} |
45 |
|
46 |
@Override
|
47 |
public boolean connect (boolean arg0, ICancellable arg1) |
48 |
{ //TODO: Gestionar las excepciones.
|
49 |
try {
|
50 |
if (handler == null) { |
51 |
if (getHost().trim().length() > 0) { |
52 |
handler = WPSProtocolHandlerFactory.negotiate(getHost()); |
53 |
handler.setHost(getHost()); |
54 |
} else {
|
55 |
// must to specify host first!!!!
|
56 |
return false; |
57 |
} |
58 |
} |
59 |
|
60 |
getCapabilities(); |
61 |
|
62 |
return true; |
63 |
|
64 |
} catch (Throwable e) { |
65 |
// TODO Auto-generated catch block
|
66 |
e.printStackTrace(); |
67 |
errorsStack.add(e.getMessage()); |
68 |
|
69 |
Throwable t = e;
|
70 |
while( (t = t.getCause())!=null) |
71 |
{ |
72 |
errorsStack.add(t.getClass().toString() + ": " + t.getMessage());
|
73 |
} |
74 |
} |
75 |
return false; |
76 |
} |
77 |
|
78 |
public Stack<String> getErrorsStack() |
79 |
{ |
80 |
|
81 |
return errorsStack;
|
82 |
} |
83 |
|
84 |
public boolean connect() |
85 |
{ |
86 |
return connect(false, null); |
87 |
} |
88 |
|
89 |
/**
|
90 |
* Obtiene la información del servidor.
|
91 |
*/
|
92 |
public void getCapabilities() throws Throwable { |
93 |
handler.getCapabilites(); |
94 |
} |
95 |
|
96 |
/**
|
97 |
*/
|
98 |
public String getVersion(){ |
99 |
return handler.getVersion();
|
100 |
} |
101 |
|
102 |
public String getServiceAbstract() { |
103 |
return handler.getServiceIdentification().getOwsAbstract();
|
104 |
} |
105 |
|
106 |
public File executeProcessGetLayer(Rectangle2D extent, String srs,String layerName, |
107 |
String datailLevel) {
|
108 |
|
109 |
Double[] lowerCorner = {0.0, 0.0}; |
110 |
Double[] upperCorner = {0.0, 0.0}; |
111 |
|
112 |
//TODO: Comprobación de extent == null y lanzar excepción en su caso.
|
113 |
BoundingBox box= new BoundingBox();
|
114 |
|
115 |
if (extent != null) { |
116 |
lowerCorner[0] = extent.getMinX();
|
117 |
lowerCorner[1] = extent.getMinY();
|
118 |
upperCorner[0] = extent.getMaxX();
|
119 |
upperCorner[1] = extent.getMaxY();
|
120 |
} |
121 |
|
122 |
box.setLowerCorner(lowerCorner); |
123 |
box.setUpperCorner(upperCorner); |
124 |
box.setCrsAttribute(srs); |
125 |
|
126 |
return handler.executeProcessGetLayer(box, layerName, datailLevel);
|
127 |
|
128 |
} |
129 |
|
130 |
public List<String> executeProcessGetCandidates(String town, String street, String number) { |
131 |
return handler.executeProcessGetCandidates(town, street, number);
|
132 |
} |
133 |
|
134 |
|
135 |
public WPSProtocolHandler getWPSProtocolHandler() {
|
136 |
return handler;
|
137 |
} |
138 |
|
139 |
|
140 |
} |
141 |
|
142 |
|