sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1671428 - in /sis/branches/JDK8/core/sis-referencing/src: main/java/org/apache/sis/internal/referencing/provider/ main/java/org/apache/sis/referencing/operation/projection/ test/java/org/apache/sis/internal/referencing/provider/ test/java/...
Date Sun, 05 Apr 2015 21:36:47 GMT
Author: desruisseaux
Date: Sun Apr  5 21:36:46 2015
New Revision: 1671428

URL: http://svn.apache.org/r1671428
Log:
Referencing: minor fix in parameter names, and added tests for "Mercator (variant C)" and
"Mercator (Spherical)".

Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RegionalMercator.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/NormalizedProjection.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
    sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java?rev=1671428&r1=1671427&r2=1671428&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
[UTF-8] Sun Apr  5 21:36:46 2015
@@ -50,7 +50,7 @@ public final class Mercator2SP extends A
      * The operation parameter descriptor for the <cite>Latitude of 1st standard parallel</cite>
(φ₁) parameter value.
      * Valid values range is (-90 … 90)° and default value is 0°.
      */
-    public static final ParameterDescriptor<Double> STANDARD_PARALLEL;
+    public static final ParameterDescriptor<Double> STANDARD_PARALLEL = Equirectangular.STANDARD_PARALLEL;
 
     /**
      * The operation parameter descriptor for the <cite>Latitude of natural origin</cite>
(φ₀) parameter value.
@@ -86,9 +86,6 @@ public final class Mercator2SP extends A
     static final ParameterDescriptorGroup PARAMETERS;
     static {
         final ParameterBuilder builder = builder();
-        STANDARD_PARALLEL = createLatitude(builder.addNamesAndIdentifiers(Equirectangular.STANDARD_PARALLEL)
-                .rename(Citations.GEOTIFF, "StdParallel1")
-                .rename(Citations.PROJ4,   "lat_1"), false);
         /*
          * "Latitude of natural origin" and "Scale factor" are not formally parameters of
the "Mercator (variant B)"
          * projection according EPSG. But we declare them as optional parameters because
they are sometime used.
@@ -97,7 +94,7 @@ public final class Mercator2SP extends A
          * factor applied here would rather at the standard parallel.
          */
         builder.setRequired(false); // Will apply to all remaining parameters.
