sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1689363 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/io/wkt/ sis-metadata/src/test/java/org/apache/sis/io/wkt/ sis-referencing/src/main/java/org/apache/sis/referencing/operation/
Date Mon, 06 Jul 2015 11:06:09 GMT
Author: desruisseaux
Date: Mon Jul  6 11:06:09 2015
New Revision: 1689363

URL: http://svn.apache.org/r1689363
Log:
Apply ISO 19162 recommendation to ignore leading and trailing spaces.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java?rev=1689363&r1=1689362&r2=1689363&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Element.java [UTF-8]
Mon Jul  6 11:06:09 2015
@@ -208,7 +208,12 @@ final class Element {
                     }
                     lower = upper + n;  // After the closing quote.
                 } while (lower < text.length() && text.codePointAt(lower) == closingQuote);
-                list.add(content.toString());
+                /*
+                 * Leading and trailing spaces should be ignored according ISO 19162 §B.4.
+                 * Note that the specification suggests also to replace consecutive white
+                 * spaces by a single space, but we don't do that yet.
+                 */
+                list.add(CharSequences.trimWhitespaces(content).toString());
             } else if (!Character.isUnicodeIdentifierStart(firstChar)) {
                 /*
                  * Try to parse the next element as a date or a number. We will attempt such
parsing

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java?rev=1689363&r1=1689362&r2=1689363&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/GeodeticObjectParser.java
[UTF-8] Mon Jul  6 11:06:09 2015
@@ -670,7 +670,7 @@ final class GeodeticObjectParser extends
             final Element element = parent.pullElement(OPTIONAL, WKTKeywords.CS);
             if (element != null) {
                 final String expected = type;
-                type         = CharSequences.trimWhitespaces(element.pullVoidElement("type").keyword);
+                type         = element.pullVoidElement("type").keyword;
                 dimension    = element.pullInteger("dimension");
                 csProperties = new HashMap<>(parseMetadataAndClose(element, "CS", null));
                 if (expected != null) {
@@ -954,7 +954,7 @@ final class GeodeticObjectParser extends
          * expressed by a syntax like AXIS[“South along 90°W”, SOUTH, MERIDIAN[-90,
UNIT["deg"]]]. Note that
          * the meridian is relative to the prime meridian of the enclosing geodetic CRS.
          */
-        String name = CharSequences.trimWhitespaces(element.pullString("name"));
+        String name = element.pullString("name");
         final Element orientation = element.pullVoidElement("orientation");
         Unit<?> unit = parseUnit(element);
         if (unit == null) {

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java?rev=1689363&r1=1689362&r2=1689363&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/ElementTest.java
[UTF-8] Mon Jul  6 11:06:09 2015
@@ -83,10 +83,10 @@ public final strictfp class ElementTest
         assertEquals("value", "World Geodetic System 1984", element.pullString("value"));
         element.close(null);
 
-        // Spaces inside quotes should be preserved.
+        // Leading and trailing spaces inside quotes should be ignored (ISO 19162 §B.4).
         element = parse("  Datum [  \" World Geodetic System 1984  \"  ]  ");
         assertEquals("keyword", "Datum", element.keyword);
-        assertEquals("value", " World Geodetic System 1984  ", element.pullString("value"));
+        assertEquals("value", "World Geodetic System 1984", element.pullString("value"));
         element.close(null);
 
         // Consecutive values.

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java?rev=1689363&r1=1689362&r2=1689363&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
[UTF-8] Mon Jul  6 11:06:09 2015
@@ -374,6 +374,7 @@ public class DefaultCoordinateOperationF
         /*
          * Undocumented (for now) feature: if the 'transform' argument is null but parameters
are
          * found in the given properties, create the MathTransform instance from those parameters.
+         * This is needed for WKT parsing of CoordinateOperation[…] among others.
          */
         if (transform == null) {
             final ParameterValueGroup parameters = Containers.property(properties,



Mime
View raw message