Merge pull request 'task_25066' (!15) from task_25066 into master

Reviewed-on: #15
This commit is contained in:
Francesco Mangiacrapa 2023-06-09 10:37:45 +02:00
commit bb33754558
44 changed files with 2650 additions and 1413 deletions

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/geoportal-data-viewer-app-3.5.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-3.4.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/geoportal-data-viewer-app-3.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -35,5 +35,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.4.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/geoportal-data-viewer-app-3.5.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-3.4.0-SNAPSHOT
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-3.5.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -78,8 +78,18 @@
<wb-module deploy-name="geoportal-data-viewer-app-3.4.0-SNAPSHOT">
<wb-module deploy-name="geoportal-data-viewer-app-3.5.0-SNAPSHOT">
@ -159,7 +169,12 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -239,7 +254,12 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -319,7 +339,12 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -399,7 +424,12 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
@ -479,7 +509,15 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="geoportal-data-mapper-1.0.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-mapper/geoportal-data-mapper">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -559,7 +597,12 @@
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
@ -639,7 +682,12 @@
<property name="context-root" value="geoportal-data-viewer-app"/>
@ -719,7 +767,12 @@
</wb-module>

View File

@ -4,6 +4,11 @@
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).
## [v3.5.0-SNAPSHOT]
- Supported the cross-filtering [#25074]
- Supported the grouped custom layers [#25110]
## [v3.4.0] - 2023-05-11
- Integrated the geoportal-data-mapper component [#24978]

View File

@ -14,13 +14,13 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>geoportal-data-viewer-app</artifactId>
<packaging>war</packaging>
<version>3.4.0</version>
<version>3.5.0-SNAPSHOT</version>
<name>GeoPortal Data Viewer App</name>
<description>The GeoPortal Data Viewer App is an application to access, discovery and navigate the Geoportal projects/documents by a Web-Map Interface</description>
<properties>
<!-- Convenience property to set the GWT version -->
<gwt.version>2.9.0</gwt.version>
<gwt.version>2.10.0</gwt.version>
<gwt.compiler.style>PRETTY</gwt.compiler.style>
<gson.version>2.6.2</gson.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>

View File

@ -5,13 +5,18 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
@ -20,6 +25,8 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.AddLayerToMapEv
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.ApplyCQLToLayerOnMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ApplyCQLToLayerOnMapEventHandler;
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;
@ -28,8 +35,12 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetai
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.DO_LAYER_ACTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEvent.SwapLayer;
import org.gcube.portlets.user.geoportaldataviewer.client.events.DoActionOnDetailLayersEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.FitMapToExtentEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.FitMapToExtentEventHandler;
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.OverlayCustomLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.OverlayCustomLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEventHandler;
@ -50,9 +61,11 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.collections.Ope
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.OpenLayerMap;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap.CQL_FACILITY_ORIGIN;
import org.gcube.portlets.user.geoportaldataviewer.client.resources.GNAImages;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.cms.project.relation.TimelineManagerStatus;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.OLGeoJSONUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.ControlledCallBack;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
@ -85,12 +98,6 @@ import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
import ol.Feature;
import ol.OLFactory;
import ol.format.GeoJson;
import ol.format.GeoJsonFeatureOptions;
import ol.format.GeoJsonOptions;
import ol.proj.Projection;
import ol.proj.ProjectionOptions;
/**
* Entry point classes define <code>onModuleLoad()</code>.
@ -154,6 +161,8 @@ public class GeoportalDataViewer implements EntryPoint {
// A cache (Layer_ID, GeoJSON) of layer features loaded via GetFeature Request
private HashMap<String, String> layerFeaturesCache = new HashMap<String, String>();
private ViewerConfiguration viewerConfiguration;
/**
* This is the entry point method.
*/
@ -228,6 +237,7 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void onSuccess(ViewerConfiguration result) {
super.onSuccess(result);
viewerConfiguration = result;
GWT.log("Received init config : " + result);
GWT.log("Loading base layers, count : " + result.getBaseLayers().size());
@ -282,6 +292,8 @@ public class GeoportalDataViewer implements EntryPoint {
mainPanel.openCollectionMenu();
loadConfigureduGroupedLayersForUCD();
GWT.log("DONE INIT LOAD");
}
@ -302,6 +314,77 @@ public class GeoportalDataViewer implements EntryPoint {
RootPanel.get(APP_DIV).add(attributionDiv);
}
/**
* Load Overlay Layers and Cross-Filtering layers for UCD
*
* Load configuredu grouped layers for UCD.
*/
public void loadConfigureduGroupedLayersForUCD() {
GeoportalDataViewerServiceAsync.Util.getInstance().getAvaiableCustomGroupedLayersForUCD(
GEOPORTAL_DATA_HANDLER.geoportal_grouped_overlay_layers,
new AsyncCallback<Map<String, List<GroupedLayersDV<? extends LayerIDV>>>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("loadConfigureduGroupedLayersForUCD error for "
+ GEOPORTAL_DATA_HANDLER.geoportal_grouped_overlay_layers + ": " + caught.getMessage());
}
@Override
public void onSuccess(Map<String, List<GroupedLayersDV<? extends LayerIDV>>> result) {
GWT.log(GEOPORTAL_DATA_HANDLER.geoportal_grouped_overlay_layers + " returned: " + result);
if (result != null && result.size() > 0) {
Map<String, GCubeCollection> collections = viewerConfiguration.getAvailableCollections();
for (String profileId : result.keySet()) {
List<GroupedLayersDV<? extends LayerIDV>> list = result.get(profileId);
if (list != null && list.size() > 0) {
GCubeCollection collection = collections.get(profileId);
mainPanel.addOverlayLayers(collection, list);
}
}
}
}
});
GeoportalDataViewerServiceAsync.Util.getInstance().getAvaiableCustomGroupedLayersForUCD(
GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering,
new AsyncCallback<Map<String, List<GroupedLayersDV<? extends LayerIDV>>>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("loadConfigureduGroupedLayersForUCD error for "
+ GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering + ": "
+ caught.getMessage());
}
@Override
public void onSuccess(Map<String, List<GroupedLayersDV<? extends LayerIDV>>> result) {
GWT.log(GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering + " returned: " + result);
if (result != null && result.size() > 0) {
Map<String, GCubeCollection> collections = viewerConfiguration.getAvailableCollections();
for (String profileId : result.keySet()) {
List<GroupedLayersDV<? extends LayerIDV>> list = result.get(profileId);
if (list != null && list.size() > 0) {
GCubeCollection collection = collections.get(profileId);
mainPanel.addCrossFilteringLayers(collection, list);
}
}
}
}
});
}
/**
* Gets the status.
*
@ -672,6 +755,24 @@ public class GeoportalDataViewer implements EntryPoint {
}
});
applicationBus.addHandler(OverlayCustomLayerToMapEvent.TYPE, new OverlayCustomLayerToMapEventHandler() {
@Override
public void onCustomOverlayLayerAction(OverlayCustomLayerToMapEvent customOverLayerToMapEvent) {
if (customOverLayerToMapEvent.getLayerItem() == null)
return;
if (customOverLayerToMapEvent.getActionType()
.equals(OverlayCustomLayerToMapEvent.ACTION_TYPE.VISIBILITY)) {
OpenLayerMap olMap = olMapMng.getOLMap();
olMap.setWMSGroupedCustomLayerVisible(customOverLayerToMapEvent.getLayerItem(),
customOverLayerToMapEvent.isEnabled());
}
}
});
applicationBus.addHandler(ChangeMapLayerEvent.TYPE, new ChangeMapLayerEventHandler() {
@Override
@ -703,8 +804,8 @@ public class GeoportalDataViewer implements EntryPoint {
// Showing popup after clicking on map
if (showPopupOnCentroiEvent.getProfileID() != null && showPopupOnCentroiEvent.getProjectID() != null) {
Coordinate transfCoord = MapUtils
.geoJSONTToBBoxCenter(showPopupOnCentroiEvent.getSpatialReference(), null, null);
Coordinate transfCoord = MapUtils.geoJSONToBBOXCenter(showPopupOnCentroiEvent.getSpatialReference(),
null, null);
performWFSQueryOnCentroid(showPopupOnCentroiEvent.getProjectID(), transfCoord.getX(),
transfCoord.getY());
@ -725,7 +826,7 @@ public class GeoportalDataViewer implements EntryPoint {
if (searchPerformedEvent != null) {
LinkedHashMap<String, ol.layer.Image> wmsMap = olMapMng.getOLMap().getWmsLayerMap();
String firstWMSKey = wmsMap.keySet().iterator().next();
// String firstWMSKey = wmsMap.keySet().iterator().next();
List<String> result = searchPerformedEvent.getListProjectIDs();
ViewerConfiguration viewerConfig = GeoportalDataViewer.getStatus().getViewerConfig();
@ -750,30 +851,97 @@ public class GeoportalDataViewer implements EntryPoint {
// TODO: handle exception
}
String setCqlFilter = null; // default
String newCqlFilter = null; // default
if (result != null && result.size() > 0) {
if (layerName == null) {
GWT.log("CQL FILTER skipped, layerName is NULL!!");
return;
}
// Applying CQL filter only if there are results and its number are less or
// equal to SEARCH_LIMIT_RESULTS_TO_MAXIMUM
if (result != null && result.size() > 0
&& result.size() <= GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM) {
String cqlFilter = GeoportalDataViewerConstants.PROJECT_ID_KEY_FEATURE + " IN(";
for (String projectId : result) {
cqlFilter += "'" + projectId + "',";
}
cqlFilter = cqlFilter.substring(0, cqlFilter.length() - 1) + ")";
setCqlFilter = cqlFilter;
olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, cqlFilter);
newCqlFilter = olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.SEARCH, layerName,
cqlFilter);
} else {
olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null);
setCqlFilter = null; // is already null
newCqlFilter = olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.SEARCH, layerName,
null);
}
if (searchPerformedEvent.isSearchReset()) {
olMapMng.getOLMap().setCQLFilterToWMSLayer(firstWMSKey, null);
setCqlFilter = null; // is already null
newCqlFilter = olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.SEARCH, layerName,
null);
}
if (layerName != null)
layerManager.setCQLForLayerToIndexLayer(layerName, setCqlFilter);
GWT.log("New CQL Filter is: " + newCqlFilter);
// Resetting CQL Filter
if (layerName != null)
layerManager.setCQLForLayerToIndexLayer(layerName, newCqlFilter);
}
}
});
applicationBus.addHandler(ApplyCQLToLayerOnMapEvent.TYPE, new ApplyCQLToLayerOnMapEventHandler() {
@Override
public void onApplyCQL(ApplyCQLToLayerOnMapEvent applyCQLToLayerMapEvent) {
GWT.log("Fired: " + applyCQLToLayerMapEvent);
if (applyCQLToLayerMapEvent != null) {
String layerName = null;
GCubeSDILayer layer = applyCQLToLayerMapEvent.getTheIndeLayer().getLayer();
try {
String wmsLink = layer.getOgcLinks().get("wms");
layerName = URLUtil.extractValueOfParameterFromURL("layers", wmsLink);
} catch (Exception e) {
// TODO: handle exception
}
String setCqlFilter = null;
if (layerName != null) {
GWT.log("ApplyCQLToLayerOnMapEvent: " + layerName + ", filter : "
+ applyCQLToLayerMapEvent.getCqlFilterValue());
if (applyCQLToLayerMapEvent.getCqlFilterValue() == null) {
olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.CROSS_FILTERING, layerName,
null);
setCqlFilter = null; // is already null
} else {
setCqlFilter = applyCQLToLayerMapEvent.getCqlFilterValue();
olMapMng.getOLMap().setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN.CROSS_FILTERING, layerName,
setCqlFilter);
}
layerManager.setCQLForLayerToIndexLayer(layerName, setCqlFilter);
}
}
}
});
applicationBus.addHandler(FitMapToExtentEvent.TYPE, new FitMapToExtentEventHandler() {
@Override
public void onFitToMap(FitMapToExtentEvent fitMapToExtentEvent) {
if (fitMapToExtentEvent.getExtent() != null) {
olMapMng.getOLMap().fitToExtent(fitMapToExtentEvent.getExtent());
}
}
@ -895,34 +1063,10 @@ public class GeoportalDataViewer implements EntryPoint {
*/
private void showLayerFeatures(LayerItem layerItem, String geoJSONFeatures, ProjectDV projectDV) {
GeoJsonFeatureOptions fo = new GeoJsonFeatureOptions();
ProjectionOptions projectionOptions = new ProjectionOptions();
projectionOptions.setCode(MAP_PROJECTION.EPSG_4326.getName());
Projection fp = new Projection(projectionOptions);
fo.setFeatureProjection(fp);
fo.setDataProjection(fp);
GeoJsonOptions geoJsonOpt = new GeoJsonOptions();
geoJsonOpt.setDefaultDataProjection(fp);
geoJsonOpt.setFeatureProjection(fp);
GeoJson geoJson = OLFactory.createGeoJSON(geoJsonOpt);
Feature[] features = geoJson.readFeatures(geoJSONFeatures);
Feature[] features = OLGeoJSONUtil.readGeoJsonFeatures(MAP_PROJECTION.EPSG_4326, geoJSONFeatures);
GWT.log("features: " + features);
olMapMng.getOLMap().addLayerFeaturesAsHighlight(layerItem, features, true);
/* Fit to extent calculating the features extent
if (projectDV != null) {
GeoJSON spatialReference = projectDV.getSpatialReference();
GWT.log("spatialReference is: " + spatialReference);
Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
GWT.log("transfCoord is: " + transfCoord);
if (transfCoord != null)
olMapMng.getOLMap().setCenter(transfCoord);
}
*/
}
}

View File

