svn-gvsig-desktop / trunk / libraries / libRemoteServices / src / org / gvsig / remoteClient / wcs / wcs_1_0_0 / WCSCoverage1_0_0.java @ 4493
History | View | Annotate | Download (26.2 KB)
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.WCSCoverage; |
52 |
import org.kxml2.io.KXmlParser; |
53 |
import org.xmlpull.v1.XmlPullParserException; |
54 |
|
55 |
/**
|
56 |
* @author jaume
|
57 |
*
|
58 |
*/
|
59 |
public class WCSCoverage1_0_0 extends WCSCoverage{ |
60 |
String axisDescriptionName;
|
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.SUPPORTED_CRSS) == 0) { |
95 |
parseSupportedCRSS(parser); |
96 |
} else if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_FORMATS) == 0) { |
97 |
setNativeFormat(parser.getAttributeValue("", DescribeCoverageTags.NATIVE_FORMAT));
|
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 if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_INTERPOLATIONS) == 0) { |
105 |
boolean bInterpolationsEnd = false; |
106 |
int interpolationsTag = parser.next();
|
107 |
while (!bInterpolationsEnd) {
|
108 |
switch(interpolationsTag) {
|
109 |
case KXmlParser.START_TAG:
|
110 |
if (parser.getName().compareTo(DescribeCoverageTags.INTERPOLATION_METHOD)==0) { |
111 |
addInterpolationMethod(parser.nextText()); |
112 |
} |
113 |
break;
|
114 |
case KXmlParser.END_TAG:
|
115 |
if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_INTERPOLATIONS) == 0) |
116 |
bInterpolationsEnd = true;
|
117 |
break;
|
118 |
case KXmlParser.TEXT:
|
119 |
if (parser.getName()!=null) |
120 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
121 |
break;
|
122 |
} |
123 |
interpolationsTag = parser.next(); |
124 |
} |
125 |
} else {
|
126 |
if (!parser.getName().equals("rangeSet")) // just a patch to avoid too much messages |
127 |
System.out.println("Skiped "+parser.getName()); |
128 |
} |
129 |
|
130 |
break;
|
131 |
case KXmlParser.END_TAG:
|
132 |
if (parser.getName().compareTo(DescribeCoverageTags.COVERAGE_OFFERING) == 0) |
133 |
end = true;
|
134 |
break;
|
135 |
case KXmlParser.TEXT:
|
136 |
if (parser.getName()!=null) |
137 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
138 |
break;
|
139 |
} |
140 |
currentTag = parser.next(); |
141 |
} |
142 |
} |
143 |
|
144 |
private void parseSupportedCRSS(KXmlParser parser) throws XmlPullParserException, IOException { |
145 |
int currentTag;
|
146 |
boolean end = false; |
147 |
|
148 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.SUPPORTED_CRSS);
|
149 |
currentTag = parser.next(); |
150 |
|
151 |
while (!end)
|
152 |
{ |
153 |
switch(currentTag)
|
154 |
{ |
155 |
case KXmlParser.START_TAG:
|
156 |
if (parser.getName().compareTo(DescribeCoverageTags.REQUEST_RESPONSE_CRSS)==0) { |
157 |
String[] values = parser.nextText().split(SEPARATOR); |
158 |
for (int i = 0; i < values.length; i++) { |
159 |
addSRSs(values[i]); |
160 |
} |
161 |
} |
162 |
else if (parser.getName().compareTo(DescribeCoverageTags.NATIVE_CRS) == 0) { |
163 |
setNativeSRS(parser.nextText()); |
164 |
} else if (parser.getName().compareTo(DescribeCoverageTags.REQUEST_CRSS) == 0) { |
165 |
// TODO
|
166 |
System.out.println("Skiped "+parser.getName()); |
167 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RESPONSE_CRSS) == 0) { |
168 |
// TODO
|
169 |
System.out.println("Skiped "+parser.getName()); |
170 |
} else {
|
171 |
System.out.println("Unrecognized "+parser.getName()); |
172 |
} |
173 |
|
174 |
break;
|
175 |
case KXmlParser.END_TAG:
|
176 |
if (parser.getName().compareTo(DescribeCoverageTags.SUPPORTED_CRSS) == 0) |
177 |
end = true;
|
178 |
break;
|
179 |
case KXmlParser.TEXT:
|
180 |
if (parser.getName()!=null) |
181 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
182 |
break;
|
183 |
} |
184 |
currentTag = parser.next(); |
185 |
} |
186 |
} |
187 |
|
188 |
private void parseRangeSet(KXmlParser parser) throws XmlPullParserException, IOException { |
189 |
int currentTag;
|
190 |
boolean end = false; |
191 |
|
192 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.RANGESET);
|
193 |
currentTag = parser.next(); |
194 |
|
195 |
while (!end)
|
196 |
{ |
197 |
switch(currentTag)
|
198 |
{ |
199 |
case KXmlParser.START_TAG:
|
200 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME)==0) |
201 |
setRangeSetName(parser.nextText()); |
202 |
else if (parser.getName().compareTo(DescribeCoverageTags.LABEL) == 0) |
203 |
setRangeSetLabel(parser.nextText()); |
204 |
else if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) { |
205 |
// Reading all axe description
|
206 |
int axisTag = parser.nextTag();
|
207 |
boolean endAxe = false; |
208 |
while (!endAxe) {
|
209 |
switch(axisTag)
|
210 |
{ |
211 |
case KXmlParser.START_TAG:
|
212 |
if (parser.getName().compareTo(DescribeCoverageTags.AXISDESCRIPTION)==0) { |
213 |
AxisDescription as = parseAxisDescription(parser); |
214 |
axisPool.put(as.getName(), as); |
215 |
axisDescriptionName = as.getName(); |
216 |
} |
217 |
break;
|
218 |
case KXmlParser.END_TAG:
|
219 |
if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) |
220 |
endAxe = true;
|
221 |
break;
|
222 |
case KXmlParser.TEXT:
|
223 |
if (parser.getName()!=null) |
224 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
225 |
break;
|
226 |
} |
227 |
axisTag = parser.next(); |
228 |
} |
229 |
} else {
|
230 |
System.out.println("Unrecognized "+parser.getName()); |
231 |
} |
232 |
break;
|
233 |
case KXmlParser.END_TAG:
|
234 |
if (parser.getName().compareTo(DescribeCoverageTags.RANGESET) == 0) |
235 |
end = true;
|
236 |
break;
|
237 |
case KXmlParser.TEXT:
|
238 |
if (parser.getName()!=null) |
239 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
240 |
break;
|
241 |
} |
242 |
currentTag = parser.next(); |
243 |
} |
244 |
} |
245 |
|
246 |
private AxisDescription parseAxisDescription(KXmlParser parser) throws XmlPullParserException, IOException { |
247 |
int currentTag;
|
248 |
boolean end = false; |
249 |
|
250 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.AXISDESCRIPTION);
|
251 |
AxisDescription as = new AxisDescription();
|
252 |
currentTag = parser.next(); |
253 |
|
254 |
while (!end)
|
255 |
{ |
256 |
switch(currentTag)
|
257 |
{ |
258 |
case KXmlParser.START_TAG:
|
259 |
if (parser.getName().compareTo(DescribeCoverageTags.NAME) == 0) { |
260 |
as.setName(parser.nextText()); |
261 |
} else if (parser.getName().compareTo(DescribeCoverageTags.LABEL) == 0) { |
262 |
as.setLabel(parser.nextText()); |
263 |
} else if (parser.getName().compareTo(DescribeCoverageTags.VALUES) == 0) { |
264 |
int valuesTag = parser.nextTag();
|
265 |
boolean valuesEnd = false; |
266 |
while (!valuesEnd) {
|
267 |
switch(valuesTag) {
|
268 |
case KXmlParser.START_TAG:
|
269 |
if (parser.getName().compareTo(DescribeCoverageTags.SINGLEVALUE) == 0) { |
270 |
as.addSingleValues(parser.nextText()); |
271 |
} else if (parser.getName().compareTo(DescribeCoverageTags.INTERVAL) == 0) { |
272 |
as.setInterval(parser.nextText()); |
273 |
} else if (parser.getName().compareTo(DescribeCoverageTags.DEFAULT) == 0) { |
274 |
as.setDefaultValue(parser.nextText()); |
275 |
} |
276 |
break;
|
277 |
case KXmlParser.END_TAG:
|
278 |
if (parser.getName().compareTo(DescribeCoverageTags.VALUES) == 0) |
279 |
valuesEnd = true;
|
280 |
break;
|
281 |
case KXmlParser.TEXT:
|
282 |
if (parser.getName()!=null) |
283 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
284 |
break;
|
285 |
} |
286 |
valuesTag = parser.next(); |
287 |
} |
288 |
} else if (parser.getName().compareTo(DescribeCoverageTags.NULLVALUES)==0) { |
289 |
// TODO
|
290 |
System.err.println("Missing NULL VALUE PARSING on WCS 1.0.0 Client"); |
291 |
} else {
|
292 |
System.out.println("Unrecognized "+parser.getName()); |
293 |
} |
294 |
|
295 |
break;
|
296 |
case KXmlParser.END_TAG:
|
297 |
if (parser.getName().compareToIgnoreCase(DescribeCoverageTags.AXISDESCRIPTION) == 0) |
298 |
end = true;
|
299 |
break;
|
300 |
case KXmlParser.TEXT:
|
301 |
if (parser.getName()!=null) |
302 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
303 |
break;
|
304 |
} |
305 |
currentTag = parser.next(); |
306 |
} |
307 |
return as;
|
308 |
} |
309 |
|
310 |
private void parseDomainSet(KXmlParser parser) throws XmlPullParserException, IOException { |
311 |
int currentTag;
|
312 |
boolean end = false; |
313 |
|
314 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.DOMAINSET);
|
315 |
currentTag = parser.next(); |
316 |
|
317 |
while (!end)
|
318 |
{ |
319 |
switch(currentTag)
|
320 |
{ |
321 |
case KXmlParser.START_TAG:
|
322 |
if (parser.getName().compareTo(DescribeCoverageTags.SPATIALDOMAIN)==0) |
323 |
{ |
324 |
parseSpatialDomain(parser); |
325 |
} else if (parser.getName().compareTo(DescribeCoverageTags.TEMPORALDOMAIN)==0) { |
326 |
parseTemporalDomain(parser); |
327 |
} |
328 |
break;
|
329 |
case KXmlParser.END_TAG:
|
330 |
if (parser.getName().compareTo(DescribeCoverageTags.DOMAINSET) == 0) |
331 |
end = true;
|
332 |
break;
|
333 |
case KXmlParser.TEXT:
|
334 |
if (parser.getName()!=null) |
335 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
336 |
break;
|
337 |
} |
338 |
currentTag = parser.next(); |
339 |
} |
340 |
} |
341 |
|
342 |
private void parseTemporalDomain(KXmlParser parser) throws XmlPullParserException, IOException { |
343 |
int currentTag;
|
344 |
boolean end = false; |
345 |
|
346 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.TEMPORALDOMAIN);
|
347 |
currentTag = parser.next(); |
348 |
|
349 |
while (!end)
|
350 |
{ |
351 |
switch(currentTag)
|
352 |
{ |
353 |
case KXmlParser.START_TAG:
|
354 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_TIMEPOSITION) == 0) { |
355 |
addTimePosition(parser.nextText()); |
356 |
} else if (parser.getName().compareTo(DescribeCoverageTags.TIMEPERIOD) == 0) { |
357 |
boolean timePeriodEnd = false; |
358 |
int timePeriodTag = parser.next();
|
359 |
String[] timePeriod = new String[3]; |
360 |
while (!timePeriodEnd) {
|
361 |
switch (timePeriodTag) {
|
362 |
case KXmlParser.START_TAG:
|
363 |
if (parser.getName().compareTo(DescribeCoverageTags.BEGINPOSITION) == 0) { |
364 |
timePeriod[0] = parser.nextText();
|
365 |
} else if (parser.getName().compareTo(DescribeCoverageTags.ENDPOSITION) == 0) { |
366 |
timePeriod[1] = parser.nextText();
|
367 |
} else if (parser.getName().compareTo(DescribeCoverageTags.TIMERESOLUTION) == 0) { |
368 |
timePeriod[2] = parser.nextText();
|
369 |
} else {
|
370 |
System.out.println("Unrecognized "+parser.getName()); |
371 |
} |
372 |
break;
|
373 |
case KXmlParser.END_TAG:
|
374 |
if (parser.getName().compareTo(DescribeCoverageTags.TEMPORALDOMAIN) == 0) |
375 |
end = true;
|
376 |
break;
|
377 |
case KXmlParser.TEXT:
|
378 |
if (parser.getName()!=null) |
379 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
380 |
break;
|
381 |
} |
382 |
timePeriodTag = parser.next(); |
383 |
} |
384 |
super.timePeriod = ""; |
385 |
for (int i = 0; i < timePeriod.length-1; i++) { |
386 |
if (timePeriod[i]!=null) { |
387 |
super.timePeriod += timePeriod[i];
|
388 |
} |
389 |
if (timePeriod[i+1]!=null) { |
390 |
super.timePeriod += "/"; |
391 |
} |
392 |
} |
393 |
} else {
|
394 |
System.out.println("Unrecognized "+parser.getName()); |
395 |
} |
396 |
break;
|
397 |
case KXmlParser.END_TAG:
|
398 |
if (parser.getName().compareTo(DescribeCoverageTags.TEMPORALDOMAIN) == 0) |
399 |
end = true;
|
400 |
break;
|
401 |
case KXmlParser.TEXT:
|
402 |
if (parser.getName()!=null) |
403 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
404 |
break;
|
405 |
} |
406 |
currentTag = parser.next(); |
407 |
} |
408 |
} |
409 |
|
410 |
private void parseSpatialDomain(KXmlParser parser) throws XmlPullParserException, IOException { |
411 |
int currentTag;
|
412 |
boolean end = false; |
413 |
|
414 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.SPATIALDOMAIN);
|
415 |
currentTag = parser.next(); |
416 |
|
417 |
while (!end)
|
418 |
{ |
419 |
switch(currentTag)
|
420 |
{ |
421 |
case KXmlParser.START_TAG:
|
422 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_ENVELOPE)==0) { |
423 |
BoundaryBox bBox = parseGMLEnvelope(parser); |
424 |
addBBox(bBox); |
425 |
} else if (parser.getName().compareTo(DescribeCoverageTags.RECTIFIEDGRID)==0) { |
426 |
parseRectifiedGrid(parser); |
427 |
} else {
|
428 |
System.out.println("Unrecognized "+parser.getName()); |
429 |
} |
430 |
break;
|
431 |
case KXmlParser.END_TAG:
|
432 |
if (parser.getName().compareTo(DescribeCoverageTags.SPATIALDOMAIN) == 0) |
433 |
end = true;
|
434 |
break;
|
435 |
case KXmlParser.TEXT:
|
436 |
if (parser.getName()!=null) |
437 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
438 |
break;
|
439 |
} |
440 |
currentTag = parser.next(); |
441 |
} |
442 |
} |
443 |
|
444 |
private void parseRectifiedGrid(KXmlParser parser) throws XmlPullParserException, IOException { |
445 |
int currentTag;
|
446 |
String value;
|
447 |
boolean end = false; |
448 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.RECTIFIEDGRID);
|
449 |
rg = new RectifiedGrid(Integer.parseInt(parser.getAttributeValue("", DescribeCoverageTags.DIMENSION))); |
450 |
|
451 |
currentTag = parser.next(); |
452 |
|
453 |
while (!end)
|
454 |
{ |
455 |
switch(currentTag)
|
456 |
{ |
457 |
case KXmlParser.START_TAG:
|
458 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LIMITS) == 0) { |
459 |
parser.nextTag(); |
460 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_GRIDENVELOPE)==0) { |
461 |
boolean gridEnd = false; |
462 |
int gridCurrentTag = parser.next();
|
463 |
while (!gridEnd)
|
464 |
{ |
465 |
switch (gridCurrentTag) {
|
466 |
case KXmlParser.START_TAG:
|
467 |
|
468 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LOW) == 0) { |
469 |
value = parser.nextText(); |
470 |
String[] ss = value.split(SEPARATOR); |
471 |
int[] limits = new int[ss.length]; |
472 |
for (int i = 0; i < limits.length; i++) { |
473 |
limits[i] = Integer.parseInt(ss[i]);
|
474 |
} |
475 |
rg.addLowGridEnvelopLimit(limits); |
476 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_HIGH) == 0) { |
477 |
value = parser.nextText(); |
478 |
String[] ss = value.split(SEPARATOR); |
479 |
int[] limits = new int[ss.length]; |
480 |
for (int i = 0; i < limits.length; i++) { |
481 |
limits[i] = Integer.parseInt(ss[i]);
|
482 |
} |
483 |
rg.addHighGridEnvelopLimit(limits); |
484 |
} else {
|
485 |
System.out.println("Unrecognized "+parser.getName()); |
486 |
} |
487 |
break;
|
488 |
case KXmlParser.END_TAG:
|
489 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_GRIDENVELOPE) == 0) |
490 |
gridEnd = true;
|
491 |
break;
|
492 |
case KXmlParser.TEXT:
|
493 |
if (parser.getName()!=null) |
494 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
495 |
break;
|
496 |
} |
497 |
gridCurrentTag = parser.next(); |
498 |
} |
499 |
} |
500 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_AXISNAME)==0) { |
501 |
rg.addAxisName(parser.nextText()); |
502 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_ORIGIN)==0) { |
503 |
parser.nextTag(); |
504 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_POS)==0) { |
505 |
value = parser.nextText(); |
506 |
String[] ss = value.split(SEPARATOR); |
507 |
double[] ori = new double[ss.length]; |
508 |
for (int i = 0; i < ori.length; i++) { |
509 |
ori[i] = Double.parseDouble(ss[i]);
|
510 |
} |
511 |
rg.setOrigin(ori); |
512 |
} |
513 |
} else if (parser.getName().compareTo(DescribeCoverageTags.OFFSETVECTOR) == 0) { |
514 |
value = parser.nextText(); |
515 |
String[] ss = value.split(SEPARATOR); |
516 |
double[] offset = new double[ss.length]; |
517 |
for (int i = 0; i < offset.length; i++) { |
518 |
offset[i] = Double.parseDouble(ss[i]);
|
519 |
} |
520 |
rg.addToOffsetVector(offset); |
521 |
} else {
|
522 |
System.out.println("Unrecognized "+parser.getName()); |
523 |
} |
524 |
break;
|
525 |
case KXmlParser.END_TAG:
|
526 |
if (parser.getName().compareTo(DescribeCoverageTags.RECTIFIEDGRID) == 0) |
527 |
end = true;
|
528 |
break;
|
529 |
case KXmlParser.TEXT:
|
530 |
if (parser.getName()!=null) |
531 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
532 |
break;
|
533 |
} |
534 |
currentTag = parser.next(); |
535 |
} |
536 |
} |
537 |
|
538 |
|
539 |
private BoundaryBox parseLonLatGMLEnvelope(KXmlParser parser) throws XmlPullParserException, IOException { |
540 |
BoundaryBox bBox = new BoundaryBox();
|
541 |
int currentTag;
|
542 |
String value;
|
543 |
boolean end = false; |
544 |
|
545 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.LONLAT_ENVELOPE);
|
546 |
currentTag = parser.next(); |
547 |
|
548 |
while (!end)
|
549 |
{ |
550 |
switch(currentTag)
|
551 |
{ |
552 |
case KXmlParser.START_TAG:
|
553 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_POS)==0) { |
554 |
bBox.setSrs(DescribeCoverageTags.WGS84); |
555 |
String[] coordinates; |
556 |
double minx, miny, maxx, maxy;
|
557 |
value = parser.nextText(); |
558 |
coordinates = value.split(SEPARATOR); |
559 |
minx = Double.parseDouble(coordinates[0]); |
560 |
miny = Double.parseDouble(coordinates[1]); |
561 |
|
562 |
parser.nextTag(); |
563 |
|
564 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS);
|
565 |
value = parser.nextText(); |
566 |
coordinates = value.split(SEPARATOR); |
567 |
maxx = Double.parseDouble(coordinates[0]); |
568 |
maxy = Double.parseDouble(coordinates[1]); |
569 |
|
570 |
bBox.setXmin(minx); |
571 |
bBox.setYmin(miny); |
572 |
bBox.setXmax(maxx); |
573 |
bBox.setYmax(maxy); |
574 |
} |
575 |
break;
|
576 |
case KXmlParser.END_TAG:
|
577 |
if (parser.getName().compareTo(DescribeCoverageTags.LONLAT_ENVELOPE) == 0) |
578 |
end = true;
|
579 |
break;
|
580 |
case KXmlParser.TEXT:
|
581 |
if (parser.getName()!=null) |
582 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
583 |
break;
|
584 |
} |
585 |
currentTag = parser.next(); |
586 |
} |
587 |
return bBox;
|
588 |
} |
589 |
|
590 |
private BoundaryBox parseGMLEnvelope(KXmlParser parser) throws XmlPullParserException, IOException { |
591 |
BoundaryBox bBox = new BoundaryBox();
|
592 |
int currentTag;
|
593 |
String value;
|
594 |
boolean end = false; |
595 |
|
596 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_ENVELOPE);
|
597 |
bBox.setSrs(parser.getAttributeValue("", DescribeCoverageTags.SRSNAME));
|
598 |
currentTag = parser.next(); |
599 |
|
600 |
while (!end)
|
601 |
{ |
602 |
switch(currentTag)
|
603 |
{ |
604 |
case KXmlParser.START_TAG:
|
605 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_POS)==0) { |
606 |
|
607 |
String[] coordinates; |
608 |
double minx, miny, maxx, maxy;
|
609 |
value = parser.nextText(); |
610 |
coordinates = value.split(SEPARATOR); |
611 |
minx = Double.parseDouble(coordinates[0]); |
612 |
miny = Double.parseDouble(coordinates[1]); |
613 |
|
614 |
parser.nextTag(); |
615 |
//parser.nextTag();
|
616 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS);
|
617 |
value = parser.nextText(); |
618 |
coordinates = value.split(SEPARATOR); |
619 |
maxx = Double.parseDouble(coordinates[0]); |
620 |
maxy = Double.parseDouble(coordinates[1]); |
621 |
|
622 |
bBox.setXmin(minx); |
623 |
bBox.setYmin(miny); |
624 |
bBox.setXmax(maxx); |
625 |
bBox.setYmax(maxy); |
626 |
} |
627 |
break;
|
628 |
case KXmlParser.END_TAG:
|
629 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_ENVELOPE) == 0) |
630 |
end = true;
|
631 |
break;
|
632 |
case KXmlParser.TEXT:
|
633 |
if (parser.getName()!=null) |
634 |
System.out.println("[TAG]["+parser.getName()+"]\n[TEXT]["+parser.getText().trim()+"]"); |
635 |
break;
|
636 |
} |
637 |
currentTag = parser.next(); |
638 |
} |
639 |
|
640 |
return bBox;
|
641 |
} |
642 |
} |