Revision 4427
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/utils/CapabilitiesTags.java | ||
---|---|---|
106 | 106 |
|
107 | 107 |
// WMS Extent specifics |
108 | 108 |
public static final String EXTENT="Extent"; |
109 |
public static final String EXTENT_MULTIPLE_VALUES="multipleValues";
|
|
110 |
public static final String EXTENT_NEAREST_VALUES="nearestValues";
|
|
109 |
public static final String EXTENT_MULTIPLE_VALUES = "multipleValues";
|
|
110 |
public static final String EXTENT_NEAREST_VALUE = "nearestValue";
|
|
111 | 111 |
public static final String EXTENT_CURRENT="current"; |
112 | 112 |
|
113 | 113 |
|
... | ... | |
116 | 116 |
public static final String WCS_CONTENTMETADATA = "ContentMetadata"; |
117 | 117 |
public static final String WCS_LABEL = "label"; |
118 | 118 |
public static final String WCS_KEYWORDS = "keywords"; |
119 |
public static final String WCS_DESCRIPTION = "description"; |
|
119 | 120 |
public static final String DESCRIBECOVERAGE = "DescribeCoverage"; |
120 | 121 |
public static final String GETCOVERAGE = "GetCoverage"; |
121 | 122 |
public static final String WCS_COVERAGEOFFERING = "CoverageOffering"; |
... | ... | |
128 | 129 |
|
129 | 130 |
|
130 | 131 |
|
132 |
|
|
131 | 133 |
|
132 | 134 |
|
133 | 135 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/OGCProtocolHandler.java | ||
---|---|---|
50 | 50 |
import java.net.URL; |
51 | 51 |
import java.net.UnknownHostException; |
52 | 52 |
|
53 |
import com.devx.io.TempFileManager; |
|
54 |
|
|
55 | 53 |
public abstract class OGCProtocolHandler { |
56 | 54 |
/** |
57 | 55 |
* procotol handler name |
... | ... | |
119 | 117 |
this.version = version; |
120 | 118 |
} |
121 | 119 |
|
122 |
protected File downloadFile(URL url, String fileName) throws IOException,ConnectException, UnknownHostException{ |
|
123 |
File f = null; |
|
120 |
// /** |
|
121 |
// * @deprectated |
|
122 |
// * (temporarily) |
|
123 |
// */ |
|
124 |
// protected File downloadFile(URL url, String fileName) throws IOException,ConnectException, UnknownHostException{ |
|
125 |
// File f = null; |
|
126 |
// |
|
127 |
// try{ |
|
128 |
// f = TempFileManager.createTempFile(fileName, "tmp"); |
|
129 |
// System.out.println("downloading '"+url.toString()+"' to: "+f.getAbsolutePath()); |
|
130 |
// |
|
131 |
// f.deleteOnExit(); |
|
132 |
// |
|
133 |
// } catch (IOException io) { |
|
134 |
// io.printStackTrace(); |
|
135 |
// } |
|
136 |
// DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(f))); |
|
137 |
// byte[] buffer = new byte[1024*256]; |
|
138 |
// InputStream is = url.openStream(); |
|
139 |
// long readed = 0; |
|
140 |
// for (int i = is.read(buffer); i>0; i = is.read(buffer)){ |
|
141 |
// dos.write(buffer, 0, i); |
|
142 |
// readed += i; |
|
143 |
// } |
|
144 |
// dos.close(); |
|
145 |
// /*if (!isNotAnException(f)) |
|
146 |
// // SI que es una excepci?n |
|
147 |
// throw new ServerErrorResponseException();*/ |
|
148 |
// return f; |
|
149 |
// } |
|
124 | 150 |
|
125 |
try{ |
|
126 |
f = TempFileManager.createTempFile(fileName, "tmp"); |
|
127 |
System.out.println("downloading '"+url.toString()+"' to: "+f.getAbsolutePath()); |
|
128 |
|
|
129 |
f.deleteOnExit(); |
|
130 |
|
|
131 |
} catch (IOException io) { |
|
132 |
io.printStackTrace(); |
|
133 |
} |
|
134 |
DataOutputStream dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(f))); |
|
135 |
byte[] buffer = new byte[1024*256]; |
|
136 |
InputStream is = url.openStream(); |
|
137 |
long readed = 0; |
|
138 |
for (int i = is.read(buffer); i>0; i = is.read(buffer)){ |
|
139 |
dos.write(buffer, 0, i); |
|
140 |
readed += i; |
|
141 |
} |
|
142 |
dos.close(); |
|
143 |
/*if (!isNotAnException(f)) |
|
144 |
// SI que es una excepci?n |
|
145 |
throw new ServerErrorResponseException();*/ |
|
146 |
return f; |
|
147 |
} |
|
148 |
|
|
149 | 151 |
|
150 | 152 |
/** |
151 | 153 |
* parses the data retrieved by the Capabilities XML document |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wcs/WCSLayer.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.gvsig.remoteClient.ILayer; |
|
51 |
import org.gvsig.remoteClient.utils.BoundaryBox; |
|
52 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
|
53 |
import org.kxml2.io.KXmlParser; |
|
54 |
import org.xmlpull.v1.XmlPullParserException; |
|
55 |
|
|
56 |
/** |
|
57 |
* @author jaume |
|
58 |
* |
|
59 |
*/ |
|
60 |
public abstract class WCSLayer implements ILayer{ |
|
61 |
public static final String SEPARATOR = " +"; // separator used to split list of values, usually is just a space |
|
62 |
private String name; |
|
63 |
private String title; |
|
64 |
private String _abstract; |
|
65 |
private Hashtable bBoxes = new Hashtable(); |
|
66 |
private BoundaryBox lonLatBbox; |
|
67 |
public RectifiedGrid rg; |
|
68 |
public ArrayList timePositions = new ArrayList(); |
|
69 |
public String timePeriod; |
|
70 |
private String rangeSetName; |
|
71 |
private String rangeSetLabel; |
|
72 |
public Hashtable axisPool = new Hashtable(); |
|
73 |
private String nativeSRS; |
|
74 |
private ArrayList supportedSRSs = new ArrayList(); |
|
75 |
private String nativeFormat; |
|
76 |
private ArrayList formats = new ArrayList(); |
|
77 |
|
|
78 |
public ArrayList getFormats() { |
|
79 |
return formats; |
|
80 |
} |
|
81 |
|
|
82 |
public void addFormat(String format) { |
|
83 |
formats.add(format); |
|
84 |
} |
|
85 |
public void setNativeFormat(String nativeFormat) { |
|
86 |
this.nativeFormat = nativeFormat; |
|
87 |
} |
|
88 |
|
|
89 |
public String getNativeFormat() { |
|
90 |
return nativeFormat; |
|
91 |
} |
|
92 |
|
|
93 |
public String getNativeSRS() { |
|
94 |
return nativeSRS; |
|
95 |
} |
|
96 |
|
|
97 |
public void setNativeSRS(String nativeSRS) { |
|
98 |
this.nativeSRS = nativeSRS; |
|
99 |
} |
|
100 |
|
|
101 |
public ArrayList getSRSs() { |
|
102 |
return supportedSRSs; |
|
103 |
} |
|
104 |
|
|
105 |
public void addSRSs(String srs) { |
|
106 |
supportedSRSs.add(srs); |
|
107 |
} |
|
108 |
|
|
109 |
public String getRangeSetLabel() { |
|
110 |
return rangeSetLabel; |
|
111 |
} |
|
112 |
|
|
113 |
public void setRangeSetLabel(String rangeSetLabel) { |
|
114 |
this.rangeSetLabel = rangeSetLabel; |
|
115 |
} |
|
116 |
|
|
117 |
public String getRangeSetName() { |
|
118 |
return rangeSetName; |
|
119 |
} |
|
120 |
|
|
121 |
public void setRangeSetName(String rangeSetName) { |
|
122 |
this.rangeSetName = rangeSetName; |
|
123 |
} |
|
124 |
|
|
125 |
/* (non-Javadoc) |
|
126 |
* @see org.gvsig.remoteClient.ILayer#getName() |
|
127 |
*/ |
|
128 |
public String getName() { |
|
129 |
return name; |
|
130 |
} |
|
131 |
|
|
132 |
/* (non-Javadoc) |
|
133 |
* @see org.gvsig.remoteClient.ILayer#setName(java.lang.String) |
|
134 |
*/ |
|
135 |
public void setName(String _name) { |
|
136 |
name = _name; |
|
137 |
} |
|
138 |
|
|
139 |
/* (non-Javadoc) |
|
140 |
* @see org.gvsig.remoteClient.ILayer#setTitle(java.lang.String) |
|
141 |
*/ |
|
142 |
public void setTitle(String _title) { |
|
143 |
title = _title; |
|
144 |
} |
|
145 |
|
|
146 |
/* (non-Javadoc) |
|
147 |
* @see org.gvsig.remoteClient.ILayer#getTitle() |
|
148 |
*/ |
|
149 |
public String getTitle() { |
|
150 |
return title; |
|
151 |
} |
|
152 |
|
|
153 |
/* (non-Javadoc) |
|
154 |
* @see org.gvsig.remoteClient.ILayer#getAbstract() |
|
155 |
*/ |
|
156 |
public String getAbstract() { |
|
157 |
return _abstract; |
|
158 |
} |
|
159 |
|
|
160 |
/* (non-Javadoc) |
|
161 |
* @see org.gvsig.remoteClient.ILayer#setAbstract(java.lang.String) |
|
162 |
*/ |
|
163 |
public void setAbstract(String _abstract) { |
|
164 |
this._abstract = _abstract; |
|
165 |
} |
|
166 |
|
|
167 |
public void addBBox(BoundaryBox bBox) { |
|
168 |
bBoxes.put(bBox.getSrs(), bBox); |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* <p>returns the bbox with that id in the Bboxes vector</p> |
|
173 |
* @param id |
|
174 |
*/ |
|
175 |
public BoundaryBox getBbox(String id) { |
|
176 |
if ((id.compareToIgnoreCase( CapabilitiesTags.EPSG_4326 )==0) |
|
177 |
||(id.compareToIgnoreCase( CapabilitiesTags.CRS_84)==0)) |
|
178 |
{ |
|
179 |
if (lonLatBbox != null) |
|
180 |
return lonLatBbox; |
|
181 |
} |
|
182 |
|
|
183 |
return (BoundaryBox)bBoxes.get(id); |
|
184 |
} |
|
185 |
|
|
186 |
public BoundaryBox getLatLonBox() |
|
187 |
{ |
|
188 |
return lonLatBbox; |
|
189 |
} |
|
190 |
|
|
191 |
public void setLonLatBox(BoundaryBox box) |
|
192 |
{ |
|
193 |
lonLatBbox = box; |
|
194 |
} |
|
195 |
|
|
196 |
/** |
|
197 |
* Parses the fragment of the XML document that describes this layer (or coverage) |
|
198 |
* @param parser |
|
199 |
* @throws IOException |
|
200 |
* @throws XmlPullParserException |
|
201 |
*/ |
|
202 |
public abstract void parse(KXmlParser parser) throws XmlPullParserException, IOException; |
|
203 |
|
|
204 |
public class RectifiedGrid { |
|
205 |
private int dimensions; |
|
206 |
private String[] axisNames; |
|
207 |
private int[][] lowGridEnvelopLimits; |
|
208 |
private int[][] highGridEnvelopLimits; |
|
209 |
private double[] origins; |
|
210 |
private double[][] offsetVector; |
|
211 |
|
|
212 |
public RectifiedGrid(int dimensions) { |
|
213 |
this.dimensions = dimensions; |
|
214 |
} |
|
215 |
|
|
216 |
public void addAxisName(String axisName) { |
|
217 |
if (axisNames == null) { |
|
218 |
axisNames = new String[1]; |
|
219 |
axisNames[0] = axisName; |
|
220 |
} else { |
|
221 |
String[] aux = axisNames; |
|
222 |
axisNames = new String[axisNames.length+1]; |
|
223 |
for (int i = 0; i < aux.length; i++) { |
|
224 |
axisNames[i] = aux[i]; |
|
225 |
} |
|
226 |
axisNames[axisNames.length-1] = axisName; |
|
227 |
} |
|
228 |
} |
|
229 |
|
|
230 |
public String[] getAxisNames() { |
|
231 |
return axisNames; |
|
232 |
} |
|
233 |
|
|
234 |
public void addLowGridEnvelopLimit(int[] lowLimit) { |
|
235 |
if (lowGridEnvelopLimits == null) { |
|
236 |
lowGridEnvelopLimits = new int[1][1]; |
|
237 |
lowGridEnvelopLimits[0] = lowLimit; |
|
238 |
} else { |
|
239 |
int[][] aux = lowGridEnvelopLimits; |
|
240 |
lowGridEnvelopLimits = new int[lowGridEnvelopLimits.length+1][1]; |
|
241 |
for (int i = 0; i < aux.length; i++) { |
|
242 |
lowGridEnvelopLimits[i] = aux[i]; |
|
243 |
} |
|
244 |
lowGridEnvelopLimits[lowGridEnvelopLimits.length-1] = lowLimit; |
|
245 |
} |
|
246 |
} |
|
247 |
|
|
248 |
public int[][] getLowGridEnvelopLimits() { |
|
249 |
return lowGridEnvelopLimits; |
|
250 |
} |
|
251 |
|
|
252 |
public void addHighGridEnvelopLimit(int[] highLimit) { |
|
253 |
if (highGridEnvelopLimits == null) { |
|
254 |
highGridEnvelopLimits = new int[1][1]; |
|
255 |
highGridEnvelopLimits[0] = highLimit; |
|
256 |
} else { |
|
257 |
int[][] aux = highGridEnvelopLimits; |
|
258 |
highGridEnvelopLimits = new int[highGridEnvelopLimits.length+1][1]; |
|
259 |
for (int i = 0; i < aux.length; i++) { |
|
260 |
highGridEnvelopLimits[i] = aux[i]; |
|
261 |
} |
|
262 |
highGridEnvelopLimits[highGridEnvelopLimits.length-1] = highLimit; |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
public int[][] getHighGridEnvelopLimits() { |
|
267 |
return highGridEnvelopLimits; |
|
268 |
} |
|
269 |
|
|
270 |
public void setOrigin(double[] _origins) { |
|
271 |
origins = _origins; |
|
272 |
} |
|
273 |
|
|
274 |
public double[] getOrigins() { |
|
275 |
return origins; |
|
276 |
} |
|
277 |
|
|
278 |
public void addToOffsetVector(double[] _offsetVector) { |
|
279 |
if (offsetVector == null) { |
|
280 |
offsetVector = new double[1][1]; |
|
281 |
offsetVector[0] = _offsetVector; |
|
282 |
} else { |
|
283 |
double[][] aux = offsetVector; |
|
284 |
offsetVector = new double[offsetVector.length+1][1]; |
|
285 |
for (int i = 0; i < aux.length; i++) { |
|
286 |
offsetVector[i] = aux[i]; |
|
287 |
} |
|
288 |
offsetVector[offsetVector.length-1] = _offsetVector; |
|
289 |
} |
|
290 |
} |
|
291 |
|
|
292 |
public double[][] getOffsetVector(){ |
|
293 |
return offsetVector; |
|
294 |
} |
|
295 |
|
|
296 |
public int getDimensionCount() { |
|
297 |
return dimensions; |
|
298 |
} |
|
299 |
} |
|
300 |
|
|
301 |
public class AxisDescription { |
|
302 |
private String name; |
|
303 |
private String label; |
|
304 |
private ArrayList singleValues = new ArrayList(); |
|
305 |
private String interval; |
|
306 |
private String defaultValue; |
|
307 |
|
|
308 |
public String getDefaultValue() { |
|
309 |
return defaultValue; |
|
310 |
} |
|
311 |
|
|
312 |
public void setDefaultValue(String defaultValue) { |
|
313 |
this.defaultValue = defaultValue; |
|
314 |
} |
|
315 |
|
|
316 |
public String getInterval() { |
|
317 |
return interval; |
|
318 |
} |
|
319 |
|
|
320 |
public void setInterval(String interval) { |
|
321 |
this.interval = interval; |
|
322 |
} |
|
323 |
|
|
324 |
public String getLabel() { |
|
325 |
return label; |
|
326 |
} |
|
327 |
public void setLabel(String label) { |
|
328 |
this.label = label; |
|
329 |
} |
|
330 |
|
|
331 |
public String getName() { |
|
332 |
return name; |
|
333 |
} |
|
334 |
|
|
335 |
public void setName(String name) { |
|
336 |
this.name = name; |
|
337 |
} |
|
338 |
|
|
339 |
public ArrayList getSingleValues() { |
|
340 |
return singleValues; |
|
341 |
} |
|
342 |
|
|
343 |
public void addSingleValues(String singleValue) { |
|
344 |
this.singleValues.add(singleValue); |
|
345 |
} |
|
346 |
|
|
347 |
|
|
348 |
} |
|
349 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wcs/WCSStatus.java | ||
---|---|---|
41 | 41 |
/* |
42 | 42 |
* $Id$ |
43 | 43 |
* $Log$ |
44 |
* Revision 1.1 2006-03-06 15:18:32 jaume
|
|
44 |
* Revision 1.2 2006-03-15 08:54:42 jaume
|
|
45 | 45 |
* *** empty log message *** |
46 |
* |
|
47 |
* Revision 1.1.2.1 2006/03/08 09:08:31 jaume |
|
48 |
* *** empty log message *** |
|
49 |
* |
|
50 |
* Revision 1.1 2006/03/06 15:18:32 jaume |
|
51 |
* *** empty log message *** |
|
46 | 52 |
* |
47 | 53 |
*/ |
48 | 54 |
package org.gvsig.remoteClient.wcs; |
49 | 55 |
|
56 |
import java.awt.geom.Rectangle2D; |
|
57 |
|
|
50 | 58 |
import org.gvsig.remoteClient.RemoteClientStatus; |
51 | 59 |
|
52 | 60 |
public class WCSStatus extends RemoteClientStatus { |
... | ... | |
54 | 62 |
private String time; |
55 | 63 |
private String parameter; |
56 | 64 |
private String resolution; |
65 |
private Rectangle2D bBox; |
|
66 |
private String coverageName; |
|
67 |
private String onlineResource; |
|
57 | 68 |
|
69 |
public void setExtent(Rectangle2D bBox) { |
|
70 |
this.bBox = bBox; |
|
71 |
} |
|
72 |
|
|
73 |
|
|
74 |
public void setCoveraName(String coverageName) { |
|
75 |
this.coverageName = coverageName; |
|
76 |
} |
|
77 |
|
|
78 |
|
|
79 |
public void setParameters(String parameters) { |
|
80 |
this.parameter = parameters; |
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
public void setOnlineResource(String onlineResources) { |
|
85 |
this.onlineResource = onlineResources; |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
public String getOnlineResource() { |
|
90 |
return onlineResource; |
|
91 |
} |
|
92 |
|
|
58 | 93 |
} |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wcs/WCSProtocolHandlerFactory.java | ||
---|---|---|
41 | 41 |
/* |
42 | 42 |
* $Id$ |
43 | 43 |
* $Log$ |
44 |
* Revision 1.1 2006-03-06 15:18:32 jaume
|
|
44 |
* Revision 1.2 2006-03-15 08:54:42 jaume
|
|
45 | 45 |
* *** empty log message *** |
46 |
* |
|
47 |
* Revision 1.1.2.1 2006/03/08 09:08:31 jaume |
|
48 |
* *** empty log message *** |
|
49 |
* |
|
50 |
* Revision 1.1 2006/03/06 15:18:32 jaume |
|
51 |
* *** empty log message *** |
|
46 | 52 |
* |
47 | 53 |
*/ |
48 | 54 |
package org.gvsig.remoteClient.wcs; |
... | ... | |
211 | 217 |
kxmlParser.setInput(reader); |
212 | 218 |
kxmlParser.nextTag(); |
213 | 219 |
if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT ) { |
214 |
if ((kxmlParser.getName().compareTo(CapabilitiesTags.CAPABILITIES_ROOT1_1_0)==0) |
|
215 |
||(kxmlParser.getName().compareTo(CapabilitiesTags.CAPABILITIES_ROOT1_1_1)==0) |
|
216 |
||(kxmlParser.getName().compareTo(CapabilitiesTags.CAPABILITIES_ROOT1_3_0)==0)) { |
|
220 |
if ((kxmlParser.getName().compareTo(CapabilitiesTags.WCS_CAPABILITIES_ROOT1_0_0)==0)) { |
|
217 | 221 |
version = kxmlParser.getAttributeValue("", CapabilitiesTags.VERSION); |
218 | 222 |
} |
219 | 223 |
} |
... | ... | |
255 | 259 |
try { |
256 | 260 |
Class driver; |
257 | 261 |
version = version.replace('.', '_'); |
258 |
driver = Class.forName("org.gvsig.remoteClient.wcs.wcs_"+version+".WMSProtocolHandler" + version);
|
|
262 |
driver = Class.forName("org.gvsig.remoteClient.wcs.wcs_"+version+".WCSProtocolHandler" + version);
|
|
259 | 263 |
return (WCSProtocolHandler)driver.newInstance(); |
260 | 264 |
} catch (Exception e) { |
261 | 265 |
e.printStackTrace(); |
trunk/libraries/libRemoteServices/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.gvsig.remoteClient.ILayer; |
|
51 |
import org.gvsig.remoteClient.utils.BoundaryBox; |
|
52 |
import org.gvsig.remoteClient.utils.CapabilitiesTags; |
|
53 |
import org.kxml2.io.KXmlParser; |
|
54 |
import org.xmlpull.v1.XmlPullParserException; |
|
55 |
|
|
56 |
/** |
|
57 |
* @author jaume |
|
58 |
* |
|
59 |
*/ |
|
60 |
public abstract class WCSCoverage implements ILayer{ |
|
61 |
public static final String SEPARATOR = " +"; // separator used to split list of values, usually is just a space |
|
62 |
private String name; |
|
63 |
private String title; |
|
64 |
private String _abstract; |
|
65 |
private Hashtable bBoxes = new Hashtable(); |
|
66 |
private BoundaryBox lonLatBbox; |
|
67 |
public RectifiedGrid rg; |
|
68 |
private ArrayList timePositions = new ArrayList(); |
|
69 |
public String timePeriod; |
|
70 |
private String rangeSetName; |
|
71 |
private String rangeSetLabel; |
|
72 |
public Hashtable axisPool = new Hashtable(); |
|
73 |
private String nativeSRS; |
|
74 |
private ArrayList supportedSRSs = new ArrayList(); |
|
75 |
private String nativeFormat; |
|
76 |
private ArrayList formats = new ArrayList(); |
|
77 |
|
|
78 |
public ArrayList getTimePositions() { |
|
79 |
return timePositions; |
|
80 |
} |
|
81 |
|
|
82 |
public void addTimePosition(String timeExpr) { |
|
83 |
if (timePositions == null) |
|
84 |
timePositions = new ArrayList(); |
|
85 |
timePositions.add(timeExpr); |
|
86 |
} |
|
87 |
|
|
88 |
public ArrayList getFormats() { |
|
89 |
return formats; |
|
90 |
} |
|
91 |
|
|
92 |
public void addFormat(String format) { |
|
93 |
formats.add(format); |
|
94 |
} |
|
95 |
|
|
96 |
public void setNativeFormat(String nativeFormat) { |
|
97 |
this.nativeFormat = nativeFormat; |
|
98 |
} |
|
99 |
|
|
100 |
public String getNativeFormat() { |
|
101 |
return nativeFormat; |
|
102 |
} |
|
103 |
|
|
104 |
public String getNativeSRS() { |
|
105 |
return nativeSRS; |
|
106 |
} |
|
107 |
|
|
108 |
public void setNativeSRS(String nativeSRS) { |
|
109 |
this.nativeSRS = nativeSRS; |
|
110 |
} |
|
111 |
|
|
112 |
public ArrayList getSRSs() { |
|
113 |
return supportedSRSs; |
|
114 |
} |
|
115 |
|
|
116 |
public void addSRSs(String srs) { |
|
117 |
supportedSRSs.add(srs); |
|
118 |
} |
|
119 |
|
|
120 |
public String getRangeSetLabel() { |
|
121 |
return rangeSetLabel; |
|
122 |
} |
|
123 |
|
|
124 |
public void setRangeSetLabel(String rangeSetLabel) { |
|
125 |
this.rangeSetLabel = rangeSetLabel; |
|
126 |
} |
|
127 |
|
|
128 |
public String getRangeSetName() { |
|
129 |
return rangeSetName; |
|
130 |
} |
|
131 |
|
|
132 |
public void setRangeSetName(String rangeSetName) { |
|
133 |
this.rangeSetName = rangeSetName; |
|
134 |
} |
|
135 |
|
|
136 |
/* (non-Javadoc) |
|
137 |
* @see org.gvsig.remoteClient.ILayer#getName() |
|
138 |
*/ |
|
139 |
public String getName() { |
|
140 |
return name; |
|
141 |
} |
|
142 |
|
|
143 |
/* (non-Javadoc) |
|
144 |
* @see org.gvsig.remoteClient.ILayer#setName(java.lang.String) |
|
145 |
*/ |
|
146 |
public void setName(String _name) { |
|
147 |
name = _name; |
|
148 |
} |
|
149 |
|
|
150 |
/* (non-Javadoc) |
|
151 |
* @see org.gvsig.remoteClient.ILayer#setTitle(java.lang.String) |
|
152 |
*/ |
|
153 |
public void setTitle(String _title) { |
|
154 |
title = _title; |
|
155 |
} |
|
156 |
|
|
157 |
/* (non-Javadoc) |
|
158 |
* @see org.gvsig.remoteClient.ILayer#getTitle() |
|
159 |
*/ |
|
160 |
public String getTitle() { |
|
161 |
return title; |
|
162 |
} |
|
163 |
|
|
164 |
/* (non-Javadoc) |
|
165 |
* @see org.gvsig.remoteClient.ILayer#getAbstract() |
|
166 |
*/ |
|
167 |
public String getAbstract() { |
|
168 |
return _abstract; |
|
169 |
} |
|
170 |
|
|
171 |
/* (non-Javadoc) |
|
172 |
* @see org.gvsig.remoteClient.ILayer#setAbstract(java.lang.String) |
|
173 |
*/ |
|
174 |
public void setAbstract(String _abstract) { |
|
175 |
this._abstract = _abstract; |
|
176 |
} |
|
177 |
|
|
178 |
public void addBBox(BoundaryBox bBox) { |
|
179 |
bBoxes.put(bBox.getSrs(), bBox); |
|
180 |
} |
|
181 |
|
|
182 |
public ArrayList getAllSrs() { |
|
183 |
ArrayList mySrs = new ArrayList(); |
|
184 |
mySrs.addAll(supportedSRSs); |
|
185 |
if (!mySrs.contains(nativeSRS)) |
|
186 |
mySrs.add(nativeSRS); |
|
187 |
return mySrs; |
|
188 |
} |
|
189 |
/** |
|
190 |
* <p>returns the bbox with that id in the Bboxes vector</p> |
|
191 |
* @param id |
|
192 |
*/ |
|
193 |
public BoundaryBox getBbox(String id) { |
|
194 |
if ((id.compareToIgnoreCase( CapabilitiesTags.EPSG_4326 )==0) |
|
195 |
||(id.compareToIgnoreCase( CapabilitiesTags.CRS_84)==0)) |
|
196 |
{ |
|
197 |
if (lonLatBbox != null) |
|
198 |
return lonLatBbox; |
|
199 |
} |
|
200 |
|
|
201 |
return (BoundaryBox)bBoxes.get(id); |
|
202 |
} |
|
203 |
|
|
204 |
public BoundaryBox getLatLonBox() |
|
205 |
{ |
|
206 |
return lonLatBbox; |
|
207 |
} |
|
208 |
|
|
209 |
public void setLonLatBox(BoundaryBox box) |
|
210 |
{ |
|
211 |
lonLatBbox = box; |
|
212 |
} |
|
213 |
|
|
214 |
/** |
|
215 |
* Parses the fragment of the XML document that describes this layer (or coverage) |
|
216 |
* @param parser |
|
217 |
* @throws IOException |
|
218 |
* @throws XmlPullParserException |
|
219 |
*/ |
|
220 |
public abstract void parse(KXmlParser parser) throws XmlPullParserException, IOException; |
|
221 |
|
|
222 |
public class RectifiedGrid { |
|
223 |
private int dimensions; |
|
224 |
private String[] axisNames; |
|
225 |
private int[][] lowGridEnvelopLimits; |
|
226 |
private int[][] highGridEnvelopLimits; |
|
227 |
private double[] origins; |
|
228 |
private double[][] offsetVector; |
|
229 |
|
|
230 |
public RectifiedGrid(int dimensions) { |
|
231 |
this.dimensions = dimensions; |
|
232 |
} |
|
233 |
|
|
234 |
public void addAxisName(String axisName) { |
|
235 |
if (axisNames == null) { |
|
236 |
axisNames = new String[1]; |
|
237 |
axisNames[0] = axisName; |
|
238 |
} else { |
|
239 |
String[] aux = axisNames; |
|
240 |
axisNames = new String[axisNames.length+1]; |
|
241 |
for (int i = 0; i < aux.length; i++) { |
|
242 |
axisNames[i] = aux[i]; |
|
243 |
} |
|
244 |
axisNames[axisNames.length-1] = axisName; |
|
245 |
} |
|
246 |
} |
|
247 |
|
|
248 |
public String[] getAxisNames() { |
|
249 |
return axisNames; |
|
250 |
} |
|
251 |
|
|
252 |
public void addLowGridEnvelopLimit(int[] lowLimit) { |
|
253 |
if (lowGridEnvelopLimits == null) { |
|
254 |
lowGridEnvelopLimits = new int[1][1]; |
|
255 |
lowGridEnvelopLimits[0] = lowLimit; |
|
256 |
} else { |
|
257 |
int[][] aux = lowGridEnvelopLimits; |
|
258 |
lowGridEnvelopLimits = new int[lowGridEnvelopLimits.length+1][1]; |
|
259 |
for (int i = 0; i < aux.length; i++) { |
|
260 |
lowGridEnvelopLimits[i] = aux[i]; |
|
261 |
} |
|
262 |
lowGridEnvelopLimits[lowGridEnvelopLimits.length-1] = lowLimit; |
|
263 |
} |
|
264 |
} |
|
265 |
|
|
266 |
public int[][] getLowGridEnvelopLimits() { |
|
267 |
return lowGridEnvelopLimits; |
|
268 |
} |
|
269 |
|
|
270 |
public void addHighGridEnvelopLimit(int[] highLimit) { |
|
271 |
if (highGridEnvelopLimits == null) { |
|
272 |
highGridEnvelopLimits = new int[1][1]; |
|
273 |
highGridEnvelopLimits[0] = highLimit; |
|
274 |
} else { |
|
275 |
int[][] aux = highGridEnvelopLimits; |
|
276 |
highGridEnvelopLimits = new int[highGridEnvelopLimits.length+1][1]; |
|
277 |
for (int i = 0; i < aux.length; i++) { |
|
278 |
highGridEnvelopLimits[i] = aux[i]; |
|
279 |
} |
|
280 |
highGridEnvelopLimits[highGridEnvelopLimits.length-1] = highLimit; |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
public int[][] getHighGridEnvelopLimits() { |
|
285 |
return highGridEnvelopLimits; |
|
286 |
} |
|
287 |
|
|
288 |
public void setOrigin(double[] _origins) { |
|
289 |
origins = _origins; |
|
290 |
} |
|
291 |
|
|
292 |
public double[] getOrigins() { |
|
293 |
return origins; |
|
294 |
} |
|
295 |
|
|
296 |
public void addToOffsetVector(double[] _offsetVector) { |
|
297 |
if (offsetVector == null) { |
|
298 |
offsetVector = new double[1][1]; |
|
299 |
offsetVector[0] = _offsetVector; |
|
300 |
} else { |
|
301 |
double[][] aux = offsetVector; |
|
302 |
offsetVector = new double[offsetVector.length+1][1]; |
|
303 |
for (int i = 0; i < aux.length; i++) { |
|
304 |
offsetVector[i] = aux[i]; |
|
305 |
} |
|
306 |
offsetVector[offsetVector.length-1] = _offsetVector; |
|
307 |
} |
|
308 |
} |
|
309 |
|
|
310 |
public double[][] getOffsetVector(){ |
|
311 |
return offsetVector; |
|
312 |
} |
|
313 |
|
|
314 |
public int getDimensionCount() { |
|
315 |
return dimensions; |
|
316 |
} |
|
317 |
} |
|
318 |
|
|
319 |
public class AxisDescription { |
|
320 |
private String name; |
|
321 |
private String label; |
|
322 |
private ArrayList singleValues = new ArrayList(); |
|
323 |
private String interval; |
|
324 |
private String defaultValue; |
|
325 |
|
|
326 |
public String getDefaultValue() { |
|
327 |
return defaultValue; |
|
328 |
} |
|
329 |
|
|
330 |
public void setDefaultValue(String defaultValue) { |
|
331 |
this.defaultValue = defaultValue; |
|
332 |
} |
|
333 |
|
|
334 |
public String getInterval() { |
|
335 |
return interval; |
|
336 |
} |
|
337 |
|
|
338 |
public void setInterval(String interval) { |
|
339 |
this.interval = interval; |
|
340 |
} |
|
341 |
|
|
342 |
public String getLabel() { |
|
343 |
return label; |
|
344 |
} |
|
345 |
public void setLabel(String label) { |
|
346 |
this.label = label; |
|
347 |
} |
|
348 |
|
|
349 |
public String getName() { |
|
350 |
return name; |
|
351 |
} |
|
352 |
|
|
353 |
public void setName(String name) { |
|
354 |
this.name = name; |
|
355 |
} |
|
356 |
|
|
357 |
public ArrayList getSingleValues() { |
|
358 |
return singleValues; |
|
359 |
} |
|
360 |
|
|
361 |
public void addSingleValues(String singleValue) { |
|
362 |
this.singleValues.add(singleValue); |
|
363 |
} |
|
364 |
} |
|
365 |
|
|
366 |
public double getResX() { |
|
367 |
return Math.abs(rg.offsetVector[0][0]); |
|
368 |
} |
|
369 |
|
|
370 |
public double getResY() { |
|
371 |
return Math.abs(rg.offsetVector[1][1]); |
|
372 |
} |
|
373 |
|
|
374 |
} |
|
0 | 375 |
trunk/libraries/libRemoteServices/src/org/gvsig/remoteClient/wcs/wcs_1_0_0/WCSLayer1_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.gvsig.remoteClient.utils.BoundaryBox; |
|
50 |
import org.gvsig.remoteClient.utils.DescribeCoverageTags; |
|
51 |
import org.gvsig.remoteClient.wcs.WCSLayer; |
|
52 |
import org.kxml2.io.KXmlParser; |
|
53 |
import org.xmlpull.v1.XmlPullParserException; |
|
54 |
|
|
55 |
/** |
|
56 |
* @author jaume |
|
57 |
* |
|
58 |
*/ |
|
59 |
public class WCSLayer1_0_0 extends WCSLayer{ |
|
60 |
|
|
61 |
|
|
62 |
/* (non-Javadoc) |
|
63 |
* @see org.gvsig.remoteClient.wcs.WCSLayer#parse(org.kxml2.io.KXmlParser) |
|
64 |
*/ |
|
65 |
public void parse(KXmlParser parser) throws XmlPullParserException, IOException { |
|
66 |
int currentTag; |
|
67 |
String value; |
|
68 |
boolean end = false; |
|
69 |
|
|
70 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.COVERAGE_OFFERING); |
|
71 |
currentTag = parser.next(); |
|
72 |
|
|
73 |
while (!end) |
|
74 |
{ |
|
75 |
switch(currentTag) |
|
76 |
{ |
|
77 |
case KXmlParser.START_TAG: |
|
78 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME)==0) |
|
79 |
{ |
|
80 |
value = parser.nextText(); |
|
81 |
if (value != null) setName(value); |
|
82 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LABEL)==0){ |
|
83 |
value = parser.nextText(); |
|
84 |
if (value != null) setTitle(value); |
|
85 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LONLAT_ENVELOPE)==0){ |
|
86 |
BoundaryBox bBox = parseLonLatGMLEnvelope(parser); |
|
87 |
bBox.setSrs(DescribeCoverageTags.WGS84); |
|
88 |
addBBox(bBox); |
|
89 |
setLonLatBox(bBox); |
|
90 |
} else if (parser.getName().compareTo(DescribeCoverageTags.DOMAINSET) == 0) { |
|
91 |
parseDomainSet(parser); |
|
92 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RANGESET) == 0) { |
|
93 |
parseRangeSet(parser); |
|
94 |
} else if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTEDCRSS) == 0) { |
|
95 |
parseSupportedCRSS(parser); |
|
96 |
} else if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTEDFORMATS) == 0) { |
|
97 |
setNativeFormat(parser.getAttributeValue("", DescribeCoverageTags.NATIVEFORMAT)); |
|
98 |
parser.nextTag(); |
|
99 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.FORMATS); |
|
100 |
String[] formats = parser.nextText().split(SEPARATOR); |
|
101 |
for (int i = 0; i < formats.length; i++) { |
|
102 |
addFormat(formats[i]); |
|
103 |
} |
|
104 |
} else { |
|
105 |
if (!parser.getName().equals("rangeSet")) // just a patch to avoid too much messages |
|
106 |
System.out.println("Skiped "+parser.getName()); |
|
107 |
} |
|
108 |
|
|
109 |
break; |
|
110 |
case KXmlParser.END_TAG: |
|
111 |
if (parser.getName().compareTo(DescribeCoverageTags.COVERAGE_OFFERING) == 0) |
|
112 |
end = true; |
|
113 |
break; |
|
114 |
case KXmlParser.TEXT: |
|
115 |
if (parser.getName()!=null) |
|
116 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
117 |
break; |
|
118 |
} |
|
119 |
currentTag = parser.next(); |
|
120 |
} |
|
121 |
|
|
122 |
|
|
123 |
} |
|
124 |
|
|
125 |
private void parseSupportedCRSS(KXmlParser parser) throws XmlPullParserException, IOException { |
|
126 |
int currentTag; |
|
127 |
boolean end = false; |
|
128 |
|
|
129 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.SUPPORTEDCRSS); |
|
130 |
currentTag = parser.next(); |
|
131 |
|
|
132 |
while (!end) |
|
133 |
{ |
|
134 |
switch(currentTag) |
|
135 |
{ |
|
136 |
case KXmlParser.START_TAG: |
|
137 |
if (parser.getName().compareTo(DescribeCoverageTags.REQUESTRESPONSECRSS)==0) { |
|
138 |
String[] values = parser.nextText().split(SEPARATOR); |
|
139 |
for (int i = 0; i < values.length; i++) { |
|
140 |
addSRSs(values[i]); |
|
141 |
} |
|
142 |
} |
|
143 |
else if (parser.getName().compareTo(DescribeCoverageTags.NATIVECRS) == 0) { |
|
144 |
setNativeSRS(parser.nextText()); |
|
145 |
} else if (parser.getName().compareTo(DescribeCoverageTags.REQUESTCRSS) == 0) { |
|
146 |
// TODO |
|
147 |
System.out.println("Skiped "+parser.getName()); |
|
148 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RESPONSECRSS) == 0) { |
|
149 |
// TODO |
|
150 |
System.out.println("Skiped "+parser.getName()); |
|
151 |
} else { |
|
152 |
System.out.println("Unrecognized "+parser.getName()); |
|
153 |
} |
|
154 |
|
|
155 |
break; |
|
156 |
case KXmlParser.END_TAG: |
|
157 |
if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTEDCRSS) == 0) |
|
158 |
end = true; |
|
159 |
break; |
|
160 |
case KXmlParser.TEXT: |
|
161 |
if (parser.getName()!=null) |
|
162 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
163 |
break; |
|
164 |
} |
|
165 |
currentTag = parser.next(); |
|
166 |
} |
|
167 |
} |
|
168 |
|
|
169 |
private void parseRangeSet(KXmlParser parser) throws XmlPullParserException, IOException { |
|
170 |
int currentTag; |
|
171 |
boolean end = false; |
|
172 |
|
|
173 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.RANGESET); |
|
174 |
currentTag = parser.next(); |
|
175 |
|
|
176 |
while (!end) |
|
177 |
{ |
|
178 |
switch(currentTag) |
|
179 |
{ |
|
180 |
case KXmlParser.START_TAG: |
|
181 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME)==0) |
|
182 |
setRangeSetName(parser.nextText()); |
|
183 |
else if (parser.getName().compareTo(DescribeCoverageTags.LABEL) == 0) |
|
184 |
setRangeSetLabel(parser.nextText()); |
|
185 |
else if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) { |
|
186 |
// Reading all axe description |
|
187 |
int axisTag = parser.nextTag(); |
|
188 |
boolean endAxe = false; |
|
189 |
while (!endAxe) { |
|
190 |
switch(axisTag) |
|
191 |
{ |
|
192 |
case KXmlParser.START_TAG: |
|
193 |
if (parser.getName().compareTo(DescribeCoverageTags.AXISDESCRIPTION)==0) { |
|
194 |
AxisDescription as = parseAxisDescription(parser); |
|
195 |
axisPool.put(as.getName(), as); |
|
196 |
} |
|
197 |
break; |
|
198 |
case KXmlParser.END_TAG: |
|
199 |
if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) |
|
200 |
endAxe = true; |
|
201 |
break; |
|
202 |
case KXmlParser.TEXT: |
|
203 |
if (parser.getName()!=null) |
|
204 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
205 |
break; |
|
206 |
} |
|
207 |
axisTag = parser.next(); |
|
208 |
} |
|
209 |
} else { |
|
210 |
System.out.println("Unrecognized "+parser.getName()); |
|
211 |
} |
|
212 |
break; |
|
213 |
case KXmlParser.END_TAG: |
|
214 |
if (parser.getName().compareTo(DescribeCoverageTags.RANGESET) == 0) |
|
215 |
end = true; |
|
216 |
break; |
|
217 |
case KXmlParser.TEXT: |
|
218 |
if (parser.getName()!=null) |
|
219 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
220 |
break; |
|
221 |
} |
|
222 |
currentTag = parser.next(); |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 |
private AxisDescription parseAxisDescription(KXmlParser parser) throws XmlPullParserException, IOException { |
|
227 |
int currentTag; |
|
228 |
boolean end = false; |
|
229 |
|
|
230 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.AXISDESCRIPTION); |
|
231 |
AxisDescription as = new AxisDescription(); |
|
232 |
currentTag = parser.next(); |
|
233 |
|
|
234 |
while (!end) |
|
235 |
{ |
|
236 |
switch(currentTag) |
|
237 |
{ |
|
238 |
case KXmlParser.START_TAG: |
|
239 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME) == 0) { |
|
240 |
as.setName(parser.nextText()); |
|
241 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LABEL) == 0) { |
|
242 |
as.setLabel(parser.nextText()); |
|
243 |
} else if (parser.getName().compareTo(DescribeCoverageTags.VALUES) == 0) { |
|
244 |
int valuesTag = parser.nextTag(); |
|
245 |
boolean valuesEnd = false; |
|
246 |
while (!valuesEnd) { |
|
247 |
switch(valuesTag) { |
|
248 |
case KXmlParser.START_TAG: |
|
249 |
if (parser.getName().compareTo(DescribeCoverageTags.SINGLEVALUE) == 0) { |
|
250 |
as.addSingleValues(parser.nextText()); |
|
251 |
} else if (parser.getName().compareTo(DescribeCoverageTags.INTERVAL) == 0) { |
|
252 |
as.setInterval(parser.nextText()); |
|
253 |
} else if (parser.getName().compareTo(DescribeCoverageTags.DEFAULT) == 0) { |
|
254 |
as.setDefaultValue(parser.nextText()); |
|
255 |
} |
|
256 |
break; |
|
257 |
case KXmlParser.END_TAG: |
|
258 |
if (parser.getName().compareTo(DescribeCoverageTags.VALUES) == 0) |
|
259 |
valuesEnd = true; |
|
260 |
break; |
|
261 |
case KXmlParser.TEXT: |
|
262 |
if (parser.getName()!=null) |
|
263 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
264 |
break; |
|
265 |
} |
|
266 |
valuesTag = parser.next(); |
|
267 |
} |
|
268 |
} else if (parser.getName().compareTo(DescribeCoverageTags.NULLVALUES)==0) { |
|
269 |
// TODO |
|
270 |
System.err.println("Missing NULL VALUE PARSING on WCS 1.0.0 Client"); |
|
271 |
} else { |
|
272 |
System.out.println("Unrecognized "+parser.getName()); |
|
273 |
} |
|
274 |
|
|
275 |
break; |
|
276 |
case KXmlParser.END_TAG: |
|
277 |
if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) |
|
278 |
end = true; |
|
279 |
break; |
|
280 |
case KXmlParser.TEXT: |
|
281 |
if (parser.getName()!=null) |
|
282 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
283 |
break; |
|
284 |
} |
|
285 |
currentTag = parser.next(); |
|
286 |
} |
|
287 |
return as; |
|
288 |
} |
|
289 |
|
|
290 |
private void parseDomainSet(KXmlParser parser) throws XmlPullParserException, IOException { |
|
291 |
int currentTag; |
|
292 |
boolean end = false; |
|
293 |
|
|
294 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.DOMAINSET); |
|
295 |
currentTag = parser.next(); |
|
296 |
|
|
297 |
while (!end) |
|
298 |
{ |
|
299 |
switch(currentTag) |
|
300 |
{ |
|
301 |
case KXmlParser.START_TAG: |
|
302 |
if (parser.getName().compareTo(DescribeCoverageTags.SPATIALDOMAIN)==0) |
|
303 |
{ |
|
304 |
parseSpatialDomain(parser); |
|
305 |
} else if (parser.getName().compareTo(DescribeCoverageTags.TEMPORALDOMAIN)==0) { |
|
306 |
parseTemporalDomain(parser); |
|
307 |
} |
|
308 |
break; |
|
309 |
case KXmlParser.END_TAG: |
|
310 |
if (parser.getName().compareTo(DescribeCoverageTags.DOMAINSET) == 0) |
|
311 |
end = true; |
|
312 |
break; |
|
313 |
case KXmlParser.TEXT: |
|
314 |
if (parser.getName()!=null) |
|
315 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
316 |
break; |
|
317 |
} |
|
318 |
currentTag = parser.next(); |
|
319 |
} |
|
320 |
} |
|
321 |
|
|
322 |
private void parseTemporalDomain(KXmlParser parser) throws XmlPullParserException, IOException { |
|
323 |
int currentTag; |
|
324 |
boolean end = false; |
|
325 |
|
|
326 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.TEMPORALDOMAIN); |
|
327 |
currentTag = parser.next(); |
|
328 |
|
|
329 |
while (!end) |
|
330 |
{ |
|
331 |
switch(currentTag) |
|
332 |
{ |
|
333 |
case KXmlParser.START_TAG: |
|
334 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_TIMEPOSITION) == 0) { |
|
335 |
timePositions.add(parser.nextText()); |
|
336 |
} else if (parser.getName().compareTo(DescribeCoverageTags.TIMEPERIOD) == 0) { |
|
337 |
boolean timePeriodEnd = false; |
|
338 |
int timePeriodTag = parser.next(); |
|
339 |
String[] timePeriod = new String[3]; |
|
340 |
while (!timePeriodEnd) { |
|
341 |
switch (timePeriodTag) { |
|
342 |
case KXmlParser.START_TAG: |
|
343 |
if (parser.getName().compareTo(DescribeCoverageTags.BEGINPOSITION) == 0) { |
|
344 |
timePeriod[0] = parser.nextText(); |
|
345 |
} else if (parser.getName().compareTo(DescribeCoverageTags.ENDPOSITION) == 0) { |
|
346 |
timePeriod[1] = parser.nextText(); |
|
347 |
} else if (parser.getName().compareTo(DescribeCoverageTags.TIMERESOLUTION) == 0) { |
|
348 |
timePeriod[2] = parser.nextText(); |
|
349 |
} else { |
|
350 |
System.out.println("Unrecognized "+parser.getName()); |
|
351 |
} |
|
352 |
break; |
|
353 |
case KXmlParser.END_TAG: |
|
354 |
if (parser.getName().compareTo(DescribeCoverageTags.TEMPORALDOMAIN) == 0) |
|
355 |
end = true; |
|
356 |
break; |
|
357 |
case KXmlParser.TEXT: |
|
358 |
if (parser.getName()!=null) |
|
359 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
360 |
break; |
|
361 |
} |
|
362 |
timePeriodTag = parser.next(); |
|
363 |
} |
|
364 |
super.timePeriod = ""; |
|
365 |
for (int i = 0; i < timePeriod.length-1; i++) { |
|
366 |
if (timePeriod[i]!=null) { |
|
367 |
super.timePeriod += timePeriod[i]; |
|
368 |
} |
|
369 |
if (timePeriod[i+1]!=null) { |
|
370 |
super.timePeriod += "/"; |
|
371 |
} |
|
372 |
} |
|
373 |
} else { |
|
374 |
System.out.println("Unrecognized "+parser.getName()); |
|
375 |
} |
|
376 |
break; |
|
377 |
case KXmlParser.END_TAG: |
|
378 |
if (parser.getName().compareTo(DescribeCoverageTags.TEMPORALDOMAIN) == 0) |
|
379 |
end = true; |
|
380 |
break; |
|
381 |
case KXmlParser.TEXT: |
|
382 |
if (parser.getName()!=null) |
|
383 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
384 |
break; |
|
385 |
} |
|
386 |
currentTag = parser.next(); |
|
387 |
} |
|
388 |
} |
|
389 |
|
|
390 |
private void parseSpatialDomain(KXmlParser parser) throws XmlPullParserException, IOException { |
|
391 |
int currentTag; |
|
392 |
boolean end = false; |
|
393 |
|
|
394 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.SPATIALDOMAIN); |
|
395 |
currentTag = parser.next(); |
|
396 |
|
|
397 |
while (!end) |
|
398 |
{ |
|
399 |
switch(currentTag) |
|
400 |
{ |
|
401 |
case KXmlParser.START_TAG: |
|
402 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_ENVELOPE)==0) { |
|
403 |
BoundaryBox bBox = parseGMLEnvelope(parser); |
|
404 |
addBBox(bBox); |
|
405 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RECTIFIEDGRID)==0) { |
|
406 |
parseRectifiedGrid(parser); |
|
407 |
} else { |
|
408 |
System.out.println("Unrecognized "+parser.getName()); |
|
409 |
} |
|
410 |
break; |
|
411 |
case KXmlParser.END_TAG: |
|
412 |
if (parser.getName().compareTo(DescribeCoverageTags.SPATIALDOMAIN) == 0) |
|
413 |
end = true; |
|
414 |
break; |
|
415 |
case KXmlParser.TEXT: |
|
416 |
if (parser.getName()!=null) |
|
417 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
418 |
break; |
|
419 |
} |
|
420 |
currentTag = parser.next(); |
|
421 |
} |
|
422 |
} |
|
423 |
|
|
424 |
private void parseRectifiedGrid(KXmlParser parser) throws XmlPullParserException, IOException { |
|
425 |
int currentTag; |
|
426 |
String value; |
|
427 |
boolean end = false; |
|
428 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.RECTIFIEDGRID); |
|
429 |
rg = new RectifiedGrid(Integer.parseInt(parser.getAttributeValue("", DescribeCoverageTags.DIMENSION))); |
|
430 |
|
|
431 |
currentTag = parser.next(); |
|
432 |
|
|
433 |
while (!end) |
|
434 |
{ |
|
435 |
switch(currentTag) |
|
436 |
{ |
|
437 |
case KXmlParser.START_TAG: |
|
438 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LIMITS) == 0) { |
|
439 |
parser.nextTag(); |
|
440 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_GRIDENVELOPE)==0) { |
|
441 |
boolean gridEnd = false; |
|
442 |
int gridCurrentTag = parser.next(); |
|
443 |
while (!gridEnd) |
|
444 |
{ |
|
445 |
switch (gridCurrentTag) { |
|
446 |
case KXmlParser.START_TAG: |
|
447 |
|
|
448 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LOW) == 0) { |
|
449 |
value = parser.nextText(); |
|
450 |
String[] ss = value.split(SEPARATOR); |
|
451 |
int[] limits = new int[ss.length]; |
|
452 |
for (int i = 0; i < limits.length; i++) { |
|
453 |
limits[i] = Integer.parseInt(ss[i]); |
|
454 |
} |
|
455 |
rg.addLowGridEnvelopLimit(limits); |
|
456 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_HIGH) == 0) { |
|
457 |
value = parser.nextText(); |
|
458 |
String[] ss = value.split(SEPARATOR); |
|
459 |
int[] limits = new int[ss.length]; |
|
460 |
for (int i = 0; i < limits.length; i++) { |
|
461 |
limits[i] = Integer.parseInt(ss[i]); |
|
462 |
} |
|
463 |
rg.addHighGridEnvelopLimit(limits); |
|
464 |
} else { |
|
465 |
System.out.println("Unrecognized "+parser.getName()); |
|
466 |
} |
|
467 |
break; |
|
468 |
case KXmlParser.END_TAG: |
|
469 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_GRIDENVELOPE) == 0) |
|
470 |
gridEnd = true; |
|
471 |
break; |
|
472 |
case KXmlParser.TEXT: |
|
473 |
if (parser.getName()!=null) |
|
474 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
475 |
break; |
|
476 |
} |
|
477 |
gridCurrentTag = parser.next(); |
|
478 |
} |
|
479 |
} |
|
480 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_AXISNAME)==0) { |
|
481 |
rg.addAxisName(parser.nextText()); |
|
482 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_ORIGIN)==0) { |
|
483 |
parser.nextTag(); |
|
484 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_POS)==0) { |
|
485 |
value = parser.nextText(); |
|
486 |
String[] ss = value.split(SEPARATOR); |
|
487 |
double[] ori = new double[ss.length]; |
|
488 |
for (int i = 0; i < ori.length; i++) { |
|
489 |
ori[i] = Double.parseDouble(ss[i]); |
|
490 |
} |
|
491 |
rg.setOrigin(ori); |
|
492 |
} |
|
493 |
} else if (parser.getName().compareTo(DescribeCoverageTags.OFFSETVECTOR) == 0) { |
|
494 |
value = parser.nextText(); |
|
495 |
String[] ss = value.split(SEPARATOR); |
|
496 |
double[] offset = new double[ss.length]; |
|
497 |
for (int i = 0; i < offset.length; i++) { |
|
498 |
offset[i] = Double.parseDouble(ss[i]); |
|
499 |
} |
|
500 |
rg.addToOffsetVector(offset); |
|
501 |
} else { |
|
502 |
System.out.println("Unrecognized "+parser.getName()); |
|
503 |
} |
|
504 |
break; |
|
505 |
case KXmlParser.END_TAG: |
|
506 |
if (parser.getName().compareTo(DescribeCoverageTags.RECTIFIEDGRID) == 0) |
|
507 |
end = true; |
|
508 |
break; |
|
509 |
case KXmlParser.TEXT: |
|
510 |
if (parser.getName()!=null) |
|
511 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
512 |
break; |
|
513 |
} |
|
514 |
currentTag = parser.next(); |
|
515 |
} |
|
516 |
} |
|
517 |
|
|
518 |
|
|
519 |
private BoundaryBox parseLonLatGMLEnvelope(KXmlParser parser) throws XmlPullParserException, IOException { |
|
520 |
BoundaryBox bBox = new BoundaryBox(); |
|
521 |
int currentTag; |
|
522 |
String value; |
|
523 |
boolean end = false; |
|
524 |
|
|
525 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.LONLAT_ENVELOPE); |
|
526 |
currentTag = parser.next(); |
|
527 |
|
|
528 |
while (!end) |
|
529 |
{ |
|
530 |
switch(currentTag) |
|
531 |
{ |
|
532 |
case KXmlParser.START_TAG: |
|
533 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_POS)==0) { |
|
534 |
bBox.setSrs(DescribeCoverageTags.WGS84); |
|
535 |
String[] coordinates; |
|
536 |
double minx, miny, maxx, maxy; |
|
537 |
value = parser.nextText(); |
|
538 |
coordinates = value.split(SEPARATOR); |
|
539 |
minx = Double.parseDouble(coordinates[0]); |
|
540 |
miny = Double.parseDouble(coordinates[1]); |
|
541 |
|
|
542 |
parser.nextTag(); |
|
543 |
|
|
544 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS); |
|
545 |
value = parser.nextText(); |
|
546 |
coordinates = value.split(SEPARATOR); |
|
547 |
maxx = Double.parseDouble(coordinates[0]); |
|
548 |
maxy = Double.parseDouble(coordinates[1]); |
Also available in: Unified diff