@ -25,7 +25,9 @@ public class GeoportalDataViewerConstants {
public static final String GET_MAX_ZOOM_LEVEL = OpenLayersMapParameters.OL_MAP_PARAM.maxzoomlevel.name();
public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name();
public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name();
public static final int SEARCH_LIMIT_RESULTS_TO_MAXIMUM = 50;
public static final DateTimeFormat DATE_TIME_FORMAT = DateTimeFormat.getFormat("dd MMMM yyyy");
public static enum MapEventType {
@ -152,7 +154,8 @@ public class GeoportalDataViewerConstants {
var tabCell = tr.insertCell(-1);
var theValue = jsonObj[j][col[i]];
//console.log("the value: "+theValue);
if (theValue !== null && Object.prototype.toString.call(theValue) === '[object Array]') {
if (theValue !== null
&& Object.prototype.toString.call(theValue) === '[object Array]') {
var formattedValueArray = "";
for (var k = 0; k < theValue.length; k++) {
var theValueArray = theValue[k];

View File

@ -2,12 +2,16 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
@ -183,10 +187,10 @@ public interface GeoportalDataViewerService extends RemoteService {
/**
* Gets the WFS request.
*
* @param layerItem the layer item
* @param mapSrsName the map srs name
* @param mapBBOX the map BBOX
* @param maxFeatures the max features. If 0 means all feature
* @param layerItem the layer item
* @param mapSrsName the map srs name
* @param mapBBOX the map BBOX
* @param maxFeatures the max features. If 0 means all feature
* @param outputFormat the output format
* @return the WFS request
*/
@ -206,4 +210,21 @@ public interface GeoportalDataViewerService extends RemoteService {
String getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures,
String outputFormat);
/**
* Gets the avaiable custom grouped layers for UCD.
*
* @param theHandler the the handler
* @return the avaiable custom grouped layers for UCD
*/
Map<String, List<GroupedLayersDV<? extends LayerIDV>>> getAvaiableCustomGroupedLayersForUCD(
GEOPORTAL_DATA_HANDLER theHandler);
/**
* Gets the HTTP response for URL.
*
* @param url the url
* @return the HTTP response for URL
*/
String getHTTPResponseForURL(String url);
}

View File

@ -2,12 +2,16 @@ package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.gcube.application.geoportalcommon.shared.GNADataViewerConfigProfile;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
@ -82,4 +86,9 @@ public interface GeoportalDataViewerServiceAsync {
void getWFSResponse(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String outputFormat,
AsyncCallback<String> callback);
void getAvaiableCustomGroupedLayersForUCD(GEOPORTAL_DATA_HANDLER theHandler,
AsyncCallback<Map<String, List<GroupedLayersDV<? extends LayerIDV>>>> callback);
void getHTTPResponseForURL(String url, AsyncCallback<String> callback);
}

View File

@ -582,9 +582,7 @@ public class LayerManager {
public void setCQLForLayerToIndexLayer(String layerName, String cqlFilter) {
LayerObject theLo = mapIndexLayerObjects.get(layerName);
if (theLo != null) {
boolean isCQLFilter = cqlFilter != null;
theLo.getLayerItem().setCqlFilter(cqlFilter);
theLo.getLayerItem().setCqlFilterAvailable(isCQLFilter);
}
}

View File

@ -0,0 +1,72 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class AddedLayerToMapEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 18, 2020
*/
public class ApplyCQLToLayerOnMapEvent extends GwtEvent<ApplyCQLToLayerOnMapEventHandler> {
public static Type<ApplyCQLToLayerOnMapEventHandler> TYPE = new Type<ApplyCQLToLayerOnMapEventHandler>();
private IndexLayerDV theIndeLayer;
private String cqlFilterValue;
/**
* Instantiates a new apply CQL to layer map event.
*
* @param theIndeLayer the the inde layer
* @param cqlFilter the cql filter
*/
public ApplyCQLToLayerOnMapEvent(IndexLayerDV theIndeLayer, String cqlFilterValue) {
this.theIndeLayer = theIndeLayer;
this.cqlFilterValue = cqlFilterValue;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<ApplyCQLToLayerOnMapEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(ApplyCQLToLayerOnMapEventHandler handler) {
handler.onApplyCQL(this);
}
public IndexLayerDV getTheIndeLayer() {
return theIndeLayer;
}
public String getCqlFilterValue() {
return cqlFilterValue;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("ApplyCQLToLayerOnMapEvent [theIndeLayer=");
builder.append(theIndeLayer);
builder.append(", cqlFilterValue=");
builder.append(cqlFilterValue);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface ApplyCQLToLayerOnMapEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 31, 2023
*/
public interface ApplyCQLToLayerOnMapEventHandler extends EventHandler {
/**
* On apply CQL.
*
* @param applyCQLToLayerMapEvent the apply CQL to layer map event
*/
void onApplyCQL(ApplyCQLToLayerOnMapEvent applyCQLToLayerMapEvent);
}

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.GwtEvent;
import ol.Extent;
/**
* The Class FitMapToExtentEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 6, 2023
*/
public class FitMapToExtentEvent extends GwtEvent<FitMapToExtentEventHandler> {
public static Type<FitMapToExtentEventHandler> TYPE = new Type<FitMapToExtentEventHandler>();
private Extent extent;
/**
* Instantiates a new fit map to extent event.
*
* @param extent the extent
*/
public FitMapToExtentEvent(Extent extent) {
this.extent = extent;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<FitMapToExtentEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(FitMapToExtentEventHandler handler) {
handler.onFitToMap(this);
}
public Extent getExtent() {
return extent;
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface FitMapToExtentEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 6, 2023
*/
public interface FitMapToExtentEventHandler extends EventHandler {
/**
* On fit to map.
*
* @param fitMapToExtentEvent the fit map to extent event
*/
void onFitToMap(FitMapToExtentEvent fitMapToExtentEvent);
}

View File

@ -0,0 +1,92 @@
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 OverlayCustomLayerToMapEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public class OverlayCustomLayerToMapEvent extends GwtEvent<OverlayCustomLayerToMapEventHandler> {
public static Type<OverlayCustomLayerToMapEventHandler> TYPE = new Type<OverlayCustomLayerToMapEventHandler>();
private LayerItem layerItem;
private ACTION_TYPE actionType;
private boolean enabled;
/**
* The Enum ACTION_TYPE.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public enum ACTION_TYPE {
VISIBILITY
}
/**
* Instantiates a new overlay custom layer to map event.
*
* @param layerItem the layer item
* @param actionType the action type
* @param enabled the enabled
*/
public OverlayCustomLayerToMapEvent(LayerItem layerItem, ACTION_TYPE actionType, boolean enabled) {
this.layerItem = layerItem;
this.actionType = actionType;
this.enabled = enabled;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<OverlayCustomLayerToMapEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(OverlayCustomLayerToMapEventHandler handler) {
handler.onCustomOverlayLayerAction(this);
}
/**
* Gets the layer item.
*
* @return the layer item
*/
public LayerItem getLayerItem() {
return layerItem;
}
/**
* Gets the action type.
*
* @return the action type
*/
public ACTION_TYPE getActionType() {
return actionType;
}
/**
* Checks if is enabled.
*
* @return true, if is enabled
*/
public boolean isEnabled() {
return enabled;
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface OverlayCustomLayerToMapEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public interface OverlayCustomLayerToMapEventHandler extends EventHandler {
/**
* On custom overlay layer action.
*
* @param customOverLayerToMapEvent the custom over layer to map event
*/
void onCustomOverlayLayerAction(OverlayCustomLayerToMapEvent customOverLayerToMapEvent);
}

View File

@ -19,17 +19,18 @@ public class LayerOrder {
* Nov 12, 2021
*/
public static enum LAYER_TYPE {
BASE_MAP, BASE_WMS, WMS_DETAIL, VECTOR
BASE_MAP, CUSTOM_WMS_DETAIL, 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);
LAYER_OFFSET.put(LAYER_TYPE.BASE_MAP, 0); //Base OL or MapBox
LAYER_OFFSET.put(LAYER_TYPE.CUSTOM_WMS_DETAIL, 70); //WMS custom Overlay. Es. Layer "Limiti Amministrativi"
LAYER_OFFSET.put(LAYER_TYPE.BASE_WMS, 210); // Index layers (i.e. centroids for UCD)
LAYER_OFFSET.put(LAYER_TYPE.WMS_DETAIL, 140); //Layer/s belonging to a Project (materialized layers. Ex. "Posizionamento Scavo")
LAYER_OFFSET.put(LAYER_TYPE.VECTOR, 320); //Vector layer to show other info. Ex. Pointer with coordinates (x,y) in the Light OL Map.
}
/**

View File

@ -6,6 +6,7 @@ import com.google.gwt.core.client.GWT;
import ol.Collection;
import ol.Coordinate;
import ol.Extent;
import ol.control.Attribution;
import ol.control.Control;
import ol.control.FullScreen;
@ -55,6 +56,18 @@ public final class MapUtils {
return Projection.transform(centerCoordinate, source, target);
}
/**
* Transform extent.
*
* @param extent the extent
* @param source the source
* @param target the target
* @return the extent
*/
public static Extent transformExtent(Extent extent, String source, String target) {
return Projection.transformExtent(extent, source, target);
}
/**
* Distance between centroid.
*
@ -95,14 +108,14 @@ public final class MapUtils {
}
/**
* Geo JSONT to B box center.
* Geo JSON to B box center.
*
* @param spatialReference the spatial reference
* @param transforFrom the transfor from
* @param transformTo the transform to
* @return the coordinate
*/
public static Coordinate geoJSONTToBBoxCenter(GeoJSON spatialReference, String transforFrom, String transformTo) {
public static Coordinate geoJSONToBBOXCenter(GeoJSON spatialReference, String transforFrom, String transformTo) {
try {
if (spatialReference != null) {

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
@ -8,6 +9,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.client.util.WFSMakerUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
@ -35,6 +37,7 @@ import ol.Overlay;
import ol.OverlayOptions;
import ol.Size;
import ol.View;
import ol.ViewFitOptions;
import ol.ViewOptions;
import ol.animation.AnimationOptions;
import ol.color.Color;
@ -78,6 +81,8 @@ import ol.style.Style;
*/
public abstract class OpenLayerMap {
public static final String CQL_FILTER_PARAMETER = WFSMakerUtil.CQL_FILTER_PARAMETER;
private static final int MAX_LENGHT_CQL_FOR_GET_REQUEST = 1600; // 1600 characters
public static final int SET_CENTER_ANIMATED_DURATION = 500;
@ -86,6 +91,19 @@ public abstract class OpenLayerMap {
public static final int MAX_ZOOM = 21;
/**
* The Enum CQL_FACILITY_ORIGIN.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 6, 2023
*/
public static enum CQL_FACILITY_ORIGIN {
SEARCH, CROSS_FILTERING
}
public HashMap<CQL_FACILITY_ORIGIN, String> cqlFilterMap = new HashMap<CQL_FACILITY_ORIGIN, String>();
/**
* Click listener.
*
@ -149,6 +167,8 @@ public abstract class OpenLayerMap {
private LinkedHashMap<String, Image> wmsDetailsLayerMap;
private LinkedHashMap<String, Image> wmsGroupedCustomLayerMap;
private LinkedHashMap<String, Image> wmsLayerMap;
private LinkedHashMap<String, ol.layer.Vector> vectorLayersHighlighted = new LinkedHashMap<String, ol.layer.Vector>();
@ -417,8 +437,6 @@ public abstract class OpenLayerMap {
if (layer == null) {
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerItem.getName());
// imageWMSParams.set("CQL_FILTER", "product_id
// IN('6165b07202ad3d60e1d26f42','6166ff8002ad3d60e1d26fb7')");
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(layerItem.getMapServerHost());
@ -458,33 +476,51 @@ public abstract class OpenLayerMap {
/**
* Sets the CQL filter to WMS layer.
*
* @param key the key
* @param cqlFilterExpression the cql filter expression
* @param origin the origin
* @param layerName the key
* @param newCQLFilterExpression the cql filter expression
* @return the new CQL Filter
*/
public void setCQLFilterToWMSLayer(String key, String cqlFilterExpression) {
GWT.log("Getting key: " + key);
GWT.log("Setting CQL FILTER: " + cqlFilterExpression);
Image wmsLayer = wmsLayerMap.get(key);
public String setCQLFilterToWMSLayer(CQL_FACILITY_ORIGIN origin, String layerName, String newCQLFilterExpression) {
GWT.log("Getting key (layerName): " + layerName);
GWT.log("Adding CQL FILTER: " + newCQLFilterExpression);
Image wmsLayer = wmsLayerMap.get(layerName);
GWT.log("WMS layer is: " + wmsLayer);
// map.removeLayer(wmsLayer);
ImageWms imageWMSSource = wmsLayer.getSource();
ImageWmsParams imageWMSParams = imageWMSSource.getParams();
if (cqlFilterExpression == null || cqlFilterExpression.length() > MAX_LENGHT_CQL_FOR_GET_REQUEST) {
imageWMSParams.delete("CQL_FILTER");
} else {
imageWMSParams.set("CQL_FILTER", cqlFilterExpression);
// Setting new CQL filter for Origin
cqlFilterMap.put(origin, newCQLFilterExpression);
String setCQLFilter = "";
// Building new CQL filter
for (CQL_FACILITY_ORIGIN originKey : cqlFilterMap.keySet()) {
String originCQLFilter = cqlFilterMap.get(originKey);
if (originCQLFilter != null) {
if (setCQLFilter.isEmpty()) {
setCQLFilter = originCQLFilter;
} else {
setCQLFilter += " AND " + originCQLFilter;
}
}
}
if (setCQLFilter.isEmpty())
imageWMSParams.delete(CQL_FILTER_PARAMETER);
else
imageWMSParams.set(CQL_FILTER_PARAMETER, setCQLFilter);
imageWMSSource.updateParams(imageWMSParams);
wmsLayer.setSource(imageWMSSource);
wmsLayer.changed();
GWT.log("returning " + CQL_FILTER_PARAMETER + ": " + setCQLFilter);
return setCQLFilter;
}
/**
@ -537,6 +573,57 @@ public abstract class OpenLayerMap {
}
/**
* Adds the custom WMS detail layer.
*
* @param layerItem the layer item
*/
public void addGroupedCustomWMSLayer(LayerItem layerItem) {
if (wmsGroupedCustomLayerMap == null)
wmsGroupedCustomLayerMap = new LinkedHashMap<String, Image>();
String key = layerItem.getName();
Image layer = wmsGroupedCustomLayerMap.get(key);
if (layer == null) {
GWT.log("The grouped custom layer with key: " + key + " does not exist, creating and adding it to map");
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerItem.getName());
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(layerItem.getMapServerHost());
imageWMSOptions.setParams(imageWMSParams);
// 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());
}
if (layerItem.getMaxResolution() != null) {
layerOptions.setMaxResolution(layerItem.getMaxResolution());
}
Image wmsLayer = new Image(layerOptions);
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.CUSTOM_WMS_DETAIL) + wmsGroupedCustomLayerMap.size()
+ 1;
wmsLayer.setZIndex(zIndex);
map.addLayer(wmsLayer);
wmsGroupedCustomLayerMap.put(key, wmsLayer);
GWT.log("Added GroupedCustomWMSLayer for layer name: " + layerItem.getName());
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem, LAYER_TYPE.OVERLAY));
} else {
GWT.log("The WMS detail layer with key: " + key + " already exists, skipping");
}
}
/**
* Removes the all detail layers.
*
@ -633,8 +720,8 @@ public abstract class OpenLayerMap {
/**
* Adds the vector.
*
* @param layerItem the layer item
* @param features the features
* @param layerItem the layer item
* @param features the features
* @param fitMapToFeaturesExtent the fit map to features extent
*/
public void addLayerFeaturesAsHighlight(LayerItem layerItem, Feature[] features, boolean fitMapToFeaturesExtent) {
@ -656,7 +743,7 @@ public abstract class OpenLayerMap {
@Override
public void onEvent(ol.events.Event event) {
ol.Extent theExtent = vectorSource.getExtent();
//GWT.log(theExtent.toString());
// GWT.log(theExtent.toString());
map.getView().fit(theExtent);
}
@ -1050,7 +1137,21 @@ public abstract class OpenLayerMap {
public void setWMSDetailLayerOpacity(LayerItem layerItem, double opacity) {
String key = layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key);
layer.setOpacity(opacity);
if (layer != null)
layer.setOpacity(opacity);
}
/**
* Sets the WMS detail layer visible.
*
* @param layerItem the layer item
* @param visible the visible
*/
public void setWMSGroupedCustomLayerVisible(LayerItem layerItem, boolean visible) {
String key = layerItem.getName();
Image layer = wmsGroupedCustomLayerMap.get(key);
if (layer != null)
layer.setVisible(visible);
}
/**
@ -1090,4 +1191,17 @@ public abstract class OpenLayerMap {
return map.get((map.keySet().toArray())[index]);
}
/**
* Fit to extent.
*
* @param extent the extent
*/
public void fitToExtent(ol.Extent extent) {
ViewFitOptions opt = new ViewFitOptions();
opt.setMaxZoom(16);
opt.setDuration(SET_CENTER_ANIMATED_DURATION*5);
map.getView().fit(extent, opt);
}
}

View File

@ -8,7 +8,10 @@ import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.ConfiguredLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
@ -20,12 +23,16 @@ 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.cms.search.SearchFacilityUI;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.crossfiltering.CrossFilteringLayerPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.customoverlays.OverlayCustomLayerPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.layercollection.LayerCollectionPanel;
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.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
import org.gcube.portlets.user.geoportaldataviewer.shared.ItemFieldsResponse;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BaseMapLayer;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
@ -34,6 +41,7 @@ import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.NavLink;
import com.github.gwtbootstrap.client.ui.Paragraph;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.constants.LabelType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
@ -50,9 +58,11 @@ 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.HTML;
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.LayoutPanel;
import com.google.gwt.user.client.ui.RadioButton;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.SimplePanel;
@ -111,6 +121,18 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
DropdownButton openCollectionDropDown;
@UiField
DropdownButton linkCustomOverlayLayers;
@UiField
DropdownButton linkCrossFilteringLayers;
@UiField
HTMLPanel panelCustomOverlayLayers;
@UiField
HTMLPanel panelCrossFilteringLayers;
@UiField
HTMLPanel openCollectionPanel;
@ -173,7 +195,7 @@ public class GeonaDataViewMainPanel extends Composite {
extentToEarth.getElement().appendChild(worldImg.getElement());
extentToEarth.setWidth("140px");
linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
// linkMap.setCustomIconStyle(GNAIcons.CustomIconType.MAP.get());
linkPresetLocation.setCustomIconStyle(GNAIcons.CustomIconType.PRESET_LOCATION.get());
linkLayers.setCustomIconStyle(GNAIcons.CustomIconType.LAYERS.get());
@ -185,16 +207,8 @@ public class GeonaDataViewMainPanel extends Composite {
initialSortFilter.setOrder(ORDER.ASC);
navListSearch.addItem(PLACEHOLDER_SELECT_SEARCH_IN, PLACEHOLDER_SELECT_SEARCH_IN);
navListSearch.getElement().getFirstChildElement().setAttribute("disabled", "disabled");
// List<UseCaseDescriptorDV> listUCDs = new ArrayList<UseCaseDescriptorDV>();
//
// for (ItemFieldsResponse itemFieldsResponse : itemFieldsReponse) {
// listUCDs.add(itemFieldsResponse.getUseCaseDescriptorDV());
// }
//
// Collections.sort(listUCDs);
for (final ItemFieldsResponse itemFieldResp : itemFieldsReponse) {
@ -216,9 +230,9 @@ public class GeonaDataViewMainPanel extends Composite {
String ucdProfileID = navListSearch.getValue(navListSearch.getSelectedIndex());
GWT.log("UCD ProfileID selected: " + ucdProfileID);
if (ucdProfileID.compareTo(PLACEHOLDER_SELECT_SEARCH_IN) != 0) {
searchFacilityPanel.clear();
ItemFieldsResponse itemFieldResp = mapItemFieldsForUCD.get(ucdProfileID);
@ -260,7 +274,9 @@ public class GeonaDataViewMainPanel extends Composite {
@Override
public void execute() {
searchFacilityPanel.getElement().getParentElement().getStyle().setOpacity(0.9);
searchFacilityPanel.getElement().getParentElement().addClassName("opacity-09");
panelCustomOverlayLayers.getElement().getParentElement().addClassName("opacity-09");
panelCrossFilteringLayers.getElement().getParentElement().addClassName("opacity-09");
}
@ -310,6 +326,26 @@ public class GeonaDataViewMainPanel extends Composite {
}
}, ClickEvent.getType());
linkCustomOverlayLayers.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// event.preventDefault();
event.stopPropagation();
}
}, ClickEvent.getType());
linkCrossFilteringLayers.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// event.preventDefault();
event.stopPropagation();
}
}, ClickEvent.getType());
}
/**
@ -608,4 +644,105 @@ public class GeonaDataViewMainPanel extends Composite {
}
public void addOverlayLayers(GCubeCollection collection,
List<GroupedLayersDV<? extends LayerIDV>> listGroupedLayers) {
if (listGroupedLayers == null)
return;
com.github.gwtbootstrap.client.ui.Label collectionGroup = new com.github.gwtbootstrap.client.ui.Label(
collection.getUcd().getName());
collectionGroup.setType(LabelType.WARNING);
LayoutPanel lc = new LayoutPanel();
lc.add(collectionGroup);
panelCustomOverlayLayers.add(lc);
for (GroupedLayersDV gCustomLayerDV : listGroupedLayers) {
if (gCustomLayerDV.getListCustomLayers() != null) {
FlowPanel lcInner = new FlowPanel();
lcInner.getElement().getStyle().setMarginLeft(5.0, Unit.PX);
com.github.gwtbootstrap.client.ui.Label labelGroup = new com.github.gwtbootstrap.client.ui.Label(
gCustomLayerDV.getName());
labelGroup.setType(LabelType.INFO);
String descr = gCustomLayerDV.getDescription() != null && !gCustomLayerDV.getDescription().isEmpty()
? gCustomLayerDV.getDescription()
: gCustomLayerDV.getName();
labelGroup.setTitle(descr);
lcInner.add(labelGroup);
if (descr.compareTo(gCustomLayerDV.getName()) != 0) {
HTML overlayGroupDescr = new HTML();
overlayGroupDescr.getElement().setClassName("overlay-panel-style-description");
overlayGroupDescr.setHTML(descr);
lcInner.add(overlayGroupDescr);
}
List<ConfiguredLayerDV> list = gCustomLayerDV.getListCustomLayers();
for (ConfiguredLayerDV customLayer : list) {
if (customLayer.isDisplay()) {
LayerItem layerItem = new LayerItem();
if (customLayer.getWMS_URL() != null) {
final String mapServerHost = URLUtil.getPathURL(customLayer.getWMS_URL());
GWT.log("mapServerHost: " + mapServerHost);
layerItem.setMapServerHost(mapServerHost);
layerItem.setBaseLayer(false);
layerItem.setName(customLayer.getName());
layerItem.setTitle(customLayer.getTitle());
layerItem.setWmsLink(customLayer.getWMS_URL());
// panelCustomOverlayLayers.add(new CrossFilteringLayerPanel(layerItem,
// applicationBus));
lcInner.add(new OverlayCustomLayerPanel(layerItem, applicationBus));
map.addGroupedCustomWMSLayer(layerItem);
}
}
}
panelCustomOverlayLayers.add(lcInner);
}
}
linkCustomOverlayLayers.setVisible(listGroupedLayers.size() > 0);
}
public void addCrossFilteringLayers(GCubeCollection collection,
List<GroupedLayersDV<? extends LayerIDV>> listGroupedLayers) {
if (listGroupedLayers == null)
return;
com.github.gwtbootstrap.client.ui.Label collectionGroup = new com.github.gwtbootstrap.client.ui.Label(
collection.getUcd().getName());
collectionGroup.setType(LabelType.WARNING);
LayoutPanel lc = new LayoutPanel();
lc.add(collectionGroup);
panelCrossFilteringLayers.add(lc);
for (GroupedLayersDV<? extends LayerIDV> groupedLayerDV : listGroupedLayers) {
FlowPanel lcInner = new FlowPanel();
lcInner.getElement().getStyle().setMarginLeft(5.0, Unit.PX);
com.github.gwtbootstrap.client.ui.Label labelGroup = new com.github.gwtbootstrap.client.ui.Label(
groupedLayerDV.getName());
labelGroup.setType(LabelType.INFO);
String descr = groupedLayerDV.getDescription() != null && !groupedLayerDV.getDescription().isEmpty()
? groupedLayerDV.getDescription()
: groupedLayerDV.getName();
labelGroup.setTitle(descr);
lcInner.add(labelGroup);
// panelCustomOverlayLayers.add(labelGroup);
if (descr.compareTo(groupedLayerDV.getName()) != 0) {
HTML overlayGroupDescr = new HTML();
overlayGroupDescr.getElement().setClassName("filter-panel-style-description");
overlayGroupDescr.setHTML(descr);
lcInner.add(overlayGroupDescr);
// panelCustomOverlayLayers.add(overlayGroupDescr);
}
CrossFilteringLayerPanel cfp = new CrossFilteringLayerPanel(collection, groupedLayerDV, applicationBus);
cfp.setFilterButton(linkCrossFilteringLayers);
lcInner.add(cfp);
panelCrossFilteringLayers.add(lcInner);
}
linkCrossFilteringLayers.setVisible(listGroupedLayers.size() > 0);
}
}

View File

@ -49,17 +49,27 @@
</g:HTMLPanel>
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK"
text="Open Collection" ui:field="openCollectionDropDown">
<b:DropdownButton type="LINK" text="Collection"
ui:field="openCollectionDropDown">
<g:HTMLPanel ui:field="openCollectionPanel"
addStyleNames="open-collection-style">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK"
title="Select the Map" text="Map" ui:field="linkMap">
title="Select the base Map" text="Map" ui:field="linkMap" icon="GLOBE">
<g:HTMLPanel ui:field="panelBaseLayers">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK" visible="false"
title="Add overlay layers.." text="Overlay" ui:field="linkCustomOverlayLayers" icon="REORDER">
<g:HTMLPanel ui:field="panelCustomOverlayLayers" addStyleNames="overlay-panel-style">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK" visible="false"
title="Apply spatial filtering.." text="Filter" ui:field="linkCrossFilteringLayers" icon="FILTER">
<g:HTMLPanel ui:field="panelCrossFilteringLayers" addStyleNames="filter-panel-style">
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK" text="Search"
ui:field="searchFacilityButton">
<g:FlowPanel addStyleNames="search-field">
@ -75,7 +85,7 @@
</b:DropdownButton>
<b:DropdownButton type="LINK"
title="Center Map to Location" text="Preset Location"
ui:field="linkPresetLocation">
ui:field="linkPresetLocation" addStyleNames="preset-location">
<b:Nav>
<b:Button type="LINK" ui:field="extentToItaly"
text="Italy" title="Center to Italy"></b:Button>

View File

@ -304,7 +304,7 @@ public class ProjectViewer extends Composite {
GeoJSON spatialReference = theProjectView.getTheProjectDV().getSpatialReference();
Coordinate transfCoord = MapUtils.geoJSONTToBBoxCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(),
Coordinate transfCoord = MapUtils.geoJSONToBBOXCenter(spatialReference, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
if (transfCoord != null) {

View File

@ -15,6 +15,7 @@ import org.gcube.application.geoportalcommon.shared.WhereClause;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
@ -61,8 +62,6 @@ import com.google.gwt.user.client.ui.Widget;
*/
public class SearchFacilityUI extends Composite {
private static final int SEARCHING_LIMIT_RESULTS_TO = 50;
private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class);
protected static final int MIN_LENGHT_SERCHING_STRING = 3;
@ -127,6 +126,7 @@ public class SearchFacilityUI extends Composite {
*
* @param profileID the profile ID
* @param appManagerBus the app manager bus
* @param displayByFields the display by fields
* @param sortByFields the sort by fields
* @param searchForFields the search for fields
* @param initialSortFilter the initial sort filter
@ -237,6 +237,9 @@ public class SearchFacilityUI extends Composite {
}
/**
* Reset current search.
*/
public void resetCurrentSearch() {
searchField.setText("");
resetSearch.setVisible(false);
@ -268,8 +271,9 @@ public class SearchFacilityUI extends Composite {
panelResults.clear();
panelResults.add(new HTML("<hr>"));
panelResults.add(new LoaderIcon("Searching..."));
GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0, SEARCHING_LIMIT_RESULTS_TO,
filter, false, new AsyncCallback<ResultSetPaginatedDataIDs>() {
GeoportalDataViewerServiceAsync.Util.getInstance().getListProjects(profileID, 0,
GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM, filter, false,
new AsyncCallback<ResultSetPaginatedDataIDs>() {
@Override
public void onFailure(Throwable caught) {
@ -309,13 +313,14 @@ public class SearchFacilityUI extends Composite {
+ "). Please find below the top " + returnedItems + ".<br>";
} else if (returnedItems > 0) {
message = "Found " + returnedItems;
message += returnedItems > 0 ? " items" : " item";
message += ". ";
message += returnedItems > 0 ? " projects" : " project";
message += ".";
}
// if (returnedItems > 0) {
// message += "On the map you can see all the projects with a centroid matching the query";
// }
if (returnedItems > 0
&& returnedItems <= GeoportalDataViewerConstants.SEARCH_LIMIT_RESULTS_TO_MAXIMUM) {
message += "On the map you can see all the projects with a centroid matching the query";
}
HTML resultMessage = new HTML(message);
resultMessage.getElement().addClassName("search_result_msg");
@ -356,7 +361,8 @@ public class SearchFacilityUI extends Composite {
profileID);
// here
appManagerBus.fireEvent(new ClosedViewDetailsEvent());
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, true, true, EVENT_SOURCE.LOCATE_SEARCHED));
appManagerBus.fireEvent(
new ShowDetailsEvent(gir, null, true, true, EVENT_SOURCE.LOCATE_SEARCHED));
// appManagerBus.fireEvent(new ShowPopupOnCentroidEvent(profileID,
// resultDoc.getProjectID(), resultDoc.getSpatialReference()));

View File

@ -0,0 +1,672 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.crossfiltering;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.CrossFilteringLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.BBOXDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ApplyCQLToLayerOnMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.FitMapToExtentEvent;
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.ui.util.OLGeoJSONUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.util.WFSMakerUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
import com.github.gwtbootstrap.client.ui.Alert;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.ControlGroup;
import com.github.gwtbootstrap.client.ui.ControlLabel;
import com.github.gwtbootstrap.client.ui.Controls;
import com.github.gwtbootstrap.client.ui.DropdownButton;
import com.github.gwtbootstrap.client.ui.Fieldset;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.http.client.URL;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import jsinterop.base.JsPropertyMap;
import ol.Extent;
import ol.Feature;
import ol.source.Vector;
/**
* The Class CrossFilteringLayerPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public class CrossFilteringLayerPanel extends Composite {
private static final double BBOX_OFFESET_ON_FEATURES = 18000.0;
private static final String ITEM_LABEL = "centroid";
public static String COLORSCALERANGE = "COLORSCALERANGE";
@UiField
Fieldset fieldSet;
@UiField
HTMLPanel panelResults;
@UiField
Button buttonReset;
private CheckBox checkbox;
private GeoInformationForWMSRequest geoInformation;
private static CrossFilteringLayerPanelUiBinder uiBinder = GWT.create(CrossFilteringLayerPanelUiBinder.class);
private HandlerManager applicationBus;
private LayerItem layerItem;
private LinkedHashMap<Integer, List<? extends LayerIDV>> mapInnestedFiltering = new LinkedHashMap<Integer, List<? extends LayerIDV>>();
private LinkedHashMap<Integer, HashMap<String, SelectableItem>> mapInnestedFeatures = new LinkedHashMap<Integer, HashMap<String, SelectableItem>>();
private LinkedHashMap<Integer, List<ListBox>> mapInnestedListBoxes = new LinkedHashMap<Integer, List<ListBox>>();
private GroupedLayersDV<? extends LayerIDV> groupedLayersDV;
private GCubeCollection gCubeCollection;
private DropdownButton filterButton;
/**
* The Interface LayerCollectionPanelUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jan 16, 2023
*/
interface CrossFilteringLayerPanelUiBinder extends UiBinder<Widget, CrossFilteringLayerPanel> {
}
/**
* Instantiates a new overlay custom layer panel.
*
* @param gCubeCollection the g cube collection
* @param groupedLayersDV the grouped layers DV
* @param applicationBus the application bus
*/
public CrossFilteringLayerPanel(GCubeCollection gCubeCollection,
GroupedLayersDV<? extends LayerIDV> groupedLayersDV, HandlerManager applicationBus) {
initWidget(uiBinder.createAndBindUi(this));
this.applicationBus = applicationBus;
this.groupedLayersDV = groupedLayersDV;
this.gCubeCollection = gCubeCollection;
GWT.log("Building cross-filtering for: " + groupedLayersDV);
buttonReset.setType(ButtonType.LINK);
int level = 0;
// Building mapInnestedFiltering
recursivelyBuildSelectableLevels(level, groupedLayersDV.getListCustomLayers());
GWT.log("cross-filtering mapInnestedFiltering: " + mapInnestedFiltering);
for (Integer theLevel : mapInnestedFiltering.keySet()) {
addListBoxesLevelToPanel(theLevel, mapInnestedFiltering.get(theLevel));
}
fillSelectableLevel(level, null);
bindEvents();
}
/**
* Bind events.
*/
private void bindEvents() {
buttonReset.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
panelResults.clear();
for (int i = 1; i < mapInnestedListBoxes.size(); i++) {
resetListBoxLevel(i);
}
// Selecting the placeholder of the fist list box
List<ListBox> listBox = mapInnestedListBoxes.get(0);
listBox.get(0).setSelectedIndex(0);
// Resetting CQL filtering
applicationBus.fireEvent(new ApplyCQLToLayerOnMapEvent(gCubeCollection.getIndexes().get(0), null));
setFilterHighLighted(false);
}
});
}
/**
* Recursively build selectable levels.
*
* @param level the level
* @param layersIDV the layers IDV
*/
private void recursivelyBuildSelectableLevels(int level, List<? extends LayerIDV> layersIDV) {
if (layersIDV == null)
return;
mapInnestedFiltering.put(level, layersIDV);
for (LayerIDV layerIDV : layersIDV) {
if (layerIDV instanceof CrossFilteringLayerDV) {
CrossFilteringLayerDV crossFilteringLayer = (CrossFilteringLayerDV) layerIDV;
if (crossFilteringLayer.getRelated_to() != null) {
recursivelyBuildSelectableLevels(++level, crossFilteringLayer.getRelated_to());
}
}
}
}
/**
* Fill selectable level.
*
* @param level the level
* @param selectedItem the selected item
*/
private void fillSelectableLevel(int level, SelectableItem selectedItem) {
List<? extends LayerIDV> layersIDV = mapInnestedFiltering.get(level);
List<ListBox> listBoxes = mapInnestedListBoxes.get(level);
if (layersIDV == null)
return;
final HashMap<String, SelectableItem> mapSelectableFeatures = new HashMap<String, CrossFilteringLayerPanel.SelectableItem>();
LayerIDV layerIDV = layersIDV.get(0); // Expected one
if (layerIDV instanceof CrossFilteringLayerDV) {
CrossFilteringLayerDV crossFilteringLayer = (CrossFilteringLayerDV) layerIDV;
String wfsURL = crossFilteringLayer.getWFS_URL();
if (selectedItem != null) {
String cqlFilterValue = crossFilteringLayer.getTable_parent_key_field() + "=" + selectedItem.keyValue;
wfsURL += "&" + WFSMakerUtil.CQL_FILTER_PARAMETER + "=" + URL.encode(cqlFilterValue);
}
GWT.log("wfsURL request: " + wfsURL);
GeoportalDataViewerServiceAsync.Util.getInstance().getHTTPResponseForURL(wfsURL,
new AsyncCallback<String>() {
@Override
public void onSuccess(String response) {
GWT.log("wfsURL response: " + response);
Feature[] features = OLGeoJSONUtil.readGeoJsonFeatures(MAP_PROJECTION.EPSG_4326, response);
for (Feature feature : features) {
JsPropertyMap<Object> properties = feature.getProperties();
Object keyValue = properties.get(crossFilteringLayer.getTable_key_field());
Object itemField = properties.get(crossFilteringLayer.getTable_show_field());
Object parentKey = null;
if (crossFilteringLayer.getTable_parent_key_field() != null
&& !crossFilteringLayer.getTable_parent_key_field().isEmpty())
parentKey = properties.get(crossFilteringLayer.getTable_parent_key_field());
parentKey = parentKey == null ? "" : parentKey;
SelectableItem selectableItem = new SelectableItem(
crossFilteringLayer.getTable_key_field() + "", keyValue + "",
crossFilteringLayer.getTable_parent_key_field(), itemField + "",
crossFilteringLayer.getName(), crossFilteringLayer.getTable_geometry_name());
GWT.log("selectableItem: " + selectableItem);
String pathFeatureKey = pathFeatureKey(selectableItem);
mapSelectableFeatures.put(pathFeatureKey, selectableItem);
}
GWT.log("mapSelectableFeatures: " + mapSelectableFeatures);
mapInnestedFeatures.put(level, mapSelectableFeatures);
String placholder = placeholderLayer(layersIDV.get(0)); // Expected one
fillListBoxLevel(level, mapSelectableFeatures, listBoxes, placholder);
}
@Override
public void onFailure(Throwable caught) {
panelResults.clear();
HTML error = new HTML(
"Sorry, an issue is occurred on loading data for cross-filtering facility. Error is: "
+ caught.getMessage());
panelResults.add(error);
}
});
}
}
/**
* Path feature key.
*
* @param selectableItem the selectable item
* @return the string
*/
private String pathFeatureKey(SelectableItem selectableItem) {
return "root_" + selectableItem.parentKeyField + "_" + selectableItem.keyField + "_" + selectableItem.keyValue;
}
/**
* Placeholder layer.
*
* @param layersIDV the layers IDV
* @return the string
*/
private String placeholderLayer(LayerIDV layersIDV) {
String placeholder = "Select";
// if (layersIDV != null)
// placeholder += " " + layersIDV.getTitle();
placeholder += " ...";
return placeholder;
}
/**
* Adds the list boxes level to panel.
*
* @param level the level
* @param layersIDV the layers IDV
*/
private void addListBoxesLevelToPanel(int level, List<? extends LayerIDV> layersIDV) {
if (layersIDV == null)
return;
List<ListBox> listBoxes = new ArrayList<ListBox>(layersIDV.size());
for (LayerIDV layerIDV : layersIDV) {
ControlGroup cg = new ControlGroup();
ControlLabel cl = new ControlLabel(layerIDV.getTitle());
Controls controls = new Controls();
ListBox listBox = new ListBox();
String placeholder = placeholderLayer(layerIDV);
listBox.addItem(placeholder);
setEnabledBox(listBox, false);
listBoxes.add(listBox);
controls.add(listBox);
cg.add(cl);
cg.add(controls);
fieldSet.add(cg);
}
mapInnestedListBoxes.put(level, listBoxes);
}
/**
* Sets the enabled box.
*
* @param listBox the list box
* @param bool the bool
*/
public void setEnabledBox(ListBox listBox, boolean bool) {
listBox.setEnabled(bool);
}
/**
* Clear list box.
*
* @param listBox the list box
* @param bool the bool
*/
public void clearListBox(ListBox listBox, boolean bool) {
listBox.setEnabled(bool);
}
/**
* Reset list box level.
*
* @param level the level
*/
private void resetListBoxLevel(int level) {
List<ListBox> listBoxes = mapInnestedListBoxes.get(level);
if (listBoxes != null) {
for (ListBox listBox : listBoxes) {
listBox.clear();
setEnabledBox(listBox, false);
}
}
}
/**
* Fill list box level.
*
* @param level the level
* @param mapSelectableFeatures the map selectable features
* @param listBoxes the list boxes
* @param placeholder the placeholder
*/
private void fillListBoxLevel(int level, HashMap<String, SelectableItem> mapSelectableFeatures,
List<ListBox> listBoxes, String placeholder) {
// GWT.log("fillBox level: " + level + " map: " + mapSelectableFeatures);
if (mapSelectableFeatures == null)
return;
ListBox listBox = listBoxes.get(0); // Expected one
listBox.clear();
listBox.addItem(placeholder);
listBox.getElement().getFirstChildElement().setAttribute("disabled", "disabled");
for (String key : mapSelectableFeatures.keySet()) {
SelectableItem selItem = mapSelectableFeatures.get(key);
listBox.addItem(selItem.itemValue, key);
}
listBox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
loadInnerLevel(level, listBox.getSelectedValue());
for (int i = level + 1; i < mapInnestedListBoxes.size(); i++) {
resetListBoxLevel(i);
}
String key = listBox.getSelectedValue();
SelectableItem selectableItem = mapSelectableFeatures.get(key);
buildCrossFilteringCQLAndFireEvent(selectableItem);
setFilterHighLighted(true);
}
});
setEnabledBox(listBox, true);
}
/**
* Builds the cross filtering CQL and fire event.
*
* @param selectableItem the selectable item
*/
private void buildCrossFilteringCQLAndFireEvent(SelectableItem selectableItem) {
String setCqlFilter = "INTERSECTS(geom,querySingle('" + selectableItem.layername + "','"
+ selectableItem.theGeometryName + "','" + selectableItem.keyField + "=''" + selectableItem.keyValue
+ "'''))";
// setCqlFilter = URL.encode(setCqlFilter);
GWT.log("CQL FILTER built: " + setCqlFilter);
IndexLayerDV indexLayer = gCubeCollection.getIndexes().get(0);
try {
GCubeSDILayer layer = indexLayer.getLayer();
String wmsLink = layer.getOgcLinks().get("wms");
String layerName = URLUtil.extractValueOfParameterFromURL("layers", wmsLink);
String serviceURL = URLUtil.getPathURL(wmsLink);
String toLServiceURL = serviceURL.toLowerCase();
if (toLServiceURL.endsWith("wms")) {
toLServiceURL = toLServiceURL.substring(0, toLServiceURL.length() - 3) + "ows";
}
String wfsCrossFilteringQuery = WFSMakerUtil.buildWFSRequest(toLServiceURL, layerName, 1000, "geom",
setCqlFilter);
GWT.log("wfsCrossFilteringQuery: " + wfsCrossFilteringQuery);
showCountResultsOfWFSCrossFiltering(wfsCrossFilteringQuery);
} catch (Exception e) {
// TODO: handle exception
}
applicationBus.fireEvent(new ApplyCQLToLayerOnMapEvent(indexLayer, setCqlFilter));
}
public void showCountResultsOfWFSCrossFiltering(String wfsQuery) {
panelResults.clear();
panelResults.add(new HTML("<hr>"));
panelResults.add(new LoaderIcon("Applying spatial filter..."));
GeoportalDataViewerServiceAsync.Util.getInstance().getHTTPResponseForURL(wfsQuery, new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
panelResults.clear();
panelResults.add(new HTML("<hr>"));
Alert alert = new Alert("Error on returning number of items");
alert.setType(AlertType.ERROR);
alert.setClose(false);
panelResults.add(alert);
}
@Override
public void onSuccess(String response) {
Feature[] features = OLGeoJSONUtil.readGeoJsonFeatures(MAP_PROJECTION.EPSG_4326, response);
if (features != null) {
int dataCount = features.length;
panelResults.clear();
panelResults.add(new HTML("<hr>"));
FlexTable flexTable = new FlexTable();
String message = "";
if (dataCount <= 0) {
message = "No " + ITEM_LABEL + " found";
} else {
message = "Found " + dataCount;
message += dataCount > 1 ? " " + ITEM_LABEL + "s" : " " + ITEM_LABEL;
}
HTML resultMessage = new HTML();
resultMessage.getElement().addClassName("search_result_msg");
resultMessage.setHTML(message);
flexTable.setWidget(0, 0, resultMessage.asWidget());
panelResults.add(flexTable);
try {
if (features.length > 0) {
// Calculating Extend of the selected Features
Vector vector = new Vector();
vector.addFeatures(features);
Extent theExtent = vector.getExtent();
GWT.log("Extent from features is: " + theExtent);
theExtent = MapUtils.transformExtent(theExtent, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
double bboxOffset = features.length>1?BBOX_OFFESET_ON_FEATURES:0;
final Extent transfExtent = new ExtentWrapped(theExtent.getLowerLeftX() - bboxOffset,
theExtent.getLowerLeftY() - bboxOffset, theExtent.getUpperRightX() + bboxOffset,
theExtent.getUpperRightY() + bboxOffset);
GWT.log("Zoom to selected - transf extent: " + transfExtent);
Button selectTo = new Button("Zoom to selected");
selectTo.setTitle("Zoom to select centroids...");
selectTo.setType(ButtonType.DEFAULT);
selectTo.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
applicationBus.fireEvent(new FitMapToExtentEvent(transfExtent));
}
});
flexTable.setWidget(1, 0, selectTo);
}
} catch (Exception e) {
// TODO: handle exception
}
}
}
});
}
public static final BBOXDV fromGeoJSON(double[] coords) {
BBOXDV toReturn = new BBOXDV();
toReturn.setMaxX(coords[0]);
toReturn.setMinY(coords[1]);
if (coords.length == 6) {
// 3D
toReturn.setMinZ(coords[2]);
toReturn.setMinX(coords[3]);
toReturn.setMaxY(coords[4]);
toReturn.setMaxZ(coords[5]);
} else {
toReturn.setMinX(coords[2]);
toReturn.setMaxY(coords[3]);
}
return toReturn;
}
/**
* Load inner level.
*
* @param level the level
* @param selectableItemValue the selectable item value
*/
private void loadInnerLevel(int level, String selectableItemValue) {
// GWT.log("selected level " + level + " selectableItemValue " +
// selectableItemValue);
HashMap<String, SelectableItem> mapSelectableItem = mapInnestedFeatures.get(level);
SelectableItem selectedItem = mapSelectableItem.get(selectableItemValue);
// GWT.log("selected selectableItem " + selectedItem);
int innerLevel = level + 1;
List<? extends LayerIDV> selectedLayers = mapInnestedFiltering.get(innerLevel);
// if layer filtering exists at this level
if (selectedLayers != null) {
List<ListBox> selectedListBoxes = mapInnestedListBoxes.get(innerLevel);
GWT.log("loading inner layers " + selectedLayers);
GWT.log("loading selectedListBoxes " + selectedListBoxes);
fillSelectableLevel(innerLevel, selectedItem);
}
}
/**
* Sets the filter high lighted.
*
* @param bool the new filter high lighted
*/
private void setFilterHighLighted(boolean bool) {
if (bool) {
filterButton.getElement().addClassName("highlight-button");
} else {
filterButton.getElement().removeClassName("highlight-button");
}
}
/**
* Sets the search button.
*
* @param searchFacilityButton the new search button
*/
public void setFilterButton(DropdownButton searchFacilityButton) {
this.filterButton = searchFacilityButton;
}
/**
* The Class SelectableItem.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 31, 2023
*/
public class SelectableItem {
protected String keyField;
protected String keyValue;
protected String parentKeyField;
protected String itemValue;
protected String layername;
protected String theGeometryName;
/**
* Instantiates a new selectable item.
*/
SelectableItem() {
}
/**
* Instantiates a new selectable item.
*
* @param keyField the key field
* @param keyValue the key value
* @param parentKeyField the parent key field
* @param itemValue the item value
* @param layername the layername
* @param theGeometryName the the geometry name
*/
public SelectableItem(String keyField, String keyValue, String parentKeyField, String itemValue,
String layername, String theGeometryName) {
super();
this.keyField = keyField;
this.keyValue = keyValue;
this.parentKeyField = parentKeyField;
this.itemValue = itemValue;
this.layername = layername;
this.theGeometryName = theGeometryName;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SelectableItem [keyField=");
builder.append(keyField);
builder.append(", keyValue=");
builder.append(keyValue);
builder.append(", parentKeyField=");
builder.append(parentKeyField);
builder.append(", itemValue=");
builder.append(itemValue);
builder.append(", layername=");
builder.append(layername);
builder.append(", theGeometryName=");
builder.append(theGeometryName);
builder.append("]");
return builder.toString();
}
}
}

View File

@ -0,0 +1,28 @@
<!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:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.margin-left-10 {
margin-left: 10px;
}
</ui:style>
<g:HTMLPanel>
<g:ScrollPanel>
<g:HTMLPanel>
<b:Form ui:field="panelForm">
<b:Fieldset ui:field="fieldSet">
</b:Fieldset>
</b:Form>
<g:HTMLPanel ui:field="panelResults">
</g:HTMLPanel>
<b:Button icon="REMOVE_CIRCLE" ui:field="buttonReset"
title="Reset the filter">Reset</b:Button>
</g:HTMLPanel>
</g:ScrollPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,278 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.customoverlays;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.events.OverlayCustomLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.CheckBox;
import com.github.gwtbootstrap.client.ui.ListBox;
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.FontWeight;
import com.google.gwt.event.dom.client.ChangeEvent;
import com.google.gwt.event.dom.client.ChangeHandler;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.ErrorEvent;
import com.google.gwt.event.dom.client.ErrorHandler;
import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
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.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.FlowPanel;
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.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class OverlayCustomLayerPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 15, 2023
*/
public class OverlayCustomLayerPanel extends Composite {
public static String COLORSCALERANGE = "COLORSCALERANGE";
@UiField
HTMLPanel basePanel;
@UiField
HTMLPanel stylePanel;
@UiField
HTMLPanel styleListPanel;
@UiField
Button buttonLegend;
@UiField
ScrollPanel legendPanel;
private CheckBox checkbox;
private GeoInformationForWMSRequest geoInformation;
private static OverlayCustomLayerPanelUiBinder uiBinder = GWT.create(OverlayCustomLayerPanelUiBinder.class);
private ListBox listBoxStyles = new ListBox();
private HandlerManager applicationBus;
private LayerItem layerItem;
/**
* The Interface LayerCollectionPanelUiBinder.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jan 16, 2023
*/
interface OverlayCustomLayerPanelUiBinder extends UiBinder<Widget, OverlayCustomLayerPanel> {
}
/**
* Instantiates a new overlay custom layer panel.
*
* @param layerItem the layer item
* @param applicationBus the application bus
*/
public OverlayCustomLayerPanel(LayerItem layerItem, HandlerManager applicationBus) {
initWidget(uiBinder.createAndBindUi(this));
this.applicationBus = applicationBus;
this.layerItem = layerItem;
buttonLegend.setType(ButtonType.LINK);
legendPanel.setVisible(false);
GWT.log("Found available layerItem " + layerItem);
String label = layerItem.getTitle();
final String layerName = layerItem.getName();
checkbox = new CheckBox(label);
checkbox.setId("gcubeCustomLayerSelector_" + layerName);
checkbox.getElement().getStyle().setFontWeight(FontWeight.BOLD);
checkbox.setChecked(true);
checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
GWT.log("CustomLayer selector flag changed to value : " + event.toDebugString());
if (event.getValue()) {
// OPEN COLLECTION
applicationBus.fireEvent(new OverlayCustomLayerToMapEvent(layerItem, OverlayCustomLayerToMapEvent.ACTION_TYPE.VISIBILITY, true));
} else {
// CLOSE COLLECTION
legendPanel.clear();
legendPanel.setVisible(false);
applicationBus.fireEvent(new OverlayCustomLayerToMapEvent(layerItem, OverlayCustomLayerToMapEvent.ACTION_TYPE.VISIBILITY, false));
}
}
});
basePanel.add(checkbox);
final String wmsLink = layerItem.getWmsLink();
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName,
new AsyncCallback<GeoInformationForWMSRequest>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage());
}
@Override
public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) {
geoInformation = geoInfoWMS;
GWT.log("Parsed WMS Request returned: " + geoInfoWMS);
if (geoInfoWMS.getStyles() != null && geoInfoWMS.getStyles().getGeoStyles() != null) {
if (geoInfoWMS.getStyles().getGeoStyles().size() > 0) {
stylePanel.setVisible(true);
listBoxStyles.clear();
for (String styleName : geoInfoWMS.getStyles().getGeoStyles()) {
listBoxStyles.addItem(styleName, styleName);
}
styleListPanel.add(listBoxStyles);
}
}
listBoxStyles.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
legendPanel.clear();
legendPanel.setVisible(false);
}
});
buttonLegend.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
GWT.log("is isToggle: " + buttonLegend.isToggle());
GWT.log("is isToggled: " + buttonLegend.isToggled());
if (legendPanel.isVisible()) {
legendPanel.clear();
legendPanel.setVisible(false);
} else {
legendPanel.setVisible(true);
loadLegend(wmsLink);
}
}
});
}
});
}
/**
* Gets the checkbox.
*
* @return the checkbox
*/
public CheckBox getCheckbox() {
return checkbox;
}
/**
* Load legend.
*
* @param wmsLink the wms link
*/
private void loadLegend(String wmsLink) {
legendPanel.clear();
String theLayerName = geoInformation.getLayerName();
final FlexTable flexTable = new FlexTable();
legendPanel.add(flexTable);
// Case no style found
if (listBoxStyles.getSelectedValue() == null) {
flexTable.setWidget(0, 0, new HTML("No style found"));
return;
}
FlowPanel flow = new FlowPanel();
flow.add(new HTMLPanel("Legend for: " + theLayerName));
final HorizontalPanel hpLegend = new HorizontalPanel();
String url = geoInformation.getBaseWmsServiceHost() + "?service=WMS&" + "version="
+ URLUtil.getValueOfParameter("version", wmsLink) + "&" + "request=GetLegendGraphic&" + "layer="
+ theLayerName;
String styleName = null;
try {
styleName = listBoxStyles.getSelectedValue();
} catch (Exception e) {
}
styleName = styleName != null && !styleName.isEmpty() ? styleName : "";
if (!geoInformation.isNcWMS()) {
url += "&format=image/png" + "&STYLE=" + styleName
+ "&LEGEND_OPTIONS=forceRule:True;dx:0.2;dy:0.2;mx:0.2;my:0.2;fontStyle:bold;"
+ "borderColor:000000;border:true;fontColor:000000;fontSize:14";
} else {
int isNcWmsStyle = styleName.indexOf("/");
if (isNcWmsStyle != -1) {
styleName = styleName.substring(isNcWmsStyle + 1, styleName.length());
}
url += "&palette=" + styleName;
if (geoInformation.getMapWMSNoStandard() != null) {
for (String key : geoInformation.getMapWMSNoStandard().keySet()) { // ADDING COLORSCALERANGE?
if (key.compareToIgnoreCase(COLORSCALERANGE) == 0) {
url += "&" + key + "=" + geoInformation.getMapWMSNoStandard().get(key);
break;
}
}
}
}
GWT.log(url);
flexTable.setStyleName("layer-style-panel-table-legend");
flexTable.setWidget(0, 0, new Label("Legend"));
final Image legendImage = new Image(url);
legendImage.addLoadHandler(new LoadHandler() {
@Override
public void onLoad(LoadEvent event) {
}
});
legendImage.addErrorHandler(new ErrorHandler() {
@Override
public void onError(ErrorEvent event) {
GWT.log("ErrorEvent ");
flexTable.setWidget(0, 1, new HTML("Error on loading the style"));
}
});
hpLegend.add(legendImage);
flexTable.setWidget(0, 1, hpLegend);
}
}

