Author: desruisseaux
Date: Mon Apr 9 17:21:17 2018
New Revision: 1828760
URL: http://svn.apache.org/viewvc?rev=1828760&view=rev
Log:
Fix a test failure with Proj4 binding (missing Proj4 identifier on projection
parameter).
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal1SP.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicB.java
sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java
sis/branches/JDK8/storage/sis-gdal/src/main/resources/native/darwin/libproj-binding.so
sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/TransformTest.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal1SP.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal1SP.java?rev=1828760&r1=1828759&r2=1828760&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal1SP.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal1SP.java
[UTF-8] Mon Apr 9 17:21:17 2018
@@ -28,7 +28,7 @@ import org.apache.sis.metadata.iso.citat
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Rueben Schulz (UBC)
- * @version 0.6
+ * @version 1.0
*
* @see <a
href="http://geotiff.maptools.org/proj_list/lambert_conic_conformal_1sp.html">GeoTIFF
parameters for Lambert Conic Conformal 1SP</a>
*
@@ -68,7 +68,7 @@ public final class LambertConformal1SP e
/**
* The group of all parameters expected by this coordinate operation.
*/
- private static final ParameterDescriptorGroup PARAMETERS;
+ static final ParameterDescriptorGroup PARAMETERS;
static {
final ParameterBuilder builder = builder();
@@ -80,6 +80,7 @@ public final class LambertConformal1SP e
.addName( "Lambert Conic Conformal (1SP)")
.addName(Citations.OGC, "Lambert_Conformal_Conic_1SP")
.addName(Citations.GEOTIFF, "CT_LambertConfConic_1SP")
+ .addName(Citations.PROJ4, "lcc")
.addIdentifier(Citations.GEOTIFF, "9")
.createGroupForMapProjection(
LATITUDE_OF_ORIGIN,
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java?rev=1828760&r1=1828759&r2=1828760&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/LambertConformal2SP.java
[UTF-8] Mon Apr 9 17:21:17 2018
@@ -164,7 +164,7 @@ public final class LambertConformal2SP e
.addName(Citations.NETCDF, "LambertConformal")
.addName(Citations.GEOTIFF, "CT_LambertConfConic_2SP")
.addName(Citations.GEOTIFF, "CT_LambertConfConic")
- .addName(Citations.PROJ4, "lcc")
+ .addName(sameNameAs(Citations.PROJ4,
LambertConformal1SP.PARAMETERS))
.addIdentifier(Citations.GEOTIFF, "8")
.addIdentifier(Citations.MAP_INFO, "3")
.addIdentifier(Citations.S57, "6")
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java?rev=1828760&r1=1828759&r2=1828760&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MercatorSpherical.java
[UTF-8] Mon Apr 9 17:21:17 2018
@@ -19,6 +19,7 @@ package org.apache.sis.internal.referenc
import javax.xml.bind.annotation.XmlTransient;
import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
+import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.parameter.ParameterBuilder;
@@ -29,7 +30,7 @@ import org.apache.sis.parameter.Paramete
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Rueben Schulz (UBC)
- * @version 0.6
+ * @version 1.0
* @since 0.6
* @module
*/
@@ -66,6 +67,7 @@ public final class MercatorSpherical ext
PARAMETERS = addNameAndLegacy(addIdentifierAndLegacy(builder,
IDENTIFIER, "9841"),
"Mercator (Spherical)", "Mercator (1SP) (Spherical)") //
"Mercator (Spherical)" starting from EPSG version 7.6
+ .addName(sameNameAs(Citations.PROJ4, Mercator1SP.PARAMETERS))
.createGroupForMapProjection(
Mercator1SP.LATITUDE_OF_ORIGIN,
Mercator1SP.LONGITUDE_OF_ORIGIN,
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java?rev=1828760&r1=1828759&r2=1828760&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/ObliqueMercator.java
[UTF-8] Mon Apr 9 17:21:17 2018
@@ -97,9 +97,10 @@ public class ObliqueMercator extends Abs
.rename (Citations.NETCDF), false); //
Remove the netCDF name.
LONGITUDE_OF_CENTRE =
createLongitude(builder.addNamesAndIdentifiers(AlbersEqualArea.LONGITUDE_OF_FALSE_ORIGIN)
- .reidentify(Citations.EPSG, "8812")
- .rename (Citations.EPSG, "Longitude of projection centre")
- .addName (Citations.ESRI, "Longitude_Of_Center")
+ .reidentify(Citations.EPSG, "8812")
+ .rename (Citations.EPSG, "Longitude of projection centre")
+ .addName (Citations.ESRI, "Longitude_Of_Center")
+ .rename (Citations.PROJ4, "lonc")
.rename (Citations.NETCDF)); //
Remove the netCDF name.
AZIMUTH = builder
@@ -119,6 +120,7 @@ public class ObliqueMercator extends Abs
.addName(Citations.OGC, "rectified_grid_angle")
.addName(Citations.ESRI, "XY_Plane_Rotation")
.addName(Citations.GEOTIFF, "RectifiedGridAngle")
+ .addName(Citations.PROJ4, "gamma")
.createBounded(-360, 360, Double.NaN, Units.DEGREE);
SCALE_FACTOR = createScale(builder
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java?rev=1828760&r1=1828759&r2=1828760&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicA.java
[UTF-8] Mon Apr 9 17:21:17 2018
@@ -35,7 +35,7 @@ import org.apache.sis.measure.Units;
*
* @author Rueben Schulz (UBC)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
*
* @see <a
href="http://geotiff.maptools.org/proj_list/polar_stereographic.html">GeoTIFF
parameters for Polar Stereographic</a>
*
@@ -80,7 +80,7 @@ public final class PolarStereographicA e
/**
* The group of all parameters expected by this coordinate operation.
*/
- private static final ParameterDescriptorGroup PARAMETERS;
+ static final ParameterDescriptorGroup PARAMETERS;
static {
final ParameterBuilder builder = builder();
LONGITUDE_OF_ORIGIN = createLongitude(builder
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicB.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicB.java?rev=1828760&r1=1828759&r2=1828760&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicB.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/PolarStereographicB.java
[UTF-8] Mon Apr 9 17:21:17 2018
@@ -30,7 +30,7 @@ import org.apache.sis.parameter.Paramete
*
* @author Rueben Schulz (UBC)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.6
* @module
*/
@@ -80,10 +80,9 @@ public final class PolarStereographicB e
.rename(Citations.EPSG, "Longitude of origin")
.reidentify(Citations.EPSG, "8833"));
- STANDARD_PARALLEL = createMandatoryLatitude(builder
- .addIdentifier("8832").addName("Latitude of standard parallel")
- .addName(sameNameAs(Citations.OGC,
Mercator2SP.STANDARD_PARALLEL))
- .addName(sameNameAs(Citations.ESRI,
Mercator2SP.STANDARD_PARALLEL)));
+ STANDARD_PARALLEL =
createMandatoryLatitude(builder.addNamesAndIdentifiers(Mercator2SP.STANDARD_PARALLEL)
+ .rename(Citations.EPSG, "Latitude of standard parallel")
+ .reidentify(Citations.EPSG, "8832"));
SCALE_FACTOR = createScale(builder
.addNamesAndIdentifiers(Mercator2SP.SCALE_FACTOR)
@@ -95,6 +94,7 @@ public final class PolarStereographicB e
.addName(Citations.S57, "Polar stereographic")
.addName(Citations.S57, "PST")
.addIdentifier(Citations.S57, "11")
+ .addName(sameNameAs(Citations.PROJ4,
PolarStereographicA.PARAMETERS))
.createGroupForMapProjection(
STANDARD_PARALLEL,
LONGITUDE_OF_ORIGIN,
Modified:
sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java?rev=1828760&r1=1828759&r2=1828760&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java
[UTF-8] Mon Apr 9 17:21:17 2018
@@ -60,6 +60,7 @@ import org.apache.sis.util.resources.Err
import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.CharSequences;
import org.apache.sis.util.Classes;
+import org.apache.sis.measure.Latitude;
import org.apache.sis.measure.Units;
@@ -77,7 +78,7 @@ import org.apache.sis.measure.Units;
* Other methods delegate to one of above-cited methods if possible, or throw
a {@link FactoryException} otherwise.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.8
* @module
*/
@@ -439,6 +440,15 @@ public class Proj4Factory extends Geodet
public MathTransform createParameterizedTransform(final
ParameterValueGroup parameters) throws FactoryException {
final String proj = name(parameters.getDescriptor(),
Errors.Keys.UnsupportedOperation_1);
final StringBuilder buffer = new
StringBuilder(100).append(PROJ_PARAM).append(proj).append(STANDARD_OPTIONS);
+ /*
+ * Proj.4 requires some parameters that are not defined in the EPSG
geodetic dataset for some projections.
+ * Those parameters are unnecessary since their values are implied by
the other parameters. However Proj.4
+ * does not seem to have any "intelligence" for such inference; we
have to specify explicitely those values
+ * in the 'switch' statements below. The Objects listed below are
parameters needed for those special cases.
+ */
+ Object latitudeOfOrigin = null;
+ Object latitudeTrueScale = null;
+ Object standardParallel1 = null;
for (final GeneralParameterValue p : parameters.values()) {
/*
* Unconditionally ask the parameter name in order to throw an
exception
@@ -448,10 +458,44 @@ public class Proj4Factory extends Geodet
if (p instanceof ParameterValue) {
final Object value = ((ParameterValue) p).getValue();
if (value != null) {
- buffer.append(" +").append(name).append('=').append(value);
+ append(buffer, name, value);
+ switch (name) {
+ case "lat_0": latitudeOfOrigin = value; break;
+ case "lat_1": standardParallel1 = value; break;
+ case "lat_ts": latitudeTrueScale = value; break;
+ }
}
}
}
+ /*
+ * See above comment about parameter inference in Proj4. To verify if
those special cases
+ * are still necessary, one can try to disable them and run
TransformTest. If those tests
+ * work with a future Proj4 version, then the special cases below
should be deleted.
+ */
+ switch (proj) {
+ /*
+ * In "Lambert Conic Conformal (1SP)" case, there is no standard
parallel (lat_1) since a scale factor (k_0)
+ * is used instead. That scale is defined as the "Scale factor at
natural origin", i.e. at lat_0. But Proj4
+ * does not seem to know that definition, so we have to
explicitely tell it that lat_0 is the latitude of
+ * true scale.
+ */
+ case "lcc": {
+ if (standardParallel1 == null && latitudeOfOrigin != null) {
+ append(buffer, "lat_1", latitudeOfOrigin);
+ }
+ break;
+ }
+ /*
+ * In "Polar Stereographic (variant B)", the latitude of natural
origin is always a pole (90°N or S).
+ * Whether it is the North or South pole is determined by the sign
of the latitude of true scale.
+ */
+ case "stere": {
+ if (latitudeOfOrigin == null && latitudeTrueScale instanceof
Number) {
+ append(buffer, "lat_0", ((Number)
latitudeTrueScale).doubleValue() < 0 ? Latitude.MIN_VALUE : Latitude.MAX_VALUE);
+ }
+ break;
+ }
+ }
final String definition = buffer.toString();
try {
final PJ pj = unique(new PJ(definition));
@@ -463,6 +507,13 @@ public class Proj4Factory extends Geodet
}
/**
+ * Appends a Proj4 parameter in the given string buffer.
+ */
+ private static void append(final StringBuilder buffer, final String param,
final Object value) {
+ buffer.append(" +").append(param).append('=').append(value);
+ }
+
+ /**
* Creates a new geodetic object from the given {@literal Proj.4}
definition.
* The default implementation delegates to {@link
#createCoordinateReferenceSystem(String)}.
*
Modified:
sis/branches/JDK8/storage/sis-gdal/src/main/resources/native/darwin/libproj-binding.so
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/main/resources/native/darwin/libproj-binding.so?rev=1828760&r1=1828759&r2=1828760&view=diff
==============================================================================
Binary files - no diff available.
Modified:
sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/TransformTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/TransformTest.java?rev=1828760&r1=1828759&r2=1828760&view=diff
==============================================================================
---
sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/TransformTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/storage/sis-gdal/src/test/java/org/apache/sis/storage/gdal/TransformTest.java
[UTF-8] Mon Apr 9 17:21:17 2018
@@ -89,16 +89,12 @@ public class TransformTest extends Param
assertSetEquals(Arrays.asList(
"Abridged Molodensky",
"Cassini-Soldner", // No
OperationMethod in SIS yet.
- "Hotine Oblique Mercator (variant B)",
"Krovak", // No
OperationMethod in SIS yet.
"Lambert Azimuthal Equal Area", // No
OperationMethod in SIS yet.
- "Lambert Conic Conformal (1SP)",
"Lambert Conic Conformal (2SP Belgium)",
"Lambert Conic Conformal (2SP Michigan)",
- "Mercator (Spherical)",
- "Mercator (variant C)",
- "Polar Stereographic (variant B)",
- "Polar Stereographic (variant C)",
+ "Mercator (variant C)", // Need to
verify if Proj4 handles easting/northing correctly.
+ "Polar Stereographic (variant C)", // Need to
verify if Proj4 handles northing correctly.
"Popular Visualisation Pseudo Mercator",
"Polyconic", // No
OperationMethod in SIS yet.
"Transverse Mercator (South Orientated)"), FAILURES);