Browse Source

merged manually with branch 'layer_switcher' #21991

master
Francesco Mangiacrapa 2 months ago
parent
commit
dba98bfd0f
  1. 217
      .settings/org.eclipse.wst.common.component
  2. 1
      CHANGELOG.md
  3. 2
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml
  4. 96
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java
  5. 204
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java
  6. 9
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java
  7. 37
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OverlayLayerManager.java
  8. 32
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/AddedLayerToMapEvent.java
  9. 175
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/DoActionOnDetailLayersEvent.java
  10. 21
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/DoActionOnDetailLayersEventHandler.java
  11. 216
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java
  12. 77
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java
  13. 8
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.ui.xml
  14. 184
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/DragDropLayer.java
  15. 71
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/RangeSlider.java
  16. 16
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/dandd/RangeSlider.ui.xml
  17. 22
      src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/util/StringUtil.java
  18. 2
      src/main/resources/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml
  19. 79
      src/main/webapp/GeoportalDataViewer.css

217
.settings/org.eclipse.wst.common.component

@ -1,204 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="geoportal-data-viewer-app-2.0.0-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-common-1.2.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="geoportal-data-viewer-app"/>
</wb-module>
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="geoportal-data-viewer-app-2.0.0-SNAPSHOT">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-common-1.2.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
<property name="context-root" value="geoportal-data-viewer-app"/>
</wb-module>
</project-modules>

1
CHANGELOG.md

