Author: desruisseaux
Date: Tue Jul 21 14:34:50 2015
New Revision: 1692131
URL: http://svn.apache.org/r1692131
Log:
Bug fix in the computation of scale factor at standard parallel in the North
pole case.
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/PolarStereographicTest.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java?rev=1692131&r1=1692130&r2=1692131&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
[UTF-8] Tue Jul 21 14:34:50 2015
@@ -476,7 +476,7 @@ public abstract class NormalizedProjecti
}
}
}
- return parameters.getName().getCode().matches(regex);
+ return parameters.getName().getCode().replace('_',' ').matches(regex);
}
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java?rev=1692131&r1=1692130&r2=1692131&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/PolarStereographic.java
[UTF-8] Tue Jul 21 14:34:50 2015
@@ -82,7 +82,7 @@ public class PolarStereographic extends
if (identMatch(parameters, "(?i).*\\bvariant\\s*C\\b.*",
PolarStereographicC.IDENTIFIER)) return C;
if (identMatch(parameters, "(?i).*\\bNorth\\b.*", null))
return NORTH;
if (identMatch(parameters, "(?i).*\\bSouth\\b.*", null))
return SOUTH;
- return 0; // Unidentified case, to be considered as variant A.
+ return 0; // Unidentified case, to be considered as variant B.
}
/**
@@ -102,9 +102,9 @@ public class PolarStereographic extends
roles.put(ParameterRole.FALSE_EASTING, falseEasting);
roles.put(ParameterRole.FALSE_NORTHING, falseNorthing);
roles.put(ParameterRole.SCALE_FACTOR,
PolarStereographicA.SCALE_FACTOR);
- roles.put(ParameterRole.CENTRAL_MERIDIAN, (variant == B || variant ==
C)
- ? PolarStereographicB.LONGITUDE_OF_ORIGIN
- : PolarStereographicA.LONGITUDE_OF_ORIGIN);
+ roles.put(ParameterRole.CENTRAL_MERIDIAN, (variant == A)
+ ? PolarStereographicA.LONGITUDE_OF_ORIGIN
+ : PolarStereographicB.LONGITUDE_OF_ORIGIN);
return roles;
}
@@ -172,10 +172,11 @@ public class PolarStereographic extends
* It may be possible to specify φ0 and φ1 if the caller used his own
parameter descriptor,
* in which case maybe he really wanted different sign (e.g. for
testing purpose).
*/
- φ1 = toRadians(φ1); // May be anything in [-π/2 … π/2] range.
+ final boolean isNorthPole = (φ1 >= 0);
+ φ1 = -abs(toRadians(φ1)); // May be anything in [-π/2 … 0] range.
final double ρ;
Double ρF = null; // Actually -ρF (compared to EPSG guide).
- if (abs(abs(φ1) - PI/2) < ANGULAR_TOLERANCE) {
+ if (abs(φ1 + PI/2) < ANGULAR_TOLERANCE) {
/*
* Polar Stereographic (variant A)
* True scale at pole (part of Synder 21-33). From EPSG guide
(April 2015) §1.3.7.2:
@@ -221,7 +222,7 @@ public class PolarStereographic extends
final MatrixSIS denormalize = context.getMatrix(false);
denormalize.convertBefore(0, ρ, null);
denormalize.convertBefore(1, ρ, ρF);
- if (φ1 >= 0) { // North pole.
+ if (isNorthPole) {
context.getMatrix(true).convertAfter(1, -1, null);
denormalize.convertBefore(1, -1, null);
}
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=1692131&r1=1692130&r2=1692131&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] Tue Jul 21 14:34:50 2015
@@ -29,6 +29,7 @@ import org.apache.sis.referencing.operat
import org.apache.sis.parameter.Parameters;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.mock.MathTransformFactoryMock;
import org.junit.Test;
import static java.lang.StrictMath.*;
@@ -91,6 +92,31 @@ public final strictfp class PolarStereog
}
/**
+ * Tests <cite>"Stereographic North Pole"</cite>. The tested point is
adapted from
+ * <a
href="http://www.remotesensing.org/geotiff/proj_list/polar_stereographic.html">Polar
Stereographic
+ * on remotesensing.org</a>.
+ *
+ * @throws FactoryException if an error occurred while creating the map
projection.
+ * @throws TransformException if an error occurred while projecting a
coordinate.
+ */
+ @Test
+ public void testPolarStereographicNorth() throws FactoryException,
TransformException {
+ final PolarStereographicNorth method = new PolarStereographicNorth();
+ final Parameters pg = parameters(method, true);
+ pg.parameter("standard_parallel_1").setValue(71.0);
+ pg.parameter("central_meridian").setValue(-96.0);
+ transform = new
MathTransformFactoryMock(method).createParameterizedTransform(pg);
+ tolerance = 0.02;
+ verifyTransform(new double[] {
+ -121 - (20 + 22.380/60)/60, // 121°20'22.380"W
+ 39 + ( 6 + 4.508/60)/60 // 39°06'04.508"N
+ }, new double[] {
+ -2529570,
+ -5341800
+ });
+ }
+
+ /**
* Tests the <cite>Polar Stereographic (variant A)</cite> case (EPSG:9810).
* This test is defined in GeoAPI conformance test suite.
*