sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1802945 [3/3] - in /sis/trunk: ./ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ core/sis-referencing/src/main/java/org/apache/sis/internal/referenc...
Date Tue, 25 Jul 2017 14:07:14 GMT
Modified: sis/trunk/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Transform.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Transform.java?rev=1802945&r1=1802944&r2=1802945&view=diff
==============================================================================
--- sis/trunk/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Transform.java [UTF-8]
(original)
+++ sis/trunk/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Transform.java [UTF-8]
Tue Jul 25 14:07:13 2017
@@ -16,7 +16,9 @@
  */
 package org.apache.sis.storage.gdal;
 
+import java.io.Serializable;
 import java.util.Collections;
+import org.opengis.util.FactoryException;
 import org.opengis.parameter.ParameterValueGroup;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.ParameterDescriptorGroup;
@@ -24,11 +26,14 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.Matrix;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.referencing.operation.MathTransformFactory;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.apache.sis.internal.util.Constants;
 import org.apache.sis.metadata.iso.citation.Citations;
 import org.apache.sis.parameter.ParameterBuilder;
 import org.apache.sis.referencing.operation.DefaultOperationMethod;
 import org.apache.sis.referencing.operation.transform.AbstractMathTransform;
+import org.apache.sis.util.ComparisonMode;
 
 
 /**
@@ -39,7 +44,12 @@ import org.apache.sis.referencing.operat
  * @since   0.8
  * @module
  */
