Author: desruisseaux Date: Thu Jul 16 17:08:09 2015 New Revision: 1691420 URL: http://svn.apache.org/r1691420 Log: Added "Transverse Mercator (South Orientated)" operation method.
Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercatorSouth.java - copied, changed from r1691249, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java?rev=1691420&r1=1691419&r2=1691420&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java [UTF-8] Thu Jul 16 17:08:09 2015 @@ -25,7 +25,7 @@ import org.apache.sis.referencing.operat /** - * The provider for <cite>Transverse Mercator</cite> projection (EPSG codes 9807). + * The provider for <cite>"Transverse Mercator"</cite> projection (EPSG:9807). * * @author Martin Desruisseaux (MPO, IRD, Geomatys) * @author Rueben Schulz (UBC) Copied: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercatorSouth.java (from r1691249, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java) URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercatorSouth.java?p2=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercatorSouth.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java&r1=1691249&r2=1691420&rev=1691420&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercator.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/TransverseMercatorSouth.java [UTF-8] Thu Jul 16 17:08:09 2015 @@ -16,48 +16,35 @@ */ package org.apache.sis.internal.referencing.provider; -import org.opengis.parameter.ParameterDescriptor; import org.opengis.parameter.ParameterDescriptorGroup; import org.apache.sis.parameter.ParameterBuilder; -import org.apache.sis.metadata.iso.citation.Citations; import org.apache.sis.parameter.Parameters; import org.apache.sis.referencing.operation.projection.NormalizedProjection; /** - * The provider for <cite>Transverse Mercator</cite> projection (EPSG codes 9807). + * The provider for <cite>"Transverse Mercator (South Orientated)"</cite> projection (EPSG:9808). + * The terms <cite>false easting</cite> (FE) and <cite>false northing</cite> (FN) increase + * the Westing and Southing value at the natural origin. In other words they are effectively + * <cite>false westing</cite> (FW) and <cite>false southing</cite> (FS) respectively. * * @author Martin Desruisseaux (MPO, IRD, Geomatys) - * @author Rueben Schulz (UBC) * @since 0.6 * @version 0.6 * @module * * @see <a href="http://www.remotesensing.org/geotiff/proj_list/transverse_mercator.html">Transverse Mercator on RemoteSensing.org</a> */ -public final class TransverseMercator extends AbstractMercator { +public final class TransverseMercatorSouth extends AbstractMercator { /** * For cross-version compatibility. */ - private static final long serialVersionUID = -3386587506686432398L; + private static final long serialVersionUID = -5938929136350638347L; /** - * The operation parameter descriptor for the <cite>Latitude of natural origin</cite> (φ₀) parameter value. - * Valid values range is [-90 … 90]° and default value is 0°. + * The EPSG identifier, to be preferred to the name when available. */ - public static final ParameterDescriptor<Double> LATITUDE_OF_ORIGIN; - - /** - * The operation parameter descriptor for the <cite>Longitude of natural origin</cite> (λ₀) parameter value. - * Valid values range is [-180 … 180]° and default value is 0°. - */ - public static final ParameterDescriptor<Double> LONGITUDE_OF_ORIGIN; - - /** - * The operation parameter descriptor for the <cite>Scale factor at natural origin</cite> (k₀) parameter value. - * Valid values range is (0 … ∞) and default value is 1. - */ - public static final ParameterDescriptor<Double> SCALE_FACTOR; + public static final String IDENTIFIER = "9808"; /** * The group of all parameters expected by this coordinate operation. @@ -65,37 +52,14 @@ public final class TransverseMercator ex static final ParameterDescriptorGroup PARAMETERS; static { final ParameterBuilder builder = builder(); - LATITUDE_OF_ORIGIN = createLatitude(builder - .addNamesAndIdentifiers(Mercator1SP.LATITUDE_OF_ORIGIN), true); - - LONGITUDE_OF_ORIGIN = createLongitude(builder.addNamesAndIdentifiers(Mercator1SP.CENTRAL_MERIDIAN) - .rename(Citations.NETCDF, "longitude_of_central_meridian")); - - SCALE_FACTOR = createScale(builder - .addNamesAndIdentifiers(Mercator1SP.SCALE_FACTOR) - .rename(Citations.NETCDF, "scale_factor_at_central_meridian")); PARAMETERS = builder - .addIdentifier( "9807") - .addName( "Transverse Mercator") - .addName(Citations.OGC, "Transverse_Mercator") - .addName(Citations.ESRI, "Transverse_Mercator") - .addName(Citations.NETCDF, "TransverseMercator") - .addName(Citations.GEOTIFF, "CT_TransverseMercator") - .addName(Citations.S57, "Transverse Mercator") - .addName(Citations.PROJ4, "tmerc") - .addName( "Gauss-Kruger") - .addName(Citations.ESRI, "Gauss_Kruger") - .addName( "Gauss-Boaga") - .addName( "TM") - .addName(Citations.S57, "TME") - .addIdentifier(Citations.GEOTIFF, "1") - .addIdentifier(Citations.MAP_INFO, "8") - .addIdentifier(Citations.S57, "13") + .addIdentifier(IDENTIFIER) + .addName("Transverse Mercator (South Orientated)") .createGroupForMapProjection( - LATITUDE_OF_ORIGIN, - LONGITUDE_OF_ORIGIN, - SCALE_FACTOR, + TransverseMercator.LATITUDE_OF_ORIGIN, + TransverseMercator.LONGITUDE_OF_ORIGIN, + TransverseMercator.SCALE_FACTOR, FALSE_EASTING, FALSE_NORTHING); } @@ -103,7 +67,7 @@ public final class TransverseMercator ex /** * Constructs a new provider. */ - public TransverseMercator() { + public TransverseMercatorSouth() { super(PARAMETERS); } Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java?rev=1691420&r1=1691419&r2=1691420&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java [UTF-8] Thu Jul 16 17:08:09 2015 @@ -19,14 +19,16 @@ package org.apache.sis.referencing.opera import java.util.Map; import java.util.EnumMap; import org.opengis.parameter.ParameterDescriptor; +import org.opengis.parameter.ParameterDescriptorGroup; import org.opengis.referencing.operation.Matrix; import org.opengis.referencing.operation.OperationMethod; import org.apache.sis.referencing.operation.matrix.MatrixSIS; import org.apache.sis.internal.referencing.provider.MapProjection; +import org.apache.sis.internal.referencing.provider.TransverseMercatorSouth; import org.apache.sis.internal.util.DoubleDouble; import org.apache.sis.parameter.Parameters; - import org.apache.sis.util.resources.Errors; + import static java.lang.Math.*; import static org.apache.sis.math.MathFunctions.asinh; import static org.apache.sis.math.MathFunctions.atanh; @@ -75,16 +77,29 @@ public class TransverseMercator extends * * @return The roles map to give to super-class constructor. */ - private static Map<ParameterRole, ParameterDescriptor<Double>> roles() { + private static Map<ParameterRole, ParameterDescriptor<Double>> roles(final boolean isSouth) { final EnumMap<ParameterRole, ParameterDescriptor<Double>> roles = new EnumMap<>(ParameterRole.class); + ParameterRole xOffset = ParameterRole.FALSE_EASTING; + ParameterRole yOffset = ParameterRole.FALSE_NORTHING; + if (isSouth) { + xOffset = ParameterRole.FALSE_WESTING; + yOffset = ParameterRole.FALSE_SOUTHING; + } roles.put(ParameterRole.CENTRAL_MERIDIAN, org.apache.sis.internal.referencing.provider.TransverseMercator.LONGITUDE_OF_ORIGIN); roles.put(ParameterRole.SCALE_FACTOR, org.apache.sis.internal.referencing.provider.TransverseMercator.SCALE_FACTOR); - roles.put(ParameterRole.FALSE_EASTING, org.apache.sis.internal.referencing.provider.TransverseMercator.FALSE_EASTING); - roles.put(ParameterRole.FALSE_NORTHING, org.apache.sis.internal.referencing.provider.TransverseMercator.FALSE_NORTHING); + roles.put(xOffset, org.apache.sis.internal.referencing.provider.TransverseMercator.FALSE_EASTING); + roles.put(yOffset, org.apache.sis.internal.referencing.provider.TransverseMercator.FALSE_NORTHING); return roles; } /** + * Returns the type of the projection based on the name and identifier of the given parameter group. + */ + private static boolean isSouth(final ParameterDescriptorGroup parameters) { + return identMatch(parameters, "(?i).*\\bSouth\\b.*", TransverseMercatorSouth.IDENTIFIER); + } + + /** * Creates a Transverse Mercator projection from the given parameters. * The {@code method} argument can be the description of one of the following: * @@ -96,7 +111,7 @@ public class TransverseMercator extends * @param parameters The parameter values of the projection to create. */ public TransverseMercator(final OperationMethod method, final Parameters parameters) { - super(method, parameters, roles()); + super(method, parameters, roles(isSouth(parameters.getDescriptor()))); final double φ0 = toRadians(getAndStore(parameters, org.apache.sis.internal.referencing.provider.TransverseMercator.LATITUDE_OF_ORIGIN)); final double rs = parameters.doubleValue(MapProjection.SEMI_MINOR) Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java?rev=1691420&r1=1691419&r2=1691420&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java [UTF-8] Thu Jul 16 17:08:09 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.provider.TransverseMercatorSouth; import org.apache.sis.parameter.Parameters; import org.apache.sis.test.DependsOn; import org.junit.Test; @@ -66,6 +67,21 @@ public final strictfp class TransverseMe } /** + * Tests the <cite>Transverse Mercator (South Orientated)</cite> case (EPSG:9808). + * 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#testTransverseMercatorSouthOrientated() + */ + @Test + @org.junit.Ignore("Missing implementation of the projection derivative.") + public void testTransverseMercatorSouthOrientated() throws FactoryException, TransformException { + createGeoApiTest(new TransverseMercatorSouth()).testTransverseMercatorSouthOrientated(); + } + + /** * Creates a projection and derivates a few points. * * @throws TransformException Should never happen.