task_22027 #4

Merged
francesco.mangiacrapa merged 14 commits from task_22027 into master 2021-12-07 09:50:57 +01:00
41 changed files with 1277 additions and 260 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/geoportal-data-viewer-app-2.0.0/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/geoportal-data-viewer-app-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-2.0.0/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -35,5 +35,5 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-2.0.0/WEB-INF/classes"/>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-2.1.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,4 +1,4 @@
eclipse.preferences.version=1
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.0.0
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.1.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -1,21 +1,41 @@
<?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">
<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"/>
<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>
<wb-module deploy-name="geoportal-data-viewer-app-2.1.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"/>
<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>

View File

@ -4,6 +4,15 @@
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.1.0-SNAPSHOT] - 2021-11-10
#### Enhancements
- [#22027] Integrated with MapBox Satellite
- Added link "Open Project" in the pop-up of WFS details
- Moved to gwt-ol3 v8.1.0-gwt2_9
## [v2.0.1] - 2021-11-10
#### Fixes

View File

@ -11,7 +11,7 @@ The GeoPortal Data Viewer App is an application to access, discovery and navigat
* GWT v.2.9.0. [GWT](http://www.gwtproject.org) is licensed under [Apache License 2.0](http://www.gwtproject.org/terms.html)
* GWT-Bootstrap v.2.3.2.0. [GWT-Bootstrap](https://github.com/gwtbootstrap) is licensed under [[Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* GWT-OpenLayers 3+ v.8.0.0-gwt2_9. [GWT-OL3](https://github.com/TDesjardins/gwt-ol)
* GWT-OpenLayers 3+ v.8.1.0-gwt2_9. [GWT-OL3](https://github.com/TDesjardins/gwt-ol)
* OpenLayers v.6.X. [OpenLayers](https://openlayers.org/) is licensed under [BSD 2-Clause "Simplified"](https://github.com/openlayers/openlayers/blob/main/LICENSE.md)
## Documentation

View File

@ -14,7 +14,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-viewer-app</artifactId>
<packaging>war</packaging>
<version>2.0.1</version>
<version>2.1.0-SNAPSHOT</version>
<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>
@ -122,7 +122,7 @@
<dependency>
<groupId>com.github.tdesjardins</groupId>
<artifactId>gwt-ol3</artifactId>
<version>8.0.0-gwt2_9</version>
<version>8.1.0-gwt2_9</version>
</dependency>
<dependency>
<groupId>com.github.gwtbootstrap</groupId>

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.Iterator;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
@ -12,6 +13,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon
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.ChangeMapLayerEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ChangeMapLayerEventHandler;
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;
@ -27,9 +30,11 @@ 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.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import com.google.gwt.core.client.EntryPoint;
@ -43,6 +48,7 @@ import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
import ol.Coordinate;
@ -60,7 +66,7 @@ public class GeoportalDataViewer implements EntryPoint {
public final static String APP_DIV = "geoportal-data-viewer";
/** The ol map. */
// private OpenLayerOSM olMap = null;
// private OpenLayerMap olMap = null;
/** The main panel. */
private GeonaDataViewMainPanel mainPanel;
@ -88,11 +94,32 @@ public class GeoportalDataViewer implements EntryPoint {
private OLMapManager olMapMng = null;
int attempt = 0;
private LoaderIcon loaderApp = new LoaderIcon("Loading application... please wait");
private HTML attributionDiv = new HTML();
private static List<BaseMapLayer> listBaseMapLayers = null;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
loaderApp.getElement().addClassName("loader-gna-app");
RootPanel.get(APP_DIV).add(loaderApp);
paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER);
paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE);
paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID);
paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE);
GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest);
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType);
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID);
GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle);
RootPanel.get(APP_DIV).add(loaderApp);
mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight());
RootPanel.get(APP_DIV).add(mainPanel);
@ -101,13 +128,44 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void execute() {
olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(),
layerManager.getLayerManagerBus());
layerManager.setOlMap(olMapMng.getOLOSMMap());
mainPanel.setMap(olMapMng.getOLOSMMap());
updateSize();
ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js")
.setWindow(ScriptInjector.TOP_WINDOW).inject();
//LOADING THE BASE MAP LAYERS
GeoportalDataViewerServiceAsync.Util.getInstance().getListBaseLayers(new AsyncCallback<List<BaseMapLayer>>() {
@Override
public void onFailure(Throwable caught) {
RootPanel.get(APP_DIV).remove(loaderApp);
Window.alert("Sorry, an error occurred on instancing the GeoPortale Viewer. Please, contact the support");
}
@Override
public void onSuccess(List<BaseMapLayer> listBaseMapLayers) {
try {
RootPanel.get(APP_DIV).remove(loaderApp);
}catch (Exception e) {
loaderApp.setVisible(false);
}
GeoportalDataViewer.listBaseMapLayers = listBaseMapLayers;
//now the map is loaded and I'm sure that I can load the GeonaDataViewer Profile
loadGeonaDataViewerProfile();
mainPanel.setBaseLayers(listBaseMapLayers);
BaseMapLayer firstBaseLayer = listBaseMapLayers.get(0);
//Passing the first base map layer that will be applied as first base layer
olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(),
layerManager.getLayerManagerBus(), firstBaseLayer);
OpenLayerMap olMap = olMapMng.getOLMap();
layerManager.setOLMap(olMap);
mainPanel.setMap(olMap);
updateSize();
ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js")
.setWindow(ScriptInjector.TOP_WINDOW).inject();
}
});
}
});
@ -118,28 +176,19 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER);
paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE);
// paramUUID =
// Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER);
paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID);
paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE);
GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest);
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType);
GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID);
// GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID);
GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle);
// VALIDATING THE LONG FORMAT FOR GID
// try {
// if (paramGeonaItemID != null)
// Long.parseLong(paramGeonaItemID);
// } catch (Exception e) {
// Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID
// + ". It must be a Long");
// paramGeonaItemID = null;
// }
bindEvents();
RootPanel.get(APP_DIV).add(attributionDiv);
}
public static List<BaseMapLayer> getListBaseMapLayers() {
return listBaseMapLayers;
}
private void loadGeonaDataViewerProfile() {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
@ -195,8 +244,7 @@ public class GeoportalDataViewer implements EntryPoint {
});
}
});
bindEvents();
}
/**
@ -271,9 +319,7 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
GWT.log("Fired AddedLayerToMapEvent " + addedLayerToMapEvent.getLayerItem() + "layer type: "+addedLayerToMapEvent.getLayerType());
// GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent
// "+addedLayerToMapEvent.getLayerItem());
try {
attempt = 0;
@ -370,7 +416,7 @@ public class GeoportalDataViewer implements EntryPoint {
DO_LAYER_ACTION doAction = doLayerActionEvent.getDoAction();
GWT.log("event: "+doAction);
GWT.log("layer source: "+doLayerActionEvent.getLayerItem().getName());
OpenLayerOSM olMap = olMapMng.getOLOSMMap();
OpenLayerMap olMap = olMapMng.getOLMap();
switch (doAction) {
case OPACITY:
@ -399,6 +445,30 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
applicationBus.addHandler(ChangeMapLayerEvent.TYPE, new ChangeMapLayerEventHandler() {
@Override
public void onChangeBaseMapLayer(ChangeMapLayerEvent changeMapLayerEvent) {
BaseMapLayer baseLayer = changeMapLayerEvent.getBaseMapLayer();
if (baseLayer == null)
return;
String attributionHTML = "<div class='map-credits'><div class='map-credits-container'>"
+ baseLayer.getAttribution() + "</div></div>";
olMapMng.getOLMap().changeBaseMap(baseLayer);
// THE OSM Contributors are automatically added by gwt-ol, others ones not.
if (!baseLayer.getType().equals(BaseMapLayer.OL_BASE_MAP.OSM)) {
attributionDiv.setHTML(attributionHTML);
} else
attributionDiv.setHTML("");
}
});
}

View File

@ -9,6 +9,7 @@ import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -124,5 +125,7 @@ public interface GeoportalDataViewerService extends RemoteService {
List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel);
List<BaseMapLayer> getListBaseLayers();
}

View File

@ -9,6 +9,7 @@ import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -58,4 +59,6 @@ public interface GeoportalDataViewerServiceAsync {
void getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature,
double zoomLevel, AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
void getListBaseLayers(AsyncCallback<List<BaseMapLayer>> callback);
}

View File

@ -26,7 +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.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow;
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
@ -57,6 +57,7 @@ import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.EventListener;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.FlexTable;
@ -81,7 +82,7 @@ import ol.geom.Geometry;
public class LayerManager {
/** The ol map. */
private OpenLayerOSM olMap;
private OpenLayerMap olMap;
private Map<String, LayerObject> mapDetailLayerObjects = new HashMap<String, LayerObject>();
private Map<String, LayerObject> mapBaseLayerObjects = new HashMap<String, LayerObject>();
@ -558,6 +559,8 @@ public class LayerManager {
flowPanel.getElement().getStyle().setProperty("maxHeight", "600px");
scrollPanel.add(flowPanel);
List<Button> listOpenProject = new ArrayList<Button>();
final Button expandButton = new Button("Expand");
expandButton.setType(ButtonType.LINK);
expandButton.setIcon(IconType.EXPAND);
@ -578,6 +581,10 @@ public class LayerManager {
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
expandButton.setVisible(false);
//hiding the Open Project in expand mode (Modal Window)
for (Button butt : listOpenProject) {
butt.setVisible(false);
}
flowPanel.getElement().getStyle().setProperty("maxHeight", "100%");
int width = Window.getClientWidth() * 75 / 100;
int height = Window.getClientHeight() * 70 / 100;
@ -594,8 +601,6 @@ public class LayerManager {
}
});
//fillLayersAndProperties(listGeoNaDataObject, expandButton, flowPanel);
String prevConcessioneName = "";
for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) {
try {
@ -624,6 +629,38 @@ public class LayerManager {
heading.setTitle(nomeConcessione);
heading.getElement().getStyle().setMarginBottom(10, Unit.PX);
flowPanel.add(heading);
Button buttOpenProject = new Button("Open Project");
final String buttId = "open-details-"+Random.nextInt();
Element bEl = buttOpenProject.getElement();
bEl.setId(buttId);
bEl.getStyle().setPaddingLeft(0, Unit.PX);
buttOpenProject.setType(ButtonType.LINK);
if (buttOpenProject != null) {
flowPanel.add(buttOpenProject);
buttOpenProject.setType(ButtonType.LINK);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
Element buttonElement = DOM.getElementById(buttId);
Event.sinkEvents(buttonElement, Event.ONCLICK);
Event.setEventListener(buttonElement, new EventListener() {
@Override
public void onBrowserEvent(Event event) {
if (Event.ONCLICK == event.getTypeInt()) {
applicationBus.fireEvent(new ShowDetailsEvent("concessione", lo.getSourceConcessione().getItemId(), nomeConcessione, null));
}
}
});
}
});
}
listOpenProject.add(buttOpenProject);
HTML subText = new HTML(
"<p style=\"color:#999; font-size:14px; margin:5px 0 5px 0;\">Layers and Properties</p>");
flowPanel.add(subText);
@ -686,6 +723,7 @@ public class LayerManager {
GeoportalDataViewerConstants.printJs("Error: " + e.getMessage());
}
}
olMap.showPopup(scrollPanel.toString(), queryClick.getCenter());
@ -869,7 +907,7 @@ public class LayerManager {
*
* @param olMap the new ol map
*/
public void setOlMap(OpenLayerOSM olMap) {
public void setOLMap(OpenLayerMap olMap) {
this.olMap = olMap;
}

View File

@ -6,10 +6,11 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent;
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.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
@ -31,7 +32,7 @@ public class OLMapManager {
private String targetId;
private HandlerManager layerManagerBus;
private OpenLayerOSM olMap;
private OpenLayerMap olMap;
private ol.Extent dragStartExtent = null;
private Double zoomStart = null;
private Double zoomEnd = null;
@ -39,26 +40,28 @@ public class OLMapManager {
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 = 18.5;
/**
* Instantiates a new OL map manager.
*
* @param targetId the target id
* @param layerManagerBus the layer manager bus
* @param baseMapLayer the base map layer
*/
public OLMapManager(String targetId, HandlerManager layerManagerBus) {
public OLMapManager(String targetId, HandlerManager layerManagerBus, BaseMapLayer baseMapLayer) {
this.targetId = targetId;
this.layerManagerBus = layerManagerBus;
instanceOLMap();
instanceOLMap(baseMapLayer);
}
/**
* Instance OL map.
*
* @param baseMapLayer the base map layer
*/
public void instanceOLMap() {
public void instanceOLMap(BaseMapLayer baseMapLayer) {
olMap = new OpenLayerOSM(targetId, layerManagerBus) {
olMap = new OpenLayerMap(targetId, layerManagerBus, baseMapLayer) {
@Override
public void clickListener(MapBrowserEvent event) {
@ -138,6 +141,7 @@ public class OLMapManager {
* To data point query.
*
* @param coordinate the coordinate
* @param manualClick the manual click
* @return the geo query
*/
public GeoQuery toDataPointQuery(Coordinate coordinate, boolean manualClick) {
@ -176,16 +180,18 @@ public class OLMapManager {
}
/**
* Gets the OLOSM map.
* Gets the OL map.
*
* @return the OLOSM map
* @return the OL map
*/
public OpenLayerOSM getOLOSMMap() {
public OpenLayerMap getOLMap() {
return olMap;
}
/**
* Check select query.
*
* @param mapEventType the map event type
*/
private void checkSelectQuery(MapEventType mapEventType) {

View File

@ -0,0 +1,57 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class ChangeMapLayerEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 12, 2021
*/
public class ChangeMapLayerEvent extends GwtEvent<ChangeMapLayerEventHandler> {
public static Type<ChangeMapLayerEventHandler> TYPE = new Type<ChangeMapLayerEventHandler>();
private BaseMapLayer baseMapLayer;
/**
* Instantiates a new change map layer event.
*
* @param baseMapLayer the base map layer
*/
public ChangeMapLayerEvent(BaseMapLayer baseMapLayer) {
this.baseMapLayer = baseMapLayer;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<ChangeMapLayerEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(ChangeMapLayerEventHandler handler) {
handler.onChangeBaseMapLayer(this);
}
/**
* Gets the base map layer.
*
* @return the base map layer
*/
public BaseMapLayer getBaseMapLayer() {
return baseMapLayer;
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface ChangeMapLayerEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 12, 2021
*/
public interface ChangeMapLayerEventHandler extends EventHandler {
/**
* On change base map layer.
*
* @param changeMapLayerEvent the change map layer event
*/
void onChangeBaseMapLayer(ChangeMapLayerEvent changeMapLayerEvent);
}

View File

@ -0,0 +1,51 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import java.util.HashMap;
/**
* The Class LayerOrder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 12, 2021
*/
public class LayerOrder {
/**
* The Enum LAYER_TYPE.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 12, 2021
*/
public static enum LAYER_TYPE {
BASE_MAP, BASE_WMS, WMS_DETAIL, VECTOR
}
public static final HashMap<LAYER_TYPE, Integer> LAYER_OFFSET = new HashMap<LAYER_TYPE, Integer>(5);
static {
LAYER_OFFSET.put(LAYER_TYPE.BASE_MAP, 0);
LAYER_OFFSET.put(LAYER_TYPE.BASE_WMS, 70);
LAYER_OFFSET.put(LAYER_TYPE.WMS_DETAIL, 140);
LAYER_OFFSET.put(LAYER_TYPE.VECTOR, 210);
}
/**
* Instantiates a new layer order.
*/
public LayerOrder() {
}
/**
* Gets the offset.
*
* @param layerType the layer type
* @return the offset
*/
public Integer getOffset(LAYER_TYPE layerType) {
return LAYER_OFFSET.get(layerType);
}
}

View File

@ -5,9 +5,11 @@ import java.util.HashMap;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
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.resources.Images;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
@ -27,6 +29,7 @@ import ol.MapOptions;
import ol.OLFactory;
import ol.View;
import ol.ViewOptions;
import ol.color.Color;
import ol.control.Attribution;
import ol.event.EventListener;
import ol.geom.Point;
@ -34,6 +37,7 @@ import ol.interaction.KeyboardPan;
import ol.interaction.KeyboardZoom;
import ol.layer.Base;
import ol.layer.Image;
import ol.layer.Layer;
import ol.layer.LayerOptions;
import ol.layer.Tile;
import ol.layer.VectorLayerOptions;
@ -44,22 +48,27 @@ import ol.source.ImageWmsOptions;
import ol.source.ImageWmsParams;
import ol.source.Osm;
import ol.source.Source;
import ol.source.Xyz;
import ol.source.XyzOptions;
import ol.style.Fill;
import ol.style.FillOptions;
import ol.style.Icon;
import ol.style.IconOptions;
import ol.style.Stroke;
import ol.style.StrokeOptions;
import ol.style.Style;
import ol.style.Text;
import ol.style.TextOptions;
/**
* The Class LightOpenLayerOSM.
* The Class LightOpenLayerMap.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 11, 2020
* Nov 12, 2021
*/
public class LightOpenLayerOSM {
public class LightOpenLayerMap {
public static final int MAX_ZOOM = 20;
/** The map. */
@ -78,24 +87,19 @@ public class LightOpenLayerOSM {
private ol.layer.Vector geometryLayer;
private String markerURL = Images.ICONS.mapMarkerIcon().getURL();
private String markerURL = GNAImages.ICONS.mapMarkerIcon().getURL();
private LayerOrder layerOrder = new LayerOrder();
private Layer baseLayerTile;
/**
* Instantiates a new light open layer OSM.
* Instantiates a new light open layer map.
*
* @param divTargetId the div target id
*/
public LightOpenLayerOSM(String divTargetId) {
public LightOpenLayerMap(String divTargetId) {
// create a OSM-layer
XyzOptions osmSourceOptions = OLFactory.createOptions();
osmSourceOptions.setCrossOrigin("Anonymous");
// osmSourceOptions.setTileLoadFunction(null);
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
// create a projection
projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName());
projectionOptions.setUnits("m");
@ -114,7 +118,7 @@ public class LightOpenLayerOSM {
map = new Map(mapOptions);
map.addLayer(osmLayer);
//map.addLayer(osmLayer);
// map.addLayer(tileDebugLayer);
Attribution attribution = new Attribution();
@ -161,6 +165,72 @@ public class LightOpenLayerOSM {
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
List<BaseMapLayer> listBaseMapLayers = GeoportalDataViewer.getListBaseMapLayers();
BaseMapLayer bml = null;
if(listBaseMapLayers!=null)
bml = listBaseMapLayers.get(0);
changeBaseMap(bml);
}
/**
* Change base map.
*
* @param baseLayer the base layer
*/
public void changeBaseMap(BaseMapLayer baseLayer) {
BaseMapLayer.OL_BASE_MAP baseMap = baseLayer.getType() == null ? BaseMapLayer.OL_BASE_MAP.OSM
: baseLayer.getType();
try {
if (baseLayerTile != null)
map.removeLayer(baseLayerTile);
} catch (Exception e) {
}
switch (baseMap) {
case MAPBOX:
case OTHER:
XyzOptions xyzOptions2 = OLFactory.createOptions();
xyzOptions2.setCrossOrigin("Anonymous");
Xyz xyz = new Xyz(xyzOptions2);
//setAttributions is buggy
//xyz.setAttributions(baseLayer.getAttribution());
xyz.setUrl(baseLayer.getUrl());
LayerOptions layerOptions2 = OLFactory.createOptions();
layerOptions2.setSource(xyz);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1;
layerOptions2.setZIndex(zIndex);
baseLayerTile = new Tile(layerOptions2);
break;
case OSM:
default:
XyzOptions osmSourceOptions = OLFactory.createOptions();
osmSourceOptions.setCrossOrigin("Anonymous");
Osm osmSource = new Osm(osmSourceOptions);
//osmSource.setUrl(baseLayer.getUrl());
//setAttributions is buggy
//osmSource.setAttributions(baseLayer.getAttribution());
LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(osmSource);
zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1;
layerOptions.setZIndex(zIndex);
baseLayerTile = new Tile(layerOptions);
break;
}
// map == null at init time
if (map != null) {
map.addLayer(baseLayerTile);
}
}
@ -212,6 +282,8 @@ public class LightOpenLayerOSM {
layerOptions.setSource(imageWMSSource);
ol.layer.Image wmsLayer = new ol.layer.Image(layerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL)+1;
wmsLayer.setZIndex(zIndex);
// visibleLayerItems
map.addLayer(wmsLayer);
@ -265,6 +337,11 @@ public class LightOpenLayerOSM {
return layerNames;
}
/**
* Gets the layer UR ls property.
*
* @return the layer UR ls property
*/
public java.util.Map<String, String> getLayerURLsProperty() {
Collection<Base> layers = map.getLayerGroup().getLayers();
@ -273,7 +350,7 @@ public class LightOpenLayerOSM {
Base[] layersArr = layers.getArray();
for (int i = 0; i < layersArr.length; i++) {
Base layer = layersArr[i];
//GeoportalDataViewerConstants.printJs(layer.toString());
// GeoportalDataViewerConstants.printJs(layer.toString());
if (layer instanceof Image) {
Image layerImage = (Image) layer;
@ -303,7 +380,7 @@ public class LightOpenLayerOSM {
}
}
GWT.log("returning mapLayerNameURL: "+mapLayerNameURL);
GWT.log("returning mapLayerNameURL: " + mapLayerNameURL);
return mapLayerNameURL;
}
@ -333,14 +410,15 @@ public class LightOpenLayerOSM {
if (showCoordinateText) {
TextOptions textOptions = new TextOptions();
textOptions.setOffsetY(-25);
// StrokeOptions strokeOptions = new StrokeOptions();
// strokeOptions.setColor(new Color(0, 0, 255, 0.0));
// strokeOptions.setWidth(4);
// Stroke stroke = new Stroke(strokeOptions);
// textOptions.setStroke(stroke);
// FillOptions fillOptions = new FillOptions();
// fillOptions.setColor(new Color(0, 0, 0, 0.0));
// textOptions.setFill(new Fill(fillOptions));
StrokeOptions strokeOptions = new StrokeOptions();
strokeOptions.setColor(new Color(255, 255, 255, 1.0));
strokeOptions.setWidth(4);
Stroke stroke = new Stroke(strokeOptions);
stroke.setWidth(5);
textOptions.setStroke(stroke);
FillOptions fillOptions = new FillOptions();
fillOptions.setColor(new Color(0, 0, 255, 1.0));
textOptions.setFill(new Fill(fillOptions));
Coordinate transfCoord = MapUtils.transformCoordiante(coordinate, MAP_PROJECTION.EPSG_3857.getName(),
MAP_PROJECTION.EPSG_4326.getName());
@ -365,6 +443,8 @@ public class LightOpenLayerOSM {
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
vectorLayerOptions.setSource(vector);
geometryLayer = new ol.layer.Vector(vectorLayerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR)+1;
geometryLayer.setZIndex(zIndex);
map.addLayer(geometryLayer);
}

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import ol.Collection;
import ol.Coordinate;
import ol.control.Attribution;
import ol.control.Control;
import ol.control.FullScreen;
import ol.control.MousePosition;
@ -32,6 +33,10 @@ public final class MapUtils {
MousePosition mousePosition = new MousePosition();
mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
controls.push(mousePosition);
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
controls.push(attribution);
//controls.push(new ZoomToExtent());
}

View File

@ -8,6 +8,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon
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.DoActionOnDetailLayersEvent.SwapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.google.gwt.core.client.GWT;
@ -35,7 +36,6 @@ import ol.OverlayOptions;
import ol.Size;
import ol.View;
import ol.ViewOptions;
import ol.control.Attribution;
import ol.event.EventListener;
import ol.geom.Geometry;
import ol.interaction.Draw;
@ -47,6 +47,7 @@ import ol.interaction.KeyboardPan;
import ol.interaction.KeyboardZoom;
import ol.layer.Base;
import ol.layer.Image;
import ol.layer.Layer;
import ol.layer.LayerOptions;
import ol.layer.Tile;
import ol.layer.VectorLayerOptions;
@ -58,16 +59,17 @@ import ol.source.ImageWmsParams;
import ol.source.Osm;
import ol.source.Source;
import ol.source.Vector;
import ol.source.Xyz;
import ol.source.XyzOptions;
/**
* The Class OpenLayerOSM.
* The Class OpenLayerMap.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Oct 27, 2020
*/
public abstract class OpenLayerOSM {
public abstract class OpenLayerMap {
public static final int MAX_ZOOM = 21;
@ -134,38 +136,24 @@ public abstract class OpenLayerOSM {
private LinkedHashMap<String, Image> wmsDetailsLayerMap;
private Integer[] wmsDetailsLayerZIndex = new Integer[100];
private LinkedHashMap<String, Image> wmsLayerMap;
private Layer baseLayerTile;
private LayerOrder layerOrder = new LayerOrder();
/**
* Instantiates a new open layer OSM.
*
* @param divTargetId the div target id
* @param eventBus the event bus
* @param eventBus the event bus
* @param baseLayer the base layer
*/
/*
* (non-Javadoc)
*
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
public OpenLayerOSM(String divTargetId, HandlerManager eventBus) {
public OpenLayerMap(String divTargetId, HandlerManager eventBus, BaseMapLayer baseLayer) {
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");
// osmSourceOptions.setTileLoadFunction(null);
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());
projectionOptions.setUnits("m");
@ -184,25 +172,82 @@ public abstract class OpenLayerOSM {
map = new Map(mapOptions);
map.addLayer(osmLayer);
//map.addLayer(baseLayerTile);
// map.addLayer(tileDebugLayer);
// add some controls
map.addControl(OLFactory.createScaleLine());
MapUtils.addDefaultControls(map.getControls());
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
map.addControl(attribution);
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
//applying base map
changeBaseMap(baseLayer);
bindEvents();
}
/**
* Change base map.
*
* @param baseLayer the base layer
*/
public void changeBaseMap(BaseMapLayer baseLayer) {
BaseMapLayer.OL_BASE_MAP baseMap = baseLayer.getType() == null ? BaseMapLayer.OL_BASE_MAP.OSM
: baseLayer.getType();
try {
if (baseLayerTile != null)
map.removeLayer(baseLayerTile);
} catch (Exception e) {
// TODO: handle exception
}
switch (baseMap) {
case OSM:
XyzOptions xyzOptions = OLFactory.createOptions();
Osm osmSource = new Osm(xyzOptions);
osmSource.setUrl(baseLayer.getUrl());
//setAttributions is buggy
//osmSource.setAttributions(baseLayer.getAttribution());
LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(osmSource);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1;
layerOptions.setZIndex(zIndex);
baseLayerTile = new Tile(layerOptions);
break;
case MAPBOX:
case OTHER:
XyzOptions xyzOptions2 = OLFactory.createOptions();
Xyz xyz = new Xyz(xyzOptions2);
//setAttributions is buggy
//xyz.setAttributions(baseLayer.getAttribution());
xyz.setUrl(baseLayer.getUrl());
LayerOptions layerOptions2 = OLFactory.createOptions();
layerOptions2.setSource(xyz);
zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1;
layerOptions2.setZIndex(zIndex);
baseLayerTile = new Tile(layerOptions2);
break;
}
// map == null at init time
if (map != null) {
map.addLayer(baseLayerTile);
}
}
/**
* Bind events.
*/
@ -357,10 +402,9 @@ public abstract class OpenLayerOSM {
// imageWMSOptions.setRatio(1.5f);
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(imageWMSSource);
// Settings MIN and MAX Resolution
if (layerItem.getMinResolution() != null) {
layerOptions.setMinResolution(layerItem.getMinResolution());
@ -370,7 +414,8 @@ public abstract class OpenLayerOSM {
}
Image wmsLayer = new Image(layerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_WMS)+wmsLayerMap.size()+1;
wmsLayer.setZIndex(zIndex);
// visibleLayerItems
map.addLayer(wmsLayer);
@ -409,9 +454,9 @@ public abstract class OpenLayerOSM {
// imageWMSOptions.setRatio(1.5f);
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(imageWMSSource);
// Settings MIN and MAX Resolution
if (layerItem.getMinResolution() != null) {
layerOptions.setMinResolution(layerItem.getMinResolution());
@ -421,7 +466,8 @@ public abstract class OpenLayerOSM {
}
Image wmsLayer = new Image(layerOptions);
wmsLayer.setZIndex(wmsDetailsLayerMap.size() + 1);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL)+wmsDetailsLayerMap.size() + 1;
wmsLayer.setZIndex(zIndex);
map.addLayer(wmsLayer);
wmsDetailsLayerMap.put(key, wmsLayer);
@ -478,9 +524,12 @@ public abstract class OpenLayerOSM {
Vector vectorSource = OLFactory.createVectorSource();
vectorSource.addFeature(feature);
vectorLayerOptions.setSource(vectorSource);
ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR)+1;
vector.setZIndex(zIndex);
map.addLayer(vector);
}
@ -820,8 +869,8 @@ public abstract class OpenLayerOSM {
/**
* Swap details layers.
*
* @param layerSource the source index
* @param layerTarget the target index
* @param swapLSource the swap L source
* @param swapLTarget the swap L target
*/
public void swapDetailsLayers(SwapLayer swapLSource, SwapLayer swapLTarget) {
@ -830,15 +879,17 @@ public abstract class OpenLayerOSM {
Image layer1 = wmsDetailsLayerMap.get(layerSource);
Image layer2 = wmsDetailsLayerMap.get(layerTarget);
int zIndexS = swapLSource.getPosition()+1;
int zIndexT = swapLTarget.getPosition()+1;
GWT.log("new zindex source: "+zIndexS+", new zTarget: "+zIndexT);
int zIndexOffset = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL);
int zIndexS = swapLSource.getPosition() + zIndexOffset + 1;
int zIndexT = swapLTarget.getPosition() + zIndexOffset + 1;
GWT.log("new zindex source: " + zIndexS + ", new zTarget: " + zIndexT);
layer1.setZIndex(zIndexT);
layer2.setZIndex(zIndexS);
GWT.log("layer1 source: "+layerSource+", new zIndex: "+layer1.getZIndex());
GWT.log("layer1 target: "+layerTarget+", new zIndex: "+layer2.getZIndex());
GWT.log("layer1 source: " + layerSource + ", new zIndex: " + layer1.getZIndex());
GWT.log("layer1 target: " + layerTarget + ", new zIndex: " + layer2.getZIndex());
}
/**

View File

@ -0,0 +1,37 @@
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
import com.github.gwtbootstrap.client.ui.constants.BaseIconType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
public interface GNAIcons extends ClientBundle {
/** My custom base icon collection */
public enum CustomIconType implements BaseIconType {
MAP("map"),
PRESET_LOCATION("preset_location"),
LAYERS("layers");
/** Inject the icon's css once at first usage */
static {
GNAImages icons = GWT.create(GNAImages.class);
icons.css().ensureInjected();
}
private static final String PREFIX = "myBaseIcon_";
private String className;
private CustomIconType(String className) {
this.className = className;
}
/**
* {@inheritDoc}
*/
@Override
public String get() {
return PREFIX + className;
}
}
}

View File

@ -0,0 +1,41 @@
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.CssResource;
import com.google.gwt.resources.client.ImageResource;
public interface GNAImages extends ClientBundle {
/** Get access to the css resource during gwt compilation */
@Source("baseIcons.css")
CssResource css();
public static final GNAImages ICONS = GWT.create(GNAImages.class);
/** Our sample image icon. Makes the image resource for the gwt-compiler's css composer accessible */
@Source("map.png")
ImageResource map();
@Source("preset_location.png")
ImageResource preset_location();
@Source("layers.png")
ImageResource layers();
@Source("loading.gif")
ImageResource loading();
@Source("map-marker-icon.png")
ImageResource mapMarkerIcon();
@Source("icon_share.png")
ImageResource shareIcon();
@Source("italy.png")
ImageResource italyIcon();
@Source("world.png")
ImageResource worldIcon();
}

View File

@ -1,25 +0,0 @@
package org.gcube.portlets.user.geoportaldataviewer.client.resources;
import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public interface Images extends ClientBundle {
public static final Images ICONS = GWT.create(Images.class);
@Source("loading.gif")
ImageResource loading();
@Source("map-marker-icon.png")
ImageResource mapMarkerIcon();
@Source("icon_share.png")
ImageResource shareIcon();
@Source("italy.png")
ImageResource italyIcon();
@Source("world.png")
ImageResource worldIcon();
}

View File

@ -0,0 +1,25 @@
/* Prevent our icons from css obfuscation */
@external .myBaseIcon_*; /* Do some css stuff */
@sprite .myBaseIcon_map {
gwt-image: "map";
display: inline-block;
vertical-align: middle;
width: 17px !important;
height: 17px !important;
}
@sprite .myBaseIcon_preset_location {
gwt-image: "preset_location";
display: inline-block;
vertical-align: middle;
width: 17px !important;
height: 17px !important;
}
@sprite .myBaseIcon_layers {
gwt-image: "layers";
display: inline-block;
vertical-align: middle;
width: 17px !important;
height: 17px !important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,22 +1,31 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
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.events.ChangeMapLayerEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.DropdownButton;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.constants.IconType;
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.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.uibinder.client.UiBinder;
@ -25,7 +34,10 @@ 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.Label;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
/**
@ -69,22 +81,35 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
Button extentToItaly;
@UiField
Button extentToEarth;
@UiField
Button layersDDB;
Button linkLayers;
@UiField
ScrollPanel overlayLayersPanel;
@UiField
HTMLPanel panelAttribution;
@UiField
HTMLPanel panelBaseLayers;
@UiField
DropdownButton linkMap;
@UiField
DropdownButton linkPresetLocation;
private MapPanel mapPanel;
private OpenLayerOSM map;
private OpenLayerMap map;
private HandlerManager applicationBus;
/**
* Instantiates a new geona data view main panel.
*
@ -102,39 +127,43 @@ public class GeonaDataViewMainPanel extends Composite {
dataPointSelection.setIcon(IconType.SCREENSHOT);
dataBoxSelection.setIcon(IconType.BOOKMARK);
removeQuery.setIcon(IconType.REMOVE);
Image italyImg = new Image(Images.ICONS.italyIcon());
Image italyImg = new Image(GNAImages.ICONS.italyIcon());
italyImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
extentToItaly.getElement().appendChild(italyImg.getElement());
extentToItaly.setWidth("140px");
Image worldImg = new Image(Images.ICONS.worldIcon());
Image worldImg = new Image(GNAImages.ICONS.worldIcon());
worldImg.getElement().getStyle().setPaddingLeft(20, Unit.PX);
extentToEarth.getElement().appendChild(worldImg.getElement());
extentToEarth.setWidth("140px");
//layersDDB.setToggle(true);
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get());
linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get());
// layersDDB.setToggle(true);
bindEvents();
}
private void bindEvents() {
layersDDB.addClickHandler(new ClickHandler() {
linkLayers.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GWT.log("layersDDB clicked");
if(overlayLayersPanel.isVisible()) {
if (overlayLayersPanel.isVisible()) {
overlayLayersPanel.setVisible(false);
}else {
} else {
overlayLayersPanel.setVisible(true);
}
}
});
}
/**
@ -146,15 +175,15 @@ public class GeonaDataViewMainPanel extends Composite {
String toH = height + "px";
mapPanel.setMapHeight(height);
detailsPanel.setHeight(toH);
setOverlayPanelMaxHeight();
}
private void setOverlayPanelMaxHeight() {
String overlMH = mapPanel.getOffsetHeight()-130+"px";
GWT.log("overlayLayersPanel maxHeight: "+overlMH);
String overlMH = mapPanel.getOffsetHeight() - 130 + "px";
GWT.log("overlayLayersPanel maxHeight: " + overlMH);
overlayLayersPanel.getElement().getStyle().setProperty("maxHeight", overlMH);
}
@ -172,7 +201,7 @@ public class GeonaDataViewMainPanel extends Composite {
*
* @param map the new map
*/
public void setMap(OpenLayerOSM map) {
public void setMap(OpenLayerMap map) {
this.map = map;
}
@ -227,7 +256,7 @@ public class GeonaDataViewMainPanel extends Composite {
}
});
extentToEarth.addClickHandler(new ClickHandler() {
@Override
@ -276,7 +305,7 @@ public class GeonaDataViewMainPanel extends Composite {
* @return the layers DDB
*/
public Button getLayersDDB() {
return layersDDB;
return linkLayers;
}
/**
@ -286,37 +315,80 @@ public class GeonaDataViewMainPanel extends Composite {
*/
public void showOverlayLayers(FlowPanel panel) {
GWT.log("showOverlayLayers");
//layersDDB.setVisible(true);
// layersDDB.setVisible(true);
overlayLayersPanel.setVisible(true);
overlayLayersPanel.clear();
setOverlayPanelMaxHeight();
overlayLayersPanel.add(panel);
//layersDDBClickEvent();
// layersDDBClickEvent();
}
private void layersDDBClickEvent() {
layersDDB.fireEvent( new GwtEvent<ClickHandler>() {
@Override
public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType() {
return ClickEvent.getType();
}
@Override
protected void dispatch(ClickHandler handler) {
handler.onClick(null);
}
});
linkLayers.fireEvent(new GwtEvent<ClickHandler>() {
@Override
public com.google.gwt.event.shared.GwtEvent.Type<ClickHandler> getAssociatedType() {
return ClickEvent.getType();
}
@Override
protected void dispatch(ClickHandler handler) {
handler.onClick(null);
}
});
}
/**
* Hide overlay layers.
*/
public void hideOverlayLayers() {
GWT.log("hideOverlayLayers");
overlayLayersPanel.clear();
//layersDDB.setVisible(false);
// layersDDB.setVisible(false);
overlayLayersPanel.setVisible(false);
//layersDDBClickEvent();
// layersDDBClickEvent();
}
public void setMapAttribution(String attribution) {
panelAttribution.clear();
Label label = new Label("Base Map Credits");
Paragraph p = new Paragraph(attribution);
panelAttribution.add(label);
panelAttribution.add(p);
}
public void setBaseLayers(List<BaseMapLayer> listBaseLayers) {
if(listBaseLayers==null)
return;
int i = 0;
for (BaseMapLayer baseMapLayer : listBaseLayers) {
RadioButton radio = new RadioButton("base-layer");
radio.setText(baseMapLayer.getName());
if(i==0) {
radio.setValue(true, false);
}
radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
applicationBus.fireEvent(new ChangeMapLayerEvent(baseMapLayer));
}
});
SimplePanel sp = new SimplePanel(radio);
sp.getElement().addClassName("form-inline");
sp.getElement().addClassName("map-layers-radio");
panelBaseLayers.add(sp);
i++;
}
}
}

View File

@ -17,7 +17,7 @@
<g:HTMLPanel ui:field="mainToolBar"
addStyleNames="inner-toolbar">
<b:DropdownButton type="LINK" text=" " icon="INFO">
<g:HTMLPanel ui:field="panelMI"
<g:HTMLPanel ui:field="panelInfo"
addStyleNames="info-interaction">
<g:Label>Map Interactions</g:Label>
<b:Paragraph>
@ -30,10 +30,17 @@
<b:Icon type="HAND_UP" />
Click on the Points shown on the Map to view their features
</b:Paragraph>
<g:HTMLPanel ui:field="panelAttribution"
addStyleNames="info-interaction" visible="false">
</g:HTMLPanel>
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK" title="Select the Map" text="Map" ui:field="linkMap">
<g:HTMLPanel ui:field="panelBaseLayers">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK"
text="Preset Location" icon="TH_LARGE">
title="Center Map to Location" text="Preset Location" ui:field="linkPresetLocation">
<b:Nav>
<b:Button type="LINK" ui:field="extentToItaly"
text="Italy" title="Center to Italy"></b:Button>
@ -55,7 +62,7 @@
</b:DropdownButton>
<b:Button type="LINK" ui:field="removeQuery"
text="Remove Query" visible="false"></b:Button>
<b:Button type="LINK" text="Layers" ui:field="layersDDB">
<b:Button type="LINK" text="Layers" ui:field="linkLayers">
</b:Button>
<g:ScrollPanel ui:field="overlayLayersPanel"
addStyleNames="layers-panel" visible="false"></g:ScrollPanel>

View File

@ -1,23 +1,34 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.map;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewer;
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.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAIcons;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import com.github.gwtbootstrap.client.ui.DropdownButton;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Random;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
@ -45,12 +56,20 @@ public class MapView extends Composite {
}
@UiField
HTMLPanel theMap;
HTMLPanel panelBaseLayers;
@UiField
HTMLPanel theMapPanel;
@UiField
DropdownButton linkMap;
@UiField
HorizontalPanel coordinatePanel;
private LightOpenLayerOSM lightOLSM;
private LightOpenLayerMap lightOLSM;
private HTML attributionDiv = null;
private String theMapId = null;
@ -63,15 +82,18 @@ public class MapView extends Composite {
public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) {
initWidget(uiBinder.createAndBindUi(this));
theMapId = "map" + Random.nextInt();
theMap.getElement().setId(theMapId);
theMap.setWidth(internalMapWidth);
theMap.setHeight(internalMapHeight);
theMapPanel.getElement().setId(theMapId);
theMapPanel.setWidth(internalMapWidth);
theMapPanel.setHeight(internalMapHeight);
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
lightOLSM = new LightOpenLayerOSM(theMapId);
lightOLSM = new LightOpenLayerMap(theMapId);
setBaseLayers();
// EPSG_3857 LOCATION TO ITALY
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
@ -81,14 +103,68 @@ public class MapView extends Composite {
}
});
}
protected void setBaseLayers() {
List<BaseMapLayer> listBaseLayers = GeoportalDataViewer.getListBaseMapLayers();
if(listBaseLayers==null)
return;
int i = 0;
String radioId = "base_layer_" + Random.nextInt()+Random.nextInt();
for (BaseMapLayer baseMapLayer : listBaseLayers) {
RadioButton radio = new RadioButton(radioId);
radio.setText(baseMapLayer.getName());
if(i==0) {
radio.setValue(true, false);
setMapAttribution(baseMapLayer);
}
radio.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
lightOLSM.changeBaseMap(baseMapLayer);
setMapAttribution(baseMapLayer);
}
});
SimplePanel sp = new SimplePanel(radio);
sp.getElement().addClassName("form-inline");
sp.getElement().addClassName("map-layers-radio");
panelBaseLayers.add(sp);
i++;
}
}
private void setMapAttribution(BaseMapLayer baseMapLayer) {
if(attributionDiv!=null)
theMapPanel.remove(attributionDiv);
String attributionHTML = "<div class='map-internal-credits'><div class='map-internal-credits-container'>"
+ baseMapLayer.getAttribution() + "</div></div>";
attributionDiv = new HTML();
// THE OSM Contributors are automatically added by gwt-ol, others ones not.
if (!baseMapLayer.getType().equals(BaseMapLayer.OL_BASE_MAP.OSM)) {
attributionDiv.setHTML(attributionHTML);
theMapPanel.add(attributionDiv);
}
}
private void setMapSize() {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
int width = theMap.getParent().getOffsetWidth();
int height = theMap.getParent().getOffsetHeight();
int width = theMapPanel.getParent().getOffsetWidth();
int height = theMapPanel.getParent().getOffsetHeight();
if (width == 0)
width = 300;
@ -96,7 +172,7 @@ public class MapView extends Composite {
height = 300;
GWT.log("Internal Map w: " + width + ", h: " + height);
theMap.setSize(width + "px", height + "px");
theMapPanel.setSize(width + "px", height + "px");
}
});
}
@ -169,7 +245,7 @@ public class MapView extends Composite {
}
public LightOpenLayerOSM getLightOLSM() {
public LightOpenLayerMap getLightOLSM() {
return lightOLSM;
}

View File

@ -1,23 +1,17 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.internalMap {
height: 280px;
display: inline-block;
margin: 0 auto;
/*float: right;*/
}
.map-style {
width: 100%;
text-align:center;
margin-top: 10px;
margin-bottom: 20px;
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.map-style}">
<g:HTMLPanel ui:field="theMap"
addStyleNames="{style.internalMap}">
<g:HTMLPanel addStyleNames="map-style">
<g:HTMLPanel ui:field="theMapPanel" addStyleNames="internal-map">
<b:DropdownButton type="LINK" title="Select the Map"
addStyleNames="base-internal-layers-maplink" ui:field="linkMap">
<g:HTMLPanel ui:field="panelBaseLayers">
</g:HTMLPanel>
</b:DropdownButton>
</g:HTMLPanel>
<g:HorizontalPanel ui:field="coordinatePanel"
visible="false"></g:HorizontalPanel>

View File

@ -3,7 +3,7 @@
*/
package org.gcube.portlets.user.geoportaldataviewer.client.util;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HorizontalPanel;
@ -18,7 +18,7 @@ import com.google.gwt.user.client.ui.Image;
public class LoaderIcon extends HorizontalPanel{
private Image imgLoading = new Image(Images.ICONS.loading());
private Image imgLoading = new Image(GNAImages.ICONS.loading());
private HTML txtLoading = new HTML("");
/**

View File

@ -0,0 +1,111 @@
package org.gcube.portlets.user.geoportaldataviewer.server;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer.OL_BASE_MAP;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class GNABaseMapsResourceReader.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 18, 2021
*/
public class GNABaseMapsResourceReader {
private static Logger LOG = LoggerFactory.getLogger(GNABaseMapsResourceReader.class);
private static final String SE_PROFILE_NAME = "GNABaseMaps";
private static final String SE_CATEGORY_NAME = "Application";
/**
* Gets the list base maps.
*
* @return the list base maps
* @throws Exception the exception
*/
public static List<BaseMapLayer> getListBaseMaps() throws Exception {
List<BaseMapLayer> lstBaseMaps = new ArrayList<BaseMapLayer>();
LOG.info("Searching SE in the scope: " + ScopeProvider.instance.get() + " with profile name: " + SE_PROFILE_NAME
+ " and category name: " + SE_CATEGORY_NAME);
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq '" + SE_PROFILE_NAME + "'");
query.addCondition("$resource/Profile/Category/text() eq '" + SE_CATEGORY_NAME + "'");
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> resources = client.submit(query);
if (resources.size() > 0)
LOG.info("The query returned " + resources.size() + " ServiceEndpoint/s");
else
throw new RuntimeException("ServiceEndpoint not found. Searching for profile name: " + SE_PROFILE_NAME
+ " and category name: " + SE_CATEGORY_NAME + ", in the scope: " + ScopeProvider.instance.get());
ServiceEndpoint se = resources.get(0);
Collection<AccessPoint> theAccessPoints = se.profile().accessPoints().asCollection();
for (AccessPoint accessPoint : theAccessPoints) {
BaseMapLayer bml = new BaseMapLayer();
bml.setName(accessPoint.name());
bml.setAttribution(accessPoint.description());
String url = accessPoint.address();
String apiTokenName = accessPoint.username();
String apiTokenPwd = accessPoint.password();
LOG.debug("Found API_TOKEN name: " + apiTokenName + ", encrypted token: " + apiTokenPwd);
// decrypting the pwd
try {
if (isValorized(apiTokenPwd)) {
apiTokenPwd = StringEncrypter.getEncrypter().decrypt(apiTokenPwd);
LOG.debug("Token decrypted is: " + apiTokenPwd.substring(0, apiTokenPwd.length() / 2)
+ "_MASKED_TOKEN_");
}
} catch (Exception e) {
throw new RuntimeException("Error on decrypting the pwd: ", e);
}
if (isValorized(apiTokenName) && isValorized(apiTokenPwd)) {
url = String.format("%s?%s=%s", url, apiTokenName, apiTokenPwd);
}
bml.setUrl(url);
// SETTING MAP TYPE
String urlLower = bml.getUrl().toLowerCase();
if (urlLower.contains("mapbox")) {
bml.setType(OL_BASE_MAP.MAPBOX);
} else if (urlLower.contains("openstreetmap")) {
bml.setType(OL_BASE_MAP.OSM);
} else
bml.setType(OL_BASE_MAP.OTHER);
lstBaseMaps.add(bml);
}
LOG.debug("Read base maps: "+lstBaseMaps);
LOG.info("Returning " + lstBaseMaps.size() + " base maps");
return lstBaseMaps;
}
private static boolean isValorized(String value) {
if (value != null && !value.isEmpty()) {
return true;
}
return false;
}
}

View File

@ -34,6 +34,7 @@ import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.Concessio
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.accesspolicy.GeoNACheckAccessPolicy;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
@ -321,8 +322,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (layerPosizionamento != null) {
if (!GeoNACheckAccessPolicy.isAccessible(layerPosizionamento.getPolicy(), userName)) {
concessionDV.setPosizionamentoScavo(null);
} else {
LOG.info("Posizionamento di Scavo is not accessible by current user");
LOG.info("Posizionamento di Scavo is not accessible by current user: "+userName);
}
}
@ -332,6 +332,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
for (LayerConcessioneDV layerDV : listLayersDV) {
if (GeoNACheckAccessPolicy.isAccessible(layerDV.getPolicy(), userName)) {
accessibleListLayersDV.add(layerDV);
}else {
LOG.info("(Pianta) Layer "+layerDV.getLayerName()+" is not accessible by current user: "+userName);
}
}
concessionDV.setPianteFineScavo(accessibleListLayersDV);
@ -341,6 +343,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (abstractRS != null) {
if (!GeoNACheckAccessPolicy.isAccessible(abstractRS.getPolicy(), userName)) {
concessionDV.setAbstractRelazioneScavo(null);
LOG.info("Abstract relazione is not accessible by current user: "+userName);
}
}
@ -348,6 +351,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (relazioneScavo != null) {
if (!GeoNACheckAccessPolicy.isAccessible(relazioneScavo.getPolicy(), userName)) {
concessionDV.setRelazioneScavo(null);
LOG.info("Relazione scavo is not accessible by current user: "+userName);
}
}
@ -360,6 +364,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
if (GeoNACheckAccessPolicy.isAccessible(uploadedImageDV.getPolicy(), userName)) {
accessibleListImages.add(uploadedImageDV);
}else {
LOG.info("Immagine "+uploadedImageDV.getTitolo()+" is not accessible by current user: "+userName);
}
}
@ -660,5 +666,17 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
}
@Override
public List<BaseMapLayer> getListBaseLayers() {
LOG.info("getListBaseLayers called");
List<BaseMapLayer> listBL = new ArrayList<BaseMapLayer>();
//Setting scope in the cuurent thread
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
listBL = SessionUtil.getGNABaseMaps(this.getThreadLocalRequest());
LOG.info("getListBaseLayers returning "+listBL.size() +" base maps");
return listBL;
}
}

View File

@ -17,7 +17,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class IAMClientCredentialsReader.
* The Class GNABaseMapsResourceReader.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*

View File

@ -3,12 +3,16 @@
*/
package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.urlshortener.UrlShortener;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
@ -34,6 +38,7 @@ public class SessionUtil {
private static Logger LOG = LoggerFactory.getLogger(SessionUtil.class);
private static final String URL_SHORTENER_SERVICE = "URL_SHORTENER_SERVICE";
private static final String LIST_BASE_MAPS_LAYERS = "LIST_BASE_MAPS_LAYERS";
/**
* Checks if is into portal.
@ -168,4 +173,28 @@ public class SessionUtil {
return shortener;
}
/**
* Gets the GNA base maps.
*
* @param httpServletRequest the http servlet request
* @return the GNA base maps
*/
public static List<BaseMapLayer> getGNABaseMaps(HttpServletRequest httpServletRequest) {
HttpSession session = httpServletRequest.getSession();
List<BaseMapLayer> lstBML = null;
try {
lstBML = (List<BaseMapLayer>) session.getAttribute(LIST_BASE_MAPS_LAYERS);
if (lstBML == null) {
GNABaseMapsResourceReader gnaBMRR = new GNABaseMapsResourceReader();
lstBML = gnaBMRR.getListBaseMaps();
session.setAttribute(LIST_BASE_MAPS_LAYERS, lstBML);
}
} catch (Exception e) {
LOG.warn("Error occurred reading the base maps by " + GNABaseMapsResourceReader.class.getSimpleName(), e);
}
return lstBML;
}
}

View File

@ -24,7 +24,7 @@ public class GeoNaSpatialQueryResult implements Serializable {
private static final long serialVersionUID = 3513120677727206958L;
private List<FeatureRow> features;
private LayerObject sourceLayerObject;
// Map with couple (mongoId concessione, list of uploaded Images for the concessione)
// Map with couple (mongoId concessione, list of uploaded GNAImages for the concessione)
private Map<String, List<UploadedImageDV>> mapImages = null;
/**

View File

@ -0,0 +1,97 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
/**
* The Class BaseMapLayer.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 11, 2021
*/
public class BaseMapLayer implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6204769725053516674L;
/**
* The Enum OL_BASE_MAP.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 11, 2021
*/
public static enum OL_BASE_MAP {
OSM, MAPBOX, OTHER
};
private String name;
private String url;
private String attribution;
private OL_BASE_MAP type;
/**
* Instantiates a new base map layer.
*/
public BaseMapLayer() {
}
public BaseMapLayer(String name, String url, String attribution, OL_BASE_MAP type) {
super();
this.name = name;
this.url = url;
this.attribution = attribution;
this.type = type;
}
public String getName() {
return name;
}
public String getUrl() {
return url;
}
public String getAttribution() {
return attribution;
}
public OL_BASE_MAP getType() {
return type;
}
public void setName(String name) {
this.name = name;
}
public void setUrl(String url) {
this.url = url;
}
public void setAttribution(String attribution) {
this.attribution = attribution;
}
public void setType(OL_BASE_MAP type) {
this.type = type;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("BaseMapLayer [name=");
builder.append(name);
builder.append(", url=");
builder.append(url);
builder.append(", attribution=");
builder.append(attribution);
builder.append(", type=");
builder.append(type);
builder.append("]");
return builder.toString();
}
}

View File

@ -342,7 +342,7 @@ body {
.layers-panel {
margin-top: 10px;
background-color: white;
opacity: 80%;
opacity: 90%;
padding: 10px;
width: 410px;
}
@ -357,4 +357,97 @@ body {
.range-slider input {
width: 280px;
}
}
.map-credits {
width: 100%;
max-height: 25px;
}
.map-credits-container {
bottom: 0;
right: 0;
position: absolute;
display: block;
margin: 0px 0px;
padding: 2px 4px;
background: white;
border-radius: 4px 0 0;
}
.map-internal-credits {
width: 100%;
max-height: 25px;
position: relative;
}
.map-internal-credits-container {
bottom: 0;
right: 0;
position: absolute;
display: block;
padding: 2px 4px;
background: white;
border-radius: 4px 0 0;
}
.map-layers-radio {
margin-left: 5px;
}
.map-layers-radio input {
margin-top: 0 !important;
margin-left: 5px;
}
.map-layers-radio label {
margin-left: 5px;
padding-top: 5px;
}
/************ INTERNAL MAP***************/
.internal-map {
height: 280px;
display: inline-block;
margin: 0 auto;
/*float: right;*/
}
.map-style {
width: 100%;
margin-top: 10px;
margin-bottom: 20px;
text-align: center;
}
.base-internal-layers-maplink {
width: 100%;
text-align: left;
left: 45px;
top: 40px;
z-index: 10;
}
.base-internal-layers-maplink .btn-link {
/*border: 1px solid #eee;*/
border: 2px solid rgba(255,255,255,.4);
/*background-color: #fcfcfc;*/
margin: 1px;
}
.base-internal-layers-maplink .btn-link:hover, .inner-toolbar .btn-link:focus {
background-color: #f3f3f3 !important;
text-decoration: none;
}
.loader-gna-app {
z-index: 50;
position: absolute;
top: 50%;
left: 50%;
}

View File

@ -31,7 +31,7 @@
<!-- -->
<!-- Any title is fine -->
<!-- -->
<title>Web Application Starter Project</title>
<title>GNA Data Viewer Application</title>
<!-- -->
<!-- This script loads your compiled module. -->

View File

@ -0,0 +1,29 @@
package org.gcube.portlets.user.geoportaldataviewer;
import java.util.List;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.geoportaldataviewer.server.GNABaseMapsResourceReader;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.junit.Test;
public class GNABaseMaps {
private static final String SCOPE = "/gcube/devsec/devVRE";
@Test
public void readBaseMaps() {
System.out.println("called readBaseMaps test");
ScopeProvider.instance.set(SCOPE);
GNABaseMapsResourceReader gnaBaseMapsR = new GNABaseMapsResourceReader();
List<BaseMapLayer> lstBML = null;
try {
lstBML = gnaBaseMapsR.getListBaseMaps();
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Read base map layers: " + lstBML);
}
}