-final class Transform extends AbstractMathTransform {
+final class Transform extends AbstractMathTransform implements Serializable {
+    /**
+     * For cross-version compatibility.
+     */
+    private static final long serialVersionUID = -8593638007439108805L;
+
     /**
      * The operation method for a transformation between two {@link PJ} instances.
      * The parameter names are taken from
@@ -170,4 +180,61 @@ final class Transform extends AbstractMa
         }
         return inverse;
     }
+
+    /**
+     * If both transforms are {@literal Proj.4} wrappers, returns a single transform without
intermediate step.
+     */
+    @Override
+    protected MathTransform tryConcatenate(final boolean applyOtherFirst, final MathTransform
other,
+            final MathTransformFactory factory) throws FactoryException
+    {
+        if (other instanceof Transform) {
+            final Transform tr = (Transform) other;
+            if (applyOtherFirst) {
+                return new Transform(tr.source, tr.source3D, target, target3D);
+            } else {
+                return new Transform(source, source3D, tr.target, tr.target3D);
+            }
+        }
+        return super.tryConcatenate(applyOtherFirst, other, factory);
+    }
+
+    /**
+     * Returns {@code true} if this math transform is for the given pair of source and target
CRS.
+     */
+    final boolean isFor(final CoordinateReferenceSystem sourceCRS, final PJ sourcePJ,
+                        final CoordinateReferenceSystem targetCRS, final PJ targetPJ)
+    {
+        return source.equals(sourcePJ) && dimensionMatches(sourceCRS, source3D) &&
+               target.equals(targetPJ) && dimensionMatches(targetCRS, target3D);
+    }
+
+    /**
+     * Tests whether the given CRS matches the expected number of dimensions.
+     */
+    private static boolean dimensionMatches(final CoordinateReferenceSystem crs, final boolean
is3D) {
+        return crs.getCoordinateSystem().getDimension() == (is3D ? 3 : 2);
+    }
+
+    /**
+     * Computes a hash value for this transform. This method is invoked by {@link #hashCode()}
when first needed.
+     */
+    @Override
+    protected int computeHashCode() {
+        return super.computeHashCode() + source.hashCode() + 31*target.hashCode();
+    }
+
+    /**
+     * Compares the given object with this transform for equality.
+     * This implementation can not ignore metadata or rounding errors.
+     */
+    @Override
+    public boolean equals(final Object object, final ComparisonMode mode) {
+        if (object instanceof Transform) {
+            final Transform that = (Transform) object;
+            return source.equals(that.source) && source3D == that.source3D
+                && target.equals(that.target) && target3D == that.target3D;
+        }
+        return false;
+    }
 }

Modified: sis/trunk/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/package-info.java?rev=1802945&r1=1802944&r2=1802945&view=diff
==============================================================================
--- sis/trunk/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/package-info.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/package-info.java
[UTF-8] Tue Jul 25 14:07:13 2017
@@ -16,7 +16,65 @@
  */
 
 /**
- * Referencing services as wrapper around the C/C++ <a href="http://proj.osgeo.org/">{@literal
Proj.4}</a> library.
+ * Extensions to referencing services as wrapper around the C/C++ {@literal Proj.4} library.
+ * Current version wraps only referencing services, but future versions are expected to wrap
more GDAL functionalities.
+ * Unless otherwise specified, this optional module requires the native (C/C++) <a href="http://proj.osgeo.org/">Proj.4</a>
+ * library to be installed on the local machine. This package allows to:
+ * <ul>
+ *   <li>{@linkplain org.apache.sis.storage.gdal.Proj4#createCRS Create a Coordinate
Reference System instance from a Proj.4 definition string}.</li>
+ *   <li>Conversely, {@linkplain org.apache.sis.storage.gdal.Proj4#definition get a
Proj.4 definition string from a Coordinate Reference System}.</li>
+ *   <li>{@linkplain org.apache.sis.storage.gdal.Proj4#createOperation Create a coordinate
operation backed by Proj.4 between two arbitrary CRS}.</li>
+ * </ul>
+ *
+ * Note that Apache SIS provides its own map projection engine in pure Java, so this module
is usually not needed.
+ * This module is useful when a map projection is not yet available in Apache SIS, or when
an application needs to
+ * reproduce the exact same numerical results than Proj.4. But some Apache SIS features like
+ * {@linkplain org.apache.sis.referencing.operation.transform.AbstractMathTransform#derivative
transform derivatives}
+ * are not available through the Proj.4 wrappers.
+ *
+ * <p>When this optional module is available, the {@link org.apache.sis.referencing.CRS#forCode
CRS.forCode(String)}
+ * method accepts Proj.4 definition strings prefixed by {@code "Proj4::"}. Example:</p>
+ *
+ * {@preformat java
+ *     CoordinateReferenceSystem crs = CRS.forCode("Proj4::+init=epsg:3395");
+ * }
+ *
+ * Calls to {@link org.apache.sis.referencing.CRS#findOperation CRS.findOperation(…)} will
delegate the coordinate
+ * transformation to Proj.4 if an only if {@code sourceCRS} and {@code targetCRS} were both
obtained from a code
+ * in {@code "Proj4"} namespace or by a method in this package. If at least one CRS were
obtained by another way,
+ * then Apache SIS will use its own referencing engine. The backing referencing engine can
be seen by printing
+ * the {@code CoordinateOperation}.
+ *
+ * <div class="section">Note on Proj.4 definition strings</div>
+ * Proj.4 unconditionally requires 3 letters for the {@code "+axis="} parameter — for example
{@code "neu"} for
+ * <cite>North</cite>, <cite>East</cite> and <cite>Up</cite>
respectively — regardless the number of dimensions
+ * in the CRS to create. Apache SIS makes the vertical direction optional in order to specify
whether the CRS to
+ * create shall contain a vertical axis or not:
+ *
+ * <ul>
+ *   <li>If the vertical direction is present (as in {@code "neu"}), a three-dimensional
CRS is created.</li>
+ *   <li>If the vertical direction is absent (as in {@code "ne"}), a two-dimensional
CRS is created.</li>
+ * </ul>
+ *
+ * <div class="note"><b>Examples:</b>
+ * <ul>
+ *   <li>{@code "+init=epsg:4326"} (<strong>not</strong> equivalent to
the standard EPSG::4326 definition)</li>
+ *   <li>{@code "+proj=latlong +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"} (default
to two-dimensional CRS)</li>
+ *   <li>{@code "+proj=latlon +a=6378137.0 +b=6356752.314245179 +pm=0.0 +axis=ne"}
(explicitely two-dimensional)</li>
+ *   <li>{@code "+proj=latlon +a=6378137.0 +b=6356752.314245179 +pm=0.0 +axis=neu"}
(three-dimensional)</li>
+ * </ul>
+ * </div>
+ *
+ * <b>Warning:</b> despite the {@code "epsg"} word, coordinate reference systems
created by {@code "+init=epsg:"}
+ * syntax are not necessarily compliant with EPSG definitions. In particular, the axis order
is often different.
+ * Units of measurement may also differ.
+ *
+ * <div class="section">Installation</div>
+ * The Proj.4 library needs to be reachable on a platform-dependent library path.
+ * For example the operating system may search in {@code /usr/lib}, {@code /opt/local/lib}
and other directories.
+ * One of those directories shall contain the {@code proj} or {@code libproj} file with platform-specific
suffix
+ * (e.g. {@code .so}, {@code .dylib} or {@code .dll}).
+ * An easy way to install the library in appropriate directory is to use the package manager
provided by the platform.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 0.8

Copied: sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/MTFactory.java
(from r1802943, sis/branches/JDK7/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/MTFactory.java)
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/MTFactory.java?p2=sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/MTFactory.java&p1=sis/branches/JDK7/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/MTFactory.java&r1=1802943&r2=1802945&rev=1802945&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/MTFactory.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/MTFactory.java [UTF-8]
Tue Jul 25 14:07:13 2017
@@ -21,7 +21,6 @@ import java.text.ParseException;
 import org.opengis.util.FactoryException;
 import org.opengis.util.NoSuchIdentifierException;
 import org.opengis.parameter.ParameterValueGroup;
-import org.opengis.parameter.ParameterDescriptorGroup;
 import org.opengis.referencing.cs.CoordinateSystem;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.crs.CRSAuthorityFactory;
@@ -65,16 +64,6 @@ class MTFactory extends Proj4Factory imp
     }
 
     /**
-     * Unsupported by the {@literal Proj.4} wrapper — delegates to the Apache SIS default
factory.
-     */
-    @Override
-    public OperationMethod createOperationMethod(Map<String,?> properties, Integer
sourceDimension,
-            Integer targetDimension, ParameterDescriptorGroup parameters) throws FactoryException
-    {
-        return opFactory().createOperationMethod(properties, sourceDimension, targetDimension,
parameters);
-    }
-
-    /**
      * Creates an operation for conversion or transformation between two coordinate reference
systems.
      * This implementation always uses Proj.4 for performing the coordinate operations, regardless
if
      * the given CRS were created from Proj.4 definition strings or not. This method fails
if it can

Modified: sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/PJTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/PJTest.java?rev=1802945&r1=1802944&r2=1802945&view=diff
==============================================================================
--- sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/PJTest.java [UTF-8]
(original)
+++ sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/PJTest.java [UTF-8]
Tue Jul 25 14:07:13 2017
@@ -23,8 +23,8 @@ import org.apache.sis.test.TestCase;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
 import static org.junit.Assume.*;
+import static org.apache.sis.test.Assert.*;
 
 
 /**
@@ -60,18 +60,15 @@ public final strictfp class PJTest exten
      * Ensures that the given object is the WGS84 definition.
      */
     private static void assertIsWGS84(final PJ pj) {
-        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(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);
-        assertArrayEquals(new char[] {'e', 'n', 'u'}, pj.getAxisDirections());
+        final double[] ellps = pj.getEllipsoidDefinition();
+        assertEquals(2, ellps.length);
+        ellps[1] = 1 / (1 - StrictMath.sqrt(1 - ellps[1]));     // Replace eccentricity squared
by inverse flattening.
+        assertArrayEquals(new double[] {6378137.0, 298.257223563}, ellps, 1E-9);
     }
 
     /**
@@ -94,13 +91,15 @@ public final strictfp class PJTest exten
     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);
+        final String definition = pj.getCode();
+        assertTrue(definition, definition.contains("+proj=merc"));
+        assertTrue(definition, definition.contains("+datum=WGS84"));
+        assertTrue(definition, definition.contains("+units=m"));
         assertIsWGS84(new PJ(pj));
     }
 
     /**
-     * Tests the {@link PJ#getLinearUnitToMetre(boolean)} method.
+     * Tests the units of measurement.
      *
      * @throws FactoryException if the Proj.4 definition string used in this test is invalid.
      */
@@ -108,9 +107,11 @@ public final strictfp class PJTest exten
     public void testGetLinearUnit() throws FactoryException {
         PJ pj;
         pj = new PJ("+proj=merc +to_meter=1");
-        assertEquals(1, pj.getLinearUnitToMetre(false), STRICT);
+        String definition = pj.getCode();
+        assertTrue(definition, definition.contains("+to_meter=1"));
         pj = new PJ("+proj=merc +to_meter=0.001");
-        assertEquals(0.001, pj.getLinearUnitToMetre(false), STRICT);
+        definition = pj.getCode();
+        assertTrue(definition, definition.contains("+to_meter=0.001"));
     }
 
     /**
@@ -161,20 +162,20 @@ public final strictfp class PJTest exten
     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.getCode());
         assertNull(pj.getType());
-        assertNaN(pj.getSemiMajorAxis());
-        assertNaN(pj.getSemiMinorAxis());
-        assertNaN(pj.getEccentricitySquared());
-        assertNaN(pj.getGreenwichLongitude());
-        assertNaN(pj.getLinearUnitToMetre(false));
-        assertNaN(pj.getLinearUnitToMetre(true));
+        assertNull(pj.getEllipsoidDefinition());
     }
 
     /**
-     * Asserts that the bits pattern of the given value is strictly identical to the bits
-     * pattern of the {@link java.lang.Double#NaN} constant.
+     * Tests serialization. Since we can not serialize native resources, {@link PJ} is expected
+     * to serialize the Proj.4 definition string instead.
+     *
+     * @throws FactoryException if the Proj.4 definition string used in this test is invalid.
      */
-    private static void assertNaN(final double value) {
-        assertEquals(Double.doubleToRawLongBits(Double.NaN), Double.doubleToRawLongBits(value));
+    @Test
+    public void testSerialization() throws FactoryException {
+        final PJ pj = new PJ("+proj=latlong +datum=WGS84");
+        assertNotSame(pj, assertSerializedEquals(pj));
     }
 }

Modified: sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4FactoryTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4FactoryTest.java?rev=1802945&r1=1802944&r2=1802945&view=diff
==============================================================================
--- sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4FactoryTest.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4FactoryTest.java
[UTF-8] Tue Jul 25 14:07:13 2017
@@ -19,6 +19,7 @@ package org.apache.sis.storage.gdal;
 import java.util.Arrays;
 import org.opengis.util.FactoryException;
 import org.opengis.geometry.DirectPosition;
+import org.opengis.referencing.cs.AxisDirection;
 import org.opengis.referencing.crs.ProjectedCRS;
 import org.opengis.referencing.crs.GeographicCRS;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
@@ -26,6 +27,7 @@ import org.opengis.referencing.operation
 import org.opengis.referencing.operation.Conversion;
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
+import org.opengis.parameter.ParameterValueGroup;
 import org.apache.sis.geometry.DirectPosition2D;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
@@ -33,7 +35,7 @@ import org.apache.sis.test.TestUtilities
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.opengis.test.Assert.*;
+import static org.apache.sis.test.Assert.*;
 
 
 /**
@@ -76,12 +78,12 @@ public final strictfp class Proj4Factory
     public void test4326() throws FactoryException {
         final Proj4Factory factory = Proj4Factory.INSTANCE;
         final GeographicCRS crs = factory.createGeographicCRS("+init=epsg:4326");
-        /*
-         * 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[] {'e', 'n', 'u'}, pj.getAxisDirections());
+        final String definition = pj.getCode();
+        assertTrue(definition, definition.contains("+proj=longlat"));
+        assertTrue(definition, definition.contains("+datum=WGS84"));
+        assertAxisDirectionsEqual(definition, crs.getCoordinateSystem(), AxisDirection.EAST,
AxisDirection.NORTH);
     }
 
     /**
@@ -93,12 +95,12 @@ public final strictfp class Proj4Factory
     public void test3395() throws FactoryException {
         final Proj4Factory factory = Proj4Factory.INSTANCE;
         final ProjectedCRS crs = factory.createProjectedCRS("+init=epsg:3395");
-        /*
-         * Use Proj.4 specific API to check axis order.
-         */
         final PJ pj = (PJ) TestUtilities.getSingleton(crs.getIdentifiers());
         assertEquals(PJ.Type.PROJECTED, pj.getType());
-        assertArrayEquals(new char[] {'e', 'n', 'u'}, pj.getAxisDirections());
+        final String definition = pj.getCode();
+        assertTrue(definition, definition.contains("+proj=merc"));
+        assertTrue(definition, definition.contains("+datum=WGS84"));
+        assertAxisDirectionsEqual(definition, crs.getCoordinateSystem(), AxisDirection.EAST,
AxisDirection.NORTH);
     }
 
     /**
@@ -112,13 +114,33 @@ public final strictfp class Proj4Factory
         final Proj4Factory  factory   = Proj4Factory.INSTANCE;
         final GeographicCRS sourceCRS = factory.createGeographicCRS("+init=epsg:4326");
         final ProjectedCRS  targetCRS = factory.createProjectedCRS("+init=epsg:3395");
-        final CoordinateOperation op  = factory.createOperation(sourceCRS, targetCRS);
+        final CoordinateOperation op  = factory.createOperation(sourceCRS, targetCRS, true);
         assertInstanceOf("createOperation", Conversion.class, op);
+        testMercatorProjection(op.getMathTransform());
+    }
 
-        final MathTransform mt = op.getMathTransform();
+    /**
+     * Tests EPSG:3395 on a point.
+     */
+    static void testMercatorProjection(final MathTransform mt) throws TransformException
{
         DirectPosition pt = new DirectPosition2D(20, 40);
         pt = mt.transform(pt, pt);
         assertEquals("Easting",  2226389.816, pt.getOrdinate(0), 0.01);
         assertEquals("Northing", 4838471.398, pt.getOrdinate(1), 0.01);
     }
