Added code to manage NcWmsLayerMetadata
Get Legend updated to support GetLegenGraphic with palette for Thredds Layers git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gis-viewer@121983 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
09415a36b5
commit
27bba457c1
|
@ -159,7 +159,6 @@ public class GisViewer extends Window {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Adds the layer by wms.
|
||||
*
|
||||
|
@ -168,9 +167,10 @@ public class GisViewer extends Window {
|
|||
* @param wmsRequest the wms request
|
||||
* @param isBase the is base
|
||||
* @param displayInLayerSwitcher the display in layer switcher
|
||||
* @param isNcWMS the is nc wms
|
||||
*/
|
||||
public void addLayerByWms(String title, String layerName, String wmsRequest, boolean isBase, boolean displayInLayerSwitcher) {
|
||||
gg.addLayerByWms(title, layerName, wmsRequest, isBase, displayInLayerSwitcher);
|
||||
public void addLayerByWms(String title, String layerName, String wmsRequest, boolean isBase, boolean displayInLayerSwitcher, boolean isNcWMS) {
|
||||
gg.addLayerByWms(title, layerName, wmsRequest, isBase, displayInLayerSwitcher, isNcWMS);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -386,26 +386,27 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
|
|||
* @param wmsRequest the wms request
|
||||
* @param isBase the is base
|
||||
* @param displayInLayerSwitcher the display in layer switcher
|
||||
* @param isNcWMS
|
||||
*/
|
||||
public void addLayerByWms(String layerTitle, String layerName, String wmsRequest, boolean isBase, boolean displayInLayerSwitcher) {
|
||||
public void addLayerByWms(String layerTitle, String layerName, String wmsRequest, boolean isBase, boolean displayInLayerSwitcher, boolean isNcWMS) {
|
||||
|
||||
if(wmsRequest.contains("?")){ //IS FULL REQUEST
|
||||
GWT.log("WmsRequest string have '?', parsing parameters..");
|
||||
GWT.log("WmsRequest string has '?', parsing parameters..");
|
||||
WmsUrlValidator wmsUrlValidator = new WmsUrlValidator(wmsRequest);
|
||||
|
||||
try {
|
||||
wmsUrlValidator.parseWmsRequest(false, true);
|
||||
HashMap<String, String> mapWmsNotStandard = new HashMap<String, String>(wmsUrlValidator.getMapWmsNotStandardParams().size());
|
||||
mapWmsNotStandard.putAll(wmsUrlValidator.getMapWmsNotStandardParams());
|
||||
addLayerByWms(LayerType.FEATURETYPE, layerTitle, layerName, wmsUrlValidator.getBaseWmsServiceUrl(), true, false, false, (ArrayList<String>) wmsUrlValidator.getStylesAsList(), wmsRequest, false, mapWmsNotStandard);
|
||||
addLayerByWms(LayerType.FEATURETYPE, layerTitle, layerName, wmsUrlValidator.getBaseWmsServiceUrl(), true, false, false, (ArrayList<String>) wmsUrlValidator.getStylesAsList(), wmsRequest, false, mapWmsNotStandard, isNcWMS);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Window.alert("Sorry an error occurred during layer parsing, check your wms request");
|
||||
}
|
||||
|
||||
}else{ //IS ONLY GEOSERVER REQUEST
|
||||
GWT.log("WmsRequest string have not '?', no parameter available");
|
||||
addLayerByWms(LayerType.FEATURETYPE, layerTitle, layerName, wmsRequest, true, false, false, null, "", false, null);
|
||||
GWT.log("WmsRequest string has not '?', no parameter available");
|
||||
addLayerByWms(LayerType.FEATURETYPE, layerTitle, layerName, wmsRequest, true, false, false, null, "", false, null, isNcWMS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -577,14 +578,27 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
|
|||
dialog.add(hpLoading);
|
||||
|
||||
String url = layerItem.getGeoserverWmsUrl()
|
||||
+ "?service=WMS&version=1.1.1&request=GetLegendGraphic&"
|
||||
+ "layer="
|
||||
+ layerItem.getLayer()
|
||||
+ "&format=image/png"
|
||||
+ "&STYLE="+((layerItem.getStyle()!=null && !layerItem.getStyle().isEmpty())?layerItem.getStyle():"")
|
||||
+ "&LEGEND_OPTIONS=forceRule:True;dx:0.2;dy:0.2;mx:0.2;my:0.2;fontStyle:bold;"
|
||||
+ "borderColor:000000;border:true;fontColor:000000;fontSize:14";
|
||||
|
||||
+ "?service=WMS&"
|
||||
+ "version="+WmsUrlValidator.getValueOfParameter(WmsParameters.VERSION, layerItem.getServerWmsRequest())+"&"
|
||||
+ "request=GetLegendGraphic&"
|
||||
+ "layer="+layerItem.getLayer();
|
||||
|
||||
if(!layerItem.isNcWms()){
|
||||
|
||||
url+= "&format=image/png"
|
||||
+ "&STYLE="+((layerItem.getStyle()!=null && !layerItem.getStyle().isEmpty())?layerItem.getStyle():"")
|
||||
+ "&LEGEND_OPTIONS=forceRule:True;dx:0.2;dy:0.2;mx:0.2;my:0.2;fontStyle:bold;"
|
||||
+ "borderColor:000000;border:true;fontColor:000000;fontSize:14";
|
||||
}else{
|
||||
String style = (layerItem.getStyle()!=null && !layerItem.getStyle().isEmpty())?layerItem.getStyle():"";
|
||||
int isNcWmsStyle = style.indexOf("/");
|
||||
if(isNcWmsStyle!=-1){
|
||||
style = style.substring(isNcWmsStyle+1, style.length());
|
||||
}
|
||||
url+= "&palette="+style;
|
||||
}
|
||||
|
||||
|
||||
final Image img = new Image(url);
|
||||
img.addLoadHandler(new LoadHandler(){
|
||||
public void onLoad(LoadEvent event) {
|
||||
|
@ -892,13 +906,14 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
|
|||
public void showLegend(LayerItem layerItem, int left, int top) {
|
||||
showLegendPopup(layerItem, left, top);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.gisviewer.client.layerspanel.LayersPanelHandler#changeLegend(org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItem, java.lang.String)
|
||||
* @see org.gcube.portlets.user.gisviewer.client.layerspanel.LayersPanelHandler#setNewStyle(org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItem, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void changeLegend(LayerItem layerItem, String style) {
|
||||
public void applyStyleForLayer(LayerItem layerItem, String style) {
|
||||
openLayersMap.setNewStyle(layerItem, style);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -1117,8 +1132,9 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
|
|||
* @param serverWmsRequest the server wms request
|
||||
* @param onTop the on top
|
||||
* @param wmsNotStandardParams the wms not standard params
|
||||
* @param isNcWms
|
||||
*/
|
||||
public void addLayerByWms(LayerType layerType, String layerTitle, String layerName, String wmsServiceBaseUrl, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, ArrayList<String> styles, String serverWmsRequest, boolean onTop, HashMap<String, String> wmsNotStandardParams) {
|
||||
public void addLayerByWms(LayerType layerType, String layerTitle, String layerName, String wmsServiceBaseUrl, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, ArrayList<String> styles, String serverWmsRequest, boolean onTop, HashMap<String, String> wmsNotStandardParams, boolean isNcWms) {
|
||||
|
||||
// GWT.log("Add addLayerByWms 1");
|
||||
LayerItem l = new LayerItem();
|
||||
|
@ -1134,6 +1150,7 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
|
|||
l.setBuffer(2);
|
||||
l.setServerWmsRequest(serverWmsRequest);
|
||||
l.setWmsNotStandardParams(wmsNotStandardParams);
|
||||
l.setNcWms(isNcWms);
|
||||
|
||||
switch (layerType) {
|
||||
|
||||
|
|
|
@ -38,7 +38,10 @@ public class LayerItem implements IsSerializable, Cloneable {
|
|||
public static final String FLOAT_TYPE = "xsd:float";
|
||||
public static final String INT_TYPE = "xsd:int";
|
||||
|
||||
public Map<String, String> wmsNotStandardParams = null;
|
||||
private Map<String, String> wmsNotStandardParams = null;
|
||||
|
||||
//USED BY NCWMS
|
||||
private boolean isNcWms = false;
|
||||
|
||||
public static long ID_COUNTER = 0;
|
||||
|
||||
|
@ -193,6 +196,20 @@ public class LayerItem implements IsSerializable, Cloneable {
|
|||
return ele;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isNcWms
|
||||
*/
|
||||
public boolean isNcWms() {
|
||||
return isNcWms;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isNcWms the isNcWms to set
|
||||
*/
|
||||
public void setNcWms(boolean isNcWms) {
|
||||
this.isNcWms = isNcWms;
|
||||
}
|
||||
|
||||
public List<Property> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
|
|
@ -318,9 +318,11 @@ public class LayerToolsPanel extends VerticalPanel {
|
|||
public void componentSelected(MenuEvent ce) {
|
||||
btnStyle.setText((style.length()<11) ? style : style.substring(0, 11) + "...");
|
||||
btnStyle.setTitle(style);
|
||||
Constants.log("index: " + style);
|
||||
layerItem.setStyle(style);
|
||||
layersPanelHandler.changeLegend(layerItem, style);
|
||||
layersPanelHandler.applyStyleForLayer(layerItem, style);
|
||||
Constants.log("style: " + style);
|
||||
|
||||
// layersPanelHandler.changeLegend(layerItem, newStile);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
|
@ -47,13 +47,14 @@ public interface LayersPanelHandler {
|
|||
*/
|
||||
public void showLegend(LayerItem layerItem, int left, int top);
|
||||
|
||||
|
||||
/**
|
||||
* Change legend.
|
||||
* Apply style for layer.
|
||||
*
|
||||
* @param layerItem the layer item
|
||||
* @param style the style
|
||||
*/
|
||||
public void changeLegend(LayerItem layerItem, String style);
|
||||
public void applyStyleForLayer(LayerItem layerItem, String style);
|
||||
|
||||
/**
|
||||
* Sets the opacity layer.
|
||||
|
|
|
@ -130,7 +130,9 @@ public class MapGeneratorUtils {
|
|||
if(style!=null && !style.isEmpty() && !style.equals("null")){
|
||||
wmsStyleParam = "&STYLES="+style;
|
||||
}
|
||||
}else {
|
||||
}else if(!style.equals("null")){
|
||||
wmsStyleParam = "&STYLES="+style;
|
||||
}else{
|
||||
wmsStyleParam = "&STYLES=";
|
||||
}
|
||||
}
|
||||
|
@ -353,7 +355,9 @@ public class MapGeneratorUtils {
|
|||
if(style!=null && !style.isEmpty() && !style.equals("null")){
|
||||
wmsStyleParam = "&STYLES="+style;
|
||||
}
|
||||
}else {
|
||||
}else if(!style.equals("null")){
|
||||
wmsStyleParam = "&STYLES="+style;
|
||||
}else{
|
||||
wmsStyleParam = "&STYLES=";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue