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 4ec4fba Improve a little bit more the selection of CRS proposed to
user (more duplication removal, omit "Computer display CRS").
4ec4fba is described below
commit 4ec4fbaf0078ecdeec3a6701ac9fe35240e1a762
Author: Martin Desruisseaux <[email protected]>
AuthorDate: Sun May 17 00:12:13 2020 +0200
Improve a little bit more the selection of CRS proposed to user
(more duplication removal, omit "Computer display CRS").
---
.../java/org/apache/sis/gui/map/OperationFinder.java | 8 +++++++-
.../sis/gui/referencing/RecentReferenceSystems.java | 17 +++++++++++++++--
.../main/java/org/apache/sis/gui/referencing/Utils.java | 11 +++++++++++
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git
a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/OperationFinder.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/OperationFinder.java
index 95e6552..e776b22 100644
---
a/application/sis-javafx/src/main/java/org/apache/sis/gui/map/OperationFinder.java
+++
b/application/sis-javafx/src/main/java/org/apache/sis/gui/map/OperationFinder.java
@@ -155,12 +155,18 @@ abstract class OperationFinder extends
Task<MathTransform> {
/**
* If the given CRS is a grid CRS, replaces it by a geospatial CRS if
possible.
+ * If the given CRS is not geospatial, then this method tries to replace
it by
+ * by the CRS of the coverage shown by the canvas (this is not necessarily
the
+ * {@linkplain MapCanvas#getObjectiveCRS() objective CRS}).
+ *
+ * @param crs the CRS to eventually replace by a geospatial CRS.
+ * @param canvas the canvas that this status bar is tracking.
*/
static CoordinateReferenceSystem toGeospatial(CoordinateReferenceSystem
crs, final ReadOnlyProperty<MapCanvas> canvas) {
if (isGridCRS(crs)) {
final GridGeometry dataGeometry = dataGeometry(canvas.getValue());
if (dataGeometry != null &&
dataGeometry.isDefined(GridGeometry.CRS)) {
- return dataGeometry.getCoordinateReferenceSystem();
+ crs = dataGeometry.getCoordinateReferenceSystem();
}
}
return crs;
diff --git
a/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/RecentReferenceSystems.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/RecentReferenceSystems.java
index 6e9b4c5..edf7167 100644
---
a/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/RecentReferenceSystems.java
+++
b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/RecentReferenceSystems.java
@@ -433,10 +433,20 @@ public class RecentReferenceSystems {
systemsOrCodes.subList(i, j).clear();
break;
}
- final Object item = systemsOrCodes.get(i);
+ Object item = systemsOrCodes.get(i);
while (--j > i) {
if (Utilities.deepEquals(item, systemsOrCodes.get(j),
mode)) {
- systemsOrCodes.remove(j);
+ final Object removed = systemsOrCodes.remove(j);
+ if (IdentifiedObjects.getIdentifier((IdentifiedObject)
removed, null) != null &&
+ IdentifiedObjects.getIdentifier((IdentifiedObject)
item, null) == null)
+ {
+ /*
+ * Keep the instance which has an identifier. The
instance without identifier
+ * is typically a CRS with non-standard axis
order. It happens when it is the
+ * CRS associated to an image that has just been
read.
+ */
+ systemsOrCodes.set(i, item = removed);
+ }
}
}
}
@@ -455,6 +465,9 @@ public class RecentReferenceSystems {
if (i >= NUM_CORE_ITEMS && !Utils.intersects(domain,
system.getDomainOfValidity())) {
continue;
}
+ if (Utils.isIgnoreable(system)) { // Ignore "Computer
display" CRS.
+ continue;
+ }
systems.add(system);
if (systems.size() >= NUM_SHOWN_ITEMS) break;
}
diff --git
a/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Utils.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Utils.java
index 06b547f..bb7f6c7 100644
---
a/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Utils.java
+++
b/application/sis-javafx/src/main/java/org/apache/sis/gui/referencing/Utils.java
@@ -20,6 +20,8 @@ import org.opengis.geometry.Envelope;
import org.opengis.util.FactoryException;
import org.opengis.metadata.extent.Extent;
import org.opengis.metadata.extent.GeographicBoundingBox;
+import org.opengis.referencing.ReferenceSystem;
+import org.opengis.referencing.crs.SingleCRS;
import org.opengis.referencing.crs.CRSAuthorityFactory;
import org.opengis.referencing.operation.TransformException;
import org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox;
@@ -28,6 +30,7 @@ import org.apache.sis.geometry.ImmutableEnvelope;
import org.apache.sis.internal.system.Modules;
import org.apache.sis.internal.util.Constants;
import org.apache.sis.util.logging.Logging;
+import org.apache.sis.referencing.CommonCRS;
import org.apache.sis.referencing.CRS;
@@ -90,4 +93,12 @@ final class Utils {
}
return true;
}
+
+ /**
+ * Returns {@code true} if the given reference system should be ignored.
+ */
+ static boolean isIgnoreable(final ReferenceSystem system) {
+ return (system instanceof SingleCRS)
+ && CommonCRS.Engineering.DISPLAY.datum().equals(((SingleCRS)
system).getDatum());
+ }
}