📄 wcsoverviewfunctionality.java
字号:
package com.esri.solutions.jitk.web.wcs.data;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import javax.servlet.ServletContext;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import com.esri.adf.web.data.GISResource;
import com.esri.adf.web.data.OverviewFunctionality;
import com.esri.adf.web.data.WebOverview;
import com.esri.adf.web.data.geometry.WebExtent;
import com.esri.adf.web.util.WebUtil;
import com.esri.solutions.jitk.datasources.exceptions.ClientNotFoundException;
import com.esri.solutions.jitk.datasources.ogc.wcs.IOAgent;
import com.esri.solutions.jitk.datasources.ogc.wcs.IWCSClient;
import com.esri.solutions.jitk.datasources.ogc.wcs.WCSClientFactory;
import com.esri.solutions.jitk.datasources.ogc.wcs.WCSHTTPClientBase;
import com.esri.solutions.jitk.datasources.ogc.wcs.info.WCSBoundingBox;
import com.esri.solutions.jitk.datasources.ogc.wcs.info.WCSCapabilities;
@SuppressWarnings("unused")
public class WCSOverviewFunctionality implements OverviewFunctionality{
private static final Logger logger = LogManager.getLogger(WCSMapFunctionality.class);
private WCSMapResource resource = null;
private WebExtent extent = null;
private double transparency = 1;
private boolean disabled = false;
private String getBbox() {
StringBuffer sb = new StringBuffer();
sb.append(this.extent.getMinX() + ",");
sb.append(this.extent.getMinY() + ",");
sb.append(this.extent.getMaxX() + ",");
sb.append(this.extent.getMaxY());
if(this.resource.getDimension() == 3) {
sb.append(",0,0");
}
return sb.toString();
}
/**
* The initialization chores for the functionality must be performed in this method.
*/
public void initFunctionality(GISResource resource) {
this.resource = (WCSMapResource)resource;
this.extent = this.resource.getDefaultWebExtent();
}
/**
* Returns the GISResource associated with this functionality.
*/
public GISResource getResource() {
return resource;
}
/**
* The cleanup chores for the functionality must be performed in this method.
*/
public void destroyFunctionality() {}
/**
* Exports this map for the current extent.
*/
public InputStream exportImage() {
try {
WebOverview webOverview = this.resource.getWebContext().getWebOverview();
WCSHTTPClientBase wcsClientBase = new WCSHTTPClientBase();
WCSCapabilities wcsCapabilities = this.resource.getWCSCapabilities();
if(wcsCapabilities != null && WCSClientFactory.isSupportedVersion(wcsCapabilities.getVersion())) {
try {
IWCSClient wcsClient = WCSClientFactory.getInstance(wcsCapabilities.getVersion());
InputStream wcsIS = wcsClient.getCoverage(wcsCapabilities.getGetCoverageURL(), this.resource.getCoverage(), this.resource.getEpsgId(),
getBbox(), webOverview.getHeight(), webOverview.getWidth(), this.resource.getFormat());
if(wcsIS != null) {
return ImageFormatConverter.toRGBStream(wcsIS, this.resource.getFormat());
} else {
return ImageFormatConverter.toRGBStream(this.resource.getNoOverviewImageStream(), this.resource.getFormat());
}
} catch(ClientNotFoundException ex) {
logger.error("Unable to export image", ex);
}
}
} catch(Exception e) {
logger.error("Unable to export image", e);
}
return null;
}
/**
* Returns true if this map functionality is disabled.
*/
public boolean isDisabled() {
return this.disabled;
}
/**
* If true, this map functionality is disabled.
*/
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
/**
* Sets the transparency factor for this map functionality. Valid values are from 0.0 through 1.0. A value of 1 means it is completely opaque while a value of 0 means it is completely transparent.
*/
public void setTransparency(double transparency) {
this.transparency = transparency;
}
/**
* Returns the transparency factor for this map functionality. Valid values are from 0.0 through 1.0. A value of 1 means it is completely opaque while a value of 0 means it is completely transparent.
*/
public double getTransparency() {
return this.transparency;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -