sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1737071 - in /sis/branches/JDK8/core: sis-referencing/src/main/java/org/apache/sis/referencing/ sis-utility/src/main/java/org/apache/sis/util/
Date Tue, 29 Mar 2016 22:19:45 GMT
Author: desruisseaux
Date: Tue Mar 29 22:19:45 2016
New Revision: 1737071

URL: http://svn.apache.org/viewvc?rev=1737071&view=rev
Log:
First draft of CRS.findOperation(...) method.

Added:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CoordinateOperations.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java

Modified: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1737071&r1=1737070&r2=1737071&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
[UTF-8] (original)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java
[UTF-8] Tue Mar 29 22:19:45 2016
@@ -42,6 +42,7 @@ import org.opengis.referencing.crs.Engin
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.extent.Extent;
 import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.opengis.referencing.operation.CoordinateOperation;
 import org.apache.sis.internal.metadata.AxisDirections;
 import org.apache.sis.internal.referencing.ReferencingUtilities;
 import org.apache.sis.internal.system.DefaultFactories;
@@ -50,8 +51,12 @@ import org.apache.sis.referencing.cs.Def
 import org.apache.sis.referencing.crs.DefaultGeographicCRS;
 import org.apache.sis.referencing.crs.DefaultVerticalCRS;
 import org.apache.sis.referencing.crs.DefaultCompoundCRS;
-import org.apache.sis.metadata.iso.extent.Extents;
+import org.apache.sis.referencing.operation.CoordinateOperationContext;
+import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory;
 import org.apache.sis.referencing.factory.UnavailableFactoryException;
+import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
+import org.apache.sis.metadata.iso.extent.Extents;
+import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.Utilities;
 import org.apache.sis.util.Static;
@@ -591,4 +596,43 @@ check:  while (lower != 0 || upper != di
         }
         return AuthorityFactories.ALL.getAuthorityFactory(CRSAuthorityFactory.class, authority,
null);
     }
+
+    /**
+     * Finds a mathematical operation that transforms or converts coordinates from the given
source to the
+     * given target coordinate reference system. If an estimation of the geographic area
containing the points
+     * to transform is known, it can be specified for helping this method to find a better
suited operation.
+     *
+     * <p>Note that the area of interest is just one aspect that may affect the coordinate
operation.
+     * Other aspects are the time of interest (because some coordinate operations take in
account the
+     * plate tectonics movement) or the desired accuracy. For more control on the coordinate
operation
+     * to create, see {@link CoordinateOperationContext}.</p>
+     *
+     * @param  sourceCRS      the CRS of source coordinates.
+     * @param  targetCRS      the CRS of target coordinates.
+     * @param  areaOfInterest the area of interest, or {@code null} if none.
+     * @return the mathematical operation from {@code sourceCRS} to {@code targetCRS}.
+     * @throws FactoryException if the operation can not be created.
+     *
+     * @see DefaultCoordinateOperationFactory#createOperation(CoordinateReferenceSystem,
CoordinateReferenceSystem, CoordinateOperationContext)
+     *
+     * @since 0.7
+     */
+    public static CoordinateOperation findOperation(final CoordinateReferenceSystem sourceCRS,
+                                                    final CoordinateReferenceSystem targetCRS,
+                                                    final GeographicBoundingBox areaOfInterest)
+            throws FactoryException
+    {
+        ArgumentChecks.ensureNonNull("sourceCRS", sourceCRS);
+        ArgumentChecks.ensureNonNull("targetCRS", targetCRS);
+        CoordinateOperationContext context = null;
+        if (areaOfInterest != null) {
+            final DefaultGeographicBoundingBox bbox = DefaultGeographicBoundingBox.castOrCopy(areaOfInterest);
+            if (bbox.isEmpty()) {
+                throw new IllegalArgumentException(Errors.format(Errors.Keys.EmptyArgument_1,
"areaOfInterest"));
+            }
+            context = new CoordinateOperationContext();
+            context.setGeographicBoundingBox(bbox);
+        }
+        return CoordinateOperations.factory.createOperation(sourceCRS, targetCRS, context);
+    }
 }

Added: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CoordinateOperations.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CoordinateOperations.java?rev=1737071&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CoordinateOperations.java
(added)
+++ sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CoordinateOperations.java
[UTF-8] Tue Mar 29 22:19:45 2016
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+package org.apache.sis.referencing;
+
+import org.opengis.referencing.operation.CoordinateOperationFactory;
+import org.apache.sis.referencing.operation.DefaultCoordinateOperationFactory;
+import org.apache.sis.internal.system.DefaultFactories;
+
+
+/**
+ * The default coordinate operation factory, provided in a separated class for deferring
class loading
+ * until first needed.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.7
+ * @version 0.7
+ * @module
+ */
+final class CoordinateOperations {
+    /**
+     * The factory.
+     */
+    static final DefaultCoordinateOperationFactory factory =
+            DefaultFactories.forBuildin(CoordinateOperationFactory.class, DefaultCoordinateOperationFactory.class);
+
+    /**
+     * Do not allows instantiation of this class.
+     */
+    private CoordinateOperations() {
+    }
+}

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CoordinateOperations.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-referencing/src/main/java/org/apache/sis/referencing/CoordinateOperations.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java?rev=1737071&r1=1737070&r2=1737071&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/util/Utilities.java [UTF-8]
Tue Mar 29 22:19:45 2016
@@ -55,7 +55,7 @@ public final class Utilities extends Sta
      *
      *   <li>If the two given objects are
      *       {@linkplain org.apache.sis.referencing.crs.AbstractCRS Coordinate Reference
Systems} (CRS), then a call to
-     *       <code>{@linkplain org.apache.sis.referencing.CRS#findOperation findOperation}(crs1,
crs2)</code>
+     *       <code>{@linkplain org.apache.sis.referencing.CRS#findOperation findOperation}(crs1,
crs2, null)</code>
      *       will return an identity operation.</li>
      * </ul>
      *
@@ -92,7 +92,7 @@ public final class Utilities extends Sta
      *
      *   <li>If the two given objects are
      *       {@linkplain org.apache.sis.referencing.crs.AbstractCRS Coordinate Reference
Systems} (CRS), then a call to
-     *       <code>{@linkplain org.apache.sis.referencing.CRS#findOperation findOperation}(crs1,
crs2)</code>
+     *       <code>{@linkplain org.apache.sis.referencing.CRS#findOperation findOperation}(crs1,
crs2, null)</code>
      *       will return an operation close to identity.</li>
      * </ul>
      *



Mime
View raw message