sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1828795 - in /sis/branches/JDK8/core: sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java
Date Tue, 10 Apr 2018 08:08:31 GMT
Author: desruisseaux
Date: Tue Apr 10 08:08:31 2018
New Revision: 1828795

URL: http://svn.apache.org/viewvc?rev=1828795&view=rev
Log:
Replace the use of Java2D by SIS matrix.

Modified:
    sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java

Modified: sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java?rev=1828795&r1=1828794&r2=1828795&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/MarshallingTest.java
[UTF-8] Tue Apr 10 08:08:31 2018
@@ -51,6 +51,7 @@ import org.apache.sis.metadata.iso.maint
 import org.apache.sis.metadata.iso.spatial.*;
 import org.apache.sis.util.iso.DefaultRecordSchema;
 import org.apache.sis.util.iso.SimpleInternationalString;
+import org.apache.sis.util.iso.DefaultInternationalString;
 import org.apache.sis.util.logging.WarningListener;
 import org.apache.sis.measure.Units;
 import org.apache.sis.xml.XML;
@@ -68,6 +69,7 @@ import static org.junit.Assert.*;
  * This class is used to test the ISO 19115-3 metadata standard implementation.
  *
  * @author  Cullen Rombach (Image Matters)
+ * @author  Martin Desruisseaux (Geomatys)
  * @version 1.0
  *
  * @see <a href="https://issues.apache.org/jira/browse/SIS-400">SIS-400</a>
