|
|
|
@ -58,6 +58,7 @@ import ol.source.Source;
|
|
|
|
|
import ol.source.Vector;
|
|
|
|
|
import ol.source.XyzOptions;
|
|
|
|
|
|
|
|
|
|
// TODO: Auto-generated Javadoc
|
|
|
|
|
/**
|
|
|
|
|
* The Class OpenLayerOSM.
|
|
|
|
|
*
|
|
|
|
@ -130,6 +131,8 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
|
|
|
|
|
private java.util.Map<String, Image> wmsDetailsLayerMap;
|
|
|
|
|
|
|
|
|
|
private HashMap<String, Image> wmsLayerMap;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Instantiates a new open layer OSM.
|
|
|
|
|
*
|
|
|
|
@ -329,34 +332,46 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
*/
|
|
|
|
|
public void addWMSLayer(LayerItem layerItem) {
|
|
|
|
|
|
|
|
|
|
ImageWmsParams imageWMSParams = OLFactory.createOptions();
|
|
|
|
|
imageWMSParams.setLayers(layerItem.getName());
|
|
|
|
|
if (wmsLayerMap == null)
|
|
|
|
|
wmsLayerMap = new HashMap<String, Image>();
|
|
|
|
|
|
|
|
|
|
String key = layerItem.getName();
|
|
|
|
|
|
|
|
|
|
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
|
|
|
|
|
imageWMSOptions.setUrl(layerItem.getMapServerHost());
|
|
|
|
|
imageWMSOptions.setParams(imageWMSParams);
|
|
|
|
|
// imageWMSOptions.setRatio(1.5f);
|
|
|
|
|
Image layer = wmsLayerMap.get(key);
|
|
|
|
|
if (layer == null) {
|
|
|
|
|
ImageWmsParams imageWMSParams = OLFactory.createOptions();
|
|
|
|
|
imageWMSParams.setLayers(layerItem.getName());
|
|
|
|
|
|
|
|
|
|
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
|
|
|
|
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
|
|
|
|
|
imageWMSOptions.setUrl(layerItem.getMapServerHost());
|
|
|
|
|
imageWMSOptions.setParams(imageWMSParams);
|
|
|
|
|
// imageWMSOptions.setRatio(1.5f);
|
|
|
|
|
|
|
|
|
|
LayerOptions layerOptions = OLFactory.createOptions();
|
|
|
|
|
layerOptions.setSource(imageWMSSource);
|
|
|
|
|
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
|
|
|
|
|
|
|
|
|
// Settings MIN and MAX Resolution
|
|
|
|
|
if (layerItem.getMinResolution() != null) {
|
|
|
|
|
layerOptions.setMinResolution(layerItem.getMinResolution());
|
|
|
|
|
}
|
|
|
|
|
if (layerItem.getMaxResolution() != null) {
|
|
|
|
|
layerOptions.setMaxResolution(layerItem.getMaxResolution());
|
|
|
|
|
}
|
|
|
|
|
LayerOptions layerOptions = OLFactory.createOptions();
|
|
|
|
|
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);
|
|
|
|
|
wmsLayerMap.put(key, wmsLayer);
|
|
|
|
|
|
|
|
|
|
map.addLayer(wmsLayer);
|
|
|
|
|
GWT.log("Added WMSLayer for layer: " + layerItem.getName());
|
|
|
|
|
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
|
|
|
|
|
GWT.log("Added WMSLayer for layer: " + layerItem.getName());
|
|
|
|
|
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)
|
|
|
|
|
wmsDetailsLayerMap = new HashMap<String, Image>();
|
|
|
|
|
|
|
|
|
|
String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName();
|
|
|
|
|
String key = layerItem.getName();
|
|
|
|
|
|
|
|
|
|
Image layer = wmsDetailsLayerMap.get(key);
|
|
|
|
|
|
|
|
|
@ -406,7 +421,7 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
GWT.log("Added WMSDetailLayer for layer name: " + layerItem.getName());
|
|
|
|
|
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
|
|
|
|
|
} 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
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* if (wmsDetailsLayerMap == null) return;
|
|
|
|
|
*
|
|
|
|
|
* GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map");
|
|
|
|
|
*
|
|
|
|
|
* for (String key : wmsDetailsLayerMap.keySet()) { Image layer =
|
|
|
|
|
* wmsDetailsLayerMap.get(key); map.removeLayer(layer); }
|
|
|
|
|
*
|
|
|
|
|
* wmsDetailsLayerMap.clear();
|
|
|
|
|
*/
|
|
|
|
|
if (wmsDetailsLayerMap == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map");
|
|
|
|
|
|
|
|
|
|
for (String key : wmsDetailsLayerMap.keySet()) {
|
|
|
|
|
Image layer = wmsDetailsLayerMap.get(key);
|
|
|
|
|
map.removeLayer(layer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wmsDetailsLayerMap.clear();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -698,12 +714,13 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
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();
|
|
|
|
|
List<String> layerNames = null;
|
|
|
|
|
if (layers != null) {
|
|
|
|
@ -716,7 +733,7 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
|
|
|
|
|
Source source = layerImage.getSource();
|
|
|
|
|
// GWT.log("source: "+source.toString());
|
|
|
|
|
//GeoportalDataViewerConstants.printJsObj(source);
|
|
|
|
|
// GeoportalDataViewerConstants.printJsObj(source);
|
|
|
|
|
String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source);
|
|
|
|
|
JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj);
|
|
|
|
|
// GWT.log("jsonObj: " + jsonObj.toString());
|
|
|
|
@ -733,4 +750,22 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|