Revision 4356
trunk/extensions/extWCS/src/com/iver/cit/gvsig/fmap/services/OGCWCSService.java | ||
---|---|---|
9 | 9 |
import java.io.IOException; |
10 | 10 |
import java.util.ArrayList; |
11 | 11 |
|
12 |
import org.gvsig.remoteClient.wcs.WCSStatus; |
|
13 |
|
|
12 | 14 |
import com.iver.cit.gvsig.fmap.DriverException; |
15 |
import com.iver.cit.gvsig.fmap.drivers.WCSException; |
|
16 |
import com.iver.cit.gvsig.fmap.layers.WCSLayer; |
|
13 | 17 |
|
14 |
import es.uji.lsi.wcs.client.ServerErrorResponseException; |
|
15 |
import es.uji.lsi.wcs.client.ServerOutOfOrderException; |
|
16 |
|
|
17 | 18 |
/** |
18 | 19 |
* @author luisw |
19 | 20 |
*/ |
... | ... | |
21 | 22 |
public String getLabel(); |
22 | 23 |
public String getDescription(); |
23 | 24 |
|
24 |
public void getCapabilities() throws ServerOutOfOrderException;
|
|
25 |
public void describeCoverage() throws ServerOutOfOrderException;
|
|
26 |
public File getCoverage() throws ServerErrorResponseException, IOException;
|
|
25 |
public void getCapabilities(WCSStatus status) throws WCSException;
|
|
26 |
public void describeCoverage(WCSStatus status) throws WCSException;
|
|
27 |
public File getCoverage(WCSStatus status) throws WCSException;
|
|
27 | 28 |
|
28 |
public String [] getCoverageNames();
|
|
29 |
public WCSLayer[] getLayerList();
|
|
29 | 30 |
|
30 | 31 |
/** |
31 | 32 |
* Gets the label of an specific label. |
... | ... | |
68 | 69 |
* @param coverageName (string) |
69 | 70 |
* @return double |
70 | 71 |
*/ |
71 |
public Point2D getMaxResolution(String coverageName); |
|
72 |
public Point2D getMaxResolution(String coverageName) throws WCSException ;
|
|
72 | 73 |
|
73 | 74 |
/** |
74 | 75 |
* Gets the times list of an specific coverage. |
trunk/extensions/extWCS/src/com/iver/cit/gvsig/fmap/drivers/WCSException.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.fmap.drivers; |
|
42 |
|
|
43 |
import com.iver.andami.PluginServices; |
|
44 |
|
|
45 |
/** |
|
46 |
* Excepci�n provocada por el WCS. |
|
47 |
* |
|
48 |
* @author Vicente Caballero Navarro |
|
49 |
*/ |
|
50 |
public class WCSException extends Exception { |
|
51 |
String message; |
|
52 |
|
|
53 |
public String getMessage() { |
|
54 |
return PluginServices.getText(this, "wcs_server_error")+"\n"+format(message, 200); |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* |
|
59 |
*/ |
|
60 |
public WCSException() { |
|
61 |
super(); |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Crea WCSException. |
|
66 |
* |
|
67 |
* @param message |
|
68 |
*/ |
|
69 |
public WCSException(String message) { |
|
70 |
super(); |
|
71 |
this.message = message; |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Crea WCSException. |
|
76 |
* |
|
77 |
* @param message |
|
78 |
* @param cause |
|
79 |
*/ |
|
80 |
public WCSException(String message, Throwable cause) { |
|
81 |
super(format(message, 200), cause); |
|
82 |
} |
|
83 |
|
|
84 |
/** |
|
85 |
* Crea WCSException. |
|
86 |
* |
|
87 |
* @param cause |
|
88 |
*/ |
|
89 |
public WCSException(Throwable cause) { |
|
90 |
super(cause); |
|
91 |
} |
|
92 |
|
|
93 |
/** |
|
94 |
* Cuts the message text to force its lines to be shorter or equal to |
|
95 |
* lineLength. |
|
96 |
* @param message, the message. |
|
97 |
* @param lineLength, the max line length in number of characters. |
|
98 |
* @return the formated message. |
|
99 |
*/ |
|
100 |
private static String format(String message, int lineLength){ |
|
101 |
if (message.length() <= lineLength) return message; |
|
102 |
String[] lines = message.split("\n"); |
|
103 |
String theMessage = ""; |
|
104 |
for (int i = 0; i < lines.length; i++) { |
|
105 |
String line = lines[i].trim(); |
|
106 |
if (line.length()<lineLength) |
|
107 |
theMessage += line+"\n"; |
|
108 |
else { |
|
109 |
String[] chunks = line.split(" "); |
|
110 |
String newLine = ""; |
|
111 |
for (int j = 0; j < chunks.length; j++) { |
|
112 |
int currentLength = newLine.length(); |
|
113 |
chunks[j] = chunks[j].trim(); |
|
114 |
if (chunks[j].length()==0) |
|
115 |
continue; |
|
116 |
if ((currentLength + chunks[j].length() + " ".length()) <= lineLength) |
|
117 |
newLine += chunks[j] + " "; |
|
118 |
else { |
|
119 |
newLine += "\n"+chunks[j]+" "; |
|
120 |
theMessage += newLine; |
|
121 |
newLine = ""; |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
} |
|
126 |
} |
|
127 |
return theMessage; |
|
128 |
} |
|
129 |
} |
|
0 | 130 |
trunk/extensions/extWCS/src/com/iver/cit/gvsig/fmap/drivers/wcs/FMapWCSDriver.java | ||
---|---|---|
44 | 44 |
import java.awt.geom.Rectangle2D; |
45 | 45 |
import java.io.File; |
46 | 46 |
import java.io.IOException; |
47 |
import java.net.ConnectException; |
|
48 |
import java.net.URL; |
|
47 | 49 |
import java.util.ArrayList; |
50 |
import java.util.Hashtable; |
|
48 | 51 |
import java.util.Iterator; |
49 | 52 |
|
53 |
import org.gvsig.remoteClient.wcs.WCSClient; |
|
54 |
import org.gvsig.remoteClient.wcs.WCSCoverage; |
|
55 |
import org.gvsig.remoteClient.wcs.WCSStatus; |
|
56 |
|
|
50 | 57 |
import com.iver.cit.gvsig.fmap.DriverException; |
51 | 58 |
import com.iver.cit.gvsig.fmap.drivers.RemoteServiceDriver; |
52 |
import com.iver.cit.gvsig.fmap.layers.WCSParameterModel; |
|
59 |
import com.iver.cit.gvsig.fmap.drivers.WCSException; |
|
60 |
import com.iver.cit.gvsig.fmap.layers.WCSLayer; |
|
53 | 61 |
import com.iver.cit.gvsig.fmap.services.OGCWCSService; |
54 | 62 |
|
55 |
import es.uji.lsi.wcs.XmlWcsParsing.AxisDescription; |
|
56 |
import es.uji.lsi.wcs.XmlWcsParsing.CoverageOffering; |
|
57 |
import es.uji.lsi.wcs.XmlWcsParsing.GMLEnvelopeWithTimePeriod; |
|
58 |
import es.uji.lsi.wcs.XmlWcsParsing.Interval; |
|
59 |
import es.uji.lsi.wcs.client.ServerErrorResponseException; |
|
60 |
import es.uji.lsi.wcs.client.ServerOutOfOrderException; |
|
61 |
import es.uji.lsi.wcs.client.WCSClient; |
|
62 |
|
|
63 | 63 |
/** |
64 | 64 |
* Driver between the FMap and WCSClient |
65 | 65 |
* |
... | ... | |
69 | 69 |
* |
70 | 70 |
*/ |
71 | 71 |
public class FMapWCSDriver extends RemoteServiceDriver implements OGCWCSService { |
72 |
private WCSClient wcs = null; |
|
72 |
private WCSClient client = null; |
|
73 |
private WCSCoverage[] layers; |
|
74 |
private Hashtable coverages; |
|
75 |
private WCSLayer[] layerList; |
|
73 | 76 |
|
74 | 77 |
/** |
75 | 78 |
* Returns the string "WCSDriver", which is the driver's name. |
... | ... | |
85 | 88 |
* Establece el servidor al que se quiere conectar. |
86 | 89 |
* |
87 | 90 |
* @param host |
91 |
* @throws IOException |
|
88 | 92 |
*/ |
89 |
public void setHost(String host){ |
|
93 |
public void setHost(String host) throws IOException{
|
|
90 | 94 |
super.setHost(host); |
91 | 95 |
setServiceName("WCS"); |
92 |
wcs = new WCSClient(host);
|
|
96 |
client = new WCSClient(host);
|
|
93 | 97 |
} |
94 | 98 |
|
95 |
/** |
|
96 |
* Sends the GetCapabilities operation to the server. |
|
97 |
* |
|
98 |
* Env?a la operaci?n GetCapabilities al servidor. |
|
99 |
* |
|
100 |
* @throws ServerOutOfOrderException |
|
101 |
*/ |
|
102 |
public void getCapabilities() throws ServerOutOfOrderException{ |
|
103 |
wcs.getCapabilities(); |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Sends the DescribeCoverage operation to the server. |
|
108 |
* |
|
109 |
* Env?a la operaci?n DescribeCoverage |
|
110 |
*/ |
|
111 |
public void describeCoverage(){ |
|
112 |
wcs.describeCoverage(); |
|
113 |
} |
|
114 | 99 |
|
115 | 100 |
/** |
116 |
* Sends the GetCoverage operation. |
|
117 |
* |
|
118 |
* Env?a la operaci?n GetCoverage. |
|
119 |
* @throws IOException |
|
120 |
*/ |
|
121 |
public File getCoverage() throws ServerErrorResponseException, IOException{ |
|
122 |
return wcs.getCoverage(); |
|
123 |
|
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* Returns the server's name. The string is extracted from the GetCapabilities |
|
128 |
* response. |
|
129 |
* |
|
130 |
* Devuelve el nombre del servidor indicado por ?ste. |
|
131 |
* |
|
132 |
* @return String |
|
133 |
*/ |
|
134 |
public String getServerName(){ |
|
135 |
return wcs.getTheCapabilities().getServiceName(); |
|
136 |
} |
|
137 |
|
|
138 |
/** |
|
139 | 101 |
* Returns a human-readable string containing the server's name. |
140 | 102 |
* |
141 | 103 |
* Devuelve el nombre legible del servidor devuelto por ?ste. |
142 | 104 |
* |
143 | 105 |
* @return String |
144 |
*/ |
|
145 |
public String getLabel(){ |
|
146 |
return wcs.getTheCapabilities().getServiceLabel();
|
|
106 |
*/
|
|
107 |
public String getLabel() {
|
|
108 |
return client.getServiceTitle();
|
|
147 | 109 |
} |
148 | 110 |
|
149 | 111 |
/** |
... | ... | |
154 | 116 |
* @return String |
155 | 117 |
*/ |
156 | 118 |
public String getVersion(){ |
157 |
return wcs.getTheCapabilities().getVersion();
|
|
119 |
return client.getVersion();
|
|
158 | 120 |
} |
159 | 121 |
|
160 | 122 |
/** |
123 |
* <p> |
|
161 | 124 |
* Returns name and description of the server. It is supposed to be used |
162 | 125 |
* as the source of the abstract field in your application's interface. |
163 |
* |
|
126 |
* </p> |
|
127 |
* <p> |
|
164 | 128 |
* Devuelve nombre y descripci?n (abstract) del servidor. |
165 |
* |
|
129 |
* </p>
|
|
166 | 130 |
* @return String |
167 | 131 |
*/ |
168 | 132 |
public String getDescription(){ |
169 |
String name = wcs.getTheCapabilities().getServiceName(); |
|
170 |
String description = wcs.getTheCapabilities().getServiceDescription(); |
|
171 |
|
|
172 |
if ( (name == null) && (description == null) ) return "Sin descripci?n"; |
|
173 |
else if ( (name != null) && (description == null) ) return name; |
|
174 |
else if ( (name == null) && (description != null) ) return description; |
|
175 |
else if ( (name != null) && (description != null) ) return name+"\n\n"+description; |
|
176 |
else return null; |
|
133 |
return client.getDescription(); |
|
177 | 134 |
} |
178 | 135 |
|
179 |
/** |
|
180 |
* Returns the update sequence value. |
|
181 |
* |
|
182 |
* Devuelve el valor de update sequence del servidor |
|
183 |
* |
|
184 |
* @return String |
|
185 |
*/ |
|
186 |
public String getUpdateSequence(){ |
|
187 |
return wcs.getTheCapabilities().getUpdateSequence(); |
|
188 |
} |
|
189 | 136 |
|
190 | 137 |
/** |
191 | 138 |
* Returns a list containing the formats supported by the coverage |
... | ... | |
196 | 143 |
* @return ArrayList |
197 | 144 |
*/ |
198 | 145 |
public ArrayList getFormats(String coverage){ |
199 |
return wcs.getCoverageDescription(coverage).getSupportedFormats().getFormats();
|
|
146 |
return client.getFormats();
|
|
200 | 147 |
} |
201 | 148 |
|
202 |
/** |
|
203 |
* Returns the metadata link. |
|
204 |
* |
|
205 |
* Devuelve el enlace a los metadatos. |
|
206 |
* |
|
207 |
* @return String |
|
208 |
*/ |
|
209 |
public String getMetadataLink(){ |
|
210 |
return wcs.getTheCapabilities().getServiceMetadatalink(); |
|
211 |
} |
|
212 | 149 |
|
213 |
/** |
|
214 |
* Returns the responsible party value. |
|
215 |
* |
|
216 |
* Devuelve el valor para responsible party. |
|
217 |
* |
|
218 |
* @return String |
|
219 |
*/ |
|
220 |
public String getResponsibleParty(){ |
|
221 |
return wcs.getTheCapabilities().getServiceResponsibleParty(); |
|
150 |
public WCSLayer[] getLayerList(){ |
|
151 |
if (coverages == null) { |
|
152 |
// the WCSLayer collection will be built |
|
153 |
coverages = new Hashtable(); |
|
154 |
Hashtable wcsCoverages = client.getCoverageList(); |
|
155 |
int sz = wcsCoverages.size(); |
|
156 |
|
|
157 |
// Create an array with the WCSCoverages |
|
158 |
WCSCoverage[] coverageList = new WCSCoverage[sz]; |
|
159 |
Iterator it = wcsCoverages.keySet().iterator(); |
|
160 |
int i = 0; |
|
161 |
while (it.hasNext()) { |
|
162 |
coverageList[i] = (WCSCoverage) it.next(); |
|
163 |
i++; |
|
164 |
} |
|
165 |
|
|
166 |
// Create a WCSLayer array from the previous WCSCoverage array |
|
167 |
layerList = new WCSLayer[sz]; |
|
168 |
for (int j = 0; j < layers.length; j++) { |
|
169 |
WCSLayer lyr = new WCSLayer(); |
|
170 |
WCSCoverage cov = coverageList[i]; |
|
171 |
lyr.setName(cov.getName()); |
|
172 |
lyr.addAllSrs(cov.getAllSrs()); |
|
173 |
lyr.setTitle(cov.getTitle()); |
|
174 |
lyr.setNativeSRS(cov.getNativeSRS()); |
|
175 |
lyr.setFormats(cov.getFormats()); |
|
176 |
lyr.setMaxRes(new Point2D.Double(cov.getResX(), cov.getResY())); |
|
177 |
// TODO par?metres i time |
|
178 |
layerList[j] = lyr; |
|
179 |
coverages.put(lyr.getName(), lyr); |
|
180 |
} |
|
181 |
|
|
182 |
|
|
183 |
} |
|
184 |
|
|
185 |
return layerList; |
|
222 | 186 |
} |
223 | 187 |
|
224 | 188 |
/** |
225 |
* Returns a list containing the names of the coverages located at the server. |
|
226 |
* |
|
227 |
* Devuelve una lista de nombres de coberturas |
|
228 |
* |
|
229 |
* @return String[] |
|
230 |
*/ |
|
231 |
public String[] getCoverageNames(){ |
|
232 |
return wcs.getTheCapabilities().getCoverageNames(); |
|
233 |
} |
|
234 |
|
|
235 |
/** |
|
236 |
* Returns the number of coverages at the server. |
|
237 |
* |
|
238 |
* Devuelve el numero de coberturas en el servidor |
|
239 |
* |
|
240 |
* @return int |
|
241 |
*/ |
|
242 |
public int getNumOfCoverages(){ |
|
243 |
return getCoverageNames().length; |
|
244 |
} |
|
245 |
|
|
246 |
/** |
|
247 |
* Returns the details of the coverage given by the coverage's name. |
|
248 |
* |
|
249 |
* Devuelve los detalles de la cobertura en CoverageOffering |
|
250 |
* @param nomCobertura |
|
251 |
* @return CoverageOffering (es.uji.lsi.wcs.XmlParsing.CoverageOffering) |
|
252 |
*/ |
|
253 |
public CoverageOffering getCoverageDetails(String nomCobertura){ |
|
254 |
return wcs.getCoverageDescription(nomCobertura); |
|
255 |
} |
|
256 |
|
|
257 |
/** |
|
258 | 189 |
* Establishes the connection to the WCS server. Connecting to a WCS is |
259 | 190 |
* an abstraction, it actually sends a GetCapabilities and a general |
260 | 191 |
* DescribeCoverage request (not a coverage-specific DescribeCoverage request) |
... | ... | |
269 | 200 |
* @throws IOException, DriverException. |
270 | 201 |
*/ |
271 | 202 |
public void connect() throws IOException, DriverException { |
272 |
wcs = new WCSClient(getHost()); |
|
273 |
try { |
|
274 |
wcs.getCapabilities(); |
|
275 |
wcs.describeCoverage(); |
|
276 |
setConnected(true); |
|
277 |
} catch (ServerOutOfOrderException e) { |
|
278 |
throw new DriverException(e); |
|
279 |
} |
|
203 |
client = new WCSClient(getHost()); |
|
204 |
setConnected( client.connect() ); |
|
280 | 205 |
} |
206 |
|
|
281 | 207 |
/** |
282 | 208 |
* No close operation is needed since WCS service it is a non-session based |
283 | 209 |
* protocol. So, this does nothing and you can omit it. |
... | ... | |
288 | 214 |
* |
289 | 215 |
*/ |
290 | 216 |
public void close() { |
291 |
// No fa res, tal volta this= null?
|
|
217 |
setConnected(false);
|
|
292 | 218 |
} |
293 | 219 |
|
294 | 220 |
/** |
295 |
* Returns the full extent for a specific SRS given by the second |
|
296 |
* argument srs of the specific coverage given by the coverage's name |
|
297 |
* in the first argument. You likely preffer to use getFullExtent(String, String) |
|
298 |
* |
|
299 |
* Devuelve la extensi?n m?xima para un SRS espec?fico dado en el segundo |
|
300 |
* argumento de una cobertura especifica dada por su nombre en el primer |
|
301 |
* argumento. Probablemente prefiera usar getFullExtent(String, String) |
|
302 |
* |
|
303 |
* @param coverageName |
|
304 |
* @param srs |
|
305 |
* @throws DriverException |
|
306 |
* @throws IOException |
|
307 |
*/ |
|
308 |
private Rectangle2D getBoundingBoxExtensionMaxima(String coverageName, String srs) throws IOException, DriverException { |
|
309 |
// TODO Has de considerar el cas per a quan el SRS no vinga als RequestResponse |
|
310 |
// ni cap altre... |
|
311 |
// IDEA: agafar algun dels de CoverageOfferingBrief i aplicar la transformaci?. |
|
312 |
CoverageOffering co = wcs.getCoverageDescription(coverageName); |
|
313 |
|
|
314 |
if (!isConnected()) |
|
315 |
connect(); |
|
316 |
if (co.getDomainSet() != null) { |
|
317 |
if (co.getDomainSet().getSpatialDomain() != null){ |
|
318 |
ArrayList gewtpList = co.getDomainSet().getSpatialDomain().getGMLEnvelopeWithTimePeriodList(); |
|
319 |
Iterator it = gewtpList.iterator(); |
|
320 |
while (it.hasNext()){ |
|
321 |
GMLEnvelopeWithTimePeriod gewtp = (GMLEnvelopeWithTimePeriod) it.next(); |
|
322 |
if (gewtp.getSRSName().equals(srs)) { |
|
323 |
return new Rectangle2D.Double( |
|
324 |
gewtp.getMinX(), |
|
325 |
gewtp.getMinY(), |
|
326 |
gewtp.getMaxX()-gewtp.getMinX(), |
|
327 |
gewtp.getMaxY()-gewtp.getMinY()); |
|
328 |
} |
|
329 |
} |
|
330 |
} |
|
331 |
} |
|
332 |
|
|
333 |
// Si llego aqu? es porque no ha habido ninguno. Tengo que transformar de las del BoundingBox. |
|
334 |
|
|
335 |
return null; |
|
336 |
} |
|
337 |
|
|
338 |
/** |
|
339 |
* Sends the GetCoverage query args using a string containing list of |
|
340 |
* &-separated pair-values (name=value) |
|
341 |
* |
|
342 |
* Env?a los valores de la consulta GetCoverage en forma cadena de pares |
|
343 |
* 'nombre=valor' separados por '&'. |
|
344 |
*/ |
|
345 |
public void setGetCoverageParams(String query) { |
|
346 |
wcs.setGetCoverageParams(query); |
|
347 |
|
|
348 |
} |
|
349 |
|
|
350 |
|
|
351 |
/** |
|
352 | 221 |
* Returns the label of an specific coverage given by the coverage name |
353 | 222 |
* |
354 | 223 |
* Obtiene la etiqueta de una cobertura espec?fica |
... | ... | |
357 | 226 |
* @return string |
358 | 227 |
*/ |
359 | 228 |
public String getLabel(String coverageName) { |
360 |
CoverageOffering co = getCoverageDetails(coverageName); |
|
361 |
return co.getCoverageOfferingBrief().getLabel(); |
|
229 |
return client.getLabel(coverageName); |
|
362 | 230 |
} |
363 | 231 |
|
364 | 232 |
/** |
... | ... | |
370 | 238 |
* @throws IOException |
371 | 239 |
*/ |
372 | 240 |
public Rectangle2D getFullExtent(String coverageName, String srs) throws IOException, DriverException { |
373 |
return getBoundingBoxExtensionMaxima(coverageName, srs);
|
|
241 |
return client.getExtent(coverageName, srs);
|
|
374 | 242 |
} |
375 | 243 |
|
376 | 244 |
/** |
... | ... | |
383 | 251 |
* @return ArrayList de Parametro |
384 | 252 |
*/ |
385 | 253 |
public ArrayList getParameters(String coverageName) { |
386 |
CoverageOffering co = getCoverageDetails(coverageName); |
|
387 |
ArrayList lista_descripciones = co.getRangeSet().getAxisDescriptionList(); |
|
388 |
ArrayList lista_parametros = new ArrayList(); |
|
389 |
if (lista_descripciones!= null){ |
|
390 |
Iterator it = lista_descripciones.iterator(); |
|
391 |
while (it.hasNext()){ |
|
392 |
AxisDescription ad = ((AxisDescription) it.next()); |
|
393 |
WCSParameterModel p = new WCSParameterModel(); |
|
394 |
p.setName(ad.getName()); |
|
395 |
p.setType(ad.getValuesType()); |
|
396 |
if (p.getType().equals("singleValue")){ |
|
397 |
p.setLista_valores_simples(ad.getSingleValues()); |
|
398 |
} |
|
399 |
lista_parametros.add(p); |
|
400 |
if (p.getType().equals("interval")){ |
|
401 |
Interval interv = ad.getInterval(); |
|
402 |
p.setMin(interv.getMin()); |
|
403 |
p.setMax(interv.getMax()); |
|
404 |
p.setRes(interv.getRes()); |
|
405 |
} |
|
406 |
} |
|
407 |
} |
|
408 |
return lista_parametros; |
|
254 |
// TODO |
|
255 |
return null; |
|
409 | 256 |
} |
410 | 257 |
|
411 | 258 |
/** |
... | ... | |
415 | 262 |
* @param nombre de la cobertura (string) |
416 | 263 |
* @return double |
417 | 264 |
*/ |
418 |
/*public double getMaxResolution(String coverageName) { |
|
419 |
CoverageOffering co = getCoverageDetails(coverageName); |
|
420 |
return co.getDomainSet().getSpatialDomain().getMaxRes(); |
|
421 |
}*/ |
|
422 | 265 |
public Point2D getMaxResolution(String coverageName) { |
423 |
CoverageOffering co = getCoverageDetails(coverageName);
|
|
424 |
return co.getDomainSet().getSpatialDomain().getMaxRes();
|
|
266 |
// TODO
|
|
267 |
return null;
|
|
425 | 268 |
} |
426 | 269 |
|
427 | 270 |
|
... | ... | |
433 | 276 |
* @return ArrayList |
434 | 277 |
*/ |
435 | 278 |
public ArrayList getSRSs(String coverageName) { |
436 |
// TODO Si el servidor da algun CRS en RequestResponse se usar? esta respuesta |
|
437 |
// en caso contrario, se usar?n el de la cobertura en SpatialDomain. |
|
438 |
// Esto est? por revisar, ya que deber?a tener inteligencia para |
|
439 |
// transformar entre sistemas de proyecciones diferentes |
|
440 |
|
|
441 |
CoverageOffering co = getCoverageDetails(coverageName); |
|
442 |
return co.getDomainSet().getSpatialDomain().getGMLEnvelopeNames(); |
|
279 |
// TODO |
|
280 |
return null; |
|
443 | 281 |
} |
444 | 282 |
|
445 | 283 |
/** |
... | ... | |
450 | 288 |
* @return string |
451 | 289 |
*/ |
452 | 290 |
public String getCoverageDescription(String coverageName) { |
453 |
CoverageOffering co = getCoverageDetails(coverageName);
|
|
454 |
return co.getCoverageOfferingBrief().getDescription();
|
|
291 |
// TODO
|
|
292 |
return null;
|
|
455 | 293 |
} |
456 | 294 |
|
457 | 295 |
/** |
... | ... | |
463 | 301 |
* @return ArrayList |
464 | 302 |
*/ |
465 | 303 |
public ArrayList getTimes(String coverageName) { |
466 |
CoverageOffering co = getCoverageDetails(coverageName); |
|
467 |
if (co.getDomainSet().getTemporalDomain()!=null){ |
|
468 |
return co.getDomainSet().getTemporalDomain().getGMLTimePositionList(); |
|
469 |
} |
|
304 |
// TODO |
|
470 | 305 |
return null; |
306 |
|
|
307 |
} |
|
308 |
|
|
309 |
public void getCapabilities(WCSStatus status) throws WCSException { |
|
310 |
// TODO Auto-generated method stub |
|
311 |
|
|
312 |
} |
|
313 |
|
|
314 |
public void describeCoverage(WCSStatus status) throws WCSException { |
|
315 |
// TODO Auto-generated method stub |
|
316 |
|
|
317 |
} |
|
318 |
|
|
319 |
public File getCoverage(WCSStatus status) throws WCSException { |
|
320 |
// TODO Auto-generated method stub |
|
321 |
return null; |
|
322 |
} |
|
323 |
|
|
324 |
/** |
|
325 |
* Creates a new instance of a WCSClient. |
|
326 |
* @param host |
|
327 |
* @throws IOException |
|
328 |
* @throws ConnectException |
|
329 |
*/ |
|
330 |
public void createClient(URL host) throws ConnectException, IOException{ |
|
331 |
client = new WCSClient(host.toString()); |
|
471 | 332 |
} |
472 | 333 |
} |
trunk/extensions/extWCS/src/com/iver/cit/gvsig/fmap/drivers/RemoteServiceDriver.java | ||
---|---|---|
113 | 113 |
* Sets the host name. |
114 | 114 |
* |
115 | 115 |
* Establece el nombre del host. |
116 |
* @throws IOException |
|
116 | 117 |
*/ |
117 |
public void setHost(String hostName) { |
|
118 |
public void setHost(String hostName) throws IOException {
|
|
118 | 119 |
this.hostName = hostName; |
119 | 120 |
} |
120 | 121 |
|
trunk/extensions/extWCS/src/com/iver/cit/gvsig/fmap/layers/FMapWCSAdapter.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.fmap.layers; |
|
42 |
|
|
43 |
import java.awt.Dimension; |
|
44 |
import java.awt.Graphics2D; |
|
45 |
import java.awt.Image; |
|
46 |
import java.awt.geom.Point2D; |
|
47 |
import java.awt.geom.Rectangle2D; |
|
48 |
import java.awt.image.BufferedImage; |
|
49 |
import java.awt.image.DataBuffer; |
|
50 |
import java.io.File; |
|
51 |
import java.io.IOException; |
|
52 |
import java.util.ArrayList; |
|
53 |
|
|
54 |
import org.cresques.geo.ViewPortData; |
|
55 |
import org.cresques.io.GdalFile; |
|
56 |
import org.cresques.io.GeoRasterFile; |
|
57 |
import org.cresques.io.raster.RasterFilterStack; |
|
58 |
import org.cresques.io.raster.RasterFilterStackManager; |
|
59 |
import org.cresques.io.rasterOld.ComputeMinMaxFilter; |
|
60 |
import org.cresques.io.rasterOld.GreyscaleRasterToImageFilter; |
|
61 |
import org.cresques.io.rasterOld.LinearEnhancementFilter; |
|
62 |
import org.cresques.io.rasterOld.RasterBuf; |
|
63 |
import org.cresques.io.rasterOld.RasterStats; |
|
64 |
import org.cresques.io.rasterOld.RasterToImageFilter; |
|
65 |
import org.cresques.px.Extent; |
|
66 |
import org.cresques.px.PxRaster; |
|
67 |
|
|
68 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
69 |
import com.iver.cit.gvsig.fmap.ViewPort; |
|
70 |
import com.iver.cit.gvsig.fmap.drivers.wcs.FMapWCSDriver; |
|
71 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
|
72 |
|
|
73 |
import es.gva.cit.jgdal.Gdal; |
|
74 |
import es.gva.cit.jgdal.GdalBuffer; |
|
75 |
import es.gva.cit.jgdal.GdalException; |
|
76 |
import es.gva.cit.jgdal.GdalRasterBand; |
|
77 |
import es.gva.cit.jgdal.GeoTransform; |
|
78 |
import es.uji.lsi.wcs.client.ServerErrorResponseException; |
|
79 |
|
|
80 |
/** |
|
81 |
* Class to interact FMapWCSDriver |
|
82 |
* |
|
83 |
* La clase FMapWCSAdapter recubre la interacci?n con el FMapWCSDriver |
|
84 |
* @author jaume - jaume.dominguez@iver.es |
|
85 |
* |
|
86 |
*/ |
|
87 |
public class FMapWCSAdapter { |
|
88 |
private boolean driverInitialized = false; |
|
89 |
private FMapWCSDriver driver; |
|
90 |
private Rectangle2D fullExtent, bbox; |
|
91 |
|
|
92 |
private static final double METROSXGRADO = 111120D; |
|
93 |
private String coverageName; |
|
94 |
private String SRS; |
|
95 |
private String format; |
|
96 |
private String time; |
|
97 |
private String parameter; |
|
98 |
//private double maxRes; |
|
99 |
private Point2D maxRes; |
|
100 |
private String coverageQuery; |
|
101 |
private String lastCoverageQuery = ""; |
|
102 |
private File fCoverage = null; |
|
103 |
private PxRaster raster = null; |
|
104 |
private RasterFilterStack filterStack = null; |
|
105 |
private GeoRasterFile rasterFile = null; |
|
106 |
//private double res; |
|
107 |
private Point2D res; |
|
108 |
private boolean zoomingToPixel; |
|
109 |
|
|
110 |
private int transparency = -1; |
|
111 |
private int rband = 0, gband = 1, bband = 2; |
|
112 |
private RasterFilterStackManager stackManager = null; |
|
113 |
public boolean firstLoad = false; |
|
114 |
|
|
115 |
/** |
|
116 |
* Returns the coverage resolution |
|
117 |
* |
|
118 |
* obtiene la resoluci?n de la cobertura (de la capa FlyrWCS) |
|
119 |
* @return |
|
120 |
*/ |
|
121 |
//public double getRes() { |
|
122 |
public Point2D getRes() { |
|
123 |
return res; |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* Sets the coverage resolution (the layer's resolution) |
|
128 |
* |
|
129 |
* Establece la resoluci?n de la cobertura (de la capa FlyrWCS) |
|
130 |
* @param res |
|
131 |
*/ |
|
132 |
//public void setRes(double res) { |
|
133 |
public void setRes(Point2D res) { |
|
134 |
this.res = res; |
|
135 |
} |
|
136 |
|
|
137 |
/** |
|
138 |
* Sets the driver that works with the adaptor. |
|
139 |
* |
|
140 |
* Establece el driver sobre el que act?a el adaptador |
|
141 |
*/ |
|
142 |
public void setDriver(FMapWCSDriver d) { |
|
143 |
driver = d; |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* Gets a ref to the object that implements the vectorial interface in order |
|
148 |
* of the Strategy can optimize the driver's function. |
|
149 |
* |
|
150 |
* Obtiene una referencia al objeto que implementa la interfaz vectorial con |
|
151 |
* el fin de que las Strategy puedan optimizar en funci?n del driver. |
|
152 |
*/ |
|
153 |
public FMapWCSDriver getDriver(){ |
|
154 |
return driver; |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* Automatically called by gvSIG |
|
159 |
* |
|
160 |
* Llamado autom?ticamente por gvSIG. |
|
161 |
* Pinta la cobertura (r?ster) en el ViewPort. |
|
162 |
* |
|
163 |
* @param image, g, viewPort, cancel |
|
164 |
* @throws ServerErrorResponseException |
|
165 |
* @throws ServerErrorResponseException |
|
166 |
* @throws IOException |
|
167 |
*/ |
|
168 |
public void draw(BufferedImage image, Graphics2D g, |
|
169 |
ViewPort viewPort, Cancellable cancel) throws DriverException, ServerErrorResponseException, IOException { |
|
170 |
if (viewPort.getExtent().getMinX() > fullExtent.getMaxX()) |
|
171 |
return; |
|
172 |
if (viewPort.getExtent().getMinY() > fullExtent.getMaxY()) |
|
173 |
return; |
|
174 |
if (viewPort.getExtent().getMaxX() < fullExtent.getMinX()) |
|
175 |
return; |
|
176 |
if (viewPort.getExtent().getMaxY() < fullExtent.getMinY()) |
|
177 |
return; |
|
178 |
setBBox(viewPort.getAdjustedExtent()); |
|
179 |
|
|
180 |
double x = bbox.getMinX(); |
|
181 |
double y = bbox.getMinY(); |
|
182 |
double w = bbox.getWidth(); |
|
183 |
double h = bbox.getHeight(); |
|
184 |
|
|
185 |
double scalex = viewPort.getAffineTransform().getScaleX() /* g.getTransform().getScaleX()*/ , |
|
186 |
scaley = viewPort.getAffineTransform().getScaleY() /* g.getTransform().getScaleY() */; |
|
187 |
int wImg = (int) Math.abs(w*scalex)+1, hImg = (int) Math.abs(h*scaley)+1; |
|
188 |
if (wImg <= 0 || hImg <= 0) return; |
|
189 |
|
|
190 |
setCoverageQuery(bbox, new Dimension(wImg, hImg)); |
|
191 |
|
|
192 |
if (lastCoverageQuery.compareTo(coverageQuery) != 0) { |
|
193 |
setWCSClientCoverageQuery(coverageQuery); |
|
194 |
fCoverage = driver.getCoverage(); |
|
195 |
} |
|
196 |
|
|
197 |
if (fCoverage != null) { |
|
198 |
//drawJaume(g, viewPort, fCoverage); |
|
199 |
drawLWS(g, viewPort, fCoverage); |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* Draws using PxRaster |
|
205 |
* |
|
206 |
* Pinta usando PxRaster |
|
207 |
*/ |
|
208 |
private void drawLWS(Graphics2D g, ViewPort viewPort, File fCoverage) { |
|
209 |
|
|
210 |
//Creamos el PxRaster |
|
211 |
|
|
212 |
rasterFile = new GdalFile(viewPort.getProjection(), fCoverage.getAbsolutePath()); |
|
213 |
Extent e = new Extent(bbox); |
|
214 |
raster = new PxRaster(rasterFile, null, rasterFile.getExtent()); |
|
215 |
|
|
216 |
//Recuperamos la pila de filtros si ya hubiese sido cargado antes |
|
217 |
|
|
218 |
if(this.filterStack!=null) |
|
219 |
raster.filterStack = this.filterStack; |
|
220 |
|
|
221 |
raster.setTransparency(false); |
|
222 |
|
|
223 |
//Creamos el viewportdata |
|
224 |
|
|
225 |
ViewPortData vpData = new ViewPortData(viewPort.getProjection(), e, viewPort.getImageSize() ); |
|
226 |
vpData.setMat(viewPort.getAffineTransform()); |
|
227 |
|
|
228 |
//Asignamos transparencia y orden de bandas |
|
229 |
if(this.transparency==-1 && !this.firstLoad); |
|
230 |
else |
|
231 |
raster.setTransparency(this.transparency); |
|
232 |
|
|
233 |
raster.setBand(GeoRasterFile.RED_BAND,rband); |
|
234 |
raster.setBand(GeoRasterFile.GREEN_BAND, gband); |
|
235 |
raster.setBand(GeoRasterFile.BLUE_BAND, bband); |
|
236 |
|
|
237 |
//Despues del primer pxRaster asignamos el stackManager guardado para los siguientes. |
|
238 |
//Con esto conseguimos asignar los cambios que se hayan producido desde el cuadro de |
|
239 |
//propiedades cuando creamos un nuevo pxRaster |
|
240 |
|
|
241 |
if(this.stackManager != null) |
|
242 |
raster.setStackManager(this.stackManager); |
|
243 |
|
|
244 |
raster.draw(g, vpData); |
|
245 |
|
|
246 |
//En el primer pxRaster de una imagen obtenemos el Stack Manager para poder modificarlo |
|
247 |
//si queremos desde las propiedades |
|
248 |
|
|
249 |
if(this.stackManager == null) |
|
250 |
this.stackManager = raster.getStackManager(); |
|
251 |
|
|
252 |
|
|
253 |
if(this.filterStack == null) |
|
254 |
this.filterStack = raster.filterStack; |
|
255 |
|
|
256 |
rasterFile.close(); |
|
257 |
} |
|
258 |
|
|
259 |
/** |
|
260 |
* Gets the filter stack |
|
261 |
* |
|
262 |
* Obtiene la pila de filtros |
|
263 |
* @return |
|
264 |
*/ |
|
265 |
public RasterFilterStack getFilterStack(){ |
|
266 |
if(raster!=null) |
|
267 |
return raster.filterStack; |
|
268 |
return null; |
|
269 |
} |
|
270 |
|
|
271 |
/** |
|
272 |
* Obtiene la lista de atributos de raster |
|
273 |
* @return lista de atributos. Cada elmento de la lista es un array Object |
|
274 |
* con dos elementos. El primero el nombre del atributo y el segundo el valor |
|
275 |
* del mismo. |
|
276 |
*/ |
|
277 |
public ArrayList getAttributes() { |
|
278 |
if(rasterFile != null){ |
|
279 |
ArrayList attr = new ArrayList(); |
|
280 |
String dataType = "Byte"; |
|
281 |
if (rasterFile.getDataType() == DataBuffer.TYPE_BYTE) dataType = "Byte"; |
|
282 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_SHORT) |
|
283 |
dataType = "Short"; |
|
284 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_USHORT) |
|
285 |
dataType = "Unsigned Short"; |
|
286 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_INT) |
|
287 |
dataType = "Integer"; |
|
288 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_FLOAT) |
|
289 |
dataType = "Float"; |
|
290 |
else if (rasterFile.getDataType() == DataBuffer.TYPE_DOUBLE) |
|
291 |
dataType = "Double"; |
|
292 |
else |
|
293 |
dataType = "Unknown"; |
|
294 |
Object [][] a = { |
|
295 |
{"Filename",rasterFile.getName().substring(rasterFile.getName().lastIndexOf("/")+1, rasterFile.getName().length())}, |
|
296 |
{"Filesize",new Long(rasterFile.getFileSize())}, |
|
297 |
{"Width",new Integer(rasterFile.getWidth())}, |
|
298 |
{"Height", new Integer(rasterFile.getHeight())}, |
|
299 |
{"Bands", new Integer(rasterFile.getBandCount())} |
|
300 |
//{"BandDataType", dataType} |
|
301 |
}; |
|
302 |
for (int i=0; i<a.length; i++){ |
|
303 |
System.out.println("===> "+a[i][0]+" "+a[i][1]); |
|
304 |
attr.add(a[i]); |
|
305 |
} |
|
306 |
return attr; |
|
307 |
} |
|
308 |
return null; |
|
309 |
} |
|
310 |
|
|
311 |
/** |
|
312 |
* Sets the filter stack |
|
313 |
* |
|
314 |
* Establece la pila de filtros |
|
315 |
* |
|
316 |
* @param filterStack pila |
|
317 |
*/ |
|
318 |
public void setFilterStack(RasterFilterStack filterStack){ |
|
319 |
this.filterStack = filterStack; |
|
320 |
} |
|
321 |
|
|
322 |
/** |
|
323 |
* Gets the last created PxRaster |
|
324 |
* |
|
325 |
* Obtiene el ?ltimo PxRaster creado |
|
326 |
* |
|
327 |
* @return |
|
328 |
*/ |
|
329 |
public PxRaster getPxRaster(){ |
|
330 |
return raster; |
|
331 |
} |
|
332 |
|
|
333 |
/** |
|
334 |
* Gets the last open GeoRasterFile against the temp file received |
|
335 |
* |
|
336 |
* Obtiene el ?ltimo GeoRasterFile abierto sobre el temporal recibido |
|
337 |
* @return |
|
338 |
*/ |
|
339 |
public GeoRasterFile getGeoRasterFile(){ |
|
340 |
return rasterFile; |
|
341 |
} |
|
342 |
|
|
343 |
/** |
|
344 |
* Sets the Bouning Box of the query according to the zoom. If the zoom's extension |
|
345 |
* is greather than the coverage's full extent or the view only covers a part of |
|
346 |
* the coverage's area, it cuts the required edges to those given by the coverage's |
|
347 |
* full extent. |
|
348 |
* |
|
349 |
* Establece la Bounding Box de la consulta seg?n el zoom. En caso de que |
|
350 |
* el zoom abarque m?s de la estensi?n m?xima (fullExtent) o la vista cubra |
|
351 |
* solo una parte de la cobertura, acota los l?mites necesarios a aquellos |
|
352 |
* marcados por la extensi?n m?xima. |
|
353 |
* |
|
354 |
* @param rect |
|
355 |
*/ |
|
356 |
public void setBBox(Rectangle2D rect) { |
|
357 |
double x1 = rect.getMinX(); |
|
358 |
double y1 = rect.getMinY(); |
|
359 |
double x2 = rect.getMaxX(); |
|
360 |
double y2 = rect.getMaxY(); |
|
361 |
if (x1 < fullExtent.getMinX()) |
|
362 |
x1 = fullExtent.getMinX(); |
|
363 |
if (y1 < fullExtent.getMinY()) |
|
364 |
y1 = fullExtent.getMinY(); |
|
365 |
if (x2 > fullExtent.getMaxX()) |
|
366 |
x2 = fullExtent.getMaxX(); |
|
367 |
if (y2 > fullExtent.getMaxY()) |
|
368 |
y2 = fullExtent.getMaxY(); |
|
369 |
|
|
370 |
if (bbox == null) |
|
371 |
bbox = new Rectangle2D.Double(); |
|
372 |
|
|
373 |
bbox.setRect(x1, y1, x2 - x1, y2 - y1); |
|
374 |
} |
|
375 |
|
|
376 |
/** |
|
377 |
* Establishes the initial values that will be included in the query. |
|
378 |
* |
|
379 |
* Para establecer los valores iniciales que se incluiran en la consulta. |
|
380 |
* |
|
381 |
* @param layersRectangle |
|
382 |
* @param srs |
|
383 |
* @param format |
|
384 |
* @param parametro |
|
385 |
* @param times |
|
386 |
*/ |
|
387 |
public void setCoverageQuery(Rectangle2D bBox, Dimension sz) { |
|
388 |
String coverage = "COVERAGE=" + coverageName; |
|
389 |
String crs = "&CRS=" + SRS; |
|
390 |
String boundingBox = "&BBOX=" + bBox.getMinX() |
|
391 |
+ "," + bBox.getMinY() |
|
392 |
+ "," + bBox.getMaxX() |
|
393 |
+ "," + bBox.getMaxY(); |
|
394 |
String time = this.time != null ? "&" + this.time : ""; |
|
395 |
String param = parameter != null ? "&" + parameter : ""; |
|
396 |
res = new Point2D.Double(bBox.getWidth() / sz.getWidth(), bBox.getHeight() / sz.getHeight()); |
|
397 |
|
|
398 |
// TODO LWS 01 oct 05 esto no funciona. Hay que hacer un c?lculo correcto |
|
399 |
// y reevaluar porqu? hizo falta. |
|
400 |
// mientras tanto RESX y RESY ya no se usan |
|
401 |
// Calculo cutre para ver si son grados (o metros). Si da menos de 180 |
|
402 |
// es que son grados y lo paso a metros. (LWS) |
|
403 |
if (bBox.getMaxY() < 181D) |
|
404 |
res.setLocation(res.getX()*METROSXGRADO, res.getY()*METROSXGRADO); |
|
405 |
|
|
406 |
String resX = "&RESX=" + res.getX(); |
|
407 |
String resY = "&RESY=" + res.getY(); |
|
408 |
String format = "&FORMAT=" + this.format; |
|
409 |
|
|
410 |
coverageQuery = coverage + crs + boundingBox + time + param + format; |
|
411 |
coverageQuery += "&WIDTH="+sz.width+"&HEIGHT="+sz.height; |
|
412 |
System.out.println("coverageQuery="+coverageQuery); |
|
413 |
// coverageQuery += resX + resY; |
|
414 |
} |
|
415 |
|
|
416 |
/** |
|
417 |
* Takes the coverage parameters and give them to the WCS client. After this, |
|
418 |
* it is possible to launch a GetCoverage operation. |
|
419 |
* |
|
420 |
* Recoge los par?metros de la capa y los pasa al cliente WCS. Despu?s de |
|
421 |
* esto, ya se puede lanzar una GetCoverage |
|
422 |
* |
|
423 |
*/ |
|
424 |
private void setWCSClientCoverageQuery(String query) { |
|
425 |
lastCoverageQuery = query; |
|
426 |
((FMapWCSDriver) driver).setGetCoverageParams(query); |
|
427 |
} |
|
428 |
|
|
429 |
/** |
|
430 |
* Returns the coverage name. |
|
431 |
* |
|
432 |
* Devuelve el nombre de la cobertura |
|
433 |
* @return |
|
434 |
*/ |
|
435 |
public String getCoverageName() { |
|
436 |
return coverageName; |
|
437 |
} |
|
438 |
|
|
439 |
/** |
|
440 |
* Sets the coverage name. |
|
441 |
* |
|
442 |
* Establece el nombre de la cobertura |
|
443 |
* @param coverageName |
|
444 |
*/ |
|
445 |
public void setCoverageName(String coverageName) { |
|
446 |
this.coverageName = coverageName; |
|
447 |
} |
|
448 |
|
|
449 |
/** |
|
450 |
* Returns an string containing the query that originated the coverage. |
|
451 |
* |
|
452 |
* Obtiene una cadena que contiene la consulta que origin? la cobertura. |
|
453 |
* @return String |
|
454 |
*/ |
|
455 |
public String getCoverageQuery() { |
|
456 |
return coverageQuery; |
|
457 |
} |
|
458 |
|
|
459 |
/** |
|
460 |
* Sets the query string (an URL) that originates the coverage. |
|
461 |
* |
|
462 |
* Establece la cadena que contiene la consulta (URL) que origina la cobertura. |
|
463 |
* @param coverageQuery |
|
464 |
*/ |
|
465 |
public void setCoverageQuery(String coverageQuery) { |
|
466 |
this.coverageQuery = coverageQuery; |
|
467 |
} |
|
468 |
|
|
469 |
/** |
|
470 |
* The coverage format. |
|
471 |
* |
|
472 |
* El formato de la cobertura. |
|
473 |
* @return String |
|
474 |
*/ |
|
475 |
public String getFormat() { |
|
476 |
return format; |
|
477 |
} |
|
478 |
|
|
479 |
/** |
|
480 |
* Sets the coverage format to download. |
|
481 |
* |
|
482 |
* Establece el formato de la cobertura a descargar. |
|
483 |
* @param format |
|
484 |
*/ |
|
485 |
public void setFormat(String format) { |
|
486 |
this.format = format; |
|
487 |
} |
|
488 |
|
|
489 |
/** |
|
490 |
* Gets the max coverage extension. |
|
491 |
* |
|
492 |
* Obtiene la extensi?n m?xima de la cobertura |
|
493 |
* @return |
|
494 |
* @throws DriverException |
|
495 |
* @throws IOException |
|
496 |
*/ |
|
497 |
public Rectangle2D getFullExtent() throws IOException, DriverException { |
|
498 |
if (fullExtent==null) |
|
499 |
fullExtent = driver.getFullExtent(coverageName, SRS); |
|
500 |
return fullExtent; |
|
501 |
} |
|
502 |
|
|
503 |
/** |
|
504 |
* Sets the max extension for the coverage. This value is specified |
|
505 |
* by the server. Thus, this method should be used ONLY to reload |
|
506 |
* this value from a saved proyect. |
|
507 |
* |
|
508 |
* Establece la extensi?n m?xima de la cobertura. ?ste valor viene |
|
509 |
* especificado por el servidor. No deber?a de usarse m?s que para |
|
510 |
* recuperar un proyecto guardado o desde el Wizard. |
|
511 |
* |
|
512 |
* @param fullExtent |
|
513 |
*/ |
|
514 |
public void setFullExtent(Rectangle2D fullExtent) { |
|
515 |
this.fullExtent = fullExtent; |
|
516 |
} |
|
517 |
|
|
518 |
/** |
|
519 |
* Gets the paramenter in name-value pair-formed string. |
|
520 |
* |
|
521 |
* Recupera el valor de par?metro en forma de par nombre-valor: "nombre=valor" |
|
522 |
* |
|
523 |
* @return String |
|
524 |
*/ |
|
525 |
public String getParameter() { |
|
526 |
return parameter; |
|
527 |
} |
|
528 |
|
|
529 |
/** |
|
530 |
* Sets the parameter and the parameter value list of the coverage as a name-value |
|
531 |
* pair form where, for the moment, value is a comma-separated values list. |
|
532 |
* |
|
533 |
* Establece el par?metro y la lista de valores de la cobertura en forma |
|
534 |
* de par nombre-valor donde valor es, por el momento, una lista separada |
|
535 |
* por comas |
|
536 |
* @param parameter |
|
537 |
*/ |
|
538 |
public void setParameter(String parameter) { |
|
539 |
this.parameter = parameter; |
|
540 |
} |
|
541 |
|
|
542 |
/** |
|
543 |
* Gets the coverage SRS |
|
544 |
* |
|
545 |
* Obtiene el SRS de la cobertura |
|
546 |
* @return String |
|
547 |
*/ |
|
548 |
public String getSRS() { |
|
549 |
return SRS; |
|
550 |
} |
|
551 |
|
|
552 |
/** |
|
553 |
* Sets the coverage SRS |
|
554 |
* |
|
555 |
* Establece el SRS |
|
556 |
* @param srs |
|
557 |
*/ |
|
558 |
public void setSRS(String srs) { |
|
559 |
SRS = srs; |
|
560 |
} |
|
561 |
|
|
562 |
/** |
|
563 |
* Gets the TIME parameter. |
|
564 |
* |
|
565 |
* Obtiene el par?metro TIME. |
|
566 |
* |
|
567 |
* @return String |
|
568 |
*/ |
|
569 |
public String getTime() { |
|
570 |
return time; |
|
571 |
} |
|
572 |
|
|
573 |
/** |
|
574 |
* Sets the TIME parameter (according with the OGC standard it may |
|
575 |
* be a comma-separated value list, but probably the server will not |
|
576 |
* support querys with more than one value) |
|
577 |
* |
|
578 |
* Establece el par?metro TIME (puede ser seg?n OGC una |
|
579 |
* lista de valores separados por comas pero casi seguro que |
|
580 |
* el servidor no soportar? m?s de un valor) |
|
581 |
* @param time |
|
582 |
*/ |
|
583 |
public void setTime(String time) { |
|
584 |
this.time = time; |
|
585 |
} |
|
586 |
|
|
587 |
/** |
|
588 |
* Gets the WCS server's address. |
|
589 |
* |
|
590 |
* Obtiene la direcci?n del servidor WCS |
|
591 |
* @return String |
|
592 |
*/ |
|
593 |
public String getHost() { |
|
594 |
return ((FMapWCSDriver) driver).getHost(); |
|
595 |
} |
|
596 |
|
|
597 |
/** |
|
598 |
* Sets the WCS server address. |
|
599 |
* |
|
600 |
* Establece la direcci?n del servidor WCS |
|
601 |
* @param host (String) |
|
602 |
*/ |
|
603 |
public void setHost(String host) { |
|
604 |
((FMapWCSDriver) driver).setHost(host); |
|
605 |
} |
|
606 |
|
|
607 |
/** |
|
608 |
* @deprecated |
|
609 |
* @param g |
|
610 |
* @param viewPort |
|
611 |
* @param fCoverage |
|
612 |
*/ |
|
613 |
private void drawJaume(Graphics2D g, ViewPort viewPort, File fCoverage) { |
|
614 |
Image coverage = renderizeRaster(getRaster(fCoverage)); |
|
615 |
Point2D p1 = new Point2D.Double(bbox.getMinX(), bbox.getMaxY()); |
|
616 |
viewPort.getAffineTransform().transform(p1, p1); |
|
617 |
g.drawImage(coverage, (int) p1.getX(), (int) p1.getY(), null); |
|
618 |
} |
|
619 |
|
|
620 |
/** |
|
621 |
* Computes the geofile raster. |
|
622 |
* |
|
623 |
* Computa el r?ster del fichero geogr?fico. |
|
624 |
* |
|
625 |
* @deprecated |
|
626 |
* @param coverage |
|
627 |
* @return RasterBuf |
|
628 |
*/ |
|
629 |
private RasterBuf getRaster(File coverage) { |
|
630 |
RasterBuf raster = null; |
|
631 |
|
|
632 |
Gdal migdal = new Gdal(); |
|
633 |
GeoTransform gt = null; |
|
634 |
int ancho = 0, alto = 0; |
|
635 |
GdalRasterBand mirasterband = null; |
|
636 |
int rastercount = 0; |
|
637 |
|
|
638 |
try { |
|
639 |
migdal.open(coverage.getAbsolutePath(), Gdal.GA_ReadOnly); |
|
640 |
} catch (Exception ge) { |
|
641 |
ge.printStackTrace(); |
|
642 |
} |
|
643 |
|
|
644 |
try { |
|
645 |
gt = migdal.getGeoTransform(); |
|
646 |
} catch (GdalException e) { |
|
647 |
System.out |
|
648 |
.println("I can't obtain the array geoTransform for this image"); |
|
649 |
} |
|
650 |
|
|
651 |
try { |
|
652 |
rastercount = migdal.getRasterCount(); |
|
653 |
ancho = migdal.getRasterXSize(); |
|
654 |
alto = migdal.getRasterYSize(); |
|
655 |
int ngcp = migdal.getGCPCount(); |
|
656 |
//System.out.println("NGCP="+ngcp); |
|
657 |
} catch (GdalException ge) { |
|
658 |
ge.printStackTrace(); |
|
659 |
//... |
|
660 |
} |
|
661 |
|
|
662 |
try { |
|
663 |
int dataType = migdal.getRasterBand(1).getRasterDataType(); |
|
664 |
GdalBuffer buf = null; |
|
665 |
|
|
666 |
/* |
|
667 |
* Evita el problema de que haya m?s de 3 bandas en el fichero esto |
|
668 |
* deberia hacerse asignando a las 3 bandas del raster una banda |
|
669 |
* distinta del fichero (no necesariamente 1->0, 2->1 y 3->2 |
|
670 |
*/ |
|
671 |
|
|
672 |
if (rastercount > 3) |
|
673 |
rastercount = 3; |
|
674 |
if (dataType == Gdal.GDT_Byte) { |
|
675 |
raster = new RasterBuf(RasterBuf.TYPE_INT, ancho, alto, |
|
676 |
rastercount, null); |
|
677 |
for (int iBand = 0; iBand < rastercount; iBand++) { |
|
678 |
mirasterband = migdal.getRasterBand(iBand + 1); |
|
679 |
buf = mirasterband.readRaster(0, 0, ancho, alto, ancho, |
|
680 |
alto, dataType); |
|
681 |
for (int y = 0; y < alto; y++) |
|
682 |
for (int x = 0; x < ancho; x++) |
|
683 |
raster.setPixelInt(x, y, iBand, buf.buffByte[y |
|
684 |
* ancho + x] & 0xff); |
|
685 |
} |
|
686 |
migdal.close(); |
|
687 |
} else if (dataType == Gdal.GDT_CInt16 |
|
688 |
|| dataType == Gdal.GDT_UInt16 |
|
689 |
|| dataType == Gdal.GDT_Int16) { |
|
690 |
raster = new RasterBuf(RasterBuf.TYPE_INT, ancho, alto, |
|
691 |
rastercount, null); |
|
692 |
for (int iBand = 0; iBand < rastercount; iBand++) { |
|
693 |
// System.out.println("Banda:"+iBand); |
|
694 |
mirasterband = migdal.getRasterBand(iBand + 1); |
|
695 |
buf = mirasterband.readRaster(0, 0, ancho, alto, ancho, |
|
696 |
alto, dataType); |
|
697 |
for (int y = 0; y < alto; y++) |
|
698 |
for (int x = 0; x < ancho; x++) |
|
699 |
raster.setPixelInt(x, y, iBand, buf.buffShort[y |
|
700 |
* ancho + x] & 0xffff); |
|
701 |
} |
|
702 |
migdal.close(); |
|
703 |
} |
|
704 |
} catch (GdalException e1) { |
|
705 |
e1.printStackTrace(); |
|
706 |
} |
|
707 |
return raster; |
|
708 |
} |
|
709 |
|
|
710 |
/** |
|
711 |
* Construye un objeto Image a partir de un RasterBuf |
|
712 |
* @deprecated (usado en drawJaume) |
|
713 |
* @param raster |
|
714 |
* @return Image |
|
715 |
*/ |
|
716 |
public Image renderizeRaster(RasterBuf raster) { |
|
717 |
RasterStats stats = new RasterStats(raster.getBandNr()); |
|
718 |
int alpha = 255; // transparencia |
|
719 |
boolean debug = false; |
|
720 |
ComputeMinMaxFilter filter = new ComputeMinMaxFilter(raster, stats); |
|
721 |
|
|
722 |
LinearEnhancementFilter lEFilter = new LinearEnhancementFilter(raster, |
|
723 |
stats); |
|
724 |
Image image = null; |
|
725 |
if (raster.getBandNr() == 1) |
|
726 |
image = new GreyscaleRasterToImageFilter(raster, alpha).getImage(); |
|
727 |
else |
|
728 |
image = new RasterToImageFilter(raster, alpha).getImage(); |
|
729 |
|
|
730 |
if (debug) |
|
731 |
stats.pinta(); |
|
732 |
return image; |
|
733 |
} |
|
734 |
|
|
735 |
/** |
|
736 |
* Returns the current bounding box. |
|
737 |
* |
|
738 |
* Devuelve la boundix box actual. |
|
739 |
* |
|
740 |
* @return Rectangle2D |
|
741 |
*/ |
|
742 |
public Rectangle2D getBbox() { |
|
743 |
return bbox; |
|
744 |
} |
|
745 |
/** |
|
746 |
* Gets the max resolution of the coverage. |
|
747 |
* |
|
748 |
* Obtiene la resoluci?n m?xima de la cobertura |
|
749 |
* @return maxRes |
|
750 |
*/ |
|
751 |
//public double getMaxResolution() { |
|
752 |
public Point2D getMaxResolution() { |
|
753 |
return maxRes; |
|
754 |
} |
|
755 |
|
|
756 |
/** |
|
757 |
* Sets the MAX resolution supported by the coverage. |
|
758 |
* |
|
759 |
* The max resolution is given by the server within the DescribeCoverage document |
|
760 |
* in the SpationDomain section. |
|
761 |
* |
|
762 |
* Use this method only to load this value from there (the DescribeCoverage document) |
|
763 |
* of from an already saved project because an incorrect value will bring |
|
764 |
* computing errors when doing "zoom to raster resolution". |
|
765 |
* |
|
766 |
* |
|
767 |
* |
|
768 |
* Establece la resoluci?n M?XIMA que soporta la cobertura. |
|
769 |
* |
|
770 |
* La resoluci?n m?xima viene fijada por el servidor dentro documento |
|
771 |
* DescribeCoverage en la secci?n SpatialDomain. |
|
772 |
* |
|
773 |
* Use este m?todo ?nicamente para cargar el valor para la resoluci?n m?xima |
|
774 |
* desde all? o desde un proyecto guardado en anterioridad, puesto que un |
|
775 |
* valor incorrecto reportar? (conllevar?) errores de c?lculo cuando se haga |
|
776 |
* un "zoom a la resoluci?n del r?ster". |
|
777 |
* |
|
778 |
* @param res |
|
779 |
*/ |
|
780 |
//public void setMaxResolution(double res) { |
|
781 |
public void setMaxResolution(Point2D res) { |
|
782 |
maxRes = res; |
|
783 |
} |
|
784 |
/** |
|
785 |
* Sets the transparency for the next PxRaster that is going to be loaded. |
|
786 |
* |
|
787 |
* Asigna la transparencia para el siguiente PxRaster que se cargue. |
|
788 |
* @param t |
|
789 |
*/ |
|
790 |
public void setTransparency(int t){ |
|
791 |
this.transparency = t; |
|
792 |
} |
|
793 |
|
|
794 |
/** |
|
795 |
* Sets the R-band. |
|
796 |
* |
|
797 |
* Asigna la banda R. |
|
798 |
* @param r |
|
799 |
*/ |
|
800 |
public void setBandR(int r){ |
|
801 |
this.rband = r; |
|
802 |
} |
|
803 |
|
|
804 |
/** |
|
805 |
* Sets the G-band. |
|
806 |
* |
Also available in: Unified diff