bug fixing on showing details

This commit is contained in:
Francesco Mangiacrapa 2021-09-08 14:40:36 +02:00
parent 0c5085ca62
commit 66d3bd0c0b
6 changed files with 143 additions and 87 deletions

View File

@ -20,6 +20,7 @@ import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEven
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils; import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel; import org.gcube.portlets.user.geoportaldataviewer.client.ui.GeonaDataViewMainPanel;
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
@ -315,7 +316,7 @@ public class GeoportalDataViewer implements EntryPoint {
if (mainPanel.getDisplyedRecord() == null && !olMapMng.isQueryPointActive()) { if (mainPanel.getDisplyedRecord() == null && !olMapMng.isQueryPointActive()) {
olMapMng.hidePopInfo(); olMapMng.hidePopInfo();
olMapMng.removeDetailLayers(); layerManager.removeAllDetailLayers();
} }
} }
@ -357,7 +358,8 @@ public class GeoportalDataViewer implements EntryPoint {
GeoQuery select = olMapMng.toDataPointQuery(transfCoord, false); GeoQuery select = olMapMng.toDataPointQuery(transfCoord, false);
GWT.log("GeoQuery: " + select); GWT.log("GeoQuery: " + select);
// GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); // GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, ExtentWrapped toExt = new ExtentWrapped(transfCoord.getX(), transfCoord.getY(), transfCoord.getX(), transfCoord.getY());
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, toExt,
record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP)); record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP));
} else { } else {
GeoportalDataViewerConstants.printJs( GeoportalDataViewerConstants.printJs(

View File

@ -77,7 +77,8 @@ public class LayerManager {
/** The ol map. */ /** The ol map. */
private OpenLayerOSM olMap; private OpenLayerOSM olMap;
private Map<String, LayerObject> layerObjects = new HashMap<String, LayerObject>(); private Map<String, LayerObject> mapDetailLayerObjects = new HashMap<String, LayerObject>();
private Map<String, LayerObject> mapBaseLayerObjects = new HashMap<String, LayerObject>();
private HandlerManager layerManagerBus = new HandlerManager(""); private HandlerManager layerManagerBus = new HandlerManager("");
@ -153,7 +154,15 @@ public class LayerManager {
// GWT.log("Layer found: "+layerName); // GWT.log("Layer found: "+layerName);
// } // }
List<LayerObject> listLO = new ArrayList<LayerObject>(layerObjects.values()); List<LayerObject> listLO = new ArrayList<LayerObject>();
//for querying base layers
listLO.addAll(mapBaseLayerObjects.values());
//for querying detail layers only in this case
if(olMap.getCurrentResolution()<OLMapManager.LAYER_DETAIL_MAX_RESOLUTION) {
listLO.addAll(mapDetailLayerObjects.values());
}
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(), GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(),
mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(),
new AsyncCallback<List<GeoNaSpatialQueryResult>>() { new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
@ -224,7 +233,7 @@ public class LayerManager {
//Here I need to pass only the visible layers //Here I need to pass only the visible layers
showPopupInfoForLayer(listGeonaDataObjects, showPopupInfoForLayer(listGeonaDataObjects,
queryEvent.getOnFailureCenterTo()); queryEvent.getQueryClickExtent());
} }
return; return;
} }
@ -239,8 +248,11 @@ public class LayerManager {
GWT.log("the product id is: " + theProductId); GWT.log("the product id is: " + theProductId);
// Displaying popup info for centroid layer // Displaying popup info for centroid layer
if (queryEvent.getSourceMapEventType()
.equals(MapEventType.MOUSE_CLICK)){
showPopupInfoForCentroidLayer(geoNaDataObject, feature, showPopupInfoForCentroidLayer(geoNaDataObject, feature,
queryEvent.getOnFailureCenterTo()); queryEvent.getQueryClickExtent().getCenter());
}
// retrieving and showing WMS layers of a concessione if the ZOOM level is > // retrieving and showing WMS layers of a concessione if the ZOOM level is >
// QUERY_MIN_ZOOM_LEVEL // QUERY_MIN_ZOOM_LEVEL
@ -271,7 +283,7 @@ public class LayerManager {
} else { } else {
// removing all WMS detail layers if the ZOOM level is < // removing all WMS detail layers if the ZOOM level is <
// QUERY_MIN_ZOOM_LEVEL // QUERY_MIN_ZOOM_LEVEL
olMap.removeAllDetailLayers(); removeAllDetailLayers();
} }
} }
} }
@ -295,12 +307,17 @@ public class LayerManager {
@Override @Override
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) { public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
GWT.log("Fired into layerManagerBus " + zoomOutEvent); GWT.log("Fired into layerManagerBus " + zoomOutEvent);
olMap.removeAllDetailLayers(); removeAllDetailLayers();
applicationBus.fireEvent(zoomOutEvent); applicationBus.fireEvent(zoomOutEvent);
} }
}); });
} }
public void removeAllDetailLayers() {
mapDetailLayerObjects.clear();
olMap.removeAllDetailLayers();
}
/** /**
* Parses the geona references. * Parses the geona references.
* *
@ -384,21 +401,31 @@ public class LayerManager {
displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(), displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(),
geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(),
geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis(), minResolution, maxResolution); geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis(), minResolution, maxResolution);
LayerObject lo = new LayerObject(); LayerObject lo = new LayerObject();
lo.setLayerItem(layerItem); lo.setLayerItem(layerItem);
lo.setItemType(geonaItemType); lo.setItemType(geonaItemType);
String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName(); String key = layerItem.getName(); //should be unique
//layerObjects.put(key, lo);
// if a detail layer checking if it is already added to map if(!asDetailLayer) {
if (asDetailLayer && layerObjects.containsKey(key)) { //is a base layer
GWT.log("Skipping layer " + key + " already added to Map"); LayerObject blo = mapBaseLayerObjects.get(key);
} else { if(blo==null) {
layerObjects.put(key, lo);
if (!asDetailLayer)
olMap.addWMSLayer(layerItem); olMap.addWMSLayer(layerItem);
else mapBaseLayerObjects.put(key, lo);
}else {
GWT.log("Skipping base layer " + key + " already added to Map");
}
}else {
LayerObject dlo = mapDetailLayerObjects.get(key);
if(dlo==null) {
mapDetailLayerObjects.put(key, lo);
olMap.addWMSDetailLayer(layerItem); olMap.addWMSDetailLayer(layerItem);
}else {
GWT.log("Skipping detail layer " + key + " already added to Map");
}
} }
} }
}); });
@ -496,7 +523,7 @@ public class LayerManager {
* @param onFailureCenterTo the on failure center to * @param onFailureCenterTo the on failure center to
*/ */
public void showPopupInfoForLayer(List<GeoNaSpatialQueryResult> listGeoNaDataObject, public void showPopupInfoForLayer(List<GeoNaSpatialQueryResult> listGeoNaDataObject,
Coordinate onFailureCenterTo) { ExtentWrapped queryClick) {
ScrollPanel scrollPanel = new ScrollPanel(); ScrollPanel scrollPanel = new ScrollPanel();
VerticalPanel vpPanel = new VerticalPanel(); VerticalPanel vpPanel = new VerticalPanel();
@ -569,7 +596,7 @@ public class LayerManager {
} }
olMap.showPopup(scrollPanel.toString(), onFailureCenterTo); olMap.showPopup(scrollPanel.toString(), queryClick.getCenter());
} }

