Revision 40280
tags/libraries/org.gvsig.remoteclient/2.0_old/src/org/gvsig/remoteclient/wcs/CoverageOfferingBrief.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 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.1 2006-09-04 16:12:17 jaume |
|
47 |
* *** empty log message *** |
|
48 |
* |
|
49 |
* |
|
50 |
*/ |
|
51 |
package org.gvsig.remoteclient.wcs; |
|
52 |
|
|
53 |
import java.io.IOException; |
|
54 |
|
|
55 |
import org.kxml2.io.KXmlParser; |
|
56 |
import org.xmlpull.v1.XmlPullParserException; |
|
57 |
|
|
58 |
import org.gvsig.compat.CompatLocator; |
|
59 |
import org.gvsig.compat.lang.StringUtils; |
|
60 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
|
61 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
62 |
import org.gvsig.remoteclient.utils.DescribeCoverageTags; |
|
63 |
|
|
64 |
public class CoverageOfferingBrief { |
|
65 |
private String name; |
|
66 |
private String label; |
|
67 |
private BoundaryBox lonLatBbox; |
|
68 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
69 |
|
|
70 |
public String getLabel() { |
|
71 |
return label; |
|
72 |
} |
|
73 |
public void setLabel(String label) { |
|
74 |
this.label = label; |
|
75 |
} |
|
76 |
public BoundaryBox getLonLatBbox() { |
|
77 |
return lonLatBbox; |
|
78 |
} |
|
79 |
public void setLonLatBbox(BoundaryBox lonLatBbox) { |
|
80 |
this.lonLatBbox = lonLatBbox; |
|
81 |
} |
|
82 |
public String getName() { |
|
83 |
return name; |
|
84 |
} |
|
85 |
|
|
86 |
public void setName(String name) { |
|
87 |
this.name = name; |
|
88 |
} |
|
89 |
|
|
90 |
public void parse(KXmlParser parser) throws XmlPullParserException, IOException { |
|
91 |
int currentTag; |
|
92 |
boolean end = false; |
|
93 |
|
|
94 |
parser.require(KXmlParser.START_TAG, null, "wcs:"+CapabilitiesTags.WCS_COVERAGEOFFERINGBRIEF); |
|
95 |
currentTag = parser.next(); |
|
96 |
|
|
97 |
while (!end) |
|
98 |
{ |
|
99 |
switch(currentTag) |
|
100 |
{ |
|
101 |
case KXmlParser.START_TAG: |
|
102 |
|
|
103 |
if (parser.getName().toLowerCase().compareTo(CapabilitiesTags.NAME.toLowerCase())==0) { |
|
104 |
this.name = parser.nextText(); |
|
105 |
} else if (parser.getName().compareTo(CapabilitiesTags.WCS_LABEL)==0) { |
|
106 |
this.label = parser.nextText(); |
|
107 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LONLAT_ENVELOPE)==0) { |
|
108 |
parser.nextTag(); |
|
109 |
this.lonLatBbox = new BoundaryBox(); |
|
110 |
this.lonLatBbox.setSrs(DescribeCoverageTags.WGS84); |
|
111 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS); |
|
112 |
String[][] coord = new String[2][2]; |
|
113 |
coord[0] = stringUtils.split(parser.nextText(), WCSCoverage.SEPARATOR); |
|
114 |
parser.nextTag(); |
|
115 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS); |
|
116 |
coord[1] = stringUtils.split(parser.nextText(), WCSCoverage.SEPARATOR); |
|
117 |
this.lonLatBbox.setXmin(Double.parseDouble(coord[0][0])); |
|
118 |
this.lonLatBbox.setYmin(Double.parseDouble(coord[0][1])); |
|
119 |
this.lonLatBbox.setXmax(Double.parseDouble(coord[1][0])); |
|
120 |
this.lonLatBbox.setYmax(Double.parseDouble(coord[1][1])); |
|
121 |
} |
|
122 |
|
|
123 |
case KXmlParser.END_TAG: |
|
124 |
if (parser.getName().compareTo("wcs:"+CapabilitiesTags.WCS_COVERAGEOFFERINGBRIEF) == 0) |
|
125 |
end = true; |
|
126 |
break; |
|
127 |
case KXmlParser.TEXT: |
|
128 |
break; |
|
129 |
} |
|
130 |
currentTag = parser.next(); |
|
131 |
} |
|
132 |
|
|
133 |
} |
|
134 |
} |
|
0 | 135 |
tags/libraries/org.gvsig.remoteclient/2.0_old/src/org/gvsig/remoteclient/wcs/WCSServiceInformation.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.remoteclient.wcs; |
|
29 |
|
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.Vector; |
|
32 |
|
|
33 |
import org.gvsig.remoteclient.ogc.OGCClientOperation; |
|
34 |
import org.gvsig.remoteclient.ogc.OGCServiceInformation; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
38 |
*/ |
|
39 |
public class WCSServiceInformation extends OGCServiceInformation { |
|
40 |
public String online_resource = null; |
|
41 |
public String version; |
|
42 |
public String name; |
|
43 |
public String scope; |
|
44 |
public String title; |
|
45 |
public String abstr; |
|
46 |
public String keywords; |
|
47 |
public String fees; |
|
48 |
public String operationsInfo; |
|
49 |
public String personname; |
|
50 |
public String organization; |
|
51 |
public String function; |
|
52 |
public String addresstype; |
|
53 |
public String address; |
|
54 |
public String place; |
|
55 |
public String province; |
|
56 |
public String postcode; |
|
57 |
public String country; |
|
58 |
public String phone; |
|
59 |
public String fax; |
|
60 |
public String email; |
|
61 |
public Vector formats; |
|
62 |
public HashMap operations; // operations that WCS supports |
|
63 |
|
|
64 |
public WCSServiceInformation() |
|
65 |
{ |
|
66 |
version = new String(); |
|
67 |
name = new String(); |
|
68 |
scope = new String(); |
|
69 |
title = new String(); |
|
70 |
abstr = new String(); |
|
71 |
keywords = new String(); |
|
72 |
fees = new String(); |
|
73 |
operationsInfo = new String(); |
|
74 |
personname = new String(); |
|
75 |
organization = new String(); |
|
76 |
function = new String(); |
|
77 |
addresstype = new String(); |
|
78 |
address = new String(); |
|
79 |
place = new String(); |
|
80 |
province = new String(); |
|
81 |
postcode = new String(); |
|
82 |
country = new String(); |
|
83 |
phone = new String(); |
|
84 |
fax = new String(); |
|
85 |
email = new String(); |
|
86 |
operations = new HashMap(); |
|
87 |
} |
|
88 |
|
|
89 |
public OGCClientOperation createOperation(String name) { |
|
90 |
return new WCSOperation(name); |
|
91 |
} |
|
92 |
|
|
93 |
public OGCClientOperation createOperation(String name, String onlineResource) { |
|
94 |
return new WCSOperation(name, onlineResource); |
|
95 |
} |
|
96 |
|
|
97 |
|
|
98 |
} |
|
99 |
|
|
0 | 100 |
tags/libraries/org.gvsig.remoteclient/2.0_old/src/org/gvsig/remoteclient/wcs/WCSProtocolHandlerFactory.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 |
/* |
|
42 |
* $Id$ |
|
43 |
* $Log$ |
|
44 |
* Revision 1.4 2006-07-18 11:41:05 jaume |
|
45 |
* no hay nada nuevo pero el team synchronize est? pesado |
|
46 |
* |
|
47 |
* Revision 1.3 2006/04/25 06:47:50 jaume |
|
48 |
* clean up unnecessary imports |
|
49 |
* |
|
50 |
* Revision 1.2 2006/03/15 08:54:42 jaume |
|
51 |
* *** empty log message *** |
|
52 |
* |
|
53 |
* Revision 1.1.2.1 2006/03/08 09:08:31 jaume |
|
54 |
* *** empty log message *** |
|
55 |
* |
|
56 |
* Revision 1.1 2006/03/06 15:18:32 jaume |
|
57 |
* *** empty log message *** |
|
58 |
* |
|
59 |
*/ |
|
60 |
package org.gvsig.remoteclient.wcs; |
|
61 |
|
|
62 |
import java.io.DataInputStream; |
|
63 |
import java.io.IOException; |
|
64 |
import java.io.StringReader; |
|
65 |
import java.net.ConnectException; |
|
66 |
import java.net.URL; |
|
67 |
import java.util.ArrayList; |
|
68 |
import java.util.Iterator; |
|
69 |
|
|
70 |
import org.kxml2.io.KXmlParser; |
|
71 |
import org.xmlpull.v1.XmlPullParserException; |
|
72 |
|
|
73 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
74 |
|
|
75 |
/** |
|
76 |
* |
|
77 |
* @author jaume dominguez faus |
|
78 |
* |
|
79 |
*/ |
|
80 |
public class WCSProtocolHandlerFactory { |
|
81 |
|
|
82 |
public org.gvsig.remoteclient.wcs.WCSProtocolHandler wCSProtocolHandler; |
|
83 |
|
|
84 |
private static ArrayList supportedVersions = new ArrayList(); |
|
85 |
|
|
86 |
static { |
|
87 |
supportedVersions.add("1.0.0"); |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* M?todo que dada una respuesta de getCapabilities y un iterador sobre una |
|
92 |
* coleccion de WCSClient's ordenada descendentemente devuelve el cliente |
|
93 |
* cuya version es igual o inmediatamente inferior |
|
94 |
* |
|
95 |
* @param caps Capabilities con la respuesta del servidor |
|
96 |
* @param clients Iterador de conjunto ordenado descendientemente |
|
97 |
* |
|
98 |
* @return cliente cuya version es igual o inmediatamente inferior |
|
99 |
* @throws IllegalAccessException |
|
100 |
* @throws InstantiationException |
|
101 |
* |
|
102 |
*/ |
|
103 |
private static String getDriverVersion(String version, Iterator clients) throws InstantiationException, IllegalAccessException { |
|
104 |
while (clients.hasNext()) { |
|
105 |
String clientVersion = (String)clients.next(); |
|
106 |
int ret = version.compareTo(clientVersion); |
|
107 |
|
|
108 |
if (ret >= 0) { |
|
109 |
return clientVersion; |
|
110 |
} |
|
111 |
} |
|
112 |
return null; |
|
113 |
} |
|
114 |
|
|
115 |
/** |
|
116 |
* Establece la versi?n con la que se comunicar? con el servidor y devuelve |
|
117 |
* el objeto Capabilities obtenido con dicha versi?n |
|
118 |
* |
|
119 |
* @param host maquina con la que se negocia |
|
120 |
* |
|
121 |
* @return instancia de un cliente capaz de negociar con el host que se |
|
122 |
* pasa como par?metro |
|
123 |
*/ |
|
124 |
public static WCSProtocolHandler negotiate(String host) throws ConnectException, IOException { |
|
125 |
|
|
126 |
if (supportedVersions.size() == 0) |
|
127 |
{ |
|
128 |
return null; |
|
129 |
} |
|
130 |
|
|
131 |
try |
|
132 |
{ |
|
133 |
String highestVersionSupportedByServer = getSuitableWCSVersion(host,""); |
|
134 |
if (supportedVersions.contains(highestVersionSupportedByServer)) |
|
135 |
{ |
|
136 |
// we support the highest version supported by the server |
|
137 |
// this is the best case |
|
138 |
return createVersionDriver(highestVersionSupportedByServer); |
|
139 |
} |
|
140 |
else |
|
141 |
{ |
|
142 |
// in case we dont support the highest version from the server |
|
143 |
// we start the negotiation process in which we have to get the higest version |
|
144 |
// the WCS supports and we are able to read. |
|
145 |
Iterator iVersion = supportedVersions.iterator(); |
|
146 |
String wcsVersion; |
|
147 |
String gvSIGVersion; |
|
148 |
|
|
149 |
while (iVersion.hasNext()) { |
|
150 |
gvSIGVersion = (String)iVersion.next(); |
|
151 |
wcsVersion = getSuitableWCSVersion(host,gvSIGVersion); |
|
152 |
//TODO: |
|
153 |
//compare with the version returned by the WMS!!!!! |
|
154 |
// send GetCapabilities and read the version to compare. |
|
155 |
int res = wcsVersion.compareTo(gvSIGVersion); |
|
156 |
|
|
157 |
if (res == 0) { //Si es la misma que nuestra version |
|
158 |
return createVersionDriver(gvSIGVersion); |
|
159 |
} else if (res > 0) { //Si es mayor que nuestra version |
|
160 |
throw new Exception("Server Version too high: " + wcsVersion); |
|
161 |
} else { //Si es menor que nuestra version |
|
162 |
//Obtenemos la primera version menor o igual que tengamos |
|
163 |
String lowerVersion = WCSProtocolHandlerFactory.getDriverVersion(wcsVersion, iVersion); |
|
164 |
|
|
165 |
if (lowerVersion == null) { //Si no hay ninguna |
|
166 |
throw new Exception("Lowest server version is " + wcsVersion); |
|
167 |
} else { |
|
168 |
if (lowerVersion.equals(wcsVersion)) { |
|
169 |
return createVersionDriver(lowerVersion); |
|
170 |
} else { //Si hay una version menor que la que retorno el servidor |
|
171 |
//iV = lower; |
|
172 |
} |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
176 |
}//case we had to start the negotiation process. |
|
177 |
return null; // if it did not find any suitable version. |
|
178 |
} |
|
179 |
catch(ConnectException conEx) |
|
180 |
{ |
|
181 |
throw conEx; |
|
182 |
} |
|
183 |
catch(IOException ioEx) |
|
184 |
{ |
|
185 |
throw ioEx; |
|
186 |
} |
|
187 |
catch(Exception e) |
|
188 |
{ |
|
189 |
// e.printStackTrace(); |
|
190 |
return null; |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
/** |
|
195 |
* Sends a GetCapabilities to the WCS server to get the version |
|
196 |
* if the version parameter is null, the WCS will return the highest version supported |
|
197 |
* if not it will return the lower highest version than the one requested. |
|
198 |
* @param host |
|
199 |
* @param version |
|
200 |
* @return suitable version supported by the server |
|
201 |
*/ |
|
202 |
private static String getSuitableWCSVersion(String host, String _version) throws ConnectException, IOException { |
|
203 |
String request = WCSProtocolHandler.buildCapabilitiesSuitableVersionRequest(host, _version); |
|
204 |
String version = new String(); |
|
205 |
StringReader reader = null; |
|
206 |
//InputStreamReader reader; |
|
207 |
//InputStream is = null; |
|
208 |
DataInputStream dis = null; |
|
209 |
try { |
|
210 |
URL url = new URL(request); |
|
211 |
byte[] buffer = new byte[1024];//new byte[1024*256]; |
|
212 |
// is = url.openStream(); |
|
213 |
// reader = new InputStreamReader(is); |
|
214 |
//int numberOfBytes = is.read(buffer); |
|
215 |
//String readed = new String(buffer); |
|
216 |
dis = new DataInputStream(url.openStream()); |
|
217 |
dis.readFully(buffer); |
|
218 |
|
|
219 |
reader = new StringReader(new String(buffer)); |
|
220 |
KXmlParser kxmlParser = null; |
|
221 |
kxmlParser = new KXmlParser(); |
|
222 |
kxmlParser.setInput(reader); |
|
223 |
kxmlParser.nextTag(); |
|
224 |
if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT ) { |
|
225 |
if ((kxmlParser.getName().compareTo(CapabilitiesTags.WCS_CAPABILITIES_ROOT1_0_0)==0)) { |
|
226 |
version = kxmlParser.getAttributeValue("", CapabilitiesTags.VERSION); |
|
227 |
} |
|
228 |
} |
|
229 |
// do not forget to close the Stream. |
|
230 |
reader.close(); |
|
231 |
dis.close(); |
|
232 |
return version; |
|
233 |
} catch(ConnectException conEx) { |
|
234 |
throw new ConnectException(conEx.getMessage()); |
|
235 |
} catch(IOException ioEx) { |
|
236 |
throw new IOException(ioEx.getMessage()); |
|
237 |
} catch(XmlPullParserException xmlEx) { |
|
238 |
xmlEx.printStackTrace(); |
|
239 |
return ""; |
|
240 |
} finally { |
|
241 |
if (reader != null) { |
|
242 |
try { |
|
243 |
reader.close(); |
|
244 |
} catch(Exception ex) { |
|
245 |
ex.printStackTrace(); |
|
246 |
} |
|
247 |
} if (dis != null) { |
|
248 |
try { |
|
249 |
dis.close(); |
|
250 |
} catch(Exception ex){ |
|
251 |
ex.printStackTrace(); |
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 |
/** |
|
258 |
* It creates an instance of a WCSDriver class. |
|
259 |
* |
|
260 |
* @param String, with the version of the driver to be created |
|
261 |
* @return WCSDriver. |
|
262 |
*/ |
|
263 |
private static WCSProtocolHandler createVersionDriver(String version) { |
|
264 |
try { |
|
265 |
Class driver; |
|
266 |
version = version.replace('.', '_'); |
|
267 |
driver = Class.forName("org.gvsig.remoteclient.wcs.wcs_"+version+".WCSProtocolHandler" + version); |
|
268 |
return (WCSProtocolHandler)driver.newInstance(); |
|
269 |
} catch (Exception e) { |
|
270 |
e.printStackTrace(); |
|
271 |
//throw new Exception("WCSDriverFactory. Unknown driver version " + e); |
|
272 |
return null; |
|
273 |
} |
|
274 |
} |
|
275 |
|
|
276 |
|
|
277 |
} |
|
0 | 278 |
tags/libraries/org.gvsig.remoteclient/2.0_old/src/org/gvsig/remoteclient/wcs/WCSCoverage.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 |
/** |
|
42 |
* |
|
43 |
*/ |
|
44 |
package org.gvsig.remoteclient.wcs; |
|
45 |
|
|
46 |
import java.io.IOException; |
|
47 |
import java.util.ArrayList; |
|
48 |
import java.util.Hashtable; |
|
49 |
|
|
50 |
import org.kxml2.io.KXmlParser; |
|
51 |
import org.xmlpull.v1.XmlPullParserException; |
|
52 |
|
|
53 |
import org.gvsig.remoteclient.ILayer; |
|
54 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
|
55 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
56 |
|
|
57 |
/** |
|
58 |
* Describes a coverage in a WCS server. |
|
59 |
* |
|
60 |
* @author jaume dominguez faus - jaume.domingue@iver.es |
|
61 |
* |
|
62 |
*/ |
|
63 |
public abstract class WCSCoverage implements ILayer{ |
|
64 |
public static final String SEPARATOR = " +"; // separator used to split list of values, usually is just a space |
|
65 |
private String name; |
|
66 |
private String title; |
|
67 |
private String _abstract; |
|
68 |
private Hashtable bBoxes = new Hashtable(); |
|
69 |
private BoundaryBox lonLatBbox; |
|
70 |
public RectifiedGrid rg; |
|
71 |
private ArrayList timePositions = new ArrayList(); |
|
72 |
public String timePeriod; |
|
73 |
private String rangeSetName; |
|
74 |
private String rangeSetLabel; |
|
75 |
public Hashtable axisPool = new Hashtable(); |
|
76 |
private String nativeSRS; |
|
77 |
private ArrayList supportedSRSs = new ArrayList(); |
|
78 |
private ArrayList interpolationMethods; |
|
79 |
private String nativeFormat; |
|
80 |
private ArrayList formats = new ArrayList(); |
|
81 |
|
|
82 |
public ArrayList getTimePositions() { |
|
83 |
return timePositions; |
|
84 |
} |
|
85 |
|
|
86 |
public void addTimePosition(String timeExpr) { |
|
87 |
if (timePositions == null) |
|
88 |
timePositions = new ArrayList(); |
|
89 |
timePositions.add(timeExpr); |
|
90 |
} |
|
91 |
|
|
92 |
public ArrayList getFormats() { |
|
93 |
return formats; |
|
94 |
} |
|
95 |
|
|
96 |
public void addFormat(String format) { |
|
97 |
formats.add(format); |
|
98 |
} |
|
99 |
|
|
100 |
public void setNativeFormat(String nativeFormat) { |
|
101 |
this.nativeFormat = nativeFormat; |
|
102 |
} |
|
103 |
|
|
104 |
public String getNativeFormat() { |
|
105 |
return nativeFormat; |
|
106 |
} |
|
107 |
|
|
108 |
public String getNativeSRS() { |
|
109 |
return nativeSRS; |
|
110 |
} |
|
111 |
|
|
112 |
public void setNativeSRS(String nativeSRS) { |
|
113 |
this.nativeSRS = nativeSRS; |
|
114 |
} |
|
115 |
|
|
116 |
public ArrayList getSRSs() { |
|
117 |
return supportedSRSs; |
|
118 |
} |
|
119 |
|
|
120 |
public void addSRSs(String srs) { |
|
121 |
supportedSRSs.add(srs); |
|
122 |
} |
|
123 |
|
|
124 |
public String getRangeSetLabel() { |
|
125 |
return rangeSetLabel; |
|
126 |
} |
|
127 |
|
|
128 |
public void setRangeSetLabel(String rangeSetLabel) { |
|
129 |
this.rangeSetLabel = rangeSetLabel; |
|
130 |
} |
|
131 |
|
|
132 |
public String getRangeSetName() { |
|
133 |
return rangeSetName; |
|
134 |
} |
|
135 |
|
|
136 |
public void setRangeSetName(String rangeSetName) { |
|
137 |
this.rangeSetName = rangeSetName; |
|
138 |
} |
|
139 |
|
|
140 |
/* (non-Javadoc) |
|
141 |
* @see org.gvsig.remoteClient.ILayer#getName() |
|
142 |
*/ |
|
143 |
public String getName() { |
|
144 |
return name; |
|
145 |
} |
|
146 |
|
|
147 |
/* (non-Javadoc) |
|
148 |
* @see org.gvsig.remoteClient.ILayer#setName(java.lang.String) |
|
149 |
*/ |
|
150 |
public void setName(String _name) { |
|
151 |
name = _name; |
|
152 |
} |
|
153 |
|
|
154 |
/* (non-Javadoc) |
|
155 |
* @see org.gvsig.remoteClient.ILayer#setTitle(java.lang.String) |
|
156 |
*/ |
|
157 |
public void setTitle(String _title) { |
|
158 |
title = _title; |
|
159 |
} |
|
160 |
|
|
161 |
/* (non-Javadoc) |
|
162 |
* @see org.gvsig.remoteClient.ILayer#getTitle() |
|
163 |
*/ |
|
164 |
public String getTitle() { |
|
165 |
return title; |
|
166 |
} |
|
167 |
|
|
168 |
/* (non-Javadoc) |
|
169 |
* @see org.gvsig.remoteClient.ILayer#getAbstract() |
|
170 |
*/ |
|
171 |
public String getAbstract() { |
|
172 |
return _abstract; |
|
173 |
} |
|
174 |
|
|
175 |
/* (non-Javadoc) |
|
176 |
* @see org.gvsig.remoteClient.ILayer#setAbstract(java.lang.String) |
|
177 |
*/ |
|
178 |
public void setAbstract(String _abstract) { |
|
179 |
this._abstract = _abstract; |
|
180 |
} |
|
181 |
|
|
182 |
public void addBBox(BoundaryBox bBox) { |
|
183 |
bBoxes.put(bBox.getSrs(), bBox); |
|
184 |
} |
|
185 |
|
|
186 |
public ArrayList getAllSrs() { |
|
187 |
ArrayList mySrs = new ArrayList(); |
|
188 |
mySrs.addAll(supportedSRSs); |
|
189 |
if (!mySrs.contains(nativeSRS)) |
|
190 |
mySrs.add(nativeSRS); |
|
191 |
return mySrs; |
|
192 |
} |
|
193 |
/** |
|
194 |
* <p>returns the bbox with that id in the Bboxes vector</p> |
|
195 |
* @param id |
|
196 |
*/ |
|
197 |
public BoundaryBox getBbox(String id) { |
|
198 |
if ((id.compareToIgnoreCase( CapabilitiesTags.EPSG_4326 )==0) |
|
199 |
||(id.compareToIgnoreCase( CapabilitiesTags.CRS_84)==0)) |
|
200 |
{ |
|
201 |
if (lonLatBbox != null) |
|
202 |
return lonLatBbox; |
|
203 |
} |
|
204 |
|
|
205 |
return (BoundaryBox)bBoxes.get(id); |
|
206 |
} |
|
207 |
|
|
208 |
public BoundaryBox getLatLonBox() { |
|
209 |
return lonLatBbox; |
|
210 |
} |
|
211 |
|
|
212 |
public void setLonLatBox(BoundaryBox box) { |
|
213 |
lonLatBbox = box; |
|
214 |
} |
|
215 |
|
|
216 |
public void addInterpolationMethod(String method) { |
|
217 |
if (interpolationMethods==null) interpolationMethods = new ArrayList(); |
|
218 |
interpolationMethods.add(method); |
|
219 |
} |
|
220 |
|
|
221 |
public ArrayList getInterpolationMethods() { |
|
222 |
return interpolationMethods; |
|
223 |
} |
|
224 |
/** |
|
225 |
* Parses the fragment of the XML document that describes this layer (or coverage) |
|
226 |
* @param parser |
|
227 |
* @throws IOException |
|
228 |
* @throws XmlPullParserException |
|
229 |
*/ |
|
230 |
public abstract void parse(KXmlParser parser) throws XmlPullParserException, IOException; |
|
231 |
|
|
232 |
/** |
|
233 |
* Gets the RectifiedGrid structure |
|
234 |
* @return |
|
235 |
*/ |
|
236 |
public RectifiedGrid getRectifiedGrid() { |
|
237 |
return rg; |
|
238 |
} |
|
239 |
|
|
240 |
/** |
|
241 |
* Inner class describing the Rectified Grid of this coverage. |
|
242 |
* |
|
243 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
244 |
*/ |
|
245 |
public class RectifiedGrid { |
|
246 |
private int dimensions; |
|
247 |
private String[] axisNames; |
|
248 |
private int[][] lowGridEnvelopLimits; |
|
249 |
private int[][] highGridEnvelopLimits; |
|
250 |
private double[] origins; |
|
251 |
private double[][] offsetVector; |
|
252 |
|
|
253 |
public RectifiedGrid(int dimensions) { |
|
254 |
this.dimensions = dimensions; |
|
255 |
} |
|
256 |
|
|
257 |
public void addAxisName(String axisName) { |
|
258 |
if (axisNames == null) { |
|
259 |
axisNames = new String[1]; |
|
260 |
axisNames[0] = axisName; |
|
261 |
} else { |
|
262 |
String[] aux = axisNames; |
|
263 |
axisNames = new String[axisNames.length+1]; |
|
264 |
for (int i = 0; i < aux.length; i++) { |
|
265 |
axisNames[i] = aux[i]; |
|
266 |
} |
|
267 |
axisNames[axisNames.length-1] = axisName; |
|
268 |
} |
|
269 |
} |
|
270 |
|
|
271 |
public String[] getAxisNames() { |
|
272 |
return axisNames; |
|
273 |
} |
|
274 |
|
|
275 |
public void addLowGridEnvelopLimit(int[] lowLimit) { |
|
276 |
if (lowGridEnvelopLimits == null) { |
|
277 |
lowGridEnvelopLimits = new int[1][1]; |
|
278 |
lowGridEnvelopLimits[0] = lowLimit; |
|
279 |
} else { |
|
280 |
int[][] aux = lowGridEnvelopLimits; |
|
281 |
lowGridEnvelopLimits = new int[lowGridEnvelopLimits.length+1][1]; |
|
282 |
for (int i = 0; i < aux.length; i++) { |
|
283 |
lowGridEnvelopLimits[i] = aux[i]; |
|
284 |
} |
|
285 |
lowGridEnvelopLimits[lowGridEnvelopLimits.length-1] = lowLimit; |
|
286 |
} |
|
287 |
} |
|
288 |
|
|
289 |
public int[][] getLowGridEnvelopLimits() { |
|
290 |
return lowGridEnvelopLimits; |
|
291 |
} |
|
292 |
|
|
293 |
public void addHighGridEnvelopLimit(int[] highLimit) { |
|
294 |
if (highGridEnvelopLimits == null) { |
|
295 |
highGridEnvelopLimits = new int[1][1]; |
|
296 |
highGridEnvelopLimits[0] = highLimit; |
|
297 |
} else { |
|
298 |
int[][] aux = highGridEnvelopLimits; |
|
299 |
highGridEnvelopLimits = new int[highGridEnvelopLimits.length+1][1]; |
|
300 |
for (int i = 0; i < aux.length; i++) { |
|
301 |
highGridEnvelopLimits[i] = aux[i]; |
|
302 |
} |
|
303 |
highGridEnvelopLimits[highGridEnvelopLimits.length-1] = highLimit; |
|
304 |
} |
|
305 |
} |
|
306 |
|
|
307 |
public int[][] getHighGridEnvelopLimits() { |
|
308 |
return highGridEnvelopLimits; |
|
309 |
} |
|
310 |
|
|
311 |
public void setOrigin(double[] _origins) { |
|
312 |
origins = _origins; |
|
313 |
} |
|
314 |
|
|
315 |
public double[] getOrigins() { |
|
316 |
return origins; |
|
317 |
} |
|
318 |
|
|
319 |
public void addToOffsetVector(double[] _offsetVector) { |
|
320 |
if (offsetVector == null) { |
|
321 |
offsetVector = new double[1][1]; |
|
322 |
offsetVector[0] = _offsetVector; |
|
323 |
} else { |
|
324 |
double[][] aux = offsetVector; |
|
325 |
offsetVector = new double[offsetVector.length+1][1]; |
|
326 |
for (int i = 0; i < aux.length; i++) { |
|
327 |
offsetVector[i] = aux[i]; |
|
328 |
} |
|
329 |
offsetVector[offsetVector.length-1] = _offsetVector; |
|
330 |
} |
|
331 |
} |
|
332 |
|
|
333 |
public double[][] getOffsetVector(){ |
|
334 |
return offsetVector; |
|
335 |
} |
|
336 |
|
|
337 |
public int getDimensionCount() { |
|
338 |
return dimensions; |
|
339 |
} |
|
340 |
} |
|
341 |
|
|
342 |
/** |
|
343 |
* Inner class describing the Axis Description of this coverage. |
|
344 |
* |
|
345 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
346 |
*/ |
|
347 |
public class AxisDescription { |
|
348 |
private String _name; |
|
349 |
private String label; |
|
350 |
private ArrayList singleValues = new ArrayList(); |
|
351 |
private String interval; |
|
352 |
private String defaultValue; |
|
353 |
|
|
354 |
public String getDefaultValue() { |
|
355 |
return defaultValue; |
|
356 |
} |
|
357 |
|
|
358 |
public void setDefaultValue(String defaultValue) { |
|
359 |
this.defaultValue = defaultValue; |
|
360 |
} |
|
361 |
|
|
362 |
public String getInterval() { |
|
363 |
return interval; |
|
364 |
} |
|
365 |
|
|
366 |
public void setInterval(String interval) { |
|
367 |
this.interval = interval; |
|
368 |
} |
|
369 |
|
|
370 |
public String getLabel() { |
|
371 |
return label; |
|
372 |
} |
|
373 |
public void setLabel(String label) { |
|
374 |
this.label = label; |
|
375 |
} |
|
376 |
|
|
377 |
public String getName() { |
|
378 |
return _name; |
|
379 |
} |
|
380 |
|
|
381 |
public void setName(String name) { |
|
382 |
this._name = name; |
|
383 |
} |
|
384 |
|
|
385 |
public ArrayList getSingleValues() { |
|
386 |
return singleValues; |
|
387 |
} |
|
388 |
|
|
389 |
public void addSingleValues(String singleValue) { |
|
390 |
this.singleValues.add(singleValue); |
|
391 |
} |
|
392 |
} |
|
393 |
|
|
394 |
public double getResX() { |
|
395 |
if (rg.offsetVector== null) |
|
396 |
return -1; |
|
397 |
return Math.abs(rg.offsetVector[0][0]); |
|
398 |
} |
|
399 |
|
|
400 |
public double getResY() { |
|
401 |
if (rg.offsetVector== null) |
|
402 |
return -1; |
|
403 |
|
|
404 |
return Math.abs(rg.offsetVector[1][1]); |
|
405 |
} |
|
406 |
|
|
407 |
public Hashtable getBBoxes() { |
|
408 |
if (bBoxes == null) return new Hashtable(); |
|
409 |
else return bBoxes; |
|
410 |
} |
|
411 |
|
|
412 |
} |
|
413 |
|
|
0 | 414 |
tags/libraries/org.gvsig.remoteclient/2.0_old/src/org/gvsig/remoteclient/wcs/request/WCSGetCoverageRequest.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 Iver T.I. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.remoteclient.wcs.request; |
|
29 |
|
|
30 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
31 |
import org.gvsig.remoteclient.utils.Utilities; |
|
32 |
import org.gvsig.remoteclient.wcs.WCSProtocolHandler; |
|
33 |
import org.gvsig.remoteclient.wcs.WCSStatus; |
|
34 |
|
|
35 |
/** |
|
36 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
37 |
*/ |
|
38 |
public abstract class WCSGetCoverageRequest extends WCSRequest{ |
|
39 |
|
|
40 |
public WCSGetCoverageRequest(WCSStatus status, |
|
41 |
WCSProtocolHandler protocolHandler) { |
|
42 |
super(status, protocolHandler); |
|
43 |
} |
|
44 |
|
|
45 |
/* |
|
46 |
* (non-Javadoc) |
|
47 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getHttpPostRequest(java.lang.String) |
|
48 |
*/ |
|
49 |
protected String getHttpPostRequest(String onlineResource) { |
|
50 |
// TODO Auto-generated method stub |
|
51 |
return null; |
|
52 |
} |
|
53 |
|
|
54 |
/* |
|
55 |
* (non-Javadoc) |
|
56 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getOperationCode() |
|
57 |
*/ |
|
58 |
protected String getOperationName() { |
|
59 |
return CapabilitiesTags.GETCOVERAGE; |
|
60 |
} |
|
61 |
|
|
62 |
/* |
|
63 |
* (non-Javadoc) |
|
64 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getSchemaLocation() |
|
65 |
*/ |
|
66 |
protected String getSchemaLocation() { |
|
67 |
return null; |
|
68 |
} |
|
69 |
|
|
70 |
/* |
|
71 |
* (non-Javadoc) |
|
72 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getTempFilePrefix() |
|
73 |
*/ |
|
74 |
protected String getTempFilePrefix() { |
|
75 |
return "wcsGetCoverage" + System.currentTimeMillis(); |
|
76 |
//return "wcs_getCoverage.xml"; |
|
77 |
} |
|
78 |
} |
|
0 | 79 |
tags/libraries/org.gvsig.remoteclient/2.0_old/src/org/gvsig/remoteclient/wcs/request/WCSDescribeCoverageRequest.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 Iver T.I. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.remoteclient.wcs.request; |
|
29 |
|
|
30 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
31 |
import org.gvsig.remoteclient.wcs.WCSProtocolHandler; |
|
32 |
import org.gvsig.remoteclient.wcs.WCSStatus; |
|
33 |
|
|
34 |
/** |
|
35 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
36 |
*/ |
|
37 |
public abstract class WCSDescribeCoverageRequest extends WCSRequest{ |
|
38 |
|
|
39 |
public WCSDescribeCoverageRequest(WCSStatus status, |
|
40 |
WCSProtocolHandler protocolHandler) { |
|
41 |
super(status, protocolHandler); |
|
42 |
} |
|
43 |
|
|
44 |
/* |
|
45 |
* (non-Javadoc) |
|
46 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getHttpPostRequest(java.lang.String) |
|
47 |
*/ |
|
48 |
protected String getHttpPostRequest(String onlineResource) { |
|
49 |
// TODO Auto-generated method stub |
|
50 |
return null; |
|
51 |
} |
|
52 |
|
|
53 |
/* |
|
54 |
* (non-Javadoc) |
|
55 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getOperationCode() |
|
56 |
*/ |
|
57 |
protected String getOperationName() { |
|
58 |
return CapabilitiesTags.DESCRIBECOVERAGE; |
|
59 |
} |
|
60 |
|
|
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getSchemaLocation() |
|
64 |
*/ |
|
65 |
protected String getSchemaLocation() { |
|
66 |
return null; |
|
67 |
} |
|
68 |
|
|
69 |
/* |
|
70 |
* (non-Javadoc) |
|
71 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getTempFilePrefix() |
|
72 |
*/ |
|
73 |
protected String getTempFilePrefix() { |
|
74 |
return "wcs_describeCoverage.xml"; |
|
75 |
} |
|
76 |
} |
|
0 | 77 |
tags/libraries/org.gvsig.remoteclient/2.0_old/src/org/gvsig/remoteclient/wcs/request/WCSRequest.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 Iver T.I. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.remoteclient.wcs.request; |
|
29 |
|
|
30 |
import org.gvsig.remoteclient.ogc.request.OGCRequest; |
|
31 |
import org.gvsig.remoteclient.wcs.WCSProtocolHandler; |
|
32 |
import org.gvsig.remoteclient.wcs.WCSStatus; |
|
33 |
|
|
34 |
/** |
|
35 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
36 |
*/ |
|
37 |
public abstract class WCSRequest extends OGCRequest{ |
|
38 |
protected WCSStatus status = null; |
|
39 |
|
|
40 |
public WCSRequest(WCSStatus status, WCSProtocolHandler protocolHandler) { |
|
41 |
super(status, protocolHandler); |
|
42 |
this.status = status; |
|
43 |
} |
|
44 |
|
|
45 |
protected String getPartialQuery(WCSStatus status) |
|
46 |
{ |
|
47 |
StringBuffer req = new StringBuffer(); |
|
48 |
req.append( (status.getTime() != null) ? "&TIME=" + status.getTime() : "" ) |
|
49 |
.append( "&COVERAGE=" + status.getCoverageName()) |
|
50 |
.append( "&CRS=" + status.getSrs()) |
|
51 |
.append( "&FORMAT=" + status.getFormat() ) |
|
52 |
.append( "&HEIGHT=" + status.getHeight()) |
|
53 |
.append( "&WIDTH=" + status.getWidth()) |
|
54 |
.append( (status.getDepth() != null) ? "&DEPTH=" + status.getDepth() : "" ) |
|
55 |
.append( "&BBOX=" + status.getExtent().getMinX() + "," ) |
|
56 |
.append( status.getExtent().getMinY() + ",") |
|
57 |
.append( status.getExtent().getMaxX() + ",") |
|
58 |
.append( status.getExtent().getMaxY()) |
|
59 |
.append( (status.getParameters() != null) ? "&" + status.getParameters() : ""); |
|
60 |
|
|
61 |
return req.toString(); |
|
62 |
} |
|
63 |
} |
|
64 |
|
|
65 |
|
|
66 |
|
|
0 | 67 |
tags/libraries/org.gvsig.remoteclient/2.0_old/src/org/gvsig/remoteclient/wcs/wcs_1_0_0/WCSCoverage1_0_0.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 |
/** |
|
42 |
* |
|
43 |
*/ |
|
44 |
package org.gvsig.remoteclient.wcs.wcs_1_0_0; |
|
45 |
|
|
46 |
|
|
47 |
import java.io.IOException; |
|
48 |
|
|
49 |
import org.kxml2.io.KXmlParser; |
|
50 |
import org.xmlpull.v1.XmlPullParserException; |
|
51 |
|
|
52 |
import org.gvsig.compat.CompatLocator; |
|
53 |
import org.gvsig.compat.lang.StringUtils; |
|
54 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
|
55 |
import org.gvsig.remoteclient.utils.DescribeCoverageTags; |
|
56 |
import org.gvsig.remoteclient.wcs.WCSCoverage; |
|
57 |
|
|
58 |
/** |
|
59 |
* @author jaume |
|
60 |
* |
|
61 |
*/ |
|
62 |
public class WCSCoverage1_0_0 extends WCSCoverage{ |
|
63 |
String axisDescriptionName; |
|
64 |
|
|
65 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
66 |
|
|
67 |
/* (non-Javadoc) |
|
68 |
* @see org.gvsig.remoteClient.wcs.WCSLayer#parse(org.kxml2.io.KXmlParser) |
|
69 |
*/ |
|
70 |
public void parse(KXmlParser parser) throws XmlPullParserException, IOException { |
|
71 |
int currentTag; |
|
72 |
String value; |
|
73 |
boolean end = false; |
|
74 |
|
|
75 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.COVERAGE_OFFERING); |
|
76 |
currentTag = parser.next(); |
|
77 |
|
|
78 |
while (!end) |
|
79 |
{ |
|
80 |
switch(currentTag) |
|
81 |
{ |
|
82 |
case KXmlParser.START_TAG: |
|
83 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME)==0) |
|
84 |
{ |
|
85 |
value = parser.nextText(); |
|
86 |
if (value != null) setName(value); |
|
87 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LABEL)==0){ |
|
88 |
value = parser.nextText(); |
|
89 |
if (value != null) setTitle(value); |
|
90 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LONLAT_ENVELOPE)==0){ |
|
91 |
BoundaryBox bBox = parseLonLatGMLEnvelope(parser); |
|
92 |
bBox.setSrs(DescribeCoverageTags.WGS84); |
|
93 |
addBBox(bBox); |
|
94 |
setLonLatBox(bBox); |
|
95 |
} else if (parser.getName().compareTo(DescribeCoverageTags.DOMAINSET) == 0) { |
|
96 |
parseDomainSet(parser); |
|
97 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RANGESET) == 0) { |
|
98 |
parseRangeSet(parser); |
|
99 |
} else if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_CRSS) == 0) { |
|
100 |
parseSupportedCRSS(parser); |
|
101 |
} else if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_FORMATS) == 0) { |
|
102 |
setNativeFormat(parser.getAttributeValue("", DescribeCoverageTags.NATIVE_FORMAT)); |
|
103 |
parser.nextTag(); |
|
104 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.FORMATS); |
|
105 |
while (parser.getName().compareTo(DescribeCoverageTags.FORMATS) == 0) { |
|
106 |
String[] formats = stringUtils.split(parser.nextText(), SEPARATOR); |
|
107 |
for (int i = 0; i < formats.length; i++) { |
|
108 |
addFormat(formats[i]); |
|
109 |
} |
|
110 |
parser.nextTag(); |
|
111 |
} |
|
112 |
} else if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_INTERPOLATIONS) == 0) { |
|
113 |
boolean bInterpolationsEnd = false; |
|
114 |
int interpolationsTag = parser.next(); |
|
115 |
while (!bInterpolationsEnd) { |
|
116 |
switch(interpolationsTag) { |
|
117 |
case KXmlParser.START_TAG: |
|
118 |
if (parser.getName().compareTo(DescribeCoverageTags.INTERPOLATION_METHOD)==0) { |
|
119 |
addInterpolationMethod(parser.nextText()); |
|
120 |
} |
|
121 |
break; |
|
122 |
case KXmlParser.END_TAG: |
|
123 |
if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_INTERPOLATIONS) == 0) |
|
124 |
bInterpolationsEnd = true; |
|
125 |
break; |
|
126 |
case KXmlParser.TEXT: |
|
127 |
if (parser.getName()!=null) |
|
128 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
129 |
break; |
|
130 |
} |
|
131 |
interpolationsTag = parser.next(); |
|
132 |
} |
|
133 |
} else { |
|
134 |
if (!parser.getName().equals("rangeSet")) // just a patch to avoid too much messages |
|
135 |
System.out.println("Skiped "+parser.getName()); |
|
136 |
} |
|
137 |
|
|
138 |
break; |
|
139 |
case KXmlParser.END_TAG: |
|
140 |
if (parser.getName().compareTo(DescribeCoverageTags.COVERAGE_OFFERING) == 0) |
|
141 |
end = true; |
|
142 |
break; |
|
143 |
case KXmlParser.TEXT: |
|
144 |
if (parser.getName()!=null) |
|
145 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
146 |
break; |
|
147 |
} |
|
148 |
currentTag = parser.next(); |
|
149 |
} |
|
150 |
} |
|
151 |
|
|
152 |
private void parseSupportedCRSS(KXmlParser parser) throws XmlPullParserException, IOException { |
|
153 |
int currentTag; |
|
154 |
boolean end = false; |
|
155 |
|
|
156 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.SUPPORTED_CRSS); |
|
157 |
currentTag = parser.next(); |
|
158 |
|
|
159 |
while (!end) |
|
160 |
{ |
|
161 |
switch(currentTag) |
|
162 |
{ |
|
163 |
case KXmlParser.START_TAG: |
|
164 |
if (parser.getName().compareTo(DescribeCoverageTags.REQUEST_RESPONSE_CRSS)==0) { |
|
165 |
String[] values = stringUtils.split(parser.nextText(), SEPARATOR); |
|
166 |
for (int i = 0; i < values.length; i++) { |
|
167 |
addSRSs(values[i]); |
|
168 |
} |
|
169 |
} |
|
170 |
else if (parser.getName().compareTo(DescribeCoverageTags.NATIVE_CRS) == 0) { |
|
171 |
setNativeSRS(parser.nextText()); |
|
172 |
} else if (parser.getName().compareTo(DescribeCoverageTags.REQUEST_CRSS) == 0) { |
|
173 |
// TODO |
|
174 |
System.out.println("Skiped "+parser.getName()); |
|
175 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RESPONSE_CRSS) == 0) { |
|
176 |
// TODO |
|
177 |
System.out.println("Skiped "+parser.getName()); |
|
178 |
} else { |
|
179 |
System.out.println("Unrecognized "+parser.getName()); |
|
180 |
} |
|
181 |
|
|
182 |
break; |
|
183 |
case KXmlParser.END_TAG: |
|
184 |
if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_CRSS) == 0) |
|
185 |
return;//end = true; |
|
186 |
break; |
|
187 |
case KXmlParser.TEXT: |
|
188 |
if (parser.getName()!=null) |
|
189 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
190 |
break; |
|
191 |
} |
|
192 |
currentTag = parser.next(); |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
private void parseRangeSet(KXmlParser parser) throws XmlPullParserException, IOException { |
|
197 |
int currentTag; |
|
198 |
boolean end = false; |
|
199 |
|
|
200 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.RANGESET); |
|
201 |
currentTag = parser.next(); |
|
202 |
|
|
203 |
while (!end) |
|
204 |
{ |
|
205 |
switch(currentTag) |
|
206 |
{ |
|
207 |
case KXmlParser.START_TAG: |
|
208 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME)==0) |
|
209 |
setRangeSetName(parser.nextText()); |
|
210 |
else if (parser.getName().compareTo(DescribeCoverageTags.LABEL) == 0) |
|
211 |
setRangeSetLabel(parser.nextText()); |
|
212 |
else if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) { |
|
213 |
// Reading all axe description |
|
214 |
int axisTag = parser.nextTag(); |
|
215 |
boolean endAxe = false; |
|
216 |
while (!endAxe) { |
|
217 |
switch(axisTag) |
|
218 |
{ |
|
219 |
case KXmlParser.START_TAG: |
|
220 |
if (parser.getName().compareTo(DescribeCoverageTags.AXISDESCRIPTION)==0) { |
|
221 |
AxisDescription as = parseAxisDescription(parser); |
|
222 |
axisPool.put(as.getName(), as); |
|
223 |
axisDescriptionName = as.getName(); |
|
224 |
} |
|
225 |
break; |
|
226 |
case KXmlParser.END_TAG: |
|
227 |
if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) |
|
228 |
endAxe = true; |
|
229 |
break; |
|
230 |
case KXmlParser.TEXT: |
|
231 |
if (parser.getName()!=null) |
|
232 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
233 |
break; |
|
234 |
} |
|
235 |
axisTag = parser.next(); |
|
236 |
} |
|
237 |
} else { |
|
238 |
System.out.println("Unrecognized "+parser.getName()); |
|
239 |
} |
|
240 |
break; |
|
241 |
case KXmlParser.END_TAG: |
|
242 |
if (parser.getName().compareTo(DescribeCoverageTags.RANGESET) == 0) |
|
243 |
end = true; |
|
244 |
break; |
|
245 |
case KXmlParser.TEXT: |
|
246 |
if (parser.getName()!=null) |
|
247 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
248 |
break; |
|
249 |
} |
|
250 |
currentTag = parser.next(); |
|
251 |
} |
|
252 |
} |
|
253 |
|
|
254 |
private AxisDescription parseAxisDescription(KXmlParser parser) throws XmlPullParserException, IOException { |
|
255 |
int currentTag; |
|
256 |
boolean end = false; |
|
257 |
|
|
258 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.AXISDESCRIPTION); |
|
259 |
AxisDescription as = new AxisDescription(); |
|
260 |
currentTag = parser.next(); |
|
261 |
|
|
262 |
while (!end) |
|
263 |
{ |
|
264 |
switch(currentTag) |
|
265 |
{ |
|
266 |
case KXmlParser.START_TAG: |
|
267 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME) == 0) { |
|
268 |
as.setName(parser.nextText()); |
|
269 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LABEL) == 0) { |
|
270 |
as.setLabel(parser.nextText()); |
Also available in: Unified diff