sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tlpin...@apache.org
Subject svn commit: r1517321 [9/16] - in /sis/branches/Shapefile: ./ application/ application/sis-console/ application/sis-console/src/main/artifact/ application/sis-console/src/main/java/org/apache/sis/console/ application/sis-console/src/main/resources/org/a...
Date Sun, 25 Aug 2013 15:49:59 GMT
Modified: sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/ValueMapTest.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -20,6 +20,7 @@ import java.util.Map;
 import java.util.Collection;
 import org.opengis.util.InternationalString;
 import org.opengis.metadata.Identifier;
+import org.apache.sis.xml.NilReason;
 import org.apache.sis.util.iso.SimpleInternationalString;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.metadata.iso.citation.DefaultResponsibleParty;
@@ -45,7 +46,7 @@ import static org.apache.sis.test.TestUt
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @see MetadataStandardTest#testValueMap()
@@ -74,10 +75,11 @@ public final strictfp class ValueMapTest
      *
      * {@preformat text
      *     Citation
-     *     ├───Title…………………………………………………… Undercurrent
-     *     ├───Cited Responsible Parties
-     *     │   └───Individual Name……………… Testsuya Toyoda
-     *     └───ISBN……………………………………………………… 9782505004509
+     *       ├─Title…………………………………………………… Undercurrent
+     *       ├─Edition……………………………………………… <nil:unknown>
+     *       ├─Cited Responsible Parties
+     *       │   └─Individual Name……………… Testsuya Toyoda
+     *       └─ISBN……………………………………………………… 9782505004509
      * }
      *
      * The citation instance is stored in the {@link #citation} field.
@@ -92,6 +94,7 @@ public final strictfp class ValueMapTest
         author.setIndividualName("Testsuya Toyoda");
         citation.getCitedResponsibleParties().add(author);
         citation.setISBN("9782505004509");
+        citation.setEdition(NilReason.UNKNOWN.createNilObject(InternationalString.class));
         return MetadataStandard.ISO_19115.asValueMap(citation, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
     }
 
@@ -101,9 +104,10 @@ public final strictfp class ValueMapTest
     @Test
     public void testGet() {
         final Map<String,Object> map = createCitation();
-        assertEquals("Undercurrent",        map.get("title").toString());
-        assertEquals(singletonList(author), map.get("citedResponsibleParties"));
-        assertEquals("9782505004509",       map.get("ISBN"));
+        assertEquals("Undercurrent",                 map.get("title").toString());
+        assertEquals(singletonList(author),          map.get("citedResponsibleParties"));
+        assertEquals("9782505004509",                map.get("ISBN"));
+        assertNull  ("NilObject shall be excluded.", map.get("edition"));
         /*
          * The ISBN shall also be visible as an identifier.
          */
@@ -116,15 +120,15 @@ public final strictfp class ValueMapTest
 
     /**
      * Tests the {@link ValueMap#entrySet()} method.
-     * The metadata to be tested is:
+     * The expected metadata is:
      *
      * {@preformat text
      *     Citation
-     *     ├───Title…………………………………………………… Undercurrent
-     *     ├───Identifiers…………………………………… 9782505004509
-     *     ├───Cited Responsible Parties
-     *     │   └───Individual Name……………… Testsuya Toyoda
-     *     └───ISBN……………………………………………………… 9782505004509
+     *       ├─Title…………………………………………………… Undercurrent
+     *       ├─Identifiers…………………………………… 9782505004509
+     *       ├─Cited Responsible Parties
+     *       │   └─Individual Name……………… Testsuya Toyoda
+     *       └─ISBN……………………………………………………… 9782505004509
      * }
      *
      * Note that this test is intentionally sensitive to iteration order.
@@ -145,7 +149,34 @@ public final strictfp class ValueMapTest
 
     /**
      * Tests the {@link ValueMap#entrySet()} method for the same metadata than {@link #testEntrySet()},
-     * but asking for all non-null entries including the empty collections.
+     * but asking for all non-null and non-nil entries including the empty collections.
+     */
+    @Test
+    @DependsOnMethod("testEntrySet")
+    public void testEntrySetForNonNil() {
+        final Map<String,Object> map = createCitation();
+        final Map<String,Object> all = MetadataStandard.ISO_19115.asValueMap(citation,
+                KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_NIL);
+        assertFalse("Null values shall be excluded.", map.containsKey("alternateTitles"));
+        assertTrue ("Null values shall be included.", all.containsKey("alternateTitles"));
+        assertFalse("Nil objects shall be excluded.", map.containsKey("edition"));
+        assertFalse("Nil objects shall be excluded.", all.containsKey("edition"));
+        assertTrue ("'all' shall be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
+        assertFalse("'all' shall be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
+        assertArrayEquals(new SimpleEntry<?,?>[] {
+            new SimpleEntry<String,Object>("title",                   title),
+            new SimpleEntry<String,Object>("alternateTitles",         emptyList()),
+            new SimpleEntry<String,Object>("dates",                   emptyList()),
+            new SimpleEntry<String,Object>("identifiers",             citation.getIdentifiers()),
+            new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
+            new SimpleEntry<String,Object>("presentationForms",       emptySet()),
+            new SimpleEntry<String,Object>("ISBN",                    "9782505004509")
+        }, all.entrySet().toArray());
+    }
+
+    /**
+     * Tests the {@link ValueMap#entrySet()} method for the same metadata than {@link #testEntrySet()},
+     * but asking for all non-null entries including nil objects and the empty collections.
      */
     @Test
     @DependsOnMethod("testEntrySet")
@@ -153,14 +184,17 @@ public final strictfp class ValueMapTest
         final Map<String,Object> map = createCitation();
         final Map<String,Object> all = MetadataStandard.ISO_19115.asValueMap(citation,
                 KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_NULL);
-        assertFalse("Null values should be excluded.", map.containsKey("alternateTitles"));
-        assertTrue ("Null values should be included.", all.containsKey("alternateTitles"));
-        assertTrue ("'all' should be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
-        assertFalse("'all' should be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
+        assertFalse("Null values shall be excluded.", map.containsKey("alternateTitles"));
+        assertTrue ("Null values shall be included.", all.containsKey("alternateTitles"));
+        assertFalse("Nil objects shall be excluded.", map.containsKey("edition"));
+        assertTrue ("Nil objects shall be included.", all.containsKey("edition"));
+        assertTrue ("'all' shall be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
+        assertFalse("'all' shall be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
         assertArrayEquals(new SimpleEntry<?,?>[] {
             new SimpleEntry<String,Object>("title",                   title),
             new SimpleEntry<String,Object>("alternateTitles",         emptyList()),
             new SimpleEntry<String,Object>("dates",                   emptyList()),
+            new SimpleEntry<String,Object>("edition",                 NilReason.UNKNOWN.createNilObject(InternationalString.class)),
             new SimpleEntry<String,Object>("identifiers",             citation.getIdentifiers()),
             new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
             new SimpleEntry<String,Object>("presentationForms",       emptySet()),
@@ -178,15 +212,15 @@ public final strictfp class ValueMapTest
         final Map<String,Object> map = createCitation();
         final Map<String,Object> all = MetadataStandard.ISO_19115.asValueMap(citation,
                 KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.ALL);
-        assertFalse("Null values should be excluded.", map.containsKey("alternateTitles"));
-        assertTrue ("Null values should be included.", all.containsKey("alternateTitles"));
-        assertTrue ("'all' should be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
-        assertFalse("'all' should be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
+        assertFalse("Null values shall be excluded.", map.containsKey("alternateTitles"));
+        assertTrue ("Null values shall be included.", all.containsKey("alternateTitles"));
+        assertTrue ("'all' shall be a larger map than 'map'.", all.entrySet().containsAll(map.entrySet()));
+        assertFalse("'all' shall be a larger map than 'map'.", map.entrySet().containsAll(all.entrySet()));
         assertArrayEquals(new SimpleEntry<?,?>[] {
             new SimpleEntry<String,Object>("title",                   title),
             new SimpleEntry<String,Object>("alternateTitles",         emptyList()),
             new SimpleEntry<String,Object>("dates",                   emptyList()),
-            new SimpleEntry<String,Object>("edition",                 null),
+            new SimpleEntry<String,Object>("edition",                 NilReason.UNKNOWN.createNilObject(InternationalString.class)),
             new SimpleEntry<String,Object>("editionDate",             null),
             new SimpleEntry<String,Object>("identifiers",             citation.getIdentifiers()),
             new SimpleEntry<String,Object>("citedResponsibleParties", singletonList(author)),
@@ -212,9 +246,9 @@ public final strictfp class ValueMapTest
          * Remove the ISBN value. Result shall be:
          *
          * Citation
-         * ├───Title…………………………………………………… Undercurrent
-         * └───Cited Responsible Parties
-         *     └───Individual Name……………… Testsuya Toyoda
+         *   ├─Title…………………………………………………… Undercurrent
+         *   └─Cited Responsible Parties
+         *       └─Individual Name……………… Testsuya Toyoda
          */
         assertEquals("9782505004509", map.remove("ISBN"));
         assertNull("ISBN shall have been removed.", citation.getISBN());
@@ -227,10 +261,10 @@ public final strictfp class ValueMapTest
          * Add a value. Result shall be:
          *
          * Citation
-         * ├───Title…………………………………………………… Undercurrent
-         * ├───Cited Responsible Parties
-         * │   └───Individual Name……………… Testsuya Toyoda
-         * └───Presentation Forms………………… document hardcopy
+         *   ├─Title…………………………………………………… Undercurrent
+         *   ├─Cited Responsible Parties
+         *   │   └─Individual Name……………… Testsuya Toyoda
+         *   └─Presentation Forms………………… document hardcopy
          */
         assertNull(map.put("presentationForm", DOCUMENT_HARDCOPY));
         assertEquals(DOCUMENT_HARDCOPY, getSingleton(citation.getPresentationForms()));
@@ -243,12 +277,12 @@ public final strictfp class ValueMapTest
          * Add back the ISBN value. Result shall be:
          *
          * Citation
-         * ├───Title…………………………………………………… Undercurrent
-         * ├───Identifiers…………………………………… 9782505004509
-         * ├───Cited Responsible Parties
-         * │   └───Individual Name……………… Testsuya Toyoda
-         * ├───Presentation Forms………………… document hardcopy
-         * └───ISBN……………………………………………………… 9782505004509
+         *   ├─Title…………………………………………………… Undercurrent
+         *   ├─Identifiers…………………………………… 9782505004509
+         *   ├─Cited Responsible Parties
+         *   │   └─Individual Name……………… Testsuya Toyoda
+         *   ├─Presentation Forms………………… document hardcopy
+         *   └─ISBN……………………………………………………… 9782505004509
          */
         assertNull(map.put("ISBN", "9782505004509"));
         assertEquals("9782505004509", citation.getISBN());

Modified: sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/LoggingWatcher.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -63,6 +63,8 @@ public strictfp class LoggingWatcher ext
      * for the log messages before the tests are run. This installation will cause the
      * {@link #isLoggable(LogRecord)} method to be invoked when a message is logged.
      *
+     * @param description A description of the JUnit test which is starting.
+     *
      * @see #isLoggable(LogRecord)
      */
     @Override
@@ -75,6 +77,8 @@ public strictfp class LoggingWatcher ext
     /**
      * Invoked when a test method finishes (whether passing or failing)
      * This method removes the filter which had been set for testing purpose.
+     *
+     * @param description A description of the JUnit test that finished.
      */
     @Override
     public final void finished(final FrameworkMethod method) {

Modified: sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultResolutionTest.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -16,7 +16,10 @@
  */
 package org.apache.sis.metadata.iso.identification;
 
+import javax.xml.bind.JAXBException;
+import org.apache.sis.xml.XML;
 import org.apache.sis.metadata.iso.LoggingWatcher;
+import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Rule;
 import org.junit.Test;
@@ -32,6 +35,7 @@ import static org.apache.sis.test.Assert
  * @version 0.3
  * @module
  */
+@DependsOn(DefaultRepresentativeFractionTest.class)
 public final strictfp class DefaultResolutionTest extends TestCase {
     /**
      * A JUnit {@linkplain Rule rule} for listening to log events. This field is public
@@ -77,4 +81,65 @@ public final strictfp class DefaultResol
         assertNull("equivalentScale", metadata.getEquivalentScale());
         assertNull("distance", metadata.getDistance());
     }
+
+    /**
+     * Tests XML (un)marshalling of a resolution element. The main purpose of this method is to test our
+     * workaround for a strange JAXB behavior (bug?).  For an unknown reason, we are unable to annotate the
+     * {@link DefaultResolution#getDistance()} method directly. Doing so cause JAXB to randomly ignores the
+     * {@code <gmd:distance>} property. Annotating a separated method which in turn invokes the real method
+     * seems to work.
+     *
+     * <p>This test creates a {@link DefaultResolution} instance which is expected to be marshalled as below
+     * (ignoring namespace declarations):</p>
+     *
+     * {@preformat xml
+     *   <gmd:MD_Resolution>
+     *     <gmd:distance>
+     *       <gco:Distance uom=\"http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance>
+     *     </gmd:distance>
+     *   </gmd:MD_Resolution>
+     * }
+     *
+     * If we annotate the public {@code getDistance()} directly, JAXB will sometime marshals the resolution as
+     * expected, or sometime marshals an empty element as below:
+     *
+     * {@preformat xml
+     *   <gmd:MD_Resolution/>
+     * }
+     *
+     * In the later case, debugging shows that the {@code getDistance()} method is simply never invoked.
+     * Whether the distance is marshaled or not seems totally random: just executing this test many time
+     * make both cases to occur (however failures occur more often the successes).
+     *
+     * <p>Annotating an other method as a workaround seems to always work. See the {@link DefaultResolution#getValue()}
+     * javadoc for instructions about how to check if this workaround is still needed with more recent JAXB versions.</p>
+     *
+     * @throws JAXBException If an error occurred while marshalling the element.
+     *
+     * @see DefaultResolution#getValue()
+     */
+    @Test
+    public void testXML() throws JAXBException {
+        final DefaultResolution resolution = new DefaultResolution();
+        resolution.setDistance(1000.0);
+        final String xml = XML.marshal(resolution);
+        assertTrue("<gmd:distance> element is missing. If this test fails randomly, "
+                + "see DefaultResolutionTest.testXML() javadoc for more information", xml.contains("distance"));
+        /*
+         * Following test is done as a matter of principle, but should not be a problem.
+         * The real issue is the <gmd:distance> which happen to be randomly missing for
+         * an unknown reason.
+         */
+        assertXmlEquals(
+                "<gmd:MD_Resolution>\n" +
+                "  <gmd:distance>\n" +
+                "    <gco:Distance uom=\"http://schemas.opengis.net/iso/19139/20070417/resources/uom/gmxUom.xml#xpointer(//*[@gml:id='m'])\">1000.0</gco:Distance>\n" +
+                "  </gmd:distance>\n" +
+                "</gmd:MD_Resolution>", xml, "xmlns:*");
+        /*
+         * Unmarshal the element back to a Java object, as a safety.
+         * Should not be a problem neither.
+         */
+        assertEquals(resolution, XML.unmarshal(xml));
+    }
 }

Modified: sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-metadata/src/test/java/org/apache/sis/test/suite/MetadataTestSuite.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -26,7 +26,7 @@ import org.junit.BeforeClass;
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3
- * @version 0.3
+ * @version 0.4
  * @module
  */
 @Suite.SuiteClasses({
@@ -34,7 +34,9 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.iso.citation.DefaultCitationDateTest.class,
     org.apache.sis.metadata.iso.citation.DefaultCitationTest.class,
     org.apache.sis.metadata.iso.identification.DefaultKeywordsTest.class,
+    org.apache.sis.metadata.iso.identification.DefaultRepresentativeFractionTest.class,
     org.apache.sis.metadata.iso.identification.DefaultResolutionTest.class,
+    org.apache.sis.metadata.iso.identification.DefaultBrowseGraphicTest.class,
     org.apache.sis.metadata.iso.spatial.DefaultGeorectifiedTest.class,
     org.apache.sis.metadata.iso.maintenance.DefaultScopeDescriptionTest.class,
     org.apache.sis.metadata.iso.quality.AbstractElementTest.class,
@@ -42,6 +44,7 @@ import org.junit.BeforeClass;
     // Classes using Java reflection.
     org.apache.sis.metadata.PropertyInformationTest.class,
     org.apache.sis.metadata.PropertyAccessorTest.class,
+    org.apache.sis.metadata.SpecialCasesTest.class,
     org.apache.sis.metadata.NameMapTest.class,
     org.apache.sis.metadata.TypeMapTest.class,
     org.apache.sis.metadata.InformationMapTest.class,
@@ -49,9 +52,24 @@ import org.junit.BeforeClass;
     org.apache.sis.metadata.TreeNodeChildrenTest.class,
     org.apache.sis.metadata.TreeNodeTest.class,
     org.apache.sis.metadata.TreeTableViewTest.class,
+    org.apache.sis.metadata.TreeTableFormatTest.class,
     org.apache.sis.metadata.MetadataStandardTest.class,
     org.apache.sis.metadata.PrunerTest.class,
-    org.apache.sis.metadata.iso.AllMetadataTest.class
+    org.apache.sis.metadata.AbstractMetadataTest.class,
+    org.apache.sis.metadata.iso.ImmutableIdentifierTest.class,
+    org.apache.sis.metadata.iso.AllMetadataTest.class,
+
+    // XML marshalling.
+    org.apache.sis.internal.jaxb.code.CodeListMarshallingTest.class,
+    org.apache.sis.internal.jaxb.gmd.LanguageMarshallingTest.class,
+    org.apache.sis.internal.jaxb.gml.TimePeriodTest.class,
+    org.apache.sis.xml.FreeTextMarshallingTest.class,
+    org.apache.sis.xml.NilReasonMarshallingTest.class,
+    org.apache.sis.xml.AnchorMarshallingTest.class,
+    org.apache.sis.xml.ObjectReferenceMarshallingTest.class,
+    org.apache.sis.xml.CustomMetadataTest.class,
+    org.apache.sis.xml.ImageryMarshallingTest.class,
+    org.apache.sis.xml.MetadataMarshallingTest.class
 })
 public final strictfp class MetadataTestSuite extends TestSuite {
     /**

Modified: sis/branches/Shapefile/core/sis-referencing/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/pom.xml?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/pom.xml (original)
+++ sis/branches/Shapefile/core/sis-referencing/pom.xml Sun Aug 25 15:49:51 2013
@@ -28,9 +28,10 @@
   <parent>
     <groupId>org.apache.sis</groupId>
     <artifactId>core</artifactId>
-    <version>0.3-geoapi3.0-SNAPSHOT</version>
+    <version>0.4-SNAPSHOT</version>
   </parent>
 
+  <groupId>org.apache.sis.core</groupId>
   <artifactId>sis-referencing</artifactId>
   <packaging>bundle</packaging>
   <name>Apache SIS referencing</name>
@@ -80,7 +81,7 @@ Implementations of Coordinate Reference 
 
       <!-- Collect JAR files in <root>/target/binaries directory. -->
       <plugin>
-        <groupId>org.apache.sis</groupId>
+        <groupId>org.apache.sis.core</groupId>
         <artifactId>sis-build-helper</artifactId>
         <version>${sis.plugin.version}</version>
         <executions>
@@ -111,7 +112,7 @@ Implementations of Coordinate Reference 
        =========================================================== -->
   <dependencies>
     <dependency>
-      <groupId>org.apache.sis</groupId>
+      <groupId>org.apache.sis.core</groupId>
       <artifactId>sis-utility</artifactId>
       <version>${project.version}</version>
     </dependency>
@@ -119,14 +120,14 @@ Implementations of Coordinate Reference 
       <groupId>org.opengis</groupId>
       <artifactId>geoapi</artifactId>
     </dependency>
+
+    <!-- Test dependencies -->
     <dependency>
       <groupId>org.opengis</groupId>
       <artifactId>geoapi-conformance</artifactId>
     </dependency>
-
-    <!-- Test dependencies -->
     <dependency>
-      <groupId>org.apache.sis</groupId>
+      <groupId>org.apache.sis.core</groupId>
       <artifactId>sis-utility</artifactId>
       <version>${project.version}</version>
       <type>test-jar</type>

Modified: sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/core/LatLonPointRadius.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/core/LatLonPointRadius.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/core/LatLonPointRadius.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/core/LatLonPointRadius.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -1,4 +1,4 @@
-/**
+/*
  * 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.
@@ -24,59 +24,59 @@ import java.awt.geom.Rectangle2D;
 
 //SIS imports
 import org.apache.sis.distance.DistanceUtils;
+import org.apache.sis.geometry.DirectPosition2D;
+import org.apache.sis.geometry.GeneralDirectPosition;
 
 /**
  * Represents a 2D point associated with a radius to enable great circle
  * estimation on earth surface.
- * 
+ *
+ * @deprecated Replaced by {@link org.opengis.geometry.DirectPosition}, which is derived from OGC/ISO specifications.
  */
-public class LatLonPointRadius {
-
-  private LatLon center;
-  private double radius;
+@Deprecated
+public class LatLonPointRadius extends GeneralDirectPosition {
 
   /**
    * Creates a representation of point-radius search region.
-   * 
+   *
    * @param center
    *          the center of the search region
    * @param radius
    *          the radius of the search region
    */
-  public LatLonPointRadius(LatLon center, double radius) {
-    this.center = center;
-    this.radius = radius;
+  public LatLonPointRadius(DirectPosition2D center, double radius) {
+    super(center.x, center.y, radius);
   }
 
   /**
    * Gets the circular region approximation on the earth surface using haversine
    * formula.
-   * 
+   *
    * @param numberOfPoints
    *          the number of points used to estimate the circular region
-   * @return an array of LatLon representing the points that estimate the
+   * @return an array of DirectPosition2D representing the points that estimate the
    *         circular region
    */
-  public LatLon[] getCircularRegionApproximation(int numberOfPoints) {
-    if (this.radius >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
-      LatLon[] points = new LatLon[5];
-      points[0] = new LatLon(-90.0, -180.0);
-      points[1] = new LatLon(90.0, -180.0);
-      points[2] = new LatLon(90.0, 180.0);
-      points[3] = new LatLon(-90.0, 180.0);
+  public DirectPosition2D[] getCircularRegionApproximation(int numberOfPoints) {
+    if (super.getOrdinate(2) >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
+      DirectPosition2D[] points = new DirectPosition2D[5];
+      points[0] = new DirectPosition2D(-180.0, -90.0);
+      points[1] = new DirectPosition2D(-180.0, 90.0);
+      points[2] = new DirectPosition2D(180.0, 90.0);
+      points[3] = new DirectPosition2D(180.0, -90.0);
       points[4] = points[0];
       return points;
     }
     // plus one to add closing point
-    LatLon[] points = new LatLon[numberOfPoints + 1];
-    
+    DirectPosition2D[] points = new DirectPosition2D[numberOfPoints + 1];
+
     double bearingIncrement = 0;
     if (numberOfPoints > 0) { bearingIncrement = 360/numberOfPoints; }
 
-    for (int i = 0; i < numberOfPoints; i++) 
+    for (int i = 0; i < numberOfPoints; i++)
     {
-      points[i] = DistanceUtils.getPointOnGreatCircle(this.center.getLat(),
-          this.center.getLon(), radius, i * bearingIncrement);
+      points[i] = DistanceUtils.getPointOnGreatCircle(super.getOrdinate(1),
+          super.getOrdinate(0), super.getOrdinate(2), i * bearingIncrement);
     }
 
     points[numberOfPoints] = points[0];
@@ -86,35 +86,36 @@ public class LatLonPointRadius {
 
   /**
    * Calculates the rectangular region enclosing the circular search region.
-   * 
+   *
    * @param numberOfPoints
    *          the number of points used to estimate the circular search region
    * @return Java Rectangle2D object that bounds the circlar search region
    */
   public Rectangle2D getRectangularRegionApproximation(int numberOfPoints) {
-    if (this.radius >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
+    if (super.getOrdinate(2) >= DistanceUtils.HALF_EARTH_CIRCUMFERENCE) {
       return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
     }
     int numberOfCrossOvers = 0;
 
     Path2D path = new Path2D.Double();
-    LatLon initPT = DistanceUtils.getPointOnGreatCircle(this.center.getLat(),
-        this.center.getLon(), this.radius, 0);
-    path.moveTo(initPT.getShiftedLon(), initPT.getShiftedLat());
+    DirectPosition2D initPT = DistanceUtils.getPointOnGreatCircle(super.getOrdinate(1),
+        super.getOrdinate(0), super.getOrdinate(2), 0);
+    path.moveTo(initPT.x + 180.0, initPT.y + 90.0);
+
+    DirectPosition2D currPT = initPT;
 
-    LatLon currPT = initPT;
     for (int i = 1; i < 360; i++) {
 
-      LatLon pt = DistanceUtils.getPointOnGreatCircle(this.center.getLat(),
-          this.center.getLon(), this.radius, i);
-      path.lineTo(pt.getShiftedLon(), pt.getShiftedLat());
+      DirectPosition2D pt = DistanceUtils.getPointOnGreatCircle(super.getOrdinate(1),
+          super.getOrdinate(0), super.getOrdinate(2), i);
+      path.lineTo(pt.x + 180.0, pt.y + 90.0);
 
-      if (dateLineCrossOver(currPT.getNormLon(), pt.getNormLon())) {
+      if (dateLineCrossOver(getNormLon(currPT.x), getNormLon(pt.x))) {
         numberOfCrossOvers++;
       }
       currPT = pt;
     }
-    if (dateLineCrossOver(initPT.getNormLon(), currPT.getNormLon())) {
+    if (dateLineCrossOver(getNormLon(initPT.x), getNormLon(currPT.x))) {
       numberOfCrossOvers++;
     }
 
@@ -126,8 +127,7 @@ public class LatLonPointRadius {
       Rectangle2D r = path.getBounds2D();
       Rectangle2D lowerHalf = new Rectangle2D.Double(0.0, 0.0, 360.0, r
           .getMaxY());
-      if (lowerHalf.contains(this.center.getShiftedLon(), this.center
-          .getShiftedLat())) {
+      if (lowerHalf.contains(super.getOrdinate(0) + 180, super.getOrdinate(1) + 90)) {
         return lowerHalf;
       } else {
         return new Rectangle2D.Double(0.0, r.getMinY(), 360.0, 180.0 - r
@@ -135,7 +135,7 @@ public class LatLonPointRadius {
       }
     }
 
-    if (path.contains(this.center.getShiftedLon(), this.center.getShiftedLat())) {
+    if (path.contains(super.getOrdinate(0) + 180, super.getOrdinate(1) + 90)) {
       Rectangle2D r = path.getBounds2D();
       if ((r.getMaxX() - r.getMinX()) > 359.0) {
         return new Rectangle2D.Double(0.0, 0.0, 360.0, 180.0);
@@ -158,9 +158,27 @@ public class LatLonPointRadius {
   }
 
   /**
+   * Normalizes the longitude values to be between -180.0 and 180.0
+   *
+   * @return longitude value that is between -180.0 and 180.0 inclusive
+   */
+  private static double getNormLon(double normLon) {
+    if (normLon > 180.0) {
+      while (normLon > 180.0) {
+        normLon -= 360.0;
+      }
+    } else if (normLon < -180.0) {
+      while (normLon < -180.0) {
+        normLon += 360.0;
+      }
+    }
+    return normLon;
+  }
+
+  /**
    * Returns true if the line segment connecting the two specified longitudes
    * crosses the international dateline.
-   * 
+   *
    * @param longitude1
    *          first longitude
    * @param longitude2
@@ -168,7 +186,7 @@ public class LatLonPointRadius {
    * @return true if the line segment crosses the internation dateline, false
    *         otherwise
    */
-  private boolean dateLineCrossOver(double longitude1, double longitude2) {
+  private static boolean dateLineCrossOver(double longitude1, double longitude2) {
     if (Math.abs(longitude1 - longitude2) > 180.0)
       return true;
     return false;

Modified: sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/distance/DistanceUtils.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -18,7 +18,7 @@
 package org.apache.sis.distance;
 
 // SIS imports
-import org.apache.sis.core.LatLon;
+import org.apache.sis.geometry.DirectPosition2D;
 
 /**
  * Class to calculate distances on earth surface. Actual calculation code very
@@ -43,7 +43,7 @@ public class DistanceUtils {
    *          the great circle bearing
    * @return a coordinate at the specified bearing
    */
-  public static LatLon getPointOnGreatCircle(double latitude, double longitude,
+  public static DirectPosition2D getPointOnGreatCircle(double latitude, double longitude,
       double d, double bearing) {
     double angularDistance = d / EARTH_RADIUS;
 
@@ -62,7 +62,7 @@ public class DistanceUtils {
         + Math.atan2(Math.sin(brng) * sinD * cosLat, cosD - sinLat
             * Math.sin(lat2));
 
-    return new LatLon(Math.toDegrees(lat2), Math.toDegrees(lon2));
+    return new DirectPosition2D(Math.toDegrees(lat2), Math.toDegrees(lon2));
   }
 
   /**

Modified: sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractDirectPosition.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -142,6 +142,8 @@ public abstract class AbstractDirectPosi
      *
      * @return {@code true} if this position has been modified as a result of this method call,
      *         or {@code false} if no change has been done.
+     *
+     * @see GeneralEnvelope#normalize()
      */
     public boolean normalize() {
         boolean changed = false;

Modified: sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/AbstractEnvelope.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -80,6 +80,7 @@ import org.apache.sis.internal.jdk7.Obje
  *   <li>{@link #getMaximum(int)}</li>
  *   <li>{@link #getMedian(int)}</li>
  *   <li>{@link #getSpan(int)}</li>
+ *   <li>{@link #toSimpleEnvelopes()}</li>
  *   <li>{@link #contains(DirectPosition)}</li>
  *   <li>{@link #contains(Envelope, boolean)}</li>
  *   <li>{@link #intersects(Envelope, boolean)}</li>
@@ -110,6 +111,12 @@ import org.apache.sis.internal.jdk7.Obje
  */
 public abstract class AbstractEnvelope implements Envelope {
     /**
+     * An empty array of envelopes, to be returned by {@link #toSimpleEnvelopes()}
+     * when en envelope is empty.
+     */
+    private static final Envelope[] EMPTY = new Envelope[0];
+
+    /**
      * Constructs an envelope.
      */
     protected AbstractEnvelope() {
@@ -494,6 +501,111 @@ public abstract class AbstractEnvelope i
     }
 
     /**
+     * Returns this envelope as an array of simple (without wraparound) envelopes.
+     * The length of the returned array depends on the number of dimensions where a
+     * {@linkplain org.opengis.referencing.cs.RangeMeaning#WRAPAROUND wraparound} range is found.
+     * Typically, wraparound occurs only in the range of longitude values, when the range crosses
+     * the anti-meridian (a.k.a. date line). However this implementation will take in account any
+     * axis having wraparound {@linkplain CoordinateSystemAxis#getRangeMeaning() range meaning}.
+     *
+     * <p>Special cases:</p>
+     *
+     * <ul>
+     *   <li>If this envelope {@linkplain #isEmpty() is empty}, then this method returns an empty array.</li>
+     *   <li>If this envelope does not have any wraparound behavior, then this method returns {@code this}
+     *       in an array of length 1. This envelope is <strong>not</strong> cloned.</li>
+     *   <li>If this envelope crosses the <cite>anti-meridian</cite> (a.k.a. <cite>date line</cite>)
+     *       then this method represents this envelope as two separated simple envelopes.
+     *   <li>While uncommon, the envelope could theoretically crosses the limit of other axis having
+     *       wraparound range meaning. If wraparound occur along <var>n</var> axes, then this method
+     *       represents this envelope as 2ⁿ separated simple envelopes.
+     * </ul>
+     *
+     * @return A representation of this envelope as an array of non-empty envelope.
+     *
+     * @see Envelope2D#toRectangles()
+     *
+     * @since 0.4
+     */
+    public Envelope[] toSimpleEnvelopes() {
+        long isWrapAround = 0; // A bitmask of the dimensions having a "wrap around" behavior.
+        CoordinateReferenceSystem crs = null;
+        final int dimension = getDimension();
+        for (int i=0; i!=dimension; i++) {
+            final double span = getUpper(i) - getLower(i); // Do not use getSpan(i).
+            if (!(span > 0)) { // Use '!' for catching NaN.
+                if (!isNegative(span)) {
+                    return EMPTY; // Span is positive zero.
+                }
+                if (crs == null) {
+                    crs = getCoordinateReferenceSystem();
+                }
+                if (!isWrapAround(crs, i)) {
+                    return EMPTY;
+                }
+                if (i >= Long.SIZE) {
+                    // Actually the limit in our current implementation is not the number of axes, but the index of
+                    // axes where a wraparound has been found. However we consider that having more than 64 axes in
+                    // a CRS is unusual enough for not being worth to make the distinction in the error message.
+                    throw new IllegalStateException(Errors.format(Errors.Keys.ExcessiveListSize_2, "axis", dimension));
+                }
+                isWrapAround |= (1L << i);
+            }
+        }
+        /*
+         * The number of simple envelopes is 2ⁿ where n is the number of wraparound found. In most
+         * cases, isWrapAround == 0 so we have an array of length 1 containing only this envelope.
+         */
+        final int bitCount = Long.bitCount(isWrapAround);
+        if (bitCount >= Integer.SIZE - 1) {
+            // Should be very unusual, but let be paranoiac.
+            throw new IllegalStateException(Errors.format(Errors.Keys.ExcessiveListSize_2, "wraparound", bitCount));
+        }
+        final Envelope[] envelopes = new Envelope[1 << bitCount];
+        if (envelopes.length == 1) {
+            envelopes[0] = this;
+        } else {
+            /*
+             * Need to create at least 2 envelopes. Instantiate now all envelopes with ordinate values
+             * initialized to a copy of this envelope. We will write directly in their internal arrays later.
+             */
+            double[] c = new double[dimension * 2];
+            for (int i=0; i<dimension; i++) {
+                c[i            ] = getLower(i);
+                c[i + dimension] = getUpper(i);
+            }
+            final double[][] ordinates = new double[envelopes.length][];
+            for (int i=0; i<envelopes.length; i++) {
+                final GeneralEnvelope envelope = new GeneralEnvelope(i == 0 ? c : c.clone());
+                envelope.crs = crs;
+                envelopes[i] = envelope;
+                ordinates[i] = envelope.ordinates;
+            }
+            /*
+             * Assign the minimum and maximum ordinate values in the dimension where a wraparound has been found.
+             * The 'for' loop below iterates only over the 'i' values for which the 'isWrapAround' bit is set to 1.
+             */
+            int mask = 1; // For identifying whether we need to set the lower or the upper ordinate.
+            final CoordinateSystem cs = crs.getCoordinateSystem(); // Should not be null at this point.
+            for (int i; (i = Long.numberOfTrailingZeros(isWrapAround)) != Long.SIZE; isWrapAround &= ~(1L << i)) {
+                final CoordinateSystemAxis axis = cs.getAxis(i);
+                final double min = axis.getMinimumValue();
+                final double max = axis.getMaximumValue();
+                for (int j=0; j<ordinates.length; j++) {
+                    c = ordinates[j];
+                    if ((j & mask) == 0) {
+                        c[i + dimension] = max;
+                    } else {
+                        c[i] = min;
+                    }
+                }
+                mask <<= 1;
+            }
+        }
+        return envelopes;
+    }
+
+    /**
      * Determines whether or not this envelope is empty. An envelope is non-empty only if it has
      * at least one {@linkplain #getDimension() dimension}, and the {@linkplain #getSpan(int) span}
      * is greater than 0 along all dimensions. Note that {@link #isAllNaN()} always returns

Modified: sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelope2D.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -81,6 +81,7 @@ import org.apache.sis.internal.jdk7.Obje
  *   <li>{@link #getSpan(int)}</li>
  *   <li>{@link #getMedian(int)}</li>
  *   <li>{@link #isEmpty()}</li>
+ *   <li>{@link #toRectangles()}</li>
  *   <li>{@link #contains(double,double)}</li>
  *   <li>{@link #contains(Rectangle2D)} and its variant receiving {@code double} arguments</li>
  *   <li>{@link #intersects(Rectangle2D)} and its variant receiving {@code double} arguments</li>
@@ -98,7 +99,7 @@ import org.apache.sis.internal.jdk7.Obje
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Johann Sorel (Geomatys)
  * @since   0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.4
  * @module
  *
  * @see GeneralEnvelope
@@ -111,6 +112,17 @@ public class Envelope2D extends Rectangl
     private static final long serialVersionUID = 761232175464415062L;
 
     /**
+     * The number of dimensions in every {@code Envelope2D}.
+     */
+    private static final int DIMENSION = 2;
+
+    /**
+     * An empty array of Java2D rectangles, to be returned by {@link #toRectangles()}
+     * when en envelope is empty.
+     */
+    private static final Rectangle2D.Double[] EMPTY = new Rectangle2D.Double[0];
+
+    /**
      * The coordinate reference system, or {@code null}.
      */
     private CoordinateReferenceSystem crs;
@@ -152,7 +164,7 @@ public class Envelope2D extends Rectangl
          */
         this(lowerCorner.getOrdinate(0), lowerCorner.getOrdinate(1),
              upperCorner.getOrdinate(0), upperCorner.getOrdinate(1));
-        ensureDimensionMatches("crs", 2, crs);
+        ensureDimensionMatches("crs", DIMENSION, crs);
         this.crs = crs;
     }
 
@@ -224,7 +236,7 @@ public class Envelope2D extends Rectangl
             throws MismatchedDimensionException
     {
         super(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight()); // Really 'super', not 'this'.
-        ensureDimensionMatches("crs", 2, crs);
+        ensureDimensionMatches("crs", DIMENSION, crs);
         this.crs = crs;
     }
 
@@ -247,7 +259,7 @@ public class Envelope2D extends Rectangl
             final double width, final double height) throws MismatchedDimensionException
     {
         super(x, y, width, height); // Really 'super', not 'this'.
-        ensureDimensionMatches("crs", 2, crs);
+        ensureDimensionMatches("crs", DIMENSION, crs);
         this.crs = crs;
     }
 
@@ -270,16 +282,18 @@ public class Envelope2D extends Rectangl
      * @param crs The new coordinate reference system, or {@code null}.
      */
     public void setCoordinateReferenceSystem(final CoordinateReferenceSystem crs) {
-        ensureDimensionMatches("crs", 2, crs);
+        ensureDimensionMatches("crs", DIMENSION, crs);
         this.crs = crs;
     }
 
     /**
      * Returns the number of dimensions, which is always 2.
+     *
+     * @return Always 2 for bi-dimensional objects.
      */
     @Override
     public final int getDimension() {
-        return 2;
+        return DIMENSION;
     }
 
     /**
@@ -500,11 +514,11 @@ public class Envelope2D extends Rectangl
      * (@linkplain #height} is considered as a non-empty area if the corresponding
      * axis has the {@linkplain org.opengis.referencing.cs.RangeMeaning#WRAPAROUND
      * wraparound} range meaning.
-     * <p>
-     * Note that if the {@linkplain #width} or {@linkplain #height} value is
+     *
+     * <p>Note that if the {@linkplain #width} or {@linkplain #height} value is
      * {@link java.lang.Double#NaN NaN}, then the envelope is considered empty.
      * This is different than the default {@link java.awt.geom.Rectangle2D.Double#isEmpty()}
-     * implementation, which doesn't check for {@code NaN} values.
+     * implementation, which doesn't check for {@code NaN} values.</p>
      */
     @Override
     public boolean isEmpty() {
@@ -513,6 +527,103 @@ public class Envelope2D extends Rectangl
     }
 
     /**
+     * Returns this envelope as non-empty Java2D rectangle objects. This method returns an array of length 0, 1,
+     * 2 or 4 depending on whether the envelope crosses the anti-meridian or the limit of any other axis having
+     * {@linkplain org.opengis.referencing.cs.RangeMeaning#WRAPAROUND wraparound} range meaning.
+     * More specifically:
+     *
+     * <ul>
+     *   <li>If this envelope {@linkplain #isEmpty() is empty}, then this method returns an empty array.</li>
+     *   <li>If this envelope does not have any wraparound behavior, then this method returns a copy
+     *       of this envelope as an instance of {@code Rectangle2D.Double} in an array of length 1.</li>
+     *   <li>If this envelope crosses the <cite>anti-meridian</cite> (a.k.a. <cite>date line</cite>)
+     *       then this method represents this envelope as two separated rectangles.
+     *   <li>While uncommon, the envelope could theoretically crosses the limit of other axis having
+     *       wraparound range meaning. If wraparound occur along the two axes, then this method
+     *       represents this envelope as four separated rectangles.
+     * </ul>
+     *
+     * {@note The return type is the <code>Rectangle2D.Double</code> implementation class rather than the
+     *        <code>Rectangle2D</code> abstract class because the <code>Envelope2D</code> class hierarchy
+     *        already exposes this implementation choice.}
+     *
+     * @return A representation of this envelope as an array of non-empty Java2D rectangles.
+     *         The array never contains {@code this}.
+     *
+     * @see GeneralEnvelope#toSimpleEnvelopes()
+     *
+     * @since 0.4
+     */
+    public Rectangle2D.Double[] toRectangles() {
+        int isWrapAround = 0; // A bitmask of the dimensions having a "wrap around" behavior.
+        for (int i=0; i!=DIMENSION; i++) {
+            final double span = (i == 0) ? width : height;
+            if (!(span > 0)) { // Use '!' for catching NaN.
+                if (!isNegative(span) || !isWrapAround(crs, i)) {
+                    return EMPTY;
+                }
+                isWrapAround |= (1 << i);
+            }
+        }
+        /*
+         * The number of rectangles is 2ⁿ where n is the number of wraparound found.
+         */
+        final Rectangle2D.Double[] rect = new Rectangle2D.Double[1 << Integer.bitCount(isWrapAround)];
+        for (int i=0; i<rect.length; i++) {
+            rect[i] = new Rectangle2D.Double(x, y, width, height);
+        }
+        if ((isWrapAround & 1) != 0) {
+            /*
+             *  (x+width)   (x)
+             *          ↓   ↓
+             *    ──────┐   ┌───────
+             *    …next │   │ start…
+             *    ──────┘   └───────
+             */
+            final CoordinateSystemAxis axis = getAxis(crs, 0);
+            final Rectangle2D.Double start = rect[0];
+            final Rectangle2D.Double next  = rect[1];
+            start.width = axis.getMaximumValue() - x;
+            next.x      = axis.getMinimumValue();
+            next.width += x - next.x;
+        }
+        if ((isWrapAround & 2) != 0) {
+            /*
+             *              │   ⋮   │
+             *              │ start │
+             * (y)        → └───────┘
+             * (y+height) → ┌───────┐
+             *              │ next  │
+             *              │   ⋮   │
+             */
+            final CoordinateSystemAxis axis = getAxis(crs, 1);
+            final Rectangle2D.Double start = rect[0];
+            final Rectangle2D.Double next  = rect[isWrapAround - 1]; // == 1 if y is the only wraparound axis, or 2 otherwise.
+            start.height = axis.getMaximumValue() - y;
+            next.y       = axis.getMinimumValue();
+            next.height += y - next.y;
+        }
+        if (isWrapAround == 3) {
+            /*
+             * If there is a wraparound along both axes, copy the values.
+             * The (x) and (y) labels indicate which values to copy.
+             *
+             *      (y) R1 │   │ R0
+             *    ─────────┘   └─────────
+             *    ─────────┐   ┌─────────
+             *    (x,y) R3 │   │ R2 (x)
+             */
+            rect[1].height = rect[0].height;
+            rect[2].width  = rect[0].width;
+            rect[3].x      = rect[1].x;
+            rect[3].width  = rect[1].width;
+            rect[3].y      = rect[2].y;
+            rect[3].height = rect[2].height;
+        }
+        return rect;
+    }
+
+    /**
      * Tests if a specified coordinate is inside the boundary of this envelope. If it least one
      * of the given ordinate value is {@link java.lang.Double#NaN NaN}, then this method returns
      * {@code false}.
@@ -579,7 +690,7 @@ public class Envelope2D extends Rectangl
      */
     @Override
     public boolean contains(final double rx, final double ry, final double rw, final double rh) {
-        for (int i=0; i!=2; i++) {
+        for (int i=0; i!=DIMENSION; i++) {
             final double min0, min1, span0, span1;
             if (i == 0) {
                 min0 =  x;  span0 = width;
@@ -648,7 +759,7 @@ public class Envelope2D extends Rectangl
      */
     @Override
     public boolean intersects(final double rx, final double ry, final double rw, final double rh) {
-        for (int i=0; i!=2; i++) {
+        for (int i=0; i!=DIMENSION; i++) {
             final double min0, min1, span0, span1;
             if (i == 0) {
                 min0 =  x;  span0 = width;
@@ -692,7 +803,7 @@ public class Envelope2D extends Rectangl
     public Envelope2D createIntersection(final Rectangle2D rect) {
         final Envelope2D env = (rect instanceof Envelope2D) ? (Envelope2D) rect : null;
         final Envelope2D inter = new Envelope2D(crs, NaN, NaN, NaN, NaN);
-        for (int i=0; i!=2; i++) {
+        for (int i=0; i!=DIMENSION; i++) {
             final double min0, min1, span0, span1;
             if (i == 0) {
                 min0  = x;
@@ -778,7 +889,7 @@ public class Envelope2D extends Rectangl
     @Override
     public void add(final Rectangle2D rect) {
         final Envelope2D env = (rect instanceof Envelope2D) ? (Envelope2D) rect : null;
-        for (int i=0; i!=2; i++) {
+        for (int i=0; i!=DIMENSION; i++) {
             final double min0, min1, span0, span1;
             if (i == 0) {
                 min0  = x;

Modified: sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/Envelopes.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -113,7 +113,7 @@ public final class Envelopes extends Sta
      * parsed} by the {@code GeneralEnvelope} constructor.
      *
      * @param  envelope The envelope to format.
-     * @return The envelope as a {@code BOX} or {@code BOX3D} in WKT format.
+     * @return This envelope as a {@code BOX} or {@code BOX3D} (most typical dimensions) element.
      *
      * @see #fromWKT(CharSequence)
      * @see org.apache.sis.io.wkt

Modified: sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/main/java/org/apache/sis/geometry/GeneralEnvelope.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -80,6 +80,7 @@ import static org.apache.sis.math.MathFu
  *   <li>{@link #getMedian(int)}</li>
  *   <li>{@link #getSpan(int)}</li>
  *   <li>{@link #isEmpty()}</li>
+ *   <li>{@link #toSimpleEnvelopes() toSimpleEnvelopes()}</li>
  *   <li>{@link #contains(DirectPosition) contains(DirectPosition)}</li>
  *   <li>{@link #contains(Envelope, boolean) contains(Envelope, boolean)}</li>
  *   <li>{@link #intersects(Envelope, boolean) intersects(Envelope, boolean)}</li>
@@ -793,6 +794,8 @@ public class GeneralEnvelope extends Arr
      *
      * @return {@code true} if this envelope has been modified as a result of this method call,
      *         or {@code false} if no change has been done.
+     *
+     * @see AbstractDirectPosition#normalize()
      */
     public boolean normalize() {
         boolean changed = false;
@@ -857,10 +860,10 @@ public class GeneralEnvelope extends Arr
      * {@linkplain #getLower(int) lower ordinate value}, then there is a choice:
      *
      * <ul>
-     *   <li>If the axis has {@link RangeMeaning#WRAPAROUND}, then the lower ordinate value is
-     *       set to the {@linkplain CoordinateSystemAxis#getMinimumValue() axis minimum value}
-     *       and the upper ordinate value is set to the
-     *       {@linkplain CoordinateSystemAxis#getMaximumValue() axis maimum value}.</li>
+     *   <li>If the axis has {@link RangeMeaning#WRAPAROUND}, then:<ul>
+     *       <li>the lower ordinate value is set to the {@linkplain CoordinateSystemAxis#getMinimumValue() axis minimum value}, and</li>
+     *       <li>the upper ordinate value is set to the {@linkplain CoordinateSystemAxis#getMaximumValue() axis maximum value}.</li>
+     *     </ul></li>
      *   <li>Otherwise an {@link IllegalStateException} is thrown.</li>
      * </ul>
      *

Modified: sis/branches/Shapefile/core/sis-referencing/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/site/apt/index.apt?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/site/apt/index.apt [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/site/apt/index.apt [UTF-8] Sun Aug 25 15:49:51 2013
@@ -1,3 +1,22 @@
+~~
+~~ 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.
+~~
+
                              ------------------------------
                              Apache SIS referencing module
                              ------------------------------

Modified: sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/core/TestLatLonPointRadius.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -1,4 +1,4 @@
-/**
+/*
  * 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.
@@ -22,9 +22,12 @@ import junit.framework.TestCase;
 //JDK imports
 import java.awt.geom.Rectangle2D;
 
+//SIS imports
+import org.apache.sis.geometry.DirectPosition2D;
+
 /**
  * Tests methods from the {@link LatLonPointRadius} class.
- * 
+ *
  * @author rlaidlaw
  */
 public class TestLatLonPointRadius extends TestCase
@@ -36,7 +39,7 @@ public class TestLatLonPointRadius exten
    */
   public void testCreateLatLonPointRadius()
   {
-    LatLonPointRadius region = new LatLonPointRadius(new LatLon(0.0, 0.0), 100.0);
+    LatLonPointRadius region = new LatLonPointRadius(new DirectPosition2D(0.0, 0.0), 100.0);
     assertNotNull(region);
   }
 
@@ -45,31 +48,31 @@ public class TestLatLonPointRadius exten
    */
   public void testGetCircularRegionApproximation()
   {
-    LatLonPointRadius pr1 = new LatLonPointRadius(new LatLon(0.0, 0.0), 25000.0);
-    LatLon pts1[] = pr1.getCircularRegionApproximation(10);
+    LatLonPointRadius pr1 = new LatLonPointRadius(new DirectPosition2D(0.0, 0.0), 25000.0);
+    DirectPosition2D pts1[] = pr1.getCircularRegionApproximation(10);
     assertEquals(5, pts1.length);
-    assertEquals(-90.0, pts1[0].getLat(), EPSILON);
-    assertEquals(-180.0, pts1[0].getLon(), EPSILON);
-    assertEquals(90.0, pts1[1].getLat(), EPSILON);
-    assertEquals(-180.0, pts1[1].getLon(), EPSILON);
-    assertEquals(90.0, pts1[2].getLat(), EPSILON);
-    assertEquals(180.0, pts1[2].getLon(), EPSILON);
-    assertEquals(-90.0, pts1[3].getLat(), EPSILON);
-    assertEquals(180.0, pts1[3].getLon(), EPSILON);
-    assertEquals(-90.0, pts1[4].getLat(), EPSILON);
-    assertEquals(-180.0, pts1[4].getLon(), EPSILON);
-    
-    LatLonPointRadius pr2 = new LatLonPointRadius(new LatLon(0.0, 0.0), 1000.0);
-    LatLon pts2[] = pr2.getCircularRegionApproximation(6);
+    assertEquals(-90.0, pts1[0].y, EPSILON);
+    assertEquals(-180.0, pts1[0].x, EPSILON);
+    assertEquals(90.0, pts1[1].y, EPSILON);
+    assertEquals(-180.0, pts1[1].x, EPSILON);
+    assertEquals(90.0, pts1[2].y, EPSILON);
+    assertEquals(180.0, pts1[2].x, EPSILON);
+    assertEquals(-90.0, pts1[3].y, EPSILON);
+    assertEquals(180.0, pts1[3].x, EPSILON);
+    assertEquals(-90.0, pts1[4].y, EPSILON);
+    assertEquals(-180.0, pts1[4].x, EPSILON);
+
+    LatLonPointRadius pr2 = new LatLonPointRadius(new DirectPosition2D(0.0, 0.0), 1000.0);
+    DirectPosition2D pts2[] = pr2.getCircularRegionApproximation(6);
     assertEquals(7, pts2.length);
   }
 
   /**
    * Tests the getRectangularRegionApproximation() method.
    */
-  public void testGetRectangularRegionApproximation() 
+  public void testGetRectangularRegionApproximation()
   {
-    LatLonPointRadius pr1 = new LatLonPointRadius(new LatLon(0.0, 0.0), 25000.0);
+    LatLonPointRadius pr1 = new LatLonPointRadius(new DirectPosition2D(0.0, 0.0), 25000.0);
     Rectangle2D r1 = pr1.getRectangularRegionApproximation(10);
     assertEquals(0.0, r1.getX(), EPSILON);
     assertEquals(0.0, r1.getY(), EPSILON);

Modified: sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/geometry/AbstractEnvelopeTest.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -20,6 +20,7 @@ import java.awt.geom.Rectangle2D;
 import org.opengis.geometry.Envelope;
 import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.crs.GeographicCRS;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.TestCase;
 import org.junit.Ignore;
@@ -36,7 +37,7 @@ import static org.apache.sis.referencing
  *
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @since   0.3 (derived from geotk-3.20)
- * @version 0.3
+ * @version 0.4
  * @module
  */
 @DependsOn(GeneralDirectPositionTest.class)
@@ -44,7 +45,7 @@ public final strictfp class AbstractEnve
     /**
      * Tolerance threshold for strict floating point comparisons.
      */
-    private static final double STRICT = 0;
+    static final double STRICT = 0;
 
     /**
      * Enumeration of implementations to be tested.
@@ -459,4 +460,71 @@ public final strictfp class AbstractEnve
             verifyInvariants(type, envelope);
         }
     }
+
+    /**
+     * Tests {@link AbstractEnvelope#toSimpleEnvelopes()} on an empty envelope.
+     *
+     * @since 0.4
+     */
+    @Test
+    public void testToSimpleEnvelopesOnEmptyEnvelope() {
+        for (int type=0; type<LAST; type++) {
+            if (type != RECTANGLE) {
+                final AbstractEnvelope envelope = (AbstractEnvelope) create(type, 0, 0, 0, 0);
+                assertEquals(0, envelope.toSimpleEnvelopes().length);
+            }
+        }
+    }
+
+    /**
+     * Tests {@link AbstractEnvelope#toSimpleEnvelopes()} on a simple envelope having no wraparound axis.
+     *
+     * @since 0.4
+     */
+    @Test
+    @DependsOnMethod("testToSimpleEnvelopesOnEmptyEnvelope")
+    public void testToSimpleEnvelopesOnSimpleEnvelope() {
+        for (int type=0; type<LAST; type++) {
+            if (type != RECTANGLE) {
+                final AbstractEnvelope envelope = (AbstractEnvelope) create(type, -20, 30, -10, 15);
+                final Envelope[] simples = envelope.toSimpleEnvelopes();
+                assertEquals(1, simples.length);
+                assertSame(envelope, simples[0]);
+            }
+        }
+    }
+
+    /**
+     * Tests {@link AbstractEnvelope#toSimpleEnvelopes()} on a simple envelope having no wraparound axis.
+     *
+     * @since 0.4
+     */
+    @Test
+    @DependsOnMethod("testToSimpleEnvelopesOnEmptyEnvelope")
+    @Ignore("The tested envelope needs to be associated to CRS:84")
+    public void testToSimpleEnvelopesOverAntiMeridian() {
+        for (int type=0; type<LAST; type++) {
+            if (type != RECTANGLE) {
+                final AbstractEnvelope envelope = (AbstractEnvelope) create(type, 155, -150, 0, 50);
+                final Envelope[] simples = envelope.toSimpleEnvelopes();
+                assertEquals(2, simples.length);
+                final AbstractEnvelope e0 = (AbstractEnvelope) simples[0];
+                final AbstractEnvelope e1 = (AbstractEnvelope) simples[1];
+
+                assertEquals( 155.0, e0.getLower(0), STRICT);
+                assertEquals(   0.0, e0.getLower(1), STRICT);
+                assertEquals( 180.0, e0.getUpper(0), STRICT);
+                assertEquals(  50.0, e0.getUpper(1), STRICT);
+                assertEquals(  25.0, e0.getSpan (0), STRICT);
+                assertEquals(  50.0, e0.getSpan (1), STRICT);
+
+                assertEquals(-180.0, e1.getLower(0), STRICT);
+                assertEquals(   0.0, e1.getLower(1), STRICT);
+                assertEquals(-150.0, e1.getUpper(0), STRICT);
+                assertEquals(  50.0, e1.getUpper(1), STRICT);
+                assertEquals(  30.0, e1.getSpan (0), STRICT);
+                assertEquals(  50.0, e1.getSpan (1), STRICT);
+            }
+        }
+    }
 }

Modified: sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-referencing/src/test/java/org/apache/sis/geometry/Envelope2DTest.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -16,24 +16,28 @@
  */
 package org.apache.sis.geometry;
 
+import java.awt.geom.Rectangle2D;
 import org.apache.sis.test.DependsOn;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.opengis.test.Validators.*;
 import static org.apache.sis.referencing.Assert.*;
 import static org.apache.sis.geometry.AbstractEnvelopeTest.WGS84;
+import static org.apache.sis.geometry.AbstractEnvelopeTest.STRICT;
 
 
 /**
  * Tests the {@link Envelope2D} class.
- * Most of tests are actually performed by {@link AbstractEnvelopeTest}, which compare
+ * Most tests are actually performed by {@link AbstractEnvelopeTest}, which compare
  * {@link GeneralEnvelope} results with {@code Envelope2D} results for ensuring consistency.
  * This class adds only some tests that are specific to {@code Envelope2D} instances.
  *
  * @author  Martin Desruisseaux (Geomatys)
+ * @author  Ross Laidlaw
  * @since   0.3
- * @version 0.3
+ * @version 0.4
  * @module
  */
 @DependsOn(AbstractEnvelopeTest.class)
@@ -48,4 +52,60 @@ public final strictfp class Envelope2DTe
         assertNotSame(e1, e2);
         validate(e2);
     }
+
+    /**
+     * Tests {@link Envelope2D#toRectangles()} on an empty envelope.
+     *
+     * @since 0.4
+     */
+    @Test
+    public void testToRectanglesOnEmptyEnvelope() {
+        final Envelope2D envelope = new Envelope2D(WGS84, 0, 0, 0, 0);
+        assertEquals(0, envelope.toRectangles().length);
+    }
+
+    /**
+     * Tests {@link Envelope2D#toRectangles()} on a simple envelope having no wraparound axis.
+     *
+     * @since 0.4
+     */
+    @Test
+    public void testToRectanglesOnSimpleEnvelope() {
+        final Envelope2D envelope = new Envelope2D(WGS84, -20, -10, 50, 40);
+        final Rectangle2D[] rectangles = envelope.toRectangles();
+        assertEquals(1, rectangles.length);
+        final Rectangle2D r = rectangles[0];
+        assertNotSame("toRectangles() shall copy the envelope.", envelope, r);
+        assertEquals(-20.0, r.getX(),      STRICT);
+        assertEquals(-10.0, r.getY(),      STRICT);
+        assertEquals( 50.0, r.getWidth(),  STRICT);
+        assertEquals( 40.0, r.getHeight(), STRICT);
+    }
+
+    /**
+     * Tests {@link Envelope2D#toRectangles()} on an envelope crossing the anti-meridian.
+     * The longitude range in this test is [155 … -150].
+     *
+     * @since 0.4
+     */
+    @Test
+    @DependsOnMethod("testToRectanglesOnSimpleEnvelope")
+    @org.junit.Ignore("The tested envelope needs to be associated to CRS:84")
+    public void testToRectanglesOverAntiMeridian() {
+        final Envelope2D envelope = new Envelope2D(WGS84, 155, 0, -150 - 155, 50);
+        final Rectangle2D[] rectangles = envelope.toRectangles();
+        assertEquals(2, rectangles.length);
+        final Rectangle2D r0 = rectangles[0];
+        final Rectangle2D r1 = rectangles[1];
+
+        assertEquals( 155.0, r0.getX(),      STRICT);
+        assertEquals(   0.0, r0.getY(),      STRICT);
+        assertEquals(  25.0, r0.getWidth(),  STRICT);
+        assertEquals(  50.0, r0.getHeight(), STRICT);
+
+        assertEquals(-180.0, r1.getX(),      STRICT);
+        assertEquals(   0.0, r1.getY(),      STRICT);
+        assertEquals(  30.0, r1.getWidth(),  STRICT);
+        assertEquals(  50.0, r1.getHeight(), STRICT);
+    }
 }

Modified: sis/branches/Shapefile/core/sis-utility/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-utility/pom.xml?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-utility/pom.xml (original)
+++ sis/branches/Shapefile/core/sis-utility/pom.xml Sun Aug 25 15:49:51 2013
@@ -28,13 +28,14 @@
   <parent>
     <groupId>org.apache.sis</groupId>
     <artifactId>core</artifactId>
-    <version>0.3-geoapi3.0-SNAPSHOT</version>
+    <version>0.4-SNAPSHOT</version>
   </parent>
 
 
   <!-- ===========================================================
            Module Description
        =========================================================== -->
+  <groupId>org.apache.sis.core</groupId>
   <artifactId>sis-utility</artifactId>
   <packaging>bundle</packaging>
   <name>Apache SIS utilities</name>
@@ -134,7 +135,7 @@ Miscellaneous utilities.
 
       <!-- Compile properties files into resources UTF files and collect JAR files. -->
       <plugin>
-        <groupId>org.apache.sis</groupId>
+        <groupId>org.apache.sis.core</groupId>
         <artifactId>sis-build-helper</artifactId>
         <version>${sis.plugin.version}</version>
         <executions>
@@ -170,6 +171,8 @@ Miscellaneous utilities.
       <groupId>org.opengis</groupId>
       <artifactId>geoapi</artifactId>
     </dependency>
+
+    <!-- Test dependencies -->
     <dependency>
       <groupId>org.opengis</groupId>
       <artifactId>geoapi-conformance</artifactId>

Modified: sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/converter/ConverterRegistry.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -20,6 +20,7 @@ import java.util.Map;
 import java.util.LinkedHashMap;
 import org.apache.sis.util.Debug;
 import org.apache.sis.util.Classes;
+import org.apache.sis.util.Numbers;
 import org.apache.sis.util.ThreadSafe;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.ObjectConverter;
@@ -479,6 +480,21 @@ public class ConverterRegistry {
                 put(key, converter);
                 return converter;
             }
+            /*
+             * Still no converter found. If the source and target classes are array classes,
+             * search a converter for their components.
+             */
+            final Class<?> sourceComponent = sourceClass.getComponentType();
+            if (sourceComponent != null) {
+                final Class<?> targetComponent = targetClass.getComponentType();
+                if (targetComponent != null) {
+                    converter = new ArrayConverter<S,T>(sourceClass, targetClass, find(
+                            Numbers.primitiveToWrapper(sourceComponent),
+                            Numbers.primitiveToWrapper(targetComponent)));
+                    put(key, converter);
+                    return converter;
+                }
+            }
         }
         throw new UnconvertibleObjectException(Errors.format(Errors.Keys.CanNotConvertFromType_2, sourceClass, targetClass));
     }

Modified: sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/geoapi/temporal/TemporalFactory.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/geoapi/temporal/TemporalFactory.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/geoapi/temporal/TemporalFactory.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/geoapi/temporal/TemporalFactory.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -17,6 +17,7 @@
 package org.apache.sis.internal.geoapi.temporal;
 
 import java.util.Date;
+import org.opengis.util.InternationalString;
 
 
 /**
@@ -33,4 +34,8 @@ public interface TemporalFactory {
     Instant createInstant(Position instant);
 
     Period createPeriod(Instant begin, Instant end);
+
+    PeriodDuration createPeriodDuration(InternationalString years, InternationalString months,
+            InternationalString week, InternationalString days, InternationalString hours,
+            InternationalString minutes, InternationalString seconds);
 }

Modified: sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/AdapterReplacement.java
URL: http://svn.apache.org/viewvc/sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/AdapterReplacement.java?rev=1517321&r1=1517320&r2=1517321&view=diff
==============================================================================
--- sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/AdapterReplacement.java [UTF-8] (original)
+++ sis/branches/Shapefile/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/AdapterReplacement.java [UTF-8] Sun Aug 25 15:49:51 2013
@@ -16,7 +16,6 @@
  */
 package org.apache.sis.internal.jaxb;
 
-import java.util.ServiceLoader;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.JAXBException;
@@ -32,6 +31,11 @@ import javax.xml.bind.annotation.adapter
  * <p>This interface is mostly for handling extensions to metadata profile provided as extension,
  * like the {@code FRA} extension for France provided in the {@code sis-metadata-fra} module.</p>
  *
+ * <p><b>WARNING:</b> there is currently no mechanism for ensuring that the registration performed
+ * by an {@code AdapterReplacement} instance does not overwrite the registration performed by an
+ * other {@code AdapterReplacement} instance. This is okay as long as the instances are defined
+ * only in SIS. However we will need to revisit this issue if we move this interface to public API.</p>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
  * @version 0.3
@@ -42,20 +46,6 @@ import javax.xml.bind.annotation.adapter
  */
 public interface AdapterReplacement {
     /**
-     * The system-wide provider of {@code AdapterReplacement} instances.
-     * <strong>Every usage of this service loader must be synchronized.</strong>
-     * This loader is public for allowing modules to unregister their instance
-     * when the module is unloaded (e.g. from an OSGi container), as below:
-     *
-     * {@preformat java
-     *     synchronized (AdapterReplacement.PROVIDER) {
-     *         AdapterReplacement.PROVIDER.reload();
-     *     }
-     * }
-     */
-    ServiceLoader<AdapterReplacement> PROVIDER = ServiceLoader.load(AdapterReplacement.class);
-
-    /**
      * Invoked when a new adapter is created by {@link org.apache.sis.xml.MarshallerPool}.
      * Typical implementations will be as below:
      *



Mime
View raw message