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);
|
IndexLayerDV layer = toOpen.getIndexes().get(0);
|
||||||
// Open Index Layer
|
// Open Index Layer
|
||||||
|
|
||||||
layerManager.addIndexLayer(layer, toOpen.getUcd().getProfileID(), null);
|
layerManager.addIndexLayer(layer, toOpen.getUcd().getProfileID());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
applicationBus.addHandler(CloseCollectionEvent.TYPE, new CloseCollectionEventHandler() {
|
applicationBus.addHandler(CloseCollectionEvent.TYPE, new CloseCollectionEventHandler() {
|
||||||
|
|
||||||
});
|
@Override
|
||||||
|
public void onCloseCollection(CloseCollectionEvent closeCollectionEvent) {
|
||||||
|
|
||||||
// applicationBus.addHandler(OpenCollectionEvent.TYPE, openCollectionEvent -> {
|
String collId = closeCollectionEvent.getCollectionId();
|
||||||
// GWT.log("Fired event: " + openCollectionEvent);
|
|
||||||
// // Check if ID is available
|
if (collId != null) {
|
||||||
// String collId = openCollectionEvent.getCollectionId();
|
|
||||||
// ViewerConfiguration theConfig = GeoportalDataViewer.getStatus().getViewerConfig();
|
ViewerConfiguration theConfig = GeoportalDataViewer.getStatus().getViewerConfig();
|
||||||
//
|
GCubeCollection toCLose = theConfig.getAvailableCollections().get(collId);
|
||||||
// Set<String> ucdIds = theConfig.getAvailableCollections().keySet();
|
IndexLayerDV layer = toCLose.getIndexes().get(0);
|
||||||
//
|
layerManager.removeIndexLayer(layer);
|
||||||
// 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);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
applicationBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() {
|
applicationBus.addHandler(ShowDetailsEvent.TYPE, new ShowDetailsEventHandler() {
|
||||||
|
|
||||||
|
|
|
@ -578,15 +578,27 @@ public class LayerManager {
|
||||||
* @param profileID the profile ID
|
* @param profileID the profile ID
|
||||||
* @param projectDV the project DV
|
* @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);
|
GWT.log("Adding index layer: " + layer);
|
||||||
String wmsLink = layer.getLayer().getOgcLinks().get("wms");
|
String wmsLink = layer.getLayer().getOgcLinks().get("wms");
|
||||||
GWT.log("index layer wmsLink: " + wmsLink);
|
GWT.log("index layer wmsLink: " + wmsLink);
|
||||||
addLayer(LayerObjectType.INDEX_LAYER, null, null, wmsLink, false, false, null, false, null, null, profileID,
|
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.
|
* To layer item.
|
||||||
*
|
*
|
||||||
|
@ -1073,4 +1085,6 @@ public class LayerManager {
|
||||||
return overlayLayerManager;
|
return overlayLayerManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,8 @@ public class CloseCollectionEvent extends GwtEvent<CloseCollectionEventHandler>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dispatch(CloseCollectionEventHandler h) {
|
protected void dispatch(CloseCollectionEventHandler handler) {
|
||||||
|
handler.onCloseCollection(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CloseCollectionEvent(String collectionId) {
|
public CloseCollectionEvent(String collectionId) {
|
||||||
|
|
|
@ -4,4 +4,6 @@ import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
public interface CloseCollectionEventHandler extends EventHandler{
|
public interface CloseCollectionEventHandler extends EventHandler{
|
||||||
|
|
||||||
|
void onCloseCollection(CloseCollectionEvent closeCollectionEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,21 +139,19 @@ public abstract class OpenLayerMap {
|
||||||
private LinkedHashMap<String, Image> wmsLayerMap;
|
private LinkedHashMap<String, Image> wmsLayerMap;
|
||||||
|
|
||||||
private Layer baseLayerTile;
|
private Layer baseLayerTile;
|
||||||
|
|
||||||
private LayerOrder layerOrder = new LayerOrder();
|
private LayerOrder layerOrder = new LayerOrder();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new open layer OSM.
|
* Instantiates a new open layer OSM.
|
||||||
*
|
*
|
||||||
* @param divTargetId the div target id
|
* @param divTargetId the div target id
|
||||||
* @param eventBus the event bus
|
* @param eventBus the event bus
|
||||||
* @param baseLayer the base layer
|
* @param baseLayer the base layer
|
||||||
*/
|
*/
|
||||||
public OpenLayerMap(String divTargetId, HandlerManager eventBus, BaseMapLayer baseLayer) {
|
public OpenLayerMap(String divTargetId, HandlerManager eventBus, BaseMapLayer baseLayer) {
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
|
|
||||||
// create a projection
|
// create a projection
|
||||||
projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName());
|
projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName());
|
||||||
projectionOptions.setUnits("m");
|
projectionOptions.setUnits("m");
|
||||||
|
@ -172,7 +170,7 @@ public abstract class OpenLayerMap {
|
||||||
|
|
||||||
map = new Map(mapOptions);
|
map = new Map(mapOptions);
|
||||||
|
|
||||||
//map.addLayer(baseLayerTile);
|
// map.addLayer(baseLayerTile);
|
||||||
// map.addLayer(tileDebugLayer);
|
// map.addLayer(tileDebugLayer);
|
||||||
|
|
||||||
// add some controls
|
// add some controls
|
||||||
|
@ -182,8 +180,8 @@ public abstract class OpenLayerMap {
|
||||||
// add some interactions
|
// add some interactions
|
||||||
map.addInteraction(new KeyboardPan());
|
map.addInteraction(new KeyboardPan());
|
||||||
map.addInteraction(new KeyboardZoom());
|
map.addInteraction(new KeyboardZoom());
|
||||||
|
|
||||||
//applying base map
|
// applying base map
|
||||||
changeBaseMap(baseLayer);
|
changeBaseMap(baseLayer);
|
||||||
|
|
||||||
bindEvents();
|
bindEvents();
|
||||||
|
@ -212,11 +210,11 @@ public abstract class OpenLayerMap {
|
||||||
XyzOptions xyzOptions = OLFactory.createOptions();
|
XyzOptions xyzOptions = OLFactory.createOptions();
|
||||||
Osm osmSource = new Osm(xyzOptions);
|
Osm osmSource = new Osm(xyzOptions);
|
||||||
osmSource.setUrl(baseLayer.getUrl());
|
osmSource.setUrl(baseLayer.getUrl());
|
||||||
//setAttributions is buggy
|
// setAttributions is buggy
|
||||||
//osmSource.setAttributions(baseLayer.getAttribution());
|
// osmSource.setAttributions(baseLayer.getAttribution());
|
||||||
LayerOptions layerOptions = OLFactory.createOptions();
|
LayerOptions layerOptions = OLFactory.createOptions();
|
||||||
layerOptions.setSource(osmSource);
|
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);
|
layerOptions.setZIndex(zIndex);
|
||||||
baseLayerTile = new Tile(layerOptions);
|
baseLayerTile = new Tile(layerOptions);
|
||||||
|
|
||||||
|
@ -226,16 +224,15 @@ public abstract class OpenLayerMap {
|
||||||
|
|
||||||
XyzOptions xyzOptions2 = OLFactory.createOptions();
|
XyzOptions xyzOptions2 = OLFactory.createOptions();
|
||||||
Xyz xyz = new Xyz(xyzOptions2);
|
Xyz xyz = new Xyz(xyzOptions2);
|
||||||
//setAttributions is buggy
|
// setAttributions is buggy
|
||||||
//xyz.setAttributions(baseLayer.getAttribution());
|
// xyz.setAttributions(baseLayer.getAttribution());
|
||||||
xyz.setUrl(baseLayer.getUrl());
|
xyz.setUrl(baseLayer.getUrl());
|
||||||
|
|
||||||
LayerOptions layerOptions2 = OLFactory.createOptions();
|
LayerOptions layerOptions2 = OLFactory.createOptions();
|
||||||
layerOptions2.setSource(xyz);
|
layerOptions2.setSource(xyz);
|
||||||
zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP)+1;
|
zIndex = layerOrder.getOffset(LayerOrder.LAYER_TYPE.BASE_MAP) + 1;
|
||||||
layerOptions2.setZIndex(zIndex);
|
layerOptions2.setZIndex(zIndex);
|
||||||
baseLayerTile = new Tile(layerOptions2);
|
baseLayerTile = new Tile(layerOptions2);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -395,19 +392,19 @@ public abstract class OpenLayerMap {
|
||||||
if (layer == null) {
|
if (layer == null) {
|
||||||
ImageWmsParams imageWMSParams = OLFactory.createOptions();
|
ImageWmsParams imageWMSParams = OLFactory.createOptions();
|
||||||
imageWMSParams.setLayers(layerItem.getName());
|
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 imageWMSOptions = OLFactory.createOptions();
|
||||||
imageWMSOptions.setUrl(layerItem.getMapServerHost());
|
imageWMSOptions.setUrl(layerItem.getMapServerHost());
|
||||||
|
|
||||||
imageWMSOptions.setParams(imageWMSParams);
|
imageWMSOptions.setParams(imageWMSParams);
|
||||||
// imageWMSOptions.setRatio(1.5f);
|
// imageWMSOptions.setRatio(1.5f);
|
||||||
|
|
||||||
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
||||||
LayerOptions layerOptions = OLFactory.createOptions();
|
LayerOptions layerOptions = OLFactory.createOptions();
|
||||||
layerOptions.setSource(imageWMSSource);
|
layerOptions.setSource(imageWMSSource);
|
||||||
|
|
||||||
|
|
||||||
// Settings MIN and MAX Resolution
|
// Settings MIN and MAX Resolution
|
||||||
if (layerItem.getMinResolution() != null) {
|
if (layerItem.getMinResolution() != null) {
|
||||||
layerOptions.setMinResolution(layerItem.getMinResolution());
|
layerOptions.setMinResolution(layerItem.getMinResolution());
|
||||||
|
@ -417,8 +414,8 @@ public abstract class OpenLayerMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
Image wmsLayer = new Image(layerOptions);
|
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);
|
wmsLayer.setZIndex(zIndex);
|
||||||
// visibleLayerItems
|
// visibleLayerItems
|
||||||
|
|
||||||
|
@ -432,18 +429,18 @@ public abstract class OpenLayerMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCQLFilterToWMSLayer(String key, String cqlFilterExpression) {
|
public void setCQLFilterToWMSLayer(String key, String cqlFilterExpression) {
|
||||||
|
|
||||||
GWT.log("Getting key: "+key);
|
GWT.log("Getting key: " + key);
|
||||||
|
|
||||||
GWT.log("Setting CQL FILTER: "+cqlFilterExpression);
|
GWT.log("Setting CQL FILTER: " + cqlFilterExpression);
|
||||||
Image wmsLayer = wmsLayerMap.get(key);
|
Image wmsLayer = wmsLayerMap.get(key);
|
||||||
|
|
||||||
GWT.log("WMS layer is: "+wmsLayer);
|
GWT.log("WMS layer is: " + wmsLayer);
|
||||||
|
|
||||||
//map.removeLayer(wmsLayer);
|
// map.removeLayer(wmsLayer);
|
||||||
|
|
||||||
ImageWms imageWMSSource = wmsLayer.getSource();
|
ImageWms imageWMSSource = wmsLayer.getSource();
|
||||||
ImageWmsParams imageWMSParams = imageWMSSource.getParams();
|
ImageWmsParams imageWMSParams = imageWMSSource.getParams();
|
||||||
|
|
||||||
|
@ -452,11 +449,11 @@ public abstract class OpenLayerMap {
|
||||||
} else {
|
} else {
|
||||||
imageWMSParams.set("CQL_FILTER", cqlFilterExpression);
|
imageWMSParams.set("CQL_FILTER", cqlFilterExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
imageWMSSource.updateParams(imageWMSParams);
|
imageWMSSource.updateParams(imageWMSParams);
|
||||||
wmsLayer.setSource(imageWMSSource);
|
wmsLayer.setSource(imageWMSSource);
|
||||||
|
|
||||||
//map.addLayer(wmsLayer);
|
// map.addLayer(wmsLayer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,7 +484,7 @@ public abstract class OpenLayerMap {
|
||||||
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
||||||
LayerOptions layerOptions = OLFactory.createOptions();
|
LayerOptions layerOptions = OLFactory.createOptions();
|
||||||
layerOptions.setSource(imageWMSSource);
|
layerOptions.setSource(imageWMSSource);
|
||||||
|
|
||||||
// Settings MIN and MAX Resolution
|
// Settings MIN and MAX Resolution
|
||||||
if (layerItem.getMinResolution() != null) {
|
if (layerItem.getMinResolution() != null) {
|
||||||
layerOptions.setMinResolution(layerItem.getMinResolution());
|
layerOptions.setMinResolution(layerItem.getMinResolution());
|
||||||
|
@ -497,7 +494,7 @@ public abstract class OpenLayerMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
Image wmsLayer = new Image(layerOptions);
|
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);
|
wmsLayer.setZIndex(zIndex);
|
||||||
map.addLayer(wmsLayer);
|
map.addLayer(wmsLayer);
|
||||||
wmsDetailsLayerMap.put(key, 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.
|
* Removes the all detail layers.
|
||||||
*/
|
*/
|
||||||
|
@ -555,12 +573,12 @@ public abstract class OpenLayerMap {
|
||||||
Vector vectorSource = OLFactory.createVectorSource();
|
Vector vectorSource = OLFactory.createVectorSource();
|
||||||
vectorSource.addFeature(feature);
|
vectorSource.addFeature(feature);
|
||||||
vectorLayerOptions.setSource(vectorSource);
|
vectorLayerOptions.setSource(vectorSource);
|
||||||
|
|
||||||
ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions);
|
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);
|
vector.setZIndex(zIndex);
|
||||||
|
|
||||||
map.addLayer(vector);
|
map.addLayer(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue