You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2022/05/24 16:49:11 UTC
[sis] 02/05: More compact representation of the temporal coordinate in a (x,y,t) tuple.
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 6664478fd9674bcb575257c9c68ade2eb1521676
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Tue May 24 18:44:33 2022 +0200
More compact representation of the temporal coordinate in a (x,y,t) tuple.
---
.../org/apache/sis/geometry/CoordinateFormat.java | 27 +++++++++++++++++++++-
.../java/org/apache/sis/geometry/package-info.java | 2 +-
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java
index 7fd75e5ea1..e00e4329e7 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/CoordinateFormat.java
@@ -100,7 +100,7 @@ import static java.util.logging.Logger.getLogger;
* transform the position} before to format it.</p>
*
* @author Martin Desruisseaux (MPO, IRD, Geomatys)
- * @version 1.2
+ * @version 1.3
*
* @see AngleFormat
* @see org.apache.sis.measure.UnitFormat
@@ -1333,6 +1333,31 @@ abort: if (dimensions != 0 && groundAccuracy != null) try {
return DirectPosition.class;
}
+ /**
+ * Creates a new format to use for parsing and formatting values of the given type.
+ * This method is invoked by {@link #getFormat(Class)} the first time that a format
+ * is needed for the given type.
+ *
+ * <p>See {@linkplain CompoundFormat#createFormat(Class) super-class} for a description of recognized types.
+ * This method override uses the short date pattern instead of the (longer) default one.</p>
+ *
+ * @param valueType the base type of values to parse or format.
+ * @return the format to use for parsing of formatting values of the given type, or {@code null} if none.
+ */
+ @Override
+ protected Format createFormat(final Class<?> valueType) {
+ if (valueType == Date.class) {
+ final Locale locale = super.getLocale();
+ if (!Locale.ROOT.equals(locale)) {
+ final DateFormat format;
+ format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);
+ format.setTimeZone(getTimeZone());
+ return format;
+ }
+ }
+ return super.createFormat(valueType);
+ }
+
/**
* Formats the given coordinate.
* The type of each coordinate value (number, angle or date) is determined by the CRS of the given
diff --git a/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java b/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java
index 16eb301b67..f4500dbb9a 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java
@@ -87,7 +87,7 @@
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Alexis Manin (Geomatys)
- * @version 1.2
+ * @version 1.3
* @since 0.3
* @module
*/