001 /*
002 * GeoAPI - Java interfaces for OGC/ISO standards
003 * http://www.geoapi.org
004 *
005 * Copyright (C) 2005-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;
033
034 import java.util.List;
035 import java.util.ArrayList;
036
037 import org.opengis.util.CodeList;
038 import org.opengis.annotation.UML;
039
040 import static org.opengis.annotation.Obligation.*;
041 import static org.opengis.annotation.Specification.*;
042
043
044 /**
045 * A list of codes that identify interpolation methods that may be used for evaluating
046 * {@linkplain ContinuousCoverage continuous coverages}. Evaluation of a continuous coverage
047 * involves interpolation between known feature attribute values associated with geometric
048 * objects in the domain of the {@linkplain DiscreteCoverage discrete coverage} that is provided
049 * as control for the continuous coverage. This code list includes 9 interpolation methods. Each
050 * is used in the context of specified geometric configurations (table below). Since
051 * {@code InterpolationMethod} is a {@code CodeList}, it may be extended in an application
052 * schema that specifies additional interpolation methods.
053 * <p>
054 * <table border="1" cellspacing="0" cellpadding="2">
055 * <tr><th>Method</th> <th>Coverage Type</th> <th>Value object dimension</th></tr>
056 * <tr><td>Nearest Neighbour</td><td>Any</td> <td>Any</td></tr>
057 * <tr><td>Linear</td> <td>Segmented Curve</td> <td>1</td></tr>
058 * <tr><td>Quadratic</td> <td>Segmented Curve</td> <td>1</td></tr>
059 * <tr><td>Cubic</td> <td>Segmented Curve</td> <td>1</td></tr>
060 * <tr><td>Bilinear</td> <td>Quadrilateral Grid</td> <td>2</td></tr>
061 * <tr><td>Biquadratic</td> <td>Quadrilateral Grid</td> <td>2</td></tr>
062 * <tr><td>Bicubic</td> <td>Quadrilateral Grid</td> <td>2</td></tr>
063 * <tr><td>Lost Area</td> <td>Thiessen Polygon, Hexagonal Grid</td><td>2</td></tr>
064 * <tr><td>Barycentric</td> <td>TIN</td> <td>2</td></tr>
065 * </table>
066 *
067 * @version ISO 19123:2004
068 * @author Martin Desruisseaux (IRD)
069 * @since GeoAPI 2.1
070 */
071 @UML(identifier="CV_InterpolationMethod", specification=ISO_19123)
072 public class InterpolationMethod extends CodeList<InterpolationMethod> {
073 /**
074 * Serial number for compatibility with different versions.
075 */
076 private static final long serialVersionUID = -4289541167757079847L;
077
078 /**
079 * List of all enumerations of this type.
080 * Must be declared before any enum declaration.
081 */
082 private static final List<InterpolationMethod> VALUES = new ArrayList<InterpolationMethod>(9);
083
084 /**
085 * Generates a feature attribute value at a direct position by assigning it the feature attribute
086 * value associated with the nearest domain object in the domain of the coverage. Nearest neighbour
087 * interpolation extends a discrete coverage to a step function defined on the convex hull of the
088 * domain objects in the domain of the coverage. Nearest neighbour interpolation is the only interpolation
089 * method described in ISO 19123 that can be used to interpolate attributes that have nominal or
090 * ordinal values.
091 * <p>
092 * <B>NOTE:</B> In the case of a discrete point coverage, the "steps" of the step function are
093 * the Thiessen polygons generated by the set of points in the domain of the coverage.
094 */
095 @UML(identifier="Nearest neighbour", obligation=CONDITIONAL, specification=ISO_19123)
096 public static final InterpolationMethod NEAREST_NEIGHBOUR = new InterpolationMethod("NEAREST_NEIGHBOUR");
097
098 /**
099 * Interpolation based on the assumption that feature attribute values vary in proportion to
100 * distance along a value segment.
101 * <p>
102 * <blockquote>
103 * <var>v</var> = <var>a</var> + <var>b</var><var>x</var>
104 * </blockquote>
105 * <p>
106 * Linear interpolation may be used to interpolate feature attribute values along a line segment
107 * connecting any two point value pairs. It may also be used to interpolate feature attribute values
108 * at positions along a curve of any form, if the positions are described by values of an arc-length
109 * parameter.
110 * <p>
111 * Given two point value pairs (<var>p</var><sub>s</sub>, </var>v</var><sub>s</sub>) and
112 * (<var>p</var><sub>t</sub>, <var>v</var><sub>t</sub>), where <var>p</var><sub>s</sub> is
113 * the start point and <var>p</var><sub>t</sub> is the end point of a value segment,
114 * and <var>v</var><sub>s</sub> and <var>v</var><sub>t</sub> are the feature attribute
115 * values associated with those points, the feature attribute value <var>v</var><sub>i</sub>
116 * associated with the direct position <var>p</var><sub>i</sub> is:
117 * <p>
118 * <blockquote>
119 * <var>v</var><sub>i</sub> = <var>v</var><sub>s</sub> + (<var>v</var><sub>t</sub> - <var>v</var><sub>s</sub>)
120 * ((<var>p</var><sub>i</sub> - <var>p</var><sub>s</sub>)/(<var>p</var><sub>t</sub> - <var>p<var><sub>s</sub>))
121 * </blockquote>
122 */
123 @UML(identifier="Linear interpolation", obligation=CONDITIONAL, specification=ISO_19123)
124 public static final InterpolationMethod LINEAR = new InterpolationMethod("LINEAR");
125
126 /**
127 * Interpolation based on the assumption that feature attribute values vary as a quadratic
128 * function of distance along a value segment.
129 * <p>
130 * <blockquote>
131 * <var>v</var> = <var>a</var>
132 * + <var>b</var><var>x</var>
133 * + <var>c</var><var>x</var><sup>2</sup>
134 * </blockquote>
135 * <p>
136 * where <var>a</var> is the value of a feature attribute at the start of a value segment and
137 * <var>v</var> is the value of a feature attribute at distance <var>x</var> along the curve
138 * from the start. Three point value pairs are needed to provide control values for calculating
139 * the coefficients of the function.
140 */
141 @UML(identifier="Quadratic interpolation", obligation=CONDITIONAL, specification=ISO_19123)
142 public static final InterpolationMethod QUADRATIC = new InterpolationMethod("QUADRATIC");
143
144 /**
145 * Interpolation based on the assumption that feature attribute values vary as a cubic function
146 * of distance along a value segment.
147 * <p>
148 * <blockquote>
149 * <var>v</var> = <var>a</var>
150 * + <var>b</var><var>x</var>
151 * + <var>c</var><var>x</var><sup>2</sup>
152 * + <var>d</var><var>x</var><sup>3</sup>
153 * </blockquote>
154 * <p>
155 * where <var>a</var> is the value of a feature attribute at the start of a value segment and
156 * <var>v</var> is the value of a feature attribute at distance <var>x</var> along the curve
157 * from the start. Four point value pairs are needed to provide control values for calculating
158 * the coefficients of the function.
159 */
160 @UML(identifier="Cubic interpolation", obligation=CONDITIONAL, specification=ISO_19123)
161 public static final InterpolationMethod CUBIC = new InterpolationMethod("CUBIC");
162
163 /**
164 * Interpolation based on the assumption that feature attribute values vary as a bilinear function
165 * of position within the grid cell.
166 */
167 @UML(identifier="Bilinear interpolation", obligation=CONDITIONAL, specification=ISO_19123)
168 public static final InterpolationMethod BILINEAR = new InterpolationMethod("BILINEAR");
169
170 /**
171 * Interpolation based on the assumption that feature attribute values vary as a biquadratic function
172 * of position within the grid cell.
173 */
174 @UML(identifier="Biquadratic interpolation", obligation=CONDITIONAL, specification=ISO_19123)
175 public static final InterpolationMethod BIQUADRATIC = new InterpolationMethod("BIQUADRATIC");
176
177 /**
178 * Interpolation based on the assumption that feature attribute values vary as a bicubic function
179 * of position within the grid cell.
180 */
181 @UML(identifier="Bicubic interpolation", obligation=CONDITIONAL, specification=ISO_19123)
182 public static final InterpolationMethod BICUBIC = new InterpolationMethod("BICUBIC");
183
184 /**
185 * Lost area interpolation.
186 */
187 @UML(identifier="Lost area interpolation", obligation=CONDITIONAL, specification=ISO_19123)
188 public static final InterpolationMethod LOST_AREA = new InterpolationMethod("LOST_AREA");
189
190 /**
191 * Barycentric interpolation.
192 */
193 @UML(identifier="Barycentric interpolation", obligation=CONDITIONAL, specification=ISO_19123)
194 public static final InterpolationMethod BARYCENTRIC = new InterpolationMethod("BARYCENTRIC");
195
196 /**
197 * Constructs an enum with the given name. The new enum is
198 * automatically added to the list returned by {@link #values}.
199 *
200 * @param name The enum name. This name must not be in use by an other enum of this type.
201 */
202 private InterpolationMethod(final String name) {
203 super(name, VALUES);
204 }
205
206 /**
207 * Returns the list of {@code InterpolationMethod}s.
208 *
209 * @return The list of codes declared in the current JVM.
210 */
211 public static InterpolationMethod[] values() {
212 synchronized (VALUES) {
213 return VALUES.toArray(new InterpolationMethod[VALUES.size()]);
214 }
215 }
216
217 /**
218 * Returns the list of enumerations of the same kind than this enum.
219 */
220 public InterpolationMethod[] family() {
221 return values();
222 }
223
224 /**
225 * Returns the interpolation method that matches the given string, or returns a
226 * new one if none match it. More specifically, this methods returns the first instance for
227 * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code>
228 * returns {@code true}. If no existing instance is found, then a new one is created for
229 * the given name.
230 *
231 * @param code The name of the code to fetch or to create.
232 * @return A code matching the given name.
233 */
234 public static InterpolationMethod valueOf(String code) {
235 return valueOf(InterpolationMethod.class, code);
236 }
237 }