001 /*
002 * GeoAPI - Java interfaces for OGC/ISO standards
003 * http://www.geoapi.org
004 *
005 * Copyright (C) 2004-2013 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.metadata.spatial;
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 * Point in a pixel corresponding to the Earth location of the pixel.
046 *
047 * <p>This code list is restricted to the two-dimensional case. A similar code
048 * list, {@link org.opengis.referencing.datum.PixelInCell}, can be used for
049 * <var>n</var>-dimensional grid cell.</p>
050 *
051 * @author Martin Desruisseaux (IRD)
052 * @version 3.0
053 * @since 2.0
054 *
055 * @see org.opengis.referencing.datum.PixelInCell
056 */
057 @UML(identifier="MD_PixelOrientationCode", specification=ISO_19115)
058 public final class PixelOrientation extends CodeList<PixelOrientation> {
059 /**
060 * Serial number for compatibility with different versions.
061 */
062 private static final long serialVersionUID = 7885677198357949308L;
063
064 /**
065 * List of all enumerations of this type.
066 * Must be declared before any enum declaration.
067 */
068 private static final List<PixelOrientation> VALUES = new ArrayList<PixelOrientation>(5);
069
070 /**
071 * Point in a pixel corresponding to the Earth location of the pixel.
072 *
073 * @see org.opengis.referencing.datum.PixelInCell#CELL_CENTER
074 */
075 @UML(identifier="center", obligation=CONDITIONAL, specification=ISO_19115)
076 public static final PixelOrientation CENTER = new PixelOrientation("CENTER");
077
078 /**
079 * The corner in the pixel closest to the origin of the SRS; if two are at the same
080 * distance from the origin, the one with the smallest x-value.
081 *
082 * @todo The sentence "<cite>closest to the origin of the SRS</cite> probably applies to
083 * positive coordinates only. For the general case including both positive and negative
084 * coordinates, we should probably read "in the direction of negative infinity". This
085 * interpretation should be clarified with ISO.
086 *
087 * @see org.opengis.referencing.datum.PixelInCell#CELL_CORNER
088 */
089 @UML(identifier="lowerLeft", obligation=CONDITIONAL, specification=ISO_19115)
090 public static final PixelOrientation LOWER_LEFT = new PixelOrientation("LOWER_LEFT");
091
092 /**
093 * Next corner counterclockwise from the {@linkplain #LOWER_LEFT lower left}.
094 */
095 @UML(identifier="lowerRight", obligation=CONDITIONAL, specification=ISO_19115)
096 public static final PixelOrientation LOWER_RIGHT = new PixelOrientation("LOWER_RIGHT");
097
098 /**
099 * Next corner counterclockwise from the {@linkplain #LOWER_RIGHT lower right}.
100 */
101 @UML(identifier="upperRight", obligation=CONDITIONAL, specification=ISO_19115)
102 public static final PixelOrientation UPPER_RIGHT = new PixelOrientation("UPPER_RIGHT");
103
104 /**
105 * Next corner counterclockwise from the {@linkplain #UPPER_RIGHT upper right}.
106 */
107 @UML(identifier="upperLeft", obligation=CONDITIONAL, specification=ISO_19115)
108 public static final PixelOrientation UPPER_LEFT = new PixelOrientation("UPPER_LEFT");
109
110 /**
111 * Constructs an element of the given name. The new element is
112 * automatically added to the list returned by {@link #values()}.
113 *
114 * @param name The name of the new element.
115 * This name must not be in use by an other element of this type.
116 */
117 private PixelOrientation(final String name) {
118 super(name, VALUES);
119 }
120
121 /**
122 * Returns the list of {@code PixelOrientation}s.
123 *
124 * @return The list of codes declared in the current JVM.
125 */
126 public static PixelOrientation[] values() {
127 synchronized (VALUES) {
128 return VALUES.toArray(new PixelOrientation[VALUES.size()]);
129 }
130 }
131
132 /**
133 * Returns the list of codes of the same kind than this code list element.
134 * Invoking this method is equivalent to invoking {@link #values()}, except that
135 * this method can be invoked on an instance of the parent {@code CodeList} class.
136 */
137 @Override
138 public PixelOrientation[] family() {
139 return values();
140 }
141
142 /**
143 * Returns the pixel orientation that matches the given string, or returns a
144 * new one if none match it. More specifically, this methods returns the first instance for
145 * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code>
146 * returns {@code true}. If no existing instance is found, then a new one is created for
147 * the given name.
148 *
149 * @param code The name of the code to fetch or to create.
150 * @return A code matching the given name.
151 */
152 public static PixelOrientation valueOf(String code) {
153 return valueOf(PixelOrientation.class, code);
154 }
155 }