diff --git a/CHANGELOG.md b/CHANGELOG.md index 9242eb1..7d3424f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2.4.0-SNAPSHOT] - 2022-09-07 + +#### Enhancement + +- [#23819] Adding layers to principal map belonging to more centroids with the same spatial position + ## [v2.3.1] - 2022-08-29 #### Bug fixed diff --git a/pom.xml b/pom.xml index 783aeaf..0c6e1c7 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ org.gcube.portlets.user geoportal-data-viewer-app war - 2.3.1 + 2.4.0-SNAPSHOT GeoPortal Data Viewer App The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java index a843390..671678c 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java @@ -158,15 +158,15 @@ public class LayerManager { if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) { Collection collLO = mapDetailLayerObjects.values(); listLO.addAll(collLO); - + ArrayList layerVisibility = new ArrayList(collLO.size()); layerVisibility.addAll(collLO); - //Managing layer visibility. If a layer is not visible has to be not queryable + // Managing layer visibility. If a layer is not visible has to be not queryable for (LayerObject layerObject : layerVisibility) { String layerName = layerObject.getLayerItem().getName(); boolean isLayerVisible = olMap.isLayerVisible(layerName); - if(!isLayerVisible) { - GWT.log("From querying removing layername: "+layerName + ", it is not visible"); + if (!isLayerVisible) { + GWT.log("From querying removing layername: " + layerName + ", it is not visible"); listLO.remove(layerObject); } // else { @@ -197,52 +197,76 @@ public class LayerManager { GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size()); // GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); - // GeoportalDataViewerConstants.print("GeoNaDataObject's: - // "+listGeonaDataObjects); +// GeoportalDataViewerConstants.print("GeoNaDataObject's: +// "+listGeonaDataObjects); if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty()) return; - FeatureRow feature = null; + List theFeatures = null; MapEventType sourceEvent = queryEvent.getSourceMapEventType(); // TODO SWTCH FOR EARCH ITEM TYPE for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { + GWT.log("GeoNaDataObject: " + geoNaDataObject); List features = geoNaDataObject.getFeatures(); + LayerItem layerItem = geoNaDataObject.getSourceLayerObject().getLayerItem(); + GWT.log(" features: " + features); + GWT.log(" layerItem: " + layerItem); - GWT.log("GeoNaDataObject Source layer item name: " - + geoNaDataObject.getSourceLayerObject().getLayerItem().getName()); + GWT.log("GeoNaDataObject Source layer item name: " + layerItem.getName()); - // USING ONLY THE FIRST FEATURE IN THE LIST + HashMap> listUniqueProducts = new HashMap>(); + // Clustering features for productId if (features != null && features.size() > 0) { String theProductId = null; - // I need to show exactly the feature with produc_id == recordId - if (mongoItemId != null) { - for (FeatureRow fRow : features) { - List productIdLst = fRow.getMapProperties() - .get("product_id"); + for (FeatureRow fRow : features) { + List productIdLst = fRow.getMapProperties().get("product_id"); + if (productIdLst != null) { theProductId = productIdLst.get(0); - try { - // long productId = Long.parseLong(thePID); - if (theProductId == mongoItemId) { - feature = fRow; - GWT.log("Found recorId == product_id with id: " - + theProductId); - break; + if (theProductId != null) { + List listFeatures = listUniqueProducts + .get(theProductId); + if (listFeatures == null) { + listFeatures = new ArrayList(); } - } catch (Exception e) { - // TODO: handle exception + + listFeatures.add(fRow); + listUniqueProducts.put(theProductId, listFeatures); } } } - // If mongoItemId not passed, I'm using the first feature returned + } + + GWT.log("listUniqueProducts keyset: " + listUniqueProducts.keySet()); + + // USING ONLY THE FIRST FEATURE IN THE LIST + if (features != null && features.size() > 0) { + + // I need to show exactly the feature with produc_id == recordId + if (mongoItemId != null) { + GWT.log("MongoItemId is not null: " + mongoItemId); + // Searching mongoItemId in the list of product + theFeatures = listUniqueProducts.get(mongoItemId); + GWT.log("Loaded mongoItemId == product_id with id: " + mongoItemId + + ", the features are: " + theFeatures); + + // the recordId/mongoItemId to show has been passed but not found into + // list of + // FeatureRow + if (theFeatures == null || theFeatures.isEmpty()) { + return; + } + } + + // If mongoItemId not passed if (mongoItemId == null) { - feature = features.get(0); - List productIdLst = feature.getMapProperties() - .get("product_id"); - if (productIdLst == null) { + GWT.log("MongoItemId is null"); + // Checking if the features returned belonging to detail layers (not + // centroids). + if (listUniqueProducts.isEmpty()) { // in this case the feature/s returned is/are a (detail) layer/s // belonging // to a record/concessione (not centroid layer), @@ -257,51 +281,68 @@ public class LayerManager { } return; } - theProductId = productIdLst.get(0); - } else { - // the recordId to show has been passed but not found into list of - // FeatureRow - if (feature == null) { - return; + } + + // The features of the first centroid layer selected + if (theFeatures == null || theFeatures.size() == 0) { + for (String theProductId : listUniqueProducts.keySet()) { + + theFeatures = listUniqueProducts.get(theProductId); + + if (theFeatures.size() > 0) + break; + } } - GWT.log("the product id is: " + theProductId); - // Displaying popup info for centroid layer + // Displaying popup info for centroid layer passing the first feature if (sourceEvent.equals(MapEventType.MOUSE_CLICK) || sourceEvent.equals(MapEventType.ADDED_CENTROID_LAYER_TO_MAP)) { - showPopupInfoForCentroidLayer(geoNaDataObject, feature, + GWT.log("Source event is: " + MapEventType.MOUSE_CLICK + ", or " + + MapEventType.ADDED_CENTROID_LAYER_TO_MAP); + + // Displaying popup info for centroid layer passing the first feature + showPopupInfoForCentroidLayer(geoNaDataObject, theFeatures.get(0), queryEvent.getQueryClickExtent().getCenter()); } - // retrieving and showing WMS layers of a concessione if the ZOOM level is > - // QUERY_MIN_ZOOM_LEVEL if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) { - GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId( - "concessione", theProductId, - new AsyncCallback>() { + GWT.log("Current zoom level is less than QUERY_MIN_ZOOM_LEVEL, Loading all layers of any product"); + for (String theProductId : listUniqueProducts.keySet()) { + GWT.log("Loading layers of theProductId: " + theProductId); + // retrieving and showing WMS layers of a concessione if the ZOOM + // level + // is > + // QUERY_MIN_ZOOM_LEVEL - @Override - public void onFailure(Throwable caught) { - // TODO Auto-generated method stub + GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId( + "concessione", theProductId, + new AsyncCallback>() { - } + @Override + public void onFailure(Throwable caught) { + // TODO Auto-generated method stub - @Override - public void onSuccess(List result) { - - for (LayerConcessioneDV layer : result) { - GWT.log("Adding layer: " + layer.getLayerName()); - addLayer("concessione", layer.getLayerName(), - layer.getLayerName(), layer.getWmsLink(), - false, false, layer.getLayerUUID(), true, - OLMapManager.LAYER_DETAIL_MIN_RESOLUTION, - OLMapManager.LAYER_DETAIL_MAX_RESOLUTION, - layer.getRefersTo()); } - } - }); + @Override + public void onSuccess(List result) { + + for (LayerConcessioneDV layer : result) { + GWT.log("Adding layer: " + + layer.getLayerName()); + addLayer("concessione", layer.getLayerName(), + layer.getLayerName(), + layer.getWmsLink(), false, false, + layer.getLayerUUID(), true, + OLMapManager.LAYER_DETAIL_MIN_RESOLUTION, + OLMapManager.LAYER_DETAIL_MAX_RESOLUTION, + layer.getRefersTo()); + } + + } + }); + } } else { // removing all WMS detail layers if the ZOOM level is < // QUERY_MIN_ZOOM_LEVEL @@ -453,7 +494,7 @@ public class LayerManager { mapDetailLayerObjects.put(key, lo); olMap.addWMSDetailLayer(layerItem); overlayLayerManager.addLayerItem(lo); - //overlayLayerManager.show(); + // overlayLayerManager.show(); } else { GWT.log("Skipping detail layer " + key + " already added to Map"); } @@ -550,7 +591,7 @@ public class LayerManager { * Show popup info for layer. * * @param listGeoNaDataObject the list geo na data object - * @param queryClick the query click + * @param queryClick the query click */ public void showPopupInfoForLayer(List listGeoNaDataObject, ExtentWrapped queryClick) { @@ -558,9 +599,9 @@ public class LayerManager { final FlowPanel flowPanel = new FlowPanel(); flowPanel.getElement().getStyle().setProperty("maxHeight", "600px"); scrollPanel.add(flowPanel); - + List