001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.wcs.requests;
006:
007: import com.vividsolutions.jts.geom.Envelope;
008: import org.vfny.geoserver.wcs.servlets.WCService;
009: import java.util.Map;
010: import java.util.logging.Logger;
011:
012: /**
013: * DOCUMENT ME!
014: *
015: * @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last
016: * modification)
017: * @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last
018: * modification)
019: */
020: public class CoverageRequest extends WCSRequest {
021: /** Standard logging instance for class */
022: private static final Logger LOGGER = org.geotools.util.logging.Logging
023: .getLogger("org.vfny.geoserver.requests");
024:
025: /**
026: *
027: * @uml.property name="coverage" multiplicity="(0 1)"
028: */
029: protected String coverage = null;
030:
031: /**
032: *
033: * @uml.property name="outputFormat" multiplicity="(0 1)"
034: */
035: protected String outputFormat = null;
036: protected String CRS = null;
037: protected String ResponseCRS = null;
038:
039: /**
040: *
041: * @uml.property name="envelope"
042: * @uml.associationEnd multiplicity="(0 1)"
043: */
044: protected Envelope envelope = null;
045:
046: /**
047: *
048: * @uml.property name="interpolation" multiplicity="(0 1)"
049: */
050: protected String interpolation = null;
051:
052: /**
053: *
054: * @uml.property name="handle" multiplicity="(0 1)"
055: */
056: protected String handle = null;
057: protected String coverageVersion = null;
058:
059: /**
060: *
061: * @uml.property name="gridDimension" multiplicity="(0 1)"
062: */
063: private int gridDimension;
064:
065: /**
066: *
067: * @uml.property name="gridLow" multiplicity="(0 1)"
068: */
069: private Double[] gridLow;
070:
071: /**
072: *
073: * @uml.property name="gridHigh" multiplicity="(0 1)"
074: */
075: private Double[] gridHigh;
076:
077: /**
078: *
079: * @uml.property name="gridOrigin" multiplicity="(0 1)"
080: */
081: private Double[] gridOrigin;
082: private Map parameters;
083:
084: public CoverageRequest(WCService service) {
085: super ("GetCoverage", service);
086: }
087:
088: /**
089: *
090: * @uml.property name="outputFormat"
091: */
092: public void setOutputFormat(String outputFormat) {
093: this .outputFormat = outputFormat;
094: }
095:
096: /**
097: *
098: * @uml.property name="outputFormat"
099: */
100: public String getOutputFormat() {
101: return this .outputFormat;
102: }
103:
104: /**
105: *
106: * @uml.property name="handle"
107: */
108: public void setHandle(String handle) {
109: this .handle = handle;
110: }
111:
112: /**
113: *
114: * @uml.property name="handle"
115: */
116: public String getHandle() {
117: return this .handle;
118: }
119:
120: public void setCoverageVersion(String version) {
121: this .version = version;
122: }
123:
124: public String getCoverageVersion() {
125: return this .version;
126: }
127:
128: public String toString() {
129: StringBuffer returnString = new StringBuffer("\nRequest");
130: returnString.append(": ").append(handle);
131: returnString.append("\n coverage:").append(coverage);
132: returnString.append("\n output format:").append(outputFormat);
133: returnString.append("\n version:").append(version);
134: returnString.append("\n envelope:").append(envelope);
135: returnString.append("\n interpolation:").append(interpolation);
136:
137: return returnString.toString();
138: }
139:
140: public boolean equals(Object obj) {
141: super .equals(obj);
142:
143: if (!(obj instanceof CoverageRequest)) {
144: return false;
145: }
146:
147: CoverageRequest request = (CoverageRequest) obj;
148: boolean isEqual = true;
149:
150: if ((this .coverage == null) && (request.getCoverage() == null)) {
151: isEqual = isEqual && true;
152: } else if ((this .coverage == null)
153: || (request.getCoverage() == null)) {
154: isEqual = false;
155: } else if (request.getCoverage().equals(coverage)) {
156: isEqual = isEqual && true;
157: } else {
158: isEqual = false;
159: }
160:
161: if ((this .version == null) && (request.getVersion() == null)) {
162: isEqual = isEqual && true;
163: } else if ((this .version == null)
164: || (request.getVersion() == null)) {
165: isEqual = false;
166: } else if (request.getVersion().equals(version)) {
167: isEqual = isEqual && true;
168: } else {
169: isEqual = false;
170: }
171:
172: if ((this .handle == null) && (request.getHandle() == null)) {
173: isEqual = isEqual && true;
174: } else if ((this .handle == null)
175: || (request.getHandle() == null)) {
176: isEqual = false;
177: } else if (request.getHandle().equals(handle)) {
178: isEqual = isEqual && true;
179: } else {
180: isEqual = false;
181: }
182:
183: if ((this .outputFormat == null)
184: && (request.getOutputFormat() == null)) {
185: isEqual = isEqual && true;
186: } else if ((this .outputFormat == null)
187: || (request.getOutputFormat() == null)) {
188: isEqual = false;
189: } else if (request.getOutputFormat().equals(outputFormat)) {
190: isEqual = isEqual && true;
191: } else {
192: isEqual = false;
193: }
194:
195: if ((this .envelope == null) && (request.getEnvelope() == null)) {
196: isEqual = isEqual && true;
197: } else if ((this .envelope == null)
198: || (request.getEnvelope() == null)) {
199: isEqual = false;
200: } else if (request.getEnvelope().equals(envelope)) {
201: isEqual = isEqual && true;
202: } else {
203: isEqual = false;
204: }
205:
206: if ((this .interpolation == null)
207: && (request.getInterpolation() == null)) {
208: isEqual = isEqual && true;
209: } else if ((this .interpolation == null)
210: || (request.getInterpolation() == null)) {
211: isEqual = false;
212: } else if (request.getInterpolation().equals(interpolation)) {
213: isEqual = isEqual && true;
214: } else {
215: isEqual = false;
216: }
217:
218: return isEqual;
219: }
220:
221: public int hashCode() {
222: int result = super .hashCode();
223: result = (23 * result)
224: + ((handle == null) ? 0 : handle.hashCode());
225: result = (23 * result)
226: + ((coverage == null) ? 0 : coverage.hashCode());
227:
228: return result;
229: }
230:
231: /**
232: * @return Returns the envelope.
233: *
234: * @uml.property name="envelope"
235: */
236: public Envelope getEnvelope() {
237: return envelope;
238: }
239:
240: /**
241: * @param envelope
242: * The envelope to set.
243: *
244: * @uml.property name="envelope"
245: */
246: public void setEnvelope(Envelope envelope) {
247: this .envelope = envelope;
248: }
249:
250: public void setEnvelope(String envelope) {
251: String[] coords = envelope.split(",");
252:
253: try {
254: double arg0 = Double.parseDouble(coords[0]);
255: double arg1 = Double.parseDouble(coords[1]);
256: double arg2 = Double.parseDouble(coords[2]);
257: double arg3 = Double.parseDouble(coords[3]);
258:
259: this .envelope = new Envelope(arg0, arg2, arg1, arg3);
260: } catch (NumberFormatException e) {
261: this .envelope = null;
262: }
263: }
264:
265: /**
266: * @return Returns the interpolation.
267: *
268: * @uml.property name="interpolation"
269: */
270: public String getInterpolation() {
271: return interpolation;
272: }
273:
274: /**
275: * @param interpolation
276: * The interpolation to set.
277: *
278: * @uml.property name="interpolation"
279: */
280: public void setInterpolation(String interpolation) {
281: this .interpolation = interpolation;
282: }
283:
284: /**
285: * @return Returns the coverage.
286: *
287: * @uml.property name="coverage"
288: */
289: public String getCoverage() {
290: return coverage;
291: }
292:
293: /**
294: * @param coverage
295: * The coverage to set.
296: *
297: * @uml.property name="coverage"
298: */
299: public void setCoverage(String coverage) {
300: this .coverage = coverage;
301: }
302:
303: /**
304: * @return Returns the gridDimension.
305: *
306: * @uml.property name="gridDimension"
307: */
308: public int getGridDimension() {
309: return gridDimension;
310: }
311:
312: /**
313: * @param gridDimension
314: * The gridDimension to set.
315: *
316: * @uml.property name="gridDimension"
317: */
318: public void setGridDimension(int gridDimension) {
319: this .gridDimension = gridDimension;
320: }
321:
322: /**
323: * @param value
324: * The gridDimension to set.
325: */
326: public void setGridDimension(String value) {
327: this .gridDimension = Integer.parseInt(value);
328: }
329:
330: /**
331: * @param offsetVector
332: */
333: public void setOffsetVector(Double[] offsetVector) {
334: if (this .envelope != null) {
335: final double envWidth = Math.abs(envelope.getMaxX()
336: - envelope.getMinX());
337: final double envHeight = Math.abs(envelope.getMaxY()
338: - envelope.getMinY());
339: final double width = envWidth
340: / Math.abs(offsetVector[0].doubleValue());
341: final double height = envHeight
342: / Math.abs(offsetVector[1].doubleValue());
343: setGridOrigin(new Double[] { new Double(0.0),
344: new Double(0.0) });
345: setGridLow(new Double[] { new Double(0.0), new Double(0.0) });
346: setGridHigh(new Double[] { new Double(width),
347: new Double(height) });
348: }
349: }
350:
351: /**
352: * @param origin
353: *
354: * @uml.property name="gridOrigin"
355: */
356: public void setGridOrigin(Double[] origin) {
357: this .gridOrigin = origin;
358: }
359:
360: /**
361: * @param highers
362: *
363: * @uml.property name="gridHigh"
364: */
365: public void setGridHigh(Double[] highers) {
366: this .gridHigh = highers;
367: }
368:
369: /**
370: * @param lowers
371: *
372: * @uml.property name="gridLow"
373: */
374: public void setGridLow(Double[] lowers) {
375: this .gridLow = lowers;
376: }
377:
378: /**
379: * @return Returns the gridHigh.
380: *
381: * @uml.property name="gridHigh"
382: */
383: public Double[] getGridHigh() {
384: return gridHigh;
385: }
386:
387: /**
388: * @return Returns the gridLow.
389: *
390: * @uml.property name="gridLow"
391: */
392: public Double[] getGridLow() {
393: return gridLow;
394: }
395:
396: /**
397: * @return Returns the gridOrigin.
398: *
399: * @uml.property name="gridOrigin"
400: */
401: public Double[] getGridOrigin() {
402: return gridOrigin;
403: }
404:
405: public String getCRS() {
406: return CRS;
407: }
408:
409: public void setCRS(String crs) {
410: CRS = crs;
411: }
412:
413: public String getResponseCRS() {
414: return ResponseCRS;
415: }
416:
417: public void setResponseCRS(String responseCRS) {
418: ResponseCRS = responseCRS;
419: }
420:
421: /**
422: * @param kvpPairs
423: */
424: public void setParameters(Map kvpPairs) {
425: this .parameters = kvpPairs;
426: }
427:
428: public Map getParameters() {
429: return parameters;
430: }
431: }
|