-        LATITUDE_OF_ORIGIN = createConstant(builder.addNamesAndIdentifiers(Mercator1SP.LATITUDE_OF_ORIGIN)
+        LATITUDE_OF_ORIGIN = createConstant(exceptEPSG(Mercator1SP.LATITUDE_OF_ORIGIN, builder)
                 .setRemarks(Mercator1SP.LATITUDE_OF_ORIGIN.getRemarks()), 0.0);
 
         SCALE_FACTOR = createScale(exceptEPSG(Mercator1SP.SCALE_FACTOR, builder)

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RegionalMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RegionalMercator.java?rev=1671428&r1=1671427&r2=1671428&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RegionalMercator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/RegionalMercator.java
[UTF-8] Sun Apr  5 21:36:46 2015
@@ -24,6 +24,12 @@ import org.apache.sis.parameter.Paramete
 /**
  * The provider for "<cite>Mercator (variant C)</cite>" projection (EPSG:1044).
  *
+ * <div class="note"><b>Note on naming:</b>
+ * The "Regional Mercator" class name is inspired by MapInfo practice, while not exactly
the same projection.
+ * The idea is that this class stands for the Mercator projection giving the most control
to the user for
+ * fitting a Mercator projection to a particular area of interest.
+ * </div>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.6
  * @version 0.6

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java?rev=1671428&r1=1671427&r2=1671428&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
[UTF-8] Sun Apr  5 21:36:46 2015
@@ -198,7 +198,7 @@ public class Mercator extends Normalized
             denormalize.concatenate(0, null, offset);
         }
         if (φ0 != 0) {
-            denormalize.concatenate(0, null, new DoubleDouble(-log(expOfNorthing(φ0, excentricity
* sin(φ0)))));
+            denormalize.concatenate(1, null, new DoubleDouble(-log(expOfNorthing(φ0, excentricity
* sin(φ0)))));
         }
         if (type == MILLER) {
             normalize  .concatenate(1, new DoubleDouble(0.8),  null);

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=1671428&r1=1671427&r2=1671428&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] Sun Apr  5 21:36:46 2015
@@ -288,16 +288,25 @@ public abstract class NormalizedProjecti
      */
     final double getAndStore(final Parameters parameters, final ParameterDescriptor<Double>
descriptor) {
         final double value = parameters.doubleValue(descriptor);    // Apply a unit conversion
if needed.
-        Comparable<Double> check = descriptor.getMinimumValue();
-        if (check instanceof Number && !(value >= ((Number) check).doubleValue()))
{
-            throw outOfBounds(descriptor, value);
+        final Comparable<Double> min = descriptor.getMinimumValue();
+        final Comparable<Double> max = descriptor.getMaximumValue();
+        if (!Objects.equals(min, max)) {
+            /*
+             * Why we do not check the bounds in min == max:
+             * The only case when our descriptor have (min == max) is when a parameter can
only be zero,
+             * because of the way the map projection is defined. But in some cases, it would
be possible
+             * to deal with non-zero values, even if in principle we should not. In such
case we let the
+             * caller decides.
+             */
+            if (min instanceof Number && !(value >= ((Number) min).doubleValue()))
{
+                throw outOfBounds(descriptor, value);
+            }
+            if (max instanceof Number && !(value <= ((Number) max).doubleValue()))
{
+                throw outOfBounds(descriptor, value);
+            }
         }
-        check = descriptor.getMaximumValue();
-        if (check instanceof Number && !(value <= ((Number) check).doubleValue()))
{
-            throw outOfBounds(descriptor, value);
-        }
-        check = descriptor.getDefaultValue();
-        if (check == null || !check.equals(value)) {
+        final Double defaultValue = descriptor.getDefaultValue();
+        if (defaultValue == null || !defaultValue.equals(value)) {
             context.parameter(descriptor.getName().getCode()).setValue(value);
         }
         return value;

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java?rev=1671428&r1=1671427&r2=1671428&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
[UTF-8] Sun Apr  5 21:36:46 2015
@@ -80,7 +80,7 @@ public final strictfp class MapProjectio
         assertParamEquals(null,                                 SEMI_MAJOR,           true,
it.next());
         assertParamEquals(null,                                 SEMI_MINOR,           true,
it.next());
         assertParamEquals("Latitude of 1st standard parallel", "standard_parallel_1", true,
 it.next());
-        assertParamEquals("Latitude of natural origin",        "latitude_of_origin",  false,
it.next());
+        assertParamEquals(null,                                "latitude_of_origin",  false,
it.next());
         assertParamEquals("Longitude of natural origin",       "central_meridian",    true,
 it.next());
         assertParamEquals(null,                                "scale_factor",        false,
it.next());
         assertParamEquals("False easting",                     "false_easting",       true,
 it.next());

Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java?rev=1671428&r1=1671427&r2=1671428&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/MercatorTest.java
[UTF-8] Sun Apr  5 21:36:46 2015
@@ -21,8 +21,10 @@ import org.opengis.referencing.operation
 import org.apache.sis.internal.referencing.Formulas;
 import org.apache.sis.internal.referencing.provider.Mercator1SP;
 import org.apache.sis.internal.referencing.provider.Mercator2SP;
+import org.apache.sis.internal.referencing.provider.MercatorSpherical;
 import org.apache.sis.internal.referencing.provider.PseudoMercator;
 import org.apache.sis.internal.referencing.provider.MillerCylindrical;
+import org.apache.sis.internal.referencing.provider.RegionalMercator;
 import org.apache.sis.referencing.operation.transform.CoordinateDomain;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
@@ -172,7 +174,7 @@ public final strictfp class MercatorTest
      * @see org.opengis.test.referencing.ParameterizedTransformTest#testMercator1SP()
      */
     @Test
-    @DependsOnMethod("testMercator2SP")  // Because our Mercator implementation checks for
Mercator2SP parameters.
+    @DependsOnMethod({"testSpecialLatitudes", "testDerivative"})
     public void testMercator1SP() throws FactoryException, TransformException {
         createGeoApiTest(new Mercator1SP()).testMercator1SP();
     }
@@ -187,12 +189,42 @@ public final strictfp class MercatorTest
      * @see org.opengis.test.referencing.ParameterizedTransformTest#testMercator2SP()
      */
     @Test
-    @DependsOnMethod({"testSpecialLatitudes", "testDerivative"})
+    @DependsOnMethod("testMercator1SP")
     public void testMercator2SP() throws FactoryException, TransformException {
         createGeoApiTest(new Mercator2SP()).testMercator2SP();
     }
 
     /**
+     * Tests the <cite>"Mercator (variant C)"</cite> case (EPSG:1044).
+     * This test is defined in GeoAPI conformance test suite.
+     *
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws TransformException if an error occurred while projecting a coordinate.
+     *
+     * @see org.opengis.test.referencing.ParameterizedTransformTest#testMercatorVariantC()
+     */
+    @Test
+    @DependsOnMethod("testMercator2SP")
+    public void testRegionalMercator() throws FactoryException, TransformException {
+        createGeoApiTest(new RegionalMercator()).testMercatorVariantC();
+    }
+
+    /**
+     * Tests the <cite>"Mercator (Spherical)"</cite> case (EPSG:1026).
+     * This test is defined in GeoAPI conformance test suite.
+     *
+     * @throws FactoryException if an error occurred while creating the map projection.
+     * @throws TransformException if an error occurred while projecting a coordinate.
+     *
+     * @see org.opengis.test.referencing.ParameterizedTransformTest#testMercatorSpherical()
+     */
+    @Test
+    @DependsOnMethod("testMercator1SP")
+    public void testMercatorSpherical() throws FactoryException, TransformException {
+        createGeoApiTest(new MercatorSpherical()).testMercatorSpherical();
+    }
+
+    /**
      * Tests the <cite>"Popular Visualisation Pseudo Mercator"</cite> case (EPSG:1024).
      * This test is defined in GeoAPI conformance test suite.
      *
@@ -202,7 +234,7 @@ public final strictfp class MercatorTest
      * @see org.opengis.test.referencing.ParameterizedTransformTest#testPseudoMercator()
      */
     @Test
-    @DependsOnMethod("testMercator1SP")
+    @DependsOnMethod("testMercatorSpherical")
     public void testPseudoMercator() throws FactoryException, TransformException {
         createGeoApiTest(new PseudoMercator()).testPseudoMercator();
     }



Mime
View raw message