View File

@ -0,0 +1,29 @@
<!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:b="urn:import:com.github.gwtbootstrap.client.ui">
<ui:style>
.important {
font-weight: bold;
}
.margin-left-10 {
margin-left: 10px;
}
</ui:style>
<g:HTMLPanel addStyleNames="{style.margin-left-10}">
<g:HTMLPanel ui:field="basePanel">
</g:HTMLPanel>
<g:HTMLPanel ui:field="stylePanel" visible="false"
addStyleNames="layer-style-panel">
Layer Style
<g:HorizontalPanel>
<g:HTMLPanel ui:field="styleListPanel"></g:HTMLPanel>
<b:Button icon="BAR_CHART" ui:field="buttonLegend"
title="Show the Legend"></b:Button>
</g:HorizontalPanel>
<g:ScrollPanel ui:field="legendPanel"></g:ScrollPanel>
</g:HTMLPanel>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -42,12 +42,13 @@ import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.Widget;
/**
* The Class LayerCollectionPanel.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jan 16, 2023
* May 15, 2023
*/
public class LayerCollectionPanel extends Composite {

View File

@ -0,0 +1,59 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.util;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import ol.Feature;
import ol.OLFactory;
import ol.format.GeoJson;
import ol.format.GeoJsonFeatureOptions;
import ol.format.GeoJsonOptions;
import ol.proj.Projection;
import ol.proj.ProjectionOptions;
/**
* The Class OLGeoJSONUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 25, 2023
*/
public class OLGeoJSONUtil {
/**
* Builds the geo JSON.
*
* @param projection the projection
* @return the geo json
*/
public static GeoJson buildGeoJSON(MAP_PROJECTION projection) {
try {
GeoJsonFeatureOptions fo = new GeoJsonFeatureOptions();
ProjectionOptions projectionOptions = new ProjectionOptions();
projectionOptions.setCode(projection.getName());
Projection fp = new Projection(projectionOptions);
fo.setFeatureProjection(fp);
fo.setDataProjection(fp);
GeoJsonOptions geoJsonOpt = new GeoJsonOptions();
geoJsonOpt.setDefaultDataProjection(fp);
geoJsonOpt.setFeatureProjection(fp);
return OLFactory.createGeoJSON(geoJsonOpt);
} catch (Exception e) {
// silent
return OLFactory.createGeoJSON();
}
}
/**
* Read geo json features.
*
* @param projection the projection
* @param geoJSONString the geo JSON string
* @return the feature[]
*/
public static Feature[] readGeoJsonFeatures(MAP_PROJECTION projection, String geoJSONString) {
GeoJson geoJson = buildGeoJSON(projection);
return geoJson.readFeatures(geoJSONString);
}
}

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client.util;
/**
* The Class URLUtil.
* The Class HTTPRequestUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
@ -35,6 +35,20 @@ public class URLUtil {
return value;
}
/**
* Gets the path URL.
*
* @param url the url
* @return the path URL
*/
public static String getPathURL(String url) {
int index = url.toLowerCase().indexOf("?");
if (index > -1) {
return url.substring(0, index);
} else
return null;
}
/**
* Adds the parameter to query string.
*

View File

@ -0,0 +1,49 @@
package org.gcube.portlets.user.geoportaldataviewer.client.util;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.WFSGetFeature;
import com.google.gwt.http.client.URL;
public class WFSMakerUtil {
public static final String CQL_FILTER_PARAMETER = "CQL_FILTER";
public static String buildWFSRequest(String webserviceURL, String layerName, int maxFeatures, String propertyName,
String cqlFilter) throws Exception {
if (layerName == null)
throw new Exception("Bad parameter layerName is null");
if (webserviceURL == null)
throw new Exception("Bad parameter webserviceURL is null");
StringBuilder builder = new StringBuilder();
builder.append(webserviceURL);
builder.append("?");
builder.append(WFSGetFeature.SERVICE.getParameter() + "=" + WFSGetFeature.SERVICE.getValue());
builder.append("&");
builder.append(WFSGetFeature.VERSION.getParameter() + "=" + WFSGetFeature.VERSION.getValue());
builder.append("&");
builder.append(WFSGetFeature.REQUEST.getParameter() + "=" + WFSGetFeature.REQUEST.getValue());
builder.append("&");
builder.append(WFSGetFeature.OUTPUTFORMAT.getParameter() + "=" + URL.encode("application/json"));
builder.append("&");
builder.append(WFSGetFeature.TYPENAME.getParameter() + "=" + layerName);
builder.append("&");
if (maxFeatures > 0) {
builder.append(WFSGetFeature.MAXFEATURES.getParameter() + "=" + maxFeatures);
builder.append("&");
}
if (propertyName != null) {
builder.append(WFSGetFeature.PROPERTYNAME.getParameter() + "=" + propertyName);
builder.append("&");
}
if (cqlFilter != null) {
builder.append(CQL_FILTER_PARAMETER + "=" + cqlFilter);
}
return builder.toString();
}
}

View File

@ -3,10 +3,6 @@ package org.gcube.portlets.user.geoportaldataviewer.server;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.useCaseDescriptors;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -31,6 +27,7 @@ import org.gcube.application.geoportal.common.model.document.identification.Iden
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.useCaseDescriptor.UseCaseDescriptor;
import org.gcube.application.geoportal.common.rest.Projects;
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
@ -47,14 +44,22 @@ import org.gcube.application.geoportalcommon.shared.SearchingFilter;
import org.gcube.application.geoportalcommon.shared.geoportal.ConfigurationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.DocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GeoportalConfigurationID;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GroupedLayersDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.ConfiguredLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.CrossFilteringLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.config.layers.LayerIDV;
import org.gcube.application.geoportalcommon.shared.geoportal.geojson.GeoJSON;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDILayer;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GCubeSDIViewerLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.GeoServerPlatformInfoDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.innerobject.PayloadDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.IdentificationReferencesTYPE;
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
import org.gcube.application.geoportalcommon.shared.geoportal.project.TemporalReferenceDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_CONFIGURATION_TYPE;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.GEOPORTAL_DATA_HANDLER;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclarationDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
@ -70,6 +75,7 @@ import org.gcube.portlets.user.geoportaldataviewer.server.gis.GisMakers;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
import org.gcube.portlets.user.geoportaldataviewer.server.mongoservice.GeoportalServiceIdentityProxy;
import org.gcube.portlets.user.geoportaldataviewer.server.util.ContextRequest;
import org.gcube.portlets.user.geoportaldataviewer.server.util.HTTPRequestUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.util.SessionUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.util.TemporalComparatorUtil;
import org.gcube.portlets.user.geoportaldataviewer.shared.GCubeCollection;
@ -120,19 +126,41 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
gif, png, jpeg, jpg, bmp, tif, tiff, svg, avif, webp
}
/**
* The Enum CENTROID_LAYER_INDEX_FLAG.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* May 25, 2023
*/
public static enum CENTROID_LAYER_INDEX_FLAG {
PUBLIC("public"), PRIVATE("internal");
String id;
/**
* Instantiates a new centroid layer index flag.
*
* @param id the id
*/
CENTROID_LAYER_INDEX_FLAG(String id) {
this.id = id;
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return id;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -468,12 +496,14 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
LOG.debug("Checking configuration for collection " + u.getId());
SessionUtil.addCollectionToSession(getThreadLocalRequest(), u);
Projects<Project> p = projects(u.getId()).build();
UseCaseDescriptorDV ucd = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(u, null);
UseCaseDescriptorDV ucdDV = ConvertToDataValueObjectModel.toUseCaseDescriptorDV(u, null);
Configuration ucdConfig = p.getConfiguration();
GCubeCollection coll = new GCubeCollection();
coll.setUcd(ucd);
coll.setUcd(ucdDV);
// TODO TO Check index flag should be in configuration or evaluated according to
// user credentials
@ -532,11 +562,123 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}.execute().getResult();
}
/**
* Gets the avaiable custom grouped layers for UCD.
*
* @param theHandler the the handler
* @return the avaiable custom grouped layers for UCD
*/
@Override
public Map<String, List<GroupedLayersDV<? extends LayerIDV>>> getAvaiableCustomGroupedLayersForUCD(
GEOPORTAL_DATA_HANDLER theHandler) {
LOG.debug("getAvaiableCustomGroupedLayersForUCD called");
Map<String, List<GroupedLayersDV<? extends LayerIDV>>> mapProfileIDCustomGroupedLayers = new LinkedHashMap<>();
// Reading UCDs Collections from the session
Map<String, UseCaseDescriptor> ucdCollections = SessionUtil.getAvailableCollections(getThreadLocalRequest());
LOG.debug("ucdCollections in session are: " + ucdCollections.size());
for (String profileId : ucdCollections.keySet()) {
UseCaseDescriptor u = ucdCollections.get(profileId);
// Loading geoportal_grouped_overlay_layers if exists
List<HandlerDeclaration> handlers = u.getHandlersByType(theHandler.getType());
GEOPORTAL_CONFIGURATION_TYPE configurationType = null;
switch (theHandler) {
case geoportal_grouped_overlay_layers:
configurationType = GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers;
break;
case geoportal_grouped_cross_filtering:
configurationType = GEOPORTAL_CONFIGURATION_TYPE.grouped_cross_filtering_layers;
default:
break;
}
if (configurationType != null && handlers != null && handlers.size() > 0) {
// Loading Handler gcube_profiles
HandlerDeclaration handler = handlers.get(0);
List<GroupedLayersDV<? extends LayerIDV>> listGroupedCustomLayers = (List<GroupedLayersDV<? extends LayerIDV>>) getGroupedLayers(
u, handler, configurationType);
LOG.debug("listGroupedCustomLayers for type '{}' are: {}", configurationType, listGroupedCustomLayers);
mapProfileIDCustomGroupedLayers.put(profileId, listGroupedCustomLayers);
} else {
LOG.info("No handler '{}' found into UCD {}, continue...", theHandler, u.getId());
mapProfileIDCustomGroupedLayers.put(profileId, null);
}
}
LOG.debug("mapProfileIDCustomGroupedLayers returned: " + mapProfileIDCustomGroupedLayers);
LOG.info("mapProfileIDCustomGroupedLayers returned are: " + mapProfileIDCustomGroupedLayers.size());
return mapProfileIDCustomGroupedLayers;
}
// public Map<String, List<GroupedLayersDV>> getAvaiableCrossFilteringLayers() {
//
// Map<String, List<GroupedLayersDV>> mapProfileIDOvelayLayers = new LinkedHashMap<>();
//
// // Reading UCDs Collections from the session
// Map<String, UseCaseDescriptor> ucdCollections = SessionUtil.getAvailableCollections(getThreadLocalRequest());
//
// for (String profileId : ucdCollections.keySet()) {
//
// UseCaseDescriptor u = ucdCollections.get(profileId);
//
// // Loading geoportal_grouped_overlay_layers if exists
// GEOPORTAL_DATA_HANDLER theHandler = GEOPORTAL_DATA_HANDLER.geoportal_grouped_cross_filtering;
// List<HandlerDeclaration> handlers = u.getHandlersByType(theHandler.getType());
//
// if (handlers != null && handlers.size() > 0) {
// // Loading Handler gcube_profiles
// HandlerDeclaration handler = handlers.get(0);
// List<GroupedLayersDV> listGroupedCustomLayers = null;
// try {
//
// HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handler, u,
// GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers);
//
// if (handler != null) {
// ConfigurationDV<?> config = handlerDV.getConfiguration();
// switch (config.getConfigurationType()) {
// case grouped_overlay_layers:
// listGroupedCustomLayers = (List<GroupedLayersDV>) config.getConfiguration();
// break;
// default:
// break;
// }
// }
// } catch (Exception e) {
// LOG.error("Error on loading {} config for ucd Id {}. Returning null",
// GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers, u.getId());
// }
//
// mapProfileIDOvelayLayers.put(profileId, listGroupedCustomLayers);
// } else {
// LOG.warn("No handler " + theHandler + "found into UCD " + u.getId() + ", continue...");
// mapProfileIDOvelayLayers.put(profileId, null);
// }
// }
//
// return mapProfileIDOvelayLayers;
//
// }
/**
* Gets the layer index.
*
* @param ucdConfig the ucd config
* @param flag the flag
* @return the layer index
*/
private IndexLayerDV getLayerIndex(Configuration ucdConfig, CENTROID_LAYER_INDEX_FLAG flag) {
for (Index index : ucdConfig.getIndexes()) {
try {
IndexLayerDV toAdd = ConvertToDataValueObjectModel.convert(index);
toAdd = removeGSWorkspaceFromWMSPathOfOGCLinks(toAdd);
LOG.trace("Discovered index: " + toAdd);
if (toAdd.getFlag().compareToIgnoreCase(flag.getId()) == 0) {
LOG.debug("Layer index found for flag: " + flag + ", returning");
@ -552,6 +694,69 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return null;
}
/**
* Removes the GS workspace from WMS path of OGC links.
*
* @param index the index
* @return the index layer DV
*/
private IndexLayerDV removeGSWorkspaceFromWMSPathOfOGCLinks(IndexLayerDV index) {
LOG.info("removeGSWorkspaceFromWMSPathOfOGCLinks called");
GCubeSDILayer indexLayer = index.getLayer();
HashMap<String, String> ogcLinks = indexLayer.getOgcLinks();
String wmsLink = ogcLinks.get("wms");
LOG.info("wms link is {}", wmsLink);
int lastCharOfthePath = wmsLink.indexOf("?");
String wmsPath = wmsLink.substring(0, lastCharOfthePath);
for (GeoServerPlatformInfoDV geoserver : indexLayer.getPlatformInfos()) {
// removing "workspace/" from the wms path
if (wmsPath.contains(geoserver.getWorkspace())) {
wmsPath = wmsPath.replace(geoserver.getWorkspace() + "/", "");
LOG.debug("purged wmsPath from the 'workspace' is {}", wmsPath);
wmsLink = wmsPath + wmsLink.substring(lastCharOfthePath, wmsLink.length());
ogcLinks.put("wms", wmsLink);
LOG.info("wms link without {} is {}", geoserver.getWorkspace(), wmsLink);
}
}
return index;
}
/**
* Gets the grouped layers.
*
* @param ucd the ucd
* @param handler the handler
* @param type the type
* @return the grouped layers
*/
private List<? extends GeoportalConfigurationID> getGroupedLayers(UseCaseDescriptor ucd, HandlerDeclaration handler,
GEOPORTAL_CONFIGURATION_TYPE type) {
List<? extends GeoportalConfigurationID> listGroupedCustomLayers = null;
try {
HandlerDeclarationDV handlerDV = ConvertToDataValueObjectModel.toHandlerDeclarationDV(handler, ucd, type);
if (handler != null) {
ConfigurationDV<?> config = handlerDV.getConfiguration();
switch (config.getConfigurationType()) {
case grouped_overlay_layers:
listGroupedCustomLayers = (List<GroupedLayersDV<ConfiguredLayerDV>>) config.getConfiguration();
break;
case grouped_cross_filtering_layers:
listGroupedCustomLayers = (List<GroupedLayersDV<CrossFilteringLayerDV>>) config.getConfiguration();
default:
break;
}
}
} catch (Exception e) {
LOG.error("Error on loading {} config for ucd Id {}. Returning null", type, ucd.getId());
}
return listGroupedCustomLayers;
}
/**
* Gets the config list of fields for searching.
*
@ -1617,6 +1822,22 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return url;
}
/**
* Gets the HTTP response for URL.
*
* @param url the url
* @return the HTTP response for URL
*/
@Override
public String getHTTPResponseForURL(String url) {
LOG.info("getHTTPResponseForURL called");
if (LOG.isDebugEnabled()) {
LOG.debug("getHTTPResponseForURL for URL {} ", url);
}
return HTTPRequestUtil.getResponse(url);
}
/**
* Gets the WFS response.
*
@ -1638,39 +1859,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
}
String url = getWFSRequest(layerItem, mapSrsName, mapBBOX, maxFeatures, outputFormat);
StringBuffer response = new StringBuffer();
String theResponseString = "";
HttpURLConnection con = null;
LOG.debug("Built URL: " + url);
try {
URL obj = new URL(url);
con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
LOG.debug("GET Response Code: " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) { // success
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
} else {
LOG.info("GET request did not work.");
}
theResponseString = response.toString();
// LOG.trace(theResponseString);
if (LOG.isDebugEnabled()) {
LOG.debug("getWFSResponse is empty? " + theResponseString.isEmpty());
}
} catch (Exception e) {
LOG.error("Error on performing the request to URL: " + url, e);
} finally {
}
return theResponseString;
return HTTPRequestUtil.getResponse(url);
}
}

View File

@ -4,6 +4,7 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.application.geoportalcommon.util.URLParserUtil;
import org.gcube.portlets.user.geoportaldataviewer.server.gis.MapServerRecognize.SERVERTYPE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.WFSGetFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -12,12 +12,10 @@ import org.gcube.spatial.data.geoutility.wms.WmsUrlValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class GisViewerWMSUrlValidator.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Jan 28, 2016
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jan 28, 2016
*/
public class WMSUrlValidator {
@ -35,57 +33,56 @@ public class WMSUrlValidator {
private static final Logger LOG = LoggerFactory.getLogger(WMSUrlValidator.class);
/**
* Instantiates a new WMS url validator.
*
* @param wmsRequest the wms request
* @param wmsRequest the wms request
* @param inputLayerName the input layer name
* @throws Exception the exception
*/
public WMSUrlValidator(String wmsRequest, String inputLayerName) throws Exception{
LOG.debug("WMSURLValidator wmsRequest: "+wmsRequest);
LOG.debug("WMSURLValidator layerName: "+inputLayerName);
public WMSUrlValidator(String wmsRequest, String inputLayerName) throws Exception {
LOG.debug("WMSURLValidator wmsRequest: " + wmsRequest);
LOG.debug("WMSURLValidator layerName: " + inputLayerName);
if(wmsRequest==null || wmsRequest.isEmpty())
if (wmsRequest == null || wmsRequest.isEmpty())
throw new Exception("WMS request is null or empty");
this.wmsRequestURI = wmsRequest.trim();
boolean isOwsService = GeoWmsServiceUtility.isOWSSerice(this.wmsRequestURI);
WebMapServerHost webMapServerHost;
//IS WMS?
if(GeoWmsServiceUtility.isWMSService(wmsRequestURI)){
LOG.trace("found "+GeoWmsServiceUtility.SERVICE_WMS+" in wms request: "+wmsRequestURI);
// IS WMS?
if (GeoWmsServiceUtility.isWMSService(wmsRequestURI)) {
LOG.trace("found " + GeoWmsServiceUtility.SERVICE_WMS + " in wms request: " + wmsRequestURI);
webMapServerHost = getWebMapServerHost(wmsRequestURI);
}else
throw new Exception("WMS service not found for layer: "+inputLayerName);
} else
throw new Exception("WMS service not found for layer: " + inputLayerName);
//VALIDATION WMS
// VALIDATION WMS
String baseWmsService = webMapServerHost.getHost();
//IS OWS OR WMS?
this.wmsServiceHost = appendWmsServiceToBaseUrl(wmsRequest.substring(0, wmsRequest.indexOf("?")),isOwsService);
// IS OWS OR WMS?
this.wmsServiceHost = appendWmsServiceToBaseUrl(wmsRequest.substring(0, wmsRequest.indexOf("?")), isOwsService);
this.layerName = inputLayerName;
try {
//VALIDATE WMS SERVICE FOR WEB MAP SERVER
if(!HttpRequestUtil.urlExists(this.wmsServiceHost, true)){
LOG.info("baseWmsServiceUrl: "+wmsServiceHost +" is not a geoserver, setting as input base wms server: "+baseWmsService);
// VALIDATE WMS SERVICE FOR WEB MAP SERVER
if (!HttpRequestUtil.urlExists(this.wmsServiceHost, true)) {
LOG.info("baseWmsServiceUrl: " + wmsServiceHost
+ " is not a geoserver, setting as input base wms server: " + baseWmsService);
this.wmsServiceHost = baseWmsService;
}
} catch (Exception e) {
LOG.error("error on validating geoserver wms service: "+e);
LOG.info("setting baseWmsService as input base wms server: "+baseWmsService);
LOG.error("error on validating geoserver wms service: " + e);
LOG.info("setting baseWmsService as input base wms server: " + baseWmsService);
this.wmsServiceHost = baseWmsService;
}
//VALIDATION FOR THREDDS - FIND LAYER NAME INTO WMS PATH
if(this.layerName==null || this.layerName.isEmpty()){
// VALIDATION FOR THREDDS - FIND LAYER NAME INTO WMS PATH
if (this.layerName == null || this.layerName.isEmpty()) {
this.layerName = WmsUrlValidator.getValueOfParameter(WmsParameters.LAYERS, wmsRequest);
if(this.layerName==null || this.layerName.isEmpty())
if (this.layerName == null || this.layerName.isEmpty())
throw new Exception("Layer name is null or empty");
}
@ -93,42 +90,42 @@ public class WMSUrlValidator {
parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName);
}
/**
* Append wms service to base url.
*
* @param url the url
* @param url the url
* @param isOwsServer the is ows server
* @return the string
*/
public String appendWmsServiceToBaseUrl(String url, boolean isOwsServer){
public String appendWmsServiceToBaseUrl(String url, boolean isOwsServer) {
if(url.contains("/"+WMS) || url.contains("/"+OWS))
if (url.contains("/" + WMS) || url.contains("/" + OWS))
return url;
if(url.lastIndexOf("/") != url.length()){
url+="/";
if (url.lastIndexOf("/") != url.length()) {
url += "/";
}
if(isOwsServer)
return url+=OWS;
if (isOwsServer)
return url += OWS;
else
return url+=WMS;
return url += WMS;
}
/**
* Method: getFullWmsUrlRequest
* Create a correct wms url request
* Returns:
* Method: getFullWmsUrlRequest Create a correct wms url request Returns:
* {String}.
*
* @param returnEmptyParameter if true the wms url returned contains also wms parameter with empty value, none otherwise.
* and mandatory wms parameters that does not found are filled with empty values
* @param returnEmptyParameter if true the wms url returned contains also
* wms parameter with empty value, none
* otherwise. and mandatory wms parameters
* that does not found are filled with empty
* values
* @param fillEmptyParameterAsDefault the fill empty parameter as default
* @return a correct wms url request in formatted string like this:
* "wmsserver?key1=value1&key2=value2&key3=value3"
* "wmsserver?key1=value1&key2=value2&key3=value3"
*/
public String parseWMSRequest(boolean returnEmptyParameter, boolean fillEmptyParameterAsDefault){
public String parseWMSRequest(boolean returnEmptyParameter, boolean fillEmptyParameterAsDefault) {
urlValidator = new org.gcube.spatial.data.geoutility.wms.WmsUrlValidator(wmsRequestURI);
String fullWmsUrlBuilded;
@ -138,98 +135,100 @@ public class WMSUrlValidator {
parametersValue.putAll(urlValidator.getMapWmsParameters());
String ln = parametersValue.get(WmsParameters.LAYERS.name());
LOG.debug("Comparing layer name from Wms request: "+ln +", with OnLineResource layerName: "+this.layerName);
if(ln==null || ln.isEmpty() || ln.compareTo(this.layerName)!=0){
LOG.info("Layer name into wms request is different to OnLineResource layers name, replacing layer name: "+this.layerName);
LOG.debug("Comparing layer name from Wms request: " + ln + ", with OnLineResource layerName: "
+ this.layerName);
if (ln == null || ln.isEmpty() || ln.compareTo(this.layerName) != 0) {
LOG.info(
"Layer name into wms request is different to OnLineResource layers name, replacing layer name: "
+ this.layerName);
parametersValue.put(WmsParameters.LAYERS.getParameter(), this.layerName);
urlValidator.getMapWmsParameters().put(org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS.getParameter(), this.layerName);
fullWmsUrlBuilded = org.gcube.spatial.data.geoutility.wms.WmsUrlValidator.setValueOfParameter(org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS, fullWmsUrlBuilded, this.layerName, true);
urlValidator.getMapWmsParameters().put(
org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS.getParameter(), this.layerName);
fullWmsUrlBuilded = org.gcube.spatial.data.geoutility.wms.WmsUrlValidator.setValueOfParameter(
org.gcube.spatial.data.geoutility.bean.WmsParameters.LAYERS, fullWmsUrlBuilded, this.layerName,
true);
}
// logger.trace("parametersValue: "+parametersValue);
mapWmsNoStandardParams = new HashMap<String, String>(urlValidator.getMapWmsNoStandardParams().size());
mapWmsNoStandardParams.putAll(urlValidator.getMapWmsNoStandardParams());
wmsNoStandardParameters = urlValidator.getWmsNoStandardParameters();
}
catch (Exception e) {
LOG.error("An error occurred during wms uri build, returning uri: "+wmsRequestURI, e);
} catch (Exception e) {
LOG.error("An error occurred during wms uri build, returning uri: " + wmsRequestURI, e);
fullWmsUrlBuilded = wmsRequestURI;
}
LOG.trace("GisViewerWMSUrlValidator parseWMSRequest returning full wms url: "+fullWmsUrlBuilded);
LOG.trace("GisViewerWMSUrlValidator parseWMSRequest returning full wms url: " + fullWmsUrlBuilded);
return fullWmsUrlBuilded;
}
/**
* Gets the web map server host.
*
* @param wmsRequest the wms request
* @return the web map server host, (geoserver URI or the wmsRequest substring from start to index of '?' char (if exists))
* @return the web map server host, (geoserver URI or the wmsRequest substring
* from start to index of '?' char (if exists))
*/
public WebMapServerHost getWebMapServerHost(String wmsRequest){
public WebMapServerHost getWebMapServerHost(String wmsRequest) {
WebMapServerHost webMapServerHost = new WebMapServerHost();
if(wmsRequest==null)
return webMapServerHost; //uri is empty
if (wmsRequest == null)
return webMapServerHost; // uri is empty
int end = wmsRequest.toLowerCase().lastIndexOf("?");
if(end==-1){
LOG.trace("char ? not found in geoserver uri, return: "+wmsRequest);
return webMapServerHost; //uri is empty
if (end == -1) {
LOG.trace("char ? not found in geoserver uri, return: " + wmsRequest);
return webMapServerHost; // uri is empty
}
String webMapServerBaseURL = wmsRequest.substring(0, wmsRequest.toLowerCase().lastIndexOf("?"));
int index = webMapServerBaseURL.lastIndexOf(GEOSERVER);
if(index>-1){ //FOUND the string GEOSERVER into URL
LOG.trace("found geoserver string: "+GEOSERVER+" in "+webMapServerBaseURL);
if (index > -1) { // FOUND the string GEOSERVER into URL
LOG.trace("found geoserver string: " + GEOSERVER + " in " + webMapServerBaseURL);
//THERE IS SCOPE?
// THERE IS SCOPE?
int lastSlash = webMapServerBaseURL.lastIndexOf("/");
int includeGeoserverString = index+GEOSERVER.length();
int endUrl = lastSlash>includeGeoserverString?lastSlash:includeGeoserverString;
LOG.trace("indexs - lastSlash: ["+lastSlash+"], includeGeoserverString: ["+includeGeoserverString+"], endUrl: ["+endUrl+"]");
int startScope = includeGeoserverString+1<endUrl?includeGeoserverString+1:endUrl; //INCLUDE SLASH
int includeGeoserverString = index + GEOSERVER.length();
int endUrl = lastSlash > includeGeoserverString ? lastSlash : includeGeoserverString;
LOG.trace("indexs - lastSlash: [" + lastSlash + "], includeGeoserverString: [" + includeGeoserverString
+ "], endUrl: [" + endUrl + "]");
int startScope = includeGeoserverString + 1 < endUrl ? includeGeoserverString + 1 : endUrl; // INCLUDE SLASH
String scope = webMapServerBaseURL.substring(startScope, endUrl);
LOG.trace("geoserver url include scope: "+webMapServerBaseURL.substring(includeGeoserverString, endUrl));
LOG.trace("geoserver url include scope: " + webMapServerBaseURL.substring(includeGeoserverString, endUrl));
webMapServerHost.setHost(webMapServerBaseURL.substring(0, endUrl));
webMapServerHost.setScope(scope);
return webMapServerHost;
}else{
LOG.trace("the string 'geoserver' not found in "+webMapServerBaseURL);
} else {
LOG.trace("the string 'geoserver' not found in " + webMapServerBaseURL);
// GET LAST INDEX OF '/' AND CONCATENATE GEOSERVER
String urlConn = webMapServerBaseURL.substring(0, webMapServerBaseURL.lastIndexOf("/"))+GEOSERVER;
LOG.trace("tentative concatenating string 'geoserver' at http url "+urlConn);
String urlConn = webMapServerBaseURL.substring(0, webMapServerBaseURL.lastIndexOf("/")) + GEOSERVER;
LOG.trace("tentative concatenating string 'geoserver' at http url " + urlConn);
try {
if(HttpRequestUtil.urlExists(urlConn, false)){
LOG.trace("url: "+urlConn+" - open a connection, return "+urlConn);
if (HttpRequestUtil.urlExists(urlConn, false)) {
LOG.trace("url: " + urlConn + " - open a connection, return " + urlConn);
webMapServerHost.setHost(urlConn);
return webMapServerHost;
}
else
LOG.trace("url: "+urlConn+" - not open a connection");
} else
LOG.trace("url: " + urlConn + " - not open a connection");
} catch (Exception e) {
LOG.error("url connection is wrong at :"+urlConn);
LOG.error("url connection is wrong at :" + urlConn);
}
String uriWithoutParameters = wmsRequest.substring(0, end);
LOG.trace("url connection, returned: "+uriWithoutParameters);
LOG.trace("url connection, returned: " + uriWithoutParameters);
webMapServerHost.setHost(uriWithoutParameters);
return webMapServerHost;
}
}
/**
* Gets the wms service host.
*
@ -260,42 +259,40 @@ public class WMSUrlValidator {
return wmsNoStandardParameters;
}
/**
* Gets the value of parsed wms parameter.
*
* @param parameter the parameter
* @return the value of parsed wms parameter parsed from wms request.
*/
public String getValueOfParsedWMSParameter(WmsParameters parameter){
public String getValueOfParsedWMSParameter(WmsParameters parameter) {
return parametersValue.get(parameter.getParameter());
}
/**
* Gets the value of parameter.
*
* @param wmsParam the wms param
* @param wmsParam the wms param
* @param wmsUrlParameters the wms url parameters
* @return the value of parameter
*/
public static String getValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters){
public static String getValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters) {
return WmsUrlValidator.getValueOfParameter(wmsParam, wmsUrlParameters);
}
/**
* Sets the value of parameter.
*
* @param wmsParam the wms param
* @param wmsParam the wms param
* @param wmsUrlParameters the wms url parameters
* @param newValue the new value
* @param addIfNotExists the add if not exists
* @param newValue the new value
* @param addIfNotExists the add if not exists
* @return the string
*/
public static String setValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters, String newValue, boolean addIfNotExists){
public static String setValueOfParameter(WmsParameters wmsParam, String wmsUrlParameters, String newValue,
boolean addIfNotExists) {
return WmsUrlValidator.setValueOfParameter(wmsParam, wmsUrlParameters, newValue, addIfNotExists);
}
@ -309,8 +306,6 @@ public class WMSUrlValidator {
return layerName;
}
/**
* Gets the styles as list.
*
@ -321,18 +316,17 @@ public class WMSUrlValidator {
List<String> listStyles = new ArrayList<String>();
String styles = getValueOfParsedWMSParameter(WmsParameters.STYLES);
if(styles!=null && !styles.isEmpty()){
if (styles != null && !styles.isEmpty()) {
String[] arrayStyle = styles.split(",");
for (String style : arrayStyle) {
if(style!=null && !style.isEmpty())
if (style != null && !style.isEmpty())
listStyles.add(style);
}
}
return listStyles;
}
/**
* Gets the map wms no standard params.
*
@ -342,63 +336,4 @@ public class WMSUrlValidator {
return mapWmsNoStandardParams;
}
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
// String baseGeoserverUrl = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows";
// String baseGeoserverUrl = "http://www.fao.org/figis/geoserver/species";
// String fullPath = "http://www.fao.org/figis/geoserver/species?SERVICE=WMS&BBOX=-176.0,-90.0,180.0,90&styles=Species_prob, puppa&layers=layerName&FORMAT=image/gif";
// String fullPath = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows?service=wms&version=1.1.0&request=GetMap&layers==IGG:area_temp_1000&width=676&height=330&srs=EPSG:4326&crs=EPSG:4326&format=application/openlayers&bbox=-85.5,-180.0,90.0,180.0";
// String baseGeoserverUrl = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc";
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
// WmsUrlValidator validator = new WmsUrlValidator(baseGeoserverUrl, fullPath , "", false);
// logger.trace("base wms service url: "+validator.getBaseWmsServiceUrl());
// logger.trace("layer name: "+validator.getLayerName());
// logger.trace("full wms url: "+validator.getFullWmsUrlRequest(false, true));
// logger.trace("style: "+validator.getStyles());
// logger.trace("not standard parameter: "+validator.getWmsNotStandardParameters());
// String[] arrayStyle = validator.getStyles().split(",");
//
// if(arrayStyle!=null && arrayStyle.length>0){
//
// for (String style : arrayStyle) {
// if(style!=null && !style.isEmpty())
//
// System.out.println("Style: "+style.trim());
// }
// }
//
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
//
// WmsGeoExplorerUrlValidator validator = new WmsGeoExplorerUrlValidator("http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc", fullPath , "", false);
// validator.getFullWmsUrlRequest(false,true);
//
// System.out.println(validator.getWmsNoStandardParameters());
// System.out.println(validator.getMapWmsNoStandardParams());
// fullPath = WmsUrlValidator.setValueOfParameter(WmsParameters.STYLES, fullPath, "123", true);
//
// MapPreviewGenerator map = new MapPreviewGenerator();
// fullPath = map.buildWmsRequestMapPreview(fullPath, "-85.0,-180.0,85.0,180.0");
// System.out.println(fullPath);
String wmsRequest = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geoserver/wms?CRS=EPSG:4326&BBOX=-85.5,-180.0,90.0,180.0&VERSION=1.1.0&FORMAT=application/openlayers&SERVICE=wms&HEIGHT=330&LAYERS=aquamaps:lsoleasolea20130716162322254cest&REQUEST=GetMap&STYLES=Species_prob&SRS=EPSG:4326&WIDTH=676";
// String wmsRequest = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto&bbox=-85.0,-180.0,85.0,180.0";
WmsUrlValidator wms;
try {
wms = new WmsUrlValidator(wmsRequest);
System.out.println("Returned wms: "+wms.toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,69 @@
package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class HTTPRequestUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 5, 2023
*/
public class HTTPRequestUtil {
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
/**
* Gets the response.
*
* @param url the url
* @return the response
*/
public static String getResponse(String url) {
if (url == null || url.isEmpty())
return null;
StringBuffer response = new StringBuffer();
String theResponseString = "";
HttpURLConnection con = null;
LOG.debug("Calling URL: " + url);
try {
URL obj = new URL(url);
con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
LOG.debug("GET Response Code: " + responseCode);
if (responseCode == HttpURLConnection.HTTP_OK) { // success
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
} else {
LOG.info("GET request did not work.");
}
theResponseString = response.toString();
// LOG.trace(theResponseString);
if (LOG.isDebugEnabled()) {
LOG.debug("getResponse is empty? " + theResponseString.isEmpty());
}
} catch (Exception e) {
LOG.error("Error on performing the request to URL: " + url, e);
} finally {
}
LOG.debug("returning response with size: " + theResponseString.length());
return theResponseString;
}
}

View File

@ -3,7 +3,9 @@
*/
package org.gcube.portlets.user.geoportaldataviewer.server.util;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@ -51,6 +53,8 @@ public class SessionUtil {
private static final String COUNT_DOCS_FOR_PROFILE_ID = "GNA_DATAVIEWER_COUNT_DOCS_FOR_PROFILE_ID";
private static final String UCD_COLLECTIONS_SESSION = "THE_UCD_COLLECTIONS";
/**
* Checks if is into portal.
*
@ -136,7 +140,7 @@ public class SessionUtil {
if (token != null) {
LOG.debug("Returning token " + token.substring(1, 10) + "_MASKED_TOKEN_");
if(setInThread)
if (setInThread)
SecurityTokenProvider.instance.set(token);
}
@ -273,33 +277,6 @@ public class SessionUtil {
HttpSession session = httpServletRequest.getSession();
List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
throw new Exception("getListConcessioni must be revisited!!!!");
/*
* // setting null to force reloading from service if (reloadFromService)
* listOfConcessioni = null;
*
* if (listOfConcessioni == null) { listOfConcessioni = new
* ArrayList<Concessione>();
* LOG.info("Loading list of concessione from client mongo");
* SessionUtil.getCurrentContext(httpServletRequest, true); MongoServiceCommon
* serviceUtil = new MongoServiceCommon(); MongoConcessioni clientMongo =
* serviceUtil.getInstanceMongoConcessioni();
*
* Iterator<Concessione> concessioni = clientMongo.getList(); if (concessioni !=
* null) { while (concessioni.hasNext()) { Concessione concessione =
* (Concessione) concessioni.next(); listOfConcessioni.add(concessione);
*
* } } // LOG.debug("Got list of concessioni from client mongo: " +
* listOfConcessioni); session.setAttribute(LIST_OF_CONCESSIONI,
* listOfConcessioni);
* LOG.info("Saved in session list of concessioni from client mongo with size: "
* + listOfConcessioni.size());
*
* } else LOG.info("list of concessioni presents in session, using it");
*
* LOG.info("read list of concessioni with size: " + listOfConcessioni.size());
* return listOfConcessioni;
*
*/
}
/**
@ -352,4 +329,20 @@ public class SessionUtil {
}
public static void addCollectionToSession(HttpServletRequest httpServletRequest, UseCaseDescriptor u) {
HttpSession session = httpServletRequest.getSession();
Map<String, UseCaseDescriptor> ucds = (Map<String, UseCaseDescriptor>) session
.getAttribute(UCD_COLLECTIONS_SESSION);
if (ucds == null) {
ucds = new HashMap<String, UseCaseDescriptor>();
}
ucds.put(u.getId(), u);
session.setAttribute(UCD_COLLECTIONS_SESSION, ucds);
}
public static Map<String, UseCaseDescriptor> getAvailableCollections(HttpServletRequest httpServletRequest) {
HttpSession session = httpServletRequest.getSession();
return (Map<String, UseCaseDescriptor>) session.getAttribute(UCD_COLLECTIONS_SESSION);
}
}

View File

@ -9,7 +9,7 @@ import java.util.List;
import java.util.Map;
/**
* The Class URLUtil.
* The Class URLParserUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*

View File

@ -0,0 +1,16 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.io.Serializable;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Data
public class DisplayCategory implements Serializable {
String title;
String description;
}

View File

@ -23,7 +23,6 @@ import com.google.gwt.core.client.GWT;
*/
public class LayerItem implements Serializable, Cloneable {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 1664082688635256899L;
@ -102,9 +101,6 @@ public class LayerItem implements Serializable, Cloneable {
/** The server wms request. */
public String wmsLink;
/** The cql filter available. */
private boolean cqlFilterAvailable = false;
/** The uuid. */
private String UUID;
@ -722,7 +718,7 @@ public class LayerItem implements Serializable, Cloneable {
public String getCqlFilter() {
return cqlFilter;
}
/**
* Sets the cql filter.
*
@ -756,16 +752,7 @@ public class LayerItem implements Serializable, Cloneable {
* @return true, if is cql filter available
*/
public boolean isCqlFilterAvailable() {
return cqlFilterAvailable;
}
/**
* Sets the cql filter available.
*
* @param cqlFilterAvailable the new cql filter available
*/
public void setCqlFilterAvailable(boolean cqlFilterAvailable) {
this.cqlFilterAvailable = cqlFilterAvailable;
return (cqlFilter != null) && (!cqlFilter.isEmpty());
}
/**
@ -894,11 +881,6 @@ public class LayerItem implements Serializable, Cloneable {
return maxResolution;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
@ -952,8 +934,6 @@ public class LayerItem implements Serializable, Cloneable {
builder.append(isNcWms);
builder.append(", wmsLink=");
builder.append(wmsLink);
builder.append(", cqlFilterAvailable=");
builder.append(cqlFilterAvailable);
builder.append(", UUID=");
builder.append(UUID);
builder.append(", zAxis=");
@ -968,7 +948,6 @@ public class LayerItem implements Serializable, Cloneable {
return builder.toString();
}
/**
* To layer item.
*
@ -991,9 +970,8 @@ public class LayerItem implements Serializable, Cloneable {
* @param maxResolution the max resolution
* @return the layer item
*/
// TODO Constructor from IndexLayerDV, GCUBESDILAeryDV or direct info
// TODO Constructor from IndexLayerDV, GCUBESDILAeryDV or direct info
private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL,
String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher,
ArrayList<String> styles, String wmsLink, boolean onTop, HashMap<String, String> wmsNotStandardParams,

View File

@ -0,0 +1,13 @@
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
import java.util.Map;
public class OverlayWMSLayer {
private String title;
private String name;
private String wmsServiceBaseURL;
private boolean display;
private Map<String, String> mapProperties;
}

View File

@ -1,6 +1,4 @@
package org.gcube.portlets.user.geoportaldataviewer.server.gis;
package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs;
/**
* The Enum WfsParameters.
@ -20,6 +18,7 @@ public enum WFSGetFeature {
WIDTH("WIDTH","676"),
HEIGHT("HEIGHT","230"),
SRSNAME("srsName","EPSG:4326"),
PROPERTYNAME("propertyName", ""),
// CRS("CRS","EPSG:4326"), //WMS 1.3.0 COMPLIANT
OUTPUTFORMAT("OUTPUTFORMAT","json"),
MAXFEATURES("MAXFEATURES","");

View File

@ -26,7 +26,7 @@ body {
background-color: white;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
padding: 10px;
border-radius: 2px;
border-radius: 10px;
border: 1px solid #cccccc;
bottom: 12px;
left: -50px;
@ -158,6 +158,11 @@ body {
padding-top: 1px;
}
.preset-location ul a {
margin: 5px !important;
}
.my-control-group .controls {
margin-left: 70px !important;
}
@ -211,7 +216,7 @@ body {
}
.inner-toolbar .btn-group {
margin-left: 0px !important;
margin-left: 2px !important;
}
.inner-toolbar .btn-link {
@ -426,6 +431,7 @@ body {
.map-layers-radio label {
margin-left: 5px;
padding-top: 5px;
font-weight: bold;
}
@ -824,4 +830,70 @@ RESPONSIVE
.layer-style-panel-table-legend table td {
padding-left: 5px;
}
}
/* CUSTOM OVERLAY UI */
.overlay-panel-style {
padding-left: 10px;
padding-right: 10px;
max-width: 350px;
}
.overlay-panel-style-description {
border: none !important;
white-space: pre-line;
padding: 10px 0px;
font-style: italic;
}
.overlay-panel-style > div {
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
margin-top: 5px;
}
/* FILTER PANEL UI */
.filter-panel-style {
padding-left: 10px;
padding-right: 10px;
max-width: 350px;
}
.filter-panel-style .control-group {
margin-bottom: 5px !important;
}
.filter-panel-style select {
min-width: 310px;
}
.filter-panel-style-description {
border: none !important;
white-space: pre-line;
padding: 10px 0px;
font-style: italic;
}
.filter-panel-style > div {
border: 1px solid #ccc;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
margin-top: 5px;
}
.filter-panel-style a {
float: right;
}
.filter-panel-style label {
font-weight: bold;
}
/* END CUSTOM OVERLAY UI */
.opacity-09 {
opacity: 0.9;
}

View File

@ -0,0 +1,84 @@
package org.gcube.portlets.user.geoportaldataviewer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.spatial.data.geoutility.GeoWmsServiceUtility;
import org.gcube.spatial.data.geoutility.bean.WmsParameters;
import org.gcube.spatial.data.geoutility.util.HttpRequestUtil;
import org.gcube.spatial.data.geoutility.wms.WmsUrlValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class WMSUrlValidatorTest.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jun 1, 2023
*/
public class WMSUrlValidatorTest {
/**
* The main method.
*
* @param args the arguments
*/
public static void main(String[] args) {
// String baseGeoserverUrl = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows";
// String baseGeoserverUrl = "http://www.fao.org/figis/geoserver/species";
// String fullPath = "http://www.fao.org/figis/geoserver/species?SERVICE=WMS&BBOX=-176.0,-90.0,180.0,90&styles=Species_prob, puppa&layers=layerName&FORMAT=image/gif";
// String fullPath = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows?service=wms&version=1.1.0&request=GetMap&layers==IGG:area_temp_1000&width=676&height=330&srs=EPSG:4326&crs=EPSG:4326&format=application/openlayers&bbox=-85.5,-180.0,90.0,180.0";
// String baseGeoserverUrl = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc";
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
// WmsUrlValidator validator = new WmsUrlValidator(baseGeoserverUrl, fullPath , "", false);
// logger.trace("base wms service url: "+validator.getBaseWmsServiceUrl());
// logger.trace("layer name: "+validator.getLayerName());
// logger.trace("full wms url: "+validator.getFullWmsUrlRequest(false, true));
// logger.trace("style: "+validator.getStyles());
// logger.trace("not standard parameter: "+validator.getWmsNotStandardParameters());
// String[] arrayStyle = validator.getStyles().split(",");
//
// if(arrayStyle!=null && arrayStyle.length>0){
//
// for (String style : arrayStyle) {
// if(style!=null && !style.isEmpty())
//
// System.out.println("Style: "+style.trim());
// }
// }
//
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
//
// WmsGeoExplorerUrlValidator validator = new WmsGeoExplorerUrlValidator("http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc", fullPath , "", false);
// validator.getFullWmsUrlRequest(false,true);
//
// System.out.println(validator.getWmsNoStandardParameters());
// System.out.println(validator.getMapWmsNoStandardParams());
// fullPath = WmsUrlValidator.setValueOfParameter(WmsParameters.STYLES, fullPath, "123", true);
//
// MapPreviewGenerator map = new MapPreviewGenerator();
// fullPath = map.buildWmsRequestMapPreview(fullPath, "-85.0,-180.0,85.0,180.0");
// System.out.println(fullPath);
String wmsRequest = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geoserver/wms?CRS=EPSG:4326&BBOX=-85.5,-180.0,90.0,180.0&VERSION=1.1.0&FORMAT=application/openlayers&SERVICE=wms&HEIGHT=330&LAYERS=aquamaps:lsoleasolea20130716162322254cest&REQUEST=GetMap&STYLES=Species_prob&SRS=EPSG:4326&WIDTH=676";
// String wmsRequest = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto&bbox=-85.0,-180.0,85.0,180.0";
WmsUrlValidator wms;
try {
wms = new WmsUrlValidator(wmsRequest);
System.out.println("Returned wms: "+wms.toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
}