#21946 managed detail layer with min/max resolution

This commit is contained in:
Francesco Mangiacrapa 2021-09-02 12:54:39 +02:00
parent 94d1ffbe05
commit 6900a988f2
5 changed files with 205 additions and 118 deletions

View File

@ -81,7 +81,6 @@ public class GeoportalDataViewer implements EntryPoint {
int attempt = 0; int attempt = 0;
// https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6&centermap=12.45%2C42.98 // https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6&centermap=12.45%2C42.98
/** /**
@ -171,7 +170,7 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("The layerItem is: " + layerItem); GWT.log("The layerItem is: " + layerItem);
layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false,
null, false); null, false, null, null);
if (paramGeonaItemID != null) { if (paramGeonaItemID != null) {
if (paramGeonaItemType == null) { if (paramGeonaItemType == null) {
@ -194,8 +193,6 @@ public class GeoportalDataViewer implements EntryPoint {
} }
/** /**
* Update window size. * Update window size.
*/ */
@ -241,7 +238,8 @@ public class GeoportalDataViewer implements EntryPoint {
if (showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) { if (showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId, new AsyncCallback<ConcessioneDV>() { GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId,
new AsyncCallback<ConcessioneDV>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -267,7 +265,8 @@ public class GeoportalDataViewer implements EntryPoint {
@Override @Override
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) { public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
GWT.log("Fired AddedLayerToMapEvent " + addedLayerToMapEvent.getLayerItem()); GWT.log("Fired AddedLayerToMapEvent " + addedLayerToMapEvent.getLayerItem());
//GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem()); // GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent
// "+addedLayerToMapEvent.getLayerItem());
try { try {
@ -326,7 +325,6 @@ public class GeoportalDataViewer implements EntryPoint {
} }
}); });
applicationBus.addHandler(MapExtentToEvent.TYPE, new MapExtentToEventHandler() { applicationBus.addHandler(MapExtentToEvent.TYPE, new MapExtentToEventHandler() {
@Override @Override
@ -340,21 +338,26 @@ public class GeoportalDataViewer implements EntryPoint {
private void performWFSQueryOnCentroid(RecordDV record) { private void performWFSQueryOnCentroid(RecordDV record) {
if (record != null) { if (record != null) {
GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV) +" with mongo item id: "+record.getItemId()); GWT.log("record instanceof ConcessioneDV: " + (record instanceof ConcessioneDV) + " with mongo item id: "
//GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV)); + record.getItemId());
// GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: "
// +(record instanceof ConcessioneDV));
if (record instanceof ConcessioneDV) { if (record instanceof ConcessioneDV) {
ConcessioneDV concessioneDV = (ConcessioneDV) record; ConcessioneDV concessioneDV = (ConcessioneDV) record;
Double x = concessioneDV.getCentroidLong(); Double x = concessioneDV.getCentroidLong();
Double y = concessioneDV.getCentroidLat(); Double y = concessioneDV.getCentroidLat();
GWT.log("X: " + x + ", Y:" + y); GWT.log("X: " + x + ", Y:" + y);
if (x != null && y != null) { if (x != null && y != null) {
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y),
MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName());
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, record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP)); layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord,
record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP));
} else { } else {
GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y); GeoportalDataViewerConstants.printJs(
"I cannot select the point one or both coordiantes are null. X: " + x + ", Y:" + y);
} }
} }
} }

View File

@ -221,7 +221,8 @@ public class LayerManager {
GWT.log("the product id is: " + theProductId); GWT.log("the product id is: " + theProductId);
// retrieving and showing WMS layers of a concessione if the ZOOM level is > QUERY_MIN_ZOOM_LEVEL // retrieving and showing WMS layers of a concessione if the ZOOM level is >
// QUERY_MIN_ZOOM_LEVEL
if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) { if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) {
GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId( GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId(
"concessione", theProductId, "concessione", theProductId,
@ -239,18 +240,16 @@ public class LayerManager {
for (LayerConcessioneDV layer : result) { for (LayerConcessioneDV layer : result) {
addLayer("concessione", layer.getLayerName(), addLayer("concessione", layer.getLayerName(),
layer.getLayerName(), layer.getWmsLink(), layer.getLayerName(), layer.getWmsLink(),
false, false, layer.getLayerUUID(), true); false, false, layer.getLayerUUID(), true,
// LayerItem li = new LayerItem(); OLMapManager.LAYER_DETAIL_MIN_RESOLUTION,
// li.setBaseLayer(false); OLMapManager.LAYER_DETAIL_MAX_RESOLUTION);
// li.setWmsLink(layer.getWmsLink());
// li.setTitle(layer.getLayerName());
// olMap.addWMSLayer(li);
} }
} }
}); });
} else { } else {
// removing all WMS detail layers if the ZOOM level is < QUERY_MIN_ZOOM_LEVEL // removing all WMS detail layers if the ZOOM level is <
// QUERY_MIN_ZOOM_LEVEL
olMap.removeAllDetailLayers(); olMap.removeAllDetailLayers();
} }
@ -455,10 +454,12 @@ public class LayerManager {
* @param displayInLayerSwitcher the display in layer switcher * @param displayInLayerSwitcher the display in layer switcher
* @param UUID the uuid * @param UUID the uuid
* @param asDetailLayer the as detail layer * @param asDetailLayer the as detail layer
* @param minResolution the min resolution
* @param maxResolution the max resolution
*/ */
public void addLayer(final String geonaItemType, final String layerTitle, final String layerName, public void addLayer(final String geonaItemType, final String layerTitle, final String layerName,
final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID, final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID,
final boolean asDetailLayer) { final boolean asDetailLayer, Double minResolution, Double maxResolution) {
// final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); // final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent();
// //
@ -498,23 +499,23 @@ public class LayerManager {
geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase, geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase,
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()); 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.getMapServerHost() + "/layer/" + layerItem.getName();
// //if a detail layer checking if it is already added to map // if a detail layer checking if it is already added to map
// if (asDetailLayer && layerObjects.containsKey(key)) { if (asDetailLayer && layerObjects.containsKey(key)) {
// GWT.log("Skipping layer already added to Map"); GWT.log("Skipping layer " + key + " already added to Map");
// } else { } else {
layerObjects.put(key, lo); layerObjects.put(key, lo);
if (!asDetailLayer) if (!asDetailLayer)
olMap.addWMSLayer(layerItem); olMap.addWMSLayer(layerItem);
else else
olMap.addWMSDetailLayer(layerItem); olMap.addWMSDetailLayer(layerItem);
// } }
} }
}); });
} }
@ -537,12 +538,14 @@ public class LayerManager {
* @param isNcWms the is nc wms * @param isNcWms the is nc wms
* @param UUID the uuid * @param UUID the uuid
* @param zAxis the z axis * @param zAxis the z axis
* @param minResolution the min resolution
* @param maxResolution the max resolution
* @return the layer item * @return the layer item
*/ */
private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL, private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL,
String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher,
ArrayList<String> styles, String wmsLink, boolean onTop, HashMap<String, String> wmsNotStandardParams, ArrayList<String> styles, String wmsLink, boolean onTop, HashMap<String, String> wmsNotStandardParams,
boolean isNcWms, String UUID, ZAxis zAxis) { boolean isNcWms, String UUID, ZAxis zAxis, Double minResolution, Double maxResolution) {
// GWT.log("Add addLayerByWms 1"); // GWT.log("Add addLayerByWms 1");
LayerItem layerItem = new LayerItem(); LayerItem layerItem = new LayerItem();
@ -559,6 +562,8 @@ public class LayerManager {
layerItem.setNcWms(isNcWms); layerItem.setNcWms(isNcWms);
layerItem.setUUID(UUID); layerItem.setUUID(UUID);
layerItem.setZAxis(zAxis); layerItem.setZAxis(zAxis);
layerItem.setMinResolution(minResolution);
layerItem.setMaxResolution(maxResolution);
switch (layerType) { switch (layerType) {

View File

@ -37,6 +37,9 @@ public class OLMapManager {
private Double zoomEnd = null; private Double zoomEnd = null;
private ol.Extent dragEndExtent = null; private ol.Extent dragEndExtent = null;
public static final int QUERY_MIN_ZOOM_LEVEL = 13; public static final int QUERY_MIN_ZOOM_LEVEL = 13;
public static final Double LAYER_DETAIL_MIN_RESOLUTION = 0.10;
public static final Double LAYER_DETAIL_MAX_RESOLUTION = 13.0;
/** /**
* Instantiates a new OL map manager. * Instantiates a new OL map manager.
@ -192,6 +195,7 @@ public class OLMapManager {
private void checkSelectQuery(MapEventType mapEventType) { private void checkSelectQuery(MapEventType mapEventType) {
GWT.log("Zoom is:" + olMap.getCurrentZoomLevel()); GWT.log("Zoom is:" + olMap.getCurrentZoomLevel());
GWT.log("Resolution is:" + olMap.getCurrentResolution());
if (dragStartExtent != null && olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) { if (dragStartExtent != null && olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) {
dragEndExtent = olMap.getExtent(); dragEndExtent = olMap.getExtent();

View File

@ -334,12 +334,20 @@ public abstract class OpenLayerOSM {
LayerOptions layerOptions = OLFactory.createOptions(); LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(imageWMSSource); 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); Image wmsLayer = new Image(layerOptions);
// visibleLayerItems // visibleLayerItems
map.addLayer(wmsLayer); map.addLayer(wmsLayer);
GWT.log("Fired the event Added Layer"); GWT.log("Added WMSLayer for layer: "+layerItem.getName());
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
} }
@ -372,6 +380,13 @@ public abstract class OpenLayerOSM {
LayerOptions layerOptions = OLFactory.createOptions(); LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(imageWMSSource); 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); Image wmsLayer = new Image(layerOptions);
@ -380,7 +395,7 @@ public abstract class OpenLayerOSM {
map.addLayer(wmsLayer); map.addLayer(wmsLayer);
wmsDetailsLayerMap.put(key, wmsLayer); wmsDetailsLayerMap.put(key, wmsLayer);
GWT.log("Fired the event Added Layer"); 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 detail layer with key: " + key + " already exists, skipping");
@ -389,6 +404,9 @@ public abstract class OpenLayerOSM {
} }
public void removeAllDetailLayers() { public void removeAllDetailLayers() {
/*
if (wmsDetailsLayerMap == null) if (wmsDetailsLayerMap == null)
return; return;
@ -400,6 +418,7 @@ public abstract class OpenLayerOSM {
} }
wmsDetailsLayerMap.clear(); wmsDetailsLayerMap.clear();
*/
} }
@ -596,6 +615,15 @@ public abstract class OpenLayerOSM {
return map.getView().getZoom(); return map.getView().getZoom();
} }
/**
* Gets the current zoom level.
*
* @return the current zoom level
*/
public double getCurrentResolution() {
return map.getView().getResolution();
}
/** /**
* Gets the bbox. * Gets the bbox.
* *

View File

@ -9,7 +9,6 @@ import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Property; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.Property;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
// TODO: Auto-generated Javadoc
/** /**
* The Class LayerItem. * The Class LayerItem.
* *
@ -115,6 +114,10 @@ public class LayerItem implements Serializable, Cloneable {
/** The Constant INT_TYPE. */ /** The Constant INT_TYPE. */
public static final String INT_TYPE = "xsd:int"; public static final String INT_TYPE = "xsd:int";
public Double minResolution;
public Double maxResolution;
/** /**
* Instantiates a new layer item. * Instantiates a new layer item.
*/ */
@ -849,6 +852,47 @@ public class LayerItem implements Serializable, Cloneable {
this.zAxisSelected = zAxisSelected; this.zAxisSelected = zAxisSelected;
} }
/**
* Sets the max resolution.
*
* @param maxResolution the new max resolution
*/
public void setMaxResolution(Double maxResolution) {
this.maxResolution = maxResolution;
}
/**
* Sets the min resolution.
*
* @param minResolution the new min resolution
*/
public void setMinResolution(Double minResolution) {
this.minResolution = minResolution;
}
/**
* Gets the min resolution.
*
* @return the min resolution
*/
public Double getMinResolution() {
return minResolution;
}
/**
* Gets the max resolution.
*
* @return the max resolution
*/
public Double getMaxResolution() {
return maxResolution;
}
/**
* To string.
*
* @return the string
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -910,9 +954,12 @@ public class LayerItem implements Serializable, Cloneable {
builder.append(zAxis); builder.append(zAxis);
builder.append(", zAxisSelected="); builder.append(", zAxisSelected=");
builder.append(zAxisSelected); builder.append(zAxisSelected);
builder.append(", minResolution=");
builder.append(minResolution);
builder.append(", maxResolution=");
builder.append(maxResolution);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }