sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1667291 - in /sis/branches/JDK8/core/sis-metadata/src: main/java/org/apache/sis/metadata/iso/identification/ test/java/org/apache/sis/metadata/
Date Tue, 17 Mar 2015 12:32:14 GMT
Author: desruisseaux
Date: Tue Mar 17 12:32:14 2015
New Revision: 1667291

URL: http://svn.apache.org/r1667291
Log:
Metadata bug fix: DefaultResolution.isEmpty() and prune() need to detect when RepresentativeFraction
is empty [SIS-194].

Modified:
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
    sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java?rev=1667291&r1=1667290&r2=1667291&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultRepresentativeFraction.java
[UTF-8] Tue Mar 17 12:32:14 2015
@@ -35,6 +35,7 @@ import org.apache.sis.xml.IdentifierSpac
 import org.apache.sis.xml.IdentifiedObject;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.ArgumentChecks;
+import org.apache.sis.util.Emptiable;
 import org.apache.sis.util.resources.Errors;
 
 import static org.apache.sis.util.collection.Containers.isNullOrEmpty;
@@ -62,14 +63,14 @@ import static org.apache.sis.internal.me
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see DefaultResolution#getEquivalentScale()
  */
 @XmlType(name = "MD_RepresentativeFraction_Type")
 @XmlRootElement(name = "MD_RepresentativeFraction")
-public class DefaultRepresentativeFraction extends Number implements RepresentativeFraction,
IdentifiedObject {
+public class DefaultRepresentativeFraction extends Number implements RepresentativeFraction,
IdentifiedObject, Emptiable {
     /**
      * Serial number for compatibility with different versions.
      */
@@ -239,6 +240,26 @@ public class DefaultRepresentativeFracti
     }
 
     /**
+     * Returns {@code true} if no scale is defined.
+     * The following relationship shall hold:
+     *
+     * {@preformat java
+     *   assert isEmpty() == Double.isNaN(doubleValue());
+     * }
+     *
+     * @return {@code true} if no scale is defined.
+     *
+     * @see #doubleValue()
+     * @see #floatValue()
+     *
+     * @since 0.6
+     */
+    @Override
+    public boolean isEmpty() {
+        return (denominator == 0);
+    }
+
+    /**
      * Compares this object with the specified value for equality.
      *
      * @param object The object to compare with.

Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java?rev=1667291&r1=1667290&r2=1667291&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultResolution.java
[UTF-8] Tue Mar 17 12:32:14 2015
@@ -55,7 +55,7 @@ import static org.apache.sis.internal.me
  * @author  Touraïvane (IRD)
  * @author  Cédric Briançon (Geomatys)
  * @since   0.3
- * @version 0.5
+ * @version 0.6
  * @module
  *
  * @see AbstractIdentification#getSpatialResolutions()
@@ -121,7 +121,10 @@ public class DefaultResolution extends I
      * @since 0.4
      */
     public DefaultResolution(final RepresentativeFraction scale) {
-        value = scale;
+        if (scale != null) {
+            value = scale;
+            property = SCALE;
+        }
     }
 
     // Note: there is not yet DefaultResolution(double) method because

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java?rev=1667291&r1=1667290&r2=1667291&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/PrunerTest.java
[UTF-8] Tue Mar 17 12:32:14 2015
@@ -20,7 +20,9 @@ import org.apache.sis.metadata.iso.Defau
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.extent.DefaultExtent;
 import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
+import org.apache.sis.metadata.iso.identification.DefaultResolution;
 import org.apache.sis.metadata.iso.identification.DefaultDataIdentification;
+import org.apache.sis.metadata.iso.identification.DefaultRepresentativeFraction;
 import org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation;
 import org.apache.sis.internal.simple.SimpleIdentifier;
 import org.apache.sis.test.DependsOnMethod;
@@ -38,7 +40,7 @@ import static org.apache.sis.metadata.Va
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.5
+ * @version 0.6
  * @module
  */
 @DependsOn(ValueMapTest.class)
@@ -54,6 +56,11 @@ public final strictfp class PrunerTest e
     private final DefaultDataIdentification identification;
 
     /**
+     * A child of an other child metadata object being tested.
+     */
+    private final DefaultRepresentativeFraction scale;
+
+    /**
      * A child of the metadata object being tested.
      */
     private final DefaultExtent extent;
@@ -69,10 +76,12 @@ public final strictfp class PrunerTest e
     public PrunerTest() {
         metadata       = new DefaultMetadata();
         identification = new DefaultDataIdentification();
+        scale          = new DefaultRepresentativeFraction();
         extent         = new DefaultExtent();
         bbox           = new DefaultGeographicBoundingBox();
         extent.setGeographicElements(singleton(bbox));
         identification.setExtents(singleton(extent));
+        identification.setSpatialResolutions(singleton(new DefaultResolution(scale)));
         metadata.setIdentificationInfo(singleton(identification));
     }
 
@@ -86,6 +95,7 @@ public final strictfp class PrunerTest e
          */
         assertTrue("GeographicBoundingBox", bbox.isEmpty());
         assertTrue("Extent",                extent.isEmpty());
+        assertTrue("Scale",                 scale.isEmpty());
         assertTrue("DataIdentification",    identification.isEmpty());
         assertTrue("Metadata",              metadata.isEmpty());
         /*
@@ -94,6 +104,7 @@ public final strictfp class PrunerTest e
         identification.setCitation(new DefaultCitation("A citation title"));
         assertTrue ("GeographicBoundingBox", bbox.isEmpty());
         assertTrue ("Extent",                extent.isEmpty());
+        assertTrue ("Scale",                 scale.isEmpty());
         assertFalse("DataIdentification",    identification.isEmpty());
         assertFalse("Metadata",              metadata.isEmpty());
         /*
@@ -102,6 +113,7 @@ public final strictfp class PrunerTest e
         metadata.setMetadataIdentifier(new SimpleIdentifier(null, "A file identifiers"));
         assertTrue ("GeographicBoundingBox", bbox.isEmpty());
         assertTrue ("Extent",                extent.isEmpty());
+        assertTrue ("Scale",                 scale.isEmpty());
         assertFalse("DataIdentification",    identification.isEmpty());
         assertFalse("Metadata",              metadata.isEmpty());
         /*
@@ -110,13 +122,26 @@ public final strictfp class PrunerTest e
         identification.setCitation(new DefaultCitation("  "));
         assertTrue ("GeographicBoundingBox", bbox.isEmpty());
         assertTrue ("Extent",                extent.isEmpty());
+        assertTrue ("Scale",                 scale.isEmpty());
         assertTrue ("DataIdentification",    identification.isEmpty());
         assertFalse("Metadata",              metadata.isEmpty());
         /*
+         * Set a representative fraction.
+         */
+        scale.setDenominator(1000);
+        assertTrue ("GeographicBoundingBox", bbox.isEmpty());
+        assertTrue ("Extent",                extent.isEmpty());
+        assertFalse("Scale",                 scale.isEmpty());
+        assertFalse("DataIdentification",    identification.isEmpty());
+        assertFalse("Metadata",              metadata.isEmpty());
+        /*
          * Set an empty string in an element.
          */
+        scale.setScale(Double.NaN);
         metadata.setMetadataIdentifier(new SimpleIdentifier(null, "   "));
-        assertTrue("Metadata", metadata.isEmpty());
+        assertTrue("Scale",                 scale.isEmpty());
+        assertTrue("DataIdentification",    identification.isEmpty());
+        assertTrue("Metadata",              metadata.isEmpty());
     }
 
     /**



Mime
View raw message