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/06/15 17:56:37 UTC
svn commit: r1685605 - in /sis/branches/JDK8/core/sis-metadata/src:
main/java/org/apache/sis/metadata/iso/extent/Extents.java
test/java/org/apache/sis/metadata/iso/extent/ExtentsTest.java
test/java/org/apache/sis/test/mock/VerticalCRSMock.java
Author: desruisseaux
Date: Mon Jun 15 15:56:37 2015
New Revision: 1685605
URL: http://svn.apache.org/r1685605
Log:
Added tests for Extents.getVerticalRange(Extent).
Modified:
sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/ExtentsTest.java
sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/mock/VerticalCRSMock.java
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java?rev=1685605&r1=1685604&r2=1685605&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/Extents.java [UTF-8] Mon Jun 15 15:56:37 2015
@@ -160,7 +160,7 @@ public final class Extents extends Stati
* <div class="note"><b>Rational:</b> like {@linkplain #getGeographicBoundingBox(Extent) geographic bounding box},
* the vertical range is an approximative information; the range returned by this method does not carry any
* information about the vertical CRS and this method does not attempt to perform coordinate transformation.
- * But this method is more useful if the returned ranges are close so a frequently used surface, like the
+ * But this method is more useful if the returned ranges are close to a frequently used surface, like the
* Mean Sea Level. The same simplification is applied in the
* <a href="http://docs.opengeospatial.org/is/12-063r5/12-063r5.html#31">{@code VerticalExtent} element of
* Well Known Text (WKT) format</a>, which specifies that <cite>“Vertical extent is an approximate description
Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/ExtentsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/ExtentsTest.java?rev=1685605&r1=1685604&r2=1685605&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/ExtentsTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/extent/ExtentsTest.java [UTF-8] Mon Jun 15 15:56:37 2015
@@ -16,13 +16,19 @@
*/
package org.apache.sis.metadata.iso.extent;
+import java.util.List;
import java.util.Arrays;
+import java.util.Collections;
import javax.measure.unit.SI;
+import javax.measure.converter.UnitConverter;
+import javax.measure.converter.ConversionException;
import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.apache.sis.measure.Units;
import org.apache.sis.measure.MeasurementRange;
import org.apache.sis.test.mock.VerticalCRSMock;
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
+import org.apache.sis.test.TestUtilities;
import org.junit.Test;
import static org.apache.sis.internal.metadata.ReferencingServices.NAUTICAL_MILE;
@@ -34,7 +40,7 @@ import static org.junit.Assert.*;
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*/
@DependsOn(DefaultGeographicBoundingBoxTest.class)
@@ -46,22 +52,32 @@ public final strictfp class ExtentsTest
/**
* Tests {@link Extents#getVerticalRange(Extent)}.
+ *
+ * @throws ConversionException should never happen in this test.
*/
@Test
- public void testGetVerticalRange() {
- final DefaultExtent extent = new DefaultExtent();
- extent.setVerticalElements(Arrays.asList(
+ public void testGetVerticalRange() throws ConversionException {
+ final List<DefaultVerticalExtent> extents = Arrays.asList(
new DefaultVerticalExtent( -200, -100, VerticalCRSMock.HEIGHT),
new DefaultVerticalExtent( 150, 300, VerticalCRSMock.DEPTH),
new DefaultVerticalExtent( 0.1, 0.2, VerticalCRSMock.SIGMA_LEVEL),
new DefaultVerticalExtent( -600, -300, VerticalCRSMock.HEIGHT_ft), // [91.44 182.88] metres
new DefaultVerticalExtent(10130, 20260, VerticalCRSMock.BAROMETRIC_HEIGHT)
- ));
+ );
+ Collections.shuffle(extents, TestUtilities.createRandomNumberGenerator());
+ final DefaultExtent extent = new DefaultExtent();
+ extent.setVerticalElements(extents);
+ /*
+ * Since we have shuffled the vertical extents in random order, the range obtained below
+ * may be either in metres or in feet (depending which vertical extent appear first).
+ * Consequently our test will need to convert the values to metres.
+ */
final MeasurementRange<Double> range = Extents.getVerticalRange(extent);
assertNotNull("getVerticalRange", range);
- assertEquals("unit", SI.METRE, range.unit());
- assertEquals("minimum", -300, range.getMinDouble(), 0.001);
- assertEquals("maximum", -91.44, range.getMaxDouble(), 0.001);
+ assertTrue("unit", Units.isLinear(range.unit()));
+ final UnitConverter c = range.unit().getConverterToAny(SI.METRE);
+ assertEquals("minimum", -300, c.convert(range.getMinDouble()), 0.001);
+ assertEquals("maximum", -91.44, c.convert(range.getMaxDouble()), 0.001);
}
/**
Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/mock/VerticalCRSMock.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/mock/VerticalCRSMock.java?rev=1685605&r1=1685604&r2=1685605&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/mock/VerticalCRSMock.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/test/mock/VerticalCRSMock.java [UTF-8] Mon Jun 15 15:56:37 2015
@@ -36,7 +36,7 @@ import org.opengis.util.InternationalStr
*
* @author Martin Desruisseaux (Geomatys)
* @since 0.4
- * @version 0.4
+ * @version 0.6
* @module
*/
@SuppressWarnings("serial")
@@ -47,31 +47,36 @@ public final strictfp class VerticalCRSM
* Height in metres.
*/
public static final VerticalCRS HEIGHT = new VerticalCRSMock("Height",
- Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, true);
+ VerticalDatumType.GEOIDAL, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, SI.METRE, true);
/**
* Height in feet.
*/
public static final VerticalCRS HEIGHT_ft = new VerticalCRSMock("Height",
- Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, NonSI.FOOT, true);
+ VerticalDatumType.GEOIDAL, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, NonSI.FOOT, true);
/**
* Height estimated from hPa.
*/
public static final VerticalCRS BAROMETRIC_HEIGHT = new VerticalCRSMock("Barometric height",
- 0, Double.POSITIVE_INFINITY, SI.MetricPrefix.HECTO(SI.PASCAL), true);
+ VerticalDatumType.BAROMETRIC, 0, Double.POSITIVE_INFINITY, SI.MetricPrefix.HECTO(SI.PASCAL), true);
/**
* Depth in metres.
*/
public static final VerticalCRS DEPTH = new VerticalCRSMock("Depth",
- 0, Double.POSITIVE_INFINITY, SI.METRE, false);
+ VerticalDatumType.DEPTH, 0, Double.POSITIVE_INFINITY, SI.METRE, false);
/**
* Depth as a fraction of the sea floor depth at the location of the point for which the depth is evaluated.
*/
public static final VerticalCRS SIGMA_LEVEL = new VerticalCRSMock("Sigma level",
- 0, 1, Unit.ONE, false);
+ VerticalDatumType.OTHER_SURFACE, 0, 1, Unit.ONE, false);
+
+ /**
+ * The datum type (geoidal, barometric, etc.).
+ */
+ private final VerticalDatumType type;
/**
* The minimum and maximum values.
@@ -97,10 +102,11 @@ public final strictfp class VerticalCRSM
* @param minimumValue The minium value.
* @param maximumValue The maximum value.
*/
- private VerticalCRSMock(final String name, final double minimumValue, final double maximumValue,
- final Unit<?> unit, final boolean up)
+ private VerticalCRSMock(final String name, VerticalDatumType type,
+ final double minimumValue, final double maximumValue, final Unit<?> unit, final boolean up)
{
super(name);
+ this.type = type;
this.minimumValue = minimumValue;
this.maximumValue = maximumValue;
this.unit = unit;
@@ -120,7 +126,7 @@ public final strictfp class VerticalCRSM
@Override public InternationalString getAnchorPoint() {return null;}
@Override public Date getRealizationEpoch() {return null;}
@Override public Extent getDomainOfValidity() {return null;}
- @Override public VerticalDatumType getVerticalDatumType() {return VerticalDatumType.GEOIDAL;}
+ @Override public VerticalDatumType getVerticalDatumType() {return type;}
@Override public VerticalDatum getDatum() {return this;}
@Override public VerticalCS getCoordinateSystem() {return this;}
@Override public int getDimension() {return 1;}