@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- [#22042] Implemented the public access
- [#22040] Revisited the "Abstract and Relazione di Scavo"
- [#22041] Files have been ported to FileSet model
- [#21991] Implemented the Layer Switcher
## [v1.2.0-SNAPSHOT] - 2021-07-19

2
src/main/java/org/gcube/portlets/user/geoportaldataviewer/GeoportalDataViewer.gwt.xml

@ -6,7 +6,7 @@
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<inherits name='ol.GwtOL' />

96
src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java

@ -10,9 +10,13 @@ import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
@ -22,6 +26,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMini
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
@ -87,9 +92,7 @@ public class GeoportalDataViewer implements EntryPoint {
* This is the entry point method.
*/
public void onModuleLoad() {
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight());
RootPanel.get(APP_DIV).add(mainPanel);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@ -173,7 +176,7 @@ public class GeoportalDataViewer implements EntryPoint {
layerItem.setName(layerName);
layerManager.setBaseLayerFromIsProfile(layerItem);
layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false,
null, false, null, null,null);
null, false, null, null, null);
if (paramGeonaItemID != null) {
if (paramGeonaItemType == null) {
@ -193,7 +196,6 @@ public class GeoportalDataViewer implements EntryPoint {
});
bindEvents();
}
/**
@ -267,7 +269,7 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
GWT.log("Fired AddedLayerToMapEvent " + addedLayerToMapEvent.getLayerItem());
GWT.log("Fired AddedLayerToMapEvent " + addedLayerToMapEvent.getLayerItem() + "layer type: "+addedLayerToMapEvent.getLayerType());
// GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent
// "+addedLayerToMapEvent.getLayerItem());
@ -304,6 +306,23 @@ public class GeoportalDataViewer implements EntryPoint {
// TODO: handle exception
}
LAYER_TYPE layerType = addedLayerToMapEvent.getLayerType();
if (layerType != null) {
switch (layerType) {
case BASE:
break;
case OVERLAY:
mainPanel.showOverlayLayers(layerManager.getOverlayLayerManager().getPanel());
break;
default:
break;
}
}
}
});
@ -315,8 +334,13 @@ public class GeoportalDataViewer implements EntryPoint {
if (mainPanel.getDisplyedRecord() == null && !olMapMng.isQueryPointActive()) {
olMapMng.hidePopInfo();
layerManager.removeAllDetailLayers();
}
mainPanel.hideOverlayLayers();
// layerManager.getOverlayLayerManager().hide();
// hidePopupLayers();
}
});
@ -337,8 +361,63 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
applicationBus.addHandler(DoActionOnDetailLayersEvent.TYPE, new DoActionOnDetailLayersEventHandler() {
@Override
public void onDoActionOnDetailLayers(DoActionOnDetailLayersEvent doLayerActionEvent) {
DO_LAYER_ACTION doAction = doLayerActionEvent.getDoAction();
GWT.log("event: "+doAction);
GWT.log("layer source: "+doLayerActionEvent.getLayerItem().getName());
OpenLayerOSM olMap = olMapMng.getOLOSMMap();
switch (doAction) {
case OPACITY:
GWT.log("opacity: "+doLayerActionEvent.getOpacity());
olMap.setWMSDetailLayerOpacity(doLayerActionEvent.getLayerItem(),
doLayerActionEvent.getOpacity());
break;
case SWAP:
org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem sourceLayerSwap = doLayerActionEvent.getSourceLayerSwap();
org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem target = doLayerActionEvent.getTargetLayerSwap();
GWT.log("SWAPPING source "+sourceLayerSwap.getName() +", target: "+target.getName());
olMap.swapDetailsLayers(sourceLayerSwap.getName(), target.getName());
break;
case VISIBILITY:
GWT.log("visibility: "+doLayerActionEvent.getVisibility());
olMap.setWMSDetailLayerVisible(doLayerActionEvent.getLayerItem(),
doLayerActionEvent.getVisibility());
break;
default:
break;
}
}
});
}
// /**
// * Handler popu closer.
// *
// * @param divId the div id
// * @param overlayId the overlay id
// */
// public static native void handlerPopuCloser(String divId, String overlayId) /*-{
// var closer = $doc.getElementById(divId);
// var overlay = $doc.getElementById(overlayId);
// closer.onclick = function() {
// overlay.setPosition(undefined);
// closer.blur();
// return false;
// };
//
// }-*/;
private void performWFSQueryOnCentroid(RecordDV record) {
if (record != null) {
GWT.log("record instanceof ConcessioneDV: " + (record instanceof ConcessioneDV) + " with mongo item id: "
@ -356,9 +435,10 @@ public class GeoportalDataViewer implements EntryPoint {
GeoQuery select = olMapMng.toDataPointQuery(transfCoord, false);
GWT.log("GeoQuery: " + select);
// GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
ExtentWrapped toExt = new ExtentWrapped(transfCoord.getX(), transfCoord.getY(), transfCoord.getX(), transfCoord.getY());
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, toExt,
record.getItemId(), true, MapEventType.ADDED_CENTROID_LAYER_TO_MAP));
ExtentWrapped toExt = new ExtentWrapped(transfCoord.getX(), transfCoord.getY(), transfCoord.getX(),
transfCoord.getY());
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, toExt, record.getItemId(),
true, MapEventType.ADDED_CENTROID_LAYER_TO_MAP));
} else {
GeoportalDataViewerConstants.printJs(
"I cannot select the point one or both coordiantes are null. X: " + x + ", Y:" + y);

204
src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/LayerManager.java

@ -4,6 +4,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -89,6 +90,8 @@ public class LayerManager {
private org.gcube.application.geoportalcommon.shared.LayerItem baseLayerFromISProfile;
private OverlayLayerManager overlayLayerManager;
/**
* Instantiates a new layer manager.
*
@ -96,6 +99,7 @@ public class LayerManager {
*/
public LayerManager(HandlerManager applicationBus) {
this.applicationBus = applicationBus;
overlayLayerManager = new OverlayLayerManager(applicationBus);
bindEvents();
}
@ -118,11 +122,6 @@ public class LayerManager {
GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2()
+ "," + selectDataInfo.getY2() + ")");
// for (LayerObject layerObj : layerObjects.values()) {
// // TODO
// isLayerVisible(layerObj.getLayerItem());
// }
BoundsMap mapBBOX = new BoundsMap();
double minX = queryEvent.getGeoQuery().getX1();
double minY = queryEvent.getGeoQuery().getY1();
@ -154,7 +153,30 @@ public class LayerManager {
// for querying detail layers only in this case
if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
listLO.addAll(mapDetailLayerObjects.values());
Collection<LayerObject> collLO = mapDetailLayerObjects.values();
listLO.addAll(collLO);
ArrayList<LayerObject> layerVisibility = new ArrayList<LayerObject>(collLO.size());
layerVisibility.addAll(collLO);
//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");
listLO.remove(layerObject);
}
// else {
// ExtentWrapped layerExtent = olMap.getSourceExtentForLayer(layerName);
// if(layerExtent!=null) {
// ExtentWrapped centerQueryPoint = new ExtentWrapped(minX, minY, maxX,maxY);
//
// boolean contains = layerExtent.containsExtent(centerQueryPoint);
// GWT.log("layer: "+layerName + " contains the queried BBOX: "+contains);
// }
// }
//
}
}
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(),
@ -309,9 +331,13 @@ public class LayerManager {
});
}
/**
* Removes the all detail layers.
*/
public void removeAllDetailLayers() {
mapDetailLayerObjects.clear();
olMap.removeAllDetailLayers();
overlayLayerManager.resetLayers();
}
/**
@ -422,6 +448,8 @@ public class LayerManager {
if (dlo == null) {
mapDetailLayerObjects.put(key, lo);
olMap.addWMSDetailLayer(layerItem);
overlayLayerManager.addLayerItem(lo);
//overlayLayerManager.show();
} else {
GWT.log("Skipping detail layer " + key + " already added to Map");
}
@ -517,15 +545,14 @@ public class LayerManager {
/**
* Show popup info for layer.
*
* @param geoNaDataObject the geo na data object
* @param feature the feature
* @param onFailureCenterTo the on failure center to
* @param listGeoNaDataObject the list geo na data object
* @param queryClick the query click
*/
public void showPopupInfoForLayer(List<GeoNaSpatialQueryResult> listGeoNaDataObject, ExtentWrapped queryClick) {
ScrollPanel scrollPanel = new ScrollPanel();
FlowPanel flowPanel = new FlowPanel();
//flowPanel.getElement().getStyle().setProperty("maxHeight", "600px");
// flowPanel.getElement().getStyle().setProperty("maxHeight", "600px");
scrollPanel.add(flowPanel);
String prevConcessioneName = "";
@ -542,7 +569,13 @@ public class LayerManager {
|| layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName()) == 0) {
continue;
}
List<FeatureRow> features = geoNaSpatialQueryResult.getFeatures();
if (features == null || features.isEmpty()) {
continue;
}
String nomeConcessione = lo.getSourceConcessione().getNome();
if (prevConcessioneName.compareTo(nomeConcessione) != 0) {
String concessioneIntro = StringUtil.ellipsize(lo.getSourceConcessione().getNome(), 40);
@ -559,13 +592,15 @@ public class LayerManager {
Label layerLabel = new Label();
layerLabel.setType(LabelType.INFO);
layerLabel.setText(layerSourceName);
String layerName = StringUtil.fullNameToLayerName(layerSourceName, ":");
layerLabel.setText(layerName);
layerLabel.setTitle(layerSourceName);
layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX);
layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX);
flowPanel.add(layerLabel);
List<FeatureRow> features = geoNaSpatialQueryResult.getFeatures();
/*
if (features == null || features.isEmpty()) {
FlexTable flex = new FlexTable();
flex.setCellPadding(1);
@ -575,9 +610,9 @@ public class LayerManager {
flowPanel.add(flex);
continue;
// olMap.showPopup(vpPanel.toString(), onFailureCenterTo);
}
GWT.log("Displaying "+features.size() + " features");
}*/
GWT.log("Displaying " + features.size() + " features");
FlexTable intFlex = new FlexTable();
intFlex.setCellPadding(1);
intFlex.setCellSpacing(1);
@ -593,8 +628,8 @@ public class LayerManager {
Map<String, List<String>> entries = feature.getMapProperties();
if (entries.size() == 0) {
//Adding this row to show "no property" for feature
//intFlex.setHTML(i + 1, 1, new HTML("<i>No property</i>").toString());
// Adding this row to show "no property" for feature
// intFlex.setHTML(i + 1, 1, new HTML("<i>No property</i>").toString());
}
int j = 0;
for (String key : entries.keySet()) {
@ -619,113 +654,13 @@ public class LayerManager {
}
flowPanel.add(intFlex);
} catch (Exception e) {
GeoportalDataViewerConstants.printJs("Error: "+e.getMessage());
GeoportalDataViewerConstants.printJs("Error: " + e.getMessage());
}
}
olMap.showPopup(scrollPanel.toString(), queryClick.getCenter());
}
// /**
// * Show popup info for layer.
// *
// * @param geoNaDataObject the geo na data object
// * @param feature the feature
// * @param onFailureCenterTo the on failure center to
// */
// public void showPopupInfoForLayer(List<GeoNaSpatialQueryResult> listGeoNaDataObject,
// ExtentWrapped queryClick) {
//
// ScrollPanel scrollPanel = new ScrollPanel();
// VerticalPanel vpPanel = new VerticalPanel();
// scrollPanel.add(vpPanel);
//
// String prevConcessioneName = "";
// for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) {
//
// GWT.log("baseLayerFromISProfile.getName() :"+baseLayerFromISProfile.getName());
// LayerObject lo = geoNaSpatialQueryResult.getSourceLayerObject();
// LayerItem sourceLI = lo.getLayerItem();
//
// String layerSourceName = sourceLI.getName();
//
// //skipping centroid layer
// if(layerSourceName==null || layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName())==0) {
// continue;
// }
//
// String nomeConcessione = lo.getSourceConcessione().getNome();
// if(prevConcessioneName.compareTo(nomeConcessione)!=0) {
// String concessioneIntro = StringUtil.ellipsize(lo.getSourceConcessione().getNome(), 40);
// Heading heading = new Heading(4, concessioneIntro);
// heading.getElement().getStyle().setMarginBottom(10, Unit.PX);
// vpPanel.add(heading);
// HTML subText = new HTML("<p style=\"color:#999; font-size:14px; margin:5px 0 5px 0;\">Layers and Properties</p>");
// vpPanel.add(subText);
// }
//
// prevConcessioneName = nomeConcessione;
//
// Label layerLabel = new Label();
// layerLabel.setType(LabelType.INFO);
//
// layerLabel.setText(layerSourceName);
// layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX);
// layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX);
// vpPanel.add(layerLabel);
//
// List<FeatureRow> features = geoNaSpatialQueryResult.getFeatures();
//
// if (features == null || features.isEmpty()) {
// FlexTable flex = new FlexTable();
// flex.setCellPadding(1);
// flex.setCellSpacing(1);
// flex.getElement().addClassName("table-feature");
// flex.setHTML(0, 0, new HTML("No data available").toString());
// vpPanel.add(flex);
// continue;
// //olMap.showPopup(vpPanel.toString(), onFailureCenterTo);
// }
//
// for (FeatureRow feature : features) {
//
// FlexTable intFlex = new FlexTable();
// intFlex.setCellPadding(1);
// intFlex.setCellSpacing(1);
// intFlex.getElement().addClassName("table-feature");
//
// intFlex.setHTML(0, 0, new HTML("Feature Id").toString());
// intFlex.setHTML(1, 0, new HTML(feature.getId()).toString());
//
// // Showing properties belonging to concessioni centroid layer
// Map<String, List<String>> entries = feature.getMapProperties();
//
// if (entries.size() == 0) {
// intFlex.setHTML(1, 1, new HTML("No property available").toString());
// }
// int j = 1;
// for (String key : entries.keySet()) {
// List<String> theValues = entries.get(key);
// String valueToDisplay = "";
// for (String value : theValues) {
// valueToDisplay+=value+", ";
//
// }
// valueToDisplay = valueToDisplay.substring(0,valueToDisplay.length()-2);
// intFlex.setHTML(0, j, new HTML(key).toString());
// intFlex.setHTML(1, j, new HTML(valueToDisplay).toString());
// j++;
//
// }
//
// vpPanel.add(intFlex);
// }
// }
//
// olMap.showPopup(scrollPanel.toString(), queryClick.getCenter());
//
// }
/**
* Show popup info for centroid layer.
@ -900,16 +835,6 @@ public class LayerManager {
}
/**
* Checks if is layer visible.
*
* @param layerItem the layer item
* @return true, if is layer visible
*/
public boolean isLayerVisible(LayerItem layerItem) {
return olMap.isLayerVisible(layerItem.getName());
}
/**
* Sets the ol map.
*
@ -928,12 +853,31 @@ public class LayerManager {
return layerManagerBus;
}
/**
* Sets the base layer from is profile.
*
* @param layerItem the new base layer from is profile
*/
public void setBaseLayerFromIsProfile(org.gcube.application.geoportalcommon.shared.LayerItem layerItem) {
this.baseLayerFromISProfile = layerItem;
}
/**
* Gets the base layer from IS proile.
*
* @return the base layer from IS proile
*/
public org.gcube.application.geoportalcommon.shared.LayerItem getBaseLayerFromISProile() {
return baseLayerFromISProfile;
}
/**
* Gets the overlay layer manager.
*
* @return the overlay layer manager
*/
public OverlayLayerManager getOverlayLayerManager() {
return overlayLayerManager;
}
}

