001/* 002 * GeoAPI - Java interfaces for OGC/ISO standards 003 * Copyright © 2003-2023 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.referencing.datum; 019 020import java.util.Map; 021import java.util.Date; 022import java.util.Collection; 023import java.time.temporal.Temporal; 024import javax.measure.Unit; 025import javax.measure.quantity.Angle; 026import javax.measure.quantity.Length; 027import org.opengis.referencing.ObjectFactory; 028import org.opengis.util.FactoryException; 029import org.opengis.util.UnimplementedServiceException; 030import org.opengis.metadata.quality.PositionalAccuracy; 031import org.opengis.annotation.UML; 032 033import static org.opengis.annotation.Specification.*; 034 035 036/** 037 * Builds up complex datum objects from simpler objects or values. 038 * {@code DatumFactory} allows applications to make {@linkplain Datum datums} 039 * that cannot be created by a {@link DatumAuthorityFactory}. 040 * This factory is very flexible, whereas the authority factory is easier to use. 041 * So {@link DatumAuthorityFactory} can be used to make "standard" datums, 042 * and {@code DatumFactory} can be used to make "special" datums. 043 * 044 * <h2>Default methods</h2> 045 * All {@code create(…)} methods in this interface are optional. 046 * If a method is not overridden by the implementer, 047 * the default is to throw an {@link UnimplementedServiceException} 048 * with a message saying that the type or service is not supported. 049 * 050 * @author OGC 01-009 (for abstract model and documentation) 051 * @author Martin Desruisseaux (IRD, Geomatys) 052 * @author Johann Sorel (Geomatys) 053 * @version 3.1 054 * @since 1.0 055 * 056 * @see org.opengis.referencing.cs.CSFactory 057 * @see org.opengis.referencing.crs.CRSFactory 058 */ 059@UML(identifier="CS_CoordinateSystemFactory", specification=OGC_01009) 060public interface DatumFactory extends ObjectFactory { 061 /** 062 * Creates an ellipsoid from radius values. 063 * The {@code properties} map shall contain at least an entry for the {@value Ellipsoid#NAME_KEY} key. 064 * 065 * @param properties name and other properties to give to the new object. 066 * Available properties are {@linkplain ObjectFactory listed there}. 067 * @param semiMajorAxis equatorial radius in supplied linear units. 068 * @param semiMinorAxis polar radius in supplied linear units. 069 * @param unit linear units of ellipsoid axes. 070 * @return the ellipsoid for the given properties. 071 * @throws FactoryException if the object creation failed. 072 */ 073 @UML(identifier="createEllipsoid", specification=OGC_01009) 074 default Ellipsoid createEllipsoid(Map<String,?> properties, 075 double semiMajorAxis, 076 double semiMinorAxis, 077 Unit<Length> unit) throws FactoryException 078 { 079 throw new UnimplementedServiceException(this, Ellipsoid.class); 080 } 081 082 /** 083 * Creates an ellipsoid from an major radius, and inverse flattening. 084 * The {@code properties} map shall contain at least an entry for the {@value Ellipsoid#NAME_KEY} key. 085 * 086 * @param properties name and other properties to give to the new object. 087 * Available properties are {@linkplain ObjectFactory listed there}. 088 * @param semiMajorAxis equatorial radius in supplied linear units. 089 * @param inverseFlattening eccentricity of ellipsoid. 090 * @param unit linear units of major axis. 091 * @return the ellipsoid for the given properties. 092 * @throws FactoryException if the object creation failed. 093 */ 094 @UML(identifier="createFlattenedSphere", specification=OGC_01009) 095 default Ellipsoid createFlattenedSphere(Map<String,?> properties, 096 double semiMajorAxis, 097 double inverseFlattening, 098 Unit<Length> unit) throws FactoryException 099 { 100 throw new UnimplementedServiceException(this, Ellipsoid.class, "flattened"); 101 } 102 103 /** 104 * Creates a prime meridian, relative to Greenwich. 105 * The {@code properties} map shall contain at least an entry for the {@value PrimeMeridian#NAME_KEY} key. 106 * 107 * @param properties name and other properties to give to the new object. 108 * Available properties are {@linkplain ObjectFactory listed there}. 109 * @param longitude longitude of prime meridian in supplied angular units East of Greenwich. 110 * @param unit angular units of longitude. 111 * @return the prime meridian for the given properties. 112 * @throws FactoryException if the object creation failed. 113 */ 114 @UML(identifier="createPrimeMeridian", specification=OGC_01009) 115 default PrimeMeridian createPrimeMeridian(Map<String,?> properties, 116 double longitude, 117 Unit<Angle> unit) throws FactoryException 118 { 119 throw new UnimplementedServiceException(this, PrimeMeridian.class); 120 } 121 122 /** 123 * Creates geodetic reference frame from ellipsoid and prime meridian. 124 * The {@code properties} map shall contain at least an entry for the {@value Datum#NAME_KEY} key. 125 * 126 * @param properties name and other properties to give to the new object. 127 * Available properties are {@linkplain ObjectFactory listed there}. 128 * @param ellipsoid ellipsoid to use in new geodetic reference frame. 129 * @param primeMeridian prime meridian to use in new geodetic reference frame. 130 * @return the datum for the given properties. 131 * @throws FactoryException if the object creation failed. 132 */ 133 @UML(identifier="createHorizontalDatum", specification=OGC_01009) 134 default GeodeticDatum createGeodeticDatum(Map<String,?> properties, 135 Ellipsoid ellipsoid, 136 PrimeMeridian primeMeridian) throws FactoryException 137 { 138 throw new UnimplementedServiceException(this, GeodeticDatum.class); 139 } 140 141 /** 142 * Creates a vertical datum from an enumerated type value. 143 * The {@code properties} map shall contain at least an entry for the {@value Datum#NAME_KEY} key. 144 * 145 * @param properties name and other properties to give to the new object. 146 * Available properties are {@linkplain ObjectFactory listed there}. 147 * @param type the type of this vertical datum (often "geoidal"). 148 * @return the datum for the given properties. 149 * @throws FactoryException if the object creation failed. 150 * 151 * @deprecated Replaced by {@link #createVerticalDatum(Map, RealizationMethod)}. 152 */ 153 @Deprecated(since = "3.1") 154 @UML(identifier="createVerticalDatum", specification=OGC_01009) 155 default VerticalDatum createVerticalDatum(Map<String,?> properties, 156 VerticalDatumType type) throws FactoryException 157 { 158 throw new UnimplementedServiceException(this, VerticalDatum.class); 159 } 160 161 /** 162 * Creates a vertical datum from an enumerated type value. 163 * The {@code properties} map shall contain at least an entry for the {@value Datum#NAME_KEY} key. 164 * 165 * @param properties name and other properties to give to the new object. 166 * Available properties are {@linkplain ObjectFactory listed there}. 167 * @param method the realization method of this vertical datum, or {@code null} if unspecified. 168 * @return the datum for the given properties. 169 * @throws FactoryException if the object creation failed. 170 * 171 * @since 3.1 172 */ 173 default VerticalDatum createVerticalDatum(Map<String,?> properties, 174 RealizationMethod method) throws FactoryException 175 { 176 throw new UnimplementedServiceException(this, VerticalDatum.class); 177 } 178 179 /** 180 * Creates a temporal datum from a temporal origin. 181 * 182 * @param properties name and other properties to give to the new object. 183 * Available properties are {@linkplain ObjectFactory listed there}. 184 * @param origin the date and time origin of this temporal datum. 185 * The {@link java.time.Instant} sub-type is recommended. 186 * @return the datum for the given properties. 187 * @throws FactoryException if the object creation failed. 188 * 189 * @deprecated The {@code origin} argument type has been changed from {@link Date} to {@link Temporal}. 190 */ 191 @Deprecated(since = "3.1") 192 default TemporalDatum createTemporalDatum(Map<String,?> properties, Date origin) throws FactoryException { 193 return createTemporalDatum(properties, origin.toInstant()); 194 } 195 196 /** 197 * Creates a temporal datum from a temporal origin. 198 * The {@code properties} map shall contain at least an entry for the {@value Datum#NAME_KEY} key. 199 * 200 * @param properties name and other properties to give to the new object. 201 * Available properties are {@linkplain ObjectFactory listed there}. 202 * @param origin the date and time origin of this temporal datum. 203 * The {@link java.time.Instant} sub-type is recommended. 204 * @return the datum for the given properties. 205 * @throws FactoryException if the object creation failed. 206 * 207 * @since 3.1 208 */ 209 default TemporalDatum createTemporalDatum(Map<String,?> properties, Temporal origin) throws FactoryException { 210 throw new UnimplementedServiceException(this, TemporalDatum.class); 211 } 212 213 /** 214 * Creates a parametric datum. 215 * The {@code properties} map shall contain at least an entry for the {@value Datum#NAME_KEY} key. 216 * 217 * @param properties name and other properties to give to the new object. 218 * Available properties are {@linkplain ObjectFactory listed there}. 219 * @return the datum for the given properties. 220 * @throws FactoryException if the object creation failed. 221 * 222 * @since 3.1 223 */ 224 default ParametricDatum createParametricDatum(Map<String,?> properties) throws FactoryException { 225 throw new UnimplementedServiceException(this, ParametricDatum.class); 226 } 227 228 /** 229 * Creates an engineering datum. 230 * The {@code properties} map shall contain at least an entry for the {@value Datum#NAME_KEY} key. 231 * 232 * @param properties name and other properties to give to the new object. 233 * Available properties are {@linkplain ObjectFactory listed there}. 234 * @return the datum for the given properties. 235 * @throws FactoryException if the object creation failed. 236 */ 237 @UML(identifier="createLocalDatum", specification=OGC_01009) 238 default EngineeringDatum createEngineeringDatum(Map<String,?> properties) throws FactoryException { 239 throw new UnimplementedServiceException(this, EngineeringDatum.class); 240 } 241 242 /** 243 * Creates an image datum. 244 * 245 * @param properties name and other properties to give to the new object. 246 * Available properties are {@linkplain ObjectFactory listed there}. 247 * @param pixelInCell specification of the way the image grid is associated 248 * with the image data attributes. 249 * @return the datum for the given properties. 250 * @throws FactoryException if the object creation failed. 251 * 252 * @deprecated {@code ImageDatum} is replaced by {@link EngineeringDatum} as of ISO 19111:2019. 253 */ 254 @Deprecated(since="3.1") 255 default ImageDatum createImageDatum(Map<String,?> properties, 256 PixelInCell pixelInCell) throws FactoryException 257 { 258 throw new UnimplementedServiceException(this, ImageDatum.class); 259 } 260 261 /** 262 * Creates a datum ensemble from a collection of members. 263 * The {@code properties} map shall contain at least an entry for the {@value DatumEnsemble#NAME_KEY} key. 264 * 265 * @param <D> the type of datum contained in the ensemble. 266 * @param properties name and other properties to give to the new object. 267 * Available properties are {@linkplain ObjectFactory listed there}. 268 * @param members datum or reference frames which are members of the datum ensemble. 269 * @param accuracy inaccuracy introduced through use of the given collection of datums. 270 * @return the datum ensemble for the given properties. 271 * @throws FactoryException if the object creation failed. 272 * 273 * @since 3.1 274 */ 275 default <D extends Datum> DatumEnsemble<D> createDatumEnsemble(Map<String,?> properties, 276 Collection<D> members, PositionalAccuracy accuracy) throws FactoryException 277 { 278 throw new UnimplementedServiceException(this, DatumEnsemble.class); 279 } 280}