Author: desruisseaux
Date: Mon Nov 9 19:52:03 2015
New Revision: 1713526
URL: http://svn.apache.org/viewvc?rev=1713526&view=rev
Log:
Simplify the MathTransform WKT in Convention.INTERNAL mode by omitting the unit
of measurement if equals to the default unit.
This make the debugging WKT much less verbose.
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1713526&r1=1713525&r2=1713526&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java
[UTF-8] Mon Nov 9 19:52:03 2015
@@ -187,7 +187,9 @@ public enum Convention {
* <li>All quoted texts (not only the remarks) preserve non-ASCII
characters.</li>
* <li>Map projections are shown as SIS stores them internally, i.e.
with the separation between
* linear and non-linear steps, rather than as a single
operation.</li>
- * <li>{@code CompoundCRS} shows nested compound CRS if any (the
structure is not flattened).</li>
+ * <li>{@code Parameter} elements omit the unit of measurement if that
unit is equal to the default unit
+ * (as declared in the parameter descriptor).</li>
+ * <li>{@code CompoundCRS} elements show nested compound CRS if any (the
structure is not flattened).</li>
* <li>{@code Id} elements are formatted for child elements in addition
to the root one.</li>
* <li>{@code Id} element omits the {@code URI} sub-element if the later
is derived by Apache SIS
* from the {@code Id} properties.</li>
Modified:
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java?rev=1713526&r1=1713525&r2=1713526&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/parameter/DefaultParameterValue.java
[UTF-8] Mon Nov 9 19:52:03 2015
@@ -957,9 +957,14 @@ public class DefaultParameterValue<T> ex
* is identical in both units (typically the 0 value).
*/
if (!ignoreUnits && !Double.isNaN(value)) {
+ // Test equivalent to unit.equals(contextualUnit) but more
aggressive.
ignoreUnits = Numerics.equals(value,
doubleValue(contextualUnit));
}
- if (!ignoreUnits || !convention.isSimplified() ||
!hasContextualUnit(formatter)) {
+ if (ignoreUnits && convention != Convention.INTERNAL) {
+ // One last check about if we are really allowed to ignore
units.
+ ignoreUnits = convention.isSimplified() &&
hasContextualUnit(formatter);
+ }
+ if (!ignoreUnits) {
if (!isWKT1) {
formatter.append(unit);
} else if (!ignoreUnits) {
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java?rev=1713526&r1=1713525&r2=1713526&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/parameter/DefaultParameterValueTest.java
[UTF-8] Mon Nov 9 19:52:03 2015
@@ -607,9 +607,15 @@ public final strictfp class DefaultParam
@Test
@DependsOnMethod("testWKT")
public void testWKT_withUnformattableUnit() {
- final DefaultParameterValue<Double> p = create("Angle", 10.3,
Units.valueOfEPSG(9111));
+ final Unit<?> degreesAndMinutes = Units.valueOfEPSG(9111);
+ DefaultParameterValue<Double> p = create("Angle", 10.3,
degreesAndMinutes);
assertWktEquals(Convention.WKT1, "PARAMETER[“Angle”, 10.3]", p);
// 10.3 DM == 10.5°
assertWktEquals(Convention.WKT2, "PARAMETER[“Angle”, 10.5,
ANGLEUNIT[“degree”, 0.017453292519943295]]", p);
+ assertWktEquals(Convention.INTERNAL, "Parameter[“Angle”, 10.3]", p);
// Value in same unit than descriptor.
+
+ p = create("Angle", 0, NonSI.DEGREE_ANGLE);
+ p.setValue(10.3, degreesAndMinutes); // Can not be formatted in WKT1.
+ assertWktEquals(Convention.WKT2, "PARAMETER[“Angle”, 10.5,
ANGLEUNIT[“degree”, 0.017453292519943295]]", p);
assertWktEquals(Convention.INTERNAL, "Parameter[“Angle”, 10.3,
Unit[“D.M”, 0.017453292519943295, Id[“EPSG”, 9111]]]", p);
}
Modified:
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java
URL:
http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java?rev=1713526&r1=1713525&r2=1713526&view=diff
==============================================================================
---
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java
[UTF-8] (original)
+++
sis/branches/JDK8/core/sis-referencing/src/test/java/org/apache/sis/referencing/operation/transform/MolodenskyTransformTest.java
[UTF-8] Mon Nov 9 19:52:03 2015
@@ -301,12 +301,12 @@ public final strictfp class MolodenskyTr
" Parameter[“elt_0_0”, 0.017453292519943295],\n" + //
Degrees to radians conversion
" Parameter[“elt_1_1”, 0.017453292519943295]],\n" +
" Param_MT[“Molodensky”,\n" +
- " Parameter[“X-axis translation”, 84.87, Unit[“metre”, 1,
Id[“EPSG”, 9001]]],\n" +
- " Parameter[“Y-axis translation”, 96.49, Unit[“metre”, 1,
Id[“EPSG”, 9001]]],\n" +
- " Parameter[“Z-axis translation”, 116.95, Unit[“metre”, 1,
Id[“EPSG”, 9001]]],\n" +
- " Parameter[“Semi-major axis length difference”, 251.0,
Unit[“metre”, 1, Id[“EPSG”, 9001]]],\n" +
- " Parameter[“Flattening difference”, 1.4192702255886284E-5,
Unit[“unity”, 1, Id[“EPSG”, 9201]]],\n" +
- " Parameter[“src_semi_major”, 6378137.0, Unit[“metre”, 1,
Id[“EPSG”, 9001]]],\n" +
+ " Parameter[“X-axis translation”, 84.87],\n" +
+ " Parameter[“Y-axis translation”, 96.49],\n" +
+ " Parameter[“Z-axis translation”, 116.95],\n" +
+ " Parameter[“Semi-major axis length difference”, 251.0],\n"
+
+ " Parameter[“Flattening difference”,
1.4192702255886284E-5],\n" +
+ " Parameter[“src_semi_major”, 6378137.0],\n" +
" Parameter[“eccentricity”, 0.0818191908426215],\n" +
" Parameter[“abridged”, TRUE],\n" +
" Parameter[“dim”, 3]],\n" +