Author: desruisseaux
Date: Mon Jul 20 16:08:54 2015
New Revision: 1691970
URL: http://svn.apache.org/r1691970
Log:
Added some tests and documentation.
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomainTest.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java?rev=1691970&r1=1691969&r2=1691970&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/LambertConformal.java
[UTF-8] Mon Jul 20 16:08:54 2015
@@ -110,6 +110,16 @@ public class LambertConformal extends Co
* Internal coefficients for computation, depending only on values of
standards parallels.
* This is defined as {@literal n = (ln m₁ – ln m₂) / (ln t₁ – ln t₂)} in
§1.3.1.1 of
* IOGP Publication 373-7-2 – Geomatics Guidance Note number 7, part 2 –
April 2015.
+ *
+ * <p><b>Note:</b></p>
+ * <ul>
+ * <li>If φ1 = -φ2, then the cone become a cylinder and this {@code n}
value become 0.
+ * This is limiting case is the Mercator projection, but we can not
compare with this class
+ * because {@code n=0} causes indetermination like 0 × ∞ in the
equations of this class.</li>
+ * <li>If φ1 = φ2 = ±90°, then this {@code n} value become ±1. The
formulas in the transform and
+ * inverse transform methods become basically the same than the ones
in {@link PolarStereographic},
+ * (de)normalization matrices contain NaN values.</li>
+ * </ul>
*/
final double n;
@@ -196,6 +206,11 @@ public class LambertConformal extends Co
double φ1 = getAndStore(parameters,
LambertConformal2SP.STANDARD_PARALLEL_1, φ0);
double φ2 = getAndStore(parameters,
LambertConformal2SP.STANDARD_PARALLEL_2, φ1);
if (abs(φ1 + φ2) < Formulas.ANGULAR_TOLERANCE) {
+ /*
+ * We can not allow that because if φ1 = -φ2, then n = 0 and the
equations
+ * in this class break down with indetermination like 0 × ∞.
+ * The caller should use the Mercator projection instead for such
cases.
+ */
throw new
IllegalArgumentException(Errors.format(Errors.Keys.LatitudesAreOpposite_2,
new Latitude(φ1), new Latitude(φ2)));
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java?rev=1691970&r1=1691969&r2=1691970&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
[UTF-8] Mon Jul 20 16:08:54 2015
@@ -18,6 +18,7 @@ package org.apache.sis.referencing.opera
import org.opengis.util.FactoryException;
import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.internal.referencing.Formulas;
import org.apache.sis.internal.referencing.provider.PolarStereographicA;
import org.apache.sis.internal.referencing.provider.PolarStereographicB;
import org.apache.sis.referencing.operation.transform.CoordinateDomain;
@@ -116,4 +117,41 @@ public final strictfp class PolarStereog
public void testPolarStereographicB() throws FactoryException,
TransformException {
createGeoApiTest(new PolarStereographicB()).testPolarStereographicB();
}
+
+ /**
+ * Verifies the consistency of elliptical formulas with the spherical
formulas.
+ * This test compares the results of elliptical formulas with the
spherical ones
+ * for some random points.
+ *
+ * @throws FactoryException if an error occurred while creating the map
projection.
+ * @throws TransformException if an error occurred while projecting a
coordinate.
+ */
+ private void compareEllipticalWithSpherical(final CoordinateDomain domain,
final double latitudeOfOrigin,
+ final long randomSeed) throws FactoryException, TransformException
+ {
+ createCompleteProjection(new PolarStereographicA(), false,
+ 0.5, // Central meridian
+ latitudeOfOrigin, // Latitude of origin
+ 0, // Standard parallel (none)
+ 0.994, // Scale factor
+ 200, // False easting
+ 100); // False northing
+ tolerance = Formulas.LINEAR_TOLERANCE;
+ compareEllipticalWithSpherical(domain, randomSeed);
+ }
+
+ /**
+ * Verifies the consistency of elliptical formulas with the spherical
formulas.
+ * This test compares the results of elliptical formulas with the
spherical ones
+ * for some random points.
+ *
+ * @throws FactoryException if an error occurred while creating the map
projection.
+ * @throws TransformException if an error occurred while projecting a
coordinate.
+ */
+ @Test
+ @DependsOnMethod({"testSphericalCaseSouth", "testSphericalCaseNorth"})
+ public void compareEllipticalWithSpherical() throws FactoryException,
TransformException {
+ compareEllipticalWithSpherical(CoordinateDomain.GEOGRAPHIC_SOUTH_POLE,
-90, 17326686);
+ compareEllipticalWithSpherical(CoordinateDomain.GEOGRAPHIC_NORTH_POLE,
+90, 970559366);
+ }
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java?rev=1691970&r1=1691969&r2=1691970&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomain.java
[UTF-8] Mon Jul 20 16:08:54 2015
@@ -101,7 +101,7 @@ public strictfp class CoordinateDomain {
public static final CoordinateDomain GEOGRAPHIC_POLES = new
CoordinateDomain(
Longitude.MIN_VALUE, Longitude.MAX_VALUE,
Latitude .MIN_VALUE, Latitude .MAX_VALUE,
- -0*5 * HEIGHT, 0.5 * HEIGHT)
+ -HEIGHT, HEIGHT)
{
@Override
public double[] generateRandomInput(final Random random, final int
dimension, final int numPts) {
@@ -120,6 +120,24 @@ public strictfp class CoordinateDomain {
};
/**
+ * Geographic input coordinates close to the north pole.
+ * Ordinates are in (<var>longitude</var>, <var>latitude</var>,
<var>height</var>) order.
+ */
+ public static final CoordinateDomain GEOGRAPHIC_NORTH_POLE = new
CoordinateDomain(
+ Longitude.MIN_VALUE, Longitude.MAX_VALUE,
+ ARTICLE_CIRCLE, Latitude .MAX_VALUE,
+ -HEIGHT, HEIGHT);
+
+ /**
+ * Geographic input coordinates close to the south pole.
+ * Ordinates are in (<var>longitude</var>, <var>latitude</var>,
<var>height</var>) order.
+ */
+ public static final CoordinateDomain GEOGRAPHIC_SOUTH_POLE = new
CoordinateDomain(
+ Longitude.MIN_VALUE, Longitude.MAX_VALUE,
+ Latitude .MIN_VALUE, -ARTICLE_CIRCLE,
+ -HEIGHT, HEIGHT);
+
+ /**
* Geographic input coordinates with angles in radians.
* Ordinates are in (<var>lambda</var>, <var>phi</var>, <var>height</var>)
order.
*/
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomainTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomainTest.java?rev=1691970&r1=1691969&r2=1691970&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomainTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/CoordinateDomainTest.java
[UTF-8] Mon Jul 20 16:08:54 2015
@@ -107,15 +107,45 @@ public class CoordinateDomainTest extend
public void testGeographicPole() {
assertArrayEquals(new double[] {
// ……λ …………φ ………………H
- -136.6, -74.3, 2467.5,
- -17.9, 74.7, 2338.4,
- 98.2, 66.9, 2078.0,
- 151.9, 73.8, 2799.3,
- -90.5, -86.4, 585.3
+ -136.6, -74.3, -130.1,
+ -17.9, 74.7, -646.5,
+ 98.2, 66.9, -1687.9,
+ 151.9, 73.8, 1197.0,
+ -90.5, -86.4, -7658.8
}, CoordinateDomain.GEOGRAPHIC_POLES.generateRandomInput(new
Random(6784869539382621964L), 3, 5), TOLERANCE);
}
/**
+ * Tests {@link CoordinateDomain#GEOGRAPHIC_NORTH_POLE}.
+ */
+ @Test
+ public void testGeographicNorthPole() {
+ assertArrayEquals(new double[] {
+ // ……λ …………φ ………………H
+ -41.7, 72.6, 9605.3,
+ -107.7, 68.2, 388.5,
+ 32.9, 69.3, 2553.6,
+ 106.5, 81.0, -7334.3,
+ 135.2, 87.6, -3518.9
+ }, CoordinateDomain.GEOGRAPHIC_NORTH_POLE.generateRandomInput(new
Random(2141713460614422218L), 3, 5), TOLERANCE);
+ }
+
+ /**
+ * Tests {@link CoordinateDomain#GEOGRAPHIC_SOUTH_POLE}.
+ */
+ @Test
+ public void testGeographicSouthPole() {
+ assertArrayEquals(new double[] {
+ // ……λ …………φ ………………H
+ -106.2, -71.9, -2202.6,
+ -172.6, -89.5, 2428.1,
+ 33.2, -84.3, 6068.1,
+ -64.3, -76.3, -3436.7,
+ -97.6, -72.5, 8702.2
+ }, CoordinateDomain.GEOGRAPHIC_SOUTH_POLE.generateRandomInput(new
Random(5769644852151897296L), 3, 5), TOLERANCE);
+ }
+
+ /**
* Tests {@link CoordinateDomain#GEOGRAPHIC_RADIANS}.
*/
@Test