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 2017/11/17 18:12:46 UTC
svn commit: r1815606 [2/3] - in /sis/trunk: ./ application/
application/sis-console/src/main/artifact/
application/sis-console/src/main/java/org/apache/sis/console/
application/sis-openoffice/
application/sis-openoffice/src/main/java/org/apache/sis/ope...
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGFactory.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -45,6 +45,7 @@ import org.apache.sis.internal.system.De
import org.apache.sis.internal.util.Constants;
import org.apache.sis.referencing.factory.ConcurrentAuthorityFactory;
import org.apache.sis.referencing.factory.UnavailableFactoryException;
+import org.apache.sis.util.resources.Messages;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.Classes;
@@ -270,7 +271,7 @@ public class EPSGFactory extends Concurr
throw new UnavailableFactoryException(Initializer.unspecified(locale));
}
} catch (Exception e) {
- throw new UnavailableFactoryException(message(e), e);
+ throw new UnavailableFactoryException(canNotUse(e), e);
}
dataSource = ds;
nameFactory = factory(NameFactory.class, "nameFactory", properties);
@@ -293,12 +294,19 @@ public class EPSGFactory extends Concurr
/**
* Returns the message to put in an {@link UnavailableFactoryException} having the given exception as its cause.
*/
- private String message(final Exception e) {
+ private String canNotUse(final Exception e) {
String message = Exceptions.getLocalizedMessage(e, locale);
if (message == null) {
message = Classes.getShortClassName(e);
}
- return Resources.forLocale(locale).getString(Resources.Keys.CanNotUseGeodeticParameters_2, Constants.EPSG, message);
+ return canNotUse(message);
+ }
+
+ /**
+ * Returns the message to put in an {@link UnavailableFactoryException} having the given cause.
+ */
+ private String canNotUse(final String cause) {
+ return Resources.forLocale(locale).getString(Resources.Keys.CanNotUseGeodeticParameters_2, Constants.EPSG, cause);
}
/**
@@ -367,15 +375,18 @@ public class EPSGFactory extends Concurr
* See <a href="https://issues.apache.org/jira/browse/LEGAL-183">LEGAL-183</a> for more information.</p>
*
* @param connection connection to the database where to create the EPSG schema.
- * @throws FileNotFoundException if a SQL script has not been found,
- * typically because a required resource is not on the classpath.
- * @throws IOException if an I/O error occurred while reading a SQL script.
- * @throws SQLException if an error occurred while writing to the database.
+ * @throws UnavailableFactoryException if installation failed. The exception will have a
+ * {@link FileNotFoundException} cause if a SQL script has not been found
+ * (typically because a required resource is not on the classpath), an
+ * {@link IOException} if an I/O error occurred while reading a SQL script, or a
+ * {@link SQLException} if an error occurred while writing to the database.
*
* @see InstallationScriptProvider
*/
- public synchronized void install(final Connection connection) throws IOException, SQLException {
+ public synchronized void install(final Connection connection) throws UnavailableFactoryException {
ArgumentChecks.ensureNonNull("connection", connection);
+ String message = null;
+ Exception failure = null;
try (EPSGInstaller installer = new EPSGInstaller(connection)) {
final boolean ac = connection.getAutoCommit();
if (ac) {
@@ -403,9 +414,21 @@ public class EPSGFactory extends Concurr
}
}
} catch (IOException | SQLException e) {
- installer.logFailure(locale, e);
- throw e;
+ message = installer.failure(locale, e);
+ failure = e;
}
+ } catch (SQLException e) {
+ message = Messages.getResources(locale).getString(Messages.Keys.CanNotCreateSchema_1, Constants.EPSG);
+ failure = e;
+ }
+ if (failure != null) {
+ /*
+ * Derby sometime wraps SQLException into another SQLException. For making the stack strace a
+ * little bit simpler, keep only the root cause provided that the exception type is compatible.
+ */
+ UnavailableFactoryException exception = new UnavailableFactoryException(message, Exceptions.unwrap(failure));
+ exception.setUnavailableFactory(this);
+ throw exception;
}
}
@@ -455,7 +478,7 @@ public class EPSGFactory extends Concurr
return newDataAccess(connection, tr);
} else {
connection.close();
- exception = new UnavailableFactoryException(SQLTranslator.tableNotFound(locale));
+ exception = new UnavailableFactoryException(canNotUse(SQLTranslator.tableNotFound(locale)));
}
} catch (Exception e) { // Really want to catch all exceptions here.
if (connection != null) try {
@@ -463,11 +486,14 @@ public class EPSGFactory extends Concurr
} catch (SQLException e2) {
e.addSuppressed(e2);
}
+ if (e instanceof FactoryException) {
+ throw (FactoryException) e;
+ }
/*
* Derby sometime wraps SQLException into another SQLException. For making the stack strace a
* little bit simpler, keep only the root cause provided that the exception type is compatible.
*/
- exception = new UnavailableFactoryException(message(e), Exceptions.unwrap(e));
+ exception = new UnavailableFactoryException(canNotUse(e), Exceptions.unwrap(e));
}
exception.setUnavailableFactory(this);
throw exception;
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/factory/sql/EPSGInstaller.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -25,7 +25,6 @@ import java.sql.SQLException;
import java.util.StringTokenizer;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
-import java.util.logging.LogRecord;
import java.io.BufferedReader;
import org.apache.sis.util.StringBuilders;
import org.apache.sis.internal.metadata.sql.ScriptRunner;
@@ -280,18 +279,16 @@ final class EPSGInstaller extends Script
}
/**
- * Logs a message reporting the failure to create EPSG database. This method is invoked when {@link EPSGFactory}
- * caught an exception. This log completes rather than replaces the exception message since {@code EPSGFactory}
- * lets the exception propagate. Another code (for example {@link org.apache.sis.referencing.CRS#forCode(String)})
- * may catch that exception and log another record with the exception message.
+ * Creates a message reporting the failure to create EPSG database. This method is invoked when {@link EPSGFactory}
+ * caught an exception. This method completes the exception message with the file name and line number where the
+ * error occurred, if such information is available.
*/
- final void logFailure(final Locale locale, final Exception cause) {
+ final String failure(final Locale locale, final Exception cause) {
String message = Messages.getResources(locale).getString(Messages.Keys.CanNotCreateSchema_1, EPSG);
String status = status(locale);
if (status != null) {
message = message + ' ' + status;
}
- message = Exceptions.formatChainedMessages(locale, message, cause);
- InstallationScriptProvider.log(new LogRecord(Level.WARNING, message));
+ return Exceptions.formatChainedMessages(locale, message, cause);
}
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -53,6 +53,7 @@ import org.apache.sis.util.collection.Co
import org.apache.sis.util.UnsupportedImplementationException;
import org.apache.sis.util.logging.Logging;
import org.apache.sis.parameter.Parameterized;
+import org.apache.sis.metadata.iso.citation.Citations;
import org.apache.sis.referencing.cs.CoordinateSystems;
import org.apache.sis.referencing.AbstractIdentifiedObject;
import org.apache.sis.referencing.operation.transform.MathTransforms;
@@ -64,6 +65,7 @@ import org.apache.sis.internal.referenci
import org.apache.sis.internal.referencing.WKTUtilities;
import org.apache.sis.internal.metadata.WKTKeywords;
import org.apache.sis.internal.metadata.MetadataUtilities;
+import org.apache.sis.internal.util.Constants;
import org.apache.sis.internal.util.CollectionsExt;
import org.apache.sis.internal.util.UnmodifiableArrayList;
import org.apache.sis.internal.system.Semaphores;
@@ -963,10 +965,27 @@ check: for (int isTarget=0; ; isTar
parameters = null;
}
if (parameters != null) {
+ /*
+ * Format the parameter values. Apache SIS uses the EPSG geodetic dataset as the main source of
+ * parameter definitions. When a parameter is defined by both OGC and EPSG with different names,
+ * the Formatter class is responsible for choosing an appropriate name. But when the difference
+ * is more fundamental, we may have duplication. For example in the "Molodensky" operation, OGC
+ * uses source and target axis lengths while EPSG uses only difference between those lengths.
+ * In this case, OGC and EPSG parameters are defined separately and are redundant. To simplify
+ * the CoordinateOperation WKT, we omit non-EPSG parameters when we have determined that we are
+ * about to describe an EPSG operation. We could generalize this filtering to any authority, but
+ * we don't because few authorities are as complete as EPSG, so other authorities are more likely
+ * to mix EPSG or someone else components with their own. Note also that we don't apply filtering
+ * on MathTransform WKT neither for more reliable debugging.
+ */
+ final boolean filter = WKTUtilities.isEPSG(parameters.getDescriptor(), false) && // NOT method.getName()
+ Constants.EPSG.equalsIgnoreCase(Citations.getCodeSpace(formatter.getNameAuthority()));
formatter.newLine();
formatter.indent(+1);
for (final GeneralParameterValue param : parameters.values()) {
- WKTUtilities.append(param, formatter);
+ if (!filter || WKTUtilities.isEPSG(param.getDescriptor(), true)) {
+ WKTUtilities.append(param, formatter);
+ }
}
formatter.indent(-1);
}
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilder.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -113,7 +113,7 @@ public class LinearTransformBuilder exte
private int numPoints;
/**
- * The transform created by the last call to {@link #create()}.
+ * The transform created by the last call to {@link #create(MathTransformFactory)}.
* This is reset to {@code null} when coordinates are modified.
*/
private transient LinearTransform transform;
@@ -376,8 +376,6 @@ search: for (int j=0; j<numPoints; j++)
throws MismatchedDimensionException
{
ArgumentChecks.ensureNonNull("sourceToTarget", sourceToTarget);
- pendingSources = null;
- pendingTargets = null;
transform = null;
correlation = null;
sources = null;
@@ -516,7 +514,6 @@ search: for (int j=0; j<numPoints; j++)
* @since 0.8
*/
public double[] getControlPoint(final int[] source) {
- processPendings();
ArgumentChecks.ensureNonNull("source", source);
verifySourceDimension(source.length);
if (targets == null) {
@@ -554,97 +551,6 @@ search: for (int j=0; j<numPoints; j++)
}
/**
- * Sets the source points, overwriting any previous setting. The number of source points will need to be the same
- * than the number of {@linkplain #setTargetPoints target points} when the {@link #create()} method will be invoked.
- * In current Apache SIS implementation, the source points must be one or two-dimensional.
- *
- * <p>If this builder has been created with the {@link #LinearTransformBuilder(int...)} constructor,
- * then all given points must be two-dimensional and all ordinate values must be integers in the
- * [0 … <var>width</var>-1] or [0 … <var>height</var>-1] range for the first and second dimension
- * respectively. This constraint does not apply if this builder has been created with the
- * {@link #LinearTransformBuilder()} constructor.</p>
- *
- * <p>It is caller's responsibility to ensure that no source point is duplicated.
- * If the same source point is repeated twice, then {@code LinearTransformBuilder} behavior is undefined.</p>
- *
- * @param points the source points, assumed precise.
- * @throws MismatchedDimensionException if at least one point does not have the expected number of dimensions.
- *
- * @deprecated Replaced by {@link #setControlPoints(Map)}.
- */
- @Deprecated
- public void setSourcePoints(final DirectPosition... points) throws MismatchedDimensionException {
- ArgumentChecks.ensureNonNull("points", points);
- transform = null;
- correlation = null;
- sources = null;
- targets = null;
- numPoints = 0;
- pendingSources = points.clone();
- }
-
- /**
- * Sets the target points, overwriting any previous setting. The number of target points will need to be the same
- * than the number of {@linkplain #setSourcePoints source points} when the {@link #create()} method will be invoked.
- * Target points can have any number of dimensions (not necessarily 2), but all points shall have
- * the same number of dimensions.
- *
- * @param points the target points, assumed uncertain.
- * @throws MismatchedDimensionException if not all points have the same number of dimensions.
- *
- * @deprecated Replaced by {@link #setControlPoints(Map)}.
- */
- @Deprecated
- public void setTargetPoints(final DirectPosition... points) throws MismatchedDimensionException {
- ArgumentChecks.ensureNonNull("points", points);
- transform = null;
- correlation = null;
- sources = null;
- targets = null;
- numPoints = 0;
- pendingTargets = points.clone();
- }
-
- @Deprecated
- private transient DirectPosition[] pendingSources, pendingTargets;
-
- @Deprecated
- private void processPendings() {
- if (pendingSources != null || pendingTargets != null) {
- if (pendingSources == null || pendingTargets == null) {
- throw new IllegalStateException(Errors.format(
- Errors.Keys.MissingValueForProperty_1, (pendingSources == null) ? "sources" : "targets"));
- }
- final int length = pendingSources.length;
- if (pendingTargets.length != length) {
- throw new IllegalStateException(Errors.format(Errors.Keys.MismatchedArrayLengths));
- }
- final Map<DirectPosition,DirectPosition> sourceToTarget = new java.util.HashMap<>(length);
- for (int i=0; i<length; i++) {
- sourceToTarget.put(pendingSources[i], pendingTargets[i]);
- }
- setControlPoints(sourceToTarget);
- }
- }
-
- /**
- * Creates a linear transform approximation from the source positions to the target positions.
- * This method assumes that source positions are precise and that all uncertainty is in the target positions.
- *
- * @return the fitted linear transform.
- *
- * @deprecated Replaced by {@link #create(MathTransformFactory)}.
- */
- @Deprecated
- public LinearTransform create() {
- try {
- return create(null);
- } catch (FactoryException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
* Creates a linear transform approximation from the source positions to the target positions.
* This method assumes that source positions are precise and that all uncertainty is in the target positions.
*
@@ -661,7 +567,6 @@ search: for (int j=0; j<numPoints; j++)
@SuppressWarnings("serial")
public LinearTransform create(final MathTransformFactory factory) throws FactoryException {
if (transform == null) {
- processPendings();
final double[][] sources = this.sources; // Protect from changes.
final double[][] targets = this.targets;
if (targets == null) {
@@ -734,7 +639,7 @@ search: for (int j=0; j<numPoints; j++)
}
/**
- * Returns the correlation coefficients of the last transform created by {@link #create()},
+ * Returns the correlation coefficients of the last transform created by {@link #create create(…)},
* or {@code null} if none. If non-null, the array length is equals to the number of target
* dimensions.
*
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/CoordinateSystemTransform.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -157,9 +157,9 @@ abstract class CoordinateSystemTransform
}
/**
- * Implementation of {@link DefaultMathTransformFactory#createCoordinateSystemChange(CoordinateSystem, CoordinateSystem)},
- * defined here for reducing the {@code DefaultMathTransformFactory} weight in the common case where the conversions
- * handled by this class are not needed.
+ * Implementation of {@link DefaultMathTransformFactory#createCoordinateSystemChange(CoordinateSystem,
+ * CoordinateSystem, Ellipsoid)}, defined here for reducing the {@code DefaultMathTransformFactory}
+ * weight in the common case where the conversions handled by this class are not needed.
*/
static MathTransform create(final MathTransformFactory factory, final CoordinateSystem source,
final CoordinateSystem target) throws FactoryException
Modified: sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/DefaultMathTransformFactory.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -1206,25 +1206,6 @@ public class DefaultMathTransformFactory
}
/**
- * Creates a math transform that represent a change of coordinate system.
- *
- * @param source the source coordinate system.
- * @param target the target coordinate system.
- * @return a conversion from the given source to the given target coordinate system.
- * @throws FactoryException if the conversion can not be created.
- *
- * @deprecated Replaced by {@link #createCoordinateSystemChange(CoordinateSystem, CoordinateSystem, Ellipsoid)}
- *
- * @since 0.7
- */
- @Deprecated
- public MathTransform createCoordinateSystemChange(final CoordinateSystem source, final CoordinateSystem target)
- throws FactoryException
- {
- return createCoordinateSystemChange(source, target, null);
- }
-
- /**
* Creates a math transform that represent a change of coordinate system. If exactly one argument is
* an {@linkplain org.apache.sis.referencing.cs.DefaultEllipsoidalCS ellipsoidal coordinate systems},
* then the {@code ellipsoid} argument is mandatory. In all other cases (including the case where both
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultConcatenatedOperationTest.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -43,7 +43,7 @@ import static org.apache.sis.test.TestUt
* Tests the {@link DefaultConcatenatedOperation} class.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 0.8
* @since 0.7
* @module
*/
@@ -114,9 +114,7 @@ public final strictfp class DefaultConca
" Axis[“Latitude (B)”, north, Unit[“degree”, 0.017453292519943295]],\n" +
" Axis[“Ellipsoidal height (h)”, up, Unit[“metre”, 1]]]],\n" +
" CoordinateOperationStep[“Geographic to geocentric”,\n" +
- " Method[“Geographic/geocentric conversions”],\n" +
- " Parameter[“semi_major”, 6377397.155, Unit[“metre”, 1]],\n" +
- " Parameter[“semi_minor”, 6356078.962818189, Unit[“metre”, 1]]],\n" +
+ " Method[“Geographic/geocentric conversions”]],\n" + // Omit non-EPSG parameters for EPSG method.
" CoordinateOperationStep[“Tokyo to JGD2000 (GSI)”,\n" +
" Method[“Geocentric translations”],\n" +
" Parameter[“X-axis translation”, -146.414],\n" +
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultCoordinateOperationFactoryTest.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -169,16 +169,18 @@ public final strictfp class DefaultCoord
assertSame ("targetCRS", targetCRS, operation.getTargetCRS());
assertInstanceOf("operation", ConcatenatedOperation.class, operation);
/*
- * The accuracy of the coordinate operation depends on whether a path as been found with the help
+ * The accuracy of the coordinate operation depends on whether a path has been found with the help
* of the EPSG database (in which case the reported accuracy is 2 metres) or if we had to find an
- * operation by ourselves (in which case we conservatively report an accuracy of 3000 metres, bu
- * in practice observe an error of about 80 metres for this test).
+ * operation by ourselves (in which case we conservatively report an accuracy of 3000 metres, but
+ * in practice observe an error between 80 and 515 metres for this test depending on the operation
+ * method used). By comparison, the translation declared in EPSG database is about 370 metres in
+ * geocentric coordinates.
*/
final boolean isUsingEpsgFactory = verifyParametersNTF(((ConcatenatedOperation) operation).getOperations(), 1);
assertEquals("linearAccuracy", isUsingEpsgFactory ? 2 : PositionalAccuracyConstant.UNKNOWN_ACCURACY,
CRS.getLinearAccuracy(operation), STRICT);
- tolerance = isUsingEpsgFactory ? Formulas.LINEAR_TOLERANCE : 100;
+ tolerance = isUsingEpsgFactory ? Formulas.LINEAR_TOLERANCE : 600;
transform = operation.getMathTransform();
/*
* Test using the location of Paris (48.856578°N, 2.351828°E) first,
@@ -236,7 +238,7 @@ public final strictfp class DefaultCoord
assertEquals("linearAccuracy", isUsingEpsgFactory ? 2 : PositionalAccuracyConstant.UNKNOWN_ACCURACY,
CRS.getLinearAccuracy(operation), STRICT);
- tolerance = isUsingEpsgFactory ? Formulas.LINEAR_TOLERANCE : 100;
+ tolerance = isUsingEpsgFactory ? Formulas.LINEAR_TOLERANCE : 600;
transform = operation.getMathTransform();
isInverseTransformSupported = false;
/*
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/builder/LinearTransformBuilderTest.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -74,15 +74,12 @@ public final strictfp class LinearTransf
*/
@Test
public void testMinimalist2D() throws FactoryException {
+ final Map<DirectPosition2D,DirectPosition2D> pos = new HashMap<>(8);
+ assertNull(pos.put(new DirectPosition2D(1, 1), new DirectPosition2D(3, 2)));
+ assertNull(pos.put(new DirectPosition2D(1, 2), new DirectPosition2D(3, 5)));
+ assertNull(pos.put(new DirectPosition2D(2, 2), new DirectPosition2D(5, 5)));
final LinearTransformBuilder builder = new LinearTransformBuilder();
- builder.setSourcePoints(
- new DirectPosition2D(1, 1),
- new DirectPosition2D(1, 2),
- new DirectPosition2D(2, 2));
- builder.setTargetPoints(
- new DirectPosition2D(3, 2),
- new DirectPosition2D(3, 5),
- new DirectPosition2D(5, 5));
+ builder.setControlPoints(pos);
assertArrayEquals(new double[] {3, 2}, builder.getControlPoint(new int[] {1, 1}), STRICT);
assertArrayEquals(new double[] {3, 5}, builder.getControlPoint(new int[] {1, 2}), STRICT);
Modified: sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-referencing/src/test/java/org/apache/sis/test/integration/ConsistencyTest.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -25,6 +25,7 @@ import org.opengis.util.FactoryException
import org.opengis.util.NoSuchIdentifierException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.apache.sis.referencing.factory.FactoryDataException;
+import org.apache.sis.referencing.factory.UnavailableFactoryException;
import org.apache.sis.referencing.IdentifiedObjects;
import org.apache.sis.referencing.CRS;
import org.apache.sis.io.wkt.Convention;
@@ -67,11 +68,22 @@ public final strictfp class ConsistencyT
* Codes to exclude for now.
*/
private static final Set<String> EXCLUDES = new HashSet<>(Arrays.asList(
- "CRS:1", // Computer display
- "EPSG:5819" // EPSG topocentric example A
+ "CRS:1", // Computer display: WKT parser alters the (i,j) axis names.
+ "EPSG:5819", // EPSG topocentric example A: error while parsing WKT.
+ "AUTO2:42001", // This projection requires parameters, but we provide none.
+ "AUTO2:42002", // This projection requires parameters, but we provide none.
+ "AUTO2:42003", // This projection requires parameters, but we provide none.
+ "AUTO2:42004", // This projection requires parameters, but we provide none.
+ "AUTO2:42005" // This projection requires parameters, but we provide none.
));
/**
+ * Width of the code columns in the warnings formatted by {@link #print(String, String, Object)}.
+ * We begin with an arbitrary width and will expand if necessary.
+ */
+ private int codeWidth = 15;
+
+ /**
* Verifies the WKT consistency of all CRS instances.
*
* @throws FactoryException if an error other than "unsupported operation method" occurred.
@@ -92,7 +104,7 @@ public final strictfp class ConsistencyT
final CoordinateReferenceSystem crs;
try {
crs = CRS.forCode(code);
- } catch (NoSuchIdentifierException | FactoryDataException e) {
+ } catch (UnavailableFactoryException | NoSuchIdentifierException | FactoryDataException e) {
print(code, "WARNING", e.getLocalizedMessage());
continue;
}
@@ -118,9 +130,13 @@ public final strictfp class ConsistencyT
* Prints the given code followed by spaces and the given {@code "ERROR"} or {@code "WARNING"} word,
* then the given message.
*/
- private static void print(final String code, final String word, final Object message) {
+ private void print(final String code, final String word, final Object message) {
+ final int currentWidth = code.length();
+ if (currentWidth >= codeWidth) {
+ codeWidth = currentWidth + 1;
+ }
out.print(code);
- out.print(CharSequences.spaces(15 - code.length()));
+ out.print(CharSequences.spaces(codeWidth - currentWidth));
out.print(word);
out.print(": ");
out.println(message);
@@ -135,7 +151,7 @@ public final strictfp class ConsistencyT
* @param crs the CRS to test.
* @return the parsed CRS.
*/
- private static CoordinateReferenceSystem parseAndFormat(final WKTFormat f,
+ private CoordinateReferenceSystem parseAndFormat(final WKTFormat f,
final String code, final CoordinateReferenceSystem crs)
{
String wkt = f.format(crs);
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -84,25 +84,33 @@ public enum DataDirectory {
private Path directory;
/**
+ * Prevents the log message about {@code SIS_DATA} environment variable not set.
+ * This is used for the "About" command line action only.
+ */
+ public static void quiet() {
+ lastWarning = Messages.Keys.DataDirectoryNotSpecified_1;
+ }
+
+ /**
* Logs a message to the {@code "org.apache.sis.system"} logger only if different than the last warning.
*/
- private static void warning(final String method, final Exception e, final short key, final Object... parameters) {
+ private static void warning(final Exception e, final short key, final Object... parameters) {
if (key != lastWarning) {
lastWarning = key;
- log(Level.WARNING, method, e, key, parameters);
+ log(Level.WARNING, e, key, parameters);
}
}
/**
* Logs a message to the {@code "org.apache.sis.system"} logger.
*/
- private static void log(final Level level, final String method, final Exception e, final short key, final Object... parameters) {
+ private static void log(final Level level, final Exception e, final short key, final Object... parameters) {
final LogRecord record = Messages.getResources(null).getLogRecord(level, key, parameters);
record.setLoggerName(Loggers.SYSTEM);
if (e != null) {
record.setThrown(e);
}
- Logging.log(DataDirectory.class, method, record);
+ Logging.log(null, null, record); // Let Logging.log(…) infers the public caller.
}
/**
@@ -153,22 +161,22 @@ public enum DataDirectory {
if (rootDirectory == null) try {
final String dir = getenv();
if (dir == null || dir.isEmpty()) {
- warning("getRootDirectory", null, Messages.Keys.DataDirectoryNotSpecified_1, ENV);
+ warning(null, Messages.Keys.DataDirectoryNotSpecified_1, ENV);
} else try {
final Path path = Paths.get(dir);
if (!Files.isDirectory(path)) {
- warning("getRootDirectory", null, Messages.Keys.DataDirectoryDoesNotExist_2, ENV, path);
+ warning(null, Messages.Keys.DataDirectoryDoesNotExist_2, ENV, path);
} else if (!Files.isReadable(path)) {
- warning("getRootDirectory", null, Messages.Keys.DataDirectoryNotReadable_2, ENV, path);
+ warning(null, Messages.Keys.DataDirectoryNotReadable_2, ENV, path);
} else {
- log(Level.CONFIG, "getRootDirectory", null, Messages.Keys.DataDirectory_2, ENV, path);
+ log(Level.CONFIG, null, Messages.Keys.DataDirectory_2, ENV, path);
rootDirectory = path;
}
} catch (InvalidPathException e) {
- warning("getRootDirectory", e, Messages.Keys.DataDirectoryDoesNotExist_2, ENV, dir);
+ warning(e, Messages.Keys.DataDirectoryDoesNotExist_2, ENV, dir);
}
} catch (SecurityException e) {
- warning("getRootDirectory", e, Messages.Keys.DataDirectoryNotAuthorized_1, ENV);
+ warning(e, Messages.Keys.DataDirectoryNotAuthorized_1, ENV);
}
return rootDirectory;
}
@@ -198,12 +206,12 @@ public enum DataDirectory {
} else if (Files.isWritable(root)) try {
directory = Files.createDirectory(dir);
} catch (IOException e) {
- warning("getDirectory", e, Messages.Keys.DataDirectoryNotWritable_2, ENV, root);
+ warning(e, Messages.Keys.DataDirectoryNotWritable_2, ENV, root);
} else {
- warning("getDirectory", null, Messages.Keys.DataDirectoryNotWritable_2, ENV, root);
+ warning(null, Messages.Keys.DataDirectoryNotWritable_2, ENV, root);
}
} catch (SecurityException e) {
- warning("getDirectory", e, Messages.Keys.DataDirectoryNotAccessible_2, ENV, name);
+ warning(e, Messages.Keys.DataDirectoryNotAccessible_2, ENV, name);
}
}
}
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -109,7 +109,7 @@ public abstract class Vector extends Abs
*
* <div class="section">Unsigned integers</div>
* Java has no primitive support for unsigned integers. But some file formats use unsigned integers,
- * which can be simulated in Java by the use of bit masks or methods like {@link Integer#toUnsignedLong(int)}.
+ * which can be simulated in Java by the use of bit masks or methods like {@code Integer.toUnsignedLong(int)}.
* This {@code Vector} class applies automatically those masks (unless otherwise noticed in method Javadoc)
* if the {@code isUnsigned} argument is {@code true}.
* That argument applies only to {@code byte[]}, {@code short[]}, {@code int[]} or {@code long[]} arrays
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/measure/Units.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -27,18 +27,14 @@ import org.opengis.geometry.DirectPositi
import org.opengis.referencing.cs.AxisDirection; // For javadoc
import org.apache.sis.util.Static;
-import org.apache.sis.util.Workaround;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.util.Constants;
-import static java.lang.Math.PI;
-import static java.lang.Math.abs;
import static org.apache.sis.measure.UnitRegistry.SI;
import static org.apache.sis.measure.UnitRegistry.ACCEPTED;
import static org.apache.sis.measure.UnitRegistry.IMPERIAL;
import static org.apache.sis.measure.UnitRegistry.OTHER;
import static org.apache.sis.measure.UnitRegistry.PREFIXABLE;
-import static org.apache.sis.measure.SexagesimalConverter.EPS;
/**
@@ -1479,51 +1475,6 @@ public final class Units extends Static
}
/**
- * Multiplies the given unit by the given factor. For example multiplying {@link #METRE}
- * by 1000 gives {@link #KILOMETRE}. Invoking this method is equivalent to invoking
- * {@link Unit#multiply(double)} except for the following:
- *
- * <ul>
- * <li>A small tolerance factor is applied for a few factors commonly used in GIS.
- * For example {@code multiply(RADIANS, 0.0174532925199...)} will return {@link #DEGREE}
- * even if the given numerical value is slightly different than {@linkplain Math#PI π}/180.
- * The tolerance factor and the set of units handled especially may change in future SIS versions.</li>
- * <li>This method tries to returns unique instances for some common units.</li>
- * </ul>
- *
- * @param <Q> the quantity measured by the unit.
- * @param unit the unit to multiply.
- * @param factor the multiplication factor.
- * @return the unit multiplied by the given factor.
- *
- * @deprecated Replaced by Apache SIS implementation of {@link Unit#multiply(double)}.
- */
- @Deprecated
- @Workaround(library="JSR-275", version="0.9.3")
- @SuppressWarnings("unchecked")
- public static <Q extends Quantity<Q>> Unit<Q> multiply(Unit<Q> unit, final double factor) {
- if (RADIAN.equals(unit)) {
- if (abs(factor - (PI / 180)) <= (EPS * PI/180)) {
- return (Unit<Q>) DEGREE;
- }
- if (abs(factor - (PI / 200)) <= (EPS * PI/200)) {
- return (Unit<Q>) GRAD;
- }
- } else if (METRE.equals(unit)) {
- if (abs(factor - 0.3048) <= (EPS * 0.3048)) {
- return (Unit<Q>) FOOT;
- }
- if (abs(factor - (1200.0/3937)) <= (EPS * (1200.0/3937))) {
- return (Unit<Q>) US_SURVEY_FOOT;
- }
- }
- if (abs(factor - 1) > EPS) {
- unit = unit.multiply(factor);
- }
- return unit;
- }
-
- /**
* Returns the factor by which to multiply the standard unit in order to get the given unit.
* The "standard" unit is usually the SI unit on which the given unit is based, as given by
* {@link Unit#getSystemUnit()}.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/OptionKey.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -75,16 +75,6 @@ public class OptionKey<T> implements Ser
private static final long serialVersionUID = -7580514229639750246L;
/**
- * The library to use for creating geometric objects at reading time.
- * Some libraries are the Java Topology Suite (JTS), ESRI geometry API and Java2D.
- * If this option is not specified, then a default library will be selected among
- * the libraries available in the runtime environment.
- *
- * @since 0.8
- */
- public static final OptionKey<GeometryLibrary> GEOMETRY_LIBRARY = new OptionKey<>("GEOMETRY_LIBRARY", GeometryLibrary.class);
-
- /**
* The locale to use for locale-sensitive data. This option determines the language to use for writing
* {@link org.apache.sis.util.iso.AbstractInternationalString international strings} when the target
* storage support only one language. It may also control number and date patterns in some file formats
@@ -192,6 +182,16 @@ public class OptionKey<T> implements Ser
public static final OptionKey<ByteBuffer> BYTE_BUFFER = new OptionKey<>("BYTE_BUFFER", ByteBuffer.class);
/**
+ * The library to use for creating geometric objects at reading time.
+ * Some libraries are the Java Topology Suite (JTS), ESRI geometry API and Java2D.
+ * If this option is not specified, then a default library will be selected among
+ * the libraries available in the runtime environment.
+ *
+ * @since 0.8
+ */
+ public static final OptionKey<GeometryLibrary> GEOMETRY_LIBRARY = new OptionKey<>("GEOMETRY_LIBRARY", GeometryLibrary.class);
+
+ /**
* The number of spaces to use for indentation when formatting text files in WKT or XML formats.
* A value of {@value org.apache.sis.io.wkt.WKTFormat#SINGLE_LINE} means to format the whole WKT
* or XML document on a single line without line feeds or indentation.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/setup/package-info.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -17,9 +17,13 @@
/**
* Provides information and some controls about SIS configuration.
+ * System-wide informations are provided by the {@link org.apache.sis.setup.About} class.
+ * Some controls, for example on the {@linkplain org.apache.sis.setup.GeometryLibrary geometry library} to use,
+ * is provided by a set of {@linkplain org.apache.sis.setup.OptionKey options} which can be used when a data store
+ * is created.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 0.8
* @since 0.3
* @module
*/
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/collection/Cache.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -63,7 +63,7 @@ import org.apache.sis.internal.jdk8.Supp
* public MyObject getMyObject(final String key) throws MyCheckedException {
* try {
* return cache.getOrCreate(key, new Callable<MyObject>() {
- * MyObject call() throws FactoryException {
+ * public MyObject call() throws MyCheckedException {
* return createMyObject(key);
* }
* });
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -21,6 +21,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.LogRecord;
+import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.Configuration;
import org.apache.sis.util.Static;
import org.apache.sis.util.Exceptions;
@@ -47,7 +48,7 @@ import org.apache.sis.internal.system.Mo
* </ul>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.6
+ * @version 0.8
* @since 0.3
* @module
*/
@@ -204,21 +205,101 @@ public final class Logging extends Stati
* @param method the name of the method which is logging a record.
* @param record the record to log.
*/
- public static void log(final Class<?> classe, final String method, final LogRecord record) {
- record.setSourceClassName(classe.getCanonicalName());
- record.setSourceMethodName(method);
+ public static void log(final Class<?> classe, String method, final LogRecord record) {
+ ArgumentChecks.ensureNonNull("record", record);
final String loggerName = record.getLoggerName();
- final Logger logger;
+ Logger logger;
if (loggerName == null) {
logger = getLogger(classe);
record.setLoggerName(logger.getName());
} else {
logger = getLogger(loggerName);
}
+ if (classe != null && method != null) {
+ record.setSourceClassName(classe.getCanonicalName());
+ record.setSourceMethodName(method);
+ } else {
+ /*
+ * If the given class or method is null, infer them from stack trace. We do not document this feature
+ * in public API because the rules applied here are heuristic and may change in any future SIS version.
+ */
+ logger = inferCaller(logger, (classe != null) ? classe.getCanonicalName() : null,
+ method, Thread.currentThread().getStackTrace(), record);
+ }
logger.log(record);
}
/**
+ * Sets the {@code LogRecord} source class and method names according values inferred from the given stack trace.
+ * This method inspects the given stack trace, skips what looks like internal API based on heuristic rules, then
+ * if some arguments are non-null tries to match them.
+ *
+ * @param logger where the log record will be sent after this method call, or {@code null} if unknown.
+ * @param classe the name of the class to report in the log record, or {@code null} if unknown.
+ * @param method the name of the method to report in the log record, or {@code null} if unknown.
+ * @param trace the stack trace to use for inferring the class and method names.
+ * @param record the record where to set the class and method names.
+ * @return the record to use for logging the record.
+ */
+ private static Logger inferCaller(Logger logger, String classe, String method,
+ final StackTraceElement[] trace, final LogRecord record)
+ {
+ for (final StackTraceElement element : trace) {
+ /*
+ * Search for the first stack trace element with a classname matching the expected one.
+ * We compare against the name of the class given in argument if it was non-null.
+ *
+ * Note: a previous version also compared logger name with package name.
+ * This has been removed because those names are only loosely related.
+ */
+ final String classname = element.getClassName();
+ if (classe != null) {
+ if (!classname.equals(classe)) {
+ continue;
+ }
+ } else if (!WarningListeners.isPublic(element)) {
+ continue;
+ }
+ /*
+ * Now that we have a stack trace element from the expected class (or any
+ * element if we don't know the class), make sure that we have the right method.
+ */
+ final String methodName = element.getMethodName();
+ if (method != null && !methodName.equals(method)) {
+ continue;
+ }
+ /*
+ * Now computes every values that are null, and stop the loop.
+ */
+ if (logger == null) {
+ final int separator = classname.lastIndexOf('.');
+ logger = getLogger((separator >= 1) ? classname.substring(0, separator-1) : "");
+ }
+ if (classe == null) {
+ classe = classname;
+ }
+ if (method == null) {
+ method = methodName;
+ }
+ break;
+ }
+ /*
+ * The logger may stay null if we have been unable to find a suitable stack trace.
+ * Fallback on the global logger.
+ */
+ if (logger == null) {
+ logger = getLogger(Logger.GLOBAL_LOGGER_NAME);
+ }
+ if (classe != null) {
+ record.setSourceClassName(classe);
+ }
+ if (method != null) {
+ record.setSourceMethodName(method);
+ }
+ return logger;
+ }
+
+ /**
* Invoked when an unexpected error occurred. This method logs a message at {@link Level#WARNING}
* to the specified logger. The originating class name and method name can optionally be specified.
* If any of them is {@code null}, then it will be inferred from the error stack trace as described below.
@@ -290,79 +371,6 @@ public final class Logging extends Stati
return false;
}
/*
- * Loggeable, so complete the null argument from the stack trace if we can.
- */
- if (logger == null || classe == null || method == null) {
- String paquet = (logger != null) ? logger.getName() : null;
- for (final StackTraceElement element : error.getStackTrace()) {
- /*
- * Searches for the first stack trace element with a classname matching the
- * expected one. We compare preferably against the name of the class given
- * in argument, or against the logger name (taken as the package name) otherwise.
- */
- final String classname = element.getClassName();
- if (classe != null) {
- if (!classname.equals(classe)) {
- continue;
- }
- } else if (paquet != null) {
- if (!classname.startsWith(paquet)) {
- continue;
- }
- final int length = paquet.length();
- if (classname.length() > length) {
- /*
- * We expect '.' but we accept also '$' or end of string.
- */
- final char separator = classname.charAt(length);
- if (Character.isJavaIdentifierPart(separator)) {
- continue;
- }
- }
- }
- /*
- * Now that we have a stack trace element from the expected class (or any
- * element if we don't know the class), make sure that we have the right method.
- */
- final String methodName = element.getMethodName();
- if (method != null && !methodName.equals(method)) {
- continue;
- }
- /*
- * Now computes every values that are null, and stop the loop.
- */
- if (paquet == null) {
- final int separator = classname.lastIndexOf('.');
- paquet = (separator >= 1) ? classname.substring(0, separator-1) : "";
- logger = getLogger(paquet);
- if (!logger.isLoggable(level)) {
- return false;
- }
- }
- if (classe == null) {
- classe = classname;
- }
- if (method == null) {
- method = methodName;
- }
- break;
- }
- /*
- * The logger may stay null if we have been unable to find a suitable
- * stack trace. Fallback on the global logger.
- */
- if (logger == null) {
- logger = getLogger(Logger.GLOBAL_LOGGER_NAME);
- if (!logger.isLoggable(level)) {
- return false;
- }
- }
- }
- /*
- * Now prepare the log message. If we have been unable to figure out a source class and
- * method name, we will fallback on JDK logging default mechanism, which may return a
- * less relevant name than our attempt to use the logger name as the package name.
- *
* The message is fetched using Exception.getMessage() instead than getLocalizedMessage()
* because in a client-server architecture, we want the locale on the server-side instead
* than the locale on the client side. See LocalizedException policy.
@@ -375,15 +383,15 @@ public final class Logging extends Stati
message = buffer.toString();
message = Exceptions.formatChainedMessages(null, message, error);
final LogRecord record = new LogRecord(level, message);
- if (classe != null) {
- record.setSourceClassName(classe);
- }
- if (method != null) {
- record.setSourceMethodName(method);
- }
if (level.intValue() >= LEVEL_THRESHOLD_FOR_STACKTRACE) {
record.setThrown(error);
}
+ if (logger == null || classe == null || method == null) {
+ logger = inferCaller(logger, classe, method, error.getStackTrace(), record);
+ } else {
+ record.setSourceClassName(classe);
+ record.setSourceMethodName(method);
+ }
record.setLoggerName(logger.getName());
logger.log(record);
return true;
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/MonolineFormatter.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -109,7 +109,7 @@ import static org.apache.sis.internal.ut
* from multiple threads.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.0
*
* @see SimpleFormatter
* @see Handler#setFormatter(Formatter)
@@ -166,6 +166,11 @@ public class MonolineFormatter extends F
private static final boolean SHOW_LEVEL = true;
/**
+ * Number of spaces to colorize at the beginning of lines that are continuation of a single log record.
+ */
+ private static final int CONTINUATION_MARGIN = 4;
+
+ /**
* Minimal number of stack trace elements to print before and after the "interesting" elements.
* The "interesting" elements are the first stack trace elements, and the element which point
* to the method that produced the log record.
@@ -175,6 +180,11 @@ public class MonolineFormatter extends F
private static final int CONTEXT_STACK_TRACE_ELEMENTS = 2;
/**
+ * Maximal amount of causes to print in stack traces. This is an arbitrary limit.
+ */
+ private static final int MAX_CAUSES = 10;
+
+ /**
* The string to write on the left side of the first line of every log records.
* The default value is an empty string. This field can not be null.
*
@@ -332,7 +342,7 @@ public class MonolineFormatter extends F
/**
* Returns the length of the widest level name, taking in account only the standard levels
- * equals or greater then the given threshold.
+ * equals or greater than the given threshold.
*/
static int levelWidth(final Level threshold) {
int levelWidth = 0;
@@ -626,11 +636,18 @@ loop: for (int i=0; ; i++) {
*/
@Override
public String format(final LogRecord record) {
+ boolean faint = false; // Whether to use faint text for level < INFO.
+ String emphaseStart = ""; // ANSI escape sequence for bold text if we use it.
+ String emphaseEnd = ""; // ANSI escape sequence for stopping bold text if we use it.
final Level level = record.getLevel();
final StringBuffer buffer = this.buffer;
synchronized (buffer) {
- final boolean colors = (this.colors != null);
- final boolean emphase = !faintSupported || (level.intValue() >= LEVEL_THRESHOLD.intValue());
+ final boolean colors = (this.colors != null);
+ if (colors && level.intValue() >= LEVEL_THRESHOLD.intValue()) {
+ emphaseStart = X364.BOLD.sequence();
+ emphaseEnd = X364.NORMAL.sequence();
+ faint = faintSupported;
+ }
buffer.setLength(header.length());
/*
* Appends the time (e.g. "00:00:12.365"). The time pattern can be set either
@@ -653,10 +670,10 @@ loop: for (int i=0; ; i++) {
levelColor = colorAt(level);
levelReset = X364.BACKGROUND_DEFAULT.sequence();
}
- final int offset = buffer.append(levelColor).length();
- buffer.append(level.getLocalizedName())
- .append(CharSequences.spaces(levelWidth - (buffer.length() - offset)));
- margin += buffer.length() - offset;
+ final int offset = buffer.append(levelColor).append(emphaseStart).length();
+ final int length = buffer.append(level.getLocalizedName()).length() - offset;
+ buffer.append(emphaseEnd).append(CharSequences.spaces(levelWidth - length));
+ margin += buffer.length() - emphaseEnd.length() - offset;
buffer.append(levelReset).append(' ');
}
/*
@@ -685,14 +702,7 @@ loop: for (int i=0; ; i++) {
if (sourceFormat == METHOD) {
source = source + '.' + record.getSourceMethodName();
}
- if (colors && emphase) {
- buffer.append(X364.BOLD.sequence());
- }
- buffer.append('[').append(source).append(']');
- if (colors && emphase) {
- buffer.append(X364.NORMAL.sequence());
- }
- buffer.append(' ');
+ buffer.append(emphaseStart).append('[').append(source).append(']').append(emphaseEnd).append(' ');
}
/*
* Now prepare the LineAppender for the message. We set a line separator prefixed by some
@@ -701,10 +711,12 @@ loop: for (int i=0; ; i++) {
String bodyLineSeparator = writer.getLineSeparator();
final String lineSeparator = System.lineSeparator();
if (bodyLineSeparator.length() != lineSeparator.length() + margin + 1) {
- bodyLineSeparator = lineSeparator + levelColor + CharSequences.spaces(margin) + levelReset + ' ';
+ final int highlight = Math.min(CONTINUATION_MARGIN, margin);
+ bodyLineSeparator = lineSeparator + levelColor + CharSequences.spaces(highlight)
+ + levelReset + CharSequences.spaces(margin - highlight + 1);
writer.setLineSeparator(bodyLineSeparator);
}
- if (colors && !emphase) {
+ if (faint) {
buffer.append(X364.FAINT.sequence());
}
final Throwable exception = record.getThrown();
@@ -738,7 +750,7 @@ loop: for (int i=0; ; i++) {
throw new AssertionError(e);
}
buffer.setLength(CharSequences.skipTrailingWhitespaces(buffer, 0, buffer.length()));
- if (colors && !emphase) {
+ if (faint) {
buffer.append(X364.NORMAL.sequence());
}
buffer.append(lineSeparator);
@@ -814,8 +826,7 @@ loop: for (int i=0; ; i++) {
final String loggerName, final String sourceClassName, final String sourceMethodName) throws IOException
{
StackTraceElement previous = null;
- // Arbitrary limit of 10 causes to format.
- for (int numCauses=0; numCauses<10; numCauses++) {
+ for (int numCauses=0; numCauses<MAX_CAUSES; numCauses++) {
final StackTraceElement[] trace = exception.getStackTrace();
/*
* Find the index of the stack trace element where the log has been produced.
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/WarningListeners.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -27,6 +27,7 @@ import org.apache.sis.util.Localized;
import org.apache.sis.util.Exceptions;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.util.UnmodifiableArrayList;
@@ -267,6 +268,7 @@ public class WarningListeners<S> impleme
/**
* Returns {@code true} if the given stack trace element describes a method considered part of public API.
* This method is invoked in order to infer the class and method names to declare in a {@link LogRecord}.
+ * We do not document this feature in public Javadoc because it is based on heuristic rules that may change.
*
* <p>The current implementation compares the class name against a hard-coded list of classes to hide.
* This implementation may change in any future SIS version.</p>
@@ -274,11 +276,17 @@ public class WarningListeners<S> impleme
* @param e a stack trace element.
* @return {@code true} if the class and method specified by the given element can be considered public API.
*/
- private static boolean isPublic(final StackTraceElement e) {
- final String classname = e.getClassName();
- return !classname.equals("org.apache.sis.util.logging.WarningListeners") &&
- !classname.contains(".internal.") && !classname.startsWith("java") &&
- classname.indexOf('$') < 0 && e.getMethodName().indexOf('$') < 0;
+ static boolean isPublic(final StackTraceElement e) {
+ final String classname = e.getClassName();
+ if (classname.startsWith("java") || classname.contains(".internal.") ||
+ classname.indexOf('$') >= 0 || e.getMethodName().indexOf('$') >= 0)
+ {
+ return false;
+ }
+ if (classname.startsWith(Modules.CLASSNAME_PREFIX + "util.logging.")) {
+ return classname.endsWith("Test"); // Consider JUnit tests as public.
+ }
+ return true; // TODO: with StackWalker on JDK9, check if the class is public.
}
/**
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/package-info.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/logging/package-info.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -50,7 +50,7 @@
* order to give SIS a chance to redirect log events to an other logging framework.
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
*
* @see <a href="http://download.oracle.com/javase/6/docs/technotes/guides/logging/overview.html">Java Logging Overview</a>
*
Modified: sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -482,28 +482,6 @@ public class IndexedResourceBundle exten
}
/**
- * Gets a string for the given key and appends ":" to it.
- * A space may or may not be added before ":", depending on the locale.
- * No space is added after the string; it is up to the caller to add such space if needed.
- *
- * @param key the key for the desired string.
- * @return the string for the given key.
- * @throws MissingResourceException if no object for the given key can be found.
- *
- * @deprecated Replaced by {@link #appendLabel(short, Appendable)}.
- */
- @Deprecated
- public final String getLabel(final short key) throws MissingResourceException {
- String label = getString(key);
- if (Locale.FRENCH.getLanguage().equals(getLocale().getLanguage())) {
- label += "\u00A0:";
- } else {
- label += ':';
- }
- return label;
- }
-
- /**
* Gets a string for the given key from this resource bundle or one of its parents.
*
* @param key the key for the desired string.
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/TestSuite.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -28,7 +28,9 @@ import java.net.URL;
import java.net.URISyntaxException;
import org.apache.sis.internal.system.Shutdown;
import org.apache.sis.internal.system.SystemListener;
+import org.apache.sis.util.logging.MonolineFormatter;
import org.apache.sis.util.Classes;
+import org.junit.BeforeClass;
import org.junit.AfterClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -40,7 +42,7 @@ import static org.junit.Assert.*;
* Base class of Apache SIS test suites (except the ones that extend GeoAPI suites).
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.7
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -240,6 +242,21 @@ public abstract strictfp class TestSuite
}
/**
+ * Installs Apache SIS monoline formatter for easier identification of Apache SIS log messages among Maven outputs.
+ * We perform this installation only for {@code *TestSuite}, not for individual {@code *Test}. Consequently this is
+ * typically enabled when building a whole module with Maven but not when debugging an individual class.
+ *
+ * @since 1.0
+ */
+ @BeforeClass
+ public static void configureLogging() {
+ MonolineFormatter f = MonolineFormatter.install();
+ f.setHeader(null);
+ f.setTimeFormat(null);
+ f.setSourceFormat("class.method");
+ }
+
+ /**
* Simulates a module uninstall after all tests. This method will first notify any classpath-dependant
* services that the should clear their cache, then stop the SIS daemon threads. Those operations are
* actually not needed in non-server environment (it is okay to just let the JVM stop by itself), but
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/package-info.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/package-info.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/package-info.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/test/package-info.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -41,7 +41,7 @@
* </ul>
*
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.0
* @since 0.3
* @module
*/
Modified: sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/logging/WarningListenersTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/logging/WarningListenersTest.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/logging/WarningListenersTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-utility/src/test/java/org/apache/sis/util/logging/WarningListenersTest.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -110,6 +110,7 @@ public final strictfp class WarningListe
listeners.warning("The message", null);
listeners.removeWarningListener(this);
assertNotNull("Listener has not been notified.", warning);
+ assertEquals(getClass().getName(), warning.getSourceClassName());
assertEquals("testWarning", warning.getSourceMethodName());
assertEquals("The message", warning.getMessage());
}
Propchange: sis/trunk/storage/sis-gdal/src/main/resources/native/linux/libproj-binding.so
------------------------------------------------------------------------------
svn:executable = *
Modified: sis/trunk/storage/sis-netcdf/pom.xml
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/pom.xml?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/pom.xml (original)
+++ sis/trunk/storage/sis-netcdf/pom.xml Fri Nov 17 18:12:45 2017
@@ -132,7 +132,7 @@ Bridge between netCDF Climate and Foreca
<repository>
<id>UCAR</id>
<name>UCAR repository</name>
- <url>https://artifacts.unidata.ucar.edu/content/repositories/unidata-releases</url>
+ <url>https://artifacts.unidata.ucar.edu/repository/unidata-releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
Modified: sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/AttributeNames.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -109,7 +109,6 @@ import org.opengis.metadata.extent.Geogr
* {@value #METADATA_CREATION}<br>
* {@value #METADATA_LINK}<br>
* {@linkplain #TITLE "name"}<br>
- * {@value #NAMING_AUTHORITY}<br>
* {@value #PROCESSING_LEVEL}<br>
* {@value #PRODUCT_VERSION}<br>
* {@linkplain #PROGRAM "program"}<br>
@@ -276,28 +275,6 @@ public class AttributeNames {
public static final Term IDENTIFIER = new Term(ACDD.id, ACDD.naming_authority);
/**
- * The {@value} attribute name for the identifier authority (<em>Recommended</em>).
- * The combination of the {@value} and the {@code "id"} should be a globally
- * unique identifier for the dataset.
- *
- * <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
- * {@link Metadata#getFileIdentifier() fileIdentifier}</li>
- * <li>{@link Metadata} /
- * {@link Metadata#getIdentificationInfo() identificationInfo} /
- * {@link DataIdentification#getCitation() citation} /
- * {@link Citation#getIdentifiers() identifier} /
- * {@link Identifier#getAuthority() authority} /
- * {@link Citation#getTitle() title}</li></ul>
- *
- * @see #IDENTIFIER
- * @see <a href="http://wiki.esipfed.org/index.php/Attribute_Convention_for_Data_Discovery#naming_authority">ESIP reference</a>
- *
- * @deprecated Moved to {@code IDENTIFIER.VOCABULARY}.
- */
- @Deprecated
- public static final String NAMING_AUTHORITY = ACDD.naming_authority;
-
- /**
* The set of attribute names for a long descriptive name for the variable taken from a controlled
* vocabulary of variable names. This is actually a {@linkplain VariableSimpleIF variable} attribute,
* but sometime appears also in {@linkplain NetcdfFile#findGlobalAttribute(String) global attributes}.
@@ -318,25 +295,6 @@ public class AttributeNames {
public static final Term STANDARD_NAME = new Term(CF.STANDARD_NAME, ACDD.standard_name_vocabulary);
/**
- * The {@value} attribute name for indicating which controlled list of variable names has been
- * used in the {@code "standard_name"} attribute.
- *
- * <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
- * {@link Metadata#getIdentificationInfo() identificationInfo} /
- * {@link DataIdentification#getDescriptiveKeywords() descriptiveKeywords} /
- * {@link Keywords#getThesaurusName() thesaurusName} /
- * {@link Citation#getTitle() title}</li></ul>
- *
- * @see #STANDARD_NAME
- * @see #VOCABULARY
- * @see <a href="http://wiki.esipfed.org/index.php/Attribute_Convention_for_Data_Discovery#standard_name_vocabulary">ESIP reference</a>
- *
- * @deprecated Moved to {@code STANDARD_NAME.VOCABULARY}.
- */
- @Deprecated
- public static final String STANDARD_NAME_VOCABULARY = ACDD.standard_name_vocabulary;
-
- /**
* The set of attribute names for a comma separated list of key words and phrases
* (<em>Highly Recommended</em>).
*
@@ -356,25 +314,6 @@ public class AttributeNames {
public static final Term KEYWORDS = new Term(ACDD.keywords, ACDD.keywords_vocabulary);
/**
- * The {@value} attribute name for the guideline for the words/phrases in the
- * {@code "keyword"} attribute (<em>Recommended</em>).
- *
- * <p><b>Path in ISO 19115:</b></p> <ul><li>{@link Metadata} /
- * {@link Metadata#getIdentificationInfo() identificationInfo} /
- * {@link DataIdentification#getDescriptiveKeywords() descriptiveKeywords} /
- * {@link Keywords#getThesaurusName() thesaurusName} /
- * {@link Citation#getTitle() title}</li></ul>
- *
- * @see #KEYWORDS
- * @see #STANDARD_NAME_VOCABULARY
- * @see <a href="http://wiki.esipfed.org/index.php/Attribute_Convention_for_Data_Discovery#keywords_vocabulary">ESIP reference</a>
- *
- * @deprecated Moved to {@code KEYWORDS.VOCABULARY}.
- */
- @Deprecated
- public static final String VOCABULARY = ACDD.keywords_vocabulary;
-
- /**
* The {@value} attribute name for a high-level geographic data thematic classification.
* Typical values are {@code "farming"}, {@code "biota"}, {@code "boundaries"},
* {@code "climatology meteorology atmosphere"}, {@code "economy"}, {@code "elevation"},
@@ -721,16 +660,6 @@ public class AttributeNames {
public final Role DEFAULT_ROLE;
/**
- * @deprecated replaced by the constructor with one more argument (the type).
- */
- @Deprecated
- public Responsible(final String name, final String institution, final String url, final String email,
- final String role, final Role defaultRole)
- {
- this(name, null, institution, url, email, role, defaultRole);
- }
-
- /**
* Creates a new set of attribute names. Any argument can be {@code null} if not applicable.
*
* @param name the attribute name for the responsible's name.
@@ -864,11 +793,6 @@ public class AttributeNames {
public static final String ACKNOWLEDGEMENT = ACDD.acknowledgement;
/**
- * @deprecated Renamed {@link #ACKNOWLEDGEMENT}.
- */
- public static final String ACKNOWLEDGMENT = "acknowledgment";
-
- /**
* The {@value} attribute name for a description of the restrictions to data access
* and distribution (<em>Recommended</em>).
*
Modified: sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] (original)
+++ sis/trunk/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -83,21 +83,6 @@ public class NetcdfStore extends DataSto
* This constructor invokes {@link StorageConnector#closeAllExcept(Object)}, keeping open only the
* needed resource.
*
- * @param connector information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile} instance, <i>etc</i>).
- * @throws DataStoreException if an error occurred while opening the netCDF file.
- *
- * @deprecated Replaced by {@link #NetcdfStore(NetcdfStoreProvider, StorageConnector)}.
- */
- @Deprecated
- public NetcdfStore(final StorageConnector connector) throws DataStoreException {
- this(null, connector);
- }
-
- /**
- * Creates a new netCDF store from the given file, URL, stream or {@link ucar.nc2.NetcdfFile} object.
- * This constructor invokes {@link StorageConnector#closeAllExcept(Object)}, keeping open only the
- * needed resource.
- *
* @param provider the factory that created this {@code DataStore} instance, or {@code null} if unspecified.
* @param connector information about the storage (URL, stream, {@link ucar.nc2.NetcdfFile} instance, <i>etc</i>).
* @throws DataStoreException if an error occurred while opening the netCDF file.
Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/DocumentedStoreProvider.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -16,7 +16,8 @@
*/
package org.apache.sis.internal.storage;
-import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
import org.opengis.metadata.distribution.Format;
import org.apache.sis.metadata.sql.MetadataSource;
import org.apache.sis.metadata.sql.MetadataStoreException;
@@ -98,13 +99,17 @@ public abstract class DocumentedStorePro
if (listeners != null) {
listeners.warning(null, e);
} else {
- final Logger logger = Logging.getLogger(Modules.STORAGE);
+ final Level level;
if (!logged) {
logged = true; // Not atomic - not a big deal if we use warning level twice.
- Logging.unexpectedException(logger, getClass(), "getFormat", e);
+ level = Level.WARNING;
} else {
- Logging.recoverableException(logger, getClass(), "getFormat", e);
+ level = Level.FINE;
}
+ final LogRecord record = Resources.forLocale(null).getLogRecord(level,
+ Resources.Keys.CanNotGetCommonMetadata_2, getShortName(), e.getLocalizedMessage());
+ record.setLoggerName(Modules.STORAGE);
+ Logging.log(getClass(), "getFormat", record);
}
}
return super.getFormat();
Modified: sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java
URL: http://svn.apache.org/viewvc/sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1815606&r1=1815605&r2=1815606&view=diff
==============================================================================
--- sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] (original)
+++ sis/trunk/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] Fri Nov 17 18:12:45 2017
@@ -32,7 +32,7 @@ import org.apache.sis.util.resources.Res
* all modules in the Apache SIS project, see {@link org.apache.sis.util.resources} package.
*
* @author Martin Desruisseaux (IRD, Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.8
* @module
*/
@@ -67,6 +67,11 @@ public final class Resources extends Ind
public static final short AmbiguousName_4 = 15;
/**
+ * Can not get metadata common to “{0}” files. Reason: {1}
+ */
+ public static final short CanNotGetCommonMetadata_2 = 39;
+
+ /**
* Can not read the Coordinate Reference System (CRS) Well Known Text (WKT) in “{0}”.
*/
public static final short CanNotReadCRS_WKT_1 = 37;
@@ -153,6 +158,11 @@ public final class Resources extends Ind
public static final short FeatureNotFound_2 = 17;
/**
+ * Whether to assemble trajectory fragments (lines in CSV file) in a single feature instance.
+ */
+ public static final short FoliationRepresentation = 38;
+
+ /**
* The {0} data store does not accept features of type “{1}”.
*/
public static final short IllegalFeatureType_2 = 7;