001/* 002 * GeoAPI - Java interfaces for OGC/ISO standards 003 * Copyright © 2004-2024 Open Geospatial Consortium, Inc. 004 * http://www.geoapi.org 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); 007 * you may not use this file except in compliance with the License. 008 * You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.opengis.metadata.spatial; 019 020import org.opengis.util.CodeList; 021import org.opengis.annotation.UML; 022import org.opengis.geoapi.internal.Vocabulary; 023 024import static org.opengis.annotation.Obligation.*; 025import static org.opengis.annotation.Specification.*; 026 027 028/** 029 * Name of point and vector spatial objects used to locate zero-, one-, and two-dimensional 030 * spatial locations in the dataset. 031 * 032 * @author Martin Desruisseaux (IRD) 033 * @author Cory Horner (Refractions Research) 034 * @version 3.1 035 * @since 2.0 036 */ 037@Vocabulary(capacity=6) 038@UML(identifier="MD_GeometricObjectTypeCode", specification=ISO_19115) 039public final class GeometricObjectType extends CodeList<GeometricObjectType> { 040 /** 041 * Serial number for compatibility with different versions. 042 */ 043 private static final long serialVersionUID = -8910485325021913980L; 044 045 /** 046 * Set of geometric primitives such that their boundaries can be represented as a 047 * union of other primitives. 048 */ 049 @UML(identifier="complex", obligation=CONDITIONAL, specification=ISO_19115) 050 public static final GeometricObjectType COMPLEX = new GeometricObjectType("COMPLEX"); 051 052 /** 053 * Connected set of curves, solids or surfaces. 054 */ 055 @UML(identifier="composite", obligation=CONDITIONAL, specification=ISO_19115) 056 public static final GeometricObjectType COMPOSITE = new GeometricObjectType("COMPOSITE"); 057 058 /** 059 * Bounded, 1-dimensional geometric primitive, representing the continuous image of a line. 060 */ 061 @UML(identifier="curve", obligation=CONDITIONAL, specification=ISO_19115) 062 public static final GeometricObjectType CURVE = new GeometricObjectType("CURVE"); 063 064 /** 065 * Zero-dimensional geometric primitive, representing a position but not having an extent. 066 */ 067 @UML(identifier="point", obligation=CONDITIONAL, specification=ISO_19115) 068 public static final GeometricObjectType POINT = new GeometricObjectType("POINT"); 069 070 /** 071 * Bounded, connected 3-dimensional geometric primitive, representing the 072 * continuous image of a region of space. 073 */ 074 @UML(identifier="solid", obligation=CONDITIONAL, specification=ISO_19115) 075 public static final GeometricObjectType SOLID = new GeometricObjectType("SOLID"); 076 077 /** 078 * Bounded, connected 2-dimensional geometric, representing the continuous image 079 * of a region of a plane. 080 */ 081 @UML(identifier="surface", obligation=CONDITIONAL, specification=ISO_19115) 082 public static final GeometricObjectType SURFACE = new GeometricObjectType("SURFACE"); 083 084 /** 085 * Constructs an element of the given name. 086 * 087 * @param name the name of the new element. This name shall not be in use by another element of this type. 088 */ 089 private GeometricObjectType(final String name) { 090 super(name); 091 } 092 093 /** 094 * Returns the list of {@code GeometricObjectType}s. 095 * 096 * @return the list of codes declared in the current JVM. 097 */ 098 public static GeometricObjectType[] values() { 099 return values(GeometricObjectType.class); 100 } 101 102 /** 103 * Returns the list of codes of the same kind as this code list element. 104 * Invoking this method is equivalent to invoking {@link #values()}, except that 105 * this method can be invoked on an instance of the parent {@code CodeList} class. 106 * 107 * @return all code {@linkplain #values() values} for this code list. 108 */ 109 @Override 110 public GeometricObjectType[] family() { 111 return values(); 112 } 113 114 /** 115 * Returns the geometric object type that matches the given string, or returns a new one if none match it. 116 * This methods returns the first instance (in declaration order) for which the {@linkplain #name() name} 117 * is {@linkplain String#equalsIgnoreCase(String) equals, ignoring case}, to the given name. 118 * If no existing instance is found, then a new one is created for the given name. 119 * 120 * @param code the name of the code to fetch or to create. 121 * @return a code matching the given name. 122 */ 123 public static GeometricObjectType valueOf(String code) { 124 return valueOf(GeometricObjectType.class, code, GeometricObjectType::new).get(); 125 } 126}