Author: desruisseaux
Date: Thu Jun 30 10:07:44 2016
New Revision: 1750764
URL: http://svn.apache.org/viewvc?rev=1750764&view=rev
Log:
Merge from JDK8 branch.
Added:
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java
- copied unchanged from r1750763, sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/geometry/Shapes2D.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/Shapes2DTest.java
- copied unchanged from r1750763, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/geometry/Shapes2DTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/TransformTestCase.java
- copied unchanged from r1750763, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/geometry/TransformTestCase.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java
- copied unchanged from r1750763, sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MathTransformWrapper.java
Modified:
sis/branches/JDK7/ (props changed)
sis/branches/JDK7/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CalcAddins.java
sis/branches/JDK7/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/ReferencingFunctions.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/DirectPosition2D.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ShapeUtilities.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java
sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/EnvelopesTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/XMLInputFactory.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
Propchange: sis/branches/JDK7/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun 30 10:07:44 2016
@@ -1,4 +1,4 @@
/sis/branches/Android:1430670-1480699
/sis/branches/JDK6:1394913-1508480
-/sis/branches/JDK8:1584960-1748692
+/sis/branches/JDK8:1584960-1750763
/sis/trunk:1394364-1508466,1519089-1519674
Modified: sis/branches/JDK7/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CalcAddins.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CalcAddins.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CalcAddins.java [UTF-8] (original)
+++ sis/branches/JDK7/application/sis-openoffice/src/main/java/org/apache/sis/openoffice/CalcAddins.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -16,7 +16,6 @@
*/
package org.apache.sis.openoffice;
-import java.util.Arrays;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.LogRecord;
@@ -185,24 +184,6 @@ public abstract class CalcAddins extends
}
/**
- * Returns a table filled with {@link Double#NaN} values.
- * This method is invoked when an operation failed for a whole table.
- *
- * @param rows the number of rows.
- * @param cols the number of columns.
- * @return A table of the given size filled with NaN values.
- */
- static double[][] getFailure(final int rows, final int cols) {
- final double[][] dummy = new double[rows][];
- for (int i=0; iThis class inherits {@linkplain #x x} and {@linkplain #y y} fields.
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -54,7 +54,7 @@ import java.util.Objects;
/**
- * A two-dimensional envelope on top of {@link Rectangle2D}.
+ * A two-dimensional envelope on top of Java2D rectangle.
* This implementation is provided for inter-operability between Java2D and GeoAPI.
*
* This class inherits {@linkplain #x x} and {@linkplain #y y} fields.
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -103,7 +103,7 @@ public final class Envelopes extends Sta
/**
* Returns {@code true} if the given axis is of kind "Wrap Around".
*/
- private static boolean isWrapAround(final CoordinateSystemAxis axis) {
+ static boolean isWrapAround(final CoordinateSystemAxis axis) {
return RangeMeaning.WRAPAROUND.equals(axis.getRangeMeaning());
}
@@ -111,8 +111,8 @@ public final class Envelopes extends Sta
* Invoked when a recoverable exception occurred. Those exceptions must be minor enough
* that they can be silently ignored in most cases.
*/
- private static void recoverableException(final TransformException exception) {
- Logging.recoverableException(Logging.getLogger(Loggers.GEOMETRY), Envelopes.class, "transform", exception);
+ static void recoverableException(final Class extends Static> caller, final TransformException exception) {
+ Logging.recoverableException(Logging.getLogger(Loggers.GEOMETRY), caller, "transform", exception);
}
/**
@@ -129,7 +129,7 @@ public final class Envelopes extends Sta
* @throws TransformException If the point can not be transformed
* or if a problem occurred while calculating the derivative.
*/
- private static Matrix derivativeAndTransform(final MathTransform transform, final double[] srcPts,
+ static Matrix derivativeAndTransform(final MathTransform transform, final double[] srcPts,
final double[] dstPts, final int dstOff, final boolean derivate) throws TransformException
{
if (transform instanceof AbstractMathTransform) {
@@ -296,7 +296,7 @@ public final class Envelopes extends Sta
}
isDerivativeSupported = false;
transform.transform(sourcePt, 0, ordinates, offset, 1);
- recoverableException(e); // Log only if the above call was successful.
+ recoverableException(Envelopes.class, e); // Log only if the above call was successful.
}
/*
* The transformed point has been saved for future reuse after the enclosing
@@ -554,7 +554,7 @@ public final class Envelopes extends Sta
* step. That ordinate is set to the minimal and maximal values of that axis.
*
* Example: If the above steps found that the point (90°S, 30°W) need to be included,
- * then this step #3 will also test phe points (90°S, 180°W) and (90°S, 180°E).
+ * then this step #3 will also test the points (90°S, 180°W) and (90°S, 180°E).
*
* NOTE: we test (-180°, centerY), (180°, centerY), (centerX, -90°) and (centerX, 90°)
* at step #1 before to test (-180°, -90°), (180°, -90°), (-180°, 90°) and (180°, 90°)
@@ -604,7 +604,7 @@ public final class Envelopes extends Sta
* lost dimensions. So we don't log any warning in this case.
*/
if (dimension >= mt.getSourceDimensions()) {
- recoverableException(exception);
+ recoverableException(Envelopes.class, exception);
}
return transformed;
}
@@ -720,7 +720,7 @@ public final class Envelopes extends Sta
}
}
if (warning != null) {
- recoverableException(warning);
+ recoverableException(Envelopes.class, warning);
}
return transformed;
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/geometry/package-info.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -45,6 +45,12 @@
*
*
*
+ *
Java2D dependency
+ * All classes having a name that ends with "2D" are designed for inter-operability with Java2D.
+ * All other classes have no dependency to Java2D.
+ * This clear separation aims to make easier to use Apache SIS on platforms that do not support Java2D
+ * (for example Android) or to avoid loading Java2D classes when only JavaFX is desired.
+ *
* Envelopes spanning the anti-meridian of a Geographic CRS
* The Web Coverage Service (WCS) 1.1 specification uses an extended interpretation
* of the bounding box definition. In a WCS 1.1 data structure, the
@@ -77,7 +83,7 @@
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.8
* @module
*/
package org.apache.sis.geometry;
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ShapeUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ShapeUtilities.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ShapeUtilities.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ShapeUtilities.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -63,9 +63,7 @@ public final class ShapeUtilities extend
* @param by2 y value of the last point on the second line.
* @return The intersection point, or {@code null} if none.
*
- * @todo This method is used by Geotk (a sandbox for code that may migrate to SIS), but not yet by SIS.
- * We temporarily keep this code here, but may delete or move it elsewhere in a future SIS version
- * depending whether we port to SIS the sandbox code.
+ * @see org.apache.sis.geometry.Shapes2D#intersectionPoint(Line2D, Line2D)
*/
public static Point2D.Double intersectionPoint(final double ax1, final double ay1, double ax2, double ay2,
final double bx1, final double by1, double bx2, double by2)
@@ -118,9 +116,7 @@ public final class ShapeUtilities extend
*
* @see #colinearPoint(double,double , double,double , double,double , double)
*
- * @todo This method is used by Geotk (a sandbox for code that may migrate to SIS), but not yet by SIS.
- * We temporarily keep this code here, but may delete or move it elsewhere in a future SIS version
- * depending whether we port to SIS the sandbox code.
+ * @see org.apache.sis.geometry.Shapes2D#nearestColinearPoint(Line2D, Point2D)
*/
public static Point2D.Double nearestColinearPoint(final double x1, final double y1,
final double x2, final double y2,
@@ -179,9 +175,7 @@ public final class ShapeUtilities extend
*
* @see #nearestColinearPoint(double,double , double,double , double,double)
*
- * @todo This method is used by Geotk (a sandbox for code that may migrate to SIS), but not yet by SIS.
- * We temporarily keep this code here, but may delete or move it elsewhere in a future SIS version
- * depending whether we port to SIS the sandbox code.
+ * @see org.apache.sis.geometry.Shapes2D#colinearPoint(Line2D, Point2D, double)
*/
public static Point2D.Double colinearPoint(double x1, double y1, double x2, double y2,
double x, double y, double distance)
@@ -323,10 +317,10 @@ public final class ShapeUtilities extend
x2 -= x1;
y2 -= y1;
if (horizontal) {
- final double a = (y2 - py*x2/px) / (x2-px); // Actually "a*x2"
+ final double a = (y2 - py*x2/px) / (x2-px); // Actually "a*x2"
final double check = abs(a);
- if (!(check <= 1/EPS)) return null; // Two points have the same coordinates.
- if (!(check >= EPS)) return null; // The three points are co-linear.
+ if (!(check <= 1/EPS)) return null; // Two points have the same coordinates.
+ if (!(check >= EPS)) return null; // The three points are co-linear.
final double b = y2/x2 - a;
px = (1 + b/(2*a))*x2 - y2/(2*a);
py = y1 + b*px;
@@ -339,18 +333,18 @@ public final class ShapeUtilities extend
final double rx2 = x2;
final double ry2 = y2;
x2 = hypot(x2,y2);
- y2 = (px*rx2 + py*ry2) / x2; // use 'y2' as a temporary variable for 'x1'
+ y2 = (px*rx2 + py*ry2) / x2; // use 'y2' as a temporary variable for 'x1'
py = (py*rx2 - px*ry2) / x2;
px = y2;
- y2 = 0; // set as a matter of principle (but not used).
+ y2 = 0; // set as a matter of principle (but not used).
/*
* Now compute the control point coordinates in our new coordinate system axis.
*/
- final double x = 0.5; // Actually "x/x2"
- final double y = (py*x*x2) / (px*(x2-px)); // Actually "y/y2"
+ final double x = 0.5; // Actually "x/x2"
+ final double y = (py*x*x2) / (px*(x2-px)); // Actually "y/y2"
final double check = abs(y);
- if (!(check <= 1/EPS)) return null; // Two points have the same coordinates.
- if (!(check >= EPS)) return null; // The three points are co-linear.
+ if (!(check <= 1/EPS)) return null; // Two points have the same coordinates.
+ if (!(check >= EPS)) return null; // The three points are co-linear.
/*
* Applies the inverse rotation then a translation to bring
* us back to the original coordinate system.
@@ -362,7 +356,7 @@ public final class ShapeUtilities extend
}
/**
- * Returns a circle passing by the 3 given points. The distance between the returned
+ * Returns the center of a circle passing by the 3 given points. The distance between the returned
* point and any of the given points will be constant; it is the circle radius.
*
* @param x1 x value of the first point.
@@ -371,11 +365,9 @@ public final class ShapeUtilities extend
* @param y2 y value of the second point.
* @param x3 x value of the third point.
* @param y3 y value of the third point.
- * @return A circle passing by the given points.
+ * @return The center of a circle passing by the given points.
*
- * @todo This method is used by Geotk (a sandbox for code that may migrate to SIS), but not yet by SIS.
- * We temporarily keep this code here, but may delete or move it elsewhere in a future SIS version
- * depending whether we port to SIS the sandbox code.
+ * @see org.apache.sis.geometry.Shapes2D#circle(Point2D, Point2D, Point2D)
*/
public static Point2D.Double circleCentre(double x1, double y1,
double x2, double y2,
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/AuthorityCodes.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -148,8 +148,8 @@ final class AuthorityCodes extends Abstr
for (int i=0; i candidate = table.subTypes[i];
if (candidate.isAssignableFrom(type)) {
- buffer.append(" WHERE (").append(table.typeColumn)
- .append(" LIKE '").append(table.typeNames[i]).append("%')");
+ buffer.append(" WHERE (CAST(").append(table.typeColumn).append(" AS ").append(TableInfo.ENUM_REPLACEMENT)
+ .append(") LIKE '").append(table.typeNames[i]).append("%')");
hasWhere = true;
tableType = candidate;
break;
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGDataAccess.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -3217,7 +3217,7 @@ next: while (r.next()) {
"SELECT COORD_REF_SYS_CODE" +
" FROM [Coordinate Reference System]" +
" WHERE PROJECTION_CONV_CODE = ?" +
- " AND COORD_REF_SYS_KIND LIKE 'projected%'", code))
+ " AND CAST(COORD_REF_SYS_KIND AS " + TableInfo.ENUM_REPLACEMENT + ") LIKE 'projected%'", code))
{
projection = result.next();
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -162,9 +162,9 @@ final class EPSGInstaller extends Script
prependNamespace(schema);
}
if (!isEnumTypeSupported) {
- addReplacement(SQLTranslator.TABLE_PREFIX + "datum_kind", "VARCHAR(24)");
- addReplacement(SQLTranslator.TABLE_PREFIX + "crs_kind", "VARCHAR(24)");
- addReplacement(SQLTranslator.TABLE_PREFIX + "cs_kind", "VARCHAR(24)");
+ addReplacement(SQLTranslator.TABLE_PREFIX + "datum_kind", TableInfo.ENUM_REPLACEMENT);
+ addReplacement(SQLTranslator.TABLE_PREFIX + "crs_kind", TableInfo.ENUM_REPLACEMENT);
+ addReplacement(SQLTranslator.TABLE_PREFIX + "cs_kind", TableInfo.ENUM_REPLACEMENT);
addReplacement(SQLTranslator.TABLE_PREFIX + "table_name", "VARCHAR(80)");
}
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/TableInfo.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -162,10 +162,17 @@ final class TableInfo {
/**
* Column type for the type (usually with the {@code "_TYPE"} suffix), or {@code null}.
+ * {@link EPSGDataAccess} and {@link AuthorityCodes} assumes that values in this column
+ * have the maximal length described in the {@value #ENUM_REPLACEMENT} statement.
*/
final String typeColumn;
/**
+ * The SQL type to use as a replacement for enumerated values on databases that do not support enumerations.
+ */
+ static final String ENUM_REPLACEMENT = "VARCHAR(24)";
+
+ /**
* Sub-interfaces of {@link #type} to handle, or {@code null} if none.
*/
final Class>[] subTypes;
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/Mercator.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -354,8 +354,10 @@ public class Mercator extends ConformalP
final double a = abs(φ);
if (a < PI/2) {
y = log(expOfNorthing(φ, eccentricity * sinφ)); // Snyder (7-7)
+ } else if (a <= (PI/2 + ANGULAR_TOLERANCE)) {
+ y = copySign(POSITIVE_INFINITY, φ);
} else {
- y = copySign(a <= (PI/2 + ANGULAR_TOLERANCE) ? POSITIVE_INFINITY : NaN, φ);
+ y = NaN;
}
}
dstPts[dstOff ] = srcPts[srcOff]; // Scale will be applied by the denormalization matrix.
@@ -395,8 +397,10 @@ public class Mercator extends ConformalP
final double y;
if (a < PI/2) {
y = log(expOfNorthing(φ, eccentricity * sin(φ)));
+ } else if (a <= (PI/2 + ANGULAR_TOLERANCE)) {
+ y = copySign(POSITIVE_INFINITY, φ);
} else {
- y = copySign(a <= (PI/2 + ANGULAR_TOLERANCE) ? POSITIVE_INFINITY : NaN, φ);
+ y = NaN;
}
dstPts[dstOff] = y;
}
@@ -484,8 +488,10 @@ public class Mercator extends ConformalP
final double a = abs(φ);
if (a < PI/2) {
y = log(tan(PI/4 + 0.5*φ)); // Part of Snyder (7-2)
+ } else if (a <= (PI/2 + ANGULAR_TOLERANCE)) {
+ y = copySign(POSITIVE_INFINITY, φ);
} else {
- y = copySign(a <= (PI/2 + ANGULAR_TOLERANCE) ? POSITIVE_INFINITY : NaN, φ);
+ y = NaN;
}
}
dstPts[dstOff ] = srcPts[srcOff];
@@ -518,8 +524,10 @@ public class Mercator extends ConformalP
final double y;
if (a < PI/2) {
y = log(tan(PI/4 + 0.5*φ)); // Part of Snyder (7-2)
+ } else if (a <= (PI/2 + ANGULAR_TOLERANCE)) {
+ y = copySign(POSITIVE_INFINITY, φ);
} else {
- y = copySign(a <= (PI/2 + ANGULAR_TOLERANCE) ? POSITIVE_INFINITY : NaN, φ);
+ y = NaN;
}
dstPts[dstOff] = y;
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ProjectionException.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -78,14 +78,4 @@ public class ProjectionException extends
ProjectionException(final short code) {
this(Errors.format(code));
}
-
- /**
- * Constructs a new exception with the specified detail message.
- *
- * @param code One of the constants suitable for {@link Errors#format(short)}.
- * @param value An argument value to be formatted.
- */
- ProjectionException(final short code, final Object value) {
- this(Errors.format(code, value));
- }
}
Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/TransverseMercator.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -59,7 +59,7 @@ import static org.apache.sis.internal.re
* @author Martin Desruisseaux (Geomatys)
* @author Rémi Maréchal (Geomatys)
* @since 0.6
- * @version 0.7
+ * @version 0.8
* @module
*
* @see Mercator
@@ -313,13 +313,34 @@ public class TransverseMercator extends
final double[] dstPts, final int dstOff,
final boolean derivate) throws ProjectionException
{
- final double λ = srcPts[srcOff ];
+ final double λ = srcPts[srcOff];
+ if (abs(λ) >= (0.9*PI/2)) {
+ /*
+ * The Transverse Mercator projection is conceptually a Mercator projection rotated by 90°.
+ * In Mercator projection, y values tend toward infinity for latitudes close to ±90°.
+ * In Transverse Mercator, x values tend toward infinity for longitudes close to ±90°
+ * at equator and after subtraction of central meridian. After we pass the 90° limit,
+ * the Transverse Mercator results at (90° + Δ) are the same as for (90° - Δ).
+ *
+ * Problem is that 90° is an ordinary longitude value, not even close to the limit of longitude
+ * values range (±180°). So having f(π/2+Δ, φ) = f(π/2-Δ, φ) results in wrong behavior in some
+ * algorithms like the one used by Envelopes.transform(CoordinateOperation, Envelope).
+ * Since a distance of 90° from central meridian is far outside the Transverse Mercator
+ * domain of validity anyway, we do not let the user go further.
+ *
+ * In the particular case of ellipsoidal formulas, we put a limit of 81° instead of 90°
+ * because experience shows that results close to equator become chaotic after 85° when
+ * using WGS84 ellipsoid. We do not need to reduce the limit for the spherical formulas,
+ * because the mathematic are simpler and the function still smooth until 90°.
+ */
+ throw new ProjectionException(Errors.Keys.OutsideDomainOfValidity);
+ }
final double φ = srcPts[srcOff+1];
final double sinλ = sin(λ);
final double ℯsinφ = sin(φ) * eccentricity;
final double Q = asinh(tan(φ)) - atanh(ℯsinφ) * eccentricity;
- final double coshQ = cosh(Q);
- final double η0 = atanh(sinλ / coshQ);
+ final double coshQ = cosh(Q); // Can not be smaller than 1.
+ final double η0 = atanh(sinλ / coshQ); // Tends toward ±∞ if λ → ±90°.
/*
* Original formula: η0 = atanh(sin(λ) * cos(β)) where
* cos(β) = cos(atan(sinh(Q)))
@@ -595,7 +616,11 @@ public class TransverseMercator extends
final double[] dstPts, final int dstOff,
final boolean derivate) throws ProjectionException
{
- final double λ = srcPts[srcOff ];
+ final double λ = srcPts[srcOff ];
+ if (abs(λ) > PI/2) {
+ // See comment in the overridden class.
+ throw new ProjectionException(Errors.Keys.OutsideDomainOfValidity);
+ }
final double φ = srcPts[srcOff+1];
final double sinλ = sin(λ);
final double cosλ = cos(λ);
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/EnvelopesTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/EnvelopesTest.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/EnvelopesTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/EnvelopesTest.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -16,34 +16,87 @@
*/
package org.apache.sis.geometry;
+import java.util.Collections;
import org.opengis.geometry.Envelope;
import org.opengis.util.FactoryException;
-import org.apache.sis.test.TestCase;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.CoordinateOperation;
+import org.opengis.referencing.operation.MathTransform2D;
+import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.referencing.crs.DefaultCompoundCRS;
+import org.apache.sis.referencing.crs.HardCodedCRS;
+import org.apache.sis.referencing.operation.transform.MathTransformWrapper;
import org.apache.sis.test.DependsOn;
import org.junit.Test;
-import static org.apache.sis.test.Assert.*;
+import static org.apache.sis.test.ReferencingAssert.*;
import static org.opengis.test.Validators.validate;
/**
* Tests the {@link Envelopes} class.
+ * This class inherits the test methods defined in {@link TransformTestCase}.
*
* @author Martin Desruisseaux (IRD, Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.8
* @module
*/
@DependsOn({
GeneralEnvelopeTest.class,
CurveExtremumTest.class
})
-public final strictfp class EnvelopesTest extends TestCase {
+public final strictfp class EnvelopesTest extends TransformTestCase {
+ /**
+ * Creates an envelope for the given CRS and coordinate values.
+ */
+ @Override
+ GeneralEnvelope createFromExtremums(CoordinateReferenceSystem crs, double xmin, double ymin, double xmax, double ymax) {
+ final GeneralEnvelope env = new GeneralEnvelope(crs);
+ env.setRange(0, xmin, xmax);
+ env.setRange(1, ymin, ymax);
+ return env;
+ }
- /*
- * Tests of the 'transform' methods are not yet ported because they need more MathTransform
- * implementations. Those tests will be ported in a future Apache SIS version.
+ /**
+ * Transforms an envelope using the given math transform.
+ * This transformation can not handle poles.
+ *
+ * This method wraps the math transform into an opaque object for hiding the fact that the given
+ * transform implement the {@link MathTransform2D} interface. The intend is to disable optimization
+ * paths (if any), in order to test the generic path.
*/
+ @Override
+ GeneralEnvelope transform(CoordinateReferenceSystem targetCRS, MathTransform2D transform, GeneralEnvelope envelope) throws TransformException {
+ final GeneralEnvelope env = Envelopes.transform(new MathTransformWrapper(transform), envelope);
+ env.setCoordinateReferenceSystem(targetCRS);
+ return env;
+ }
+
+ /**
+ * Transforms an envelope using the given operation.
+ * This transformation can handle poles.
+ */
+ @Override
+ GeneralEnvelope transform(CoordinateOperation operation, GeneralEnvelope envelope) throws TransformException {
+ return Envelopes.transform(operation, envelope);
+ }
+
+ /**
+ * Returns {@code true} if the outer envelope contains the inner one.
+ */
+ @Override
+ boolean contains(GeneralEnvelope outer, GeneralEnvelope inner) {
+ return outer.contains(inner);
+ }
+
+ /**
+ * Asserts that the given envelope is equals to the expected value.
+ */
+ @Override
+ void assertGeometryEquals(GeneralEnvelope expected, GeneralEnvelope actual, double tolx, double toly) {
+ assertEnvelopeEquals(expected, actual, tolx, toly);
+ }
/**
* Tests {@link Envelopes#fromWKT(CharSequence)}. This test is provided as a matter of principle,
@@ -83,4 +136,39 @@ public final strictfp class EnvelopesTes
envelope.setRange(1, 20, 25);
assertEquals("POLYGON((40 20, 40 25, 50 25, 50 20, 40 20))", Envelopes.toPolygonWKT(envelope));
}
+
+ /**
+ * Tests the transformation of an envelope from a 4D CRS to a 2D CRS
+ * where the ordinates in one dimension are NaN.
+ *
+ * @throws TransformException if an error occurred while transforming the envelope.
+ *
+ * @since 0.8
+ */
+ @Test
+ public void testTransform4to2D() throws TransformException {
+ final CoordinateReferenceSystem targetCRS = HardCodedCRS.WGS84;
+ final CoordinateReferenceSystem sourceCRS = new DefaultCompoundCRS(
+ Collections.singletonMap(DefaultCompoundCRS.NAME_KEY, "4D CRS"),
+ HardCodedCRS.WGS84,
+ HardCodedCRS.GRAVITY_RELATED_HEIGHT,
+ HardCodedCRS.TIME);
+
+ final GeneralEnvelope env = new GeneralEnvelope(sourceCRS);
+ env.setRange(0, -170, 170);
+ env.setRange(1, -80, 80);
+ env.setRange(2, -50, -50);
+ env.setRange(3, Double.NaN, Double.NaN);
+ assertFalse("isAllNaN", env.isAllNaN()); // Opportunist test (not really the topic of this method).
+ assertTrue ("isEmpty", env.isEmpty()); // Opportunist test (not really the topic of this method).
+ /*
+ * If the referencing framework has selected the CopyTransform implementation
+ * as expected, then the envelope ordinates should not be NaN.
+ */
+ final Envelope env2D = Envelopes.transform(env, targetCRS);
+ assertEquals(-170, env2D.getMinimum(0), 0);
+ assertEquals( 170, env2D.getMaximum(0), 0);
+ assertEquals( -80, env2D.getMinimum(1), 0);
+ assertEquals( 80, env2D.getMaximum(1), 0);
+ }
}
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/projection/TransverseMercatorTest.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -158,6 +158,10 @@ public final strictfp class TransverseMe
*/
final double[] source = CoordinateDomain.GEOGRAPHIC_RADIANS_HALF_λ.generateRandomInput(new Random(5346144739450824145L), 2, 10);
final double[] target = new double[source.length];
+ for (int i=0; iNote that this method does not open streams from files, paths or URLs.
+ * Creating input streams and closing them after usage are caller's responsibility.
+ *
+ * @param in where to read from.
+ * @return the reader, or {@code null} if the given file where not recognized.
+ * @throws XMLStreamException if the type of the given input is one recognized types,
+ * but despite that the reader can not be created.
+ *
+ * @since 0.8
+ */
+ public static XMLStreamReader createFromAny(final Object in) throws XMLStreamException {
+ if (in instanceof XMLStreamReader) return ((XMLStreamReader) in);
+ if (in instanceof XMLEventReader) return createXMLStreamReader((XMLEventReader) in);
+ if (in instanceof InputSource) return createXMLStreamReader((InputSource) in);
+ if (in instanceof InputStream) return createXMLStreamReader((InputStream) in);
+ if (in instanceof Reader) return createXMLStreamReader((Reader) in);
+ if (in instanceof Source) return createXMLStreamReader((Source) in);
+ if (in instanceof Node) return createXMLStreamReader((Node) in);
+ return null;
+ }
+
/*
* Do not provide convenience method for java.io.File, because the caller needs to close the created
* input stream himself (this is not done by XMLInputFactory.close(), despite its method name).
@@ -60,9 +85,9 @@ public final class XMLInputFactory exten
/**
* Creates a new reader for the given stream.
*
- * @param in Where to read from.
- * @return The reader.
- * @throws XMLStreamException If the reader can not be created.
+ * @param in where to read from.
+ * @return the reader.
+ * @throws XMLStreamException if the reader can not be created.
*/
public static XMLStreamReader createXMLStreamReader(final InputStream in) throws XMLStreamException {
return FACTORY.createXMLStreamReader(in);
@@ -71,9 +96,9 @@ public final class XMLInputFactory exten
/**
* Creates a new reader for the given stream.
*
- * @param in Where to read from.
- * @return The reader.
- * @throws XMLStreamException If the reader can not be created.
+ * @param in where to read from.
+ * @return the reader.
+ * @throws XMLStreamException if the reader can not be created.
*/
public static XMLStreamReader createXMLStreamReader(final Reader in) throws XMLStreamException {
return FACTORY.createXMLStreamReader(in);
@@ -82,9 +107,9 @@ public final class XMLInputFactory exten
/**
* Creates a new reader for the given source.
*
- * @param in Where to read from.
- * @return The reader.
- * @throws XMLStreamException If the reader can not be created.
+ * @param in where to read from.
+ * @return the reader.
+ * @throws XMLStreamException if the reader can not be created.
*/
public static XMLStreamReader createXMLStreamReader(final InputSource in) throws XMLStreamException {
return FACTORY.createXMLStreamReader(new SAXSource(in));
@@ -93,9 +118,9 @@ public final class XMLInputFactory exten
/**
* Creates a new reader for the given source.
*
- * @param in Where to read from.
- * @return The reader.
- * @throws XMLStreamException If the reader can not be created.
+ * @param in where to read from.
+ * @return the reader.
+ * @throws XMLStreamException if the reader can not be created.
*/
public static XMLStreamReader createXMLStreamReader(final XMLEventReader in) throws XMLStreamException {
return FACTORY.createXMLStreamReader(new StAXSource(in));
@@ -104,9 +129,9 @@ public final class XMLInputFactory exten
/**
* Creates a new reader for the given source.
*
- * @param in Where to read from.
- * @return The reader.
- * @throws XMLStreamException If the reader can not be created.
+ * @param in where to read from.
+ * @return the reader.
+ * @throws XMLStreamException if the reader can not be created.
*/
public static XMLStreamReader createXMLStreamReader(final Node in) throws XMLStreamException {
return FACTORY.createXMLStreamReader(new DOMSource(in));
@@ -115,9 +140,9 @@ public final class XMLInputFactory exten
/**
* Creates a new reader for the given source.
*
- * @param in Where to read from.
- * @return The reader.
- * @throws XMLStreamException If the reader can not be created.
+ * @param in where to read from.
+ * @return the reader.
+ * @throws XMLStreamException if the reader can not be created.
*/
public static XMLStreamReader createXMLStreamReader(final Source in) throws XMLStreamException {
return FACTORY.createXMLStreamReader(in);
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -201,6 +201,11 @@ public final class Errors extends Indexe
public static final short CloneNotSupported_1 = 13;
/**
+ * This {0} reader is closed.
+ */
+ public static final short ClosedReader_1 = 231;
+
+ /**
* Axis directions {0} and {1} are colinear.
*/
public static final short ColinearAxisDirections_2 = 14;
@@ -408,6 +413,11 @@ public final class Errors extends Indexe
public static final short IllegalIdentifierForCodespace_2 = 208;
/**
+ * The {0} reader does not accept inputs of type ‘{1}’.
+ */
+ public static final short IllegalInputTypeForReader_2 = 230;
+
+ /**
* The “{0}” language is not recognized.
*/
public static final short IllegalLanguageCode_1 = 36;
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors.properties [ISO-8859-1] Thu Jun 30 10:07:44 2016
@@ -51,6 +51,7 @@ CanNotUseGeodeticParameters_2 = Can
CircularReference = Circular reference.
ClassNotFinal_1 = Class \u2018{0}\u2019 is not final.
CloneNotSupported_1 = Can not clone an object of type \u2018{0}\u2019.
+ClosedReader_1 = This {0} reader is closed.
ColinearAxisDirections_2 = Axis directions {0} and {1} are colinear.
CoordinateOperationNotFound_2 = Coordinate conversion of transformation from system \u201c{0}\u201d to \u201c{1}\u201d has not been found.
DatabaseError_2 = Database error while creating a \u2018{0}\u2019 object for code \u201c{1}\u201d.
@@ -91,6 +92,7 @@ IllegalCoordinateSystem_1 = Coor
IllegalCRSType_1 = Coordinate reference system can not be of type \u2018{0}\u2019.
IllegalFormatPatternForClass_2 = The \u201c{1}\u201d pattern can not be applied to formating of objects of type \u2018{0}\u2019.
IllegalIdentifierForCodespace_2 = \u201c{1}\u201d is not a valid identifier for the \u201c{0}\u201d code space.
+IllegalInputTypeForReader_2 = The {0} reader does not accept inputs of type \u2018{1}\u2019.
IllegalLanguageCode_1 = The \u201c{0}\u201d language is not recognized.
IllegalMemberType_2 = Member \u201c{0}\u201d can not be associated to type \u201c{1}\u201d.
IllegalOperationDimension_3 = Dimensions of \u201c{0}\u201d operation can not be ({1} \u2192 {2}).
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Thu Jun 30 10:07:44 2016
@@ -48,6 +48,7 @@ CanNotUseGeodeticParameters_2 = Ne p
CircularReference = R\u00e9f\u00e9rence circulaire.
ClassNotFinal_1 = La classe \u2018{0}\u2019 n\u2019est pas finale.
CloneNotSupported_1 = Un objet de type \u2018{0}\u2019 ne peut pas \u00eatre clon\u00e9.
+ClosedReader_1 = Ce lecteur {0} est ferm\u00e9.
ColinearAxisDirections_2 = Les directions d\u2019axes {0} et {1} sont colin\u00e9aires.
CoordinateOperationNotFound_2 = La conversion ou transformation des coordonn\u00e9es du syst\u00e8me \u00ab\u202f{0}\u202f\u00bb vers \u00ab\u202f{1}\u202f\u00bb n\u2019a pas \u00e9t\u00e9 trouv\u00e9e.
DatabaseError_2 = Erreur de base de donn\u00e9es lors de la cr\u00e9ation d\u2019un objet \u2018{0}\u2019 pour le code \u00ab\u202f{1}\u202f\u00bb.
@@ -88,6 +89,7 @@ IllegalCoordinateSystem_1 = Le s
IllegalCRSType_1 = Le syst\u00e8me de r\u00e9f\u00e9rence des coordonn\u00e9es ne peut pas \u00eatre de type \u2018{0}\u2019.
IllegalFormatPatternForClass_2 = Le mod\u00e8le \u00ab\u202f{1}\u202f\u00bb ne peut pas \u00eatre appliqu\u00e9 au formatage d\u2019objets de type \u2018{0}\u2019.
IllegalIdentifierForCodespace_2 = \u00ab\u202f{1}\u202f\u00bb n\u2019est pas un identifiant valide pour l\u2019espace de codes \u00ab\u202f{0}\u202f\u00bb.
+IllegalInputTypeForReader_2 = Le lecteur {0} n\u2019accepte pas des entr\u00e9s de type \u2018{1}\u2019.
IllegalLanguageCode_1 = Le code de langue \u00ab\u202f{0}\u202f\u00bb n\u2019est pas reconnu.
IllegalMemberType_2 = Le membre \u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre associ\u00e9 au type \u00ab\u202f{1}\u202f\u00bb.
IllegalOperationDimension_3 = Les dimensions de l\u2019op\u00e9ration \u00ab\u202f{0}\u202f\u00bb ne peuvent pas \u00eatre ({1} \u2192 {2}).
Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -22,6 +22,7 @@ import java.util.TimeZone;
import java.util.logging.LogRecord; // For javadoc
import java.net.URL;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.StringReader;
@@ -33,6 +34,7 @@ import javax.xml.transform.Source;
import javax.xml.transform.Result;
import org.apache.sis.util.Static;
import org.apache.sis.util.Version;
+import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.logging.WarningListener;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.system.SystemListener;
@@ -40,6 +42,11 @@ import org.apache.sis.internal.jaxb.Type
import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
+// Branch-dependent imports
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+
/**
* Provides convenience methods for marshalling and unmarshalling SIS objects.
@@ -63,7 +70,7 @@ import static org.apache.sis.util.Argume
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.4
+ * @version 0.8
* @module
*/
public final class XML extends Static {
@@ -353,7 +360,7 @@ public final class XML extends Static {
*
* @param object The root of content tree to be marshalled.
* @return The XML representation of the given object.
- * @throws JAXBException If an error occurred during the marshalling.
+ * @throws JAXBException if an error occurred during the marshalling.
*/
public static String marshal(final Object object) throws JAXBException {
ensureNonNull("object", object);
@@ -370,7 +377,7 @@ public final class XML extends Static {
*
* @param object The root of content tree to be marshalled.
* @param output The stream where to write.
- * @throws JAXBException If an error occurred during the marshalling.
+ * @throws JAXBException if an error occurred during the marshalling.
*/
public static void marshal(final Object object, final OutputStream output) throws JAXBException {
ensureNonNull("object", object);
@@ -386,7 +393,7 @@ public final class XML extends Static {
*
* @param object The root of content tree to be marshalled.
* @param output The file to be written.
- * @throws JAXBException If an error occurred during the marshalling.
+ * @throws JAXBException if an error occurred during the marshalling.
*/
public static void marshal(final Object object, final File output) throws JAXBException {
ensureNonNull("object", object);
@@ -398,6 +405,26 @@ public final class XML extends Static {
}
/**
+ * Marshall the given object into a path.
+ *
+ * @param object The root of content tree to be marshalled.
+ * @param output The file to be written.
+ * @throws JAXBException if an error occurred during the marshalling.
+ */
+ public static void marshal(final Object object, final Path output) throws JAXBException {
+ ensureNonNull("object", object);
+ ensureNonNull("output", output);
+ try (OutputStream out = Files.newOutputStream(output, StandardOpenOption.CREATE, StandardOpenOption.WRITE)) {
+ final MarshallerPool pool = getPool();
+ final Marshaller marshaller = pool.acquireMarshaller();
+ marshaller.marshal(object, out);
+ pool.recycle(marshaller);
+ } catch (IOException e) {
+ throw new JAXBException(Errors.format(Errors.Keys.CanNotOpen_1, output), e);
+ }
+ }
+
+ /**
* Marshall the given object to a stream, DOM or other destinations.
* This is the most flexible marshalling method provided in this {@code XML} class.
* The destination is specified by the {@code output} argument implementation, for example
@@ -409,7 +436,7 @@ public final class XML extends Static {
* @param object The root of content tree to be marshalled.
* @param output The file to be written.
* @param properties An optional map of properties to give to the marshaller, or {@code null} if none.
- * @throws JAXBException If a property has an illegal value, or if an error occurred during the marshalling.
+ * @throws JAXBException if a property has an illegal value, or if an error occurred during the marshalling.
*
* @since 0.4
*/
@@ -434,7 +461,7 @@ public final class XML extends Static {
*
* @param xml The XML representation of an object.
* @return The object unmarshalled from the given input.
- * @throws JAXBException If an error occurred during the unmarshalling.
+ * @throws JAXBException if an error occurred during the unmarshalling.
*/
public static Object unmarshal(final String xml) throws JAXBException {
ensureNonNull("input", xml);
@@ -451,7 +478,7 @@ public final class XML extends Static {
*
* @param input The stream from which to read a XML representation.
* @return The object unmarshalled from the given input.
- * @throws JAXBException If an error occurred during the unmarshalling.
+ * @throws JAXBException if an error occurred during the unmarshalling.
*/
public static Object unmarshal(final InputStream input) throws JAXBException {
ensureNonNull("input", input);
@@ -467,7 +494,7 @@ public final class XML extends Static {
*
* @param input The URL from which to read a XML representation.
* @return The object unmarshalled from the given input.
- * @throws JAXBException If an error occurred during the unmarshalling.
+ * @throws JAXBException if an error occurred during the unmarshalling.
*/
public static Object unmarshal(final URL input) throws JAXBException {
ensureNonNull("input", input);
@@ -483,7 +510,7 @@ public final class XML extends Static {
*
* @param input The file from which to read a XML representation.
* @return The object unmarshalled from the given input.
- * @throws JAXBException If an error occurred during the unmarshalling.
+ * @throws JAXBException if an error occurred during the unmarshalling.
*/
public static Object unmarshal(final File input) throws JAXBException {
ensureNonNull("input", input);
@@ -495,6 +522,27 @@ public final class XML extends Static {
}
/**
+ * Unmarshall an object from the given path.
+ *
+ * @param input The path from which to read a XML representation.
+ * @return The object unmarshalled from the given input.
+ * @throws JAXBException if an error occurred during the unmarshalling.
+ */
+ public static Object unmarshal(final Path input) throws JAXBException {
+ ensureNonNull("input", input);
+ final Object object;
+ try (InputStream in = Files.newInputStream(input, StandardOpenOption.READ)) {
+ final MarshallerPool pool = getPool();
+ final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
+ object = unmarshaller.unmarshal(in);
+ pool.recycle(unmarshaller);
+ } catch (IOException e) {
+ throw new JAXBException(Errors.format(Errors.Keys.CanNotRead_1, input), e);
+ }
+ return object;
+ }
+
+ /**
* Unmarshall an object from the given stream, DOM or other sources.
* This is the most flexible unmarshalling method provided in this {@code XML} class.
* The source is specified by the {@code input} argument implementation, for example
@@ -506,7 +554,7 @@ public final class XML extends Static {
* @param input The file from which to read a XML representation.
* @param properties An optional map of properties to give to the unmarshaller, or {@code null} if none.
* @return The object unmarshalled from the given input.
- * @throws JAXBException If a property has an illegal value, or if an error occurred during the unmarshalling.
+ * @throws JAXBException if a property has an illegal value, or if an error occurred during the unmarshalling.
*
* @since 0.4
*/
Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/MetadataReader.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -188,8 +188,8 @@ final class MetadataReader {
/**
* Invoked when a non-fatal exception occurred while reading metadata.
- * This method will send a record to the registered listeners if any,
- * or will log the record otherwise.
+ * This method sends a record to the registered listeners if any,
+ * or logs the record otherwise.
*/
private void warning(final Exception e) {
decoder.listeners.warning(null, e);
Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -19,7 +19,9 @@ package org.apache.sis.storage.netcdf;
import java.io.IOException;
import org.opengis.metadata.Metadata;
import org.apache.sis.util.Debug;
+import org.apache.sis.util.Classes;
import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.resources.Errors;
import org.apache.sis.storage.DataStore;
import org.apache.sis.storage.DataStoreException;
import org.apache.sis.storage.StorageConnector;
@@ -33,7 +35,7 @@ import org.apache.sis.metadata.Modifiabl
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.3
- * @version 0.3
+ * @version 0.8
* @module
*
* @see NetcdfStoreProvider
@@ -56,7 +58,7 @@ public class NetcdfStore extends DataSto
* needed resource.
*
* @param storage Information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile} instance, etc).
- * @throws DataStoreException If an error occurred while opening the NetCDF file.
+ * @throws DataStoreException if an error occurred while opening the NetCDF file.
*/
public NetcdfStore(final StorageConnector storage) throws DataStoreException {
ArgumentChecks.ensureNonNull("storage", storage);
@@ -65,6 +67,10 @@ public class NetcdfStore extends DataSto
} catch (IOException e) {
throw new DataStoreException(e);
}
+ if (decoder == null) {
+ throw new DataStoreException(Errors.format(Errors.Keys.IllegalInputTypeForReader_2,
+ "NetCDF", Classes.getClass(storage.getStorage())));
+ }
}
/**
@@ -73,7 +79,7 @@ public class NetcdfStore extends DataSto
* data quality, usage constraints and more.
*
* @return Information about the dataset.
- * @throws DataStoreException If an error occurred while reading the data.
+ * @throws DataStoreException if an error occurred while reading the data.
*/
@Override
public Metadata getMetadata() throws DataStoreException {
@@ -92,7 +98,7 @@ public class NetcdfStore extends DataSto
/**
* Closes this NetCDF store and releases any underlying resources.
*
- * @throws DataStoreException If an error occurred while closing the NetCDF file.
+ * @throws DataStoreException if an error occurred while closing the NetCDF file.
*/
@Override
public void close() throws DataStoreException {
Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStoreProvider.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -205,7 +205,7 @@ public class NetcdfStoreProvider extends
*
* @param storage Information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile} instance, etc).
* @return A data store implementation associated with this provider for the given storage.
- * @throws DataStoreException If an error occurred while creating the data store instance.
+ * @throws DataStoreException if an error occurred while creating the data store instance.
*/
@Override
public DataStore open(final StorageConnector storage) throws DataStoreException {
@@ -218,9 +218,9 @@ public class NetcdfStoreProvider extends
*
* @param listeners Where to send the warnings.
* @param storage Information about the input (file, input stream, etc.)
- * @return The decoder for the given input.
- * @throws IOException If an error occurred while opening the NetCDF file.
- * @throws DataStoreException If a logical error (other than I/O) occurred.
+ * @return The decoder for the given input, or {@code null} if the input type is not recognized.
+ * @throws IOException if an error occurred while opening the NetCDF file.
+ * @throws DataStoreException if a logical error (other than I/O) occurred.
*/
static Decoder decoder(final WarningListeners> listeners, final StorageConnector storage)
throws IOException, DataStoreException
@@ -257,9 +257,9 @@ public class NetcdfStoreProvider extends
* @param input The NetCDF file object of filename string from which to read data.
* @param isUCAR {@code true} if {@code input} is an instance of the UCAR {@link ucar.nc2.NetcdfFile} object,
* or {@code false} if it is the filename as a {@code String}.
- * @return The {@link DecoderWrapper} instance for the given input.
- * @throws IOException If an error occurred while opening the NetCDF file.
- * @throws DataStoreException If a logical error (other than I/O) occurred.
+ * @return The {@link DecoderWrapper} instance for the given input, or {@code null} if the input type is not recognized.
+ * @throws IOException if an error occurred while opening the NetCDF file.
+ * @throws DataStoreException if a logical error (other than I/O) occurred.
*/
private static Decoder createByReflection(final WarningListeners> listeners, final Object input, final boolean isUCAR)
throws IOException, DataStoreException
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/IOUtilities.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -442,7 +442,7 @@ public final class IOUtilities extends S
*/
final Set optionSet;
if (options == null || options.length == 0) {
- optionSet = Collections.emptySet();
+ optionSet = Collections.singleton(StandardOpenOption.READ);
} else {
optionSet = new HashSet<>(Arrays.asList(options));
optionSet.add(StandardOpenOption.READ);
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -144,7 +144,7 @@ final class Store extends DataStore {
private void unmarshal() throws DataStoreException {
final StreamSource s = source;
final Closeable in = input(s);
- source = null; // Cleared first in case of error.
+ source = null; // Cleared first in case of error.
if (in != null) try {
try {
object = XML.unmarshal(s, properties());
@@ -195,7 +195,7 @@ final class Store extends DataStore {
public void close() throws DataStoreException {
object = null;
final Closeable in = input(source);
- source = null; // Cleared first in case of failure.
+ source = null; // Cleared first in case of failure.
if (in != null) try {
in.close();
} catch (IOException e) {
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java?rev=1750764&r1=1750763&r2=1750764&view=diff
==============================================================================
--- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] (original)
+++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] Thu Jun 30 10:07:44 2016
@@ -90,7 +90,7 @@ public abstract class DataStore implemen
* or distributor, data quality, update frequency, usage constraints and more.
*
* @return Information about the dataset, or {@code null} if none.
- * @throws DataStoreException If an error occurred while reading the data.
+ * @throws DataStoreException if an error occurred while reading the data.
*/
public abstract Metadata getMetadata() throws DataStoreException;
@@ -118,7 +118,7 @@ public abstract class DataStore implemen
* }
*
* @param listener The listener to add.
- * @throws IllegalArgumentException If the given listener is already registered in this data store.
+ * @throws IllegalArgumentException if the given listener is already registered in this data store.
*/
public void addWarningListener(final WarningListener super DataStore> listener)
throws IllegalArgumentException
@@ -130,7 +130,7 @@ public abstract class DataStore implemen
* Removes a previously registered listener.
*
* @param listener The listener to remove.
- * @throws NoSuchElementException If the given listener is not registered in this data store.
+ * @throws NoSuchElementException if the given listener is not registered in this data store.
*/
public void removeWarningListener(final WarningListener super DataStore> listener)
throws NoSuchElementException
@@ -141,7 +141,7 @@ public abstract class DataStore implemen
/**
* Closes this data store and releases any underlying resources.
*
- * @throws DataStoreException If an error occurred while closing this data store.
+ * @throws DataStoreException if an error occurred while closing this data store.
*/
@Override
public abstract void close() throws DataStoreException;