You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2015/05/12 15:50:17 UTC
svn commit: r1678946 - in /sis/branches/JDK8/core:
sis-metadata/src/main/java/org/apache/sis/io/wkt/
sis-referencing/src/main/java/org/apache/sis/internal/referencing/
sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/
sis-referenci...
Author: desruisseaux
Date: Tue May 12 13:50:17 2015
New Revision: 1678946
URL: http://svn.apache.org/r1678946
Log:
Referencing: consolidation and first tests for DefaultTransformation.
Added:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java (with props)
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] Tue May 12 13:50:17 2015
@@ -674,8 +674,8 @@ public class Formatter implements Locali
* }
*
* For non-internal conventions, all elements other than {@code ID[…]} are formatted
- * only for {@link CoordinateOperation} and {@link ReferenceSystem} types.
- * In the later case, we also require that the CRS is not the base of a derived CRS.
+ * only for {@link CoordinateOperation} and root {@link ReferenceSystem} instances,
+ * with an exception for remarks of {@code ReferenceSystem} embedded inside {@code CoordinateOperation}.
* Those restrictions are our interpretation of the following ISO 19162 requirement:
*
* <blockquote>(…snip…) {@code <scope extent identifier remark>} is a collection of four optional attributes
@@ -689,11 +689,13 @@ public class Formatter implements Locali
isComplement = true;
final boolean showIDs; // Whether to format ID[…] elements.
final boolean filterID; // Whether we shall limit to a single ID[…] element.
- final boolean showOthers; // Whether to format any element other than ID[…].
+ final boolean showOthers; // Whether to format any element other than ID[…] and Remarks[…].
+ final boolean showRemarks; // Whether to format Remarks[…].
if (convention == Convention.INTERNAL) {
- showIDs = true;
- filterID = false;
- showOthers = true;
+ showIDs = true;
+ filterID = false;
+ showOthers = true;
+ showRemarks = true;
} else {
if (convention == Convention.WKT2_SIMPLIFIED) {
showIDs = isRoot;
@@ -701,16 +703,20 @@ public class Formatter implements Locali
showIDs = isRoot || (object instanceof OperationMethod) || (object instanceof GeneralParameterDescriptor);
}
if (convention.majorVersion() == 1) {
- filterID = true;
- showOthers = false;
+ filterID = true;
+ showOthers = false;
+ showRemarks = false;
} else {
filterID = !isRoot;
if (object instanceof CoordinateOperation) {
- showOthers = true;
+ showOthers = true;
+ showRemarks = true;
} else if (object instanceof ReferenceSystem) {
- showOthers = !(getEnclosingElement(1) instanceof ReferenceSystem);
+ showOthers = isRoot;
+ showRemarks = isRoot || (getEnclosingElement(2) instanceof CoordinateOperation);
} else {
- showOthers = false; // Mandated by ISO 19162.
+ showOthers = false; // Mandated by ISO 19162.
+ showRemarks = false;
}
}
}
@@ -719,7 +725,7 @@ public class Formatter implements Locali
}
if (showIDs) {
Collection<? extends Identifier> identifiers = object.getIdentifiers();
- if (identifiers != null) { // Paranoiac check
+ if (identifiers != null) { // Paranoiac check
if (filterID) {
for (final Identifier id : identifiers) {
if (Citations.identifierMatches(authority, id.getAuthority())) {
@@ -737,7 +743,7 @@ public class Formatter implements Locali
}
}
}
- if (showOthers) {
+ if (showRemarks) {
appendOnNewLine(WKTKeywords.Remarks, object.getRemarks(), ElementKind.REMARKS);
}
isComplement = false;
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/OperationMethods.java [UTF-8] Tue May 12 13:50:17 2015
@@ -41,7 +41,7 @@ import org.apache.sis.measure.Units;
public final class OperationMethods extends Static {
/**
* The key for specifying explicitely the value to be returned by
- * {@link org.apache.sis.referencing.operation.DefaultSingleOperation#getParameterValues()}.
+ * {@link org.apache.sis.referencing.operation.DefaultConversion#getParameterValues()}.
* It is usually not necessary to specify those parameters because they are inferred either from
* the {@link MathTransform}, or specified explicitely in a {@code DefiningConversion}. However
* there is a few cases, for example the Molodenski transform, where none of the above can apply,
@@ -127,12 +127,12 @@ public final class OperationMethods exte
* about the return values chosen.
*/
if (operation instanceof Transformation) {
- if (!accuracies.contains(PositionalAccuracyConstant.DATUM_SHIFT_OMITTED)) {
- if (accuracies.contains(PositionalAccuracyConstant.DATUM_SHIFT_APPLIED)) {
- return PositionalAccuracyConstant.DATUM_SHIFT_ACCURACY;
- }
+ if (accuracies.contains(PositionalAccuracyConstant.DATUM_SHIFT_APPLIED)) {
+ return PositionalAccuracyConstant.DATUM_SHIFT_ACCURACY;
+ }
+ if (accuracies.contains(PositionalAccuracyConstant.DATUM_SHIFT_OMITTED)) {
+ return PositionalAccuracyConstant.UNKNOWN_ACCURACY;
}
- return PositionalAccuracyConstant.UNKNOWN_ACCURACY;
}
/*
* If the coordinate operation is a compound of other coordinate operations, returns the sum of their accuracy,
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/j2d/ParameterizedAffine.java [UTF-8] Tue May 12 13:50:17 2015
@@ -104,7 +104,7 @@ public final class ParameterizedAffine e
*/
@Override
public ParameterDescriptorGroup getParameterDescriptors() {
- return isDefinitive || Semaphores.query(Semaphores.PROJCS) // See comment in getParameterValues().
+ return isDefinitive || Semaphores.query(Semaphores.ENCLOSED_IN_OPERATION) // See comment in getParameterValues().
? parameters.getDescriptor() : super.getParameterDescriptors();
}
@@ -112,9 +112,9 @@ public final class ParameterizedAffine e
* Returns the parameter values for this map projection.
*
* <p><b>Hack:</b> this method normally returns the matrix parameters in case of doubt. However if
- * {@link Semaphores#PROJCS} is set, then this method returns the map projection parameters even
- * if they are not a complete description of this math transform. This internal hack shall be used
- * only by {@link org.apache.sis.referencing.operation.DefaultSingleOperation}.</p>
+ * {@link Semaphores#ENCLOSED_IN_OPERATION} is set, then this method returns the map projection parameters
+ * even if they are not a complete description of this math transform. This internal hack shall be used
+ * only by {@link org.apache.sis.referencing.operation.AbstractCoordinateOperation}.</p>
*
* <p><b>Use case of above hack:</b> consider an "Equidistant Cylindrical (Spherical)" map projection
* from a {@code GeographiCRS} base using (latitude, longitude) axis order. We need to concatenate an
@@ -132,14 +132,16 @@ public final class ParameterizedAffine e
* has been applied.</li>
* </ul>
*
- * The {@code Semaphores.PROJCS} flag is SIS internal mechanism for distinguish the two above-cited cases.
+ * The {@code Semaphores.ENCLOSED_IN_OPERATION} flag is SIS internal mechanism for distinguish the two above-cited
+ * cases.
*
* @return The map projection parameters if they are an accurate description of this transform,
* or the generic affine parameters in case of doubt.
*/
@Override
public ParameterValueGroup getParameterValues() {
- return isDefinitive || Semaphores.query(Semaphores.PROJCS) ? parameters : super.getParameterValues();
+ return isDefinitive || Semaphores.query(Semaphores.ENCLOSED_IN_OPERATION)
+ ? parameters : super.getParameterValues();
}
/**
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/AbstractCoordinateOperation.java [UTF-8] Tue May 12 13:50:17 2015
@@ -32,6 +32,7 @@ import org.opengis.referencing.operation
import org.opengis.referencing.operation.MathTransform;
import org.opengis.metadata.Identifier;
import org.apache.sis.parameter.Parameterized;
+import org.opengis.parameter.GeneralParameterValue;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.parameter.ParameterValueGroup;
import org.apache.sis.io.wkt.Formatter;
@@ -75,7 +76,7 @@ import java.util.Objects;
* <div class="section">Instantiation</div>
* This class is conceptually <cite>abstract</cite>, even if it is technically possible to instantiate it.
* Typical applications should create instances of the most specific subclass prefixed by {@code Default} instead.
- * An exception to this rule may occur when it is not possible to identify the exact CRS type.
+ * An exception to this rule may occur when it is not possible to identify the exact operation type.
*
* <div class="section">Immutability and thread safety</div>
* This base class is immutable and thus thread-safe if the property <em>values</em> (not necessarily the map itself)
@@ -587,13 +588,13 @@ public class AbstractCoordinateOperation
while (mt != null) {
if (mt instanceof Parameterized) {
final ParameterDescriptorGroup param;
- if (Semaphores.queryAndSet(Semaphores.PROJCS)) {
+ if (Semaphores.queryAndSet(Semaphores.ENCLOSED_IN_OPERATION)) {
throw new AssertionError(); // Should never happen.
}
try {
param = ((Parameterized) mt).getParameterDescriptors();
} finally {
- Semaphores.clear(Semaphores.PROJCS);
+ Semaphores.clear(Semaphores.ENCLOSED_IN_OPERATION);
}
if (param != null) {
return param;
@@ -621,13 +622,13 @@ public class AbstractCoordinateOperation
while (mt != null) {
if (mt instanceof Parameterized) {
final ParameterValueGroup param;
- if (Semaphores.queryAndSet(Semaphores.PROJCS)) {
+ if (Semaphores.queryAndSet(Semaphores.ENCLOSED_IN_OPERATION)) {
throw new AssertionError(); // Should never happen.
}
try {
param = ((Parameterized) mt).getParameterValues();
} finally {
- Semaphores.clear(Semaphores.PROJCS);
+ Semaphores.clear(Semaphores.ENCLOSED_IN_OPERATION);
}
if (param != null) {
return param;
@@ -729,9 +730,17 @@ public class AbstractCoordinateOperation
@Override
protected String formatTo(final Formatter formatter) {
super.formatTo(formatter);
+ formatter.newLine();
append(formatter, getSourceCRS(), WKTKeywords.SourceCRS);
append(formatter, getTargetCRS(), WKTKeywords.TargetCRS);
formatter.append(DefaultOperationMethod.castOrCopy(getMethod()));
+ final ParameterValueGroup parameters = getParameterValues();
+ if (parameters != null) {
+ formatter.newLine();
+ for (final GeneralParameterValue param : parameters.values()) {
+ WKTUtilities.append(param, formatter);
+ }
+ }
append(formatter, getInterpolationCRS(), WKTKeywords.InterpolationCRS);
final double accuracy = getLinearAccuracy();
if (accuracy > 0) {
@@ -759,7 +768,9 @@ public class AbstractCoordinateOperation
if (crs != null) {
formatter.append(new FormattableObject() {
@Override protected String formatTo(final Formatter formatter) {
+ formatter.indent(-1);
formatter.append(WKTUtilities.toFormattable(crs));
+ formatter.indent(+1);
return type;
}
});
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/DefaultOperationMethod.java [UTF-8] Tue May 12 13:50:17 2015
@@ -104,7 +104,8 @@ import java.util.Objects;
* @since 0.5
* @module
*
- * @see DefaultSingleOperation
+ * @see DefaultConversion
+ * @see DefaultTransformation
* @see org.apache.sis.referencing.operation.transform.MathTransformProvider
*/
public class DefaultOperationMethod extends AbstractIdentifiedObject implements OperationMethod {
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/SubTypes.java [UTF-8] Tue May 12 13:50:17 2015
@@ -145,8 +145,10 @@ final class SubTypes {
}
}
final Conversion conversion;
- if (type.isInstance(definition) && definition.getSourceCRS() == sourceCRS
- && definition.getTargetCRS() == targetCRS)
+ if (type.isInstance(definition)
+ && definition.getSourceCRS() == sourceCRS
+ && definition.getTargetCRS() == targetCRS
+ && definition.getMathTransform() != null)
{
conversion = definition;
} else if (CylindricalProjection.class.isAssignableFrom(type)) {
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/package-info.java [UTF-8] Tue May 12 13:50:17 2015
@@ -25,16 +25,18 @@
* sub-packages, but most users will not need to deal with them directly:</p>
*
* <ul>
- * <li>{@link org.apache.sis.referencing.operation.projection} for map projections</li>
- * <li>{@link org.apache.sis.referencing.operation.transform} for any transform other than map projections</li>
+ * <li>{@link org.apache.sis.referencing.operation.projection} — map projections,</li>
+ * <li>{@link org.apache.sis.referencing.operation.transform} — any transform other than map projections.</li>
* </ul>
*
* <div class="section">Apache SIS extensions</div>
* Some SIS implementations provide additional methods that are not part of OGC/ISO specifications:
*
* <ul>
- * <li>{@link org.apache.sis.referencing.operation.AbstractCoordinateOperation#getLinearAccuracy() AbstractCoordinateOperation.getLinearAccuracy()}</li>
- * <li>{@link org.apache.sis.referencing.operation.DefaultConversion#specialize DefaultConversion.specialize(Class, CoordinateReferenceSystem, CoordinateReferenceSystem, MathTransformFactory)}</li>
+ * <li>{@link org.apache.sis.referencing.operation.AbstractCoordinateOperation#getLinearAccuracy() AbstractCoordinateOperation.getLinearAccuracy()}
+ * — tries to convert the accuracy to metres,</li>
+ * <li>{@link org.apache.sis.referencing.operation.DefaultConversion#specialize DefaultConversion.specialize(…)}
+ * — changes a <cite>defining conversion</cite> into a complete conversion.</li>
* </ul>
*
* <div class="section">Apache SIS specific behavior</div>
@@ -78,6 +80,5 @@ import javax.xml.bind.annotation.adapter
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
import org.apache.sis.xml.Namespaces;
import org.apache.sis.internal.jaxb.gco.*;
-import org.apache.sis.internal.jaxb.referencing.*;
import org.apache.sis.internal.jaxb.metadata.EX_Extent;
import org.apache.sis.internal.jaxb.metadata.DQ_PositionalAccuracy;
Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/transform/ConcatenatedTransform.java [UTF-8] Tue May 12 13:50:17 2015
@@ -459,22 +459,20 @@ class ConcatenatedTransform extends Abst
* is more than one remaining step, even if all other transform steps are not parameterizable,
* would be a contract violation.</p>
*
- * <p>However in the special case where we are formatting {@code PROJCS} element, the above rule
- * is slightly relaxed. More specifically we ignore affine transforms in order to accept axis
- * swapping or unit conversions. This special case is internal to SIS implementation of WKT
- * formatter and should be unknown to users.</p>
- *
- * <p>See {@link org.apache.sis.referencing.operation.DefaultSingleOperation#getParameterValues()}
- * for the code where the above-cited special case is applied.</p>
+ * <p>However in the special case where we are getting the parameters of a {@code CoordinateOperation} instance
+ * through {@link org.apache.sis.referencing.operation.AbstractCoordinateOperation#getParameterValues()} method
+ * (often indirectly trough WKT formatting of a {@code "ProjectedCRS"} element), then the above rule is slightly
+ * relaxed: we ignore affine transforms in order to accept axis swapping or unit conversions. We do that in that
+ * particular case only because the coordinate systems given with the enclosing {@code CoordinateOperation} or
+ * {@code GeneralDerivedCRS} specify the axis swapping and unit conversions.
+ * This special case is internal to SIS implementation and should be unknown to users.</p>
*
* @return The parameterizable transform step, or {@code null} if none.
- *
- * @see org.apache.sis.referencing.operation.DefaultSingleOperation#simplify(MathTransform)
*/
private Parameterized getParameterised() {
Parameterized param = null;
final List<Object> transforms = getPseudoSteps();
- if (transforms.size() == 1 || Semaphores.query(Semaphores.PROJCS)) {
+ if (transforms.size() == 1 || Semaphores.query(Semaphores.ENCLOSED_IN_OPERATION)) {
for (final Object candidate : transforms) {
/*
* Search for non-linear parameters only, ignoring affine transforms and the matrices
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterDescriptorTest.java [UTF-8] Tue May 12 13:50:17 2015
@@ -144,7 +144,7 @@ public final strictfp class DefaultParam
* @param code The parameter identifier.
* @return The descriptor with the given EPSG identifier.
*/
- static DefaultParameterDescriptor<Double> createEPSG(final String name, final short code) {
+ public static DefaultParameterDescriptor<Double> createEPSG(final String name, final short code) {
final Map<String, Object> properties = properties(name);
assertNull(properties.put(DefaultParameterDescriptor.IDENTIFIERS_KEY,
new ImmutableIdentifier(HardCodedCitations.IOGP, Constants.EPSG, Short.toString(code))));
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/datum/HardCodedDatum.java [UTF-8] Tue May 12 13:50:17 2015
@@ -19,6 +19,7 @@ package org.apache.sis.referencing.datum
import java.util.Date;
import java.util.Map;
import java.util.HashMap;
+import javax.measure.unit.SI;
import javax.measure.unit.NonSI;
import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.datum.VerticalDatumType;
@@ -35,7 +36,7 @@ import static org.opengis.referencing.da
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.5
+ * @version 0.6
* @module
*/
public final strictfp class HardCodedDatum {
@@ -83,7 +84,7 @@ public final strictfp class HardCodedDat
* Earth Gravitational Model}.
*/
public static final DefaultGeodeticDatum WGS72 = new DefaultGeodeticDatum(
- properties("World Geodetic System 1972", "6322", "Satellite navigation."),
+ properties("World Geodetic System 1972", "6322", WGS84.getScope()),
new DefaultEllipsoid(GeodeticDatumMock.WGS84.getEllipsoid()), GREENWICH);
/**
@@ -96,6 +97,28 @@ public final strictfp class HardCodedDat
new DefaultEllipsoid(GeodeticDatumMock.NTF.getEllipsoid()), PARIS);
/**
+ * Tokyo 1918 datum (EPSG:6301). Ellipsoid is Bessel 1841 and prime meridian is Greenwich.
+ * Bursa-Wolf parameters to {@link #JGD2000} are (-146.414, 507.337, 680.507).
+ *
+ * @since 0.6
+ */
+ public static final DefaultGeodeticDatum TOKYO = new DefaultGeodeticDatum(
+ properties("Tokyo 1918", "6301", "Geodetic survey."),
+ DefaultEllipsoid.createFlattenedSphere(properties("Bessel 1841", "7004", null),
+ 6377397.155, 299.1528128, SI.METRE), GREENWICH);
+
+ /**
+ * Japanese Geodetic Datum 2000 datum (EPSG:6612). Ellipsoid is GRS 1980 and prime meridian is Greenwich.
+ * This is useful for testing datum shift from {@link #TOKYO}.
+ *
+ * @since 0.6
+ */
+ public static final DefaultGeodeticDatum JGD2000 = new DefaultGeodeticDatum(
+ properties("Japanese Geodetic Datum 2000", "6612", TOKYO.getScope()),
+ DefaultEllipsoid.createFlattenedSphere(properties("GRS 1980", "7019", null),
+ 6378137, 298.257222101, SI.METRE), GREENWICH);
+
+ /**
* Spherical datum based on GRS 1980 Authalic Sphere (EPSG:6047). Prime meridian is Greenwich.
*/
public static final DefaultGeodeticDatum SPHERE = new DefaultGeodeticDatum(
@@ -103,21 +126,21 @@ public final strictfp class HardCodedDat
new DefaultEllipsoid(GeodeticDatumMock.SPHERE.getEllipsoid()), GREENWICH);
/**
- * Mean sea level, which can be used as an approximation of geoid.
- */
- public static final DefaultVerticalDatum MEAN_SEA_LEVEL = new DefaultVerticalDatum(
- properties("Mean Sea Level", "5100", "Hydrography."),
- VerticalDatumType.GEOIDAL);
-
- /**
* Ellipsoid for measurements of height above the ellipsoid.
* This is not a valid datum according ISO 19111, but is used by Apache SIS for internal calculation.
*/
public static final DefaultVerticalDatum ELLIPSOID = new DefaultVerticalDatum(
- properties("Ellipsoid", null, "Not a valid datum."),
+ properties("Ellipsoid", null, SPHERE.getScope()),
VerticalDatumTypes.ELLIPSOIDAL);
/**
+ * Mean sea level, which can be used as an approximation of geoid.
+ */
+ public static final DefaultVerticalDatum MEAN_SEA_LEVEL = new DefaultVerticalDatum(
+ properties("Mean Sea Level", "5100", "Hydrography."),
+ VerticalDatumType.GEOIDAL);
+
+ /**
* Default datum for time measured since January 1st, 1970 at 00:00 UTC.
*/
public static final DefaultTemporalDatum UNIX = new DefaultTemporalDatum(
@@ -147,7 +170,7 @@ public final strictfp class HardCodedDat
/**
* Creates a map of properties for the given name and EPSG code.
*/
- private static Map<String,?> properties(final String name, final String code, final String scope) {
+ private static Map<String,?> properties(final String name, final String code, final CharSequence scope) {
final Map<String,Object> properties = new HashMap<>(4);
properties.put(NAME_KEY, name);
if (code != null) {
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/AbstractSingleOperationTest.java [UTF-8] Tue May 12 13:50:17 2015
@@ -41,7 +41,7 @@ import static org.opengis.test.Assert.*;
*/
@DependsOn({
DefaultOperationMethodTest.class,
- org.apache.sis.referencing.operation.transform.MathTransformsTest.class
+ MathTransformsTest.class
})
public final strictfp class AbstractSingleOperationTest extends TestCase {
/**
@@ -55,7 +55,7 @@ public final strictfp class AbstractSing
}
/**
- * Tests {@link OperationMethods#checkDimensions(OperationMethod, MathTransform, Map)}.
+ * Tests {@link AbstractSingleOperation#checkDimensions(OperationMethod, MathTransform, Map)}.
*/
@Test
public void testCheckDimensions() {
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultOperationMethodTest.java [UTF-8] Tue May 12 13:50:17 2015
@@ -19,6 +19,7 @@ package org.apache.sis.referencing.opera
import java.util.Map;
import java.util.HashMap;
import org.opengis.metadata.Identifier;
+import org.opengis.parameter.ParameterDescriptor;
import org.opengis.parameter.ParameterDescriptorGroup;
import org.opengis.referencing.operation.OperationMethod;
import org.apache.sis.io.wkt.Convention;
@@ -45,7 +46,8 @@ import static org.apache.sis.test.Refere
*/
@DependsOn({
DefaultFormulaTest.class,
- org.apache.sis.referencing.AbstractIdentifiedObjectTest.class
+ org.apache.sis.referencing.AbstractIdentifiedObjectTest.class,
+ org.apache.sis.parameter.DefaultParameterDescriptorGroupTest.class
})
public final strictfp class DefaultOperationMethodTest extends TestCase {
/**
@@ -54,11 +56,12 @@ public final strictfp class DefaultOpera
* @param method The operation name (example: "Mercator (variant A)").
* @param identifier The EPSG numeric identifier (example: "9804").
* @param formula Formula citation (example: "EPSG guidance note #7-2").
- * @param dimension The number of input and output dimension.
+ * @param dimension The number of input and output dimension, or {@code null}.
+ * @param parameters The parameters (can be empty).
* @return The operation method.
*/
- private static DefaultOperationMethod create(final String method, final String identifier, final String formula,
- final Integer dimension)
+ static DefaultOperationMethod create(final String method, final String identifier, final String formula,
+ final Integer dimension, final ParameterDescriptor<?>... parameters)
{
final Map<String,Object> properties = new HashMap<>(8);
assertNull(properties.put(OperationMethod.NAME_KEY, method));
@@ -68,15 +71,15 @@ public final strictfp class DefaultOpera
* The parameter group for a Mercator projection is actually not empty, but it is not the purpose of
* this class to test DefaultParameterDescriptorGroup. So we use an empty group of parameters here.
*/
- final ParameterDescriptorGroup parameters = new DefaultParameterDescriptorGroup(properties, 1, 1);
+ final ParameterDescriptorGroup pg = new DefaultParameterDescriptorGroup(properties, 1, 1, parameters);
/*
* NAME_KEY share the same Identifier instance for saving a little bit of memory.
* Then define the other properties to be given to OperationMethod.
*/
- assertNotNull(properties.put(OperationMethod.NAME_KEY, parameters.getName()));
+ assertNotNull(properties.put(OperationMethod.NAME_KEY, pg.getName()));
assertNull(properties.put(OperationMethod.IDENTIFIERS_KEY, new ImmutableIdentifier(HardCodedCitations.IOGP, "EPSG", identifier)));
assertNull(properties.put(OperationMethod.FORMULA_KEY, new DefaultCitation(formula)));
- return new DefaultOperationMethod(properties, dimension, dimension, parameters);
+ return new DefaultOperationMethod(properties, dimension, dimension, pg);
}
/**
@@ -151,6 +154,8 @@ public final strictfp class DefaultOpera
/**
* Tests {@link DefaultOperationMethod#toWKT()}.
+ * Since the WKT format of {@code OperationMethod} does not include parameters,
+ * we do not bother specifying the parameters in the object created here.
*/
@Test
@DependsOnMethod("testConstruction")
Added: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java?rev=1678946&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java (added)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java [UTF-8] Tue May 12 13:50:17 2015
@@ -0,0 +1,150 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.referencing.operation;
+
+import java.util.Map;
+import java.util.HashMap;
+import org.opengis.parameter.ParameterValueGroup;
+import org.opengis.referencing.datum.GeodeticDatum;
+import org.opengis.referencing.operation.OperationMethod;
+import org.apache.sis.internal.referencing.OperationMethods;
+import org.apache.sis.parameter.DefaultParameterDescriptorTest;
+import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.referencing.cs.HardCodedCS;
+import org.apache.sis.referencing.crs.DefaultGeocentricCRS;
+import org.apache.sis.referencing.datum.HardCodedDatum;
+import org.apache.sis.referencing.operation.matrix.Matrix4;
+import org.apache.sis.referencing.operation.transform.MathTransforms;
+import org.apache.sis.io.wkt.Convention;
+import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+import static org.apache.sis.test.MetadataAssert.*;
+
+
+/**
+ * Tests {@link DefaultTransformation}.
+ *
+ * @author Martin Desruisseaux (Geomatys)
+ * @since 0.6
+ * @version 0.6
+ * @module
+ */
+@DependsOn({
+ AbstractSingleOperationTest.class,
+ org.apache.sis.referencing.crs.DefaultGeocentricCRSTest.class
+})
+public final strictfp class DefaultTransformationTest extends TestCase {
+ /**
+ * Creates a geocentric CRS using the given datum.
+ */
+ private static DefaultGeocentricCRS createCRS(final GeodeticDatum datum) {
+ return new DefaultGeocentricCRS(
+ IdentifiedObjects.getProperties(datum, DefaultGeocentricCRS.IDENTIFIERS_KEY),
+ datum, HardCodedCS.GEOCENTRIC);
+ }
+
+ /**
+ * Creates a “Tokyo to JGD2000 (GSI)” transformation.
+ */
+ private static DefaultTransformation createGeocentricTranslation() {
+ final Matrix4 translation = new Matrix4();
+ final OperationMethod method = DefaultOperationMethodTest.create(
+ "Geocentric translations", "1031", "EPSG guidance note #7-2", 3,
+ DefaultParameterDescriptorTest.createEPSG("X-axis translation", (short) 8605),
+ DefaultParameterDescriptorTest.createEPSG("Y-axis translation", (short) 8606),
+ DefaultParameterDescriptorTest.createEPSG("Z-axis translation", (short) 8607));
+ final ParameterValueGroup pg = method.getParameters().createValue();
+ pg.parameter("X-axis translation").setValue(translation.m02 = -146.414);
+ pg.parameter("Y-axis translation").setValue(translation.m12 = 507.337);
+ pg.parameter("Z-axis translation").setValue(translation.m22 = 680.507);
+ final Map<String, Object> properties = new HashMap<>(4);
+ properties.put(DefaultTransformation.NAME_KEY, "Tokyo to JGD2000 (GSI)");
+ properties.put(OperationMethods.PARAMETERS_KEY, pg);
+ return new DefaultTransformation(properties,
+ createCRS(HardCodedDatum.TOKYO), // SourceCRS
+ createCRS(HardCodedDatum.JGD2000), // TargetCRS
+ null, // InterpolationCRS
+ method,
+ MathTransforms.linear(translation));
+ }
+
+ /**
+ * Tests WKT formatting.
+ */
+ @Test
+ public void testWKT() {
+ final DefaultTransformation op = createGeocentricTranslation();
+
+ assertWktEquals(
+ "CoordinateOperation[“Tokyo to JGD2000 (GSI)”,\n" +
+ " SourceCRS[GeodeticCRS[“Tokyo 1918”,\n" +
+ " Datum[“Tokyo 1918”,\n" +
+ " Ellipsoid[“Bessel 1841”, 6377397.155, 299.1528128, LengthUnit[“metre”, 1]]],\n" +
+ " PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]],\n" +
+ " CS[“Cartesian”, 3],\n" +
+ " Axis[“(X)”, geocentricX, Order[1]],\n" +
+ " Axis[“(Y)”, geocentricY, Order[2]],\n" +
+ " Axis[“(Z)”, geocentricZ, Order[3]],\n" +
+ " LengthUnit[“metre”, 1]]],\n" +
+ " TargetCRS[GeodeticCRS[“Japanese Geodetic Datum 2000”,\n" +
+ " Datum[“Japanese Geodetic Datum 2000”,\n" +
+ " Ellipsoid[“GRS 1980”, 6378137.0, 298.257222101, LengthUnit[“metre”, 1]]],\n" +
+ " PrimeMeridian[“Greenwich”, 0.0, AngleUnit[“degree”, 0.017453292519943295]],\n" +
+ " CS[“Cartesian”, 3],\n" +
+ " Axis[“(X)”, geocentricX, Order[1]],\n" +
+ " Axis[“(Y)”, geocentricY, Order[2]],\n" +
+ " Axis[“(Z)”, geocentricZ, Order[3]],\n" +
+ " LengthUnit[“metre”, 1]]],\n" +
+ " Method[“Geocentric translations”, Id[“EPSG”, 1031, Citation[“IOGP”]]],\n" +
+ " Parameter[“X-axis translation”, -146.414, Id[“EPSG”, 8605]],\n" +
+ " Parameter[“Y-axis translation”, 507.337, Id[“EPSG”, 8606]],\n" +
+ " Parameter[“Z-axis translation”, 680.507, Id[“EPSG”, 8607]]]", op);
+
+ assertWktEquals(Convention.WKT2_SIMPLIFIED,
+ "CoordinateOperation[“Tokyo to JGD2000 (GSI)”,\n" +
+ " SourceCRS[GeodeticCRS[“Tokyo 1918”,\n" +
+ " Datum[“Tokyo 1918”,\n" +
+ " Ellipsoid[“Bessel 1841”, 6377397.155, 299.1528128]],\n" +
+ " CS[“Cartesian”, 3],\n" +
+ " Axis[“(X)”, geocentricX],\n" +
+ " Axis[“(Y)”, geocentricY],\n" +
+ " Axis[“(Z)”, geocentricZ],\n" +
+ " Unit[“metre”, 1]]],\n" +
+ " TargetCRS[GeodeticCRS[“Japanese Geodetic Datum 2000”,\n" +
+ " Datum[“Japanese Geodetic Datum 2000”,\n" +
+ " Ellipsoid[“GRS 1980”, 6378137.0, 298.257222101]],\n" +
+ " CS[“Cartesian”, 3],\n" +
+ " Axis[“(X)”, geocentricX],\n" +
+ " Axis[“(Y)”, geocentricY],\n" +
+ " Axis[“(Z)”, geocentricZ],\n" +
+ " Unit[“metre”, 1]]],\n" +
+ " Method[“Geocentric translations”],\n" +
+ " Parameter[“X-axis translation”, -146.414],\n" +
+ " Parameter[“Y-axis translation”, 507.337],\n" +
+ " Parameter[“Z-axis translation”, 680.507]]", op);
+ }
+
+ /**
+ * Tests serialization.
+ */
+ @Test
+ public void testSerialization() {
+ assertSerializedEquals(createGeocentricTranslation());
+ }
+}
Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/DefaultTransformationTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain;charset=UTF-8
Modified: sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Tue May 12 13:50:17 2015
@@ -128,6 +128,7 @@ import org.junit.BeforeClass;
org.apache.sis.referencing.crs.DefaultGeographicCRSTest.class,
org.apache.sis.referencing.crs.DefaultVerticalCRSTest.class,
org.apache.sis.referencing.crs.DefaultTemporalCRSTest.class,
+ org.apache.sis.referencing.operation.DefaultTransformationTest.class,
org.apache.sis.referencing.crs.DefaultProjectedCRSTest.class,
org.apache.sis.referencing.crs.DefaultDerivedCRSTest.class,
org.apache.sis.referencing.crs.SubTypesTest.class,
Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java?rev=1678946&r1=1678945&r2=1678946&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/system/Semaphores.java [UTF-8] Tue May 12 13:50:17 2015
@@ -24,7 +24,7 @@ package org.apache.sis.internal.system;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.5
- * @version 0.5
+ * @version 0.6
* @module
*/
public final class Semaphores {
@@ -39,11 +39,11 @@ public final class Semaphores {
public static final byte COMPARING = 1;
/**
- * A flag to indicate that {@link org.apache.sis.referencing.operation.DefaultSingleOperation}
- * is querying {@code org.apache.sis.referencing.operation.transform.ConcatenatedTransform} in
- * the intend to format WKT (normally a {@code "PROJCS"} element).
+ * A flag to indicate that {@link org.apache.sis.referencing.operation.AbstractCoordinateOperation}
+ * is querying parameters of a {@code MathTransform} enclosed in the operation. This is often in the
+ * intend to format WKT of a {@code "ProjectedCRS"} element.
*/
- public static final byte PROJCS = 2;
+ public static final byte ENCLOSED_IN_OPERATION = 2;
/**
* A flag to indicate that empty collections should be returned as {@code null}. Returning null
@@ -71,7 +71,7 @@ public final class Semaphores {
/**
* Returns {@code true} if the given flag is set.
*
- * @param flag One of {@link #COMPARING}, {@link #PROJCS} or other constants.
+ * @param flag One of {@link #COMPARING}, {@link #ENCLOSED_IN_OPERATION} or other constants.
* @return {@code true} if the given flag is set.
*/
public static boolean query(final byte flag) {
@@ -82,7 +82,7 @@ public final class Semaphores {
/**
* Sets the given flag.
*
- * @param flag One of {@link #COMPARING}, {@link #PROJCS} or other constants.
+ * @param flag One of {@link #COMPARING}, {@link #ENCLOSED_IN_OPERATION} or other constants.
* @return {@code true} if the given flag was already set.
*/
public static boolean queryAndSet(final byte flag) {
@@ -99,7 +99,7 @@ public final class Semaphores {
/**
* Clears the given flag.
*
- * @param flag One of {@link #COMPARING}, {@link #PROJCS} or other constants.
+ * @param flag One of {@link #COMPARING}, {@link #ENCLOSED_IN_OPERATION} or other constants.
*/
public static void clear(final byte flag) {
final Semaphores s = FLAGS.get();