@@ -110,81 +112,141 @@ public final class MarshallingTest exten
     @SuppressWarnings("deprecation")
     private DefaultMetadata metadata() throws URISyntaxException {
         /*
+         * Metadata
+         *   ├─Metadata identifier…… dummy-metadata
+         *   │   └─Code space………………… sis.test
+         *   ├─Parent metadata……………… A parent metadata
+         *   │   └─Identifier………………… dummy-parent-metadata
+         *   │       └─Code space……… sis.test
+         *   ├─Language (1 de 2)………… English
+         *   ├─Language (2 de 2)………… French (Canada)
+         *   ├─Character set…………………… ISO-8859-1
+         *   └─Metadata scope
+         *       ├─Resource scope……… Dataset
+         *       └─Name………………………………… Metadata for an
(imaginary) data set
+         *
          * Some code are indented for readability and more local variable scopes.
          */
         final DefaultMetadata md = new DefaultMetadata();
         {
             // Metadata identifier
-            final DefaultIdentifier id = new DefaultIdentifier("fileIdentifier");
-            id.setCodeSpace("fileIdentifierNamespace");
+            final DefaultIdentifier id = new DefaultIdentifier("dummy-metadata");
+            id.setCodeSpace("sis.test");
             md.setMetadataIdentifier(id);
         }
-        // Languages
-        final Collection<Locale> languages = Arrays.asList(Locale.US, Locale.GERMANY);
+        // Languages — one language only, and one (country, language) tupple.
+        final Collection<Locale> languages = Arrays.asList(Locale.ENGLISH, Locale.CANADA_FRENCH);
         md.setLanguages(languages);
 
         // Character Sets (character encoding)
-        final Collection<Charset> charSets = Collections.singleton(StandardCharsets.UTF_8);
+        final Collection<Charset> charSets = Collections.singleton(StandardCharsets.ISO_8859_1);
         md.setCharacterSets(charSets);
         {
             // Parent metadata
-            final DefaultCitation parent = new DefaultCitation("parentMetadata");
-            final DefaultIdentifier parentId = new DefaultIdentifier("parentMetadata");
-            parentId.setCodeSpace("parentMetadataCodeSpace");
+            final DefaultCitation parent = new DefaultCitation("A parent metadata");
+            final DefaultIdentifier parentId = new DefaultIdentifier("dummy-parent-metadata");
+            parentId.setCodeSpace("sis.test");
             parent.getIdentifiers().add(parentId);
             md.setParentMetadata(parent);
         }
         // mdb:metadataScope (hierarchyLevel and hierarchyLevelName in legacy ISO 19115:2003
model)
-        md.getMetadataScopes().add(new DefaultMetadataScope(ScopeCode.DATASET, "hierarchyLevelName"));
+        md.getMetadataScopes().add(new DefaultMetadataScope(ScopeCode.DATASET, "Metadata
for an (imaginary) data set"));
         final DefaultOnlineResource onlineResource;
         {
-            // Contact information for the parties.
+            /*
+             * Contact information for the parties.
+             *
+             * Organisation…………………………………………………………………
Plato Republic
+             *   ├─Contact info
+             *   │   ├─Phone (1 de 2)
+             *   │   │   ├─Number…………………………………………………
555-444-3333
+             *   │   │   └─Number type……………………………………
Voice
+             *   │   ├─Phone (2 de 2)
+             *   │   │   ├─Number…………………………………………………
555-555-5555
+             *   │   │   └─Number type……………………………………
Facsimile
+             *   │   ├─Address
+             *   │   │   ├─Delivery point……………………………
At the desk
+             *   │   │   ├─City………………………………………………………
Metropolis city
+             *   │   │   ├─Administrative area……………… Utopia area
+             *   │   │   ├─Postal code……………………………………
A1A 2C2
+             *   │   │   ├─Country………………………………………………
Atlantis island
+             *   │   │   └─Electronic mail address…… test@example.com
+             *   │   ├─Online resource
+             *   │   │   ├─Linkage………………………………………………
http://example.com
+             *   │   │   ├─Protocol……………………………………………
Hyper-text
+             *   │   │   ├─Application profile……………… Test only
+             *   │   │   ├─Name………………………………………………………
Timaeus & Critias
+             *   │   │   ├─Description……………………………………
A dialog between philosophers.
+             *   │   │   └─Function……………………………………………
Search
+             *   │   ├─Hours of service…………………………………
Weekdays 9:00 AM - 5:00 PM
+             *   │   ├─Contact instructions……………………… Knock at
the door
+             *   │   └─Contact type……………………………………………
Imaginary
+             *   └─Individual……………………………………………………………
Socrates
+             *       └─Position name…………………………………………
Philosopher
+             */
             final DefaultContact contact = new DefaultContact();
-            contact.setPhones(Arrays.asList(new DefaultTelephone("555-867-5309", TelephoneType.VOICE),
+            contact.setPhones(Arrays.asList(new DefaultTelephone("555-444-3333", TelephoneType.VOICE),
                                             new DefaultTelephone("555-555-5555", TelephoneType.FACSIMILE)));
             {
                 {
                     // Address information
                     final DefaultAddress address = new DefaultAddress();
-                    address.setDeliveryPoints(Collections.singleton(new SimpleInternationalString("deliveryPoint")));
+                    address.setDeliveryPoints(Collections.singleton(new SimpleInternationalString("At
the desk")));
                     address.getElectronicMailAddresses().add("test@example.com");
-                    address.setCity(new SimpleInternationalString("city"));
-                    address.setAdministrativeArea(new SimpleInternationalString("administrativeArea"));
-                    address.setPostalCode("postalCode");
-                    address.setCountry(new SimpleInternationalString("country"));
+                    address.setCity(new SimpleInternationalString("Metropolis city"));
+                    address.setAdministrativeArea(new SimpleInternationalString("Utopia area"));
+                    address.setPostalCode("A1A 2C2");
+                    address.setCountry(new SimpleInternationalString("Atlantis island"));
                     contact.getAddresses().add(address);
                 }
                 // Online resources
-                onlineResource = new DefaultOnlineResource();
-                onlineResource.setLinkage(new URI("http://example.com"));
-                onlineResource.setProtocol("protocol");
-                onlineResource.setApplicationProfile("applicationProfile");
-                onlineResource.setName(new SimpleInternationalString("name"));
-                onlineResource.setDescription(new SimpleInternationalString("description"));
-                onlineResource.setFunction(OnLineFunction.DOWNLOAD);
+                final DefaultInternationalString description = new DefaultInternationalString();
+                description.add(Locale.ENGLISH, "A dialog between philosophers.");
+                description.add(Locale.FRENCH,  "Un dialogue entre philosophes.");
+                onlineResource = new DefaultOnlineResource(new URI("http://example.com"));
+                onlineResource.setName(new SimpleInternationalString("Timaeus & Critias"));
+                onlineResource.setDescription(description);
+                onlineResource.setProtocol("Submarine HTTP");
+                onlineResource.setApplicationProfile("Test only");
+                onlineResource.setFunction(OnLineFunction.SEARCH);
                 contact.getOnlineResources().add(onlineResource);
                 contact.setHoursOfService(Collections.singleton(new SimpleInternationalString("Weekdays
9:00 AM - 5:00 PM")));
-                contact.setContactInstructions(new SimpleInternationalString("contactInstructions"));
-                contact.setContactType(new SimpleInternationalString("contactType"));
+                contact.setContactInstructions(new SimpleInternationalString("Knock at the
door"));
+                contact.setContactType(new SimpleInternationalString("Imaginary"));
             }
-            // Create some DefaultIndividuals
-            final DefaultIndividual individual  = new DefaultIndividual("individualName",
"positionName", null);
-            final DefaultIndividual individual2 = new DefaultIndividual("individualName2",
"positionName2", contact);
-            final DefaultOrganisation org = new DefaultOrganisation("organisationName", null,
individual, contact);
+            // Create some individuals
+            final DefaultIndividual individual  = new DefaultIndividual("Socrates", "Philosopher",
null);
+            final DefaultIndividual individual2 = new DefaultIndividual("Hermocrates", "Politician",
contact);
+            final DefaultOrganisation org = new DefaultOrganisation("Plato Republic", null,
individual, contact);
             md.setContacts(Arrays.asList(new DefaultResponsibility(Role.POINT_OF_CONTACT,
null, org),
                                          new DefaultResponsibility(Role.POINT_OF_CONTACT,
null, individual2)));
         }
         // Date info (date stamp in legacy ISO 19115:2003 model)
-        final Collection<CitationDate> dateInfo = Collections.singleton(new DefaultCitationDate(new
Date(), DateType.CREATION));
+        final Collection<CitationDate> dateInfo = Collections.singleton(new DefaultCitationDate(new
Date(1260961229580L), DateType.CREATION));
         md.setDateInfo(dateInfo);
         {
             // Metadata standard
-            final DefaultCitation standard = new DefaultCitation("metadataStandardName");
-            standard.setEdition(new SimpleInternationalString("metadataStandardVersion"));
+            final DefaultCitation standard = new DefaultCitation("ISO 19115-1");
+            standard.setEdition(new SimpleInternationalString("2014"));
             md.getMetadataStandards().add(standard);
         }
         {
-            // Spatial Representation Info
+            /*
+             * Spatial Representation Info
+             *
+             * Georectified
+             *   ├─Number of dimensions…………………………………………………
2
+             *   ├─Axis dimension properties (1 de 2)…………… Row
+             *   │   ├─Dimension size………………………………………………………
7 777
+             *   │   └─Resolution…………………………………………………………………
10
+             *   ├─Axis dimension properties (2 de 2)…………… Column
+             *   │   ├─Dimension size………………………………………………………
2 233
+             *   │   └─Resolution…………………………………………………………………
5
+             *   ├─Cell geometry……………………………………………………………………
Area
+             *   ├─Transformation parameter availability…… false
+             *   ├─Check point availability………………………………………
false
+             *   └─Point in pixel…………………………………………………………………
Upper right
+             */
             final DefaultGeorectified georectified = new DefaultGeorectified();
             georectified.setNumberOfDimensions(2);
             final DefaultDimension dim1 = new DefaultDimension(DimensionNameType.ROW,   
7777);
@@ -199,20 +261,20 @@ public final class MarshallingTest exten
         {
             // Reference System Information
             final ReferenceSystemMetadata refSystem = new ReferenceSystemMetadata();
-            final DefaultCitation cit = new DefaultCitation("refSystemCitationTitle");
+            final DefaultCitation cit = new DefaultCitation("Atlantis grid");
             cit.setDates(dateInfo);
             {
                 //  Responsibilities
                 final DefaultOrganisation org = new DefaultOrganisation();
-                org.setName(new SimpleInternationalString("orgName"));
+                org.setName(new SimpleInternationalString("Atlantis national mapping agency"));
                 cit.getCitedResponsibleParties().add(new DefaultResponsibility(Role.PUBLISHER,
null, org));
             }
             // Identifier
-            final DefaultIdentifier id = new DefaultIdentifier("refSystemCode");
+            final DefaultIdentifier id = new DefaultIdentifier("AG9000");
             id.setAuthority(cit);
-            id.setCodeSpace("refSystemCodeSpace");
+            id.setCodeSpace("sis.test");
             id.setVersion("1.0");
-            id.setDescription(new SimpleInternationalString("refSystemDescription"));
+            id.setDescription(new SimpleInternationalString("An imaginary reference system."));
             refSystem.setName(id);
             md.getReferenceSystemInfo().add(refSystem);
         }
@@ -238,21 +300,26 @@ public final class MarshallingTest exten
         }
         // Data identification info
         final DefaultDataIdentification dataId = new DefaultDataIdentification();
-        dataId.setAbstract(new SimpleInternationalString("abstract"));
-        dataId.setPurpose(new SimpleInternationalString("purpose"));
+        {
+            final DefaultInternationalString description = new DefaultInternationalString();
+            description.add(Locale.ENGLISH, "Metadata for an imaginary map.");
+            description.add(Locale.FRENCH,  "Méta-données pour une carte imaginaire.");
+            dataId.setAbstract(description);
+            dataId.setPurpose(new SimpleInternationalString("For XML (un)marshalling tests."));
+        }
         final Collection<Extent> extents;
         {
             // Extents
             final DefaultExtent extent = new DefaultExtent();
-            extent.setDescription(new SimpleInternationalString("description"));
+            extent.setDescription(new SimpleInternationalString("Azores"));
             {
                 // Bounding box
                 final DefaultGeographicBoundingBox boundingBox = new DefaultGeographicBoundingBox();
                 boundingBox.setInclusion(true);
-                boundingBox.setNorthBoundLatitude(11.11);
-                boundingBox.setEastBoundLongitude(11.11);
-                boundingBox.setSouthBoundLatitude(11.11);
-                boundingBox.setWestBoundLongitude(11.11);
+                boundingBox.setNorthBoundLatitude( 39);
+                boundingBox.setEastBoundLongitude(-28);
+                boundingBox.setSouthBoundLatitude( 35);
+                boundingBox.setWestBoundLongitude(-22);
                 extent.getGeographicElements().add(boundingBox);
             }
             final DefaultTemporalExtent tempExtent = new DefaultTemporalExtent();
@@ -267,19 +334,19 @@ public final class MarshallingTest exten
             DefaultConstraints constraint = new DefaultConstraints();
             constraint.getResponsibleParties().add(new DefaultResponsibility());
             constraint.setReferences(emptyCitations);
-            final DefaultBrowseGraphic graphic = new DefaultBrowseGraphic(new URI("filename.png"));
-            graphic.setFileDescription(new SimpleInternationalString("description"));
-            graphic.setFileType("fileType");
+            final DefaultBrowseGraphic graphic = new DefaultBrowseGraphic(new URI("ocean.png"));
+            graphic.setFileDescription(new SimpleInternationalString("Somewhere in the Atlantic
ocean"));
+            graphic.setFileType("PNG image");
             graphic.getImageConstraints().add(new DefaultConstraints());
             graphic.getLinkages().add(new DefaultOnlineResource());
             constraint.getGraphics().add(graphic);
-            constraint.setUseLimitations(Collections.singleton(new SimpleInternationalString("useLimitation")));
+            constraint.setUseLimitations(Collections.singleton(new SimpleInternationalString("Not
for navigation.")));
 
             // Releasability
             final DefaultReleasability releasability = new DefaultReleasability();
-            releasability.setStatement(new SimpleInternationalString("statement"));
+            releasability.setStatement(new SimpleInternationalString("Public domain"));
             constraint.setReleasability(releasability);
-            constraint.setConstraintApplicationScope(new DefaultScope(ScopeCode.APPLICATION));
+            constraint.setConstraintApplicationScope(new DefaultScope(ScopeCode.DOCUMENT));
             resourceConstraints = Collections.singleton(constraint);
             dataId.setResourceConstraints(resourceConstraints);
         }
@@ -293,32 +360,32 @@ public final class MarshallingTest exten
             resolution.setDistance(56777.0);
             dataId.getSpatialResolutions().add(resolution);
         }
-        dataId.setTopicCategories(Arrays.asList(TopicCategory.OCEANS, TopicCategory.FARMING));
-        dataId.getStatus().add(Progress.ACCEPTED);
+        dataId.setTopicCategories(Arrays.asList(TopicCategory.OCEANS, TopicCategory.SOCIETY));
+        dataId.getStatus().add(Progress.HISTORICAL_ARCHIVE);
 
         // Citation
         final DefaultCitation cit = new DefaultCitation();
-        cit.setTitle(new SimpleInternationalString("citationTitle"));
-        cit.setEdition(new SimpleInternationalString("edition"));
-        cit.setEditionDate(new Date());
-        cit.setCollectiveTitle(new SimpleInternationalString("collectiveTitle"));
-        cit.setAlternateTitles(Arrays.asList(new SimpleInternationalString("alternateTitle"),
-                                             new Anchor(new URI("http://example.com"), "alternateTitle")));
-        cit.getDates().add(new DefaultCitationDate(new Date(), DateType.CREATION));
+        cit.setTitle(new SimpleInternationalString("A lost island"));
+        cit.setEdition(new SimpleInternationalString("First edition"));
+        cit.setEditionDate(new Date(1523311200000L));
+        cit.setCollectiveTitle(new SimpleInternationalString("Popular legends"));
+        cit.setAlternateTitles(Arrays.asList(new SimpleInternationalString("Island lost again"),
+                                             new Anchor(new URI("http://map-example.com"),
"Map example")));
+        cit.getDates().add(new DefaultCitationDate(new Date(1523224800000L), DateType.CREATION));
         dataId.setCitation(cit);
         dataId.setTemporalResolutions(Collections.emptySet());              // TODO: depends
on sis-temporal
         final Collection<MaintenanceInformation> resourceMaintenances;
         {
             // Resource maintenance
             DefaultMaintenanceInformation maintenanceInfo = new DefaultMaintenanceInformation();
-            maintenanceInfo.setMaintenanceAndUpdateFrequency(MaintenanceFrequency.ANNUALLY);
-            maintenanceInfo.getMaintenanceDates().add(new DefaultCitationDate(new Date(),
DateType.NEXT_UPDATE));
+            maintenanceInfo.setMaintenanceAndUpdateFrequency(MaintenanceFrequency.NOT_PLANNED);
+            maintenanceInfo.getMaintenanceDates().add(new DefaultCitationDate(new Date(32503676400000L),
DateType.REVISION));
             final DefaultScope maintenanceScope = new DefaultScope();
-            maintenanceScope.setLevel(ScopeCode.APPLICATION);
+            maintenanceScope.setLevel(ScopeCode.MODEL);
             {
                 // Scope level descriptions
                 final DefaultScopeDescription scopeDescription = new DefaultScopeDescription();
-                scopeDescription.setDataset("dataset");
+                scopeDescription.setDataset("Imaginary map");
                 maintenanceScope.getLevelDescription().add(scopeDescription);
             }
             maintenanceInfo.getMaintenanceScopes().add(maintenanceScope);

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java?rev=1828795&r1=1828794&r2=1828795&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/operation/projection/ObliqueMercator.java
[UTF-8] Tue Apr 10 08:08:31 2018
@@ -17,7 +17,6 @@
 package org.apache.sis.referencing.operation.projection;
 
 import java.util.EnumMap;
-import java.awt.geom.AffineTransform;
 import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.parameter.InvalidParameterValueException;
 import org.opengis.referencing.operation.OperationMethod;
@@ -25,8 +24,8 @@ import org.opengis.referencing.operation
 import org.apache.sis.measure.Angle;
 import org.apache.sis.parameter.Parameters;
 import org.apache.sis.referencing.operation.matrix.Matrix2;
+import org.apache.sis.referencing.operation.matrix.Matrix3;
 import org.apache.sis.referencing.operation.matrix.MatrixSIS;
-import org.apache.sis.referencing.operation.matrix.AffineTransforms2D;
 import org.apache.sis.referencing.operation.transform.ContextualParameters.MatrixRole;
 import org.apache.sis.internal.referencing.provider.ObliqueMercatorTwoPoints;
 import org.apache.sis.internal.referencing.Resources;
@@ -245,16 +244,10 @@ public class ObliqueMercator extends Con
         getContextualParameters().getMatrix(MatrixRole.NORMALIZATION).convertAfter(0, null,
-λ0);
         final MatrixSIS denormalize = getContextualParameters().getMatrix(MatrixRole.DENORMALIZATION);
         if (γc != 0) {
-            // TODO: This complicated code is only a workaround for the absence of "rotate"
method in MatrixSIS.
-            // We should provide a "rotate" method in a future SIS version instead.
-            final AffineTransform tmp = AffineTransforms2D.castOrCopy(denormalize);
-            tmp.rotate(-γc);
-            final Matrix m = AffineTransforms2D.toMatrix(tmp);
-            for (int i=0; i<3; i++) {
-                for (int j=0; j<3; j++) {
-                    denormalize.setElement(j, i, m.getElement(j, i));
-                }
-            }
+            final Matrix3 rotation = new Matrix3();
+            rotation.m00 =   rotation.m11 = cos(γc);
+            rotation.m10 = -(rotation.m01 = sin(γc));
+            denormalize.setMatrix(denormalize.multiply(rotation));
         }
         /*
          * For variant B only, an additional (uc, vc) translation is applied here.



Mime
View raw message