sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/02: Adjustement in the search for geographic bounding boxes.
Date Wed, 08 Jul 2020 18:28:54 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

commit bb1b31be94e306ee7c57437a9bf028c03e298d4a
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Wed Jul 8 10:23:44 2020 +0200

    Adjustement in the search for geographic bounding boxes.
---
 .../org/apache/sis/gui/metadata/IdentificationInfo.java     | 13 +++++++------
 .../src/main/java/org/apache/sis/gui/metadata/Section.java  |  8 ++++++++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
index 2f08f61..9797620 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/IdentificationInfo.java
@@ -179,9 +179,12 @@ final class IdentificationInfo extends Section<Identification>
{
      * If this pane has no geographic bounds information, search for geographic bounds in
the child resources.
      * This method is used as a fallback when {@link #buildContent(Identification)} did not
find bounding box
      * in the metadata directly provided. If bounds has been found, then this method does
nothing.
+     *
+     * <p>The method does nothing if there is more than one {@link Identification}
metadata element,
+     * because we would not know to which element to assign the extent of children resources.</p>
      */
     final void completeMissingGeographicBounds(final Aggregate resource) {
-        if (!isWorld && isWorldMapEmpty() && !super.isEmpty()) {
+        if (!isWorld && isWorldMapEmpty() && !super.isEmpty() &&
numPages() == 1) {
             /*
              * If a map was visible previously, add back an empty map for avoiding flicking
effect.
              * If it appears that the map has no bounding box to show, it will be removed
after the
@@ -194,13 +197,13 @@ final class IdentificationInfo extends Section<Identification>
{
                 /** Invoked in a background thread for fetching bounding boxes. */
                 @Override protected Set<GeographicBoundingBox> call() throws DataStoreException
{
                     final Set<GeographicBoundingBox> boxes = new LinkedHashSet<>();
-search:             for (final Resource child : resource.components()) {
+                    for (final Resource child : resource.components()) {
                         final Metadata metadata = child.getMetadata();
+                        if (isCancelled()) break;
                         if (metadata != null) {
                             for (final Identification id : nonNull(metadata.getIdentificationInfo()))
{
                                 if (id != null) {
                                     for (final Extent extent : id.getExtents()) {
-                                        if (isCancelled()) break search;
                                         final GeographicBoundingBox b = Extents.getGeographicBoundingBox(extent);
                                         if (b != null) boxes.add(b);
                                     }
@@ -214,9 +217,7 @@ search:             for (final Resource child : resource.components())
{
                 /** Shows the result in JavaFX thread. */
                 @Override protected void succeeded() {
                     aggregateWalker = null;
-                    if (!isCancelled()) {
-                        drawOnMap(getValue());
-                    }
+                    drawOnMap(getValue());
                 }
 
                 /** Invoked in JavaFX thread if metadata loading failed. */
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/Section.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/Section.java
index 3b3f775..559468a 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/Section.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/metadata/Section.java
@@ -138,6 +138,14 @@ abstract class Section<T> extends GridPane implements EventHandler<ActionEvent>
     }
 
     /**
+     * Returns the number of non-null items specified in last calls to
+     * {@link #setInformation(Collection, IntFunction)}.
+     */
+    final int numPages() {
+        return (information != null) ? information.length : 0;
+    }
+
+    /**
      * Sets the information from the given metadata. Subclasses extract the collection of
interest
      * and delegate to the {@link #setInformation(Collection, IntFunction)} method.
      *


Mime
View raw message