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