sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/03: Add test.
Date Wed, 19 Dec 2018 18:54:49 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 65f8e67982856b652e86c5e0bb780530bc525141
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Dec 18 10:26:41 2018 +0100

    Add test.
---
 .../internal/referencing/ServicesForMetadata.java  |  2 +-
 .../referencing/ServicesForMetadataTest.java       | 27 ++++++++++++++++++++--
 pom.xml                                            |  2 +-
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
index 46b34cd..97bf7ff 100644
--- a/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
+++ b/core/sis-referencing/src/main/java/org/apache/sis/internal/referencing/ServicesForMetadata.java
@@ -203,7 +203,7 @@ public final class ServicesForMetadata extends ReferencingServices {
             westBoundLongitude += rotation;
             eastBoundLongitude += rotation;
         }
-        if (eastBoundLongitude - westBoundLongitude >= 360) {
+        if (eastBoundLongitude - westBoundLongitude >= (Longitude.MAX_VALUE - Longitude.MIN_VALUE))
{
             westBoundLongitude = Longitude.MIN_VALUE;
             eastBoundLongitude = Longitude.MAX_VALUE;
         } else {
diff --git a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
index 1ff2cad..22eb03d 100644
--- a/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
+++ b/core/sis-referencing/src/test/java/org/apache/sis/internal/referencing/ServicesForMetadataTest.java
@@ -44,7 +44,7 @@ import static org.apache.sis.test.TestUtilities.getSingleton;
  * Tests {@link ServicesForMetadata}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.5
  * @module
  */
@@ -68,7 +68,7 @@ public final strictfp class ServicesForMetadataTest extends TestCase {
      * and [51000 … 52000] modified Julian days.
      */
     @SuppressWarnings("fallthrough")
-    private static Envelope createEnvelope(final CoordinateReferenceSystem crs) {
+    private static GeneralEnvelope createEnvelope(final CoordinateReferenceSystem crs) {
         final GeneralEnvelope envelope = new GeneralEnvelope(crs);
         switch (crs.getCoordinateSystem().getDimension()) {
             default: throw new AssertionError();
@@ -168,6 +168,29 @@ public final strictfp class ServicesForMetadataTest extends TestCase
{
     }
 
     /**
+     * Tests (indirectly) {@link ServicesForMetadata#setBounds(Envelope, DefaultGeographicBoundingBox,
boolean)}
+     * from an envelope spanning the antimeridian.
+     *
+     * @throws TransformException should never happen.
+     */
+    @Test
+    public void testSetGeographicBoundsSpanningAntimeridian() throws TransformException {
+        final DefaultGeographicBoundingBox box = new DefaultGeographicBoundingBox();
+        final GeneralEnvelope envelope = createEnvelope(HardCodedCRS.WGS84);
+        envelope.setRange(0, 170, 195);
+        box.setBounds(envelope);
+        assertEquals( 170, box.getWestBoundLongitude(), STRICT);
+        assertEquals(-165, box.getEastBoundLongitude(), STRICT);
+        envelope.setRange(0, 0, 360);
+        box.setBounds(envelope);
+        assertEquals(-180, box.getWestBoundLongitude(), STRICT);
+        assertEquals(+180, box.getEastBoundLongitude(), STRICT);
+        assertEquals( -20, box.getSouthBoundLatitude(), STRICT);
+        assertEquals(  30, box.getNorthBoundLatitude(), STRICT);
+        assertEquals(Boolean.TRUE, box.getInclusion());
+    }
+
+    /**
      * Tests {@link DefaultVerticalExtent#intersect(VerticalExtent)}.
      *
      * @throws TransformException if the transformation failed.
diff --git a/pom.xml b/pom.xml
index ac07005..81529c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -655,7 +655,7 @@
            INDEX.LIST file is incomplete (which seem to happen in practice). -->
       <plugin>
         <artifactId>maven-jar-plugin</artifactId>
-        <version>3.1.0</version>
+        <version>3.1.1</version>
         <configuration>
           <archive>
             <addMavenDescriptor>false</addMavenDescriptor>


Mime
View raw message