sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] branch geoapi-4.0 updated: Make canvas more robust to missing CRS information.
Date Mon, 12 Jul 2021 17:17:46 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 351dbc1  Make canvas more robust to missing CRS information.
351dbc1 is described below

commit 351dbc1576af3e343f6b1c4d51d1a1abaeaabbec
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Mon Jul 12 19:17:28 2021 +0200

    Make canvas more robust to missing CRS information.
---
 .../src/main/java/org/apache/sis/portrayal/Canvas.java  | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/Canvas.java b/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/Canvas.java
index a430d65..6a1a144 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/Canvas.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/portrayal/Canvas.java
@@ -966,7 +966,7 @@ public class Canvas extends Observable implements Localized {
              * the Point of Interest and/or the objective CRS changed since last call.
              */
             if (augmentedObjectiveCRS == null) {
-                if (pointOfInterest != null) {
+                if (pointOfInterest != null && objectiveCRS != null) {
                     final CoordinateReferenceSystem crs = pointOfInterest.getCoordinateReferenceSystem();
                     final ArrayList<CoordinateReferenceSystem> components = new ArrayList<>(4);
                     components.add(objectiveCRS);
@@ -1071,8 +1071,15 @@ public class Canvas extends Observable implements Localized {
              * Result of this block: POINT_OF_INTEREST_PROPERTY: newPOI
              */
             final MathTransform gridToCRS = newValue.getGridToCRS(PixelInCell.CELL_CORNER);
-            final CoordinateReferenceSystem crs = newValue.getCoordinateReferenceSystem();
-            final GeneralDirectPosition newPOI = new GeneralDirectPosition(crs);
+            final CoordinateReferenceSystem crs;
+            final GeneralDirectPosition newPOI;
+            if (newValue.isDefined(GridGeometry.CRS)) {
+                crs = newValue.getCoordinateReferenceSystem();
+                newPOI = new GeneralDirectPosition(crs);
+            } else {
+                crs = null;
+                newPOI = new GeneralDirectPosition(gridToCRS.getTargetDimensions());
+            }
             gridToCRS.transform(extent.getPointOfInterest(), 0, newPOI.coordinates, 0, 1);
             /*
              * Get the CRS component in the dimensions shown by this canvas.
@@ -1128,10 +1135,10 @@ public class Canvas extends Observable implements Localized {
      *
      * @param  propertyName  name of the property that changed its value.
      * @param  oldValue      the old property value (may be {@code null}).
-     * @param  newValue      the new property value, shall not be {@code null}.
+     * @param  newValue      the new property value.
      */
     private void fireIfChanged(final String propertyName, final Object oldValue, final Object
newValue) {
-        if (!newValue.equals(oldValue)) {
+        if (!Objects.equals(oldValue, newValue)) {
             firePropertyChange(propertyName, oldValue, newValue);
         }
     }

Mime
View raw message