Author: desruisseaux
Date: Thu Sep 3 13:15:44 2015
New Revision: 1701013
URL: http://svn.apache.org/r1701013
Log:
First draft of a <gml:Transformation> test.
Added:
sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Transformation.xml
(with props)
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Equirectangular.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator1SP.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameter.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -43,9 +43,9 @@ import org.apache.sis.internal.jaxb.Cont
* JAXB adapter mapping implementing class to the GeoAPI interface. See
* package documentation for more information about JAXB and interface.
*
- * <p>This class provides an additional {@link
#replacement(GeneralParameterDescriptor, GeneralParameterDescriptor)}
- * method building a unique descriptor instance when the same descriptor is
declared in more than one place in the
- * GML document. Some examples of duplications are:</p>
+ * <p>This class provides additional {@code merge(…)} methods for building a
unique descriptor
+ * instance when the same descriptor is declared in more than one place in the
GML document.
+ * Some examples of duplications are:</p>
*
* <ul>
* <li>The descriptors listed under the {@code <gml:group>} element, which
duplicate the descriptors listed
@@ -171,8 +171,8 @@ public final class CC_GeneralOperationPa
* @param complete The descriptor to use for completing missing
information.
* @return The descriptor to use. May be one of the arguments given to
this method, or a new instance.
*/
- static GeneralParameterDescriptor replacement(final
GeneralParameterDescriptor provided,
- final
GeneralParameterDescriptor complete)
+ static GeneralParameterDescriptor merge(final GeneralParameterDescriptor
provided,
+ final GeneralParameterDescriptor
complete)
{
if (provided == complete) {
return complete;
@@ -258,7 +258,7 @@ public final class CC_GeneralOperationPa
*/
GeneralParameterDescriptor predefined =
complete.descriptor(p.getName().getCode());
if (predefined != null) { // Safety in case 'complete' is a
user's implementation.
- canSubstitute &= (provided[i] = replacement(p,
predefined)) == predefined;
+ canSubstitute &= (provided[i] = merge(p, predefined)) ==
predefined;
if (!included.add(predefined)) {
throw new CorruptedObjectException(predefined); //
Broken hashCode/equals, or object mutated.
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroup.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -101,15 +101,27 @@ public final class CC_OperationParameter
/**
* Invoked by {@link
DefaultParameterDescriptorGroup#setDescriptors(GeneralParameterDescriptor[])}
* for merging into a single set the descriptors which are repeated twice
in a GML document.
- * The descriptors are:
*
+ * <p>The {@code descriptors} argument gives the descriptors listed
explicitely inside a
+ * {@code <gml:OperationParameterGroup>} or {@code <gml:OperationMethod>}
element. Those
+ * descriptors are said "incomplete" (from SIS point of view) because they
are missing the
+ * {@link ParameterDescriptor#getValueClass()} property, which does not
exist in GML but
+ * is mandatory for us. However an exception to this "incompleteness"
happen when SIS has
+ * been able to match the {@code <gml:OperationMethod>} parent to one of
the pre-defined
+ * operations in the {@link org.apache.sis.internal.referencing.provider}
package.</p>
+ *
+ * <p>The {@code fromValues} argument gives the descriptors declared in
each {@code <gml:ParameterValue>}
+ * instances of a {@code <gml:ParameterValueGroup>} or {@code
<gml:AbstractSingleOperation>} element.
+ * Contrarily to the {@code descriptors} argument, the {@code fromValues}
instances should have non-null
+ * {@link ParameterDescriptor#getValueClass()} property inferred by SIS
from the parameter value.</p>
+ *
+ * <p>So the preferred descriptors from more complete to less complete
are:</p>
* <ol>
- * <li>The descriptors declared explicitely in the {@code
ParameterDescriptorGroup}.</li>
- * <li>The descriptors declared in the {@code ParameterValue} instances
of the {@code ParameterValueGroup}.</li>
+ * <li>{@code descriptors} if and only if they contain pre-defined
parameters inferred by SIS from the {@code <gml:OperationMethod>} name.</li>
+ * <li>{@code fromValues}, which contain the descriptors declared in the
{@code <gml:ParameterValue>} instances.</li>
+ * <li>{@code descriptors}, which contain the descriptor listed in
{@code <gml:OperationParameterGroup>} or {@code <gml:OperationMethod>}.</li>
* </ol>
*
- * The later are more complete than the former, because they allow us to
infer the {@code valueClass} property.
- *
* <div class="note"><b>Note:</b>
* this code is defined in this {@code CC_OperationParameterGroup} class
instead than in the
* {@link DefaultParameterDescriptorGroup} class in the hope to reduce the
amount of code
@@ -147,45 +159,45 @@ public final class CC_OperationParameter
/*
* Verify if any descriptors found in the ParameterValue instances
could replace the descriptors in the group.
* We give precedence to the descriptors having a non-null
'valueClass' property, which normally appear in the
- * 'valids' array.
+ * 'fromValues' array.
*/
- for (GeneralParameterDescriptor valid : fromValues) {
- final String name = valid.getName().getCode();
- GeneralParameterDescriptor previous = union.put(name, valid);
+ for (final GeneralParameterDescriptor valueDescriptor : fromValues) {
+ final String name = valueDescriptor.getName().getCode();
+ GeneralParameterDescriptor complete = valueDescriptor;
+ GeneralParameterDescriptor previous = union.put(name, complete);
if (previous != null) {
if (previous instanceof ParameterDescriptor<?>) {
- verifyEquivalence(name, valid instanceof
ParameterDescriptor<?>);
+ verifyEquivalence(name, complete instanceof
ParameterDescriptor<?>);
final Class<?> valueClass = ((ParameterDescriptor<?>)
previous).getValueClass();
if (valueClass != null) {
- final Class<?> r = ((ParameterDescriptor<?>)
valid).getValueClass();
+ /*
+ * This may happen if the 'descriptors' argument
contain the parameters of a pre-defined
+ * method from the
'org.apache.sis.internal.referencing.provider' package instead than a
+ * descriptor from the GML file. In such case,
presume that 'previous' is actually more
+ * complete than 'complete'.
+ *
+ * Note that 'r' should never be null unless JAXB
unmarshalled the elements in reverse
+ * order (e.g. <gml:ParameterValue> before
<gml:OperationMethod>). Since this behavior
+ * may depend on JAXB implementation, we are better to
check for such case.
+ */
+ final Class<?> r = ((ParameterDescriptor<?>)
complete).getValueClass();
if (r != null) {
- /*
- * Should never happen unless the same (according
its name) ParameterValue appears
- * more than once in the 'valids' array, or unless
this method is invoked more
- * often than expected.
- */
verifyEquivalence(name, valueClass == r);
- } else {
- /*
- * Should never happen unless JAXB unmarshalled
the elements in reverse order
- * (i.e. ParameterValue before
ParameterDescriptorGroup). Since this behavior
- * may depend on JAXB implementation, we are
better to check for such case.
- * Restore the previous value in the map and swap
'previous' with 'replacement'.
- */
- previous = union.put(name, valid = previous);
}
+ // Restore the previous value in the map and swap
'previous' with 'replacement'.
+ previous = union.put(name, complete = previous);
}
} else if (previous instanceof ParameterDescriptorGroup) {
- verifyEquivalence(name, valid instanceof
ParameterDescriptorGroup);
+ verifyEquivalence(name, complete instanceof
ParameterDescriptorGroup);
}
/*
* Verify that the replacement contains at least all the
information provided by the previous
* descriptor. The replacement is allowed to contain more
information however.
*/
- final GeneralParameterDescriptor replacement =
CC_GeneralOperationParameter.replacement(previous, valid);
- if (replacement != valid) {
+ final GeneralParameterDescriptor replacement =
CC_GeneralOperationParameter.merge(previous, complete);
+ if (replacement != valueDescriptor) {
union.put(name, replacement);
- if (replacements.put(valid, replacement) != null) {
+ if (replacements.put(valueDescriptor, replacement) !=
null) {
// Should never happen, unless the parameter name
changed during execution of this loop.
throw new CorruptedObjectException(name);
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/AbstractProvider.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -114,12 +114,13 @@ abstract class AbstractProvider extends
}
/**
- * Creates a descriptor for a constant value in degrees.
+ * Creates a descriptor for a 0 constant value in degrees.
*
* @see MapProjection#validate(ParameterDescriptor, double)
*/
- static ParameterDescriptor<Double> createConstant(final ParameterBuilder
builder, final Double constant) {
- return builder.createBounded(MeasurementRange.create(constant, true,
constant, true, NonSI.DEGREE_ANGLE), constant);
+ static ParameterDescriptor<Double> createZeroConstant(final
ParameterBuilder builder) {
+ final Double zero = +0.0;
+ return builder.createBounded(MeasurementRange.create(-0.0, true, zero,
true, NonSI.DEGREE_ANGLE), zero);
}
/**
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Equirectangular.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Equirectangular.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Equirectangular.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Equirectangular.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -163,7 +163,7 @@ public final class Equirectangular exten
* still see it in use sometime. However, taking inspiration from the
practice done in "Mercator (1SP)"
* projection, we require that the parameter value must be zero.
*/
- LATITUDE_OF_ORIGIN = createConstant(builder // Was used by
EPSG:9823 (also EPSG:9842).
+ LATITUDE_OF_ORIGIN = createZeroConstant(builder // Was used by
EPSG:9823 (also EPSG:9842).
.addIdentifier("8801")
.addName("Latitude of natural origin")
.addName(Citations.OGC, "latitude_of_origin")
@@ -172,7 +172,7 @@ public final class Equirectangular exten
.addName(Citations.GEOTIFF, "ProjCenterLat")
.addName(Citations.PROJ4, "lat_0")
.setRemarks(Messages.formatInternational(Messages.Keys.ConstantProjParameterValue_1,
0))
- .setRequired(false), 0.0);
+ .setRequired(false));
// Do not declare the ESRI "Equidistant_Cylindrical" projection name
below,
// for avoiding confusion with EPSG "Equidistant Cylindrical"
ellipsoidal projection.
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/MapProjection.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -47,7 +47,6 @@ import org.apache.sis.util.resources.Mes
import static org.opengis.metadata.Identifier.AUTHORITY_KEY;
// Branch-dependent imports
-import java.util.Objects;
/**
@@ -133,7 +132,7 @@ public abstract class MapProjection exte
* @param value The parameter value in the units given by the descriptor.
* @throws IllegalArgumentException if the given value is out of bounds.
*
- * @see #createConstant(ParameterBuilder, Double)
+ * @see #createZeroConstant(ParameterBuilder)
*/
public static void validate(final ParameterDescriptor<? extends Number>
descriptor, final double value)
throws IllegalArgumentException
@@ -144,7 +143,9 @@ public abstract class MapProjection exte
}
final Comparable<? extends Number> min = descriptor.getMinimumValue();
final Comparable<? extends Number> max = descriptor.getMaximumValue();
- if (!Objects.equals(min, max)) {
+ final double minValue = (min instanceof Number) ? ((Number)
min).doubleValue() : Double.NaN;
+ final double maxValue = (max instanceof Number) ? ((Number)
max).doubleValue() : Double.NaN;
+ if (value < minValue || value > maxValue) {
/*
* RATIONAL: why we do not check the bounds if (min == max):
* The only case when our descriptor have (min == max) is when a
parameter can only be zero,
@@ -152,11 +153,9 @@ public abstract class MapProjection exte
* But in some cases, it would be possible to deal with non-zero
values, even if in principle
* we should not. In such case we let the caller decides.
*
- * Above check should be revisited if
createConstant(ParameterBuilder, Double) is modified.
+ * Above check should be revisited if
createZeroConstant(ParameterBuilder) is modified.
*/
- if ((min instanceof Number && !(value >= ((Number)
min).doubleValue())) ||
- (max instanceof Number && !(value <= ((Number)
max).doubleValue())))
- {
+ if (minValue != maxValue) { // Compare as 'double' because we
want (-0 == +0) to be true.
throw new
IllegalArgumentException(Errors.format(Errors.Keys.ValueOutOfRange_4,
descriptor.getName(), min, max, value));
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator1SP.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator1SP.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator1SP.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator1SP.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -66,9 +66,9 @@ public final class Mercator1SP extends A
static final ParameterDescriptorGroup PARAMETERS;
static {
final ParameterBuilder builder = builder();
- LATITUDE_OF_ORIGIN =
createConstant(builder.addNamesAndIdentifiers(Equirectangular.LATITUDE_OF_ORIGIN)
+ LATITUDE_OF_ORIGIN =
createZeroConstant(builder.addNamesAndIdentifiers(Equirectangular.LATITUDE_OF_ORIGIN)
.rename(Citations.GEOTIFF, "NatOriginLat")
- .setRemarks(Equirectangular.LATITUDE_OF_ORIGIN.getRemarks()),
0.0);
+ .setRemarks(Equirectangular.LATITUDE_OF_ORIGIN.getRemarks()));
LONGITUDE_OF_ORIGIN =
createLongitude(builder.addNamesAndIdentifiers(Equirectangular.LONGITUDE_OF_ORIGIN)
.rename(Citations.GEOTIFF, "NatOriginLong"));
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/provider/Mercator2SP.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -77,9 +77,9 @@ public final class Mercator2SP extends A
*/
builder.setRequired(false); // Will apply to all remaining parameters.
final InternationalString remarks = notFormalParameter("Mercator
(variant A)");
- final ParameterDescriptor<Double> latitudeOfOrigin =
createConstant(builder
+ final ParameterDescriptor<Double> latitudeOfOrigin =
createZeroConstant(builder
.addNamesAndIdentifiers(Mercator1SP.LATITUDE_OF_ORIGIN)
- .setRemarks(remarks), 0.0);
+ .setRemarks(remarks));
/*
* Remove the EPSG name and identifier at least for the scale factor,
because its meaning does not fit well
* in this context. The EPSG name is "Scale factor at natural origin"
while actually the scale factor applied
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/ParameterValueList.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -34,6 +34,7 @@ import org.opengis.metadata.Identifier;
import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.ArgumentChecks;
import org.apache.sis.util.resources.Errors;
+import org.apache.sis.referencing.IdentifiedObjects;
/**
@@ -238,14 +239,15 @@ final class ParameterValueList extends A
* parameter name was not found, or the parameter descriptor does
not matches.
*/
final Identifier name = desc.getName();
+ final String code = name.getCode();
for (final GeneralParameterDescriptor descriptor : descriptors) {
- if (name.equals(descriptor.getName())) {
+ if (IdentifiedObjects.isHeuristicMatchForName(descriptor,
code)) {
throw new IllegalArgumentException(Errors.format(
Errors.Keys.MismatchedParameterDescriptor_1,
name));
}
}
throw new
InvalidParameterNameException(Errors.format(Errors.Keys.ParameterNotFound_2,
- Verifier.getDisplayName(descriptor), name),
name.getCode());
+ Verifier.getDisplayName(descriptor), name), code);
}
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_GeneralOperationParameterTest.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -123,20 +123,20 @@ public final strictfp class CC_GeneralOp
public void testParameterSubstitution() throws JAXBException {
ParameterDescriptor<?> provided = unmarshal("Optional parameter",
null);
ParameterDescriptor<?> complete = create("Optional parameter", null,
false, null);
- assertSame("Trivial case.", complete,
CC_GeneralOperationParameter.replacement(complete, complete));
- assertSame("Same properties.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ assertSame("Trivial case.", complete,
CC_GeneralOperationParameter.merge(complete, complete));
+ assertSame("Same properties.", complete,
CC_GeneralOperationParameter.merge(provided, complete));
complete = create("OptionalParameter", null, false, null);
- assertSame("Slightly different name.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ assertSame("Slightly different name.", complete,
CC_GeneralOperationParameter.merge(provided, complete));
complete = create("Optional parameter", null, false, 3);
- assertSame("With default value.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ assertSame("With default value.", complete,
CC_GeneralOperationParameter.merge(provided, complete));
complete = create("Optional parameter", "More details here.", false,
null);
- assertSame("With additional property.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ assertSame("With additional property.", complete,
CC_GeneralOperationParameter.merge(provided, complete));
provided = unmarshal("Optional parameter", "More details here.");
- assertSame("With same remark.", complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ assertSame("With same remark.", complete,
CC_GeneralOperationParameter.merge(provided, complete));
}
/**
@@ -150,7 +150,7 @@ public final strictfp class CC_GeneralOp
public void testParameterMerge() throws JAXBException {
ParameterDescriptor<?> provided = unmarshal("Test parameter", null);
ParameterDescriptor<?> complete = create("Test parameter", null, true,
null);
- ParameterDescriptor<?> merged = (ParameterDescriptor<?>)
CC_GeneralOperationParameter.replacement(provided, complete);
+ ParameterDescriptor<?> merged = (ParameterDescriptor<?>)
CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame("Different obligation.", complete, merged);
assertSame ("name", complete.getName(),
merged.getName());
assertEquals ("minimumOccurs", 0,
merged.getMinimumOccurs()); // From provided descriptor.
@@ -159,11 +159,11 @@ public final strictfp class CC_GeneralOp
assertNull ("remarks",
merged.getRemarks());
complete = create("Test parameter", null, false, null);
- assertSame(complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ assertSame(complete, CC_GeneralOperationParameter.merge(provided,
complete));
// Above assertion was tested by testParameterSubstitutions(), but was
verified again here
// for making sure that the following assertion verifies the effect of
the remarks alone.
provided = unmarshal("Test parameter", "More details here.");
- merged = (ParameterDescriptor<?>)
CC_GeneralOperationParameter.replacement(provided, complete);
+ merged = (ParameterDescriptor<?>)
CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame("Different remark.", complete, merged);
assertSame ("name", complete.getName(),
merged.getName());
assertEquals ("minimumOccurs", 0,
merged.getMinimumOccurs());
@@ -195,7 +195,7 @@ public final strictfp class CC_GeneralOp
create("Parameter C", "Remarks C.", false, 5),
create("Parameter D", "Remarks D.", false, 6));
- assertSame(complete,
CC_GeneralOperationParameter.replacement(provided, complete));
+ assertSame(complete, CC_GeneralOperationParameter.merge(provided,
complete));
}
/**
@@ -223,7 +223,7 @@ public final strictfp class CC_GeneralOp
create("Parameter D", "Remarks D.", false, 6));
final ParameterDescriptorGroup merged =
- (ParameterDescriptorGroup)
CC_GeneralOperationParameter.replacement(provided, complete);
+ (ParameterDescriptorGroup)
CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame(complete, provided);
assertSame ("name", complete.getName(),
merged.getName());
assertSame ("remarks", complete.getRemarks(),
merged.getRemarks());
@@ -262,7 +262,7 @@ public final strictfp class CC_GeneralOp
create("Parameter C", null, false, 5));
final ParameterDescriptorGroup merged =
- (ParameterDescriptorGroup)
CC_GeneralOperationParameter.replacement(provided, complete);
+ (ParameterDescriptorGroup)
CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame(complete, provided);
assertSame ("name", complete.getName(),
merged.getName());
assertSame ("remarks", complete.getRemarks(),
merged.getRemarks());
@@ -305,7 +305,7 @@ public final strictfp class CC_GeneralOp
listener.maximumLogCount = 1;
final ParameterDescriptorGroup merged =
- (ParameterDescriptorGroup)
CC_GeneralOperationParameter.replacement(provided, complete);
+ (ParameterDescriptorGroup)
CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame(complete, provided);
assertSame ("name", complete.getName(),
merged.getName());
assertSame ("remarks", complete.getRemarks(),
merged.getRemarks());
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/jaxb/referencing/CC_OperationParameterGroupTest.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -109,30 +109,11 @@ public final strictfp class CC_Operation
*/
@Test
public void testSubtitution() throws JAXBException {
- final ParameterDescriptorGroup fromXML = unmarshal();
- final ParameterDescriptor<?>[] expected = create(REMARK);
- final UnmodifiableArrayList<GeneralParameterDescriptor> fromValues =
UnmodifiableArrayList.wrap(expected);
-
- // Normal usage: merge to existing descriptors the more complete
information found in parameter values.
- verifySubtitution(fromXML.descriptors(), fromValues, expected);
-
- // Unusual case, tested for safety: the existing descriptors were
actually more complete.
- verifySubtitution(fromValues, fromXML.descriptors(), expected);
- }
-
- /**
- * Implementation of {@link #testSubtitution()}.
- *
- * @param descriptors Simulates the descriptors already present in a
{@code ParameterDescriptorGroup}.
- * @param fromValues Simulates the descriptors created from {@code
ParameterValue} instances.
- * @param expected The expected descriptors.
- */
- private static void verifySubtitution(final
List<GeneralParameterDescriptor> descriptors,
- final
List<GeneralParameterDescriptor> fromValues,
- final GeneralParameterDescriptor[]
expected)
- {
+ final ParameterDescriptor<?>[] expected = create(REMARK);
+ final List<GeneralParameterDescriptor> fromXML =
unmarshal().descriptors();
+ final List<GeneralParameterDescriptor> fromValues =
UnmodifiableArrayList.wrap(expected);
final Map<GeneralParameterDescriptor,GeneralParameterDescriptor>
replacements = new IdentityHashMap<>(4);
- final GeneralParameterDescriptor[] merged =
CC_OperationParameterGroup.merge(descriptors,
+ final GeneralParameterDescriptor[] merged =
CC_OperationParameterGroup.merge(fromXML,
fromValues.toArray(new
GeneralParameterDescriptor[fromValues.size()]), replacements);
assertTrue("Expected no replacement.", replacements.isEmpty());
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/provider/MapProjectionTest.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -141,8 +141,7 @@ public final strictfp class MapProjectio
* This test is mostly for {@link Equirectangular#LATITUDE_OF_ORIGIN}.
*/
private static void assertIsForcedToZero(final ParameterDescriptor<?>
parameter) {
- final Double zero = 0.0;
- assertEquals("minimumValue", zero, parameter.getMinimumValue());
- assertEquals("maximumValue", zero, parameter.getMaximumValue());
+ assertEquals("minimumValue", -0.0, parameter.getMinimumValue());
+ assertEquals("maximumValue", +0.0, parameter.getMaximumValue());
}
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java?rev=1701013&r1=1701012&r2=1701013&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/OperationMarshallingTest.java
[UTF-8] Thu Sep 3 13:15:44 2015
@@ -135,6 +135,7 @@ public final strictfp class OperationMar
assertEquals("name", "World Mercator", c.getName().getCode());
assertEquals("identifier", "3395",
getSingleton(c.getIdentifiers()).getCode());
assertEquals("scope", "Very small scale mapping.",
String.valueOf(c.getScope()));
+ assertNull ("operationVersion", c.getOperationVersion());
final GeographicBoundingBox e = (GeographicBoundingBox)
getSingleton(c.getDomainOfValidity().getGeographicElements());
assertEquals("eastBoundLongitude", +180, e.getEastBoundLongitude(),
STRICT);
@@ -179,4 +180,19 @@ public final strictfp class OperationMar
assertSame("method.descriptor", descriptor,
method.getParameters().descriptor(name));
assertEquals("value", expectedValue, parameter.doubleValue(), STRICT);
}
+
+ /**
+ * Tests unmarshalling of a transformation.
+ *
+ * @throws JAXBException if an error occurred during marshalling or
unmarshalling.
+ */
+ @Test
+ @DependsOnMethod("testConversionUnmarshalling")
+ public void testTransformationUnmarshalling() throws JAXBException {
+ final DefaultTransformation c =
unmarshalFile(DefaultTransformation.class, "Transformation.xml");
+ assertEquals("name", "NTF (Paris) to NTF (1)", c.getName().getCode());
+ assertEquals("identifier", "1763",
getSingleton(c.getIdentifiers()).getCode());
+ assertEquals("scope", "Change of prime meridian.",
String.valueOf(c.getScope()));
+ assertEquals("operationVersion", "IGN-Fra", c.getOperationVersion());
+ }
}
Added:
sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Transformation.xml
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Transformation.xml?rev=1701013&view=auto
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Transformation.xml
(added)
+++
sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Transformation.xml
Thu Sep 3 13:15:44 2015
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+
+<gml:Transformation xsi:schemaLocation = "http://www.opengis.net/gml/3.2
http://schemas.opengis.net/gml/3.2.1/datums.xsd"
+ xmlns:gml = "http://www.opengis.net/gml/3.2"
+ xmlns:xsi =
"http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xlink = "http://www.w3.org/1999/xlink"
+ gml:id = "toGreenwich">
+
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:coordinateOperation:EPSG::1763</gml:identifier>
+ <gml:name>NTF (Paris) to NTF (1)</gml:name>
+ <gml:scope>Change of prime meridian.</gml:scope>
+ <gml:operationVersion>IGN-Fra</gml:operationVersion>
+
+ <!--
+ This XML file defines a longitude rotation from the source CRS below to
+ a target CRS identical to the source CRS except for the prime meridian.
+ -->
+ <gml:sourceCRS>
+ <gml:GeodeticCRS gml:id="Paris">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:crs:EPSG::4807</gml:identifier>
+ <gml:name>NTF (Paris)</gml:name>
+ <gml:scope>Geodetic survey.</gml:scope>
+ <gml:ellipsoidalCS>
+ <gml:EllipsoidalCS gml:id="CoordinateSystem">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:cs:EPSG::6422</gml:identifier>
+ <gml:name>Latitude (north), Longitude (east)</gml:name>
+ <gml:axis>
+ <gml:CoordinateSystemAxis gml:id="Ï"
uom="urn:ogc:def:uom:EPSG::9122">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:axis:EPSG::106</gml:identifier>
+ <gml:name>Geodetic latitude</gml:name>
+ <gml:axisAbbrev>Ï</gml:axisAbbrev>
+ <gml:axisDirection codeSpace="EPSG">north</gml:axisDirection>
+ <gml:rangeMeaning codeSpace="EPSG">exact</gml:rangeMeaning>
+ </gml:CoordinateSystemAxis>
+ </gml:axis>
+ <gml:axis>
+ <gml:CoordinateSystemAxis gml:id="λ"
uom="urn:ogc:def:uom:EPSG::9122">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:axis:EPSG::107</gml:identifier>
+ <gml:name>Geodetic longitude</gml:name>
+ <gml:axisAbbrev>λ</gml:axisAbbrev>
+ <gml:axisDirection codeSpace="EPSG">east</gml:axisDirection>
+ <gml:rangeMeaning codeSpace="EPSG">wraparound</gml:rangeMeaning>
+ </gml:CoordinateSystemAxis>
+ </gml:axis>
+ </gml:EllipsoidalCS>
+ </gml:ellipsoidalCS>
+ <gml:geodeticDatum>
+ <gml:GeodeticDatum gml:id="ParisDatum">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:datum:EPSG::6807</gml:identifier>
+ <gml:name>Nouvelle Triangulation Française (Paris)</gml:name>
+ <gml:scope>Topographic mapping.</gml:scope>
+ <gml:primeMeridian>
+ <gml:PrimeMeridian gml:id = "ParisMeridian">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:meridian:EPSG::8901</gml:identifier>
+ <gml:name>Greenwich</gml:name>
+ <gml:greenwichLongitude
uom="urn:ogc:def:uom:EPSG::9105">2.5969213</gml:greenwichLongitude>
+ </gml:PrimeMeridian>
+ </gml:primeMeridian>
+ <gml:ellipsoid>
+ <gml:Ellipsoid gml:id = "Ellipsoid">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:ellipsoid:EPSG::7030</gml:identifier>
+ <gml:name>Clarke 1880 (IGN)</gml:name>
+ <gml:semiMajorAxis
uom="urn:ogc:def:uom:EPSG::9001">6378249.2</gml:semiMajorAxis>
+ <gml:secondDefiningParameter>
+ <gml:SecondDefiningParameter>
+ <gml:semiMinorAxis
uom="urn:ogc:def:uom:EPSG::9001">6356515</gml:semiMinorAxis>
+ </gml:SecondDefiningParameter>
+ </gml:secondDefiningParameter>
+ </gml:Ellipsoid>
+ </gml:ellipsoid>
+ </gml:GeodeticDatum>
+ </gml:geodeticDatum>
+ </gml:GeodeticCRS>
+ </gml:sourceCRS>
+
+ <!--
+ Following CRS definition contains a lot of information identical to the
source CRS.
+ The only difference are the datum and the prime meridian.
+
+ See https://issues.apache.org/jira/browse/SIS-173 issue.
+ Duplicated value have the "-copy" suffix in gml:id.
+ -->
+ <gml:targetCRS>
+ <gml:GeodeticCRS gml:id="Greenwich">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:crs:EPSG::4275</gml:identifier>
+ <gml:name>NTF</gml:name>
+ <gml:scope>Geodetic survey.</gml:scope>
+ <gml:ellipsoidalCS>
+ <!-- TODO (SIS-173): replace following element by IDREF -->
+ <gml:EllipsoidalCS gml:id="CoordinateSystem-copy">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:cs:EPSG::6422</gml:identifier>
+ <gml:name>Latitude (north), Longitude (east)</gml:name>
+ <gml:axis>
+ <gml:CoordinateSystemAxis gml:id="Ï-copy"
uom="urn:ogc:def:uom:EPSG::9122">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:axis:EPSG::106</gml:identifier>
+ <gml:name>Geodetic latitude</gml:name>
+ <gml:axisAbbrev>Ï</gml:axisAbbrev>
+ <gml:axisDirection codeSpace="EPSG">north</gml:axisDirection>
+ <gml:rangeMeaning codeSpace="EPSG">exact</gml:rangeMeaning>
+ </gml:CoordinateSystemAxis>
+ </gml:axis>
+ <gml:axis>
+ <gml:CoordinateSystemAxis gml:id="λ-copy"
uom="urn:ogc:def:uom:EPSG::9122">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:axis:EPSG::107</gml:identifier>
+ <gml:name>Geodetic longitude</gml:name>
+ <gml:axisAbbrev>λ</gml:axisAbbrev>
+ <gml:axisDirection codeSpace="EPSG">east</gml:axisDirection>
+ <gml:rangeMeaning codeSpace="EPSG">wraparound</gml:rangeMeaning>
+ </gml:CoordinateSystemAxis>
+ </gml:axis>
+ </gml:EllipsoidalCS>
+ </gml:ellipsoidalCS>
+ <gml:geodeticDatum>
+ <gml:GeodeticDatum gml:id="GreenwichDatum">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:datum:EPSG::6275</gml:identifier>
+ <gml:name>Nouvelle Triangulation Française</gml:name>
+ <gml:scope>Topographic mapping.</gml:scope>
+ <gml:primeMeridian>
+ <gml:PrimeMeridian gml:id = "GreenwichMeridian">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:meridian:EPSG::8901</gml:identifier>
+ <gml:name>Greenwich</gml:name>
+ <gml:greenwichLongitude
uom="urn:ogc:def:uom:EPSG::9102">0</gml:greenwichLongitude>
+ </gml:PrimeMeridian>
+ </gml:primeMeridian>
+ <!-- TODO (SIS-173): replace following element by IDREF -->
+ <gml:ellipsoid>
+ <gml:Ellipsoid gml:id = "Ellipsoid-copy">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:ellipsoid:EPSG::7011</gml:identifier>
+ <gml:name>Clarke 1880 (IGN)</gml:name>
+ <gml:semiMajorAxis
uom="urn:ogc:def:uom:EPSG::9001">6378249.2</gml:semiMajorAxis>
+ <gml:secondDefiningParameter>
+ <gml:SecondDefiningParameter>
+ <gml:semiMinorAxis
uom="urn:ogc:def:uom:EPSG::9001">6356515</gml:semiMinorAxis>
+ </gml:SecondDefiningParameter>
+ </gml:secondDefiningParameter>
+ </gml:Ellipsoid>
+ </gml:ellipsoid>
+ </gml:GeodeticDatum>
+ </gml:geodeticDatum>
+ </gml:GeodeticCRS>
+ </gml:targetCRS>
+
+ <gml:method>
+ <gml:OperationMethod gml:id="OperationMethod">
+ <gml:identifier
codeSpace="IOGP">urn:ogc:def:method:EPSG::9601</gml:identifier>
+ <gml:name>Longitude rotation</gml:name>
+ <gml:formula>Target_longitude = Source_longitude +
longitude_offset.</gml:formula>
+ <gml:sourceDimensions>2</gml:sourceDimensions>
+ <gml:targetDimensions>2</gml:targetDimensions>
+ <gml:parameter>
+ <gml:OperationParameter gml:id="ParameterDescriptor">
+ <gml:identifier
codeSpace="OGP">urn:ogc:def:parameter:EPSG::8602</gml:identifier>
+ <gml:name>Longitude offset</gml:name>
+ </gml:OperationParameter>
+ </gml:parameter>
+ </gml:OperationMethod>
+ </gml:method>
+
+ <gml:parameterValue>
+ <gml:ParameterValue>
+ <gml:value uom="urn:ogc:def:uom:EPSG::9105">2.5969213</gml:value>
+ <!--
+ The following duplicates the descriptor defined in above <gml:method>,
so we could replace the definition
+ by a gml:idref="ParameterDescriptor" attribute
(http://issues.apache.org/jira/browse/SIS-173). But we do
+ not apply this simplification because we want to opportunistically
test SIS capability to consolidate the
+ various descriptors into canonical instances based on the parameter
name.
+ -->
+ <gml:operationParameter>
+ <gml:OperationParameter gml:id="ParameterDescriptor-copy">
+ <gml:identifier
codeSpace="OGP">urn:ogc:def:parameter:EPSG::8602</gml:identifier>
+ <gml:name>Longitude offset</gml:name>
+ </gml:OperationParameter>
+ </gml:operationParameter>
+ </gml:ParameterValue>
+ </gml:parameterValue>
+</gml:Transformation>
Propchange:
sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Transformation.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
sis/branches/JDK8/core/sis-referencing/src/test/resources/org/apache/sis/referencing/operation/Transformation.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml