sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Allow DecimalFormat precision to be set even if the CRS is unknown (in which case a generic number format is used).
Date Mon, 16 Mar 2020 22:25:01 GMT
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


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 791558a  Allow DecimalFormat precision to be set even if the CRS is unknown (in which
case a generic number format is used).
791558a is described below

commit 791558a008ec054ff8f59c6de89c3c7c20d13f4b
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Mar 16 23:24:10 2020 +0100

    Allow DecimalFormat precision to be set even if the CRS is unknown (in which case a generic
number format is used).
---
 .../main/java/org/apache/sis/geometry/CoordinateFormat.java | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

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 3d8176b..4638060 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
@@ -875,7 +875,18 @@ public class CoordinateFormat extends CompoundFormat<DirectPosition>
{
         if (crs != lastCRS) {
             configure(crs);
         }
-        if (desiredPrecisions != null && formats != null && formats == sharedFormats)
{
+        /*
+         * Unconditionally configure the formatters for the desired precisions because those
precisions
+         * may change for every point. Note that the formatters may not have been created
if the CRS is
+         * null (because `configure(…)` does not know which format to use), in which case
generic number
+         * formats will be used.
+         */
+        if (desiredPrecisions != null) {
+            if (sharedFormats == null) {
+                formats = sharedFormats = new Format[desiredPrecisions.length];
+                Arrays.fill(formats, getDefaultFormat());
+                types = new byte[formats.length];
+            }
             final int n = Math.min(desiredPrecisions.length, formats.length);
             for (int i=0; i<n; i++) {
                 applyPrecision(i);


Mime
View raw message