9
src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java

@ -38,7 +38,7 @@ public class OLMapManager {
private ol.Extent dragEndExtent = null;
public static final int QUERY_MIN_ZOOM_LEVEL = 13;
public static final Double LAYER_DETAIL_MIN_RESOLUTION = 0.01;
public static final Double LAYER_DETAIL_MAX_RESOLUTION = 13.0;
public static final Double LAYER_DETAIL_MAX_RESOLUTION = 18.5;
/**
@ -255,11 +255,4 @@ public class OLMapManager {
olMap.hidePopup();
}
// /**
// * Removes the detail layers.
// */
// public void removeDetailLayers() {
// olMap.removeAllDetailLayers();
// }
}

37
src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OverlayLayerManager.java

@ -0,0 +1,37 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dandd.DragDropLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.FlowPanel;
public class OverlayLayerManager {
private ArrayList<LayerObject> layers = new ArrayList<LayerObject>();
private FlowPanel fp = new FlowPanel();
private HandlerManager applicationBus;
public OverlayLayerManager(HandlerManager applicationBus) {
this.applicationBus = applicationBus;
//fp.addStyleName("layers-panel");
}
void addLayerItem(LayerObject lo) {
DragDropLayer dandd = new DragDropLayer(applicationBus, lo, true, true);
layers.add(lo);
fp.add(dandd);
}
public void resetLayers() {
layers.clear();
fp.clear();
}
public FlowPanel getPanel() {
return fp;
}
}