+
+    /**
+     * Tests {@link Proj4Factory#createParameterizedTransform(ParameterValueGroup)}.
+     *
+     * @throws FactoryException if an error occurred while creating the CRS objects.
+     * @throws TransformException if an error occurred while projecting a test point.
+     */
+    @Test
+    public void testParameterizedTransform() throws FactoryException, TransformException
{
+        final Proj4Factory factory   = Proj4Factory.INSTANCE;
+        final ParameterValueGroup pg = factory.getDefaultParameters("merc");
+        pg.parameter("a").setValue(6378137.0);
+        pg.parameter("b").setValue(6356752.314245179);
+        testMercatorProjection(factory.createParameterizedTransform(pg));
+    }
 }

Modified: sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4ParserTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4ParserTest.java?rev=1802945&r1=1802944&r2=1802945&view=diff
==============================================================================
--- sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4ParserTest.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/Proj4ParserTest.java
[UTF-8] Tue Jul 25 14:07:13 2017
@@ -21,6 +21,7 @@ import org.opengis.referencing.operation
 import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory;
 import org.apache.sis.internal.referencing.provider.Mercator1SP;
 import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.measure.Units;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 import org.opengis.parameter.ParameterValueGroup;
@@ -62,5 +63,21 @@ public final strictfp class Proj4ParserT
         assertInstanceOf("method", Mercator1SP.class, parser.method(opFactory));
         final ParameterValueGroup pg = parser.parameters();
         assertEquals("scale_factor", pg.parameter("scale_factor").getValue(), 1.0);
