sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1811545 [2/2] - in /sis/branches/JDK7: ./ application/sis-console/ application/sis-console/src/main/artifact/lib/ application/sis-console/src/main/artifact/lib/darwin/ application/sis-console/src/main/artifact/lib/linux/ application/sis-co...
Date Mon, 09 Oct 2017 09:40:03 GMT
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/crs/DefaultCompoundCRSTest.java
[UTF-8] Mon Oct  9 09:40:02 2017
@@ -17,6 +17,9 @@
 package org.apache.sis.referencing.crs;
 
 import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Locale;
 import javax.xml.bind.JAXBException;
 import org.opengis.test.Validators;
 import org.opengis.referencing.cs.AxisDirection;
@@ -33,7 +36,7 @@ import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
 import static java.util.Collections.singletonMap;
-import static org.opengis.referencing.cs.CoordinateSystem.NAME_KEY;
+import static org.opengis.referencing.crs.CompoundCRS.NAME_KEY;
 import static org.apache.sis.test.ReferencingAssert.*;
 
 
@@ -41,7 +44,7 @@ import static org.apache.sis.test.Refere
  * Tests the {@link DefaultCompoundCRS} class.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 0.8
  * @since   0.4
  * @module
  */
@@ -67,6 +70,64 @@ public final strictfp class DefaultCompo
     private static final String XML_FILE = "CompoundCRS.xml";
 
     /**
+     * Verifies that we do not allow construction with a duplicated horizontal or vertical
component.
+     *
+     * @since 0.8
+     */
+    @Test
+    @SuppressWarnings("ResultOfObjectAllocationIgnored")
+    public void testDuplicatedComponent() {
+        final Map<String,Object> properties = new HashMap<>(4);
+        assertNull(properties.put(DefaultCompoundCRS.LOCALE_KEY, Locale.ENGLISH));
+        assertNull(properties.put(DefaultCompoundCRS.NAME_KEY,   "3D + illegal"));
+        try {
+            new DefaultCompoundCRS(properties, HardCodedCRS.WGS84, HEIGHT, HardCodedCRS.SPHERE);
+            fail("Should not allow construction with two horizontal components.");
+        } catch (IllegalArgumentException e) {
+            assertEquals("Compound coordinate reference systems can not contain two horizontal
components.", e.getMessage());
+        }
+        /*
+         * Try again with duplicated vertical components, opportunistically
+         * testing localization in a different language.
+         */
+        properties.put(DefaultCompoundCRS.LOCALE_KEY, Locale.FRENCH);
+        try {
+            new DefaultCompoundCRS(properties, HardCodedCRS.WGS84, HEIGHT, HardCodedCRS.ELLIPSOIDAL_HEIGHT);
+            fail("Should not allow construction with two vertical components.");
+        } catch (IllegalArgumentException e) {
+            assertEquals("Un système de référence des coordonnées ne peut pas contenir
deux composantes verticales.", e.getMessage());
+        }
+    }
+
+    /**
+     * Verifies that horizontal CRS + ellipsoidal height is disallowed.
+     *
+     * @see <a href="https://issues.apache.org/jira/browse/SIS-303">SIS-303</a>
+     *
+     * @since 0.8
+     */
+    @Test
+    @SuppressWarnings("ResultOfObjectAllocationIgnored")
+    public void testEllipsoidalHeight() {
+        final Map<String,Object> properties = new HashMap<>(4);
+        assertNull(properties.put(DefaultCompoundCRS.LOCALE_KEY, Locale.ENGLISH));
+        assertNull(properties.put(DefaultCompoundCRS.NAME_KEY,   "3D"));
+        try {
+            new DefaultCompoundCRS(properties, HardCodedCRS.WGS84, HardCodedCRS.ELLIPSOIDAL_HEIGHT);
+            fail("Should not allow construction with ellipsoidal height.");
+        } catch (IllegalArgumentException e) {
+            assertEquals("Compound coordinate reference systems should not contain ellipsoidal
height. "
+                    + "Use a three-dimensional geographic system instead.", e.getMessage());
+        }
+        /*
+         * We allow an ellipsoidal height if there is no horizontal CRS.
+         * This is a departure from ISO 19111.
+         */
+        final DefaultCompoundCRS crs = new DefaultCompoundCRS(properties, HardCodedCRS.ELLIPSOIDAL_HEIGHT,
TIME);
+        assertAxisDirectionsEqual("CompoundCRS", crs.getCoordinateSystem(), AxisDirection.UP,
AxisDirection.FUTURE);
+    }
+
+    /**
      * Tests construction and serialization of a {@link DefaultCompoundCRS}.
      */
     @Test

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/cs/HardCodedCS.java
[UTF-8] Mon Oct  9 09:40:02 2017
@@ -163,6 +163,19 @@ public final strictfp class HardCodedCS
             HardCodedAxes.NORTHING);
 
     /**
+     * A three-dimensional Cartesian CS with
+     * <var>{@linkplain HardCodedAxes#EASTING Easting}</var>,
+     * <var>{@linkplain HardCodedAxes#NORTHING Northing}</var>
+     * <var>{@linkplain HardCodedAxes#ELLIPSOIDAL_HEIGHT Height}</var>
+     * axes in metres.
+     */
+    public static final DefaultCartesianCS PROJECTED_3D = new DefaultCartesianCS(
+            singletonMap(NAME_KEY, "Projected"),
+            HardCodedAxes.EASTING,
+            HardCodedAxes.NORTHING,
+            HardCodedAxes.ELLIPSOIDAL_HEIGHT);
+
+    /**
      * A two-dimensional Cartesian CS with
      * <var>{@linkplain HardCodedAxes#X x}</var>,
      * <var>{@linkplain HardCodedAxes#Y y}</var>

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/CoordinateOperationFinderTest.java
[UTF-8] Mon Oct  9 09:40:02 2017
@@ -814,7 +814,7 @@ public final strictfp class CoordinateOp
                 "  Id[“EPSG”, “3395”]]");
 
         CoordinateReferenceSystem sourceCRS = targetCRS;
-        sourceCRS = compound("Mercator 3D", sourceCRS, CommonCRS.Vertical.ELLIPSOIDAL.crs());
+        sourceCRS = compound("Mercator 3D", sourceCRS, CommonCRS.Vertical.MEAN_SEA_LEVEL.crs());
         sourceCRS = compound("Mercator 4D", sourceCRS, CommonCRS.Temporal.MODIFIED_JULIAN.crs());
 
         final CoordinateOperation operation = finder.createOperation(sourceCRS, targetCRS);

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java
[UTF-8] Mon Oct  9 09:40:02 2017
@@ -212,10 +212,10 @@ public final strictfp class DefaultCoord
         final CoordinateReferenceSystem sourceCRS = parse(
                 "CompoundCRS[“NTF 4D”," +
                 "  $NTF,\n" +
-                "  VerticalCRS[“Ellipsoidal height”,\n" +
-                "    VerticalDatum[“Ellipsoid”],\n" +
+                "  VerticalCRS[“Geoidal height”,\n" +
+                "    VerticalDatum[“Geoid”],\n" +
                 "    CS[vertical, 1],\n" +
-                "      Axis[“Ellipsoidal height (h)”, up],\n" +
+                "      Axis[“Geoidal height (H)”, up],\n" +
                 "      Unit[“metre”, 1]],\n" +
                 "  TimeCRS[“Modified Julian”,\n" +
                 "    TimeDatum[“Modified Julian”, TimeOrigin[1858-11-17T00:00:00.0Z]],\n"
+
@@ -229,7 +229,7 @@ public final strictfp class DefaultCoord
         assertSame      ("targetCRS", targetCRS, operation.getTargetCRS());
         assertInstanceOf("operation", ConcatenatedOperation.class, operation);
         /*
-         * The accuracy of the coordinate operation depends on whether a path as been found
with the help
+         * The accuracy of the coordinate operation depends on whether a path has been found
with the help
          * of the EPSG database. See testProjectionAndLongitudeRotation() for more information.
          */
         final boolean isUsingEpsgFactory = verifyParametersNTF(((ConcatenatedOperation) operation).getOperations(),
2);

Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
[UTF-8] Mon Oct  9 09:40:02 2017
@@ -229,7 +229,7 @@ import org.junit.BeforeClass;
     org.apache.sis.referencing.operation.builder.LinearTransformBuilderTest.class,
     org.apache.sis.referencing.operation.builder.LocalizationGridBuilderTest.class,
 
-    // Geometry
+    // Geometry and miscellaneous
     org.apache.sis.geometry.AbstractDirectPositionTest.class,
     org.apache.sis.geometry.GeneralDirectPositionTest.class,
     org.apache.sis.geometry.DirectPosition1DTest.class,
@@ -244,6 +244,7 @@ import org.junit.BeforeClass;
     org.apache.sis.geometry.Shapes2DTest.class,                 // Simpler than EnvelopesTest.
     org.apache.sis.geometry.EnvelopesTest.class,
     org.apache.sis.internal.referencing.ServicesForMetadataTest.class,
+    org.apache.sis.internal.metadata.EllipsoidalHeightCombinerTest.class,
     org.apache.sis.geometry.CoordinateFormatTest.class,
 
     org.apache.sis.distance.LatLonPointRadiusTest.class,        // Pending refactoring in
a geometry package.

Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/OS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/OS.java?rev=1811545&r1=1811544&r2=1811545&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/OS.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/OS.java
[UTF-8] Mon Oct  9 09:40:02 2017
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.system;
 
 import java.net.URL;
+import java.net.URI;
 import java.net.URISyntaxException;
 import java.io.File;
 import java.io.InputStream;
@@ -122,7 +123,7 @@ public enum OS {
      */
     public static void load(final Class<?> caller, final String name) {
         try {
-            System.load(current().nativeLibrary(caller.getClassLoader(), name));
+            System.load(current().nativeLibrary(caller, name));
         } catch (IOException | SecurityException e) {
             throw (UnsatisfiedLinkError) new UnsatisfiedLinkError(e.getMessage()).initCause(e);
         }
@@ -133,7 +134,7 @@ public enum OS {
      * If the resources can not be accessed by an absolute path, then this method
      * copies the resource in a temporary file.
      *
-     * @param  loader  the loader of the JAR file where to look for native resources.
+     * @param  caller  a class in the JAR file where to look for native resources.
      * @param  name    the native library name without {@code ".so"} or {@code ".dll"} extension.
      * @return absolute path to the library (may be a temporary file).
      * @throws IOException if an error occurred while copying the library to a temporary
file.
@@ -142,11 +143,40 @@ public enum OS {
      *
      * @see System#load(String)
      */
-    private String nativeLibrary(final ClassLoader loader, final String name) throws IOException
{
+    private String nativeLibrary(final Class<?> caller, final String name) throws IOException
{
         if (libdir != null) {
             final String ext = unix ? ".so" : ".dll";
-            final String path = "native/" + libdir + '/' + name + ext;
-            final URL res = loader.getResource(path);
+            final String path = libdir + '/' + name + ext;
+            final ClassLoader loader = caller.getClassLoader();
+            /*
+             * First, verify if the "linux", "darwin" or "windows" directory exists at the
same level
+             * than the JAR file containing the caller class. If it exists, then we will
use it. This
+             * check avoid the need to copy the ".so" or ".dll" file in a temporary location.
 If the
+             * directory does not exist, then we do NOT create it in order to reduce the
risk to mess
+             * with user's installation.
+             *
+             * Example of URL for a JAR entry: jar:file:/home/…/sis-gdal.jar!/org/apache/…/PJ.class
+             */
+            URL res = loader.getResource(caller.getName().replace('.', '/').concat(".class"));
+            if (res != null && "jar".equals(res.getProtocol())) {
+                String file = res.getPath();
+                final int s = file.indexOf('!');
+                if (s >= 0) try {
+                    File location = new File(new URI(file.substring(0, s)));
+                    location = new File(location.getParentFile(), path);
+                    if (location.canExecute()) {
+                        return location.getAbsolutePath();
+                    }
+                } catch (IllegalArgumentException | URISyntaxException e) {
+                    Logging.recoverableException(Logging.getLogger(Loggers.SYSTEM), OS.class,
"nativeLibrary", e);
+                }
+            }
+            /*
+             * If we didn't found an existing "linux", "darwin" or "windows" directory with
native library,
+             * copy the library in a temporary file. That file will be deleted on JVM exists,
so a new file
+             * will be copied each time the application is executed.
+             */
+            res = loader.getResource("native/".concat(path));
             if (res != null) {
                 try {
                     return new File(res.toURI()).getAbsolutePath();



Mime
View raw message