This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit c351e038b5d6c83a41b6f6b559d17238b5cfd7b4 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Sun Apr 3 16:04:43 2022 +0200 Move `DEFAULT_CRS` from `OptionKey` to `DataOptionKey`. Conceptually, CRS is more about the data than the carrier format. --- .../main/java/org/apache/sis/setup/OptionKey.java | 14 +----------- .../apache/sis/internal/storage/PRJDataStore.java | 26 +++++++++++----------- .../java/org/apache/sis/storage/DataOptionKey.java | 14 +++++++++++- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java b/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java index 54911c6..8aebfad 100644 --- a/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java +++ b/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java @@ -29,7 +29,6 @@ import java.util.TimeZone; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.logging.Logging; import org.apache.sis.internal.system.Modules; -import org.opengis.referencing.crs.CoordinateReferenceSystem; /** @@ -62,7 +61,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem; * } * * @author Martin Desruisseaux (Geomatys) - * @version 1.2 + * @version 0.8 * * @param <T> the type of option values. * @@ -193,17 +192,6 @@ public class OptionKey<T> implements Serializable { public static final OptionKey<GeometryLibrary> GEOMETRY_LIBRARY = new OptionKey<>("GEOMETRY_LIBRARY", GeometryLibrary.class); /** - * The coordinate reference system (CRS) of data to use if not explicitly defined. - * This option can be used when the file to read does not describe itself the data CRS. - * For example this option can be used when reading ASCII Grid without CRS information, - * but is ignored if the ASCII Grid file is accompanied by a {@code *.prj} file giving the CRS. - * - * @since 1.2 - */ - public static final OptionKey<CoordinateReferenceSystem> DEFAULT_CRS = - new OptionKey<>("DEFAULT_CRS", CoordinateReferenceSystem.class); - - /** * The number of spaces to use for indentation when formatting text files in WKT or XML formats. * A value of {@value org.apache.sis.io.wkt.WKTFormat#SINGLE_LINE} means to format the whole WKT * or XML document on a single line without line feeds or indentation. diff --git a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/PRJDataStore.java b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/PRJDataStore.java index f339599..0a5a548 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/PRJDataStore.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/PRJDataStore.java @@ -34,6 +34,7 @@ import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.parameter.ParameterValueGroup; import org.opengis.referencing.crs.CoordinateReferenceSystem; +import org.apache.sis.storage.DataOptionKey; import org.apache.sis.storage.DataStore; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.DataStoreProvider; @@ -43,7 +44,6 @@ import org.apache.sis.internal.storage.wkt.StoreFormat; import org.apache.sis.io.wkt.Convention; import org.apache.sis.parameter.ParameterBuilder; import org.apache.sis.parameter.Parameters; -import org.apache.sis.setup.OptionKey; import org.apache.sis.util.resources.Vocabulary; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.ArraysExt; @@ -51,13 +51,13 @@ import org.apache.sis.util.ArraysExt; /** * A data store for a file or URI accompanied by an auxiliary file of the same name with {@code .prj} extension. - * If the auxiliary file is absent, {@link OptionKey#DEFAULT_CRS} is used as a fallback. + * If the auxiliary file is absent, {@link DataOptionKey#DEFAULT_CRS} is used as a fallback. * The WKT 1 variant used for parsing the {@code "*.prj"} file is the variant used by "World Files" and GDAL; * this is not the standard specified by OGC 01-009 (they differ in there interpretation of units of measurement). * * <p>It is still possible to create a data store with a {@link java.nio.channels.ReadableByteChannel}, * {@link java.io.InputStream} or {@link java.io.Reader}, in which case the {@linkplain #location} will - * be null and the CRS defined by the {@code OptionKey} will be used.</p> + * be null and the CRS defined by the {@code DataOptionKey} will be used.</p> * * @author Martin Desruisseaux (Geomatys) * @version 1.2 @@ -92,7 +92,7 @@ public abstract class PRJDataStore extends URIDataStore { private final TimeZone timezone; /** - * The coordinate reference system. This is initialized on the value provided by {@link OptionKey#DEFAULT_CRS} + * The coordinate reference system. This is initialized on the value provided by {@link DataOptionKey#DEFAULT_CRS} * at construction time, and is modified later if a {@code "*.prj"} file is found. */ protected CoordinateReferenceSystem crs; @@ -101,10 +101,10 @@ public abstract class PRJDataStore extends URIDataStore { * Creates a new data store. The following options are recognized: * * <ul> - * <li>{@link OptionKey#DEFAULT_CRS}: default CRS if no auxiliary {@code "*.prj"} file is found.</li> - * <li>{@link OptionKey#ENCODING}: encoding of the {@code "*.prj"} file. Default is the JVM default.</li> - * <li>{@link OptionKey#TIMEZONE}: timezone of dates in the {@code "*.prj"} file. Default is UTC.</li> - * <li>{@link OptionKey#LOCALE}: locale for texts in the {@code "*.prj"} file. Default is English.</li> + * <li>{@link DataOptionKey#DEFAULT_CRS}: default CRS if no auxiliary {@code "*.prj"} file is found.</li> + * <li>{@link DataOptionKey#ENCODING}: encoding of the {@code "*.prj"} file. Default is the JVM default.</li> + * <li>{@link DataOptionKey#TIMEZONE}: timezone of dates in the {@code "*.prj"} file. Default is UTC.</li> + * <li>{@link DataOptionKey#LOCALE}: locale for texts in the {@code "*.prj"} file. Default is English.</li> * </ul> * * @param provider the factory that created this {@code PRJDataStore} instance, or {@code null} if unspecified. @@ -113,10 +113,10 @@ public abstract class PRJDataStore extends URIDataStore { */ protected PRJDataStore(final DataStoreProvider provider, final StorageConnector connector) throws DataStoreException { super(provider, connector); - crs = connector.getOption(OptionKey.DEFAULT_CRS); - encoding = connector.getOption(OptionKey.ENCODING); - locale = connector.getOption(OptionKey.LOCALE); // For `InternationalString`, not for numbers. - timezone = connector.getOption(OptionKey.TIMEZONE); + crs = connector.getOption(DataOptionKey.DEFAULT_CRS); + encoding = connector.getOption(DataOptionKey.ENCODING); + locale = connector.getOption(DataOptionKey.LOCALE); // For `InternationalString`, not for numbers. + timezone = connector.getOption(DataOptionKey.TIMEZONE); } /** @@ -298,7 +298,7 @@ public abstract class PRJDataStore extends URIDataStore { ArgumentChecks.ensureNonNull("parameter", parameters); final StorageConnector connector = connector(this, parameters); final Parameters pg = Parameters.castOrWrap(parameters); - connector.setOption(OptionKey.DEFAULT_CRS, pg.getValue(DEFAULT_CRS)); + connector.setOption(DataOptionKey.DEFAULT_CRS, pg.getValue(DEFAULT_CRS)); return open(connector); } } diff --git a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java index 699dcf5..208f62c 100644 --- a/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java +++ b/storage/sis-storage/src/main/java/org/apache/sis/storage/DataOptionKey.java @@ -18,6 +18,7 @@ package org.apache.sis.storage; import org.apache.sis.setup.OptionKey; import org.apache.sis.feature.FoliationRepresentation; +import org.opengis.referencing.crs.CoordinateReferenceSystem; /** @@ -26,7 +27,7 @@ import org.apache.sis.feature.FoliationRepresentation; * or other kinds of structure that are specific to some data formats. * * @author Martin Desruisseaux (Geomatys) - * @version 1.0 + * @version 1.2 * * @param <T> the type of option values. * @@ -40,6 +41,17 @@ public final class DataOptionKey<T> extends OptionKey<T> { private static final long serialVersionUID = 8927757348322016043L; /** + * The coordinate reference system (CRS) of data to use if not explicitly defined. + * This option can be used when the file to read does not describe itself the data CRS. + * For example this option can be used when reading ASCII Grid without CRS information, + * but is ignored if the ASCII Grid file is accompanied by a {@code *.prj} file giving the CRS. + * + * @since 1.2 + */ + public static final OptionKey<CoordinateReferenceSystem> DEFAULT_CRS = + new DataOptionKey<>("DEFAULT_CRS", CoordinateReferenceSystem.class); + + /** * Whether to assemble trajectory fragments (distinct CSV lines) into a single {@code Feature} instance * forming a foliation. This is ignored if the file does not seem to contain moving features. *