root / branches / v2_0_0_prep / libraries / libRemoteServices / src / org / gvsig / remoteclient / wcs / WCSCoverage.java @ 33738
History | View | Annotate | Download (9.76 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 |
* Inner class describing the Rectified Grid of this coverage.
|
234 |
*
|
235 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
236 |
*/
|
237 |
public class RectifiedGrid { |
238 |
private int dimensions; |
239 |
private String[] axisNames; |
240 |
private int[][] lowGridEnvelopLimits; |
241 |
private int[][] highGridEnvelopLimits; |
242 |
private double[] origins; |
243 |
private double[][] offsetVector; |
244 |
|
245 |
public RectifiedGrid(int dimensions) { |
246 |
this.dimensions = dimensions;
|
247 |
} |
248 |
|
249 |
public void addAxisName(String axisName) { |
250 |
if (axisNames == null) { |
251 |
axisNames = new String[1]; |
252 |
axisNames[0] = axisName;
|
253 |
} else {
|
254 |
String[] aux = axisNames; |
255 |
axisNames = new String[axisNames.length+1]; |
256 |
for (int i = 0; i < aux.length; i++) { |
257 |
axisNames[i] = aux[i]; |
258 |
} |
259 |
axisNames[axisNames.length-1] = axisName;
|
260 |
} |
261 |
} |
262 |
|
263 |
public String[] getAxisNames() { |
264 |
return axisNames;
|
265 |
} |
266 |
|
267 |
public void addLowGridEnvelopLimit(int[] lowLimit) { |
268 |
if (lowGridEnvelopLimits == null) { |
269 |
lowGridEnvelopLimits = new int[1][1]; |
270 |
lowGridEnvelopLimits[0] = lowLimit;
|
271 |
} else {
|
272 |
int[][] aux = lowGridEnvelopLimits; |
273 |
lowGridEnvelopLimits = new int[lowGridEnvelopLimits.length+1][1]; |
274 |
for (int i = 0; i < aux.length; i++) { |
275 |
lowGridEnvelopLimits[i] = aux[i]; |
276 |
} |
277 |
lowGridEnvelopLimits[lowGridEnvelopLimits.length-1] = lowLimit;
|
278 |
} |
279 |
} |
280 |
|
281 |
public int[][] getLowGridEnvelopLimits() { |
282 |
return lowGridEnvelopLimits;
|
283 |
} |
284 |
|
285 |
public void addHighGridEnvelopLimit(int[] highLimit) { |
286 |
if (highGridEnvelopLimits == null) { |
287 |
highGridEnvelopLimits = new int[1][1]; |
288 |
highGridEnvelopLimits[0] = highLimit;
|
289 |
} else {
|
290 |
int[][] aux = highGridEnvelopLimits; |
291 |
highGridEnvelopLimits = new int[highGridEnvelopLimits.length+1][1]; |
292 |
for (int i = 0; i < aux.length; i++) { |
293 |
highGridEnvelopLimits[i] = aux[i]; |
294 |
} |
295 |
highGridEnvelopLimits[highGridEnvelopLimits.length-1] = highLimit;
|
296 |
} |
297 |
} |
298 |
|
299 |
public int[][] getHighGridEnvelopLimits() { |
300 |
return highGridEnvelopLimits;
|
301 |
} |
302 |
|
303 |
public void setOrigin(double[] _origins) { |
304 |
origins = _origins; |
305 |
} |
306 |
|
307 |
public double[] getOrigins() { |
308 |
return origins;
|
309 |
} |
310 |
|
311 |
public void addToOffsetVector(double[] _offsetVector) { |
312 |
if (offsetVector == null) { |
313 |
offsetVector = new double[1][1]; |
314 |
offsetVector[0] = _offsetVector;
|
315 |
} else {
|
316 |
double[][] aux = offsetVector; |
317 |
offsetVector = new double[offsetVector.length+1][1]; |
318 |
for (int i = 0; i < aux.length; i++) { |
319 |
offsetVector[i] = aux[i]; |
320 |
} |
321 |
offsetVector[offsetVector.length-1] = _offsetVector;
|
322 |
} |
323 |
} |
324 |
|
325 |
public double[][] getOffsetVector(){ |
326 |
return offsetVector;
|
327 |
} |
328 |
|
329 |
public int getDimensionCount() { |
330 |
return dimensions;
|
331 |
} |
332 |
} |
333 |
|
334 |
/**
|
335 |
* Inner class describing the Axis Description of this coverage.
|
336 |
*
|
337 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
338 |
*/
|
339 |
public class AxisDescription { |
340 |
private String _name; |
341 |
private String label; |
342 |
private ArrayList singleValues = new ArrayList(); |
343 |
private String interval; |
344 |
private String defaultValue; |
345 |
|
346 |
public String getDefaultValue() { |
347 |
return defaultValue;
|
348 |
} |
349 |
|
350 |
public void setDefaultValue(String defaultValue) { |
351 |
this.defaultValue = defaultValue;
|
352 |
} |
353 |
|
354 |
public String getInterval() { |
355 |
return interval;
|
356 |
} |
357 |
|
358 |
public void setInterval(String interval) { |
359 |
this.interval = interval;
|
360 |
} |
361 |
|
362 |
public String getLabel() { |
363 |
return label;
|
364 |
} |
365 |
public void setLabel(String label) { |
366 |
this.label = label;
|
367 |
} |
368 |
|
369 |
public String getName() { |
370 |
return _name;
|
371 |
} |
372 |
|
373 |
public void setName(String name) { |
374 |
this._name = name;
|
375 |
} |
376 |
|
377 |
public ArrayList getSingleValues() { |
378 |
return singleValues;
|
379 |
} |
380 |
|
381 |
public void addSingleValues(String singleValue) { |
382 |
this.singleValues.add(singleValue);
|
383 |
} |
384 |
} |
385 |
|
386 |
public double getResX() { |
387 |
if (rg.offsetVector== null) |
388 |
return -1; |
389 |
return Math.abs(rg.offsetVector[0][0]); |
390 |
} |
391 |
|
392 |
public double getResY() { |
393 |
if (rg.offsetVector== null) |
394 |
return -1; |
395 |
|
396 |
return Math.abs(rg.offsetVector[1][1]); |
397 |
} |
398 |
|
399 |
public Hashtable getBBoxes() { |
400 |
if (bBoxes == null) return new Hashtable(); |
401 |
else return bBoxes; |
402 |
} |
403 |
|
404 |
} |
405 |
|