+        assertEquals(Units.METRE, parser.unit(false));
+    }
+
+    /**
+     * Tests parsing a definition string with axes in kilometres.
+     *
+     * @throws FactoryException if the parsing failed.
+     */
+    @Test
+    public void testKilometres() throws FactoryException {
+        final Proj4Parser parser = new Proj4Parser("+proj=merc +to_meter=0.001");
+
+        assertInstanceOf("method", Mercator1SP.class, parser.method(opFactory));
+        final ParameterValueGroup pg = parser.parameters();
+        assertEquals("scale_factor", pg.parameter("scale_factor").getValue(), 1.0);
+        assertEquals(Units.KILOMETRE, parser.unit(false));
     }
 }

Modified: sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/test/suite/GDALTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/test/suite/GDALTestSuite.java?rev=1802945&r1=1802944&r2=1802945&view=diff
==============================================================================
--- sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/test/suite/GDALTestSuite.java
[UTF-8] (original)
+++ sis/trunk/storage/sis-gdal/src/test/java/org/apache/sis/test/suite/GDALTestSuite.java
[UTF-8] Tue Jul 25 14:07:13 2017
@@ -33,7 +33,8 @@ import org.junit.runners.Suite;
     org.apache.sis.storage.gdal.PJTest.class,
     org.apache.sis.storage.gdal.Proj4Test.class,
     org.apache.sis.storage.gdal.Proj4ParserTest.class,
-    org.apache.sis.storage.gdal.Proj4FactoryTest.class
+    org.apache.sis.storage.gdal.Proj4FactoryTest.class,
+    org.apache.sis.storage.gdal.IntegrationTest.class
 })
 public final strictfp class GDALTestSuite extends TestSuite {
     /**



Mime
View raw message