001: /*
002: * Geotools2 - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2003-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: */
017: package org.geotools.arcsde.gce;
018:
019: import java.io.File;
020: import java.util.HashMap;
021: import java.util.logging.Level;
022: import java.util.logging.Logger;
023:
024: import org.geotools.arcsde.pool.ArcSDEConnectionConfig;
025: import org.geotools.coverage.grid.io.AbstractGridFormat;
026: import org.geotools.coverage.grid.io.imageio.GeoToolsWriteParams;
027: import org.geotools.data.DataSourceException;
028: import org.geotools.factory.Hints;
029: import org.geotools.parameter.DefaultParameterDescriptorGroup;
030: import org.geotools.parameter.ParameterGroup;
031: import org.opengis.coverage.grid.Format;
032: import org.opengis.coverage.grid.GridCoverageReader;
033: import org.opengis.coverage.grid.GridCoverageWriter;
034: import org.opengis.parameter.GeneralParameterDescriptor;
035: import org.opengis.parameter.ParameterValueGroup;
036:
037: /**
038: * An implementation of the ArcSDE Raster Format. Based on the ArcGrid module.
039: *
040: * @author Saul Farber (saul.farber)
041: * @author jeichar
042: * @author Simone Giannecchini (simboss)
043: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/arcsde/datastore/src/main/java/org/geotools/arcsde/gce/ArcSDERasterFormat.java $
044: */
045: public class ArcSDERasterFormat extends AbstractGridFormat implements
046: Format {
047:
048: protected static final Logger LOGGER = org.geotools.util.logging.Logging
049: .getLogger(ArcSDERasterFormat.class.getPackage().getName());
050:
051: /**
052: * Creates an instance and sets the metadata.
053: */
054: public ArcSDERasterFormat() {
055: setInfo();
056: }
057:
058: /**
059: * Sets the metadata information.
060: */
061: private void setInfo() {
062: HashMap info = new HashMap();
063:
064: info.put("name", "ArcSDE Raster");
065: info.put("description", "ArcSDE Raster Format");
066: info.put("vendor", "Geotools");
067: info.put("docURL", "");
068: info.put("version", "0.1-alpha");
069: mInfo = info;
070:
071: readParameters = new ParameterGroup(
072: new DefaultParameterDescriptorGroup(
073: mInfo,
074: new GeneralParameterDescriptor[] { READ_GRIDGEOMETRY2D }));
075: }
076:
077: /**
078: * @see org.geotools.data.coverage.grid.AbstractGridFormat#getReader(Object
079: * source)
080: */
081: public GridCoverageReader getReader(Object source) {
082: return getReader(source, null);
083: }
084:
085: public GridCoverageReader getReader(Object source, Hints hints) {
086: try {
087: return new ArcSDERasterGridCoverage2DReader(source, hints);
088: } catch (DataSourceException dse) {
089: LOGGER.log(Level.SEVERE,
090: "Unable to creata ArcSDERasterReader for " + source
091: + ".", dse);
092: return null;
093: }
094: }
095:
096: /**
097: * @see org.geotools.data.coverage.grid.AbstractGridFormat#createWriter(java.lang.Object
098: * destination)
099: */
100: public GridCoverageWriter getWriter(Object destination) {
101: //return new ArcGridWriter(destination);
102: return null;
103: }
104:
105: /**
106: * @see org.geotools.data.coverage.grid.AbstractGridFormat#accepts(Object
107: * input)
108: */
109: public boolean accepts(Object input) {
110: StringBuffer url;
111: if (input instanceof File) {
112: url = new StringBuffer(((File) input).getPath());
113: } else if (input instanceof String) {
114: url = new StringBuffer((String) input);
115: } else {
116: return false;
117: }
118: try {
119: ArcSDERasterGridCoverage2DReader
120: .sdeURLToConnectionConfig(url);
121: return true;
122: } catch (Exception e) {
123: return false;
124: }
125: }
126:
127: /**
128: * @see org.opengis.coverage.grid.Format#getName()
129: */
130: public String getName() {
131: return (String) this .mInfo.get("name");
132: }
133:
134: /**
135: * @see org.opengis.coverage.grid.Format#getDescription()
136: */
137: public String getDescription() {
138: return (String) this .mInfo.get("description");
139: }
140:
141: /**
142: * @see org.opengis.coverage.grid.Format#getVendor()
143: */
144: public String getVendor() {
145: return (String) this .mInfo.get("vendor");
146: }
147:
148: /**
149: * @see org.opengis.coverage.grid.Format#getDocURL()
150: */
151: public String getDocURL() {
152: return (String) this .mInfo.get("docURL");
153: }
154:
155: /**
156: * @see org.opengis.coverage.grid.Format#getVersion()
157: */
158: public String getVersion() {
159: return (String) this .mInfo.get("version");
160: }
161:
162: /**
163: * Retrieves the default instance for the {@link ArcSDERasterFormat} of the
164: * {@link GeoToolsWriteParams} to control the writing process.
165: *
166: * @return a default instance for the {@link ArcSDERasterFormat} of the
167: * {@link GeoToolsWriteParams} to control the writing process.
168: */
169: public GeoToolsWriteParams getDefaultImageIOWriteParameters() {
170: throw new UnsupportedOperationException(
171: "ArcSDE Rasters are read only for now.");
172: }
173: }
|