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    import java.util.Collection; // For javadoc
037    import org.opengis.util.CodeList;
038    import org.opengis.geometry.DirectPosition;
039    import org.opengis.annotation.UML;
040    
041    import static org.opengis.annotation.Obligation.*;
042    import static org.opengis.annotation.Specification.*;
043    
044    
045    /**
046     * List of codes that identify methods for handling cases where the {@linkplain DirectPosition direct position}
047     * input to the {@link Coverage#evaluate(DirectPosition,Collection) evaluate} operation falls within
048     * two or more of the geometric objects. The interpretation of these rules differs between discrete
049     * and continuous coverages. In the case of a {@linkplain DiscreteCoverage discrete coverage}, each
050     * <var>geometry</var>-<var>value</var> pair provides one value for each attribute. The rule is applied
051     * to the set of values associated with the set of <var>geometry</var>-<var>value</var> pairs that contain
052     * the direct position. In the case of a continuous coverage, a value for each attribute shall be interpolated
053     * for each {@link ValueObject} that contains the direct position. The rule shall then be applied to the set
054     * of interpolated values for each attribute.
055     *
056     * @version ISO 19123:2004
057     * @author  Martin Desruisseaux (IRD)
058     * @author  Stephane Fellah
059     * @since   GeoAPI 2.1
060     *
061     * @see Coverage#getCommonPointRule
062     */
063    @UML(identifier="CV_CommonPointRule", specification=ISO_19123)
064    public class CommonPointRule extends CodeList<CommonPointRule> {
065        /**
066         * Serial number for compatibility with different versions.
067         */
068        private static final long serialVersionUID = -2713234273445009558L;
069    
070        /**
071         * List of all enumerations of this type.
072         * Must be declared before any enum declaration.
073         */
074        private static final List<CommonPointRule> VALUES = new ArrayList<CommonPointRule>(6);
075    
076        /**
077         * The mean of the feature attribute values.
078         */
079        @UML(identifier="average", obligation=CONDITIONAL, specification=ISO_19123)
080        public static final CommonPointRule AVERAGE = new CommonPointRule("AVERAGE");
081    
082        /**
083         * The least of the feature attribute values.
084         */
085        @UML(identifier="low", obligation=CONDITIONAL, specification=ISO_19123)
086        public static final CommonPointRule LOW = new CommonPointRule("LOW");
087    
088        /**
089         * The greatest of the feature attribute values.
090         */
091        @UML(identifier="high", obligation=CONDITIONAL, specification=ISO_19123)
092        public static final CommonPointRule HIGH = new CommonPointRule("HIGH");
093    
094        /**
095         * All the feature attribute values that can be determined for the input direct position.
096         */
097        @UML(identifier="all", obligation=CONDITIONAL, specification=ISO_19123)
098        public static final CommonPointRule ALL = new CommonPointRule("ALL");
099    
100        /**
101         * The {@linkplain ValueSegment#getStartParameter start value} of the second
102         * {@linkplain ValueSegment value segment}.
103         * Applies only to segmented curve coverages.
104         */
105        @UML(identifier="start", obligation=CONDITIONAL, specification=ISO_19123)
106        public static final CommonPointRule START = new CommonPointRule("START");
107    
108        /**
109         * The {@linkplain ValueSegment#getEndParameter end value} of the first
110         * {@linkplain ValueSegment value segment}.
111         * Applies only to segmented curve coverages.
112         */
113        @UML(identifier="end", obligation=CONDITIONAL, specification=ISO_19123)
114        public static final CommonPointRule END = new CommonPointRule("END");
115    
116        /**
117         * Constructs an enum with the given name. The new enum is
118         * automatically added to the list returned by {@link #values}.
119         *
120         * @param name The enum name. This name must not be in use by an other enum of this type.
121         */
122        private CommonPointRule(final String name) {
123            super(name, VALUES);
124        }
125    
126        /**
127         * Returns the list of {@code CommonPointRule}s.
128         *
129         * @return The list of codes declared in the current JVM.
130         */
131        public static CommonPointRule[] values() {
132            synchronized (VALUES) {
133                return VALUES.toArray(new CommonPointRule[VALUES.size()]);
134            }
135        }
136    
137        /**
138         * Returns the list of enumerations of the same kind than this enum.
139         *
140         * @return All common point rules defined.
141         */
142        public CommonPointRule[] family() {
143            return values();
144        }
145    
146        /**
147         * Returns the common point rule that matches the given string, or returns a
148         * new one if none match it. More specifically, this methods returns the first instance for
149         * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code>
150         * returns {@code true}. If no existing instance is found, then a new one is created for
151         * the given name.
152         *
153         * @param code The name of the code to fetch or to create.
154         * @return A code matching the given name.
155         */
156        public static CommonPointRule valueOf(String code) {
157            return valueOf(CommonPointRule.class, code);
158        }
159    }