svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.remoteclient / src / main / java / org / gvsig / remoteclient / wcs / WCSCoverage.java @ 40769
History | View | Annotate | Download (9.63 KB)
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 |
|