001 /*
002 * GeoAPI - Java interfaces for OGC/ISO standards
003 * http://www.geoapi.org
004 *
005 * Copyright (C) 2004-2012 Open Geospatial Consortium, Inc.
006 * All Rights Reserved. http://www.opengeospatial.org/ogc/legal
007 *
008 * Permission to use, copy, and modify this software and its documentation, with
009 * or without modification, for any purpose and without fee or royalty is hereby
010 * granted, provided that you include the following on ALL copies of the software
011 * and documentation or portions thereof, including modifications, that you make:
012 *
013 * 1. The full text of this NOTICE in a location viewable to users of the
014 * redistributed or derivative work.
015 * 2. Notice of any changes or modifications to the OGC files, including the
016 * date changes were made.
017 *
018 * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
019 * NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
020 * TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
021 * THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
022 * PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
023 *
024 * COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
025 * CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
026 *
027 * The name and trademarks of copyright holders may NOT be used in advertising or
028 * publicity pertaining to the software without specific, written prior permission.
029 * Title to copyright in this software and any associated documentation will at all
030 * times remain with copyright holders.
031 */
032 package org.opengis.coverage.grid;
033
034 import java.io.IOException;
035 import org.opengis.parameter.GeneralParameterValue;
036 import org.opengis.parameter.ParameterNotFoundException;
037 import org.opengis.parameter.InvalidParameterNameException;
038 import org.opengis.parameter.InvalidParameterValueException;
039
040
041 /**
042 * Support for writing grid coverages into a persistent store. Instance
043 * of {@code GridCoverageWriter} are obtained through a call to
044 * {@link GridCoverageExchange#getWriter}. Grid coverages are usually
045 * added to the output stream in a sequential order.
046 *
047 * <P> </P>
048 * <TABLE WIDTH="80%" ALIGN="center" CELLPADDING="18" BORDER="4" BGCOLOR="#FFE0B0">
049 * <TR><TD>
050 * <P align="justify"><STRONG>WARNING: THIS CLASS WILL CHANGE.</STRONG> Current API is derived from OGC
051 * <A HREF="http://www.opengis.org/docs/01-004.pdf">Grid Coverages Implementation specification 1.0</A>.
052 * We plan to replace it by new interfaces derived from ISO 19123 (<CITE>Schema for coverage geometry
053 * and functions</CITE>). Current interfaces should be considered as legacy and are included in this
054 * distribution only because they were part of GeoAPI 1.0 release. We will try to preserve as much
055 * compatibility as possible, but no migration plan has been determined yet.</P>
056 * </TD></TR>
057 * </TABLE>
058 *
059 * @author Martin Desruisseaux (IRD)
060 * @since GeoAPI 2.0
061 *
062 * @see GridCoverageExchange#getWriter
063 * @see javax.imageio.ImageWriter
064 *
065 * @deprecated In favor of migrating to ISO 19123 definition for Coverage.
066 */
067 @Deprecated
068 public interface GridCoverageWriter {
069 /**
070 * Returns the format handled by this {@code GridCoverageWriter}.
071 */
072 Format getFormat();
073
074 /**
075 * Returns the output destination. This is the object passed to the
076 * {@link GridCoverageExchange#getWriter} method. It can be a
077 * {@link java.lang.String}, an {@link java.io.OutputStream},
078 * a {@link java.nio.channels.FileChannel}, etc.
079 */
080 Object getDestination();
081
082 /**
083 * Returns the list of metadata keywords associated with the {@linkplain #getDestination
084 * output destination} as a whole (not associated with any particular grid coverage).
085 * If no metadata is allowed, the array will be empty.
086 *
087 * @return The list of metadata keywords for the output destination.
088 * @throws IOException if an error occurs during reading or writing.
089 *
090 * @todo This javadoc may not apply thats well in the iterator scheme.
091 */
092 String[] getMetadataNames();
093
094 /**
095 * Sets the metadata value for a given metadata name.
096 *
097 * @param name Metadata keyword for which to set the metadata.
098 * @param value The metadata value for the given metadata name.
099 * @throws IOException if an error occurs during writing.
100 *
101 * @todo This javadoc may not apply thats well in the iterator scheme.
102 */
103 void setMetadataValue(String name, String value) throws IOException;
104
105 /**
106 * Set the name for the next grid coverage to {@linkplain #write write} within the
107 * {@linkplain #getDestination output destination}. The subname can been fetch later
108 * at reading time.
109 *
110 * @throws IOException if an error occurs during writing.
111 * @todo Do we need a special method for that, or should it be a metadata?
112 */
113 void setCurrentSubname(String name) throws IOException;
114
115 /**
116 * Writes the specified grid coverage.
117 *
118 * @param coverage The {@linkplain GridCoverage grid coverage} to write.
119 * @param parameters An optional set of parameters. Should be any or all of the
120 * parameters returned by {@link Format#getWriteParameters}.
121 * @throws InvalidParameterNameException if a parameter in {@code parameters}
122 * doesn't have a recognized name.
123 * @throws InvalidParameterValueException if a parameter in {@code parameters}
124 * doesn't have a valid value.
125 * @throws ParameterNotFoundException if a parameter was required for the operation but was
126 * not provided in the {@code parameters} list.
127 * @throws FileFormatNotCompatibleWithGridCoverageException if the grid coverage
128 * can't be exported in the {@linkplain #getFormat writer format}.
129 * @throws IOException if the export failed for some other input/output reason, including
130 * {@link javax.imageio.IIOException} if an error was thrown by the underlying
131 * image library.
132 */
133 void write(GridCoverage coverage, GeneralParameterValue[] parameters)
134 throws IllegalArgumentException, IOException;
135
136 /**
137 * Allows any resources held by this object to be released. The result of calling any other
138 * method subsequent to a call to this method is undefined. It is important for applications
139 * to call this method when they know they will no longer be using this {@code GridCoverageWriter}.
140 * Otherwise, the writer may continue to hold on to resources indefinitely.
141 *
142 * @throws IOException if an error occured while disposing resources
143 * (for example while flushing data and closing a file).
144 */
145 void dispose() throws IOException;
146 }