Remove collection from Map, implemented.
This commit is contained in:
parent
941805a596
commit
819032fb13
|
@ -302,43 +302,30 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
IndexLayerDV layer = toOpen.getIndexes().get(0);
|
||||
// Open Index Layer
|
||||
|
||||
layerManager.addIndexLayer(layer, toOpen.getUcd().getProfileID(), null);
|
||||
layerManager.addIndexLayer(layer, toOpen.getUcd().getProfileID());
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
applicationBus.addHandler(CloseCollectionEvent.TYPE, new CloseCollectionEventHandler() {
|
||||
|
||||
});
|
||||
@Override
|
||||
public void onCloseCollection(CloseCollectionEvent closeCollectionEvent) {
|
||||
|
||||
// applicationBus.addHandler(OpenCollectionEvent.TYPE, openCollectionEvent -> {
|
||||
// GWT.log("Fired event: " + openCollectionEvent);
|
||||
// // Check if ID is available
|
||||
// String collId = openCollectionEvent.getCollectionId();
|
||||
// ViewerConfiguration theConfig = GeoportalDataViewer.getStatus().getViewerConfig();
|
||||
//
|
||||
// Set<String> ucdIds = theConfig.getAvailableCollections().keySet();
|
||||
//
|
||||
// if (!ucdIds.contains(collId)) {
|
||||
// GWT.log("!! Collection " + collId + " is not available");
|
||||
// Window.alert("Collection " + collId + " is not found.");
|
||||
// } else {
|
||||
// GCubeCollection toOpen = theConfig.getAvailableCollections().get(collId);
|
||||
//
|
||||
// // Check if indexes is empty
|
||||
// if (toOpen.getIndexes() == null || toOpen.getIndexes().isEmpty()) {
|
||||
// GWT.log("Unexpected empty indexes in collection " + toOpen);
|
||||
// Window.alert("Cannot open collection index layer for " + toOpen.getUcd().getName() + ".");
|
||||
// }
|
||||
// // TODO Get Default Index Layer
|
||||
// // For now we just take the first - only 1 is expected
|
||||
// IndexLayerDV layer = toOpen.getIndexes().get(0);
|
||||
// // Open Index Layer
|
||||
//
|
||||
// layerManager.addIndexLayer(layer);
|
||||
//
|
||||
// }
|
||||
// });
|
||||
String collId = closeCollectionEvent.getCollectionId();
|
||||
|
||||
if (collId != null) {
|
||||
|
||||
ViewerConfiguration theConfig = GeoportalDataViewer.getStatus().getViewerConfig();
|
||||
GCubeCollection toCLose = theConfig.getAvailableCollections().get(collId);
|
||||
IndexLayerDV layer = toCLose.getIndexes().get(0);
|
||||
layerManager.removeIndexLayer(layer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
applicationBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() {
|
||||
|
||||
|
|
|
@ -578,15 +578,27 @@ public class LayerManager {
|
|||
* @param profileID the profile ID
|
||||
* @param projectDV the project DV
|
||||
*/
|
||||
public void addIndexLayer(IndexLayerDV layer, String profileID, ProjectDV projectDV) {
|
||||
public void addIndexLayer(IndexLayerDV layer, String profileID) {
|
||||
GWT.log("Adding index layer: " + layer);
|
||||
String wmsLink = layer.getLayer().getOgcLinks().get("wms");
|
||||
GWT.log("index layer wmsLink: " + wmsLink);
|
||||
addLayer(LayerObjectType.INDEX_LAYER, null, null, wmsLink, false, false, null, false, null, null, profileID,
|
||||
null, projectDV);
|
||||
null, null);
|
||||
|
||||
}
|
||||
|
||||
public void removeIndexLayer(IndexLayerDV layer) {
|
||||
|
||||
String wmsLink = layer.getLayer().getOgcLinks().get("wms");
|
||||
GWT.log("index layer wmsLink: " + wmsLink);
|
||||
|
||||
String layerNameKey = URLUtil.getValueOfParameter("layers", wmsLink);
|
||||
olMap.removeWMSLayer(layerNameKey);
|
||||
mapIndexLayerObjects.remove(layerNameKey);
|
||||
GWT.log("New INDEX_LAYER mapIndexLayerObjects is: " + mapIndexLayerObjects);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* To layer item.
|
||||
*
|
||||
|
@ -1073,4 +1085,6 @@ public class LayerManager {
|
|||
return overlayLayerManager;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ public class CloseCollectionEvent extends GwtEvent<CloseCollectionEventHandler>
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(CloseCollectionEventHandler h) {
|
||||
protected void dispatch(CloseCollectionEventHandler handler) {
|
||||
handler.onCloseCollection(this);
|
||||
}
|
||||
|
||||
public CloseCollectionEvent(String collectionId) {
|
||||
|
|
|
@ -4,4 +4,6 @@ import com.google.gwt.event.shared.EventHandler;
|
|||
|
||||
public interface CloseCollectionEventHandler extends EventHandler{
|
||||
|
||||
void onCloseCollection(CloseCollectionEvent closeCollectionEvent);
|
||||
|
||||
}
|
||||
|
|
|
@ -139,21 +139,19 @@ public abstract class OpenLayerMap {
|
|||
private LinkedHashMap<String, Image> wmsLayerMap;
|
||||
|
||||
private Layer baseLayerTile;
|
||||
|
||||
|
||||
private LayerOrder layerOrder = new LayerOrder();
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new open layer OSM.
|
||||
*
|
||||
* @param divTargetId the div target id
|
||||
* @param eventBus the event bus
|
||||
* @param baseLayer the base layer
|
||||
* @param eventBus the event bus
|
||||
* @param baseLayer the base layer
|
||||
*/
|
||||
public OpenLayerMap(String divTargetId, HandlerManager eventBus, BaseMapLayer baseLayer) {
|
||||
this.eventBus = eventBus;
|
||||
|
||||
|
||||
// create a projection
|
||||
projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName());
|
||||
projectionOptions.setUnits("m");
|
||||
|
@ -172,7 +170,7 @@ public abstract class OpenLayerMap {
|
|||
|
||||
map = new Map(mapOptions);
|
||||
|
||||
//map.addLayer(baseLayerTile);
|
||||
// map.addLayer(baseLayerTile);
|
||||
// map.addLayer(tileDebugLayer);
|
||||
|
||||
// add some controls
|
||||
|
@ -182,8 +180,8 @@ public abstract class OpenLayerMap {
|
|||
// add some interactions
|
||||
map.addInteraction(new KeyboardPan());
|
||||
map.addInteraction(new KeyboardZoom());
|
||||
|
||||
//applying base map
|
||||
|
||||
// applying base map
|
||||
changeBaseMap(baseLayer);
|
||||
|
||||
bindEvents();
|
||||
|
@ -212,11 +210,11 @@ public abstract class OpenLayerMap {
|
|||
XyzOptions xyzOptions = OLFactory.createOptions();
|
||||
Osm osmSource = new Osm(xyzOptions);
|
||||
osmSource.setUrl(baseLayer.getUrl());
|
||||
//setAttributions is buggy
|
||||
//osmSource.setAttributions(baseLayer.getAttribution());
|
||||
// setAttributions is buggy
|
||||
// osmSource.setAttributions(baseLayer.getAttribution());
|
||||
LayerOptions layerOptions = OLFactory.createOptions();
|
||||
layerOptions.setSource(osmSource);
|
||||
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1;
|
||||
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP) + 1;
|
||||
layerOptions.setZIndex(zIndex);
|
||||
baseLayerTile = new Tile(layerOptions);
|
||||
|
||||
|
@ -226,16 +224,15 @@ public abstract class OpenLayerMap {
|
|||
|
||||
XyzOptions xyzOptions2 = OLFactory.createOptions();
|
||||
Xyz xyz = new Xyz(xyzOptions2);
|
||||
//setAttributions is buggy
|
||||
//xyz.setAttributions(baseLayer.getAttribution());
|
||||
// setAttributions is buggy
|
||||
// xyz.setAttributions(baseLayer.getAttribution());
|
||||
xyz.setUrl(baseLayer.getUrl());
|
||||
|
||||
LayerOptions layerOptions2 = OLFactory.createOptions();
|
||||
layerOptions2.setSource(xyz);
|
||||
zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1;
|
||||
zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP) + 1;
|
||||
layerOptions2.setZIndex(zIndex);
|
||||
baseLayerTile = new Tile(layerOptions2);
|
||||
|
||||
|
||||
break;
|
||||
|
||||
|
@ -395,19 +392,19 @@ public abstract class OpenLayerMap {
|
|||
if (layer == null) {
|
||||
ImageWmsParams imageWMSParams = OLFactory.createOptions();
|
||||
imageWMSParams.setLayers(layerItem.getName());
|
||||
//imageWMSParams.set("CQL_FILTER", "product_id IN('6165b07202ad3d60e1d26f42','6166ff8002ad3d60e1d26fb7')");
|
||||
// imageWMSParams.set("CQL_FILTER", "product_id
|
||||
// IN('6165b07202ad3d60e1d26f42','6166ff8002ad3d60e1d26fb7')");
|
||||
|
||||
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
|
||||
imageWMSOptions.setUrl(layerItem.getMapServerHost());
|
||||
|
||||
|
||||
imageWMSOptions.setParams(imageWMSParams);
|
||||
// imageWMSOptions.setRatio(1.5f);
|
||||
|
||||
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
||||
LayerOptions layerOptions = OLFactory.createOptions();
|
||||
layerOptions.setSource(imageWMSSource);
|
||||
|
||||
|
||||
|
||||
// Settings MIN and MAX Resolution
|
||||
if (layerItem.getMinResolution() != null) {
|
||||
layerOptions.setMinResolution(layerItem.getMinResolution());
|
||||
|
@ -417,8 +414,8 @@ public abstract class OpenLayerMap {
|
|||
}
|
||||
|
||||
Image wmsLayer = new Image(layerOptions);
|
||||
|
||||
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_WMS)+wmsLayerMap.size()+1;
|
||||
|
||||
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_WMS) + wmsLayerMap.size() + 1;
|
||||
wmsLayer.setZIndex(zIndex);
|
||||
// visibleLayerItems
|
||||
|
||||
|
@ -432,18 +429,18 @@ public abstract class OpenLayerMap {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setCQLFilterToWMSLayer(String key, String cqlFilterExpression) {
|
||||
|
||||
GWT.log("Getting key: "+key);
|
||||
|
||||
GWT.log("Setting CQL FILTER: "+cqlFilterExpression);
|
||||
GWT.log("Getting key: " + key);
|
||||
|
||||
GWT.log("Setting CQL FILTER: " + cqlFilterExpression);
|
||||
Image wmsLayer = wmsLayerMap.get(key);
|
||||
|
||||
GWT.log("WMS layer is: "+wmsLayer);
|
||||
|
||||
//map.removeLayer(wmsLayer);
|
||||
|
||||
|
||||
GWT.log("WMS layer is: " + wmsLayer);
|
||||
|
||||
// map.removeLayer(wmsLayer);
|
||||
|
||||
ImageWms imageWMSSource = wmsLayer.getSource();
|
||||
ImageWmsParams imageWMSParams = imageWMSSource.getParams();
|
||||
|
||||
|
@ -452,11 +449,11 @@ public abstract class OpenLayerMap {
|
|||
} else {
|
||||
imageWMSParams.set("CQL_FILTER", cqlFilterExpression);
|
||||
}
|
||||
|
||||
|
||||
imageWMSSource.updateParams(imageWMSParams);
|
||||
wmsLayer.setSource(imageWMSSource);
|
||||
|
||||
//map.addLayer(wmsLayer);
|
||||
|
||||
// map.addLayer(wmsLayer);
|
||||
|
||||
}
|
||||
|
||||
|
@ -487,7 +484,7 @@ public abstract class OpenLayerMap {
|
|||
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
||||
LayerOptions layerOptions = OLFactory.createOptions();
|
||||
layerOptions.setSource(imageWMSSource);
|
||||
|
||||
|
||||
// Settings MIN and MAX Resolution
|
||||
if (layerItem.getMinResolution() != null) {
|
||||
layerOptions.setMinResolution(layerItem.getMinResolution());
|
||||
|
@ -497,7 +494,7 @@ public abstract class OpenLayerMap {
|
|||
}
|
||||
|
||||
Image wmsLayer = new Image(layerOptions);
|
||||
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL)+wmsDetailsLayerMap.size() + 1;
|
||||
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.WMS_DETAIL) + wmsDetailsLayerMap.size() + 1;
|
||||
wmsLayer.setZIndex(zIndex);
|
||||
map.addLayer(wmsLayer);
|
||||
wmsDetailsLayerMap.put(key, wmsLayer);
|
||||
|
@ -510,6 +507,27 @@ public abstract class OpenLayerMap {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the all detail layers.
|
||||
*/
|
||||
public void removeWMSLayer(String layerName) {
|
||||
GWT.log("Removing layerName: " + layerName + " from map: " + wmsLayerMap);
|
||||
|
||||
// NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION
|
||||
|
||||
if (wmsLayerMap == null)
|
||||
return;
|
||||
|
||||
Image layer = wmsLayerMap.get(layerName);
|
||||
|
||||
if (layer != null) {
|
||||
map.removeLayer(layer);
|
||||
wmsLayerMap.remove(layerName);
|
||||
GWT.log("Removed layerName: " + layerName + " from map: " + wmsLayerMap.keySet());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the all detail layers.
|
||||
*/
|
||||
|
@ -555,12 +573,12 @@ public abstract class OpenLayerMap {
|
|||
Vector vectorSource = OLFactory.createVectorSource();
|
||||
vectorSource.addFeature(feature);
|
||||
vectorLayerOptions.setSource(vectorSource);
|
||||
|
||||
|
||||
ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions);
|
||||
|
||||
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR)+1;
|
||||
|
||||
int zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.VECTOR) + 1;
|
||||
vector.setZIndex(zIndex);
|
||||
|
||||
|
||||
map.addLayer(vector);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue