sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1802029 [2/2] - in /sis/branches/JDK8: core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/ core/sis-referencing/src/main/java/org/apache/sis/referencing/op...
Date Sat, 15 Jul 2017 18:39:16 GMT
Copied: sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Transform.java
(from r1802028, sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Operation.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Transform.java?p2=sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Transform.java&p1=sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Operation.java&r1=1802028&r2=1802029&rev=1802029&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Operation.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Transform.java
[UTF-8] Sat Jul 15 18:39:15 2017
@@ -16,85 +16,60 @@
  */
 package org.apache.sis.storage.gdal;
 
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.metadata.Identifier;
-import org.opengis.metadata.quality.PositionalAccuracy;
-import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.crs.GeographicCRS;
-import org.opengis.referencing.crs.ProjectedCRS;
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.OperationMethod;
-import org.opengis.referencing.operation.SingleOperation;
 import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.geometry.GeneralDirectPosition;
+import org.apache.sis.referencing.operation.transform.AbstractMathTransform;
 
 
 /**
- * A math transform which delegate its work to the Proj4 native library.
+ * A math transform which delegate its work to the {@literal Proj.4} native library.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 0.8
  * @since   0.8
  * @module
  */
-class Operation extends PJObject implements SingleOperation, MathTransform {
+final class Transform extends AbstractMathTransform {
     /**
      * The source and target CRS.
      */
-    final CRS source, target;
+    private final PJ source, target;
 
     /**
-     * The inverse transform, created only when first needed.
+     * Whether the source and destination are 2 or 3 dimensional.
      */
-    private transient Operation inverse;
+    private final boolean source3D, target3D;
 
     /**
-     * Creates a new operation for the given source and target CRS.
+     * The inverse transform, created only when first needed.
      */
-    Operation(final Identifier name, final CRS source, final CRS target) {
-        super(name);
-        this.source = source;
-        this.target = target;
-    }
+    private transient Transform inverse;
 
     /**
-     * Returns the operation method.
-     *
-     * @todo Not yet implemented.
+     * Creates a new operation for the given source and target CRS.
      */
-    @Override
-    public OperationMethod getMethod() {
-        return null;
+    Transform(final PJ source, final boolean source3D, final PJ target, final boolean target3D)
{
+        this.source   = source;
+        this.target   = target;
+        this.source3D = source3D;
+        this.target3D = target3D;
     }
 
     /**
-     * Returns the parameter values defining this operation.
-     *
-     * @todo Not yet implemented.
+     * Returns the number of source dimensions.
      */
     @Override
-    public ParameterValueGroup getParameterValues() {
-        return null;
+    public final int getSourceDimensions() {
+        return source3D ? 3 : 2;
     }
 
-    /*
-     * Trivial methods.
+    /**
+     * Returns the number of target dimensions.
      */
-    @Override public CoordinateReferenceSystem getSourceCRS() {return source;}
-    @Override public CoordinateReferenceSystem getTargetCRS() {return target;}
-    @Override public final int     getSourceDimensions()      {return source.getDimension();}
-    @Override public final int     getTargetDimensions()      {return target.getDimension();}
-    @Override public MathTransform getMathTransform()         {return this;}
-    @Override public String        getOperationVersion()      {return PJ.getVersion();}
     @Override
-    public Collection<PositionalAccuracy> getCoordinateOperationAccuracy() {
-        return Collections.emptySet();
+    public final int getTargetDimensions() {
+        return target3D ? 3 : 2;
     }
 
     /**
@@ -104,177 +79,40 @@ class Operation extends PJObject impleme
      */
     @Override
     public boolean isIdentity() {
-        return source.pj.equals(target.pj) && source.getDimension() == target.getDimension();
+        return source3D == target3D && source.equals(target);
     }
 
     /**
-     * Transforms a single coordinate point.
+     * Transforms a single point. This method is inefficient; callers should prefer the methods
+     * transforming multiple points at once.
      */
     @Override
-    public DirectPosition transform(final DirectPosition ptSrc, DirectPosition ptDst)
-            throws MismatchedDimensionException, TransformException
+    public Matrix transform(double[] srcPts, int srcOff,
+                            double[] dstPts, int dstOff,
+                            boolean derivate) throws TransformException
     {
-        final int srcDim = source.getDimension();
-        final int tgtDim = target.getDimension();
-        if (ptSrc.getDimension() != srcDim) {
-            throw new MismatchedDimensionException();
-        }
-        double[] ordinates = new double[Math.max(srcDim, tgtDim)];
-        for (int i=0; i<srcDim; i++) {
-            ordinates[i] = ptSrc.getOrdinate(i);
-        }
-        source.pj.transform(target.pj, ordinates.length, ordinates, 0, 1);
-        if (ptDst != null) {
-            if (ptDst.getDimension() != tgtDim) {
-                throw new MismatchedDimensionException();
-            }
-            for (int i=0; i<tgtDim; i++) {
-                ptDst.setOrdinate(i, ordinates[i]);
-            }
-        } else {
-            if (ordinates.length != tgtDim) {
-                ordinates = Arrays.copyOf(ordinates, tgtDim);
-            }
-            ptDst = new GeneralDirectPosition(ordinates);
-        }
-        return ptDst;
+        transform(srcPts, srcOff, dstPts, dstOff, 1);
+        return null;
     }
 
     /**
      * Transforms an array of coordinate tuples.
      */
     @Override
-    public void transform(final double[] srcPts, final int srcOff,
-                          final double[] dstPts, final int dstOff,
-                          final int numPts) throws TransformException
+    public void transform(double[] srcPts, int srcOff,
+                          double[] dstPts, int dstOff,
+                          int numPts) throws TransformException
     {
-        final int srcDim = source.getDimension();
-        final int tgtDim = target.getDimension();
-        if (srcDim == tgtDim) {
+        if (source3D != target3D) {
+            super.transform(srcPts, srcOff, dstPts, dstOff, numPts);
+        } else {
+            final int dim = getTargetDimensions();
             if (srcPts != dstPts || srcOff != dstOff) {
-                final int length = tgtDim * numPts;
+                final int length = dim * numPts;
                 System.arraycopy(srcPts, srcOff, dstPts, dstOff, length);
             }
-        } else {
-            // TODO: need special check for overlapping arrays.
-            throw new TransformException("Transformation between CRS of different dimensions
not yet supported.");
+            source.transform(target, dim, dstPts, dstOff, numPts);
         }
-        source.pj.transform(target.pj, tgtDim, dstPts, dstOff, numPts);
-    }
-
-    /**
-     * Transforms an array of coordinate tuples.
-     */
-    @Override
-    public void transform(final float[] srcPts, int srcOff,
-                          final float[] dstPts, int dstOff,
-                          int numPts) throws TransformException
-    {
-        if (numPts > 0) {
-            final int srcDim = source.getDimension();
-            final int tgtDim = target.getDimension();
-            final int dimension = Math.min(srcDim, tgtDim);
-            final int length = dimension * numPts;
-            final double[] copy = new double[length];
-            int skip = srcDim - dimension;
-            int stop = (skip == 0) ? length : dimension;
-            for (int i=0;;) {
-                copy[i] = srcPts[srcOff + i];
-                if (++i == stop) {
-                    if (i == length) break;
-                    srcOff += skip;
-                    stop += dimension;
-                }
-            }
-            source.pj.transform(target.pj, dimension, copy, 0, numPts);
-            skip = tgtDim - dimension;
-            stop = (skip == 0) ? length : dimension;
-            for (int i=0;;) {
-                dstPts[dstOff + i] = (float) copy[i];
-                if (++i == stop) {
-                    if (i == length) break;
-                    dstOff += skip;
-                    stop += dimension;
-                }
-            }
-        }
-    }
-
-    /**
-     * Transforms an array of coordinate tuples.
-     */
-    @Override
-    public void transform(final float[]  srcPts, int srcOff,
-                          final double[] dstPts, int dstOff,
-                          final int numPts) throws TransformException
-    {
-        if (numPts > 0) {
-            final int srcDim = source.getDimension();
-            final int tgtDim = target.getDimension();
-            final int dimension = Math.min(srcDim, tgtDim);
-            final int skipS  = srcDim - dimension;
-            final int skipT  = tgtDim - dimension;
-            final int length = dimension * numPts;
-            int stop = (skipS == 0 && skipT == 0) ? length : dimension;
-            if (skipT != 0) {
-                Arrays.fill(dstPts, dstOff, dstOff + tgtDim * numPts, Double.NaN);
-            }
-            for (int i=0;;) {
-                dstPts[dstOff + i] = srcPts[srcOff + i];
-                if (++i == stop) {
-                    if (i == length) break;
-                    srcOff += skipS;
-                    dstOff += skipT;
-                    stop += dimension;
-                }
-            }
-            source.pj.transform(target.pj, tgtDim, dstPts, dstOff, numPts);
-        }
-    }
-
-    /**
-     * Transforms an array of coordinate tuples.
-     */
-    @Override
-    public void transform(final double[] srcPts, int srcOff,
-                          final float[]  dstPts, int dstOff,
-                          final int numPts) throws TransformException
-    {
-        if (numPts > 0) {
-            final int srcDim = source.getDimension();
-            final int tgtDim = target.getDimension();
-            final int dimension = Math.min(srcDim, tgtDim);
-            final int length = dimension * numPts;
-            final double[] copy;
-            if (srcDim == dimension) {
-                copy = Arrays.copyOfRange(srcPts, srcOff, srcOff + length);
-            } else {
-                copy = new double[length];
-                for (int i=0; i!=length; i+=dimension) {
-                    System.arraycopy(srcPts, srcOff, copy, i, dimension);
-                    srcOff += srcDim;
-                }
-            }
-            source.pj.transform(target.pj, dimension, copy, 0, numPts);
-            final int skip = tgtDim - dimension;
-            int stop = (skip == 0) ? length : dimension;
-            for (int i=0;;) {
-                dstPts[dstOff + i] = (float) copy[i];
-                if (++i == stop) {
-                    if (i == length) break;
-                    dstOff += skip;
-                    stop += dimension;
-                }
-            }
-        }
-    }
-
-    /**
-     * The Proj4 library does not provide derivative functions.
-     */
-    @Override
-    public Matrix derivative(DirectPosition point) throws TransformException {
-        throw new TransformException("Not supported yet.");
     }
 
     /**
@@ -283,42 +121,9 @@ class Operation extends PJObject impleme
     @Override
     public synchronized MathTransform inverse() {
         if (inverse == null) {
-            inverse = new Operation(name, target, source);
+            inverse = new Transform(target, target3D, source, source3D);
             inverse.inverse = this;
         }
         return inverse;
     }
-
-    /**
-     * A specialization of {@link Operation} for map projections.
-     */
-    static final class Projection extends Operation implements org.opengis.referencing.operation.Projection
{
-        Projection(final Identifier name, final CRS.Geographic source, final CRS.Projected
target) {
-            super(name, source, target);
-        }
-
-        /**
-         * Always {@code null} by definition for map projection, according ISO 19111.
-         */
-        @Override
-        public String getOperationVersion() {
-            return null;
-        }
-
-        /**
-         * Returns the source CRS, which must be geographic or {@code null}.
-         */
-        @Override
-        public final GeographicCRS getSourceCRS() {
-            return (GeographicCRS) super.getSourceCRS();
-        }
-
-        /**
-         * Returns the target CRS, which must be projected or {@code null}.
-         */
-        @Override
-        public final ProjectedCRS getTargetCRS() {
-            return (ProjectedCRS) super.getTargetCRS();
-        }
-    }
 }

Modified: sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/package-info.java?rev=1802029&r1=1802028&r2=1802029&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/package-info.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/package-info.java
[UTF-8] Sat Jul 15 18:39:15 2017
@@ -16,7 +16,7 @@
  */
 
 /**
- * Referencing services as wrapper around the C/C++ <a href="http://proj.osgeo.org/">Proj4</a>
library.
+ * Referencing services as wrapper around the C/C++ <a href="http://proj.osgeo.org/">{@literal
Proj.4}</a> library.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 0.8

Modified: sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/EPSGFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/EPSGFactoryTest.java?rev=1802029&r1=1802028&r2=1802029&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/EPSGFactoryTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/EPSGFactoryTest.java
[UTF-8] Sat Jul 15 18:39:15 2017
@@ -20,6 +20,7 @@ import org.opengis.util.FactoryException
 import org.opengis.referencing.crs.GeographicCRS;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
+import org.apache.sis.test.TestUtilities;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -37,7 +38,7 @@ import static org.junit.Assert.*;
 @DependsOn(PJTest.class)
 public final strictfp class EPSGFactoryTest extends TestCase {
     /**
-     * Verifies if the Proj4 library is available.
+     * Verifies if the {@literal Proj.4} library is available.
      */
     @BeforeClass
     public static void verifyNativeLibraryAvailability() {
@@ -55,8 +56,11 @@ public final strictfp class EPSGFactoryT
     public void testEPSG_4326() throws FactoryException {
         final EPSGFactory factory = new EPSGFactory(true);
         final GeographicCRS crs = factory.createGeographicCRS("EPSG:4326");
-        // Use Proj.4 specific API to check axis order.
-        final PJ pj = (PJ) crs.getDatum();
+        /*
+         * Use Proj.4 specific API to check axis order.
+         */
+        final PJ pj = (PJ) TestUtilities.getSingleton(crs.getIdentifiers());
+        assertEquals(PJ.Type.GEOGRAPHIC, pj.getType());
         assertArrayEquals(new char[] {'n', 'e', 'u'}, pj.getAxisDirections());
     }
 }

Modified: sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/PJTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/PJTest.java?rev=1802029&r1=1802028&r2=1802029&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/PJTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/PJTest.java
[UTF-8] Sat Jul 15 18:39:15 2017
@@ -16,9 +16,9 @@
  */
 package org.apache.sis.storage.gdal;
 
+import org.opengis.util.FactoryException;
 import org.opengis.referencing.operation.TransformException;
-import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
-import org.apache.sis.measure.Units;
+import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.test.TestCase;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -37,18 +37,18 @@ import static org.junit.Assume.*;
  */
 public final strictfp class PJTest extends TestCase {
     /**
-     * If the Proj4 library has been successfully initialized, an empty string.
+     * If the {@literal Proj.4} library has been successfully initialized, an empty string.
      * Otherwise, the reason why the library is not available.
      */
     private static String status;
 
     /**
-     * Verifies if the Proj4 library is available.
+     * Verifies if the {@literal Proj.4} library is available.
      */
     @BeforeClass
     public static synchronized void verifyNativeLibraryAvailability() {
         if (status == null) try {
-            out.println("Proj.4 version: " + PJ.getVersion());
+            out.println("Proj.4 version: " + PJ.getRelease());
             status = "";
         } catch (UnsatisfiedLinkError e) {
             status = e.toString();
@@ -60,39 +60,39 @@ public final strictfp class PJTest exten
      * Ensures that the given object is the WGS84 definition.
      */
     private static void assertIsWGS84(final PJ pj) {
-        assertEquals("+proj=latlong +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0", pj.getDefinition().trim());
-        assertEquals("Lat/long (Geodetic alias)", pj.toString().trim());
+        assertEquals("Lat/long (Geodetic alias)", pj.getName().trim());
+        assertEquals("+proj=latlong +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0", pj.getCode().trim());
+        assertEquals("Proj4",            pj.getCodeSpace());
+        assertSame  (Citations.PROJ4,    pj.getAuthority());
+        assertTrue  (Character.isDigit(  pj.getVersion().codePointAt(0)));
         assertEquals(PJ.Type.GEOGRAPHIC, pj.getType());
-        assertEquals("WGS84",            pj.getName().getCode());
         assertEquals(6378137.0,          pj.getSemiMajorAxis(),         1E-9);
         assertEquals(6356752.314245179,  pj.getSemiMinorAxis(),         1E-9);
         assertEquals(298.257223563,      pj.getInverseFlattening(),     1E-9);
         assertEquals(0.0,                pj.getGreenwichLongitude(),    STRICT);
         assertEquals(1.0,                pj.getLinearUnitToMetre(true), STRICT);
-        assertSame  (Units.METRE,        pj.getAxisUnit());
-        assertFalse(pj.isSphere());
         assertArrayEquals(new char[] {'e', 'n', 'u'}, pj.getAxisDirections());
     }
 
     /**
      * Tests the creation of a simple WGS84 object.
      *
-     * @throws InvalidGeodeticParameterException if the Proj4 definition string used in this
test is invalid.
+     * @throws FactoryException if the Proj.4 definition string used in this test is invalid.
      */
     @Test
-    public void testWGS84() throws InvalidGeodeticParameterException {
-        final PJ pj = new PJ(null, "+proj=latlong +datum=WGS84");
+    public void testWGS84() throws FactoryException {
+        final PJ pj = new PJ("+proj=latlong +datum=WGS84");
         assertIsWGS84(pj);
     }
 
     /**
      * Tests the creation of the EPSG:3395 projected CRS.
      *
-     * @throws InvalidGeodeticParameterException if the Proj4 definition string used in this
test is invalid.
+     * @throws FactoryException if the Proj.4 definition string used in this test is invalid.
      */
     @Test
-    public void testEPSG3395() throws InvalidGeodeticParameterException {
-        final PJ pj = new PJ(null, "+init=epsg:3395");
+    public void testEPSG3395() throws FactoryException {
+        final PJ pj = new PJ("+init=epsg:3395");
         assertEquals(PJ.Type.PROJECTED, pj.getType());
         assertArrayEquals(new char[] {'e', 'n', 'u'}, pj.getAxisDirections());
         assertEquals(1.0, pj.getLinearUnitToMetre(true), STRICT);
@@ -100,29 +100,29 @@ public final strictfp class PJTest exten
     }
 
     /**
-     * Tests the {@link PJ#getLinearUnit(boolean)} method.
+     * Tests the {@link PJ#getLinearUnitToMetre(boolean)} method.
      *
-     * @throws InvalidGeodeticParameterException if the Proj4 definition string used in this
test is invalid.
+     * @throws FactoryException if the Proj.4 definition string used in this test is invalid.
      */
     @Test
-    public void testGetLinearUnit() throws InvalidGeodeticParameterException {
+    public void testGetLinearUnit() throws FactoryException {
         PJ pj;
-        pj = new PJ(null, "+proj=merc +to_meter=1");
-        assertSame(Units.METRE, pj.getLinearUnit(false));
-        pj = new PJ(null, "+proj=merc +to_meter=0.001");
-        assertSame(Units.KILOMETRE, pj.getLinearUnit(false));
+        pj = new PJ("+proj=merc +to_meter=1");
+        assertEquals(1, pj.getLinearUnitToMetre(false), STRICT);
+        pj = new PJ("+proj=merc +to_meter=0.001");
+        assertEquals(0.001, pj.getLinearUnitToMetre(false), STRICT);
     }
 
     /**
      * Ensures that the native code correctly detects the case of null pointers.
      * This is important in order to ensure that we don't have a JVM crash.
      *
-     * @throws InvalidGeodeticParameterException if the Proj4 definition string used in this
test is invalid.
+     * @throws FactoryException if the Proj.4 definition string used in this test is invalid.
      * @throws TransformException should never happen.
      */
     @Test
-    public void testNullPointerException() throws InvalidGeodeticParameterException, TransformException
{
-        final PJ pj = new PJ(null, "+proj=latlong +datum=WGS84");
+    public void testNullPointerException() throws FactoryException, TransformException {
+        final PJ pj = new PJ("+proj=latlong +datum=WGS84");
         try {
             pj.transform(null, 2, null, 0, 1);
             fail("Expected an exception to be thrown.");
@@ -135,12 +135,12 @@ public final strictfp class PJTest exten
      * Ensures that the native code correctly detects the case of index out of bounds.
      * This is important in order to ensure that we don't have a JVM crash.
      *
-     * @throws InvalidGeodeticParameterException if the Proj4 definition string used in this
test is invalid.
+     * @throws FactoryException if the Proj.4 definition string used in this test is invalid.
      * @throws TransformException should never happen.
      */
     @Test
-    public void testIndexOutOfBoundsException() throws InvalidGeodeticParameterException,
TransformException {
-        final PJ pj = new PJ(null, "+proj=latlong +datum=WGS84");
+    public void testIndexOutOfBoundsException() throws FactoryException, TransformException
{
+        final PJ pj = new PJ("+proj=latlong +datum=WGS84");
         try {
             pj.transform(pj, 2, new double[5], 2, 2);
             fail("Expected an exception to be thrown.");
@@ -154,12 +154,12 @@ public final strictfp class PJTest exten
      * {@link java.lang.Double#NaN} constant, because not all C/C++ compiler define
      * a {@code NAN} constant.
      *
-     * @throws InvalidGeodeticParameterException if the Proj4 definition string used in this
test is invalid.
+     * @throws FactoryException if the Proj.4 definition string used in this test is invalid.
      */
     @Test
     @SuppressWarnings("FinalizeCalledExplicitly")
-    public void testNaN() throws InvalidGeodeticParameterException {
-        final PJ pj = new PJ(null, "+proj=latlong +datum=WGS84");
+    public void testNaN() throws FactoryException {
+        final PJ pj = new PJ("+proj=latlong +datum=WGS84");
         pj.finalize();              // This cause the disposal of the internal PJ structure.
         assertNull(pj.getType());
         assertNaN(pj.getSemiMajorAxis());

Added: sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4Test.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4Test.java?rev=1802029&view=auto
==============================================================================
--- sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4Test.java
(added)
+++ sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4Test.java
[UTF-8] Sat Jul 15 18:39:15 2017
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.gdal;
+
+import org.opengis.util.FactoryException;
+import org.apache.sis.referencing.crs.HardCodedCRS;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+
+/**
+ * Tests the {@link Proj4} class.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since   0.8
+ * @module
+ */
+public final strictfp class Proj4Test extends TestCase {
+    /**
+     * Tests {@link Proj4#definition(CoordinateReferenceSystem)} on geographic CRS.
+     *
+     * @throws FactoryException if an error occurred while computing the Proj.4 definition
string.
+     */
+    @Test
+    public void testGeographicDefinition() throws FactoryException {
+        assertEquals("+proj=latlon +a=6378137.0 +b=6356752.314245179 +pm=0.0 +axis=enu",
Proj4.definition(HardCodedCRS.WGS84));
+        assertEquals("+proj=latlon +a=6378137.0 +b=6356752.314245179 +pm=0.0 +axis=neu",
Proj4.definition(HardCodedCRS.WGS84_φλ));
+    }
+}

Propchange: sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4Test.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/test/suite/GDALTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/test/suite/GDALTestSuite.java?rev=1802029&r1=1802028&r2=1802029&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/test/suite/GDALTestSuite.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/test/suite/GDALTestSuite.java
[UTF-8] Sat Jul 15 18:39:15 2017
@@ -31,6 +31,7 @@ import org.junit.runners.Suite;
  */
 @Suite.SuiteClasses({
     org.apache.sis.storage.gdal.PJTest.class,
+    org.apache.sis.storage.gdal.Proj4Test.class,
     org.apache.sis.storage.gdal.EPSGFactoryTest.class
 })
 public final strictfp class GDALTestSuite extends TestSuite {



Mime
View raw message