📄 wmcwmsmapresourcewriter.java
字号:
/**
*
*/
package com.esri.solutions.jitk.data.wmc;
import java.util.Iterator;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import com.esri.adf.web.wms.data.WMSMapResource;
/**
* @author vlad2928
*
*/
public class WMCWMSMapResourceWriter extends WMCGISResourceWriter {
private static final Logger _logger = LogManager.getLogger(WMCWMSMapResourceWriter.class);
WMSMapResource resource = null;
protected WMCWMSMapResourceWriter(WMSMapResource resource) {
super(resource);
this.resource = resource;
}
private StringBuffer serverTagToWMC() {
StringBuffer buf = new StringBuffer();
if(resource != null && resource.getWmsServerConnection() != null) {
com.esri.wms.client.ServerConnection conn = resource.getWmsServerConnection();
Tag serverTag = new Tag("Server", new String[][] {{"title", resource.getAlias()}, {"service", "OGC:WMS"}, {"version" , conn.getServerVersion()}}, null, true);
buf.append(serverTag.open());
buf.append(attsTag("OnlineResource", new String[][] {{"xlink:href", conn.getCapabilitiesServiceURL()}, {"xlink:type" , "simple"}}));
buf.append(serverTag.close());
} else {
_logger.warn("WMS resource/WMS server connection is null.");
}
return buf;
}
/*
<Layer queryable="1" hidden="0">
<Server service="OGC:WMS" version="1.1.0" title="ESA CubeSERV">
<OnlineResource xlink:type="simple" xlink:href="http://mapserv2.esrin.esa.it/cubestor/cubeserv/cubeserv.cgi"/>
</Server>
<Name>WORLD_MODIS_1KM:MapAdmin</Name>
<Title>WORLD_MODIS_1KM</Title>
<Abstract>Global maps derived from various Earth Observation sensors / WORLD_MODIS_1KM:MapAdmin</Abstract>
<SRS>EPSG:4326</SRS>
<FormatList>
<Format current="1">image/png</Format>
</FormatList>
<StyleList>
<Style current="1">
<Name>default</Name>
<Title>default</Title>
<LegendURL width="16" height="16" format="image/gif">
<OnlineResource xlink:type="simple" xlink:href="http://mapserv2.esrin.esa.it/cubestor/cubeserv/cubeserv.cgi?VERSION=1.1.0&REQUEST=GetLegendIcon&LAYER=WORLD_MODIS_1KM:MapAdmin&SPATIAL_TYPE=RASTER&STYLE=default&FORMAT=image/gif"/>
</LegendURL>
</Style>
</StyleList>
</Layer>
*/
/* (non-Javadoc)
* @see com.esri.solutions.jitk.data.wmc.IWMCGISResourceWriter#write()
*/
public StringBuffer write() {
StringBuffer buf = new StringBuffer();
StringBuffer serverTagBuffer = serverTagToWMC();
if(serverTagBuffer.length() > 0) {
for(Iterator<com.esri.wms.client.Layer> i = resource.getWmsMap().getAllLayers().iterator(); i.hasNext();) {
com.esri.wms.client.Layer layer = i.next();
Tag layerTag = new Tag("Layer", new String[][] {{ "hidden", layer.isVisible() ? "0" : "1"}, {"queryable" , layer.isQueryable() ? "1" : "0"}}, null, true);
buf.append(layerTag.open());
buf.append(serverTagBuffer);
buf.append(valueTag("Name", layer.getName()));
buf.append(valueTag("Title", layer.getTitle()));
buf.append(valueTag("Abstract", layer.getAbstract()));
// List of <SRS> supported
for(Iterator<com.esri.wms.client.SpatialReference> j = resource.getWmsMap().getSpatialReferences().iterator(); j.hasNext();) {
buf.append(valueTag("SRS", "EPSG:" + j.next().toEPSG()));
}
// <FormatList> section
Tag formatListTag = new Tag("FormatList", null, null, true);
buf.append(formatListTag.open());
for(Iterator<String> j = resource.getWmsServerConnection().getMapFormats().iterator(); j.hasNext();) {
String mapFormat = j.next().trim();
if(mapFormat.equalsIgnoreCase("image/png")) {
buf.append(attsValueTag("Format", new String[][] {{ "current", "1"}}, mapFormat));
} else {
buf.append(valueTag("Format", mapFormat));
}
}
buf.append(formatListTag.close());
// <StyleList> section
/*
<StyleList>
<Style current="1">
<Name>default</Name>
<Title>default</Title>
<Abstract></Abstract> <!-- Optional -->
<LegendURL width="16" height="16" format="image/gif"> <!-- Optional -->
<OnlineResource xlink:type="simple" xlink:href="http://mapserv2.esrin.esa.it/cubestor/cubeserv/cubeserv.cgi?VERSION=1.1.0&REQUEST=GetLegendIcon&LAYER=WORLD_MODIS_1KM:MapAdmin&SPATIAL_TYPE=RASTER&STYLE=default&FORMAT=image/gif"/>
</LegendURL>
.. OR ..
<SLD>
<Name>default</Name>
<Title>default</Title> <!-- Optional -->
1) <OnlineResource xmlns:xlink="http://www.w3.org/TR/xlink" xlink:type="simple" xlink:href=攈ttp://example.org/this/is/an/example/link/to/the/sld">
2) <StyledLayerDescriptor></StyledLayerDescriptor>
3) <FeatureTypeStyle></FeatureTypeStyle>
</SLD>
</Style>
</StyleList>
*/
buf.append(layerTag.close());
}
}
return buf;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -