//Query the image service using the clip geometry.
ISpatialFilter spatFilter = new ImageQueryFilterClass();
spatFilter.Geometry = clipGeometry;
spatFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelEnvelopeIntersects;
IFIDSet fidSet = imageServer3.GetCatalogItemIDs((IQueryFilter)spatFilter);
//Define the Web client.
System.Net.WebClient webClient = new System.Net.WebClient();
//Clip and download rasters to TIFF images. The format can be TIFF, NITF, or Imagine image file format.
IImageServerDownloadResults isDownloadResults = imageServer3.Download(fidSet,
null, TIFF);
IImageServerDownloadResult isDownloadResult;
string url, fileName;
for (int i = 0; i < isDownloadResults.Count; i++)
{
isDownloadResult = isDownloadResults.get_Element(i);
url = imageServer3.GetFile(isDownloadResult);
fileName = d:\\temp\\ + url.Substring(url.LastIndexOf(/) + 1);
webClient.DownloadFile(url, fileName);
}
1 个回复
朱新颖
赞同来自:
1,首先发布Image Service时有个Download功能处需要打钩,否则无法下载。
2,imageServer3.Download(fidSet, clipGeometry, TIFF); 第二个参数处设置为ClipGeometry的话,在执行到url = imageServer3.GetFile(isDownloadResult);处会报错(错误为“The download file doesn''t exist.”),设置为null,则可以正常下载。因为之前做过空间查询了,已经将查询到的栅格ID存入IFIDSet中,所以只是想获取与ClipGeometry相交的影像可以将其设置为null。
要回复问题请先登录或注册