32
src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/AddedLayerToMapEvent.java

@ -4,26 +4,38 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class AddedLayerToMapEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 18, 2020
* Nov 18, 2020
*/
public class AddedLayerToMapEvent extends GwtEvent<AddedLayerToMapEventHandler> {
public static Type<AddedLayerToMapEventHandler> TYPE = new Type<AddedLayerToMapEventHandler>();
private LayerItem layerItem;
private LAYER_TYPE layerType;
/**
* The Enum LAYER_TYPE.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 11, 2021
*/
public enum LAYER_TYPE {
BASE, OVERLAY
}
/**
* Instantiates a new added layer to map event.
*
* @param layerItem the layer item
* @param layerType the layer type
*/
public AddedLayerToMapEvent(LayerItem layerItem) {
public AddedLayerToMapEvent(LayerItem layerItem, LAYER_TYPE layerType) {
this.layerItem = layerItem;
this.layerType = layerType;
}
/**
@ -46,7 +58,7 @@ public class AddedLayerToMapEvent extends GwtEvent<AddedLayerToMapEventHandler>
handler.onLayerRendered(this);
}
/**
* Gets the layer item.
*
@ -55,6 +67,14 @@ public class AddedLayerToMapEvent extends GwtEvent<AddedLayerToMapEventHandler>
public LayerItem getLayerItem() {
return layerItem;
}
/**
* Gets the layer type.
*
* @return the layer type
*/
public LAYER_TYPE getLayerType() {
return layerType;
}
}

175
src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/DoActionOnDetailLayersEvent.java

@ -0,0 +1,175 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class DoActionOnDetailLayersEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 12, 2021
*/
public class DoActionOnDetailLayersEvent extends GwtEvent<DoActionOnDetailLayersEventHandler> {
public static Type<DoActionOnDetailLayersEventHandler> TYPE = new Type<DoActionOnDetailLayersEventHandler>();
/**
* The Enum DO_LAYER_ACTION.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 12, 2021
*/
public static enum DO_LAYER_ACTION {
VISIBILITY, SWAP, OPACITY
}
private DO_LAYER_ACTION doAction;
private LayerItem layerItem;
private double opacity;
private boolean visibility;
private LayerItem sourceLayerSwap;
private LayerItem targetLayerSwap;
/**
* Instantiates a new do action on detail layers event.
*
* @param action the action
* @param layerItem the layer item
*/
public DoActionOnDetailLayersEvent(DO_LAYER_ACTION action, LayerItem layerItem) {
this.layerItem = layerItem;
this.doAction = action;
}
/**
* Sets the swap layers.
*
* @param sourceLayerItem the source layer item
* @param targetLayerItem the target layer item
*/
public void setSwapLayers(LayerItem sourceLayerItem, LayerItem targetLayerItem) {
this.sourceLayerSwap = sourceLayerItem;
this.targetLayerSwap = targetLayerItem;
}
/**
* Sets the opacity.
*
* @param opacity the new opacity
*/
public void setOpacity(double opacity) {
this.opacity = opacity;
}
/**
* Sets the visibility.
*
* @param visibility the new visibility
*/
public void setVisibility(boolean visibility) {
this.visibility = visibility;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<DoActionOnDetailLayersEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(DoActionOnDetailLayersEventHandler handler) {
handler.onDoActionOnDetailLayers(this);
}
/**
* Gets the do action.
*
* @return the do action
*/
public DO_LAYER_ACTION getDoAction() {
return doAction;
}
/**
* Gets the layer item.
*
* @return the layer item
*/
public LayerItem getLayerItem() {
return layerItem;
}
/**
* Gets the source layer swap.
*
* @return the source layer swap
*/
public LayerItem getSourceLayerSwap() {
return sourceLayerSwap;
}
/**
* Gets the target layer swap.
*
* @return the target layer swap
*/
public LayerItem getTargetLayerSwap() {
return targetLayerSwap;
}
/**
* Gets the opacity.
*
* @return the opacity
*/
public double getOpacity() {
return opacity;
}
/**
* Gets the visibility.
*
* @return the visibility
*/
public boolean getVisibility() {
return visibility;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("DoActionOnDetailLayersEvent [doAction=");
builder.append(doAction);
builder.append(", layerItem=");
builder.append(layerItem);
builder.append(", opacity=");
builder.append(opacity);
builder.append(", visibility=");
builder.append(visibility);
builder.append(", sourceLayerSwap=");
builder.append(sourceLayerSwap);
builder.append(", targetLayerSwap=");
builder.append(targetLayerSwap);
builder.append("]");
return builder.toString();
}
}

21
src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/events/DoActionOnDetailLayersEventHandler.java

@ -0,0 +1,21 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface DoActionOnDetailLayersEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Oct 8, 2021
*/
public interface DoActionOnDetailLayersEventHandler extends EventHandler {
/**
* On do action on detail layers.
*
* @param doActionOnDetailLayersEvent the do action on detail layers event
*/
void onDoActionOnDetailLayers(DoActionOnDetailLayersEvent doActionOnDetailLayersEvent);
}

216
src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java

@ -1,17 +1,18 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.LinkedHashMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent.LAYER_TYPE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
@ -58,7 +59,6 @@ import ol.source.Source;
import ol.source.Vector;
import ol.source.XyzOptions;
// TODO: Auto-generated Javadoc
/**
* The Class OpenLayerOSM.
*
@ -131,9 +131,11 @@ public abstract class OpenLayerOSM {
private boolean isQueryPointActive;
private java.util.Map<String, Image> wmsDetailsLayerMap;
private LinkedHashMap<String, Image> wmsDetailsLayerMap;
private HashMap<String, Image> wmsLayerMap;
private Integer[] wmsDetailsLayerZIndex = new Integer[100];
private LinkedHashMap<String, Image> wmsLayerMap;
/**
* Instantiates a new open layer OSM.
@ -149,6 +151,10 @@ public abstract class OpenLayerOSM {
public OpenLayerOSM(String divTargetId, HandlerManager eventBus) {
this.eventBus = eventBus;
for (int i = 0; i < 100; i++) {
wmsDetailsLayerZIndex[i] = 1000 + i;
}
// create a OSM-layer
XyzOptions xyzOptions = OLFactory.createOptions();
// osmSourceOptions.setCrossOrigin("Anonymous");
@ -157,7 +163,7 @@ public abstract class OpenLayerOSM {
Osm osmSource = new Osm(xyzOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
// create a projection
projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName());
@ -335,11 +341,11 @@ public abstract class OpenLayerOSM {
public void addWMSLayer(LayerItem layerItem) {
if (wmsLayerMap == null)
wmsLayerMap = new HashMap<String, Image>();
wmsLayerMap = new LinkedHashMap<String, Image>();
String key = layerItem.getName();
Image layer = wmsLayerMap.get(key);
Image layer = wmsLayerMap.get(layerItem.getName());
if (layer == null) {
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerItem.getName());
@ -370,7 +376,7 @@ public abstract class OpenLayerOSM {
wmsLayerMap.put(key, wmsLayer);
GWT.log("Added WMSLayer for layer: " + layerItem.getName());
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem, LAYER_TYPE.BASE));
} else {
GWT.log("The WMS layer with key: " + key + " already exists, skipping");
}
@ -385,9 +391,9 @@ public abstract class OpenLayerOSM {
public void addWMSDetailLayer(LayerItem layerItem) {
if (wmsDetailsLayerMap == null)
wmsDetailsLayerMap = new HashMap<String, Image>();
wmsDetailsLayerMap = new LinkedHashMap<String, Image>();
String key = layerItem.getName();
String key = layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key);
@ -414,14 +420,12 @@ public abstract class OpenLayerOSM {
}
Image wmsLayer = new Image(layerOptions);
// visibleLayerItems
wmsLayer.setZIndex(wmsDetailsLayerMap.size() + 1);
map.addLayer(wmsLayer);
wmsDetailsLayerMap.put(key, wmsLayer);
GWT.log("Added WMSDetailLayer for layer name: " + layerItem.getName());
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem, LAYER_TYPE.OVERLAY));
} else {
GWT.log("The WMS detail layer with key: " + key + " already exists, skipping");
}
@ -562,7 +566,7 @@ public abstract class OpenLayerOSM {
* @param element the element
* @return the overlay
*/
private Overlay addOverlay(Element element) {
public Overlay addOverlay(Element element) {
/**
* Create an overlay to anchor the popup to the map.
*/
@ -574,55 +578,6 @@ public abstract class OpenLayerOSM {
return overlay;
}
/**
* Checks if is layer visible.
*
* @param layerName the layer name
* @return true, if is layer visible
*/
public boolean isLayerVisible(String layerName) {
Collection<Base> layers = map.getLayers();
if (layers != null) {
Base[] layersArr = layers.getArray();
for (int i = 0; i < layersArr.length; i++) {
Base layer = layersArr[i];
String theLayerName = (String) layer.get("name");
GWT.log("The Layer name is: " + theLayerName);
if (theLayerName != null && theLayerName.equals(layerName))
return true;
}
}
return false;
}
/**
* Gets the layer property.
*
* @param layerName the layer name
* @param property the property
* @return the layer property
*/
public String getLayerProperty(String layerName, String property) {
Collection<Base> layers = map.getLayers();
if (layers != null) {
Base[] layersArr = layers.getArray();
for (int i = 0; i < layersArr.length; i++) {
Base layer = layersArr[i];
String theLayerName = (String) layer.get("name");
GWT.log("The Layer name is: " + layerName);
if (theLayerName != null && theLayerName.equals(layerName))
return layer.get(property);
}
}
return null;
}
/**
* Gets the projection code.
*
@ -716,15 +671,14 @@ public abstract class OpenLayerOSM {
return this.map != null;
}
/**
* Gets the layers from map.
*
* @return the layers from map
*/
public List<String> getLayersFromMap() {
public ArrayList<String> getLayersFromMap() {
Collection<Base> layers = map.getLayers();
List<String> layerNames = null;
ArrayList<String> layerNames = null;
if (layers != null) {
Base[] layersArr = layers.getArray();
layerNames = new ArrayList<String>(layersArr.length);
@ -734,30 +688,78 @@ public abstract class OpenLayerOSM {
Image layerImage = (Image) layer;
Source source = layerImage.getSource();
// GWT.log("source: "+source.toString());
// GeoportalDataViewerConstants.printJsObj(source);
String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source);
JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj);
// GWT.log("jsonObj: " + jsonObj.toString());
JSONObject jsonSourceObj = (JSONObject) jsonObj;
GeoportalDataViewerConstants.printJsObj(jsonSourceObj);
JSONObject jsonParamsObj = (JSONObject) jsonSourceObj.get("params_");
// GWT.log("jsonParamsObj is: "+jsonParamsObj);
JSONValue jsonLayers = jsonParamsObj.get("LAYERS");
GWT.log("theLayerName name is: " + jsonLayers);
layerNames.add(jsonLayers.toString());
JSONObject imagesParamsObj = (JSONObject) jsonSourceObj.get("image_");
JSONArray extent = (JSONArray) imagesParamsObj.get("extent");
GWT.log("extentLayer: " + extent.toString());
}
}
}
return layerNames;
}
/**
* Gets the source extent for layer.
*
* @param layerName the layer name
* @return the source extent for layer
*/
public ExtentWrapped getSourceExtentForLayer(String layerName) {
Collection<Base> layers = map.getLayers();
if (layers != null) {
Base[] layersArr = layers.getArray();
for (int i = 0; i < layersArr.length; i++) {
Base layer = layersArr[i];
if (layer instanceof Image) {
Image layerImage = (Image) layer;
Source source = layerImage.getSource();
// GeoportalDataViewerConstants.printJsObj(source);
String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source);
JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj);
// GWT.log("jsonObj: " + jsonObj.toString());
JSONObject jsonSourceObj = (JSONObject) jsonObj;
// GeoportalDataViewerConstants.printJsObj(jsonSourceObj);
JSONObject jsonParamsObj = (JSONObject) jsonSourceObj.get("params_");
// GWT.log("jsonParamsObj is: "+jsonParamsObj);
JSONValue jsonLayers = jsonParamsObj.get("LAYERS");
String layerNameIntoMap = jsonLayers.toString().replaceAll("\"", "");
if (layerName.compareTo(layerNameIntoMap) == 0) {
JSONObject imagesParamsObj = (JSONObject) jsonSourceObj.get("image_");
JSONArray extent = (JSONArray) imagesParamsObj.get("extent");
// GWT.log("extentLayer: "+extent.toString());
double minX = Double.parseDouble(extent.get(0).toString());
double minY = Double.parseDouble(extent.get(1).toString());
double maxX = Double.parseDouble(extent.get(2).toString());
double maxY = Double.parseDouble(extent.get(3).toString());
return new ExtentWrapped(minX, minY, maxX, maxY);
}
}
}
}
return null;
}
/**
* Gets the wms details layer map.
*
* @return the wms details layer map
*/
public java.util.Map<String, Image> getWmsDetailsLayerMap() {
public LinkedHashMap<String, Image> getWmsDetailsLayerMap() {
return wmsDetailsLayerMap;
}
@ -766,8 +768,80 @@ public abstract class OpenLayerOSM {
*
* @return the wms layer map
*/
public HashMap<String, Image> getWmsLayerMap() {
public LinkedHashMap<String, Image> getWmsLayerMap() {
return wmsLayerMap;
}
/**
* Checks if is layer visible.
*
* @param layerName the layer name
* @return true, if is layer visible
*/
public boolean isLayerVisible(String layerName) {
String key = layerName;
Image layer = wmsLayerMap.get(key);
if (layer != null)
return layer.getVisible();
layer = wmsDetailsLayerMap.get(key);
if (layer != null)
return layer.getVisible();
return false;
}
/**
* Sets the WMS detail layer visible.
*
* @param layerItem the layer item
* @param visible the visible
*/
public void setWMSDetailLayerVisible(LayerItem layerItem, boolean visible) {
String key = layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key);
layer.setVisible(visible);
}
/**
* Sets the WMS detail layer opacity.
*
* @param layerItem the layer item
* @param opacity the opacity
*/
public void setWMSDetailLayerOpacity(LayerItem layerItem, double opacity) {
String key = layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key);
layer.setOpacity(opacity);
}
/**
* Swap details layers.
*
* @param layerSource the source index
* @param layerTarget the target index
*/
public void swapDetailsLayers(String layerSource, String layerTarget) {
Image layer1 = wmsDetailsLayerMap.get(layerSource);
Image layer2 = wmsDetailsLayerMap.get(layerTarget);
int zIndex1 = layer1.getZIndex();
int zIndex2 = layer2.getZIndex();
layer1.setZIndex(zIndex2);
layer2.setZIndex(zIndex1);
}
/**
* Gets the layer by index.
*
* @param map the map
* @param index the index
* @return the layer by index
*/
private Image getLayerByIndex(LinkedHashMap<String, Image> map, int index) {
return map.get((map.keySet().toArray())[index]);
}
}

