Revision 42216
tags/org.gvsig.desktop-2.0.100/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wcs/WCSCoverage.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wcs; |
|
25 |
|
|
26 |
import java.io.IOException; |
|
27 |
import java.util.ArrayList; |
|
28 |
import java.util.Hashtable; |
|
29 |
|
|
30 |
import org.kxml2.io.KXmlParser; |
|
31 |
import org.xmlpull.v1.XmlPullParserException; |
|
32 |
|
|
33 |
import org.gvsig.remoteclient.ILayer; |
|
34 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
|
35 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
36 |
|
|
37 |
/** |
|
38 |
* Describes a coverage in a WCS server. |
|
39 |
* |
|
40 |
* @author jaume dominguez faus - jaume.domingue@iver.es |
|
41 |
* |
|
42 |
*/ |
|
43 |
public abstract class WCSCoverage implements ILayer{ |
|
44 |
public static final String SEPARATOR = " +"; // separator used to split list of values, usually is just a space |
|
45 |
private String name; |
|
46 |
private String title; |
|
47 |
private String _abstract; |
|
48 |
private Hashtable bBoxes = new Hashtable(); |
|
49 |
private BoundaryBox lonLatBbox; |
|
50 |
public RectifiedGrid rg; |
|
51 |
private ArrayList timePositions = new ArrayList(); |
|
52 |
public String timePeriod; |
|
53 |
private String rangeSetName; |
|
54 |
private String rangeSetLabel; |
|
55 |
public Hashtable axisPool = new Hashtable(); |
|
56 |
private String nativeSRS; |
|
57 |
private ArrayList supportedSRSs = new ArrayList(); |
|
58 |
private ArrayList interpolationMethods; |
|
59 |
private String nativeFormat; |
|
60 |
private ArrayList formats = new ArrayList(); |
|
61 |
|
|
62 |
public ArrayList getTimePositions() { |
|
63 |
return timePositions; |
|
64 |
} |
|
65 |
|
|
66 |
public void addTimePosition(String timeExpr) { |
|
67 |
if (timePositions == null) |
|
68 |
timePositions = new ArrayList(); |
|
69 |
timePositions.add(timeExpr); |
|
70 |
} |
|
71 |
|
|
72 |
public ArrayList getFormats() { |
|
73 |
return formats; |
|
74 |
} |
|
75 |
|
|
76 |
public void addFormat(String format) { |
|
77 |
formats.add(format); |
|
78 |
} |
|
79 |
|
|
80 |
public void setNativeFormat(String nativeFormat) { |
|
81 |
this.nativeFormat = nativeFormat; |
|
82 |
} |
|
83 |
|
|
84 |
public String getNativeFormat() { |
|
85 |
return nativeFormat; |
|
86 |
} |
|
87 |
|
|
88 |
public String getNativeSRS() { |
|
89 |
return nativeSRS; |
|
90 |
} |
|
91 |
|
|
92 |
public void setNativeSRS(String nativeSRS) { |
|
93 |
this.nativeSRS = nativeSRS; |
|
94 |
} |
|
95 |
|
|
96 |
public ArrayList getSRSs() { |
|
97 |
return supportedSRSs; |
|
98 |
} |
|
99 |
|
|
100 |
public void addSRSs(String srs) { |
|
101 |
supportedSRSs.add(srs); |
|
102 |
} |
|
103 |
|
|
104 |
public String getRangeSetLabel() { |
|
105 |
return rangeSetLabel; |
|
106 |
} |
|
107 |
|
|
108 |
public void setRangeSetLabel(String rangeSetLabel) { |
|
109 |
this.rangeSetLabel = rangeSetLabel; |
|
110 |
} |
|
111 |
|
|
112 |
public String getRangeSetName() { |
|
113 |
return rangeSetName; |
|
114 |
} |
|
115 |
|
|
116 |
public void setRangeSetName(String rangeSetName) { |
|
117 |
this.rangeSetName = rangeSetName; |
|
118 |
} |
|
119 |
|
|
120 |
/* (non-Javadoc) |
|
121 |
* @see org.gvsig.remoteClient.ILayer#getName() |
|
122 |
*/ |
|
123 |
public String getName() { |
|
124 |
return name; |
|
125 |
} |
|
126 |
|
|
127 |
/* (non-Javadoc) |
|
128 |
* @see org.gvsig.remoteClient.ILayer#setName(java.lang.String) |
|
129 |
*/ |
|
130 |
public void setName(String _name) { |
|
131 |
name = _name; |
|
132 |
} |
|
133 |
|
|
134 |
/* (non-Javadoc) |
|
135 |
* @see org.gvsig.remoteClient.ILayer#setTitle(java.lang.String) |
|
136 |
*/ |
|
137 |
public void setTitle(String _title) { |
|
138 |
title = _title; |
|
139 |
} |
|
140 |
|
|
141 |
/* (non-Javadoc) |
|
142 |
* @see org.gvsig.remoteClient.ILayer#getTitle() |
|
143 |
*/ |
|
144 |
public String getTitle() { |
|
145 |
return title; |
|
146 |
} |
|
147 |
|
|
148 |
/* (non-Javadoc) |
|
149 |
* @see org.gvsig.remoteClient.ILayer#getAbstract() |
|
150 |
*/ |
|
151 |
public String getAbstract() { |
|
152 |
return _abstract; |
|
153 |
} |
|
154 |
|
|
155 |
/* (non-Javadoc) |
|
156 |
* @see org.gvsig.remoteClient.ILayer#setAbstract(java.lang.String) |
|
157 |
*/ |
|
158 |
public void setAbstract(String _abstract) { |
|
159 |
this._abstract = _abstract; |
|
160 |
} |
|
161 |
|
|
162 |
public void addBBox(BoundaryBox bBox) { |
|
163 |
bBoxes.put(bBox.getSrs(), bBox); |
|
164 |
} |
|
165 |
|
|
166 |
public ArrayList getAllSrs() { |
|
167 |
ArrayList mySrs = new ArrayList(); |
|
168 |
mySrs.addAll(supportedSRSs); |
|
169 |
if (!mySrs.contains(nativeSRS)) |
|
170 |
mySrs.add(nativeSRS); |
|
171 |
return mySrs; |
|
172 |
} |
|
173 |
/** |
|
174 |
* <p>returns the bbox with that id in the Bboxes vector</p> |
|
175 |
* @param id |
|
176 |
*/ |
|
177 |
public BoundaryBox getBbox(String id) { |
|
178 |
if ((id.compareToIgnoreCase( CapabilitiesTags.EPSG_4326 )==0) |
|
179 |
||(id.compareToIgnoreCase( CapabilitiesTags.CRS_84)==0)) |
|
180 |
{ |
|
181 |
if (lonLatBbox != null) |
|
182 |
return lonLatBbox; |
|
183 |
} |
|
184 |
|
|
185 |
return (BoundaryBox)bBoxes.get(id); |
|
186 |
} |
|
187 |
|
|
188 |
public BoundaryBox getLatLonBox() { |
|
189 |
return lonLatBbox; |
|
190 |
} |
|
191 |
|
|
192 |
public void setLonLatBox(BoundaryBox box) { |
|
193 |
lonLatBbox = box; |
|
194 |
} |
|
195 |
|
|
196 |
public void addInterpolationMethod(String method) { |
|
197 |
if (interpolationMethods==null) interpolationMethods = new ArrayList(); |
|
198 |
interpolationMethods.add(method); |
|
199 |
} |
|
200 |
|
|
201 |
public ArrayList getInterpolationMethods() { |
|
202 |
return interpolationMethods; |
|
203 |
} |
|
204 |
/** |
|
205 |
* Parses the fragment of the XML document that describes this layer (or coverage) |
|
206 |
* @param parser |
|
207 |
* @throws IOException |
|
208 |
* @throws XmlPullParserException |
|
209 |
*/ |
|
210 |
public abstract void parse(KXmlParser parser) throws XmlPullParserException, IOException; |
|
211 |
|
|
212 |
/** |
|
213 |
* Gets the RectifiedGrid structure |
|
214 |
* @return |
|
215 |
*/ |
|
216 |
public RectifiedGrid getRectifiedGrid() { |
|
217 |
return rg; |
|
218 |
} |
|
219 |
|
|
220 |
/** |
|
221 |
* Inner class describing the Rectified Grid of this coverage. |
|
222 |
* |
|
223 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
224 |
*/ |
|
225 |
public class RectifiedGrid { |
|
226 |
private int dimensions; |
|
227 |
private String[] axisNames; |
|
228 |
private int[][] lowGridEnvelopLimits; |
|
229 |
private int[][] highGridEnvelopLimits; |
|
230 |
private double[] origins; |
|
231 |
private double[][] offsetVector; |
|
232 |
|
|
233 |
public RectifiedGrid(int dimensions) { |
|
234 |
this.dimensions = dimensions; |
|
235 |
} |
|
236 |
|
|
237 |
public void addAxisName(String axisName) { |
|
238 |
if (axisNames == null) { |
|
239 |
axisNames = new String[1]; |
|
240 |
axisNames[0] = axisName; |
|
241 |
} else { |
|
242 |
String[] aux = axisNames; |
|
243 |
axisNames = new String[axisNames.length+1]; |
|
244 |
for (int i = 0; i < aux.length; i++) { |
|
245 |
axisNames[i] = aux[i]; |
|
246 |
} |
|
247 |
axisNames[axisNames.length-1] = axisName; |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
public String[] getAxisNames() { |
|
252 |
return axisNames; |
|
253 |
} |
|
254 |
|
|
255 |
public void addLowGridEnvelopLimit(int[] lowLimit) { |
|
256 |
if (lowGridEnvelopLimits == null) { |
|
257 |
lowGridEnvelopLimits = new int[1][1]; |
|
258 |
lowGridEnvelopLimits[0] = lowLimit; |
|
259 |
} else { |
|
260 |
int[][] aux = lowGridEnvelopLimits; |
|
261 |
lowGridEnvelopLimits = new int[lowGridEnvelopLimits.length+1][1]; |
|
262 |
for (int i = 0; i < aux.length; i++) { |
|
263 |
lowGridEnvelopLimits[i] = aux[i]; |
|
264 |
} |
|
265 |
lowGridEnvelopLimits[lowGridEnvelopLimits.length-1] = lowLimit; |
|
266 |
} |
|
267 |
} |
|
268 |
|
|
269 |
public int[][] getLowGridEnvelopLimits() { |
|
270 |
return lowGridEnvelopLimits; |
|
271 |
} |
|
272 |
|
|
273 |
public void addHighGridEnvelopLimit(int[] highLimit) { |
|
274 |
if (highGridEnvelopLimits == null) { |
|
275 |
highGridEnvelopLimits = new int[1][1]; |
|
276 |
highGridEnvelopLimits[0] = highLimit; |
|
277 |
} else { |
|
278 |
int[][] aux = highGridEnvelopLimits; |
|
279 |
highGridEnvelopLimits = new int[highGridEnvelopLimits.length+1][1]; |
|
280 |
for (int i = 0; i < aux.length; i++) { |
|
281 |
highGridEnvelopLimits[i] = aux[i]; |
|
282 |
} |
|
283 |
highGridEnvelopLimits[highGridEnvelopLimits.length-1] = highLimit; |
|
284 |
} |
|
285 |
} |
|
286 |
|
|
287 |
public int[][] getHighGridEnvelopLimits() { |
|
288 |
return highGridEnvelopLimits; |
|
289 |
} |
|
290 |
|
|
291 |
public void setOrigin(double[] _origins) { |
|
292 |
origins = _origins; |
|
293 |
} |
|
294 |
|
|
295 |
public double[] getOrigins() { |
|
296 |
return origins; |
|
297 |
} |
|
298 |
|
|
299 |
public void addToOffsetVector(double[] _offsetVector) { |
|
300 |
if (offsetVector == null) { |
|
301 |
offsetVector = new double[1][1]; |
|
302 |
offsetVector[0] = _offsetVector; |
|
303 |
} else { |
|
304 |
double[][] aux = offsetVector; |
|
305 |
offsetVector = new double[offsetVector.length+1][1]; |
|
306 |
for (int i = 0; i < aux.length; i++) { |
|
307 |
offsetVector[i] = aux[i]; |
|
308 |
} |
|
309 |
offsetVector[offsetVector.length-1] = _offsetVector; |
|
310 |
} |
|
311 |
} |
|
312 |
|
|
313 |
public double[][] getOffsetVector(){ |
|
314 |
return offsetVector; |
|
315 |
} |
|
316 |
|
|
317 |
public int getDimensionCount() { |
|
318 |
return dimensions; |
|
319 |
} |
|
320 |
} |
|
321 |
|
|
322 |
/** |
|
323 |
* Inner class describing the Axis Description of this coverage. |
|
324 |
* |
|
325 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
326 |
*/ |
|
327 |
public class AxisDescription { |
|
328 |
private String _name; |
|
329 |
private String label; |
|
330 |
private ArrayList singleValues = new ArrayList(); |
|
331 |
private String interval; |
|
332 |
private String defaultValue; |
|
333 |
|
|
334 |
public String getDefaultValue() { |
|
335 |
return defaultValue; |
|
336 |
} |
|
337 |
|
|
338 |
public void setDefaultValue(String defaultValue) { |
|
339 |
this.defaultValue = defaultValue; |
|
340 |
} |
|
341 |
|
|
342 |
public String getInterval() { |
|
343 |
return interval; |
|
344 |
} |
|
345 |
|
|
346 |
public void setInterval(String interval) { |
|
347 |
this.interval = interval; |
|
348 |
} |
|
349 |
|
|
350 |
public String getLabel() { |
|
351 |
return label; |
|
352 |
} |
|
353 |
public void setLabel(String label) { |
|
354 |
this.label = label; |
|
355 |
} |
|
356 |
|
|
357 |
public String getName() { |
|
358 |
return _name; |
|
359 |
} |
|
360 |
|
|
361 |
public void setName(String name) { |
|
362 |
this._name = name; |
|
363 |
} |
|
364 |
|
|
365 |
public ArrayList getSingleValues() { |
|
366 |
return singleValues; |
|
367 |
} |
|
368 |
|
|
369 |
public void addSingleValues(String singleValue) { |
|
370 |
this.singleValues.add(singleValue); |
|
371 |
} |
|
372 |
} |
|
373 |
|
|
374 |
public double getResX() { |
|
375 |
if (rg.offsetVector== null) |
|
376 |
return -1; |
|
377 |
return Math.abs(rg.offsetVector[0][0]); |
|
378 |
} |
|
379 |
|
|
380 |
public double getResY() { |
|
381 |
if (rg.offsetVector== null) |
|
382 |
return -1; |
|
383 |
|
|
384 |
return Math.abs(rg.offsetVector[1][1]); |
|
385 |
} |
|
386 |
|
|
387 |
public Hashtable getBBoxes() { |
|
388 |
if (bBoxes == null) return new Hashtable(); |
|
389 |
else return bBoxes; |
|
390 |
} |
|
391 |
|
|
392 |
} |
|
393 |
|
|
0 | 394 |
tags/org.gvsig.desktop-2.0.100/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wcs/request/WCSRequest.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wcs.request; |
|
25 |
|
|
26 |
import org.gvsig.remoteclient.ogc.request.OGCRequest; |
|
27 |
import org.gvsig.remoteclient.wcs.WCSProtocolHandler; |
|
28 |
import org.gvsig.remoteclient.wcs.WCSStatus; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
32 |
*/ |
|
33 |
public abstract class WCSRequest extends OGCRequest{ |
|
34 |
protected WCSStatus status = null; |
|
35 |
|
|
36 |
public WCSRequest(WCSStatus status, WCSProtocolHandler protocolHandler) { |
|
37 |
super(status, protocolHandler); |
|
38 |
this.status = status; |
|
39 |
} |
|
40 |
|
|
41 |
protected String getPartialQuery(WCSStatus status) |
|
42 |
{ |
|
43 |
StringBuffer req = new StringBuffer(); |
|
44 |
req.append( (status.getTime() != null) ? "&TIME=" + status.getTime() : "" ) |
|
45 |
.append( "&COVERAGE=" + status.getCoverageName()) |
|
46 |
.append( "&CRS=" + status.getSrs()) |
|
47 |
.append( "&FORMAT=" + status.getFormat() ) |
|
48 |
.append( "&HEIGHT=" + status.getHeight()) |
|
49 |
.append( "&WIDTH=" + status.getWidth()) |
|
50 |
.append( (status.getDepth() != null) ? "&DEPTH=" + status.getDepth() : "" ) |
|
51 |
.append( "&BBOX=" + status.getExtent().getMinX() + "," ) |
|
52 |
.append( status.getExtent().getMinY() + ",") |
|
53 |
.append( status.getExtent().getMaxX() + ",") |
|
54 |
.append( status.getExtent().getMaxY()) |
|
55 |
.append( (status.getParameters() != null) ? "&" + status.getParameters() : ""); |
|
56 |
|
|
57 |
return req.toString(); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
|
|
0 | 63 |
tags/org.gvsig.desktop-2.0.100/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wcs/request/WCSGetCoverageRequest.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wcs.request; |
|
25 |
|
|
26 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
27 |
import org.gvsig.remoteclient.utils.Utilities; |
|
28 |
import org.gvsig.remoteclient.wcs.WCSProtocolHandler; |
|
29 |
import org.gvsig.remoteclient.wcs.WCSStatus; |
|
30 |
|
|
31 |
/** |
|
32 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
33 |
*/ |
|
34 |
public abstract class WCSGetCoverageRequest extends WCSRequest{ |
|
35 |
|
|
36 |
public WCSGetCoverageRequest(WCSStatus status, |
|
37 |
WCSProtocolHandler protocolHandler) { |
|
38 |
super(status, protocolHandler); |
|
39 |
} |
|
40 |
|
|
41 |
/* |
|
42 |
* (non-Javadoc) |
|
43 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getHttpPostRequest(java.lang.String) |
|
44 |
*/ |
|
45 |
protected String getHttpPostRequest(String onlineResource) { |
|
46 |
// TODO Auto-generated method stub |
|
47 |
return null; |
|
48 |
} |
|
49 |
|
|
50 |
/* |
|
51 |
* (non-Javadoc) |
|
52 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getOperationCode() |
|
53 |
*/ |
|
54 |
protected String getOperationName() { |
|
55 |
return CapabilitiesTags.GETCOVERAGE; |
|
56 |
} |
|
57 |
|
|
58 |
/* |
|
59 |
* (non-Javadoc) |
|
60 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getSchemaLocation() |
|
61 |
*/ |
|
62 |
protected String getSchemaLocation() { |
|
63 |
return null; |
|
64 |
} |
|
65 |
|
|
66 |
/* |
|
67 |
* (non-Javadoc) |
|
68 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getTempFilePrefix() |
|
69 |
*/ |
|
70 |
protected String getTempFilePrefix() { |
|
71 |
return "wcsGetCoverage" + System.currentTimeMillis(); |
|
72 |
//return "wcs_getCoverage.xml"; |
|
73 |
} |
|
74 |
} |
|
0 | 75 |
tags/org.gvsig.desktop-2.0.100/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wcs/request/WCSDescribeCoverageRequest.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wcs.request; |
|
25 |
|
|
26 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
27 |
import org.gvsig.remoteclient.wcs.WCSProtocolHandler; |
|
28 |
import org.gvsig.remoteclient.wcs.WCSStatus; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
32 |
*/ |
|
33 |
public abstract class WCSDescribeCoverageRequest extends WCSRequest{ |
|
34 |
|
|
35 |
public WCSDescribeCoverageRequest(WCSStatus status, |
|
36 |
WCSProtocolHandler protocolHandler) { |
|
37 |
super(status, protocolHandler); |
|
38 |
} |
|
39 |
|
|
40 |
/* |
|
41 |
* (non-Javadoc) |
|
42 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getHttpPostRequest(java.lang.String) |
|
43 |
*/ |
|
44 |
protected String getHttpPostRequest(String onlineResource) { |
|
45 |
// TODO Auto-generated method stub |
|
46 |
return null; |
|
47 |
} |
|
48 |
|
|
49 |
/* |
|
50 |
* (non-Javadoc) |
|
51 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getOperationCode() |
|
52 |
*/ |
|
53 |
protected String getOperationName() { |
|
54 |
return CapabilitiesTags.DESCRIBECOVERAGE; |
|
55 |
} |
|
56 |
|
|
57 |
/* |
|
58 |
* (non-Javadoc) |
|
59 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getSchemaLocation() |
|
60 |
*/ |
|
61 |
protected String getSchemaLocation() { |
|
62 |
return null; |
|
63 |
} |
|
64 |
|
|
65 |
/* |
|
66 |
* (non-Javadoc) |
|
67 |
* @see org.gvsig.remoteClient.wfs.requests.WFSRequest#getTempFilePrefix() |
|
68 |
*/ |
|
69 |
protected String getTempFilePrefix() { |
|
70 |
return "wcs_describeCoverage.xml"; |
|
71 |
} |
|
72 |
} |
|
0 | 73 |
tags/org.gvsig.desktop-2.0.100/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wcs/wcs_1_0_0/WCSCoverage1_0_0.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wcs.wcs_1_0_0; |
|
25 |
|
|
26 |
|
|
27 |
import java.io.IOException; |
|
28 |
|
|
29 |
import org.kxml2.io.KXmlParser; |
|
30 |
import org.xmlpull.v1.XmlPullParserException; |
|
31 |
|
|
32 |
import org.gvsig.compat.CompatLocator; |
|
33 |
import org.gvsig.compat.lang.StringUtils; |
|
34 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
|
35 |
import org.gvsig.remoteclient.utils.DescribeCoverageTags; |
|
36 |
import org.gvsig.remoteclient.wcs.WCSCoverage; |
|
37 |
|
|
38 |
/** |
|
39 |
* @author jaume |
|
40 |
* |
|
41 |
*/ |
|
42 |
public class WCSCoverage1_0_0 extends WCSCoverage{ |
|
43 |
String axisDescriptionName; |
|
44 |
|
|
45 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
46 |
|
|
47 |
/* (non-Javadoc) |
|
48 |
* @see org.gvsig.remoteClient.wcs.WCSLayer#parse(org.kxml2.io.KXmlParser) |
|
49 |
*/ |
|
50 |
public void parse(KXmlParser parser) throws XmlPullParserException, IOException { |
|
51 |
int currentTag; |
|
52 |
String value; |
|
53 |
boolean end = false; |
|
54 |
|
|
55 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.COVERAGE_OFFERING); |
|
56 |
currentTag = parser.next(); |
|
57 |
|
|
58 |
while (!end) |
|
59 |
{ |
|
60 |
switch(currentTag) |
|
61 |
{ |
|
62 |
case KXmlParser.START_TAG: |
|
63 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME)==0) |
|
64 |
{ |
|
65 |
value = parser.nextText(); |
|
66 |
if (value != null) setName(value); |
|
67 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LABEL)==0){ |
|
68 |
value = parser.nextText(); |
|
69 |
if (value != null) setTitle(value); |
|
70 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LONLAT_ENVELOPE)==0){ |
|
71 |
BoundaryBox bBox = parseLonLatGMLEnvelope(parser); |
|
72 |
bBox.setSrs(DescribeCoverageTags.WGS84); |
|
73 |
addBBox(bBox); |
|
74 |
setLonLatBox(bBox); |
|
75 |
} else if (parser.getName().compareTo(DescribeCoverageTags.DOMAINSET) == 0) { |
|
76 |
parseDomainSet(parser); |
|
77 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RANGESET) == 0) { |
|
78 |
parseRangeSet(parser); |
|
79 |
} else if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_CRSS) == 0) { |
|
80 |
parseSupportedCRSS(parser); |
|
81 |
} else if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_FORMATS) == 0) { |
|
82 |
setNativeFormat(parser.getAttributeValue("", DescribeCoverageTags.NATIVE_FORMAT)); |
|
83 |
parser.nextTag(); |
|
84 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.FORMATS); |
|
85 |
while (parser.getName().compareTo(DescribeCoverageTags.FORMATS) == 0) { |
|
86 |
String[] formats = stringUtils.split(parser.nextText(), SEPARATOR); |
|
87 |
for (int i = 0; i < formats.length; i++) { |
|
88 |
addFormat(formats[i]); |
|
89 |
} |
|
90 |
parser.nextTag(); |
|
91 |
} |
|
92 |
} else if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_INTERPOLATIONS) == 0) { |
|
93 |
boolean bInterpolationsEnd = false; |
|
94 |
int interpolationsTag = parser.next(); |
|
95 |
while (!bInterpolationsEnd) { |
|
96 |
switch(interpolationsTag) { |
|
97 |
case KXmlParser.START_TAG: |
|
98 |
if (parser.getName().compareTo(DescribeCoverageTags.INTERPOLATION_METHOD)==0) { |
|
99 |
addInterpolationMethod(parser.nextText()); |
|
100 |
} |
|
101 |
break; |
|
102 |
case KXmlParser.END_TAG: |
|
103 |
if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_INTERPOLATIONS) == 0) |
|
104 |
bInterpolationsEnd = true; |
|
105 |
break; |
|
106 |
case KXmlParser.TEXT: |
|
107 |
if (parser.getName()!=null) |
|
108 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
109 |
break; |
|
110 |
} |
|
111 |
interpolationsTag = parser.next(); |
|
112 |
} |
|
113 |
} else { |
|
114 |
if (!parser.getName().equals("rangeSet")) // just a patch to avoid too much messages |
|
115 |
System.out.println("Skiped "+parser.getName()); |
|
116 |
} |
|
117 |
|
|
118 |
break; |
|
119 |
case KXmlParser.END_TAG: |
|
120 |
if (parser.getName().compareTo(DescribeCoverageTags.COVERAGE_OFFERING) == 0) |
|
121 |
end = true; |
|
122 |
break; |
|
123 |
case KXmlParser.TEXT: |
|
124 |
if (parser.getName()!=null) |
|
125 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
126 |
break; |
|
127 |
} |
|
128 |
currentTag = parser.next(); |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
private void parseSupportedCRSS(KXmlParser parser) throws XmlPullParserException, IOException { |
|
133 |
int currentTag; |
|
134 |
boolean end = false; |
|
135 |
|
|
136 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.SUPPORTED_CRSS); |
|
137 |
currentTag = parser.next(); |
|
138 |
|
|
139 |
while (!end) |
|
140 |
{ |
|
141 |
switch(currentTag) |
|
142 |
{ |
|
143 |
case KXmlParser.START_TAG: |
|
144 |
if (parser.getName().compareTo(DescribeCoverageTags.REQUEST_RESPONSE_CRSS)==0) { |
|
145 |
String[] values = stringUtils.split(parser.nextText(), SEPARATOR); |
|
146 |
for (int i = 0; i < values.length; i++) { |
|
147 |
addSRSs(values[i]); |
|
148 |
} |
|
149 |
} |
|
150 |
else if (parser.getName().compareTo(DescribeCoverageTags.NATIVE_CRS) == 0) { |
|
151 |
setNativeSRS(parser.nextText()); |
|
152 |
} else if (parser.getName().compareTo(DescribeCoverageTags.REQUEST_CRSS) == 0) { |
|
153 |
// TODO |
|
154 |
System.out.println("Skiped "+parser.getName()); |
|
155 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RESPONSE_CRSS) == 0) { |
|
156 |
// TODO |
|
157 |
System.out.println("Skiped "+parser.getName()); |
|
158 |
} else { |
|
159 |
System.out.println("Unrecognized "+parser.getName()); |
|
160 |
} |
|
161 |
|
|
162 |
break; |
|
163 |
case KXmlParser.END_TAG: |
|
164 |
if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_CRSS) == 0) |
|
165 |
return;//end = true; |
|
166 |
break; |
|
167 |
case KXmlParser.TEXT: |
|
168 |
if (parser.getName()!=null) |
|
169 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
170 |
break; |
|
171 |
} |
|
172 |
currentTag = parser.next(); |
|
173 |
} |
|
174 |
} |
|
175 |
|
|
176 |
private void parseRangeSet(KXmlParser parser) throws XmlPullParserException, IOException { |
|
177 |
int currentTag; |
|
178 |
boolean end = false; |
|
179 |
|
|
180 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.RANGESET); |
|
181 |
currentTag = parser.next(); |
|
182 |
|
|
183 |
while (!end) |
|
184 |
{ |
|
185 |
switch(currentTag) |
|
186 |
{ |
|
187 |
case KXmlParser.START_TAG: |
|
188 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME)==0) |
|
189 |
setRangeSetName(parser.nextText()); |
|
190 |
else if (parser.getName().compareTo(DescribeCoverageTags.LABEL) == 0) |
|
191 |
setRangeSetLabel(parser.nextText()); |
|
192 |
else if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) { |
|
193 |
// Reading all axe description |
|
194 |
int axisTag = parser.nextTag(); |
|
195 |
boolean endAxe = false; |
|
196 |
while (!endAxe) { |
|
197 |
switch(axisTag) |
|
198 |
{ |
|
199 |
case KXmlParser.START_TAG: |
|
200 |
if (parser.getName().compareTo(DescribeCoverageTags.AXISDESCRIPTION)==0) { |
|
201 |
AxisDescription as = parseAxisDescription(parser); |
|
202 |
axisPool.put(as.getName(), as); |
|
203 |
axisDescriptionName = as.getName(); |
|
204 |
} |
|
205 |
break; |
|
206 |
case KXmlParser.END_TAG: |
|
207 |
if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) |
|
208 |
endAxe = true; |
|
209 |
break; |
|
210 |
case KXmlParser.TEXT: |
|
211 |
if (parser.getName()!=null) |
|
212 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
213 |
break; |
|
214 |
} |
|
215 |
axisTag = parser.next(); |
|
216 |
} |
|
217 |
} else { |
|
218 |
System.out.println("Unrecognized "+parser.getName()); |
|
219 |
} |
|
220 |
break; |
|
221 |
case KXmlParser.END_TAG: |
|
222 |
if (parser.getName().compareTo(DescribeCoverageTags.RANGESET) == 0) |
|
223 |
end = true; |
|
224 |
break; |
|
225 |
case KXmlParser.TEXT: |
|
226 |
if (parser.getName()!=null) |
|
227 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
228 |
break; |
|
229 |
} |
|
230 |
currentTag = parser.next(); |
|
231 |
} |
|
232 |
} |
|
233 |
|
|
234 |
private AxisDescription parseAxisDescription(KXmlParser parser) throws XmlPullParserException, IOException { |
|
235 |
int currentTag; |
|
236 |
boolean end = false; |
|
237 |
|
|
238 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.AXISDESCRIPTION); |
|
239 |
AxisDescription as = new AxisDescription(); |
|
240 |
currentTag = parser.next(); |
|
241 |
|
|
242 |
while (!end) |
|
243 |
{ |
|
244 |
switch(currentTag) |
|
245 |
{ |
|
246 |
case KXmlParser.START_TAG: |
|
247 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME) == 0) { |
|
248 |
as.setName(parser.nextText()); |
|
249 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LABEL) == 0) { |
|
250 |
as.setLabel(parser.nextText()); |
|
251 |
} else if (parser.getName().compareTo(DescribeCoverageTags.VALUES) == 0) { |
|
252 |
int valuesTag = parser.nextTag(); |
|
253 |
boolean valuesEnd = false; |
|
254 |
while (!valuesEnd) { |
|
255 |
switch(valuesTag) { |
|
256 |
case KXmlParser.START_TAG: |
|
257 |
if (parser.getName().compareTo(DescribeCoverageTags.SINGLEVALUE) == 0) { |
|
258 |
as.addSingleValues(parser.nextText()); |
|
259 |
} else if (parser.getName().compareTo(DescribeCoverageTags.INTERVAL) == 0) { |
|
260 |
as.setInterval(parser.nextText()); |
|
261 |
} else if (parser.getName().compareTo(DescribeCoverageTags.DEFAULT) == 0) { |
|
262 |
as.setDefaultValue(parser.nextText()); |
|
263 |
} |
|
264 |
break; |
|
265 |
case KXmlParser.END_TAG: |
|
266 |
if (parser.getName().compareTo(DescribeCoverageTags.VALUES) == 0) |
|
267 |
valuesEnd = true; |
|
268 |
break; |
|
269 |
case KXmlParser.TEXT: |
|
270 |
if (parser.getName()!=null) |
|
271 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
272 |
break; |
|
273 |
} |
|
274 |
valuesTag = parser.next(); |
|
275 |
} |
|
276 |
} else if (parser.getName().compareTo(DescribeCoverageTags.NULLVALUES)==0) { |
|
277 |
// TODO |
|
278 |
System.err.println("Missing NULL VALUE PARSING on WCS 1.0.0 Client"); |
|
279 |
} else { |
|
280 |
System.out.println("Unrecognized "+parser.getName()); |
|
281 |
} |
|
282 |
|
|
283 |
break; |
|
284 |
case KXmlParser.END_TAG: |
|
285 |
if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) |
|
286 |
end = true; |
|
287 |
break; |
|
288 |
case KXmlParser.TEXT: |
|
289 |
if (parser.getName()!=null) |
|
290 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
291 |
break; |
|
292 |
} |
|
293 |
currentTag = parser.next(); |
|
294 |
} |
|
295 |
return as; |
|
296 |
} |
|
297 |
|
|
298 |
private void parseDomainSet(KXmlParser parser) throws XmlPullParserException, IOException { |
|
299 |
int currentTag; |
|
300 |
boolean end = false; |
|
301 |
|
|
302 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.DOMAINSET); |
|
303 |
currentTag = parser.next(); |
|
304 |
|
|
305 |
while (!end) |
|
306 |
{ |
|
307 |
switch(currentTag) |
|
308 |
{ |
|
309 |
case KXmlParser.START_TAG: |
|
310 |
if (parser.getName().compareTo(DescribeCoverageTags.SPATIALDOMAIN)==0) |
|
311 |
{ |
|
312 |
parseSpatialDomain(parser); |
|
313 |
} else if (parser.getName().compareTo(DescribeCoverageTags.TEMPORALDOMAIN)==0) { |
|
314 |
parseTemporalDomain(parser); |
|
315 |
} |
|
316 |
break; |
|
317 |
case KXmlParser.END_TAG: |
|
318 |
if (parser.getName().compareTo(DescribeCoverageTags.DOMAINSET) == 0) |
|
319 |
end = true; |
|
320 |
break; |
|
321 |
case KXmlParser.TEXT: |
|
322 |
if (parser.getName()!=null) |
|
323 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
324 |
break; |
|
325 |
} |
|
326 |
currentTag = parser.next(); |
|
327 |
} |
|
328 |
} |
|
329 |
|
|
330 |
private void parseTemporalDomain(KXmlParser parser) throws XmlPullParserException, IOException { |
|
331 |
int currentTag; |
|
332 |
boolean end = false; |
|
333 |
|
|
334 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.TEMPORALDOMAIN); |
|
335 |
currentTag = parser.next(); |
|
336 |
|
|
337 |
while (!end) |
|
338 |
{ |
|
339 |
switch(currentTag) |
|
340 |
{ |
|
341 |
case KXmlParser.START_TAG: |
|
342 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_TIMEPOSITION) == 0) { |
|
343 |
addTimePosition(parser.nextText()); |
|
344 |
} else if (parser.getName().compareTo(DescribeCoverageTags.TIMEPERIOD) == 0) { |
|
345 |
boolean timePeriodEnd = false; |
|
346 |
int timePeriodTag = parser.next(); |
|
347 |
String[] myTimePeriod = new String[3]; |
|
348 |
while (!timePeriodEnd) { |
|
349 |
switch (timePeriodTag) { |
|
350 |
case KXmlParser.START_TAG: |
|
351 |
if (parser.getName().compareTo(DescribeCoverageTags.BEGINPOSITION) == 0) { |
|
352 |
myTimePeriod[0] = parser.nextText(); |
|
353 |
} else if (parser.getName().compareTo(DescribeCoverageTags.ENDPOSITION) == 0) { |
|
354 |
myTimePeriod[1] = parser.nextText(); |
|
355 |
} else if (parser.getName().compareTo(DescribeCoverageTags.TIMERESOLUTION) == 0) { |
|
356 |
myTimePeriod[2] = parser.nextText(); |
|
357 |
} else { |
|
358 |
System.out.println("Unrecognized "+parser.getName()); |
|
359 |
} |
|
360 |
break; |
|
361 |
case KXmlParser.END_TAG: |
|
362 |
if (parser.getName().compareTo(DescribeCoverageTags.TEMPORALDOMAIN) == 0) |
|
363 |
end = true; |
|
364 |
break; |
|
365 |
case KXmlParser.TEXT: |
|
366 |
if (parser.getName()!=null) |
|
367 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
368 |
break; |
|
369 |
} |
|
370 |
timePeriodTag = parser.next(); |
|
371 |
} |
|
372 |
super.timePeriod = ""; |
|
373 |
for (int i = 0; i < myTimePeriod.length-1; i++) { |
|
374 |
if (myTimePeriod[i]!=null) { |
|
375 |
super.timePeriod += myTimePeriod[i]; |
|
376 |
} |
|
377 |
if (myTimePeriod[i+1]!=null) { |
|
378 |
super.timePeriod += "/"; |
|
379 |
} |
|
380 |
} |
|
381 |
} else { |
|
382 |
System.out.println("Unrecognized "+parser.getName()); |
|
383 |
} |
|
384 |
break; |
|
385 |
case KXmlParser.END_TAG: |
|
386 |
if (parser.getName().compareTo(DescribeCoverageTags.TEMPORALDOMAIN) == 0) |
|
387 |
end = true; |
|
388 |
break; |
|
389 |
case KXmlParser.TEXT: |
|
390 |
if (parser.getName()!=null) |
|
391 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
392 |
break; |
|
393 |
} |
|
394 |
currentTag = parser.next(); |
|
395 |
} |
|
396 |
} |
|
397 |
|
|
398 |
private void parseSpatialDomain(KXmlParser parser) throws XmlPullParserException, IOException { |
|
399 |
int currentTag; |
|
400 |
boolean end = false; |
|
401 |
|
|
402 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.SPATIALDOMAIN); |
|
403 |
currentTag = parser.next(); |
|
404 |
|
|
405 |
while (!end) |
|
406 |
{ |
|
407 |
switch(currentTag) |
|
408 |
{ |
|
409 |
case KXmlParser.START_TAG: |
|
410 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_ENVELOPE)==0) { |
|
411 |
BoundaryBox bBox = parseGMLEnvelope(parser); |
|
412 |
addBBox(bBox); |
|
413 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GRID)==0) { |
|
414 |
parseGrid(parser); |
|
415 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RECTIFIEDGRID)==0) { |
|
416 |
parseRectifiedGrid(parser); |
|
417 |
} else { |
|
418 |
System.out.println("Unrecognized "+parser.getName()); |
|
419 |
} |
|
420 |
break; |
|
421 |
case KXmlParser.END_TAG: |
|
422 |
if (parser.getName().compareTo(DescribeCoverageTags.SPATIALDOMAIN) == 0) |
|
423 |
return; |
|
424 |
break; |
|
425 |
case KXmlParser.TEXT: |
|
426 |
if (parser.getName()!=null) |
|
427 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
428 |
break; |
|
429 |
} |
|
430 |
currentTag = parser.next(); |
|
431 |
} |
|
432 |
} |
|
433 |
|
|
434 |
private void parseGrid(KXmlParser parser) throws XmlPullParserException, IOException { |
|
435 |
int currentTag; |
|
436 |
String value; |
|
437 |
boolean end = false; |
|
438 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GRID); |
|
439 |
rg = new RectifiedGrid(Integer.parseInt(parser.getAttributeValue("", DescribeCoverageTags.DIMENSION))); |
|
440 |
|
|
441 |
currentTag = parser.next(); |
|
442 |
|
|
443 |
while (!end) |
|
444 |
{ |
|
445 |
switch(currentTag) { |
|
446 |
case KXmlParser.START_TAG: |
|
447 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LIMITS) == 0) { |
|
448 |
parser.nextTag(); |
|
449 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_GRIDENVELOPE)==0) { |
|
450 |
boolean gridEnd = false; |
|
451 |
int gridCurrentTag = parser.next(); |
|
452 |
while (!gridEnd){ |
|
453 |
switch (gridCurrentTag) { |
|
454 |
case KXmlParser.START_TAG: |
|
455 |
|
|
456 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LOW) == 0) { |
|
457 |
value = parser.nextText(); |
|
458 |
String[] ss = stringUtils.split(value, 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.addLowGridEnvelopLimit(limits); |
|
464 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_HIGH) == 0) { |
|
465 |
value = parser.nextText(); |
|
466 |
String[] ss = stringUtils.split(value, SEPARATOR); |
|
467 |
int[] limits = new int[ss.length]; |
|
468 |
for (int i = 0; i < limits.length; i++) { |
|
469 |
limits[i] = Integer.parseInt(ss[i]); |
|
470 |
} |
|
471 |
rg.addHighGridEnvelopLimit(limits); |
|
472 |
} else { |
|
473 |
System.out.println("Unrecognized "+parser.getName()); |
|
474 |
} |
|
475 |
break; |
|
476 |
case KXmlParser.END_TAG: |
|
477 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_GRIDENVELOPE) == 0) |
|
478 |
gridEnd = true; |
|
479 |
break; |
|
480 |
case KXmlParser.TEXT: |
|
481 |
if (parser.getName()!=null) |
|
482 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
483 |
break; |
|
484 |
} |
|
485 |
gridCurrentTag = parser.next(); |
|
486 |
} |
|
487 |
} |
|
488 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_AXISNAME)==0) { |
|
489 |
rg.addAxisName(parser.nextText()); |
|
490 |
} else { |
|
491 |
System.out.println("Unrecognized "+parser.getName()); |
|
492 |
} |
|
493 |
break; |
|
494 |
case KXmlParser.END_TAG: |
|
495 |
if (parser.getName().compareTo(DescribeCoverageTags.GRID) == 0) |
|
496 |
return;//end = true; |
|
497 |
break; |
|
498 |
case KXmlParser.TEXT: |
|
499 |
if (parser.getName()!=null) |
|
500 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
501 |
break; |
|
502 |
} |
|
503 |
currentTag = parser.next(); |
|
504 |
} |
|
505 |
} |
|
506 |
|
|
507 |
private void parseRectifiedGrid(KXmlParser parser) throws XmlPullParserException, IOException { |
|
508 |
int currentTag; |
|
509 |
String value; |
|
510 |
boolean end = false; |
|
511 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.RECTIFIEDGRID); |
|
512 |
rg = new RectifiedGrid(Integer.parseInt(parser.getAttributeValue("", DescribeCoverageTags.DIMENSION))); |
|
513 |
|
|
514 |
// TODO maybe this is wrong |
|
515 |
rg.addToOffsetVector(new double[] { -1, -1}); |
|
516 |
rg.addToOffsetVector(new double[] { -1, -1}); |
|
517 |
|
|
518 |
currentTag = parser.next(); |
|
519 |
|
|
520 |
while (!end) |
|
521 |
{ |
|
522 |
switch(currentTag) |
|
523 |
{ |
|
524 |
case KXmlParser.START_TAG: |
|
525 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LIMITS) == 0) { |
|
526 |
parser.nextTag(); |
|
527 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_GRIDENVELOPE)==0) { |
|
528 |
boolean gridEnd = false; |
|
529 |
int gridCurrentTag = parser.next(); |
|
530 |
while (!gridEnd) |
|
531 |
{ |
|
532 |
switch (gridCurrentTag) { |
|
533 |
case KXmlParser.START_TAG: |
|
534 |
|
|
535 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LOW) == 0) { |
|
536 |
value = parser.nextText(); |
|
537 |
String[] ss = stringUtils.split(value, SEPARATOR); |
|
538 |
int[] limits = new int[ss.length]; |
|
539 |
for (int i = 0; i < limits.length; i++) { |
|
540 |
limits[i] = Integer.parseInt(ss[i]); |
|
541 |
} |
|
542 |
rg.addLowGridEnvelopLimit(limits); |
|
543 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_HIGH) == 0) { |
|
544 |
value = parser.nextText(); |
|
545 |
String[] ss = stringUtils.split(value, SEPARATOR); |
|
546 |
int[] limits = new int[ss.length]; |
|
547 |
for (int i = 0; i < limits.length; i++) { |
|
548 |
limits[i] = Integer.parseInt(ss[i]); |
|
549 |
} |
|
550 |
rg.addHighGridEnvelopLimit(limits); |
|
551 |
} else { |
|
552 |
System.out.println("Unrecognized "+parser.getName()); |
|
553 |
} |
|
554 |
break; |
|
555 |
case KXmlParser.END_TAG: |
|
556 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_GRIDENVELOPE) == 0) |
|
557 |
gridEnd = true; |
|
558 |
break; |
|
559 |
case KXmlParser.TEXT: |
|
560 |
if (parser.getName()!=null) |
|
561 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
562 |
break; |
|
563 |
} |
|
564 |
gridCurrentTag = parser.next(); |
|
565 |
} |
|
566 |
} |
|
567 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_AXISNAME)==0) { |
|
568 |
rg.addAxisName(parser.nextText()); |
|
569 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_ORIGIN)==0) { |
|
570 |
parser.nextTag(); |
|
571 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_POS)==0) { |
|
572 |
value = parser.nextText(); |
|
573 |
String[] ss = stringUtils.split(value, SEPARATOR); |
|
574 |
double[] ori = new double[ss.length]; |
|
575 |
for (int i = 0; i < ori.length; i++) { |
|
576 |
ori[i] = Double.parseDouble(ss[i]); |
|
577 |
} |
|
578 |
rg.setOrigin(ori); |
|
579 |
} |
|
580 |
} else if (parser.getName().compareTo(DescribeCoverageTags.OFFSETVECTOR) == 0) { |
|
581 |
value = parser.nextText(); |
|
582 |
String[] ss = stringUtils.split(value, SEPARATOR); |
|
583 |
double[] offset = new double[ss.length]; |
|
584 |
for (int i = 0; i < offset.length; i++) { |
|
585 |
offset[i] = Double.parseDouble(ss[i]); |
|
586 |
} |
|
587 |
rg.addToOffsetVector(offset); |
|
588 |
} else { |
|
589 |
System.out.println("Unrecognized "+parser.getName()); |
|
590 |
} |
|
591 |
break; |
|
592 |
case KXmlParser.END_TAG: |
|
593 |
if (parser.getName().compareTo(DescribeCoverageTags.RECTIFIEDGRID) == 0) |
|
594 |
end = true; |
|
595 |
break; |
|
596 |
case KXmlParser.TEXT: |
|
597 |
if (parser.getName()!=null) |
|
598 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
599 |
break; |
|
600 |
} |
|
601 |
currentTag = parser.next(); |
|
602 |
} |
|
603 |
} |
|
604 |
|
|
605 |
|
|
606 |
private BoundaryBox parseLonLatGMLEnvelope(KXmlParser parser) throws XmlPullParserException, IOException { |
|
607 |
BoundaryBox bBox = new BoundaryBox(); |
|
608 |
int currentTag; |
|
609 |
String value; |
|
610 |
boolean end = false; |
|
611 |
|
|
612 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.LONLAT_ENVELOPE); |
|
613 |
currentTag = parser.next(); |
|
614 |
|
|
615 |
while (!end) |
|
616 |
{ |
|
617 |
switch(currentTag) |
|
618 |
{ |
|
619 |
case KXmlParser.START_TAG: |
|
620 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_POS)==0) { |
|
621 |
bBox.setSrs(DescribeCoverageTags.WGS84); |
|
622 |
String[] coordinates; |
|
623 |
double minx, miny, maxx, maxy; |
|
624 |
value = parser.nextText(); |
|
625 |
coordinates = stringUtils.split(value, SEPARATOR); |
|
626 |
minx = Double.parseDouble(coordinates[0]); |
|
627 |
miny = Double.parseDouble(coordinates[1]); |
|
628 |
|
|
629 |
parser.nextTag(); |
|
630 |
|
|
631 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS); |
|
632 |
value = parser.nextText(); |
|
633 |
coordinates = stringUtils.split(value, SEPARATOR); |
|
634 |
maxx = Double.parseDouble(coordinates[0]); |
|
635 |
maxy = Double.parseDouble(coordinates[1]); |
|
636 |
|
|
637 |
bBox.setXmin(minx); |
|
638 |
bBox.setYmin(miny); |
|
639 |
bBox.setXmax(maxx); |
|
640 |
bBox.setYmax(maxy); |
|
641 |
} |
|
642 |
break; |
|
643 |
case KXmlParser.END_TAG: |
|
644 |
if (parser.getName().compareTo(DescribeCoverageTags.LONLAT_ENVELOPE) == 0) |
|
645 |
end = true; |
|
646 |
break; |
|
647 |
case KXmlParser.TEXT: |
|
648 |
if (parser.getName()!=null) |
|
649 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
650 |
break; |
|
651 |
} |
|
652 |
currentTag = parser.next(); |
|
653 |
} |
|
654 |
return bBox; |
|
655 |
} |
|
656 |
|
|
657 |
private BoundaryBox parseGMLEnvelope(KXmlParser parser) throws XmlPullParserException, IOException { |
|
658 |
BoundaryBox bBox = new BoundaryBox(); |
|
659 |
int currentTag; |
|
660 |
String value; |
|
661 |
boolean end = false; |
|
662 |
|
|
663 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_ENVELOPE); |
|
664 |
bBox.setSrs(parser.getAttributeValue("", DescribeCoverageTags.SRSNAME)); |
|
665 |
currentTag = parser.next(); |
|
666 |
|
|
667 |
while (!end) |
|
668 |
{ |
|
669 |
switch(currentTag) |
|
670 |
{ |
|
671 |
case KXmlParser.START_TAG: |
|
672 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_POS)==0) { |
|
673 |
|
|
674 |
String[] coordinates; |
|
675 |
double minx, miny, maxx, maxy; |
|
676 |
value = parser.nextText(); |
|
677 |
coordinates = stringUtils.split(value, SEPARATOR); |
|
678 |
minx = Double.parseDouble(coordinates[0]); |
|
679 |
miny = Double.parseDouble(coordinates[1]); |
|
680 |
|
|
681 |
parser.nextTag(); |
|
682 |
//parser.nextTag(); |
|
683 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS); |
|
684 |
value = parser.nextText(); |
|
685 |
coordinates = stringUtils.split(value, SEPARATOR); |
|
686 |
maxx = Double.parseDouble(coordinates[0]); |
|
687 |
maxy = Double.parseDouble(coordinates[1]); |
|
688 |
|
|
689 |
bBox.setXmin(minx); |
|
690 |
bBox.setYmin(miny); |
|
691 |
bBox.setXmax(maxx); |
|
692 |
bBox.setYmax(maxy); |
|
693 |
} |
|
694 |
break; |
|
695 |
case KXmlParser.END_TAG: |
|
696 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_ENVELOPE) == 0) |
|
697 |
end = true; |
|
698 |
break; |
|
699 |
case KXmlParser.TEXT: |
|
700 |
if (parser.getName()!=null) |
|
701 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
|
702 |
break; |
|
703 |
} |
|
704 |
currentTag = parser.next(); |
|
705 |
} |
|
706 |
|
|
707 |
return bBox; |
|
708 |
} |
|
709 |
} |
|
0 | 710 |
tags/org.gvsig.desktop-2.0.100/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wcs/wcs_1_0_0/request/WCSGetCoverageRequest1_0_0.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wcs.wcs_1_0_0.request; |
|
25 |
|
|
26 |
import org.gvsig.compat.CompatLocator; |
|
27 |
import org.gvsig.compat.lang.StringUtils; |
|
28 |
import org.gvsig.remoteclient.wcs.WCSProtocolHandler; |
|
29 |
import org.gvsig.remoteclient.wcs.WCSStatus; |
|
30 |
import org.gvsig.remoteclient.wcs.request.WCSGetCoverageRequest; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
34 |
*/ |
|
35 |
public class WCSGetCoverageRequest1_0_0 extends WCSGetCoverageRequest{ |
|
36 |
|
|
37 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
38 |
|
|
39 |
public WCSGetCoverageRequest1_0_0(WCSStatus status, |
|
40 |
WCSProtocolHandler protocolHandler) { |
|
41 |
super(status, protocolHandler); |
|
42 |
} |
|
43 |
|
|
44 |
/* |
|
45 |
* (non-Javadoc) |
|
46 |
* @see org.gvsig.remoteClient.ogc.request.OGCRequest#getHttpGetRequest(java.lang.String) |
|
47 |
*/ |
|
48 |
protected String getHttpGetRequest(String onlineResource) { |
|
49 |
StringBuffer req = new StringBuffer(); |
|
50 |
req.append(onlineResource); |
|
51 |
req.append("service=WCS&version=").append(protocolHandler.getVersion()).append("&request=GetCoverage"); |
|
52 |
req.append(getPartialQuery(status)); |
|
53 |
if (status.getExceptionFormat() != null) { |
|
54 |
req.append("&EXCEPTIONS=" + status.getExceptionFormat()); |
|
55 |
} else { |
|
56 |
req.append("&EXCEPTIONS=XML"); |
|
57 |
} |
|
58 |
return req.toString(); |
|
59 |
} |
|
60 |
|
|
61 |
} |
|
62 |
|
|
0 | 63 |
tags/org.gvsig.desktop-2.0.100/org.gvsig.desktop.compat.cdc/org.gvsig.remoteclient/src/main/java/org/gvsig/remoteclient/wcs/wcs_1_0_0/request/WCSDescribeCoverageRequest1_0_0.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
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 3 |
|
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 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.remoteclient.wcs.wcs_1_0_0.request; |
|
25 |
|
|
26 |
import org.gvsig.remoteclient.wcs.WCSProtocolHandler; |
|
27 |
import org.gvsig.remoteclient.wcs.WCSStatus; |
|
28 |
import org.gvsig.remoteclient.wcs.request.WCSDescribeCoverageRequest; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
32 |
*/ |
|
33 |
public class WCSDescribeCoverageRequest1_0_0 extends WCSDescribeCoverageRequest{ |
|
34 |
|
|
35 |
public WCSDescribeCoverageRequest1_0_0(WCSStatus status, |
|
36 |
WCSProtocolHandler protocolHandler) { |
|
37 |
super(status, protocolHandler); |
|
38 |
} |
|
39 |
|
|
40 |
/* |
|
41 |
* (non-Javadoc) |
|
42 |
* @see org.gvsig.remoteClient.ogc.request.OGCRequest#getHttpGetRequest(java.lang.String) |
|
43 |
*/ |
|
44 |
protected String getHttpGetRequest(String onlineResource) { |
|
45 |
StringBuffer req = new StringBuffer(); |
|
46 |
req.append(onlineResource).append("REQUEST=DescribeCoverage&SERVICE=WCS&"); |
|
47 |
if (status != null && status.getCoverageName()!= null) |
|
48 |
req.append("COVERAGE="+status.getCoverageName()+"&"); |
|
49 |
req.append("VERSION=").append(protocolHandler.getVersion()).append("&EXCEPTIONS=XML"); |
|
50 |
return req.toString(); |
|
51 |
} |
|
52 |
|
|
53 |
} |
|
54 |
|
|
0 | 55 |
Also available in: Unified diff