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 d39d9c6c9481eb73e27c58b9bce001e618052e71
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sun Nov 12 14:54:43 2023 +0100

    Add a little bit of context when the parsing fail over the dash character,
    for example as in "away-from" axis direction.
    Reduce rounding errors in `GridGeometry.toString()`.
---
 .../main/org/apache/sis/coverage/grid/GridGeometry.java           | 2 +-
 .../main/org/apache/sis/util/CharSequences.java                   | 8 ++++++++
 .../test/org/apache/sis/util/CharSequencesTest.java               | 1 +
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
index bfbee84f27..2b727fd543 100644
--- 
a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
+++ 
b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/coverage/grid/GridGeometry.java
@@ -1931,7 +1931,7 @@ public class GridGeometry implements LenientComparable, 
Serializable {
                     final double upper = envelope.getUpper(i);
                     final double delta = (resolution != null) ? resolution[i] 
: Double.NaN;
                     
nf.setMinimumFractionDigits(Numerics.fractionDigitsForDelta(delta));
-                    
nf.setMaximumFractionDigits(Numerics.suggestFractionDigits(lower, upper));
+                    
nf.setMaximumFractionDigits(Numerics.suggestFractionDigits(lower, upper) - 1);  
  // The -1 is for rounding errors.
                     final CoordinateSystemAxis axis = (cs != null) ? 
cs.getAxis(i) : null;
                     final String name = (axis != null) ? 
axis.getName().getCode() : vocabulary.getString(Vocabulary.Keys.Dimension_1, i);
                     table.append(name).append(": ").nextColumn();
diff --git 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/CharSequences.java 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/CharSequences.java
index 91826d5ad1..1df0f9945f 100644
--- 
a/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/CharSequences.java
+++ 
b/endorsed/src/org.apache.sis.util/main/org/apache/sis/util/CharSequences.java
@@ -2083,6 +2083,8 @@ cmp:    while (ia < lga) {
      *       {@linkplain Character#isUnicodeIdentifierStart(int) Unicode 
identifier start},
      *       then any following characters that are
      *       {@linkplain Character#isUnicodeIdentifierPart(int) Unicode 
identifier part}.</li>
+     *   <li>If <var>c</var> is a dash punctuation of a connector punctuation, 
then all following punctuation
+     *       characters of the same type followed by all characters that are 
Unicode identifier part.</li>
      *   <li>Otherwise any character for which {@link Character#getType(int)} 
returns
      *       the same value than for <var>c</var>.</li>
      * </ul>
@@ -2110,6 +2112,7 @@ cmp:    while (ia < lga) {
         while (isWhitespace(c));
         /*
          * Advance over all characters "of the same type".
+         * If the character are dash or connector punctuation, also include 
the next characters.
          */
         if (isUnicodeIdentifierStart(c)) {
             while (upper<length && isUnicodeIdentifierPart(c = 
codePointAt(text, upper))) {
@@ -2120,6 +2123,11 @@ cmp:    while (ia < lga) {
             while (upper<length && getType(c = codePointAt(text, upper)) == 
type) {
                 upper += charCount(c);
             }
+            if (type == Character.DASH_PUNCTUATION || type == 
Character.CONNECTOR_PUNCTUATION) {
+                while (upper<length && isUnicodeIdentifierPart(c = 
codePointAt(text, upper))) {
+                    upper += charCount(c);
+                }
+            }
         }
         return text.subSequence(fromIndex, upper);
     }
diff --git 
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/CharSequencesTest.java
 
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/CharSequencesTest.java
index bfbd8e0799..6c11b45cf6 100644
--- 
a/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/CharSequencesTest.java
+++ 
b/endorsed/src/org.apache.sis.util/test/org/apache/sis/util/CharSequencesTest.java
@@ -549,6 +549,7 @@ public final class CharSequencesTest extends TestCase {
     public void testToken() {
         assertEquals("Id4", token("..Id4  56B..", 2));
         assertEquals("56",  token("..Id4  56B..", 6));
+        assertEquals("-from",  token("away-from", 4));
     }
 
     /**

Reply via email to