Setting a mosaic rule and exporting a map image from an image service
A client can specify a mosaic rule when sending GetImage, ExportImage, or ExportMapImage requests to the server. The service mosaics the image with the mosaic rule and returns an image. The following code example shows how to user lock a raster and export a map image:
[C#]
public static string ExportMapImage_LockRaster(IImageServer imageServer)
{
//Cast.
IImageServer2 imageServer2 = (IImageServer2)imageServer;
//Define the mosaic rule (center).
IMosaicRule mosaicRule = new MosaicRuleClass();
mosaicRule.MosaicMethod = esriMosaicMethod.esriMosaicLockRaster;
mosaicRule.LockRasterID = "1,2,3";
mosaicRule.MosaicOperatorType = rstMosaicOperatorType.MT_MAX;
//Define the image description with a mosaic rule.
IGeoImageDescription2 geoImageDesc = new GeoImageDescriptionClass();
geoImageDesc.Height = 600;
geoImageDesc.Width = 800;
geoImageDesc.Compression = "JPEG";
geoImageDesc.Interpolation = rstResamplingTypes.RSP_BilinearInterpolation;
geoImageDesc.Extent = imageServer.ServiceInfo.Extent;
geoImageDesc.MosaicRule = mosaicRule;
//Define the image return format and the type.
IImageType imgType = new ImageTypeClass();
imgType.Format = esriImageFormat.esriImageJPG;
imgType.ReturnType = esriImageReturnType.esriImageReturnURL;
//Process the export map image request.
IMapImage mapImage = imageServer2.ExportMapImage(geoImageDesc, imgType);
return mapImage.URL;
}
[VB.NET]
Public Shared Function ExportMapImage_LockRaster(ByVal imageServer As IImageServer) As String
'Cast.
Dim imageServer2 As IImageServer2
imageServer2 = CType(imageServer, IImageServer2)
'Define the mosaic rule (center).
Dim mosaicRule As IMosaicRule = New MosaicRuleClass()
mosaicRule.MosaicMethod = esriMosaicMethod.esriMosaicLockRaster
mosaicRule.LockRasterID = "1,2,3"
mosaicRule.MosaicOperatorType = rstMosaicOperatorType.MT_MAX
'Define the image description with a mosaic rule.
Dim geoImageDesc As IGeoImageDescription2 = New GeoImageDescriptionClass()
geoImageDesc.Height = 600
geoImageDesc.Width = 800
geoImageDesc.Compression = "JPEG"
geoImageDesc.Interpolation = rstResamplingTypes.RSP_BilinearInterpolation
geoImageDesc.Extent = imageServer.ServiceInfo.Extent
geoImageDesc.MosaicRule = mosaicRule
'Define the image return format and the type.
Dim imgType As IImageType = New ImageTypeClass()
imgType.Format = esriImageFormat.esriImageJPG
imgType.ReturnType = esriImageReturnType.esriImageReturnURL
'Process the export map image request.
Dim mapImage As IMapImage
mapImage = imageServer2.ExportMapImage(geoImageDesc, imgType)
Return mapImage.URL
End Function
To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
ESRI.ArcGIS.Carto ESRI.ArcGIS.System (ESRI.ArcGIS.esriSystem)ESRI.ArcGIS.DataSourcesRaster ESRI.ArcGIS.Geodatabase ESRI.ArcGIS.Geometry
Development licensing | Deployment licensing |
---|---|
ArcInfo | ArcInfo |
ArcEditor | ArcEditor |
ArcView | ArcView |
Engine Developer Kit | Engine Runtime |