/** * Get the styles of the layer returned by the service and generate a list that contains important * information of these styles inside our object WMSStyle * * @param serviceWMSStyles List of styles id * @return List of objects WMSSTyle, one by each style id of the parameter serviceWMSStyles */ private List<WMSStyle> createListWMSStyles(ArrayList serviceWMSStyles) { List<WMSStyle> styles = new ArrayList<WMSStyle>(); for (int i = 0; i < serviceWMSStyles.size(); i++) { org.gvsig.remoteclient.wms.WMSStyle serviceWMSStyle = (org.gvsig.remoteclient.wms.WMSStyle) serviceWMSStyles.get(i); WMSStyle sty = new WMSStyle(); sty.setName(serviceWMSStyle.getName()); sty.setStyleAbstract(serviceWMSStyle.getAbstract()); sty.setTitle(serviceWMSStyle.getTitle()); styles.add(sty); } return styles; }
/** * Creates a new instance of FMapWMSStyle * * @param name * @param title * @param styleAbstract * @param parent */ public FMapWMSStyle(WMSStyle style, WMSLayerNode parent) { this.name = style.getName(); this.title = style.getTitle(); this.styleAbstract = style.getAbstract(); this.legendWidth = style.getLegendURLWidth(); this.legendHeight = style.getLegendURLHeight(); this.format = style.getLegendURLFormat(); this.href = style.getLegendURLOnlineResourceHRef(); this.type = style.getLegendURLOnlineResourceType(); this.parent = parent; }
public String getWMSLegendUrl(String urlServerWMS, String layerId, String stylesName) { String legendUrl = ""; org.gvsig.remoteclient.wms.WMSStyle layerStyle = null; org.gvsig.remoteclient.wms.WMSStyle layerStyleDefault = null; // Create conexion with server WMS try { WMSClient wms = new WMSClient(urlServerWMS); wms.connect(null); WMSLayer layer = wms.getLayer(layerId); if (layer != null) { List<org.gvsig.remoteclient.wms.WMSStyle> lstStyles = layer.getStyles(); if (StringUtils.isNotEmpty(stylesName)) { List<String> styList = Arrays.asList(stylesName.split(",")); for (org.gvsig.remoteclient.wms.WMSStyle wmsStyle : lstStyles) { // default not if (styList.contains(wmsStyle.getName()) && wmsStyle.getName().toLowerCase() != "default") { layerStyle = wmsStyle; break; } else { if (wmsStyle.getName().toLowerCase() == "default") { layerStyleDefault = wmsStyle; } } } // if layer style isn't defined on parameter, set default style // or the first if (layerStyle == null) { if (layerStyleDefault == null && !lstStyles.isEmpty()) { layerStyle = lstStyles.get(0); } else { layerStyle = layerStyleDefault; } } } else { // if haven't styles, get the first if (!lstStyles.isEmpty()) { layerStyle = lstStyles.get(0); } } if (layerStyle != null) { legendUrl = layerStyle.getLegendURLOnlineResourceHRef(); } } } catch (Exception exc) { // Show exception in log logger.error("Exception on getWMSLegendUrl", exc); } return legendUrl; }
/** * @param _name * @param _title * @param _abstract */ public void addStyle(WMSStyle style) { if (style.getName().equalsIgnoreCase("default")) selectedStyleIndex = styles.size(); if (styles == null) styles = new ArrayList(); styles.add(new FMapWMSStyle(style, this)); }