2020-11-19 15:19:27 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
2020-10-27 16:04:34 +01:00
|
|
|
package org.gcube.portlets.user.geoportaldataviewer.client;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
2021-10-14 11:34:04 +02:00
|
|
|
import java.util.Collection;
|
2020-10-27 16:04:34 +01:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
2020-10-30 12:19:51 +01:00
|
|
|
import java.util.Map;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2021-08-02 15:20:01 +02:00
|
|
|
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
|
2021-09-01 12:51:06 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
2020-11-19 15:19:27 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
|
2020-10-29 15:18:14 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEventHandler;
|
2020-11-03 13:09:08 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
|
2020-11-19 15:19:27 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler;
|
2021-09-06 16:39:12 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
|
2021-11-12 14:54:54 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerMap;
|
2021-10-15 17:51:09 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow;
|
2020-11-19 15:19:27 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
|
2020-11-19 15:19:27 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
|
2020-10-29 15:18:14 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
|
2022-10-13 16:53:33 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.IndexLayer;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
2020-11-19 15:19:27 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
2022-10-13 16:53:33 +02:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObjectType;
|
2020-11-03 13:09:08 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2020-11-03 13:09:08 +01:00
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
2021-10-15 17:51:09 +02:00
|
|
|
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
2020-10-27 16:04:34 +01:00
|
|
|
import com.google.gwt.core.client.GWT;
|
2020-11-03 18:04:47 +01:00
|
|
|
import com.google.gwt.core.client.Scheduler;
|
|
|
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
2020-11-03 13:09:08 +01:00
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
2020-10-29 15:18:14 +01:00
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
2021-09-06 16:39:12 +02:00
|
|
|
import com.google.gwt.json.client.JSONArray;
|
|
|
|
import com.google.gwt.json.client.JSONParser;
|
2020-11-03 18:04:47 +01:00
|
|
|
import com.google.gwt.user.client.DOM;
|
|
|
|
import com.google.gwt.user.client.Element;
|
|
|
|
import com.google.gwt.user.client.Event;
|
|
|
|
import com.google.gwt.user.client.EventListener;
|
2020-10-27 16:04:34 +01:00
|
|
|
import com.google.gwt.user.client.Window;
|
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
2020-10-30 12:19:51 +01:00
|
|
|
import com.google.gwt.user.client.ui.FlexTable;
|
2021-09-09 15:55:33 +02:00
|
|
|
import com.google.gwt.user.client.ui.FlowPanel;
|
2020-10-30 12:19:51 +01:00
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
2021-09-07 17:29:56 +02:00
|
|
|
import com.google.gwt.user.client.ui.ScrollPanel;
|
2020-11-03 18:04:47 +01:00
|
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2020-10-29 17:08:29 +01:00
|
|
|
import ol.Coordinate;
|
2021-09-06 16:39:12 +02:00
|
|
|
import ol.Extent;
|
|
|
|
import ol.OLFactory;
|
|
|
|
import ol.format.GeoJson;
|
|
|
|
import ol.geom.Geometry;
|
2020-10-29 17:08:29 +01:00
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/**
|
|
|
|
* The Class LayerManager.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
*
|
2021-07-30 14:57:08 +02:00
|
|
|
* Oct 27, 2020
|
2020-10-27 16:04:34 +01:00
|
|
|
*/
|
|
|
|
public class LayerManager {
|
2020-12-04 15:06:32 +01:00
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/** The ol map. */
|
2021-11-12 14:54:54 +01:00
|
|
|
private OpenLayerMap olMap;
|
2020-11-19 15:19:27 +01:00
|
|
|
|
2021-09-08 14:40:36 +02:00
|
|
|
private Map<String, LayerObject> mapDetailLayerObjects = new HashMap<String, LayerObject>();
|
|
|
|
private Map<String, LayerObject> mapBaseLayerObjects = new HashMap<String, LayerObject>();
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
private HandlerManager layerManagerBus = new HandlerManager("");
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2020-11-03 13:09:08 +01:00
|
|
|
private HandlerManager applicationBus;
|
|
|
|
|
2021-09-07 17:29:56 +02:00
|
|
|
private org.gcube.application.geoportalcommon.shared.LayerItem baseLayerFromISProfile;
|
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
private OverlayLayerManager overlayLayerManager;
|
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new layer manager.
|
2020-11-19 15:19:27 +01:00
|
|
|
*
|
|
|
|
* @param applicationBus the application bus
|
2020-10-27 16:04:34 +01:00
|
|
|
*/
|
2020-11-03 13:09:08 +01:00
|
|
|
public LayerManager(HandlerManager applicationBus) {
|
|
|
|
this.applicationBus = applicationBus;
|
2021-10-14 11:34:04 +02:00
|
|
|
overlayLayerManager = new OverlayLayerManager(applicationBus);
|
2020-10-29 15:18:14 +01:00
|
|
|
bindEvents();
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Bind events.
|
|
|
|
*/
|
2020-10-29 15:18:14 +01:00
|
|
|
private void bindEvents() {
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
layerManagerBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-10-29 15:18:14 +01:00
|
|
|
@Override
|
2020-10-30 12:19:51 +01:00
|
|
|
public void onQueryInteraction(final QueryDataEvent queryEvent) {
|
2021-07-30 14:57:08 +02:00
|
|
|
// GeoportalDataViewerConstants.print("fired QueryDataEvent:
|
|
|
|
// "+queryEvent.toString());
|
|
|
|
|
|
|
|
if (queryEvent.getGeoQuery() != null) {
|
2020-10-29 15:18:14 +01:00
|
|
|
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
|
2021-07-30 14:57:08 +02:00
|
|
|
String mongoItemId = queryEvent.getMongoItemId();
|
|
|
|
|
|
|
|
GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2()
|
|
|
|
+ "," + selectDataInfo.getY2() + ")");
|
|
|
|
|
2020-10-29 15:18:14 +01:00
|
|
|
BoundsMap mapBBOX = new BoundsMap();
|
2020-10-29 17:48:20 +01:00
|
|
|
double minX = queryEvent.getGeoQuery().getX1();
|
|
|
|
double minY = queryEvent.getGeoQuery().getY1();
|
2020-10-29 17:08:29 +01:00
|
|
|
Coordinate centerCoordinate = new Coordinate(minX, minY);
|
2021-09-01 12:51:06 +02:00
|
|
|
centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(),
|
|
|
|
MAP_PROJECTION.EPSG_4326.getName());
|
2020-10-29 17:08:29 +01:00
|
|
|
mapBBOX.setLowerLeftX(centerCoordinate.getX());
|
|
|
|
mapBBOX.setLowerLeftY(centerCoordinate.getY());
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-10-29 17:48:20 +01:00
|
|
|
// double maxX = olMap.getExtent().getUpperRightX();
|
|
|
|
// double maxY = olMap.getExtent().getUpperRightY();
|
|
|
|
double maxX = queryEvent.getGeoQuery().getX2();
|
|
|
|
double maxY = queryEvent.getGeoQuery().getY2();
|
2021-07-30 14:57:08 +02:00
|
|
|
centerCoordinate = new Coordinate(maxX, maxY);
|
2021-09-01 12:51:06 +02:00
|
|
|
centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(),
|
|
|
|
MAP_PROJECTION.EPSG_4326.getName());
|
2020-10-29 17:08:29 +01:00
|
|
|
mapBBOX.setUpperRightX(centerCoordinate.getX());
|
|
|
|
mapBBOX.setUpperRightY(centerCoordinate.getY());
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2021-09-01 12:51:06 +02:00
|
|
|
mapBBOX.setCrs(MAP_PROJECTION.EPSG_4326.getName());
|
2021-07-30 14:57:08 +02:00
|
|
|
|
|
|
|
GWT.log("Bounds is: " + mapBBOX);
|
|
|
|
GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES);
|
|
|
|
// GeoportalDataViewerConstants.print("calling getDataResult");
|
2021-09-07 17:29:56 +02:00
|
|
|
|
2021-09-08 14:40:36 +02:00
|
|
|
List<LayerObject> listLO = new ArrayList<LayerObject>();
|
2021-09-09 15:55:33 +02:00
|
|
|
// for querying base layers
|
2021-09-08 14:40:36 +02:00
|
|
|
listLO.addAll(mapBaseLayerObjects.values());
|
2021-09-09 15:55:33 +02:00
|
|
|
|
|
|
|
// for querying detail layers only in this case
|
|
|
|
if (olMap.getCurrentResolution() < OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
|
2021-10-14 11:34:04 +02:00
|
|
|
Collection<LayerObject> collLO = mapDetailLayerObjects.values();
|
|
|
|
listLO.addAll(collLO);
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
ArrayList<LayerObject> layerVisibility = new ArrayList<LayerObject>(collLO.size());
|
|
|
|
layerVisibility.addAll(collLO);
|
2022-09-06 14:53:19 +02:00
|
|
|
// Managing layer visibility. If a layer is not visible has to be not queryable
|
2021-10-14 11:34:04 +02:00
|
|
|
for (LayerObject layerObject : layerVisibility) {
|
|
|
|
String layerName = layerObject.getLayerItem().getName();
|
|
|
|
boolean isLayerVisible = olMap.isLayerVisible(layerName);
|
2022-09-06 14:53:19 +02:00
|
|
|
if (!isLayerVisible) {
|
|
|
|
GWT.log("From querying removing layername: " + layerName + ", it is not visible");
|
2021-10-14 11:34:04 +02:00
|
|
|
listLO.remove(layerObject);
|
|
|
|
}
|
|
|
|
// else {
|
|
|
|
// ExtentWrapped layerExtent = olMap.getSourceExtentForLayer(layerName);
|
|
|
|
// if(layerExtent!=null) {
|
|
|
|
// ExtentWrapped centerQueryPoint = new ExtentWrapped(minX, minY, maxX,maxY);
|
|
|
|
//
|
|
|
|
// boolean contains = layerExtent.containsExtent(centerQueryPoint);
|
|
|
|
// GWT.log("layer: "+layerName + " contains the queried BBOX: "+contains);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
}
|
2021-09-08 14:40:36 +02:00
|
|
|
}
|
2021-09-09 15:55:33 +02:00
|
|
|
|
2021-08-31 18:21:17 +02:00
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(),
|
|
|
|
mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(),
|
|
|
|
new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
|
2021-07-30 14:57:08 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
// GeoportalDataViewerConstants.print("on Failure DataResult:
|
|
|
|
// "+caught.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
|
|
|
|
|
2021-08-02 16:45:05 +02:00
|
|
|
GWT.log("GeoNaDataObject's is/are " + listGeonaDataObjects.size());
|
2022-10-13 16:53:33 +02:00
|
|
|
|
2021-09-09 15:55:33 +02:00
|
|
|
// GWT.log("GeoNaDataObject's: " + listGeonaDataObjects);
|
2022-09-06 14:53:19 +02:00
|
|
|
// GeoportalDataViewerConstants.print("GeoNaDataObject's:
|
|
|
|
// "+listGeonaDataObjects);
|
2022-10-13 16:53:33 +02:00
|
|
|
GWT.log("GeoNaDataObject's must be revisited");
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2022-09-06 14:53:19 +02:00
|
|
|
List<FeatureRow> theFeatures = null;
|
2021-09-09 15:55:33 +02:00
|
|
|
|
2021-09-08 17:13:59 +02:00
|
|
|
MapEventType sourceEvent = queryEvent.getSourceMapEventType();
|
2021-08-31 18:21:17 +02:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
// TODO SWTCH FOR EARCH ITEM TYPE
|
|
|
|
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
|
2022-09-06 14:53:19 +02:00
|
|
|
GWT.log("GeoNaDataObject: " + geoNaDataObject);
|
2021-07-30 14:57:08 +02:00
|
|
|
List<FeatureRow> features = geoNaDataObject.getFeatures();
|
2022-09-06 14:53:19 +02:00
|
|
|
LayerItem layerItem = geoNaDataObject.getSourceLayerObject().getLayerItem();
|
|
|
|
GWT.log(" features: " + features);
|
|
|
|
GWT.log(" layerItem: " + layerItem);
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2022-09-06 14:53:19 +02:00
|
|
|
GWT.log("GeoNaDataObject Source layer item name: " + layerItem.getName());
|
2021-09-07 17:29:56 +02:00
|
|
|
|
2022-09-06 14:53:19 +02:00
|
|
|
HashMap<String, List<FeatureRow>> listUniqueProducts = new HashMap<String, List<FeatureRow>>();
|
|
|
|
// Clustering features for productId
|
2021-07-30 14:57:08 +02:00
|
|
|
if (features != null && features.size() > 0) {
|
2021-07-30 15:57:25 +02:00
|
|
|
String theProductId = null;
|
2022-09-06 14:53:19 +02:00
|
|
|
for (FeatureRow fRow : features) {
|
|
|
|
List<String> productIdLst = fRow.getMapProperties().get("product_id");
|
|
|
|
if (productIdLst != null) {
|
2021-07-30 15:57:25 +02:00
|
|
|
theProductId = productIdLst.get(0);
|
2022-09-06 14:53:19 +02:00
|
|
|
if (theProductId != null) {
|
|
|
|
List<FeatureRow> listFeatures = listUniqueProducts
|
|
|
|
.get(theProductId);
|
|
|
|
if (listFeatures == null) {
|
|
|
|
listFeatures = new ArrayList<FeatureRow>();
|
2021-07-30 14:57:08 +02:00
|
|
|
}
|
2022-09-06 14:53:19 +02:00
|
|
|
|
|
|
|
listFeatures.add(fRow);
|
|
|
|
listUniqueProducts.put(theProductId, listFeatures);
|
2021-07-30 14:57:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-06 14:53:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GWT.log("listUniqueProducts keyset: " + listUniqueProducts.keySet());
|
|
|
|
|
|
|
|
// USING ONLY THE FIRST FEATURE IN THE LIST
|
|
|
|
if (features != null && features.size() > 0) {
|
|
|
|
|
|
|
|
// I need to show exactly the feature with produc_id == recordId
|
|
|
|
if (mongoItemId != null) {
|
|
|
|
GWT.log("MongoItemId is not null: " + mongoItemId);
|
|
|
|
// Searching mongoItemId in the list of product
|
|
|
|
theFeatures = listUniqueProducts.get(mongoItemId);
|
|
|
|
GWT.log("Loaded mongoItemId == product_id with id: " + mongoItemId
|
|
|
|
+ ", the features are: " + theFeatures);
|
|
|
|
|
|
|
|
// the recordId/mongoItemId to show has been passed but not found into
|
|
|
|
// list of
|
|
|
|
// FeatureRow
|
|
|
|
if (theFeatures == null || theFeatures.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If mongoItemId not passed
|
2021-07-30 14:57:08 +02:00
|
|
|
if (mongoItemId == null) {
|
2022-09-06 14:53:19 +02:00
|
|
|
GWT.log("MongoItemId is null");
|
|
|
|
// Checking if the features returned belonging to detail layers (not
|
|
|
|
// centroids).
|
|
|
|
if (listUniqueProducts.isEmpty()) {
|
2021-09-07 17:29:56 +02:00
|
|
|
// in this case the feature/s returned is/are a (detail) layer/s
|
|
|
|
// belonging
|
2021-08-31 18:21:17 +02:00
|
|
|
// to a record/concessione (not centroid layer),
|
2021-09-07 17:29:56 +02:00
|
|
|
// so calling show popuup info on detail layers if the
|
|
|
|
// following events are true.
|
2021-09-09 15:55:33 +02:00
|
|
|
if (sourceEvent.equals(MapEventType.MOUSE_CLICK) && olMap
|
|
|
|
.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) {
|
|
|
|
|
|
|
|
// Here I need to pass only the visible layers
|
2021-09-07 17:29:56 +02:00
|
|
|
showPopupInfoForLayer(listGeonaDataObjects,
|
2021-09-08 14:40:36 +02:00
|
|
|
queryEvent.getQueryClickExtent());
|
2021-09-07 17:29:56 +02:00
|
|
|
}
|
2021-08-31 18:21:17 +02:00
|
|
|
return;
|
|
|
|
}
|
2022-09-06 14:53:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// The features of the first centroid layer selected
|
|
|
|
if (theFeatures == null || theFeatures.size() == 0) {
|
|
|
|
for (String theProductId : listUniqueProducts.keySet()) {
|
|
|
|
|
|
|
|
theFeatures = listUniqueProducts.get(theProductId);
|
|
|
|
|
|
|
|
if (theFeatures.size() > 0)
|
|
|
|
break;
|
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
}
|
|
|
|
}
|
2021-07-30 15:57:25 +02:00
|
|
|
|
2022-09-06 14:53:19 +02:00
|
|
|
// Displaying popup info for centroid layer passing the first feature
|
2021-09-09 15:55:33 +02:00
|
|
|
if (sourceEvent.equals(MapEventType.MOUSE_CLICK)
|
|
|
|
|| sourceEvent.equals(MapEventType.ADDED_CENTROID_LAYER_TO_MAP)) {
|
2022-09-06 14:53:19 +02:00
|
|
|
GWT.log("Source event is: " + MapEventType.MOUSE_CLICK + ", or "
|
|
|
|
+ MapEventType.ADDED_CENTROID_LAYER_TO_MAP);
|
|
|
|
|
|
|
|
// Displaying popup info for centroid layer passing the first feature
|
|
|
|
showPopupInfoForCentroidLayer(geoNaDataObject, theFeatures.get(0),
|
2021-09-08 14:40:36 +02:00
|
|
|
queryEvent.getQueryClickExtent().getCenter());
|
|
|
|
}
|
2021-07-30 15:57:25 +02:00
|
|
|
|
2021-08-31 18:21:17 +02:00
|
|
|
if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) {
|
2022-09-06 14:53:19 +02:00
|
|
|
GWT.log("Current zoom level is less than QUERY_MIN_ZOOM_LEVEL, Loading all layers of any product");
|
|
|
|
for (String theProductId : listUniqueProducts.keySet()) {
|
|
|
|
GWT.log("Loading layers of theProductId: " + theProductId);
|
|
|
|
// retrieving and showing WMS layers of a concessione if the ZOOM
|
|
|
|
// level
|
|
|
|
// is >
|
|
|
|
// QUERY_MIN_ZOOM_LEVEL
|
|
|
|
|
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId(
|
|
|
|
"concessione", theProductId,
|
|
|
|
new AsyncCallback<List<LayerConcessioneDV>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
2021-08-31 18:21:17 +02:00
|
|
|
}
|
|
|
|
|
2022-09-06 14:53:19 +02:00
|
|
|
@Override
|
|
|
|
public void onSuccess(List<LayerConcessioneDV> result) {
|
|
|
|
|
|
|
|
for (LayerConcessioneDV layer : result) {
|
|
|
|
GWT.log("Adding layer: "
|
|
|
|
+ layer.getLayerName());
|
|
|
|
addLayer("concessione", layer.getLayerName(),
|
|
|
|
layer.getLayerName(),
|
|
|
|
layer.getWmsLink(), false, false,
|
|
|
|
layer.getLayerUUID(), true,
|
|
|
|
OLMapManager.LAYER_DETAIL_MIN_RESOLUTION,
|
|
|
|
OLMapManager.LAYER_DETAIL_MAX_RESOLUTION,
|
|
|
|
layer.getRefersTo());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2021-08-31 18:21:17 +02:00
|
|
|
} else {
|
2021-09-02 12:54:39 +02:00
|
|
|
// removing all WMS detail layers if the ZOOM level is <
|
|
|
|
// QUERY_MIN_ZOOM_LEVEL
|
2021-09-08 14:40:36 +02:00
|
|
|
removeAllDetailLayers();
|
2021-08-31 18:21:17 +02:00
|
|
|
}
|
2020-11-25 18:44:09 +01:00
|
|
|
}
|
2020-11-24 12:58:13 +01:00
|
|
|
}
|
2022-10-13 16:53:33 +02:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
2020-11-24 12:58:13 +01:00
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
});
|
2020-10-29 15:18:14 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
layerManagerBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() {
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
@Override
|
|
|
|
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
|
2021-07-30 14:57:08 +02:00
|
|
|
GWT.log("Fired into layerManagerBus " + addedLayerToMapEvent);
|
2020-11-19 15:19:27 +01:00
|
|
|
applicationBus.fireEvent(addedLayerToMapEvent);
|
|
|
|
}
|
|
|
|
});
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
layerManagerBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() {
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
@Override
|
|
|
|
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
|
2021-07-30 14:57:08 +02:00
|
|
|
GWT.log("Fired into layerManagerBus " + zoomOutEvent);
|
2021-09-08 14:40:36 +02:00
|
|
|
removeAllDetailLayers();
|
2020-11-19 15:19:27 +01:00
|
|
|
applicationBus.fireEvent(zoomOutEvent);
|
|
|
|
}
|
|
|
|
});
|
2020-10-29 15:18:14 +01:00
|
|
|
}
|
2021-09-09 15:55:33 +02:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
/**
|
|
|
|
* Removes the all detail layers.
|
|
|
|
*/
|
2021-09-08 14:40:36 +02:00
|
|
|
public void removeAllDetailLayers() {
|
|
|
|
mapDetailLayerObjects.clear();
|
|
|
|
olMap.removeAllDetailLayers();
|
2021-10-14 11:34:04 +02:00
|
|
|
overlayLayerManager.resetLayers();
|
2021-09-08 14:40:36 +02:00
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/**
|
2020-11-19 15:19:27 +01:00
|
|
|
* Parses the geona references.
|
2020-10-27 16:04:34 +01:00
|
|
|
*
|
2022-10-13 16:53:33 +02:00
|
|
|
* @param layerObject the layer object
|
|
|
|
* @param fRow the f row
|
2020-11-19 15:19:27 +01:00
|
|
|
* @return the show details event
|
2020-10-27 16:04:34 +01:00
|
|
|
*/
|
2022-10-13 16:53:33 +02:00
|
|
|
private ShowDetailsEvent parseGeonaReferences(LayerObject layerObject, FeatureRow fRow) {
|
2021-07-30 14:57:08 +02:00
|
|
|
if (fRow == null)
|
2020-11-19 15:19:27 +01:00
|
|
|
return null;
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
List<String> productIds = fRow.getMapProperties().get("product_id");
|
2021-07-30 14:57:08 +02:00
|
|
|
if (productIds != null && productIds.size() > 0) {
|
|
|
|
String productId = productIds.get(0);
|
2020-11-19 15:19:27 +01:00
|
|
|
String itemName = "Dettagli Prodotto";
|
|
|
|
List<String> listName = fRow.getMapProperties().get("nome");
|
2021-07-30 14:57:08 +02:00
|
|
|
if (listName != null && listName.size() > 0) {
|
2020-11-19 15:19:27 +01:00
|
|
|
itemName = listName.get(0);
|
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
LayerObjectType layerObjectType = layerObject.getType();
|
|
|
|
return new ShowDetailsEvent(layerObjectType != null ? layerObjectType.name() : null, layerObject.getUcid(),
|
|
|
|
productId, itemName, fRow);
|
2020-11-19 15:19:27 +01:00
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
return null;
|
|
|
|
}
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
// ******************************** LAYERS Management
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds the layer.
|
|
|
|
*
|
|
|
|
* @param object the object
|
|
|
|
*/
|
|
|
|
public void addLayer(LayerObject object) {
|
|
|
|
GWT.log("Layers management : Add layer " + object);
|
|
|
|
|
|
|
|
switch (object.getType()) {
|
|
|
|
case BASE_LAYER: {
|
|
|
|
GWT.log("ERROR : cannot add base layers ");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GENERIC_LAYER: {
|
|
|
|
GWT.log("SUPPORT TO EXTERNAL LAYERS TO BE IMPLEMENTED");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PROJECT_LAYER: {
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case INDEX_LAYER: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/**
|
2020-11-19 15:19:27 +01:00
|
|
|
* Adds the layer.
|
2020-10-27 16:04:34 +01:00
|
|
|
*
|
2022-10-13 16:53:33 +02:00
|
|
|
* @param lot the lot
|
|
|
|
* @param layerTitle the layer title
|
|
|
|
* @param layerName the layer name
|
|
|
|
* @param wmsLink the wms link
|
|
|
|
* @param isBase the is base
|
|
|
|
* @param displayInLayerSwitcher the display in layer switcher
|
|
|
|
* @param UUID the uuid
|
|
|
|
* @param asDetailLayer the as detail layer
|
|
|
|
* @param minResolution the min resolution
|
|
|
|
* @param maxResolution the max resolution
|
|
|
|
* @param profileID the profile ID
|
|
|
|
* @param projectID the project ID
|
2020-10-27 16:04:34 +01:00
|
|
|
*/
|
2022-10-13 16:53:33 +02:00
|
|
|
public void addLayer(final LayerObjectType lot, final String layerTitle, final String layerName,
|
2021-07-30 14:57:08 +02:00
|
|
|
final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID,
|
2021-09-09 15:55:33 +02:00
|
|
|
final boolean asDetailLayer, Double minResolution, Double maxResolution,
|
2022-10-13 16:53:33 +02:00
|
|
|
String profileID, String projectID) {
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
// final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent();
|
|
|
|
//
|
|
|
|
// if(layersPanel.getLayerItems().size()==0)
|
|
|
|
// westPanel.mask("Adding..."+layerName, "x-mask-loading");
|
|
|
|
// else
|
|
|
|
// layersPanel.mask("Adding..."+layerName, "x-mask-loading");
|
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE;
|
2020-10-27 16:04:34 +01:00
|
|
|
// Info.display("Adding Layer", layerName);
|
2021-09-02 12:54:39 +02:00
|
|
|
|
|
|
|
if (wmsLink == null || wmsLink.isEmpty()) {
|
2021-08-31 18:21:17 +02:00
|
|
|
GeoportalDataViewerConstants.printJs("Skipping add layer for wmsLink as null or empty");
|
|
|
|
return;
|
|
|
|
}
|
2021-09-02 12:54:39 +02:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName,
|
|
|
|
new AsyncCallback<GeoInformationForWMSRequest>() {
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
}
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
@Override
|
|
|
|
public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) {
|
|
|
|
|
|
|
|
GWT.log("Parsed WMS Request returned: " + geoInfoWMS);
|
|
|
|
// ddLayerByWms(featureType, layerTitle, result.getLayerName(),
|
|
|
|
// result.getWmsRequest(), result.getBaseWmsServiceHost(), true, isBase,
|
|
|
|
// displayInLayerSwitcher, (ArrayList<String>)
|
|
|
|
// result.getStyles().getGeoStyles(), result.getWmsRequest(), false,
|
|
|
|
// result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis());
|
|
|
|
|
|
|
|
LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(),
|
|
|
|
geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase,
|
|
|
|
displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(),
|
|
|
|
geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(),
|
2021-09-02 12:54:39 +02:00
|
|
|
geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis(), minResolution, maxResolution);
|
2021-09-09 15:55:33 +02:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
LayerObject lo = new LayerObject();
|
|
|
|
lo.setLayerItem(layerItem);
|
2022-10-13 16:53:33 +02:00
|
|
|
lo.setType(lot);
|
|
|
|
lo.setProjectId(projectID);
|
2021-08-31 18:21:17 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
String key = layerItem.getName(); // should be unique //
|
|
|
|
//layerObjects.put(key, lo);
|
2021-09-09 15:55:33 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
if (!asDetailLayer) { // is a base layer LayerObject blo =
|
2021-09-08 14:40:36 +02:00
|
|
|
LayerObject blo = mapBaseLayerObjects.get(key);
|
2021-09-09 15:55:33 +02:00
|
|
|
if (blo == null) {
|
2021-08-31 18:21:17 +02:00
|
|
|
olMap.addWMSLayer(layerItem);
|
2021-09-08 14:40:36 +02:00
|
|
|
mapBaseLayerObjects.put(key, lo);
|
2021-09-09 15:55:33 +02:00
|
|
|
} else {
|
2021-09-08 14:40:36 +02:00
|
|
|
GWT.log("Skipping base layer " + key + " already added to Map");
|
|
|
|
}
|
2021-09-09 15:55:33 +02:00
|
|
|
} else {
|
2021-09-08 14:40:36 +02:00
|
|
|
LayerObject dlo = mapDetailLayerObjects.get(key);
|
2021-09-09 15:55:33 +02:00
|
|
|
if (dlo == null) {
|
2021-09-08 14:40:36 +02:00
|
|
|
mapDetailLayerObjects.put(key, lo);
|
2021-08-31 18:21:17 +02:00
|
|
|
olMap.addWMSDetailLayer(layerItem);
|
2022-10-13 16:53:33 +02:00
|
|
|
overlayLayerManager.addLayerItem(lo); // overlayLayerManager.show(); } else {
|
2021-09-08 14:40:36 +02:00
|
|
|
GWT.log("Skipping detail layer " + key + " already added to Map");
|
|
|
|
}
|
2021-09-02 12:54:39 +02:00
|
|
|
}
|
2022-10-13 16:53:33 +02:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
}
|
|
|
|
});
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|
2020-11-19 15:19:27 +01:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
/**
|
|
|
|
* Adds the index layer.
|
|
|
|
*
|
|
|
|
* @param layer the layer
|
|
|
|
*/
|
|
|
|
public void addIndexLayer(IndexLayer layer) {
|
|
|
|
|
|
|
|
addLayer(LayerObjectType.INDEX_LAYER, null, null, layer.getLayer().getOgcLinks().get("wms"), false, false, null, false,
|
|
|
|
null, null, null, null);
|
|
|
|
|
|
|
|
// toLayerItem(null, null, null, null, null, false, false, false, null, null,
|
|
|
|
// false, null, false, null, null, null, null)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/**
|
2020-11-19 15:19:27 +01:00
|
|
|
* To layer item.
|
2020-10-27 16:04:34 +01:00
|
|
|
*
|
2021-07-30 14:57:08 +02:00
|
|
|
* @param layerType the layer type
|
|
|
|
* @param layerTitle the layer title
|
|
|
|
* @param layerName the layer name
|
|
|
|
* @param layerURL the layer URL
|
|
|
|
* @param mapServerHost the map server host
|
|
|
|
* @param isExternal the is external
|
|
|
|
* @param isBase the is base
|
2020-10-27 16:04:34 +01:00
|
|
|
* @param displayInLayerSwitcher the display in layer switcher
|
2021-07-30 14:57:08 +02:00
|
|
|
* @param styles the styles
|
|
|
|
* @param wmsLink the wms link
|
|
|
|
* @param onTop the on top
|
|
|
|
* @param wmsNotStandardParams the wms not standard params
|
|
|
|
* @param isNcWms the is nc wms
|
|
|
|
* @param UUID the uuid
|
|
|
|
* @param zAxis the z axis
|
2021-09-06 16:39:12 +02:00
|
|
|
* @param minResolution the min resolution
|
|
|
|
* @param maxResolution the max resolution
|
2020-11-19 15:19:27 +01:00
|
|
|
* @return the layer item
|
2020-10-27 16:04:34 +01:00
|
|
|
*/
|
2021-07-30 14:57:08 +02:00
|
|
|
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,
|
2021-09-02 12:54:39 +02:00
|
|
|
boolean isNcWms, String UUID, ZAxis zAxis, Double minResolution, Double maxResolution) {
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
// GWT.log("Add addLayerByWms 1");
|
2020-10-29 15:18:14 +01:00
|
|
|
LayerItem layerItem = new LayerItem();
|
|
|
|
layerItem.setBaseLayer(isBase);
|
|
|
|
layerItem.setTitle(layerTitle);
|
|
|
|
layerItem.setName(layerName);
|
|
|
|
layerItem.setUrl(layerURL);
|
|
|
|
layerItem.setMapServerHost(mapServerHost);
|
2021-07-30 14:57:08 +02:00
|
|
|
// l.setExternal(isExternal);
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setOpacity(1d);
|
|
|
|
layerItem.setBuffer(2);
|
2020-11-19 15:19:27 +01:00
|
|
|
layerItem.setWmsLink(wmsLink);
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setWmsNotStandardParams(wmsNotStandardParams);
|
|
|
|
layerItem.setNcWms(isNcWms);
|
|
|
|
layerItem.setUUID(UUID);
|
|
|
|
layerItem.setZAxis(zAxis);
|
2021-09-02 12:54:39 +02:00
|
|
|
layerItem.setMinResolution(minResolution);
|
|
|
|
layerItem.setMaxResolution(maxResolution);
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
switch (layerType) {
|
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
// TODO IMPLEMENT THIS CASE
|
|
|
|
case RASTER_BASELAYER:
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
// l.setHasLegend(false);
|
2021-07-30 14:57:08 +02:00
|
|
|
layerItem.setBaseLayer(true);
|
|
|
|
layerItem.setTrasparent(false);
|
|
|
|
layerItem.setClickData(false);
|
|
|
|
break;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
case FEATURE_TYPE:
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
// CASE FEATURE TYPE
|
|
|
|
layerItem.setBaseLayer(false);
|
|
|
|
layerItem.setClickData(true);
|
|
|
|
layerItem.setTrasparent(true);
|
|
|
|
break;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
GWT.log("styles " + styles);
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2021-07-30 14:57:08 +02:00
|
|
|
if (styles != null && styles.size() > 0) {
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setHasLegend(true);
|
|
|
|
layerItem.setDefaultStyle(styles.get(0));
|
|
|
|
layerItem.setStyle(styles.get(0));
|
|
|
|
layerItem.setStyles(styles);
|
2021-07-30 14:57:08 +02:00
|
|
|
} else {
|
2020-11-19 15:19:27 +01:00
|
|
|
String style = URLUtil.getValueOfParameter("styles", wmsLink);
|
2021-07-30 14:57:08 +02:00
|
|
|
if (style != null) { // CASE OF STYLE ="";
|
|
|
|
// TENTATIVE TO GET LEGEND
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setHasLegend(true);
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
GWT.log("Built layer: " + layerItem);
|
2020-11-19 15:19:27 +01:00
|
|
|
return layerItem;
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|
2021-07-30 14:57:08 +02:00
|
|
|
|
2021-09-07 17:29:56 +02:00
|
|
|
/**
|
|
|
|
* Show popup info for layer.
|
|
|
|
*
|
2021-10-14 11:34:04 +02:00
|
|
|
* @param listGeoNaDataObject the list geo na data object
|
2022-09-06 14:53:19 +02:00
|
|
|
* @param queryClick the query click
|
2021-09-07 17:29:56 +02:00
|
|
|
*/
|
2021-09-09 15:55:33 +02:00
|
|
|
public void showPopupInfoForLayer(List<GeoNaSpatialQueryResult> listGeoNaDataObject, ExtentWrapped queryClick) {
|
|
|
|
|
2021-09-07 17:29:56 +02:00
|
|
|
ScrollPanel scrollPanel = new ScrollPanel();
|
2021-10-15 17:51:09 +02:00
|
|
|
final FlowPanel flowPanel = new FlowPanel();
|
|
|
|
flowPanel.getElement().getStyle().setProperty("maxHeight", "600px");
|
2021-09-09 15:55:33 +02:00
|
|
|
scrollPanel.add(flowPanel);
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2021-11-22 10:25:09 +01:00
|
|
|
List<Button> listOpenProject = new ArrayList<Button>();
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2021-10-15 17:51:09 +02:00
|
|
|
final Button expandButton = new Button("Expand");
|
|
|
|
expandButton.setType(ButtonType.LINK);
|
|
|
|
expandButton.setIcon(IconType.EXPAND);
|
|
|
|
expandButton.getElement().setId("expand-query");
|
|
|
|
expandButton.setTitle("Show this view in new Window");
|
2021-09-09 15:55:33 +02:00
|
|
|
|
2021-10-15 17:51:09 +02:00
|
|
|
flowPanel.add(expandButton);
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2021-10-15 17:51:09 +02:00
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void execute() {
|
|
|
|
Element buttonElement = DOM.getElementById("expand-query");
|
|
|
|
Event.sinkEvents(buttonElement, Event.ONCLICK);
|
|
|
|
Event.setEventListener(buttonElement, new EventListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBrowserEvent(Event event) {
|
|
|
|
if (Event.ONCLICK == event.getTypeInt()) {
|
|
|
|
expandButton.setVisible(false);
|
2022-09-06 14:53:19 +02:00
|
|
|
// hiding the Open Project in expand mode (Modal Window)
|
2021-11-22 10:25:09 +01:00
|
|
|
for (Button butt : listOpenProject) {
|
|
|
|
butt.setVisible(false);
|
|
|
|
}
|
2021-10-15 17:51:09 +02:00
|
|
|
flowPanel.getElement().getStyle().setProperty("maxHeight", "100%");
|
|
|
|
int width = Window.getClientWidth() * 75 / 100;
|
|
|
|
int height = Window.getClientHeight() * 70 / 100;
|
|
|
|
Coordinate center = queryClick.getCenter();
|
|
|
|
double x = center.getX();
|
|
|
|
double y = center.getY();
|
2022-09-06 14:53:19 +02:00
|
|
|
// "with center x: "+x +", y: "+y;
|
2021-10-18 10:11:21 +02:00
|
|
|
ModalWindow mw = new ModalWindow("Query results...", width, height);
|
2021-10-15 17:51:09 +02:00
|
|
|
mw.add(flowPanel);
|
|
|
|
mw.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2021-09-09 11:38:25 +02:00
|
|
|
String prevConcessioneName = "";
|
2021-09-07 17:29:56 +02:00
|
|
|
for (GeoNaSpatialQueryResult geoNaSpatialQueryResult : listGeoNaDataObject) {
|
2021-09-09 15:55:33 +02:00
|
|
|
try {
|
|
|
|
GWT.log("baseLayerFromISProfile.getName() :" + baseLayerFromISProfile.getName());
|
|
|
|
LayerObject lo = geoNaSpatialQueryResult.getSourceLayerObject();
|
|
|
|
LayerItem sourceLI = lo.getLayerItem();
|
|
|
|
|
|
|
|
String layerSourceName = sourceLI.getName();
|
|
|
|
|
|
|
|
// skipping centroid layer
|
|
|
|
if (layerSourceName == null
|
|
|
|
|| layerSourceName.compareToIgnoreCase(baseLayerFromISProfile.getName()) == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
List<FeatureRow> features = geoNaSpatialQueryResult.getFeatures();
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
if (features == null || features.isEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2022-10-13 16:53:33 +02:00
|
|
|
GWT.log("showPopupInfoForLayer must be REVISITED");
|
|
|
|
/*
|
|
|
|
* String nomeConcessione = lo.getSourceConcessione().getNome(); if
|
|
|
|
* (prevConcessioneName.compareTo(nomeConcessione) != 0) { String
|
|
|
|
* concessioneIntro = nomeConcessione.length() > 100 ?
|
|
|
|
* StringUtil.ellipsize(nomeConcessione, 100) : nomeConcessione; Heading heading
|
|
|
|
* = new Heading(4, concessioneIntro); heading.setTitle(nomeConcessione);
|
|
|
|
* heading.getElement().getStyle().setMarginBottom(10, Unit.PX);
|
|
|
|
* flowPanel.add(heading);
|
|
|
|
*
|
|
|
|
* Button buttOpenProject = new Button("Open Project"); final String buttId =
|
|
|
|
* "open-details-" + Random.nextInt(); Element bEl =
|
|
|
|
* buttOpenProject.getElement(); bEl.setId(buttId);
|
|
|
|
* bEl.getStyle().setPaddingLeft(0, Unit.PX);
|
|
|
|
* buttOpenProject.setType(ButtonType.LINK);
|
|
|
|
*
|
|
|
|
* if (buttOpenProject != null) { flowPanel.add(buttOpenProject);
|
|
|
|
* buttOpenProject.setType(ButtonType.LINK);
|
|
|
|
* Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
*
|
|
|
|
* @Override public void execute() { Element buttonElement =
|
|
|
|
* DOM.getElementById(buttId); Event.sinkEvents(buttonElement, Event.ONCLICK);
|
|
|
|
* Event.setEventListener(buttonElement, new EventListener() {
|
|
|
|
*
|
|
|
|
* @Override public void onBrowserEvent(Event event) { if (Event.ONCLICK ==
|
|
|
|
* event.getTypeInt()) { applicationBus.fireEvent(new
|
|
|
|
* ShowDetailsEvent("concessione", lo.getSourceConcessione().getItemId(),
|
|
|
|
* nomeConcessione, null));
|
|
|
|
*
|
|
|
|
* } } }); } }); } listOpenProject.add(buttOpenProject);
|
|
|
|
*
|
|
|
|
* HTML subText = new HTML(
|
|
|
|
* "<p style=\"color:#999; font-size:14px; margin:5px 0 5px 0;\">Layers and Properties</p>"
|
|
|
|
* ); flowPanel.add(subText); }
|
|
|
|
*
|
|
|
|
* prevConcessioneName = nomeConcessione;
|
|
|
|
*
|
|
|
|
* Label layerLabel = new Label(); layerLabel.setType(LabelType.INFO);
|
|
|
|
*
|
|
|
|
* String layerName = StringUtil.fullNameToLayerName(layerSourceName, ":");
|
|
|
|
* layerLabel.setText(layerName); layerLabel.setTitle(layerSourceName);
|
|
|
|
* layerLabel.getElement().getStyle().setMarginTop(10, Unit.PX);
|
|
|
|
* layerLabel.getElement().getStyle().setMarginBottom(5, Unit.PX);
|
|
|
|
* flowPanel.add(layerLabel);
|
|
|
|
*
|
|
|
|
* GWT.log("Displaying " + features.size() + " features"); FlexTable intFlex =
|
|
|
|
* new FlexTable(); intFlex.setCellPadding(1); intFlex.setCellSpacing(1);
|
|
|
|
* intFlex.getElement().addClassName("table-feature"); intFlex.setHTML(0, 0, new
|
|
|
|
* HTML("Feature Id").toString());
|
|
|
|
*
|
|
|
|
* int i = 0; for (FeatureRow feature : features) {
|
|
|
|
*
|
|
|
|
* intFlex.setHTML(i + 1, 0, new HTML(feature.getId()).toString());
|
|
|
|
*
|
|
|
|
* // Showing properties belonging to concessioni layer Map<String,
|
|
|
|
* List<String>> entries = feature.getMapProperties();
|
|
|
|
*
|
|
|
|
* if (entries.size() == 0) { // Adding this row to show "no property" for
|
|
|
|
* feature // intFlex.setHTML(i + 1, 1, new
|
|
|
|
* HTML("<i>No property</i>").toString()); } int j = 0; for (String key :
|
|
|
|
* entries.keySet()) { List<String> theValues = entries.get(key); String
|
|
|
|
* valueToDisplay = ""; for (String value : theValues) { valueToDisplay += value
|
|
|
|
* + ", ";
|
|
|
|
*
|
|
|
|
* } valueToDisplay = valueToDisplay.substring(0, valueToDisplay.length() - 2);
|
|
|
|
*
|
|
|
|
* // adding the keys only of first feature row. They are equal for all features
|
|
|
|
* // (beloning to same layer). if (i == 0) intFlex.setHTML(0, j + 1, new
|
|
|
|
* HTML(key).toString());
|
|
|
|
*
|
|
|
|
* intFlex.setHTML(i + 1, j + 1, new HTML(valueToDisplay).toString()); j++;
|
|
|
|
*
|
|
|
|
* } i++; } flowPanel.add(intFlex);
|
|
|
|
*
|
|
|
|
*/
|
2021-09-09 15:55:33 +02:00
|
|
|
|
|
|
|
} catch (Exception e) {
|
2021-10-14 11:34:04 +02:00
|
|
|
GeoportalDataViewerConstants.printJs("Error: " + e.getMessage());
|
2021-09-07 17:29:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-08 14:40:36 +02:00
|
|
|
olMap.showPopup(scrollPanel.toString(), queryClick.getCenter());
|
2021-09-07 17:29:56 +02:00
|
|
|
|
|
|
|
}
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2021-09-06 17:15:38 +02:00
|
|
|
/**
|
|
|
|
* Show popup info for centroid layer.
|
|
|
|
*
|
2021-09-07 17:29:56 +02:00
|
|
|
* @param geoNaDataObject the geo na data object
|
|
|
|
* @param feature the feature
|
2021-09-06 17:15:38 +02:00
|
|
|
* @param onFailureCenterTo the on failure center to
|
|
|
|
*/
|
|
|
|
public void showPopupInfoForCentroidLayer(GeoNaSpatialQueryResult geoNaDataObject, FeatureRow feature,
|
|
|
|
Coordinate onFailureCenterTo) {
|
|
|
|
|
|
|
|
FlexTable flex = new FlexTable();
|
|
|
|
flex.setCellPadding(1);
|
|
|
|
flex.setCellSpacing(1);
|
|
|
|
flex.getElement().addClassName("popup-table");
|
|
|
|
VerticalPanel vpPanel = new VerticalPanel();
|
|
|
|
vpPanel.add(flex);
|
|
|
|
|
|
|
|
if (feature == null) {
|
|
|
|
flex.setHTML(0, 0, new HTML("No data available").toString());
|
2021-09-07 17:29:56 +02:00
|
|
|
olMap.showPopup(vpPanel.toString(), onFailureCenterTo);
|
2021-09-06 17:15:38 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Showing properties belonging to concessioni centroid layer
|
|
|
|
Map<String, List<String>> entries = feature.getMapProperties();
|
|
|
|
|
|
|
|
String nome = "";
|
|
|
|
String descrizione = "";
|
|
|
|
String date = "";
|
|
|
|
|
|
|
|
for (String key : entries.keySet()) {
|
|
|
|
String theValue = entries.get(key).get(0);
|
|
|
|
if (key.equalsIgnoreCase("nome")) {
|
|
|
|
nome = theValue != null ? theValue : "";
|
|
|
|
} else if (key.equalsIgnoreCase("descrizione")) {
|
|
|
|
descrizione = theValue != null ? theValue : "";
|
|
|
|
} else if (key.equalsIgnoreCase("date_scavo")) {
|
|
|
|
date = theValue != null ? theValue : "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GeoportalDataViewerConstants.print("0: "+nome);
|
|
|
|
flex.setHTML(0, 0, new HTML(nome).toString());
|
|
|
|
try {
|
|
|
|
descrizione = StringUtil.ellipsize(descrizione, 100);
|
|
|
|
GWT.log("reduced: " + descrizione);
|
|
|
|
} catch (Exception e) {
|
|
|
|
GWT.log("error: " + e.getMessage());
|
|
|
|
}
|
|
|
|
// GeoportalDataViewerConstants.print("1: "+descrizione);
|
|
|
|
flex.setText(1, 0, descrizione);
|
|
|
|
// GeoportalDataViewerConstants.print("2: "+date);
|
|
|
|
date = StringUtil.formatDate(date);
|
|
|
|
flex.setHTML(2, 0, new HTML("<code>" + date + "</code>").toString());
|
|
|
|
|
|
|
|
if (geoNaDataObject.getMapImages() != null) {
|
|
|
|
for (String key : geoNaDataObject.getMapImages().keySet()) {
|
|
|
|
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages().get(key);
|
|
|
|
GWT.log("Adding images: " + listUI);
|
|
|
|
if (listUI != null && listUI.size() > 0) {
|
|
|
|
UploadedImageDV img = listUI.get(0);
|
2022-09-06 14:53:19 +02:00
|
|
|
if (img != null && img.getListWsContent() != null) {
|
2021-09-06 17:15:38 +02:00
|
|
|
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size() - 1);
|
2021-11-10 14:29:45 +01:00
|
|
|
String theImgHTML = "<img src=\"" + wsContent.getLink() + "\"></img>";
|
2021-09-06 17:15:38 +02:00
|
|
|
GWT.log("theImgHTML: " + theImgHTML);
|
|
|
|
// GeoportalDataViewerConstants.print("The row are:
|
|
|
|
// "+flex.getRowCount());
|
|
|
|
flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GWT.log("The selected Feature is: " + feature);
|
|
|
|
// GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
|
|
|
|
FeatureRow theFeature = feature;
|
|
|
|
Button button = new Button("Open Details");
|
|
|
|
button.getElement().setId("open-details");
|
|
|
|
button.setType(ButtonType.LINK);
|
|
|
|
|
|
|
|
if (button != null) {
|
|
|
|
vpPanel.add(button);
|
|
|
|
button.setType(ButtonType.LINK);
|
|
|
|
button.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onClick(ClickEvent event) {
|
2022-10-13 16:53:33 +02:00
|
|
|
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject(), theFeature);
|
2021-09-06 17:15:38 +02:00
|
|
|
applicationBus.fireEvent(toEvent);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Coordinate centerTo = null;
|
|
|
|
GWT.log("geometry is: " + feature.getGeometry());
|
|
|
|
if (feature.getGeometry() != null) {
|
|
|
|
GWT.log("trasforming geometry: " + feature.getGeometry().getToJSONObject());
|
|
|
|
|
|
|
|
Geometry geom = new GeoJson().readGeometry(feature.getGeometry().getToJSONObject(), null);
|
|
|
|
|
|
|
|
// POINT
|
|
|
|
if (geom.getType().equalsIgnoreCase("Point")) {
|
|
|
|
GWT.log("geometry: is a point");
|
|
|
|
String coordinateJSON = feature.getGeometry().getCoordinatesJSON();
|
|
|
|
JSONArray centerJSON = (JSONArray) JSONParser.parseStrict(coordinateJSON);
|
|
|
|
// Coordinate center = OLFactory.createCoordinate(
|
|
|
|
// new Double(centerJSON.get(0).toString()),
|
|
|
|
// new Double(centerJSON.get(1).toString()));
|
|
|
|
|
|
|
|
Coordinate center = new Coordinate(new Double(centerJSON.get(0).toString()),
|
|
|
|
new Double(centerJSON.get(1).toString()));
|
|
|
|
|
|
|
|
if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
|
|
|
|
|
|
|
|
center = MapUtils.transformCoordiante(center, MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
}
|
|
|
|
centerTo = center;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Extent geomExtent = geom.getExtent();
|
|
|
|
|
|
|
|
Coordinate lower = OLFactory.createCoordinate(geomExtent.getLowerLeftX(), geomExtent.getLowerLeftY());
|
|
|
|
Coordinate upper = OLFactory.createCoordinate(geomExtent.getUpperRightX(), geomExtent.getUpperRightY());
|
|
|
|
Coordinate lowerCoord = lower;
|
|
|
|
Coordinate upperCoord = upper;
|
|
|
|
if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
|
|
|
|
|
|
|
|
lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(),
|
|
|
|
upperCoord.getY());
|
|
|
|
|
|
|
|
centerTo = new Coordinate(ew.getCenter().getX(), ew.getCenter().getY());
|
|
|
|
|
|
|
|
}
|
|
|
|
GWT.log("center is: " + centerTo);
|
|
|
|
}
|
|
|
|
|
|
|
|
// fallback
|
|
|
|
if (centerTo == null)
|
|
|
|
centerTo = onFailureCenterTo;
|
|
|
|
|
|
|
|
olMap.showPopup(vpPanel.toString(), centerTo);
|
|
|
|
|
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void execute() {
|
|
|
|
Element buttonElement = DOM.getElementById("open-details");
|
|
|
|
Event.sinkEvents(buttonElement, Event.ONCLICK);
|
|
|
|
Event.setEventListener(buttonElement, new EventListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBrowserEvent(Event event) {
|
|
|
|
if (Event.ONCLICK == event.getTypeInt()) {
|
2022-10-13 16:53:33 +02:00
|
|
|
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject(),
|
|
|
|
theFeature);
|
2021-09-06 17:15:38 +02:00
|
|
|
applicationBus.fireEvent(toEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2022-09-06 14:53:19 +02:00
|
|
|
|
2021-09-06 17:15:38 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-27 16:41:30 +01:00
|
|
|
/**
|
|
|
|
* Sets the ol map.
|
|
|
|
*
|
|
|
|
* @param olMap the new ol map
|
|
|
|
*/
|
2021-11-12 16:57:57 +01:00
|
|
|
public void setOLMap(OpenLayerMap olMap) {
|
2020-10-27 16:41:30 +01:00
|
|
|
this.olMap = olMap;
|
|
|
|
}
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2020-11-19 15:19:27 +01:00
|
|
|
/**
|
|
|
|
* Gets the layer manager bus.
|
|
|
|
*
|
|
|
|
* @return the layer manager bus
|
|
|
|
*/
|
|
|
|
public HandlerManager getLayerManagerBus() {
|
|
|
|
return layerManagerBus;
|
|
|
|
}
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
/**
|
|
|
|
* Sets the base layer from is profile.
|
|
|
|
*
|
|
|
|
* @param layerItem the new base layer from is profile
|
|
|
|
*/
|
2021-09-07 17:29:56 +02:00
|
|
|
public void setBaseLayerFromIsProfile(org.gcube.application.geoportalcommon.shared.LayerItem layerItem) {
|
|
|
|
this.baseLayerFromISProfile = layerItem;
|
|
|
|
}
|
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
/**
|
|
|
|
* Gets the base layer from IS proile.
|
|
|
|
*
|
|
|
|
* @return the base layer from IS proile
|
|
|
|
*/
|
2021-09-07 17:29:56 +02:00
|
|
|
public org.gcube.application.geoportalcommon.shared.LayerItem getBaseLayerFromISProile() {
|
|
|
|
return baseLayerFromISProfile;
|
|
|
|
}
|
|
|
|
|
2021-10-14 11:34:04 +02:00
|
|
|
/**
|
|
|
|
* Gets the overlay layer manager.
|
|
|
|
*
|
|
|
|
* @return the overlay layer manager
|
|
|
|
*/
|
|
|
|
public OverlayLayerManager getOverlayLayerManager() {
|
|
|
|
return overlayLayerManager;
|
|
|
|
}
|
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|