sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1732482 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
Date Fri, 26 Feb 2016 13:58:26 GMT
Author: desruisseaux
Date: Fri Feb 26 13:58:25 2016
New Revision: 1732482

URL: http://svn.apache.org/viewvc?rev=1732482&view=rev
Log:
More extensive test for WKT parsing/formatting consistency.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java?rev=1732482&r1=1732481&r2=1732482&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ReferencingServices.java
[UTF-8] Fri Feb 26 13:58:25 2016
@@ -450,13 +450,17 @@ public class ReferencingServices extends
                     /*
                      * At this point we have the horizontal and vertical components. The
horizontal component
                      * begins at 'axisPosition', which is almost always zero. Create the
three-dimensional CRS.
+                     * If the result is the CRS to be returned directly by this method (components.length
== 2),
+                     * use the properties given in argument. Otherwise we need to use other
properties; current
+                     * implementation recycles the properties of the existing two-dimensional
CRS.
                      */
                     final CoordinateSystemAxis[] axes = new CoordinateSystemAxis[3];
                     axes[axisPosition++   ] = cs.getAxis(0);
                     axes[axisPosition++   ] = cs.getAxis(1);
                     axes[axisPosition %= 3] = vertical.getCoordinateSystem().getAxis(0);
                     cs = csFactory.createEllipsoidalCS(getProperties(cs), axes[0], axes[1],
axes[2]);
-                    crs = crsFactory.createGeographicCRS(getProperties(crs), ((GeodeticCRS)
crs).getDatum(), cs);
+                    crs = crsFactory.createGeographicCRS((components.length == 2) ? properties
: getProperties(crs),
+                            ((GeodeticCRS) crs).getDatum(), cs);
                     /*
                      * Remove the VerticalCRS and store the three-dimensional GeographicCRS
in place of the previous
                      * two-dimensional GeographicCRS. Then let the loop continues in case
there is other CRS to merge

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java?rev=1732482&r1=1732481&r2=1732482&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
[UTF-8] Fri Feb 26 13:58:25 2016
@@ -18,13 +18,10 @@ package org.apache.sis.test.integration;
 
 import java.util.Arrays;
 import java.util.HashSet;
-import java.util.Locale;
 import java.util.Set;
-import java.util.TimeZone;
 import java.text.ParseException;
 import org.opengis.util.FactoryException;
 import org.opengis.util.NoSuchIdentifierException;
-import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.referencing.factory.FactoryDataException;
 import org.apache.sis.referencing.CRS;
@@ -73,10 +70,14 @@ public final strictfp class ConsistencyT
     @Test
     public void testCoordinateReferenceSystems() throws FactoryException {
         assumeTrue("Extensive tests not enabled.", RUN_EXTENSIVE_TESTS);
-        final WKTFormat v1 = new WKTFormat(Locale.US, TimeZone.getTimeZone("UTC"));
-        final WKTFormat v2 = new WKTFormat(Locale.US, TimeZone.getTimeZone("UTC"));
-        v1.setConvention(Convention.WKT1);
-        v2.setConvention(Convention.WKT2);
+        final WKTFormat v1  = new WKTFormat(null, null);
+        final WKTFormat v1c = new WKTFormat(null, null);
+        final WKTFormat v2  = new WKTFormat(null, null);
+        final WKTFormat v2s = new WKTFormat(null, null);
+        v1 .setConvention(Convention.WKT1);
+        v1c.setConvention(Convention.WKT1_COMMON_UNITS);
+        v2 .setConvention(Convention.WKT2);
+        v2s.setConvention(Convention.WKT2_SIMPLIFIED);
         for (final String code : CRS.getAuthorityFactory(null).getAuthorityCodes(CoordinateReferenceSystem.class))
{
             if (!EXCLUDES.contains(code)) {
                 final CoordinateReferenceSystem crs;
@@ -86,20 +87,20 @@ public final strictfp class ConsistencyT
                     print(code, "WARNING", e.getLocalizedMessage());
                     continue;
                 }
-                parseAndFormat(v2, code, crs);
+                parseAndFormat(v2,  code, crs);
+                parseAndFormat(v2s, code, crs);
                 /*
                  * There is more information lost in WKT 1 than in WKT 2, so we can not test
everything.
                  * For example we can not format fully three-dimensional geographic CRS because
the unit
                  * is not the same for all axes. We can not format neither some axis directions.
                  */
-                if (crs.getCoordinateSystem().getDimension() == 3 && (crs instanceof
GeographicCRS)) {
-                    continue;
-                }
                 try {
                     parseAndFormat(v1, code, crs);
                 } catch (UnformattableObjectException e) {
                     print(code, "WARNING", e.getLocalizedMessage());
+                    continue;
                 }
+                parseAndFormat(v1c, code, crs);
             }
         }
     }



Mime
View raw message