View File

@ -72,8 +72,9 @@ public class OLMapManager {
// //
// } // }
ExtentWrapped toExt = new ExtentWrapped(coordinate.getX(), coordinate.getY(), coordinate.getX(), coordinate.getY());
GeoQuery select = toDataPointQuery(coordinate, true); GeoQuery select = toDataPointQuery(coordinate, true);
layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true, MapEventType.MOUSE_CLICK)); layerManagerBus.fireEvent(new QueryDataEvent(select, toExt, null, true, MapEventType.MOUSE_CLICK));
} }
@ -203,7 +204,8 @@ public class OLMapManager {
GWT.log("the distance is: " + dist); GWT.log("the distance is: " + dist);
if (dist > 5000 || startExt.containsExtent(endExt)) { if (dist > 5000 || startExt.containsExtent(endExt)) {
GeoQuery select = toDataBoxQuery(dragEndExtent); GeoQuery select = toDataBoxQuery(dragEndExtent);
layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter(), null, false, mapEventType)); //TODO THE AUTOMATICALLY SHOWING POP-UP ACCORDING TO ZOOM IS BUGGY
layerManagerBus.fireEvent(new QueryDataEvent(select, endExt, null, false, mapEventType));
} }
} else if (zoomStart != null && zoomEnd != null) { } else if (zoomStart != null && zoomEnd != null) {
@ -252,11 +254,11 @@ public class OLMapManager {
olMap.hidePopup(); olMap.hidePopup();
} }
/** // /**
* Removes the detail layers. // * Removes the detail layers.
*/ // */
public void removeDetailLayers() { // public void removeDetailLayers() {
olMap.removeAllDetailLayers(); // olMap.removeAllDetailLayers();
} // }
} }

