svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wcs / WCSCoverage.java @ 35939
History | View | Annotate | Download (9.9 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; |
45 |
|
46 |
import java.io.IOException; |
47 |
import java.util.ArrayList; |
48 |
import java.util.Hashtable; |
49 |
|
50 |
import org.kxml2.io.KXmlParser; |
51 |
import org.xmlpull.v1.XmlPullParserException; |
52 |
|
53 |
import org.gvsig.remoteclient.ILayer; |
54 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
55 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
56 |
|
57 |
/**
|
58 |
* Describes a coverage in a WCS server.
|
59 |
*
|
60 |
* @author jaume dominguez faus - jaume.domingue@iver.es
|
61 |
*
|
62 |
*/
|
63 |
public abstract class WCSCoverage implements ILayer{ |
64 |
public static final String SEPARATOR = " +"; // separator used to split list of values, usually is just a space |
65 |
private String name; |
66 |
private String title; |
67 |
private String _abstract; |
68 |
private Hashtable bBoxes = new Hashtable(); |
69 |
private BoundaryBox lonLatBbox;
|
70 |
public RectifiedGrid rg;
|
71 |
private ArrayList timePositions = new ArrayList(); |
72 |
public String timePeriod; |
73 |
private String rangeSetName; |
74 |
private String rangeSetLabel; |
75 |
public Hashtable axisPool = new Hashtable(); |
76 |
private String nativeSRS; |
77 |
private ArrayList supportedSRSs = new ArrayList(); |
78 |
private ArrayList interpolationMethods; |
79 |
private String nativeFormat; |
80 |
private ArrayList formats = new ArrayList(); |
81 |
|
82 |
public ArrayList getTimePositions() { |
83 |
return timePositions;
|
84 |
} |
85 |
|
86 |
public void addTimePosition(String timeExpr) { |
87 |
if (timePositions == null) |
88 |
timePositions = new ArrayList(); |
89 |
timePositions.add(timeExpr); |
90 |
} |
91 |
|
92 |
public ArrayList getFormats() { |
93 |
return formats;
|
94 |
} |
95 |
|
96 |
public void addFormat(String format) { |
97 |
formats.add(format); |
98 |
} |
99 |
|
100 |
public void setNativeFormat(String nativeFormat) { |
101 |
this.nativeFormat = nativeFormat;
|
102 |
} |
103 |
|
104 |
public String getNativeFormat() { |
105 |
return nativeFormat;
|
106 |
} |
107 |
|
108 |
public String getNativeSRS() { |
109 |
return nativeSRS;
|
110 |
} |
111 |
|
112 |
public void setNativeSRS(String nativeSRS) { |
113 |
this.nativeSRS = nativeSRS;
|
114 |
} |
115 |
|
116 |
public ArrayList getSRSs() { |
117 |
return supportedSRSs;
|
118 |
} |
119 |
|
120 |
public void addSRSs(String srs) { |
121 |
supportedSRSs.add(srs); |
122 |
} |
123 |
|
124 |
public String getRangeSetLabel() { |
125 |
return rangeSetLabel;
|
126 |
} |
127 |
|
128 |
public void setRangeSetLabel(String rangeSetLabel) { |
129 |
this.rangeSetLabel = rangeSetLabel;
|
130 |
} |
131 |
|
132 |
public String getRangeSetName() { |
133 |
return rangeSetName;
|
134 |
} |
135 |
|
136 |
public void setRangeSetName(String rangeSetName) { |
137 |
this.rangeSetName = rangeSetName;
|
138 |
} |
139 |
|
140 |
/* (non-Javadoc)
|
141 |
* @see org.gvsig.remoteClient.ILayer#getName()
|
142 |
*/
|
143 |
public String getName() { |
144 |
return name;
|
145 |
} |
146 |
|
147 |
/* (non-Javadoc)
|
148 |
* @see org.gvsig.remoteClient.ILayer#setName(java.lang.String)
|
149 |
*/
|
150 |
public void setName(String _name) { |
151 |
name = _name; |
152 |
} |
153 |
|
154 |
/* (non-Javadoc)
|
155 |
* @see org.gvsig.remoteClient.ILayer#setTitle(java.lang.String)
|
156 |
*/
|
157 |
public void setTitle(String _title) { |
158 |
title = _title; |
159 |
} |
160 |
|
161 |
/* (non-Javadoc)
|
162 |
* @see org.gvsig.remoteClient.ILayer#getTitle()
|
163 |
*/
|
164 |
public String getTitle() { |
165 |
return title;
|
166 |
} |
167 |
|
168 |
/* (non-Javadoc)
|
169 |
* @see org.gvsig.remoteClient.ILayer#getAbstract()
|
170 |
*/
|
171 |
public String getAbstract() { |
172 |
return _abstract;
|
173 |
} |
174 |
|
175 |
/* (non-Javadoc)
|
176 |
* @see org.gvsig.remoteClient.ILayer#setAbstract(java.lang.String)
|
177 |
*/
|
178 |
public void setAbstract(String _abstract) { |
179 |
this._abstract = _abstract;
|
180 |
} |
181 |
|
182 |
public void addBBox(BoundaryBox bBox) { |
183 |
bBoxes.put(bBox.getSrs(), bBox); |
184 |
} |
185 |
|
186 |
public ArrayList getAllSrs() { |
187 |
ArrayList mySrs = new ArrayList(); |
188 |
mySrs.addAll(supportedSRSs); |
189 |
if (!mySrs.contains(nativeSRS))
|
190 |
mySrs.add(nativeSRS); |
191 |
return mySrs;
|
192 |
} |
193 |
/**
|
194 |
* <p>returns the bbox with that id in the Bboxes vector</p>
|
195 |
* @param id
|
196 |
*/
|
197 |
public BoundaryBox getBbox(String id) { |
198 |
if ((id.compareToIgnoreCase( CapabilitiesTags.EPSG_4326 )==0) |
199 |
||(id.compareToIgnoreCase( CapabilitiesTags.CRS_84)==0))
|
200 |
{ |
201 |
if (lonLatBbox != null) |
202 |
return lonLatBbox;
|
203 |
} |
204 |
|
205 |
return (BoundaryBox)bBoxes.get(id);
|
206 |
} |
207 |
|
208 |
public BoundaryBox getLatLonBox() {
|
209 |
return lonLatBbox;
|
210 |
} |
211 |
|
212 |
public void setLonLatBox(BoundaryBox box) { |
213 |
lonLatBbox = box; |
214 |
} |
215 |
|
216 |
public void addInterpolationMethod(String method) { |
217 |
if (interpolationMethods==null) interpolationMethods = new ArrayList(); |
218 |
interpolationMethods.add(method); |
219 |
} |
220 |
|
221 |
public ArrayList getInterpolationMethods() { |
222 |
return interpolationMethods;
|
223 |
} |
224 |
/**
|
225 |
* Parses the fragment of the XML document that describes this layer (or coverage)
|
226 |
* @param parser
|
227 |
* @throws IOException
|
228 |
* @throws XmlPullParserException
|
229 |
*/
|
230 |
public abstract void parse(KXmlParser parser) throws XmlPullParserException, IOException; |
231 |
|
232 |
/**
|
233 |
* Gets the RectifiedGrid structure
|
234 |
* @return
|
235 |
*/
|
236 |
public RectifiedGrid getRectifiedGrid() {
|
237 |
return rg;
|
238 |
} |
239 |
|
240 |
/**
|
241 |
* Inner class describing the Rectified Grid of this coverage.
|
242 |
*
|
243 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
244 |
*/
|
245 |
public class RectifiedGrid { |
246 |
private int dimensions; |
247 |
private String[] axisNames; |
248 |
private int[][] lowGridEnvelopLimits; |
249 |
private int[][] highGridEnvelopLimits; |
250 |
private double[] origins; |
251 |
private double[][] offsetVector; |
252 |
|
253 |
public RectifiedGrid(int dimensions) { |
254 |
this.dimensions = dimensions;
|
255 |
} |
256 |
|
257 |
public void addAxisName(String axisName) { |
258 |
if (axisNames == null) { |
259 |
axisNames = new String[1]; |
260 |
axisNames[0] = axisName;
|
261 |
} else {
|
262 |
String[] aux = axisNames; |
263 |
axisNames = new String[axisNames.length+1]; |
264 |
for (int i = 0; i < aux.length; i++) { |
265 |
axisNames[i] = aux[i]; |
266 |
} |
267 |
axisNames[axisNames.length-1] = axisName;
|
268 |
} |
269 |
} |
270 |
|
271 |
public String[] getAxisNames() { |
272 |
return axisNames;
|
273 |
} |
274 |
|
275 |
public void addLowGridEnvelopLimit(int[] lowLimit) { |
276 |
if (lowGridEnvelopLimits == null) { |
277 |
lowGridEnvelopLimits = new int[1][1]; |
278 |
lowGridEnvelopLimits[0] = lowLimit;
|
279 |
} else {
|
280 |
int[][] aux = lowGridEnvelopLimits; |
281 |
lowGridEnvelopLimits = new int[lowGridEnvelopLimits.length+1][1]; |
282 |
for (int i = 0; i < aux.length; i++) { |
283 |
lowGridEnvelopLimits[i] = aux[i]; |
284 |
} |
285 |
lowGridEnvelopLimits[lowGridEnvelopLimits.length-1] = lowLimit;
|
286 |
} |
287 |
} |
288 |
|
289 |
public int[][] getLowGridEnvelopLimits() { |
290 |
return lowGridEnvelopLimits;
|
291 |
} |
292 |
|
293 |
public void addHighGridEnvelopLimit(int[] highLimit) { |
294 |
if (highGridEnvelopLimits == null) { |
295 |
highGridEnvelopLimits = new int[1][1]; |
296 |
highGridEnvelopLimits[0] = highLimit;
|
297 |
} else {
|
298 |
int[][] aux = highGridEnvelopLimits; |
299 |
highGridEnvelopLimits = new int[highGridEnvelopLimits.length+1][1]; |
300 |
for (int i = 0; i < aux.length; i++) { |
301 |
highGridEnvelopLimits[i] = aux[i]; |
302 |
} |
303 |
highGridEnvelopLimits[highGridEnvelopLimits.length-1] = highLimit;
|
304 |
} |
305 |
} |
306 |
|
307 |
public int[][] getHighGridEnvelopLimits() { |
308 |
return highGridEnvelopLimits;
|
309 |
} |
310 |
|
311 |
public void setOrigin(double[] _origins) { |
312 |
origins = _origins; |
313 |
} |
314 |
|
315 |
public double[] getOrigins() { |
316 |
return origins;
|
317 |
} |
318 |
|
319 |
public void addToOffsetVector(double[] _offsetVector) { |
320 |
if (offsetVector == null) { |
321 |
offsetVector = new double[1][1]; |
322 |
offsetVector[0] = _offsetVector;
|
323 |
} else {
|
324 |
double[][] aux = offsetVector; |
325 |
offsetVector = new double[offsetVector.length+1][1]; |
326 |
for (int i = 0; i < aux.length; i++) { |
327 |
offsetVector[i] = aux[i]; |
328 |
} |
329 |
offsetVector[offsetVector.length-1] = _offsetVector;
|
330 |
} |
331 |
} |
332 |
|
333 |
public double[][] getOffsetVector(){ |
334 |
return offsetVector;
|
335 |
} |
336 |
|
337 |
public int getDimensionCount() { |
338 |
return dimensions;
|
339 |
} |
340 |
} |
341 |
|
342 |
/**
|
343 |
* Inner class describing the Axis Description of this coverage.
|
344 |
*
|
345 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
346 |
*/
|
347 |
public class AxisDescription { |
348 |
private String _name; |
349 |
private String label; |
350 |
private ArrayList singleValues = new ArrayList(); |
351 |
private String interval; |
352 |
private String defaultValue; |
353 |
|
354 |
public String getDefaultValue() { |
355 |
return defaultValue;
|
356 |
} |
357 |
|
358 |
public void setDefaultValue(String defaultValue) { |
359 |
this.defaultValue = defaultValue;
|
360 |
} |
361 |
|
362 |
public String getInterval() { |
363 |
return interval;
|
364 |
} |
365 |
|
366 |
public void setInterval(String interval) { |
367 |
this.interval = interval;
|
368 |
} |
369 |
|
370 |
public String getLabel() { |
371 |
return label;
|
372 |
} |
373 |
public void setLabel(String label) { |
374 |
this.label = label;
|
375 |
} |
376 |
|
377 |
public String getName() { |
378 |
return _name;
|
379 |
} |
380 |
|
381 |
public void setName(String name) { |
382 |
this._name = name;
|
383 |
} |
384 |
|
385 |
public ArrayList getSingleValues() { |
386 |
return singleValues;
|
387 |
} |
388 |
|
389 |
public void addSingleValues(String singleValue) { |
390 |
this.singleValues.add(singleValue);
|
391 |
} |
392 |
} |
393 |
|
394 |
public double getResX() { |
395 |
if (rg.offsetVector== null) |
396 |
return -1; |
397 |
return Math.abs(rg.offsetVector[0][0]); |
398 |
} |
399 |
|
400 |
public double getResY() { |
401 |
if (rg.offsetVector== null) |
402 |
return -1; |
403 |
|
404 |
return Math.abs(rg.offsetVector[1][1]); |
405 |
} |
406 |
|
407 |
public Hashtable getBBoxes() { |
408 |
if (bBoxes == null) return new Hashtable(); |
409 |
else return bBoxes; |
410 |
} |
411 |
|
412 |
} |
413 |
|