77
src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/GeonaDataViewMainPanel.java

@ -17,10 +17,12 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
@ -70,6 +72,12 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
Button extentToEarth;
@UiField
Button layersDDB;
@UiField
FlowPanel overlayLayersPanel;
private MapPanel mapPanel;
private OpenLayerOSM map;
@ -104,6 +112,28 @@ public class GeonaDataViewMainPanel extends Composite {
extentToEarth.getElement().appendChild(worldImg.getElement());
extentToEarth.setWidth("140px");
//layersDDB.setToggle(true);
bindEvents();
}
private void bindEvents() {
layersDDB.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GWT.log("layersDDB clicked");
if(overlayLayersPanel.isVisible()) {
overlayLayersPanel.setVisible(false);
}else {
overlayLayersPanel.setVisible(true);
}
}
});
}
/**
@ -229,4 +259,51 @@ public class GeonaDataViewMainPanel extends Composite {
return detailsPanel.getDisplayedRecord();
}
/**
* Gets the layers DDB.
*
* @return the layers DDB
*/
public Button getLayersDDB() {
return layersDDB;
}
/**
* Show overlay layers.
*
* @param panel the panel
*/
public void showOverlayLayers(FlowPanel panel) {
GWT.log("showOverlayLayers");
//layersDDB.setVisible(true);
overlayLayersPanel.setVisible(true);
overlayLayersPanel.clear();
overlayLayersPanel.add(panel);
//layersDDBClickEvent();
}
private void layersDDBClickEvent() {
layersDDB.fireEvent( new GwtEvent<ClickHandler>() {
@Override
public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType() {