View File

@ -1,12 +1,11 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events; package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
import ol.Coordinate;
/** /**
* The Class QueryDataEvent. * The Class QueryDataEvent.
* *
@ -17,7 +16,7 @@ import ol.Coordinate;
public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> { public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
public static Type<QueryDataEventHandler> TYPE = new Type<QueryDataEventHandler>(); public static Type<QueryDataEventHandler> TYPE = new Type<QueryDataEventHandler>();
private GeoQuery select; private GeoQuery select;
private Coordinate onFailureCenterTo; private ExtentWrapped queryClickExtent;
private String mongoItemId; private String mongoItemId;
private boolean onInit; private boolean onInit;
private MapEventType sourceMapEventType; private MapEventType sourceMapEventType;
@ -31,10 +30,10 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
* @param onInit the on init * @param onInit the on init
* @param mapEventType the map event type * @param mapEventType the map event type
*/ */
public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, String mongoItemId, boolean onInit, public QueryDataEvent(GeoQuery select, ExtentWrapped queryClickExtent, String mongoItemId, boolean onInit,
MapEventType mapEventType) { MapEventType mapEventType) {
this.select = select; this.select = select;
this.onFailureCenterTo = onFailureCenterTo; this.queryClickExtent = queryClickExtent;
this.mongoItemId = mongoItemId; this.mongoItemId = mongoItemId;
this.onInit = onInit; this.onInit = onInit;
this.sourceMapEventType = mapEventType; this.sourceMapEventType = mapEventType;
@ -88,13 +87,8 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
return select; return select;
} }
/** public ExtentWrapped getQueryClickExtent() {
* Gets the on failure center to. return queryClickExtent;
*
* @return the on failure center to
*/
public Coordinate getOnFailureCenterTo() {
return onFailureCenterTo;
} }
/** /**
@ -106,18 +100,13 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
return sourceMapEventType; return sourceMapEventType;
} }
/**
* To string.
*
* @return the string
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("QueryDataEvent [select="); builder.append("QueryDataEvent [select=");
builder.append(select); builder.append(select);
builder.append(", onFailureCenterTo="); builder.append(", queryClickExtent=");
builder.append(onFailureCenterTo); builder.append(queryClickExtent);
builder.append(", mongoItemId="); builder.append(", mongoItemId=");
builder.append(mongoItemId); builder.append(mongoItemId);
builder.append(", onInit="); builder.append(", onInit=");

View File

@ -58,6 +58,7 @@ import ol.source.Source;
import ol.source.Vector; import ol.source.Vector;
import ol.source.XyzOptions; import ol.source.XyzOptions;
// TODO: Auto-generated Javadoc
/** /**
* The Class OpenLayerOSM. * The Class OpenLayerOSM.
* *
@ -130,6 +131,8 @@ public abstract class OpenLayerOSM {
private java.util.Map<String, Image> wmsDetailsLayerMap; private java.util.Map<String, Image> wmsDetailsLayerMap;
private HashMap<String, Image> wmsLayerMap;
/** /**
* Instantiates a new open layer OSM. * Instantiates a new open layer OSM.
* *
@ -329,6 +332,13 @@ public abstract class OpenLayerOSM {
*/ */
public void addWMSLayer(LayerItem layerItem) { public void addWMSLayer(LayerItem layerItem) {
if (wmsLayerMap == null)
wmsLayerMap = new HashMap<String, Image>();
String key = layerItem.getName();
Image layer = wmsLayerMap.get(key);
if (layer == null) {
ImageWmsParams imageWMSParams = OLFactory.createOptions(); ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerItem.getName()); imageWMSParams.setLayers(layerItem.getName());
@ -355,8 +365,13 @@ public abstract class OpenLayerOSM {
// visibleLayerItems // visibleLayerItems
map.addLayer(wmsLayer); map.addLayer(wmsLayer);
wmsLayerMap.put(key, wmsLayer);
GWT.log("Added WMSLayer for layer: " + layerItem.getName()); GWT.log("Added WMSLayer for layer: " + layerItem.getName());
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
} else {
GWT.log("The WMS layer with key: " + key + " already exists, skipping");
}
} }
@ -370,7 +385,7 @@ public abstract class OpenLayerOSM {
if (wmsDetailsLayerMap == null) if (wmsDetailsLayerMap == null)
wmsDetailsLayerMap = new HashMap<String, Image>(); wmsDetailsLayerMap = new HashMap<String, Image>();
String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName(); String key = layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key); Image layer = wmsDetailsLayerMap.get(key);
@ -406,7 +421,7 @@ public abstract class OpenLayerOSM {
GWT.log("Added WMSDetailLayer for layer name: " + layerItem.getName()); GWT.log("Added WMSDetailLayer for layer name: " + layerItem.getName());
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
} else { } else {
GWT.log("The detail layer with key: " + key + " already exists, skipping"); GWT.log("The WMS detail layer with key: " + key + " already exists, skipping");
} }
} }
@ -418,16 +433,17 @@ public abstract class OpenLayerOSM {
// NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION // NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION
/* if (wmsDetailsLayerMap == null)
* if (wmsDetailsLayerMap == null) return; return;
*
* GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map"); GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map");
*
* for (String key : wmsDetailsLayerMap.keySet()) { Image layer = for (String key : wmsDetailsLayerMap.keySet()) {
* wmsDetailsLayerMap.get(key); map.removeLayer(layer); } Image layer = wmsDetailsLayerMap.get(key);
* map.removeLayer(layer);
* wmsDetailsLayerMap.clear(); }
*/
wmsDetailsLayerMap.clear();
} }
@ -698,12 +714,13 @@ public abstract class OpenLayerOSM {
return this.map != null; return this.map != null;
} }
/** /**
* Gets the layers. * Gets the layers from map.
* *
* @return the layers * @return the layers from map
*/ */
public List<String> getLayers() { public List<String> getLayersFromMap() {
Collection<Base> layers = map.getLayers(); Collection<Base> layers = map.getLayers();
List<String> layerNames = null; List<String> layerNames = null;
if (layers != null) { if (layers != null) {
@ -716,7 +733,7 @@ public abstract class OpenLayerOSM {
Source source = layerImage.getSource(); Source source = layerImage.getSource();
// GWT.log("source: "+source.toString()); // GWT.log("source: "+source.toString());
//GeoportalDataViewerConstants.printJsObj(source); // GeoportalDataViewerConstants.printJsObj(source);
String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source); String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source);
JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj); JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj);
// GWT.log("jsonObj: " + jsonObj.toString()); // GWT.log("jsonObj: " + jsonObj.toString());
@ -733,4 +750,22 @@ public abstract class OpenLayerOSM {
return layerNames; return layerNames;
} }
/**
* Gets the wms details layer map.
*
* @return the wms details layer map
*/
public java.util.Map<String, Image> getWmsDetailsLayerMap() {
return wmsDetailsLayerMap;
}
/**
* Gets the wms layer map.
*
* @return the wms layer map
*/
public HashMap<String, Image> getWmsLayerMap() {
return wmsLayerMap;
}
} }

View File

@ -151,6 +151,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
//List<UploadedImageDV> listUI = getUploadedImagesForId("Concessione", cId, 1); //List<UploadedImageDV> listUI = getUploadedImagesForId("Concessione", cId, 1);
Map<String, List<UploadedImageDV>> mapImages = new LinkedHashMap<String, List<UploadedImageDV>>(); Map<String, List<UploadedImageDV>> mapImages = new LinkedHashMap<String, List<UploadedImageDV>>();
mapImages.put(cId, Arrays.asList(uplImg)); mapImages.put(cId, Arrays.asList(uplImg));
//mapImages.put(cId, listUI);
geoDAO.setMapImages(mapImages); geoDAO.setMapImages(mapImages);
} catch (Exception e) { } catch (Exception e) {
LOG.warn("Error on loading uploaded images for concessione: " + cId, e); LOG.warn("Error on loading uploaded images for concessione: " + cId, e);