#23819 Enhancement implemented #6

Merged
francesco.mangiacrapa merged 1 commits from feature_23819 into master 2022-09-06 15:16:39 +02:00
3 changed files with 129 additions and 79 deletions

View File

@ -4,6 +4,12 @@
All notable changes to this project will be documented in this file. 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). 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 ## [v2.3.1] - 2022-08-29
#### Bug fixed #### Bug fixed

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-viewer-app</artifactId> <artifactId>geoportal-data-viewer-app</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>2.3.1</version> <version>2.4.0-SNAPSHOT</version>
<name>GeoPortal Data Viewer App</name> <name>GeoPortal Data Viewer App</name>
<description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface</description> <description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the GeoNa products by a Web-Map Interface</description>

View File

@ -158,15 +158,15 @@ public class LayerManager {
if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) { if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
Collection<LayerObject> collLO = mapDetailLayerObjects.values(); Collection<LayerObject> collLO = mapDetailLayerObjects.values();
listLO.addAll(collLO); listLO.addAll(collLO);
ArrayList<LayerObject> layerVisibility = new ArrayList<LayerObject>(collLO.size()); ArrayList<LayerObject> layerVisibility = new ArrayList<LayerObject>(collLO.size());
layerVisibility.addAll(collLO); 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) { for (LayerObject layerObject : layerVisibility) {
String layerName = layerObject.getLayerItem().getName(); String layerName = layerObject.getLayerItem().getName();
boolean isLayerVisible = olMap.isLayerVisible(layerName); boolean isLayerVisible = olMap.isLayerVisible(layerName);
if(!isLayerVisible) { if (!isLayerVisible) {
GWT.log("From querying removing layername: "+layerName + ", it is not visible"); GWT.log("From querying removing layername: " + layerName + ", it is not visible");
listLO.remove(layerObject); listLO.remove(layerObject);
} }
// else { // else {
@ -197,52 +197,76 @@ public class LayerManager {
GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size()); GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size());
// GWT.log("GeoNaDataObject's: " + listGeonaDataObjects); // GWT.log("GeoNaDataObject's: " + listGeonaDataObjects);
// GeoportalDataViewerConstants.print("GeoNaDataObject's: // GeoportalDataViewerConstants.print("GeoNaDataObject's:
// "+listGeonaDataObjects); // "+listGeonaDataObjects);
if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty()) if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty())
return; return;
FeatureRow feature = null; List<FeatureRow> theFeatures = null;
MapEventType sourceEvent = queryEvent.getSourceMapEventType(); MapEventType sourceEvent = queryEvent.getSourceMapEventType();
// TODO SWTCH FOR EARCH ITEM TYPE // TODO SWTCH FOR EARCH ITEM TYPE
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
GWT.log("GeoNaDataObject: " + geoNaDataObject);
List<FeatureRow> features = geoNaDataObject.getFeatures(); List<FeatureRow> features = geoNaDataObject.getFeatures();
LayerItem layerItem = geoNaDataObject.getSourceLayerObject().getLayerItem();
GWT.log(" features: " + features);
GWT.log(" layerItem: " + layerItem);
GWT.log("GeoNaDataObject Source layer item name: " GWT.log("GeoNaDataObject Source layer item name: " + layerItem.getName());
+ geoNaDataObject.getSourceLayerObject().getLayerItem().getName());
// USING ONLY THE FIRST FEATURE IN THE LIST HashMap<String, List<FeatureRow>> listUniqueProducts = new HashMap<String, List<FeatureRow>>();
// Clustering features for productId
if (features != null && features.size() > 0) { if (features != null && features.size() > 0) {
String theProductId = null; String theProductId = null;
// I need to show exactly the feature with produc_id == recordId for (FeatureRow fRow : features) {
if (mongoItemId != null) { List<String> productIdLst = fRow.getMapProperties().get("product_id");
for (FeatureRow fRow : features) { if (productIdLst != null) {
List<String> productIdLst = fRow.getMapProperties()
.get("product_id");
theProductId = productIdLst.get(0); theProductId = productIdLst.get(0);
try { if (theProductId != null) {
// long productId = Long.parseLong(thePID); List<FeatureRow> listFeatures = listUniqueProducts
if (theProductId == mongoItemId) { .get(theProductId);
feature = fRow; if (listFeatures == null) {
GWT.log("Found recorId == product_id with id: " listFeatures = new ArrayList<FeatureRow>();
+ theProductId);
break;
} }
} 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) { if (mongoItemId == null) {
feature = features.get(0); GWT.log("MongoItemId is null");
List<String> productIdLst = feature.getMapProperties() // Checking if the features returned belonging to detail layers (not
.get("product_id"); // centroids).
if (productIdLst == null) { if (listUniqueProducts.isEmpty()) {
// in this case the feature/s returned is/are a (detail) layer/s // in this case the feature/s returned is/are a (detail) layer/s
// belonging // belonging
// to a record/concessione (not centroid layer), // to a record/concessione (not centroid layer),
@ -257,51 +281,68 @@ public class LayerManager {
} }
return; return;
} }
theProductId = productIdLst.get(0); }
} else {
// the recordId to show has been passed but not found into list of // The features of the first centroid layer selected
// FeatureRow if (theFeatures == null || theFeatures.size() == 0) {
if (feature == null) { for (String theProductId : listUniqueProducts.keySet()) {
return;
theFeatures = listUniqueProducts.get(theProductId);
if (theFeatures.size() > 0)
break;
} }
} }
GWT.log("the product id is: " + theProductId); // Displaying popup info for centroid layer passing the first feature
// Displaying popup info for centroid layer
if (sourceEvent.equals(MapEventType.MOUSE_CLICK) if (sourceEvent.equals(MapEventType.MOUSE_CLICK)
|| sourceEvent.equals(MapEventType.ADDED_CENTROID_LAYER_TO_MAP)) { || 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()); 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) { if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) {
GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId( GWT.log("Current zoom level is less than QUERY_MIN_ZOOM_LEVEL, Loading all layers of any product");
"concessione", theProductId, for (String theProductId : listUniqueProducts.keySet()) {
new AsyncCallback<List<LayerConcessioneDV>>() { 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 GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId(
public void onFailure(Throwable caught) { "concessione", theProductId,
// TODO Auto-generated method stub new AsyncCallback<List<LayerConcessioneDV>>() {
} @Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
@Override
public void onSuccess(List<LayerConcessioneDV> 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<LayerConcessioneDV> 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 { } else {
// removing all WMS detail layers if the ZOOM level is < // removing all WMS detail layers if the ZOOM level is <
// QUERY_MIN_ZOOM_LEVEL // QUERY_MIN_ZOOM_LEVEL
@ -453,7 +494,7 @@ public class LayerManager {
mapDetailLayerObjects.put(key, lo); mapDetailLayerObjects.put(key, lo);
olMap.addWMSDetailLayer(layerItem); olMap.addWMSDetailLayer(layerItem);
overlayLayerManager.addLayerItem(lo); overlayLayerManager.addLayerItem(lo);
//overlayLayerManager.show(); // overlayLayerManager.show();
} else { } else {
GWT.log("Skipping detail layer " + key + " already added to Map"); GWT.log("Skipping detail layer " + key + " already added to Map");
} }
@ -550,7 +591,7 @@ public class LayerManager {
* Show popup info for layer. * Show popup info for layer.
* *
* @param listGeoNaDataObject the list geo na data object * @param listGeoNaDataObject the list geo na data object
* @param queryClick the query click * @param queryClick the query click
*/ */
public void showPopupInfoForLayer(List<GeoNaSpatialQueryResult> listGeoNaDataObject, ExtentWrapped queryClick) { public void showPopupInfoForLayer(List<GeoNaSpatialQueryResult> listGeoNaDataObject, ExtentWrapped queryClick) {
@ -558,9 +599,9 @@ public class LayerManager {
final FlowPanel flowPanel = new FlowPanel(); final FlowPanel flowPanel = new FlowPanel();
flowPanel.getElement().getStyle().setProperty("maxHeight", "600px"); flowPanel.getElement().getStyle().setProperty("maxHeight", "600px");
scrollPanel.add(flowPanel); scrollPanel.add(flowPanel);
List<Button> listOpenProject = new ArrayList<Button>(); List<Button> listOpenProject = new ArrayList<Button>();
final Button expandButton = new Button("Expand"); final Button expandButton = new Button("Expand");
expandButton.setType(ButtonType.LINK); expandButton.setType(ButtonType.LINK);
expandButton.setIcon(IconType.EXPAND); expandButton.setIcon(IconType.EXPAND);
@ -568,7 +609,7 @@ public class LayerManager {
expandButton.setTitle("Show this view in new Window"); expandButton.setTitle("Show this view in new Window");
flowPanel.add(expandButton); flowPanel.add(expandButton);
Scheduler.get().scheduleDeferred(new ScheduledCommand() { Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override @Override
@ -581,7 +622,7 @@ public class LayerManager {
public void onBrowserEvent(Event event) { public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) { if (Event.ONCLICK == event.getTypeInt()) {
expandButton.setVisible(false); expandButton.setVisible(false);
//hiding the Open Project in expand mode (Modal Window) // hiding the Open Project in expand mode (Modal Window)
for (Button butt : listOpenProject) { for (Button butt : listOpenProject) {
butt.setVisible(false); butt.setVisible(false);
} }
@ -591,7 +632,7 @@ public class LayerManager {
Coordinate center = queryClick.getCenter(); Coordinate center = queryClick.getCenter();
double x = center.getX(); double x = center.getX();
double y = center.getY(); double y = center.getY();
//"with center x: "+x +", y: "+y; // "with center x: "+x +", y: "+y;
ModalWindow mw = new ModalWindow("Query results...", width, height); ModalWindow mw = new ModalWindow("Query results...", width, height);
mw.add(flowPanel); mw.add(flowPanel);
mw.show(); mw.show();
@ -600,7 +641,7 @@ public class LayerManager {
}); });
} }
}); });
String prevConcessioneName = ""; String prevConcessioneName = "";
for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) { for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) {
try { try {
@ -615,23 +656,25 @@ public class LayerManager {
|| layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName()) == 0) { || layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName()) == 0) {
continue; continue;
} }
List<FeatureRow> features = geoNaSpatialQueryResult.getFeatures(); List<FeatureRow> features = geoNaSpatialQueryResult.getFeatures();
if (features == null || features.isEmpty()) { if (features == null || features.isEmpty()) {
continue; continue;
} }
String nomeConcessione = lo.getSourceConcessione().getNome(); String nomeConcessione = lo.getSourceConcessione().getNome();
if (prevConcessioneName.compareTo(nomeConcessione) != 0) { if (prevConcessioneName.compareTo(nomeConcessione) != 0) {
String concessioneIntro = nomeConcessione.length()>100? StringUtil.ellipsize(nomeConcessione, 100):nomeConcessione; String concessioneIntro = nomeConcessione.length() > 100
? StringUtil.ellipsize(nomeConcessione, 100)
: nomeConcessione;
Heading heading = new Heading(4, concessioneIntro); Heading heading = new Heading(4, concessioneIntro);
heading.setTitle(nomeConcessione); heading.setTitle(nomeConcessione);
heading.getElement().getStyle().setMarginBottom(10, Unit.PX); heading.getElement().getStyle().setMarginBottom(10, Unit.PX);
flowPanel.add(heading); flowPanel.add(heading);
Button buttOpenProject = new Button("Open Project"); Button buttOpenProject = new Button("Open Project");
final String buttId = "open-details-"+Random.nextInt(); final String buttId = "open-details-" + Random.nextInt();
Element bEl = buttOpenProject.getElement(); Element bEl = buttOpenProject.getElement();
bEl.setId(buttId); bEl.setId(buttId);
bEl.getStyle().setPaddingLeft(0, Unit.PX); bEl.getStyle().setPaddingLeft(0, Unit.PX);
@ -651,7 +694,8 @@ public class LayerManager {
@Override @Override
public void onBrowserEvent(Event event) { public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) { if (Event.ONCLICK == event.getTypeInt()) {
applicationBus.fireEvent(new ShowDetailsEvent("concessione", lo.getSourceConcessione().getItemId(), nomeConcessione, null)); applicationBus.fireEvent(new ShowDetailsEvent("concessione",
lo.getSourceConcessione().getItemId(), nomeConcessione, null));
} }
} }
@ -723,12 +767,11 @@ public class LayerManager {
GeoportalDataViewerConstants.printJs("Error: " + e.getMessage()); GeoportalDataViewerConstants.printJs("Error: " + e.getMessage());
} }
} }
olMap.showPopup(scrollPanel.toString(), queryClick.getCenter()); olMap.showPopup(scrollPanel.toString(), queryClick.getCenter());
} }
/** /**
* Show popup info for centroid layer. * Show popup info for centroid layer.
* *
@ -790,7 +833,7 @@ public class LayerManager {
GWT.log("Adding images: " + listUI); GWT.log("Adding images: " + listUI);
if (listUI != null && listUI.size() > 0) { if (listUI != null && listUI.size() > 0) {
UploadedImageDV img = listUI.get(0); UploadedImageDV img = listUI.get(0);
if (img!= null && img.getListWsContent() != null) { if (img != null && img.getListWsContent() != null) {
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size() - 1); WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size() - 1);
String theImgHTML = "<img src=\"" + wsContent.getLink() + "\"></img>"; String theImgHTML = "<img src=\"" + wsContent.getLink() + "\"></img>";
GWT.log("theImgHTML: " + theImgHTML); GWT.log("theImgHTML: " + theImgHTML);
@ -898,6 +941,7 @@ public class LayerManager {
} }
}); });
} }
}); });
} }