#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

@ -44,7 +44,7 @@ import ol.Coordinate;
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 27, 2020 * Oct 27, 2020
*/ */
public class GeoportalDataViewer implements EntryPoint { public class GeoportalDataViewer implements EntryPoint {
@ -52,37 +52,36 @@ public class GeoportalDataViewer implements EntryPoint {
public final static String APP_DIV = "geoportal-data-viewer"; public final static String APP_DIV = "geoportal-data-viewer";
/** The ol map. */ /** The ol map. */
//private OpenLayerOSM olMap = null; // private OpenLayerOSM olMap = null;
/** The main panel. */ /** The main panel. */
private GeonaDataViewMainPanel mainPanel; private GeonaDataViewMainPanel mainPanel;
/** The param wms request. */ /** The param wms request. */
private String paramWmsRequest; private String paramWmsRequest;
/** The param UUID. */ /** The param UUID. */
//private String paramUUID; // private String paramUUID;
private String paramGeonaItemType; private String paramGeonaItemType;
/** The param layer title. */ /** The param layer title. */
private String paramLayerTitle; private String paramLayerTitle;
private HandlerManager applicationBus = new HandlerManager(""); private HandlerManager applicationBus = new HandlerManager("");
/** The layer manager. */ /** The layer manager. */
private LayerManager layerManager = new LayerManager(applicationBus); private LayerManager layerManager = new LayerManager(applicationBus);
private String paramGeonaItemID; private String paramGeonaItemID;
private GeoNaDataViewerProfile geonaDataViewerProfile; private GeoNaDataViewerProfile geonaDataViewerProfile;
private OLMapManager olMapMng = null; private OLMapManager olMapMng = null;
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
/** /**
* This is the entry point method. * This is the entry point method.
@ -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) {
@ -193,9 +192,7 @@ public class GeoportalDataViewer implements EntryPoint {
bindEvents(); bindEvents();
} }
/** /**
* Update window size. * Update window size.
*/ */
@ -204,91 +201,93 @@ public class GeoportalDataViewer implements EntryPoint {
int rootHeight = getClientHeight(); int rootHeight = getClientHeight();
int height = rootHeight; int height = rootHeight;
mainPanel.setPanelsHeight(height); mainPanel.setPanelsHeight(height);
GWT.log("Set height: "+height); GWT.log("Set height: " + height);
} }
public int getClientHeight() { public int getClientHeight() {
RootPanel principalDiv = RootPanel.get(APP_DIV); RootPanel principalDiv = RootPanel.get(APP_DIV);
int topBorder = principalDiv.getAbsoluteTop(); int topBorder = principalDiv.getAbsoluteTop();
int rootHeight = Window.getClientHeight() - topBorder; int rootHeight = Window.getClientHeight() - topBorder;
return rootHeight; return rootHeight;
} }
/** /**
* Bind events. * Bind events.
*/ */
private void bindEvents() { private void bindEvents() {
applicationBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() { applicationBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() {
@Override @Override
public void onShowDetails(ShowDetailsEvent showDetailsEvent) { public void onShowDetails(ShowDetailsEvent showDetailsEvent) {
GWT.log("Fired event: "+showDetailsEvent); GWT.log("Fired event: " + showDetailsEvent);
String geonaMongoId = showDetailsEvent.getGeonaMongoID(); String geonaMongoId = showDetailsEvent.getGeonaMongoID();
if(geonaMongoId==null) { if (geonaMongoId == null) {
Window.alert("Item Id not found"); Window.alert("Item Id not found");
return; return;
} }
//TODO
boolean found = false;
GWT.log("Product with id: "+geonaMongoId+" found? "+found);
if(!found) {
if(showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId, new AsyncCallback<ConcessioneDV>() { // TODO
boolean found = false;
@Override GWT.log("Product with id: " + geonaMongoId + " found? " + found);
public void onFailure(Throwable caught) {
Window.alert(caught.getMessage()); if (!found) {
mainPanel.hidePanelDetails();
if (showDetailsEvent.getGeonaItemType().equalsIgnoreCase("Concessione")) {
}
GeoportalDataViewerServiceAsync.Util.getInstance().getConcessioneForId(geonaMongoId,
@Override new AsyncCallback<ConcessioneDV>() {
public void onSuccess(ConcessioneDV concessioneDV) {
GWT.log("Showing: "+concessioneDV); @Override
mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef()); public void onFailure(Throwable caught) {
} Window.alert(caught.getMessage());
}); mainPanel.hidePanelDetails();
}
@Override
public void onSuccess(ConcessioneDV concessioneDV) {
GWT.log("Showing: " + concessioneDV);
mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
}
});
} }
} }
} }
}); });
applicationBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() { applicationBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() {
@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 {
attempt = 0; attempt = 0;
if(paramGeonaItemID!=null) { if (paramGeonaItemID != null) {
//waiting for record retrieved by service before calling the WFS // waiting for record retrieved by service before calling the WFS
final int MAX_RETRY = 7; final int MAX_RETRY = 7;
Timer timer = new com.google.gwt.user.client.Timer() { Timer timer = new com.google.gwt.user.client.Timer() {
@Override @Override
public void run() { public void run() {
attempt++; attempt++;
GWT.log("waiting got record tenative: "+attempt); GWT.log("waiting got record tenative: " + attempt);
RecordDV record = mainPanel.getDisplyedRecord(); RecordDV record = mainPanel.getDisplyedRecord();
if(record!=null) { if (record != null) {
this.cancel(); this.cancel();
GWT.log("cancelled timer"); GWT.log("cancelled timer");
performWFSQueryOnCentroid(record); performWFSQueryOnCentroid(record);
} }
if(attempt>MAX_RETRY) { if (attempt > MAX_RETRY) {
GWT.log("MAX_RETRY reached, cancelled timer"); GWT.log("MAX_RETRY reached, cancelled timer");
this.cancel(); this.cancel();
} }
@ -296,65 +295,69 @@ public class GeoportalDataViewer implements EntryPoint {
} }
}; };
timer.scheduleRepeating(1000); timer.scheduleRepeating(1000);
} }
}catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
} }
}); });
applicationBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() { applicationBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() {
@Override @Override
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) { public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
if(mainPanel.getDisplyedRecord()==null && !olMapMng.isQueryPointActive()) { if (mainPanel.getDisplyedRecord() == null && !olMapMng.isQueryPointActive()) {
olMapMng.hidePopInfo(); olMapMng.hidePopInfo();
olMapMng.removeDetailLayers(); olMapMng.removeDetailLayers();
} }
} }
}); });
applicationBus.addHandler(ClosedViewDetailsEvent.TYPE, new ClosedViewDetailsEventHandler() { applicationBus.addHandler(ClosedViewDetailsEvent.TYPE, new ClosedViewDetailsEventHandler() {
@Override @Override
public void onClosed(ClosedViewDetailsEvent closedViewDetailsEvent) { public void onClosed(ClosedViewDetailsEvent closedViewDetailsEvent) {
olMapMng.hidePopInfo(); olMapMng.hidePopInfo();
} }
}); });
applicationBus.addHandler(MapExtentToEvent.TYPE, new MapExtentToEventHandler() { applicationBus.addHandler(MapExtentToEvent.TYPE, new MapExtentToEventHandler() {
@Override @Override
public void onExtentEvent(MapExtentToEvent mapExtentToEvent) { public void onExtentEvent(MapExtentToEvent mapExtentToEvent) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
}); });
} }
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());
if(record instanceof ConcessioneDV) { // GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: "
// +(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),
GeoQuery select = olMapMng.toDataPointQuery(transfCoord,false); MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName());
GWT.log("GeoQuery: "+select); GeoQuery select = olMapMng.toDataPointQuery(transfCoord, false);
//GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); GWT.log("GeoQuery: " + select);
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP)); // GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
}else { layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord,
GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y); record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP));
} else {
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,27 +240,25 @@ 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();
} }
// if(queryEvent.getSourceMapEventType() != null && queryEvent.getSourceMapEventType().equals(MapEventType.MAP_ZOOM_END)) { // if(queryEvent.getSourceMapEventType() != null && queryEvent.getSourceMapEventType().equals(MapEventType.MAP_ZOOM_END)) {
// GWT.log("EVENT IS "+MapEventType.MAP_ZOOM_END +" retuning"); // GWT.log("EVENT IS "+MapEventType.MAP_ZOOM_END +" retuning");
// return; // return;
// } // }
//Showing properties belonging to concessioni centroid layer // Showing properties belonging to concessioni centroid layer
Map<String, List<String>> entries = feature.getMapProperties(); Map<String, List<String>> entries = feature.getMapProperties();
String nome = ""; String nome = "";
@ -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();
// //
@ -469,12 +470,12 @@ public class LayerManager {
final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE; final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE;
// Info.display("Adding Layer", layerName); // Info.display("Adding Layer", layerName);
if(wmsLink==null || wmsLink.isEmpty()) { if (wmsLink == null || wmsLink.isEmpty()) {
GeoportalDataViewerConstants.printJs("Skipping add layer for wmsLink as null or empty"); GeoportalDataViewerConstants.printJs("Skipping add layer for wmsLink as null or empty");
return; return;
} }
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName,
new AsyncCallback<GeoInformationForWMSRequest>() { new AsyncCallback<GeoInformationForWMSRequest>() {
@ -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

@ -333,13 +333,21 @@ 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();
*/
} }
@ -595,6 +614,15 @@ public abstract class OpenLayerOSM {
public double getCurrentZoomLevel() { public double getCurrentZoomLevel() {
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();
} }
} }