You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2015/12/09 22:01:16 UTC
svn commit: r1718968 - in /sis/branches/JDK8:
core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/
core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/
core/sis-referencing/src/main/java/org/apache/sis/refe...
Author: desruisseaux
Date: Wed Dec 9 21:01:15 2015
New Revision: 1718968
URL: http://svn.apache.org/viewvc?rev=1718968&view=rev
Log:
Port more tests.
Added:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/InvalidGeodeticParameterException.java
- copied, changed from r1718829, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Geographic3Dto2D.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/VerticalOffset.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/FranceGeocentricInterpolation.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -320,7 +320,7 @@ public final class FranceGeocentricInter
try {
tr = tr.inverse();
} catch (NoninvertibleTransformException e) {
- throw new FactoryException(e); // Should never happen.
+ throw new FactoryException(e); // Should never happen.
}
return tr;
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricAffineBetweenGeographic.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -156,7 +156,7 @@ public abstract class GeocentricAffineBe
try {
toGeographic = toGeographic.inverse();
} catch (NoninvertibleTransformException e) {
- throw new FactoryException(e); // Should never happen with SIS implementation.
+ throw new FactoryException(e); // Should never happen with SIS implementation.
}
/*
* The Geocentric → Affine → Geographic chain.
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/GeocentricToGeographic.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -103,7 +103,7 @@ public final class GeocentricToGeographi
try {
tr = tr.inverse();
} catch (NoninvertibleTransformException e) {
- throw new FactoryException(e);
+ throw new FactoryException(e); // Should never happen with SIS implementation.
}
return tr;
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Geographic3Dto2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Geographic3Dto2D.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Geographic3Dto2D.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Geographic3Dto2D.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -103,11 +103,11 @@ public final class Geographic3Dto2D exte
{
if (transform == null) try {
final MatrixSIS m = Matrices.createDiagonal(4, 3);
- m.setElement(2, 2, 0); // Here is the height value that we want.
+ m.setElement(2, 2, 0); // Here is the height value that we want.
m.setElement(3, 2, 1);
transform = MathTransforms.linear(m).inverse();
} catch (NoninvertibleTransformException e) {
- throw new FactoryException(e); // Should never happen.
+ throw new FactoryException(e); // Should never happen.
}
return transform;
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/VerticalOffset.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/VerticalOffset.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/VerticalOffset.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/VerticalOffset.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -114,7 +114,7 @@ public final class VerticalOffset extend
if (after.getElement(0,0) < 0) try {
parameterized = parameterized.inverse();
} catch (NoninvertibleTransformException e) {
- throw new FactoryException(e);
+ throw new FactoryException(e); // Should never happe since matrix element is not zero.
}
return parameterized;
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/GeodeticObjectFactory.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -352,7 +352,7 @@ public class GeodeticObjectFactory exten
try {
crs = new DefaultGeocentricCRS(complete(properties), datum, cs);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createGeocentricCRS", crs);
}
@@ -387,7 +387,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultCartesianCS(complete(properties), axis0, axis1, axis2);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createCartesianCS", cs);
}
@@ -422,7 +422,7 @@ public class GeodeticObjectFactory exten
try {
crs = new DefaultGeocentricCRS(complete(properties), datum, cs);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createGeocentricCRS", crs);
}
@@ -457,7 +457,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultSphericalCS(complete(properties), axis0, axis1, axis2);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createSphericalCS", cs);
}
@@ -490,7 +490,7 @@ public class GeodeticObjectFactory exten
try {
crs = new DefaultGeographicCRS(complete(properties), datum, cs);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createGeographicCRS", crs);
}
@@ -524,7 +524,7 @@ public class GeodeticObjectFactory exten
try {
datum = new DefaultGeodeticDatum(complete(properties), ellipsoid, primeMeridian);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createGeodeticDatum", datum);
}
@@ -551,7 +551,7 @@ public class GeodeticObjectFactory exten
try {
meridian = new DefaultPrimeMeridian(complete(properties), longitude, angularUnit);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createPrimeMeridian", meridian);
}
@@ -584,7 +584,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultEllipsoidalCS(complete(properties), axis0, axis1);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createEllipsoidalCS", cs);
}
@@ -620,7 +620,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultEllipsoidalCS(complete(properties), axis0, axis1, axis2);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createEllipsoidalCS", cs);
}
@@ -647,7 +647,7 @@ public class GeodeticObjectFactory exten
try {
ellipsoid = DefaultEllipsoid.createEllipsoid(complete(properties), semiMajorAxis, semiMinorAxis, unit);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createEllipsoid", ellipsoid);
}
@@ -674,7 +674,7 @@ public class GeodeticObjectFactory exten
try {
ellipsoid = DefaultEllipsoid.createFlattenedSphere(complete(properties), semiMajorAxis, inverseFlattening, unit);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createFlattenedSphere", ellipsoid);
}
@@ -716,7 +716,7 @@ public class GeodeticObjectFactory exten
try {
crs = new DefaultProjectedCRS(complete(properties), baseCRS, conversion, derivedCS);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createProjectedCRS", crs);
}
@@ -749,7 +749,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultCartesianCS(complete(properties), axis0, axis1);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createCartesianCS", cs);
}
@@ -793,7 +793,7 @@ public class GeodeticObjectFactory exten
try {
crs = DefaultDerivedCRS.create(complete(properties), (SingleCRS) baseCRS, conversion, derivedCS);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createDerivedCRS", crs);
}
@@ -827,7 +827,7 @@ public class GeodeticObjectFactory exten
try {
crs = new DefaultVerticalCRS(complete(properties), datum, cs);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createVerticalCRS", crs);
}
@@ -851,7 +851,7 @@ public class GeodeticObjectFactory exten
try {
datum = new DefaultVerticalDatum(complete(properties), type);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createVerticalDatum", datum);
}
@@ -882,7 +882,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultVerticalCS(complete(properties), axis);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createVerticalCS", cs);
}
@@ -914,7 +914,7 @@ public class GeodeticObjectFactory exten
try {
crs = new DefaultTemporalCRS(complete(properties), datum, cs);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createTemporalCRS", crs);
}
@@ -938,7 +938,7 @@ public class GeodeticObjectFactory exten
try {
datum = new DefaultTemporalDatum(complete(properties), origin);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createTemporalDatum", datum);
}
@@ -969,7 +969,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultTimeCS(complete(properties), axis);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createTimeCS", cs);
}
@@ -1002,7 +1002,7 @@ public class GeodeticObjectFactory exten
try {
crs = new DefaultCompoundCRS(complete(properties), elements);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createCompoundCRS", crs);
}
@@ -1027,7 +1027,7 @@ public class GeodeticObjectFactory exten
try {
crs = new DefaultImageCRS(complete(properties), datum, cs);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createImageCRS", crs);
}
@@ -1051,7 +1051,7 @@ public class GeodeticObjectFactory exten
try {
datum = new DefaultImageDatum(complete(properties), pixelInCell);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createImageDatum", datum);
}
@@ -1084,7 +1084,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultAffineCS(complete(properties), axis0, axis1);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createAffineCS", cs);
}
@@ -1122,7 +1122,7 @@ public class GeodeticObjectFactory exten
try {
crs = new DefaultEngineeringCRS(complete(properties), datum, cs);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createEngineeringCRS", crs);
}
@@ -1145,7 +1145,7 @@ public class GeodeticObjectFactory exten
try {
datum = new DefaultEngineeringDatum(complete(properties));
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createEngineeringDatum", datum);
}
@@ -1180,7 +1180,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultAffineCS(complete(properties), axis0, axis1, axis2);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createAffineCS", cs);
}
@@ -1215,7 +1215,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultCylindricalCS(complete(properties), axis0, axis1, axis2);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createCylindricalCS", cs);
}
@@ -1248,7 +1248,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultPolarCS(complete(properties), axis0, axis1);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createPolarCS", cs);
}
@@ -1278,7 +1278,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultLinearCS(complete(properties), axis);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createLinearCS", cs);
}
@@ -1310,7 +1310,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultUserDefinedCS(complete(properties), axis0, axis1);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createUserDefinedCS", cs);
}
@@ -1344,7 +1344,7 @@ public class GeodeticObjectFactory exten
try {
cs = new DefaultUserDefinedCS(complete(properties), axis0, axis1, axis2);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createUserDefinedCS", cs);
}
@@ -1374,7 +1374,7 @@ public class GeodeticObjectFactory exten
try {
axis = new DefaultCoordinateSystemAxis(complete(properties), abbreviation, direction, unit);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception);
}
return unique("createCoordinateSystemAxis", axis);
}
@@ -1395,7 +1395,7 @@ public class GeodeticObjectFactory exten
try {
object = XML.unmarshal(xml);
} catch (JAXBException e) {
- throw new FactoryException(e);
+ throw new FactoryException(e.getLocalizedMessage(), e);
}
if (object instanceof CoordinateReferenceSystem) {
return (CoordinateReferenceSystem) object;
Copied: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/InvalidGeodeticParameterException.java (from r1718829, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/InvalidGeodeticParameterException.java?p2=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/InvalidGeodeticParameterException.java&p1=sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java&r1=1718829&r2=1718968&rev=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/InvalidGeodeticParameterException.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -20,27 +20,30 @@ import org.opengis.util.FactoryException
/**
- * Thrown when a factory can not be created because an optional resource is missing.
- * The most common case is when the {@link org.apache.sis.referencing.factory.epsg.EPSGFactory}
- * has no connection to an EPSG database.
+ * Thrown when a factory {@code createFoo(…)} method is given invalid parameters.
+ * This exception may be thrown by factories that create an object from geodetic parameters
+ * like semi-major or semi-minor axis length, latitude of natural origin, <i>etc</i>.
+ * The cause may be a parameter having an illegal value, or a mandatory parameter which has not been specified.
*
- * @author Martin Desruisseaux (IRD)
+ * <div class="note"><b>Note:</b>
+ * this exception is not for invalid authority codes. For such cases, see
+ * {@link org.opengis.referencing.NoSuchAuthorityCodeException} instead.</div>
+ *
+ * @author Martin Desruisseaux (Geomatys)
* @since 0.7
* @version 0.7
* @module
- *
- * @see ConcurrentAuthorityFactory#createBackingStore()
*/
-public class UnavailableFactoryException extends FactoryException {
+public class InvalidGeodeticParameterException extends FactoryException {
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = -661925454228937249L;
+ private static final long serialVersionUID = -546427967147139788L;
/**
* Construct an exception with no detail message.
*/
- public UnavailableFactoryException() {
+ public InvalidGeodeticParameterException() {
}
/**
@@ -49,31 +52,32 @@ public class UnavailableFactoryException
* @param message The detail message. The detail message is saved
* for later retrieval by the {@link #getMessage()} method.
*/
- public UnavailableFactoryException(String message) {
+ public InvalidGeodeticParameterException(String message) {
super(message);
}
/**
* Construct an exception with the specified cause.
*
+ * <p>This constructor is not public because its behavior is slightly different than the default JDK behavior:
+ * the message is set to the throwable message instead than to {@code throwable.toString()}.</p>
+ *
* @param cause The cause for this exception. The cause is saved
* for later retrieval by the {@link #getCause()} method.
*/
- public UnavailableFactoryException(Throwable cause) {
+ InvalidGeodeticParameterException(Throwable cause) {
super(cause.getLocalizedMessage(), cause);
}
/**
* Construct an exception with the specified detail message and cause.
- * The cause is the exception thrown in the underlying database
- * (e.g. {@link java.io.IOException} or {@link java.sql.SQLException}).
*
* @param message The detail message. The detail message is saved
* for later retrieval by the {@link #getMessage()} method.
* @param cause The cause for this exception. The cause is saved
* for later retrieval by the {@link #getCause()} method.
*/
- public UnavailableFactoryException(String message, Throwable cause) {
+ public InvalidGeodeticParameterException(String message, Throwable cause) {
super(message, cause);
}
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/UnavailableFactoryException.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -54,16 +54,6 @@ public class UnavailableFactoryException
}
/**
- * Construct an exception with the specified cause.
- *
- * @param cause The cause for this exception. The cause is saved
- * for later retrieval by the {@link #getCause()} method.
- */
- public UnavailableFactoryException(Throwable cause) {
- super(cause.getLocalizedMessage(), cause);
- }
-
- /**
* Construct an exception with the specified detail message and cause.
* The cause is the exception thrown in the underlying database
* (e.g. {@link java.io.IOException} or {@link java.sql.SQLException}).
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactory.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -33,6 +33,7 @@ import org.apache.sis.internal.metadata.
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.util.CollectionsExt;
import org.apache.sis.internal.util.Utilities;
+import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
import org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory;
import org.apache.sis.util.collection.WeakHashSet;
import org.apache.sis.util.collection.Containers;
@@ -246,7 +247,7 @@ public class DefaultCoordinateOperationF
try {
method = new DefaultOperationMethod(properties, sourceDimensions, targetDimensions, parameters);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
}
return pool.unique(method);
}
@@ -306,7 +307,7 @@ public class DefaultCoordinateOperationF
try {
conversion = new DefaultConversion(properties, method, null, parameters);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
}
// We do no invoke unique(conversion) because defining conversions are usually short-lived objects.
return conversion;
@@ -521,7 +522,7 @@ public class DefaultCoordinateOperationF
try {
op = new DefaultConcatenatedOperation(properties, operations, getMathTransformFactory());
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
}
return pool.unique(op);
}
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -60,6 +60,7 @@ import org.apache.sis.internal.referenci
import org.apache.sis.internal.system.Loggers;
import org.apache.sis.referencing.cs.AxesConvention;
import org.apache.sis.referencing.cs.CoordinateSystems;
+import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
import org.apache.sis.referencing.operation.DefaultOperationMethod;
import org.apache.sis.referencing.operation.matrix.Matrices;
import org.apache.sis.util.ArgumentChecks;
@@ -826,7 +827,7 @@ public class DefaultMathTransformFactory
try {
transform = ((MathTransformProvider) method).createMathTransform(this, parameters);
} catch (IllegalArgumentException | IllegalStateException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
}
/*
* Cache the transform that we just created and make sure that the number of dimensions
@@ -897,7 +898,7 @@ public class DefaultMathTransformFactory
swap1 = (sourceCS != null) ? CoordinateSystems.swapAndScaleAxes(sourceCS, CoordinateSystems.replaceAxes(sourceCS, AxesConvention.NORMALIZED)) : null;
swap3 = (targetCS != null) ? CoordinateSystems.swapAndScaleAxes(CoordinateSystems.replaceAxes(targetCS, AxesConvention.NORMALIZED), targetCS) : null;
} catch (IllegalArgumentException | ConversionException cause) {
- throw new FactoryException(cause);
+ throw new InvalidGeodeticParameterException(cause.getLocalizedMessage(), cause);
}
/*
* Prepares the concatenation of the matrices computed above and the projection.
@@ -1059,7 +1060,7 @@ public class DefaultMathTransformFactory
try {
tr = ConcatenatedTransform.create(tr1, tr2, this);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
}
assert MathTransforms.isValid(MathTransforms.getSteps(tr)) : tr;
return unique(tr);
@@ -1099,7 +1100,7 @@ public class DefaultMathTransformFactory
try {
tr = PassThroughTransform.create(firstAffectedOrdinate, subTransform, numTrailingOrdinates);
} catch (IllegalArgumentException exception) {
- throw new FactoryException(exception);
+ throw new InvalidGeodeticParameterException(exception.getLocalizedMessage(), exception);
}
return unique(tr);
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -16,21 +16,46 @@
*/
package org.apache.sis.referencing.factory;
+import java.util.Map;
+import java.util.Collections;
+import javax.measure.unit.SI;
+import javax.measure.unit.Unit;
+import javax.measure.unit.NonSI;
+import javax.measure.quantity.Angle;
+import javax.measure.quantity.Length;
+import org.opengis.util.FactoryException;
+import org.opengis.referencing.IdentifiedObject;
import org.opengis.referencing.cs.CSFactory;
+import org.opengis.referencing.cs.CartesianCS;
+import org.opengis.referencing.cs.EllipsoidalCS;
+import org.opengis.referencing.cs.AxisDirection;
+import org.opengis.referencing.cs.CoordinateSystemAxis;
import org.opengis.referencing.crs.CRSFactory;
import org.opengis.referencing.crs.GeodeticCRS;
+import org.opengis.referencing.crs.GeographicCRS;
+import org.opengis.referencing.crs.ProjectedCRS;
import org.opengis.referencing.datum.DatumFactory;
+import org.opengis.referencing.datum.Ellipsoid;
+import org.opengis.referencing.datum.PrimeMeridian;
+import org.opengis.referencing.datum.GeodeticDatum;
import org.opengis.referencing.operation.CoordinateOperationFactory;
-import org.opengis.test.referencing.ObjectFactoryTest;
-import org.opengis.util.FactoryException;
+import org.opengis.referencing.operation.OperationMethod;
+import org.opengis.referencing.operation.Conversion;
+import org.opengis.parameter.ParameterValueGroup;
import org.apache.sis.internal.system.DefaultFactories;
+import org.apache.sis.referencing.operation.DefaultConversion;
+import org.apache.sis.referencing.CommonCRS;
+import org.apache.sis.io.wkt.Convention;
+
+// Test dependencies
+import org.opengis.test.referencing.ObjectFactoryTest;
import org.apache.sis.test.DependsOn;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.Ignore;
import org.junit.Test;
-import static org.junit.Assert.*;
+import static org.apache.sis.test.MetadataAssert.*;
/**
@@ -39,7 +64,7 @@ import static org.junit.Assert.*;
*
* @author Cédric Briançon (Geomatys)
* @since 0.6
- * @version 0.6
+ * @version 0.7
* @module
*/
@RunWith(JUnit4.class)
@@ -84,4 +109,116 @@ public final strictfp class GeodeticObje
assertEquals("name", "WGS 84", crs.getName().getCode());
assertEquals("datum", "World Geodetic System 1984", crs.getDatum().getName().getCode());
}
+
+ /**
+ * Convenience method creating a map with only the "{@code name"} property.
+ * This is the only mandatory property for object creation.
+ */
+ private static Map<String,?> name(final String name) {
+ return Collections.singletonMap(IdentifiedObject.NAME_KEY, name);
+ }
+
+ /**
+ * Tests step-by-step the creation of a new projected coordinate reference systems.
+ * This test creates every objects itself and compares with expected WKT 1 after each step.
+ *
+ * <p>Note that practical applications may use existing constants declared in the
+ * {@link CommonCRS} class instead than creating everything like this test does.</p>
+ *
+ * @throws FactoryException if the creation of a geodetic component failed.
+ *
+ * @since 0.7
+ */
+ @Test
+ public void testStepByStepCreation() throws FactoryException {
+ /*
+ * List of all objects to be created in this test.
+ */
+ final Unit<Length> linearUnit;
+ final Unit<Angle> angularUnit;
+ final Ellipsoid ellipsoid;
+ final PrimeMeridian meridian;
+ final GeodeticDatum datum;
+ final CoordinateSystemAxis longitude, latitude, easting, northing;
+ final EllipsoidalCS geographicCS;
+ final GeographicCRS geographicCRS;
+ final OperationMethod method;
+ final ParameterValueGroup parameters;
+ final Conversion projection;
+ final CartesianCS projectedCS;
+ final ProjectedCRS projectedCRS;
+ /*
+ * Prime meridian
+ */
+ angularUnit = NonSI.DEGREE_ANGLE;
+ meridian = datumFactory.createPrimeMeridian(name("Greenwich"), 0, angularUnit);
+ assertWktEquals(Convention.WKT1,
+ "PRIMEM[“Greenwich”, 0.0]", meridian);
+ /*
+ * Ellipsoid
+ */
+ linearUnit = SI.METRE;
+ ellipsoid = datumFactory.createEllipsoid(name("Airy1830"), 6377563.396, 6356256.910, linearUnit);
+ assertWktEquals(Convention.WKT1,
+ "SPHEROID[“Airy1830”, 6377563.396, 299.3249753150345]", ellipsoid);
+ /*
+ * Geodetic datum
+ */
+ datum = datumFactory.createGeodeticDatum(name("Airy1830"), ellipsoid, meridian);
+ assertWktEquals(Convention.WKT1,
+ "DATUM[“Airy1830”,\n" +
+ " SPHEROID[“Airy1830”, 6377563.396, 299.3249753150345]]", datum);
+ /*
+ * Base coordinate reference system
+ */
+ longitude = csFactory.createCoordinateSystemAxis(name("Longitude"), "long", AxisDirection.EAST, angularUnit);
+ latitude = csFactory.createCoordinateSystemAxis(name("Latitude"), "lat", AxisDirection.NORTH, angularUnit);
+ geographicCS = csFactory.createEllipsoidalCS(name("Ellipsoidal"), longitude, latitude);
+ geographicCRS = crsFactory.createGeographicCRS(name("Airy1830"), datum, geographicCS);
+ assertWktEquals(Convention.WKT1,
+ "GEOGCS[“Airy1830”,\n" +
+ " DATUM[“Airy1830”,\n" +
+ " SPHEROID[“Airy1830”, 6377563.396, 299.3249753150345]],\n" +
+ " PRIMEM[“Greenwich”, 0.0],\n" +
+ " UNIT[“degree”, 0.017453292519943295],\n" +
+ " AXIS[“Longitude”, EAST],\n" +
+ " AXIS[“Latitude”, NORTH]]", geographicCRS);
+ /*
+ * Defining conversion
+ */
+ method = copFactory.getOperationMethod("Transverse_Mercator");
+ parameters = method.getParameters().createValue();
+ parameters.parameter("semi_major") .setValue(ellipsoid.getSemiMajorAxis());
+ parameters.parameter("semi_minor") .setValue(ellipsoid.getSemiMinorAxis());
+ parameters.parameter("central_meridian") .setValue( 49);
+ parameters.parameter("latitude_of_origin").setValue( -2);
+ parameters.parameter("false_easting") .setValue( 400000);
+ parameters.parameter("false_northing") .setValue(-100000);
+ projection = new DefaultConversion(name("GBN grid"), method, null, parameters);
+ /*
+ * Projected coordinate reference system
+ */
+ easting = csFactory.createCoordinateSystemAxis(name("Easting"), "x", AxisDirection.EAST, linearUnit);
+ northing = csFactory.createCoordinateSystemAxis(name("Northing"), "y", AxisDirection.NORTH, linearUnit);
+ projectedCS = csFactory.createCartesianCS(name("Cartesian"), easting, northing);
+ projectedCRS = crsFactory.createProjectedCRS(name("Great_Britian_National_Grid"), geographicCRS, projection, projectedCS);
+ assertWktEquals(Convention.WKT1,
+ "PROJCS[“Great_Britian_National_Grid”,\n" +
+ " GEOGCS[“Airy1830”,\n" +
+ " DATUM[“Airy1830”,\n" +
+ " SPHEROID[“Airy1830”, 6377563.396, 299.3249753150345]],\n" +
+ " PRIMEM[“Greenwich”, 0.0],\n" +
+ " UNIT[“degree”, 0.017453292519943295],\n" +
+ " AXIS[“Longitude”, EAST],\n" +
+ " AXIS[“Latitude”, NORTH]],\n" +
+ " PROJECTION[“Transverse_Mercator”, AUTHORITY[“EPSG”, “9807”]],\n" +
+ " PARAMETER[“latitude_of_origin”, -2.0],\n" +
+ " PARAMETER[“central_meridian”, 49.0],\n" +
+ " PARAMETER[“scale_factor”, 1.0],\n" +
+ " PARAMETER[“false_easting”, 400000.0],\n" +
+ " PARAMETER[“false_northing”, -100000.0],\n" +
+ " UNIT[“metre”, 1],\n" +
+ " AXIS[“Easting”, EAST],\n" +
+ " AXIS[“Northing”, NORTH]]", projectedCRS);
+ }
}
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactoryTest.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -16,7 +16,10 @@
*/
package org.apache.sis.referencing.operation.transform;
+import java.util.Map;
import java.util.Set;
+import java.util.Collection;
+import java.util.Collections;
import org.opengis.util.FactoryException;
import org.opengis.util.NoSuchIdentifierException;
import org.opengis.referencing.operation.Conversion;
@@ -25,11 +28,21 @@ import org.opengis.referencing.operation
import org.opengis.referencing.operation.OperationMethod;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.MathTransformFactory;
+import org.opengis.parameter.ParameterValueGroup;
+import org.apache.sis.parameter.Parameterized;
+import org.apache.sis.referencing.CommonCRS;
+import org.apache.sis.referencing.operation.DefaultConversion;
import org.apache.sis.referencing.operation.matrix.Matrix2;
+import org.apache.sis.referencing.crs.DefaultProjectedCRS;
+import org.apache.sis.referencing.factory.InvalidGeodeticParameterException;
import org.apache.sis.internal.referencing.provider.Affine;
import org.apache.sis.internal.referencing.provider.Mercator1SP;
import org.apache.sis.internal.system.DefaultFactories;
import org.apache.sis.internal.util.Constants;
+import org.apache.sis.util.CharSequences;
+
+// Test dependencies
+import org.apache.sis.referencing.cs.HardCodedCS;
import org.apache.sis.test.DependsOnMethod;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
@@ -45,7 +58,7 @@ import static org.opengis.test.Assert.*;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.6
- * @version 0.6
+ * @version 0.7
* @module
*/
@DependsOn({
@@ -162,4 +175,68 @@ public final strictfp class DefaultMathT
1, 7,
0, 1), MathTransforms.getMatrix(tr), STRICT);
}
+
+ /**
+ * Tests the creation of all registered map projections.
+ * Only the semi-axis lengths are specified. For the rest, we rely on default values.
+ *
+ * @throws FactoryException if the construction of a map projection failed.
+ *
+ * @since 0.7
+ */
+ @Test
+ public void testAllMapProjections() throws FactoryException {
+ /*
+ * Gets all map projections and creates a projection using the WGS84 ellipsoid
+ * and default parameter values.
+ */
+ final Map<String,?> dummyName = Collections.singletonMap(DefaultProjectedCRS.NAME_KEY, "Test");
+ final MathTransformFactory mtFactory = DefaultFactories.forBuildin(MathTransformFactory.class);
+ final Collection<OperationMethod> methods = mtFactory.getAvailableMethods(Projection.class);
+ for (final OperationMethod method : methods) {
+ final String classification = method.getName().getCode();
+ ParameterValueGroup param = mtFactory.getDefaultParameters(classification);
+ param.parameter("semi_major").setValue(6377563.396);
+ param.parameter("semi_minor").setValue(6356256.909237285);
+ final MathTransform mt;
+ try {
+ mt = mtFactory.createParameterizedTransform(param);
+ } catch (InvalidGeodeticParameterException e) {
+ // Some map projections have mandatory parameters which we ignore for now
+ // except for a few well-known projection that we know should not fail.
+ if (classification.contains("Mercator")) {
+ throw e;
+ }
+ out.print(classification);
+ out.print(CharSequences.spaces(42 - classification.length()));
+ out.print(": ");
+ out.println(e.getLocalizedMessage());
+ continue;
+ }
+ /*
+ * Verifies that the map projection properties are the ones that we specified.
+ * Note that the Equirectangular projection has been optimized as an affine transform, which we skip.
+ */
+ if (mt instanceof LinearTransform) {
+ continue;
+ }
+ assertInstanceOf(classification, Parameterized.class, mt);
+ param = ((Parameterized) mt).getParameterValues();
+ assertEquals(classification, param.getDescriptor().getName().getCode());
+ assertEquals(classification, 6377563.396, param.parameter("semi_major").doubleValue(), 1E-4);
+ assertEquals(classification, 6356256.909237285, param.parameter("semi_minor").doubleValue(), 1E-4);
+ /*
+ * Creates a ProjectedCRS from the map projection. This part is more an integration test than
+ * a DefaultMathTransformFactory test. Again, the intend is to verify that the properties are
+ * the one that we specified.
+ */
+ final DefaultProjectedCRS crs = new DefaultProjectedCRS(dummyName,
+ CommonCRS.WGS84.normalizedGeographic(),
+ new DefaultConversion(dummyName, method, mt, null),
+ HardCodedCS.PROJECTED);
+ final Conversion projection = crs.getConversionFromBase();
+ assertSame(classification, mt, projection.getMathTransform());
+ assertEquals(classification, projection.getMethod().getName().getCode());
+ }
+ }
}
Modified: sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java?rev=1718968&r1=1718967&r2=1718968&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] Wed Dec 9 21:01:15 2015
@@ -38,6 +38,9 @@ import org.apache.sis.util.logging.Warni
import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.Version;
+// Branch-specific import
+import java.nio.file.NoSuchFileException;
+
/**
* The provider of {@link NetcdfStore} instances. Given a {@link StorageConnector} input,
@@ -162,7 +165,7 @@ public class NetcdfStoreProvider extends
if (cause instanceof DataStoreException) throw (DataStoreException) cause;
if (cause instanceof RuntimeException) throw (RuntimeException) cause;
if (cause instanceof Error) throw (Error) cause;
- if (cause instanceof FileNotFoundException) {
+ if (cause instanceof FileNotFoundException || cause instanceof NoSuchFileException) {
/*
* Happen if the String argument uses any protocol not recognized by the UCAR library,
* in which case UCAR tries to open it as a file even if it is not a file. For example