S A M P L E S
C# code examples
for Value Objects
This page contains C# code examples for ArcGIS Server SOAP value objects
used for input and output types. The samples apply
to both desktop and Web applications. Note that
the same value object type may be utilized by multiple proxy types (multiple
service types). SOAP proxy classes and methods
may be included to demonstrate the use of a value object. By
default, the name for the SOAP proxy class is the name of the service
used to generate it plus the service type. For
example, if a SOAP proxy class is generated dynamically using a map service
named "NorthAmerica", the proxy class name will be "NorthAmerica_MapServer". For
the purposes of the example code, the proxy class names will be <service
name>_<service type>.
Value Objects
|
|
RenderingRule renderRule = new RenderingRule();
AspectFunction function = new AspectFunction();
renderRule.Function = function;
geoImgDesc.RenderingRule = renderRule;
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapFusedCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
CacheControlInfo
cachecontrlinfo = mapservice.GetCacheControlInfo(mapname);
MapService_MapServer mapService = new MapService_MapServer();
mapService.Url = "http://localhost/arcgis/services/MapService/MapServer";
MapServerInfo
mapInfo = mapService.GetServerInfo(mapService.GetDefaultMapName());
MapDescription mapDesc = mapInfo.DefaultMapDescription;
ImageType imgType = new ImageType();
imgType.ImageFormat = esriImageFormat.esriImagePNG;
imgType.ImageReturnType = esriImageReturnType.esriImageReturnURL;
ImageDisplay imgDisp = new ImageDisplay();
imgDisp.ImageHeight = pictureBox1.Height;
imgDisp.ImageWidth = pictureBox1.Width;
imgDisp.ImageDPI = 96;
ImageDescription imgDesc = new ImageDescription();
imgDesc.ImageDisplay = imgDisp;
imgDesc.ImageType = imgType;
PointN pointN = new PointN();
pointN.X = -100;
pointN.Y = 35;
CenterAndScale centerScale = new CenterAndScale();
centerScale.Center = pointN;
centerScale.Scale = mapService.ComputeScale(mapDesc, imgDisp) / 4;
mapDesc.MapArea = centerScale;
MapImage
mapImage = mapService.ExportMapImage(mapDesc, imgDesc);
MapService_MapServer mapService = new MapService_MapServer();
mapService.Url = "http://localhost/arcgis/services/MapService/MapServer";
MapServerInfo mapInfo = mapService.GetServerInfo(mapService.GetDefaultMapName());
MapDescription mapDesc = mapInfo.DefaultMapDescription;
ImageType imgType = new ImageType();
imgType.ImageFormat = esriImageFormat.esriImagePNG;
imgType.ImageReturnType = esriImageReturnType.esriImageReturnURL;
ImageDisplay imgDisp = new ImageDisplay();
imgDisp.ImageHeight = pictureBox1.Height;
imgDisp.ImageWidth = pictureBox1.Width;
imgDisp.ImageDPI = 96;
ImageDescription imgDesc = new ImageDescription();
imgDesc.ImageDisplay = imgDisp;
imgDesc.ImageType = imgType;
PointN pointN = new PointN();
pointN.X = -100;
pointN.Y = 35;
CenterAndSize centerSize = new CenterAndSize();
centerSize.Center = pointN;
centerSize.Height = 20;
centerSize.Width = 20;
centerSize.Units = mapInfo.Units.ToString();
mapDesc.MapArea = centerSize;
MapImage mapImage = mapService.ExportMapImage(mapDesc, imgDesc);
renderRule = new RenderingRule();
ClipFunction clipFunction1 = new ClipFunction();
ClipFunctionArguments clipArgument1 = new ClipFunctionArguments();
EnvelopeN clipEnvelope1 = new EnvelopeN();
double xmin, xmax, ymin, ymax;
xmin = ((EnvelopeN)isInfo.Extent).XMin;
xmax = ((EnvelopeN)isInfo.Extent).XMax;
ymin = ((EnvelopeN)isInfo.Extent).YMin;
ymax = ((EnvelopeN)isInfo.Extent).YMax;
clipEnvelope1.XMin = xmin + (xmax - xmin) / 5;
clipEnvelope1.XMax = xmin + (xmax - xmin) * 4 / 5;
clipEnvelope1.YMin = ymin + (ymax - ymin) / 5;
clipEnvelope1.YMax = ymin + (ymax - ymin) * 4 / 5;
clipEnvelope1.SpatialReference = ((EnvelopeN)isInfo.Extent).SpatialReference;
clipArgument1.Names = new string[] { "ClippingGeometry", "ClippingType", "Raster" };
clipArgument1.Values = new object[] { clipEnvelope1, 1, rfv };
renderRule = new RenderingRule();
renderRule.Function = clipFunction1 ;
renderRule.VariableName = "Raster";
ClipFunctionArguments clipArgument1 = new ClipFunctionArguments();
EnvelopeN clipEnvelope1 = new EnvelopeN();
double xmin, xmax, ymin, ymax;
xmin = ((EnvelopeN)isInfo.Extent).XMin;
xmax = ((EnvelopeN)isInfo.Extent).XMax;
ymin = ((EnvelopeN)isInfo.Extent).YMin;
ymax = ((EnvelopeN)isInfo.Extent).YMax;
clipEnvelope1.XMin = xmin + (xmax - xmin) / 5;
clipEnvelope1.XMax = xmin + (xmax - xmin) * 4 / 5;
clipEnvelope1.YMin = ymin + (ymax - ymin) / 5;
clipEnvelope1.YMax = ymin + (ymax - ymin) * 4 / 5;
clipEnvelope1.SpatialReference = ((EnvelopeN)isInfo.Extent).SpatialReference;
clipArgument1.Names = new string[] { "ClippingGeometry", "ClippingType", "Raster" };
clipArgument1.Values = new object[] { clipEnvelope1, 1, rfv };
RenderingRule renderRule = new RenderingRule();
ColormapFunction function = new ColormapFunction();
ColormapFunctionArguments argument = new ColormapFunctionArguments();
argument.Names = new string[] {"ColormapName"};
// "Random", "NDVI", "Elevation", and "Gray"
argument.Values = new object[] { "Elevation"};
renderRule.Arguments = argument;
renderRule.Function = function;
renderRule.VariableName = "Raster";
geoImgDesc.RenderingRule = renderRule;
ColormapFunctionArguments argument = new ColormapFunctionArguments();
argument.Names = new string[] {"ColormapName"};
// "Random", "NDVI", "Elevation", and "Gray"
argument.Values = new object[] { "Elevation"};
//get the service
wsmap.mapservice1_MapServer mapservice = new wsmap.mapservice1_MapServer();
mapservice.Url = "http://srver/ArcGIS/services/mapservice1/MapServer";
//get the server info
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
//subtype's field domain information for a layer
//get the layer info from the server info
MapLayerInfo lyrinfo = mapinfo.MapLayerInfos[0];
//get the subtype info
SubtypeInfo[] subtypeinfos = lyrinfo.SubtypeInfos;
if (subtypeinfos.Length > 0)
{
SubtypeInfo subtypeinfo = subtypeinfos[0];
FieldDomainInfo[] flddminfos = subtypeinfo.FieldDomainInfos;
FieldDomainInfo flddmninfo = flddminfos[0];
System.Diagnostics.Debug.WriteLine(flddmninfo.FieldName + ", " + flddmninfo.Domain + ", " + flddmninfo.DefaultValue);
}
//subtype's field domain infomation for a standalone table
//get the standalone table info from the server info if exists
StandaloneTableInfo[] stinfos = mapinfo.StandaloneTableInfos;
if (stinfos != null)
{
//get the subtype info
StandaloneTableInfo stinfo = stinfos[0];
SubtypeInfo[] stsubtypeinfos = stinfo.SubtypeInfos;
SubtypeInfo stsubtypeinfo = stsubtypeinfos[0];
//get the field domain info
FieldDomainInfo[] stflddminfos = stsubtypeinfo.FieldDomainInfos;
FieldDomainInfo stflddminfo = stflddminfos[0];
System.Diagnostics.Debug.WriteLine(stflddminfo.FieldName + ", " + stflddminfo.Domain + ", " + stflddminfo.DefaultValue);
//examine the domain types and values
if (flddmninfo.Domain is MapSrvholistic11.CodedValueDomain)
{
CodedValueDomain codeddomain = (wsmap.CodedValueDomain)flddmninfo.Domain;
CodedValue codedvalue = codeddomain.CodedValues[0];
System.Diagnostics.Debug.WriteLine(codedvalue.Code + ", " + codedvalue.Name);
}
else
{
RangeDomain rangedomain = (MapSrvholistic11.RangeDomain)flddmninfo.Domain;
System.Diagnostics.Debug.WriteLine(rangedomain.MinValue + ", " + rangedomain.MaxValue);
}
}
GPBoolean gpBool = new GPBoolean();
gpBool.Value = false;
GPDate gpDate = new GPDate();
DateTime dateTime = new DateTime(1998, 4, 11);
gpDate.Value = dateTime;
GPDouble gpDouble = new GPDouble();
gpDouble.Value = 55.98;
GPToolInfo viewshedToolInfo = gpserver.GetToolInfo("Viewshed");
GPValue[] gpValues = new GPValue[2];
//create the point for the viewshed tool from the default schema
GPParameterInfo gpPI = viewshedToolInfo.ParameterInfo[0];
//Use the default schema
GPFeatureRecordSetLayer inPoint = (GPFeatureRecordSetLayer)gpPI.Value;
RecordSet inPointRS = inPoint.RecordSet;
Record[] records = new Record[1];
Record rec = new Record();
rec.Values = new object[3];
//id field
rec.Values[0] = 0;
//shape field
PointN p = new PointN();
p.X = -13100000.0;
p.Y = 4200000.0;
rec.Values[1] = p;
//offset field
rec.Values[2] = 70;
//add the record to the set of records.
records[0] = rec;
inPointRS.Records = records;
gpLinearUnit.Value = 100;
gpLinearUnit.Units = esriUnits.esriMeters;
GPLong gpLong = new GPLong();
gpLong.Value = 90;
GPToolInfo viewshedToolInfo = gpserver.GetToolInfo("Viewshed");
//create the point for the viewshed tool from the default schema
GPParameterInfo gpPI = viewshedToolInfo.ParameterInfo[0];
//Use the default schema
GPFeatureRecordSetLayer inPoint = (GPFeatureRecordSetLayer)gpPI.Value;
RecordSet inPointRS = inPoint.RecordSet;
Record[] records = new Record[1];
Record rec = new Record();
rec.Values = new object[3];
//id field
rec.Values[0] = 0;
//shape field
PointN p = new PointN();
p.X = -13100000.0;
p.Y = 4200000.0;
rec.Values[1] = p;
//offset field
rec.Values[2] = 70;
//add the record to the set of records.
records[0] = rec;
inPointRS.Records = records;
GPToolInfo viewshedToolInfo = gpserver.GetToolInfo("Viewshed");
//create the point for the viewshed tool from the default schema
GPParameterInfo gpPI = viewshedToolInfo.ParameterInfo[0];
//Use the default schema
GPFeatureRecordSetLayer inPoint = (GPFeatureRecordSetLayer)gpPI.Value;
RecordSet inPointRS = inPoint.RecordSet;
Record[] records = new Record[1];
Record rec = new Record();
rec.Values = new object[3];
//id field
rec.Values[0] = 0;
//shape field
PointN p = new PointN();
p.X = -13100000.0;
p.Y = 4200000.0;
rec.Values[1] = p;
//offset field
rec.Values[2] = 70;
//add the record to the set of records.
records[0] = rec;
inPointRS.Records = records;
//Setup Result Options
GPResultOptions resultOptions = new GPResultOptions();
//Result Spatial Reference
ProjectedCoordinateSystem PCS = new ProjectedCoordinateSystem();
PCS.WKID = 102113;
PCS.WKIDSpecified = true;
resultOptions.SpatialReference = (SpatialReference)PCS;
//Result Format
resultOptions.Format = "kml";
//Transport Type
resultOptions.TransportType = esriGDSTransportType.esriGDSTransportTypeUrl;
resultOptions.TransportTypeSpecified = true;
GPString gpString = new GPString();
gpString.Value = "some string";
GPToolInfo viewshedToolInfo = gpserver.GetToolInfo("Viewshed");
//create the point for the viewshed tool from the default schema
GPParameterInfo gpPI = viewshedToolInfo.ParameterInfo[0];
//Use the default schema
GPFeatureRecordSetLayer inPoint = (GPFeatureRecordSetLayer)gpPI.Value;
RecordSet inPointRS = inPoint.RecordSet;
Record[] records = new Record[1];
Record rec = new Record();
rec.Values = new object[3];
//id field
rec.Values[0] = 0;
//shape field
PointN p = new PointN();
p.X = -13100000.0;
p.Y = 4200000.0;
rec.Values[1] = p;
//offset field
rec.Values[2] = 70;
//add the record to the set of records.
records[0] = rec;
inPointRS.Records = records;
GPString gpString = new GPString();
gpString.Value = "reedley";
GPLinearUnit gpLinearUnit = new GPLinearUnit();
gpLinearUnit.Value = 100;
gpLinearUnit.Units = esriUnits.esriMeters;
GPValue[] inputValues = new GPValue[2] { gpString, gpLinearUnit };
//define a raster function
HillshadeFunction function = new HillshadeFunction();
HillshadeFunctionArguments argument = new HillshadeFunctionArguments();
argument.Names = new string[] { "Altitude", "Azimuth", "ZFactor" };
argument.Values = new object[] { altitude, azimuth, zfactor }; //all double numbers
//attach to a rendering rule
RenderingRule renderRule = new RenderingRule();;
renderRule.Function = function;
renderRule.VariableName = "DEM"; //use DEM
//attach to image description
GeoImageDescription geoImgDesc = new GeoImageDescription();
geoImgDesc.RenderingRule = renderRule;
//send request
ImageType imageType = new ImageType();
imageType.ImageFormat = esriImageFormat.esriImageJPG;
imageType.ImageReturnType = esriImageReturnType.esriImageReturnURL;
MapResult mapResult = imageSrv.ExportMapImage(geoImgDesc, imageType);
//define image server
string url_DEMService = "http://ais3/arcgis/services/testDEM/ImageServer";
testDTED_ImageServer imageSrv = new testDTED_ImageServer();
imageSrv.Url = url_DEMService;
//define an image query filter
ImageQueryFilter imageQueryFilter = new ImageQueryFilter();
PointN pixelSize = new PointN();
pixelSize.X = 0.2;
pixelSize.Y = 0.2;
imageQueryFilter.PixelSize = (Point)pixelSize;
//query image service with the filter
RecordSet recordSet = imageSrv.GetCatalogItems(imageQueryFilter);
//get job messages
JobMessage[] msgs = gpserver.GetJobMessages(jobID);
System.Console.WriteLine("Number of JobMessages = " + msgs.Length.ToString());
foreach (JobMessage msg in msgs)
{
System.Console.WriteLine(msg.MessageDesc);
}
//get the service
wsmap.mapservice1_MapServer mapservice = new wsmap.mapservice1_MapServer();
mapservice.Url = "http://srver/ArcGIS/services/mapservice1/MapServer";
//get the server info
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
//get the layer infos
MapLayerInfo[] maplayerinfos = mapinfo.MapLayerInfos;
foreach (MapLayerInfo info in maplayerinfos)
{
System.Diagnostics.Debug.WriteLine(info.LayerID);
}
//define image server
string url_DEMService = "http://ais3/arcgis/services/testDEM/ImageServer";
testDTED_ImageServer imageSrv = new testDTED_ImageServer();
imageSrv.Url = url_DEMService;
//define image description
GeoImageDescription geoImgDesc = new GeoImageDescription();
geoImgDesc.Height = 600;
geoImgDesc.Width = 800;
geoImgDesc.Interpolation = rstResamplingTypes.RSP_BilinearInterpolation;
ImageServiceInfo isInfo = imageSrv.GetServiceInfo();
geoImgDesc.Extent = isInfo.Extent;
//apply a mosaic rule
MosaicRule mosaicRule = new MosaicRule();
mosaicRule.LockRasterID = "1,2,3";
geoImgDesc.MosaicRule = mosaicRule;
//Below is some sample code that will decompress a CompressedGeometry into an array of XY.
private struct XY
{
public double x;
public double y;
}
private char[] m_abc = {'0','1','2','3','4','5','6','7','8','9',
'a','b','c','d','e','f','g','h','i','j',
'k','l','m','n','o','p','q','r','s','t','u','v'};
private XY[] ExtractPointsFromCompressedGeometry(System.String compresedGeometry)
{
// initialize result storage
System.Collections.Generic.List< XY > result = new System.Collections.Generic.List< XY >(); // memory exception
int nIndex = 0;
double dMultBy = (double)ExtractInt(compresedGeometry, ref nIndex); // exception
int nLastDiffX = 0;
int nLastDiffY = 0;
int nLength = compresedGeometry.Length; // reduce call stack
while (nIndex != nLength)
{
// extract number
int nDiffX = ExtractInt(compresedGeometry, ref nIndex); // exception
int nDiffY = ExtractInt(compresedGeometry, ref nIndex); // exception
// decompress
int nX = nDiffX + nLastDiffX;
int nY = nDiffY + nLastDiffY;
double dX = (double)nX / dMultBy;
double dY = (double)nY / dMultBy;
// add result item
XY point = new XY();
point.x = dX;
point.y = dY;
result.Add(point); // memory exception
// prepare for next calculation
nLastDiffX = nX;
nLastDiffY = nY;
}
// return result
return result.ToArray();
}
// Read one integer from compressed geometry string by using passed position
// Returns extracted integer, and re-writes nStartPos for the next integer
private int ExtractInt(string src, ref int nStartPos) // exception
{
bool bStop = false;
System.Text.StringBuilder result = new System.Text.StringBuilder();
int nCurrentPos = nStartPos;
while (!bStop)
{
char cCurrent = src[nCurrentPos];
if (cCurrent == '+' || cCurrent == '-')
{
if (nCurrentPos != nStartPos)
{
bStop = true;
continue;
}
}
result.Append(cCurrent); // exception
nCurrentPos++;
if (nCurrentPos == src.Length) // check overflow
{
bStop = true;
}
int nResult = int.MinValue;
if (result.Length != 0)
{
nResult = FromStringRadix32(result.ToString());
nStartPos = nCurrentPos;
}
return nResult;
}
// Sample input and output: +1lmo -> 55000
private int FromStringRadix32(string s) // exception
{
int result = 0;
for (int i = 1; i < s.Length; i++)
{
char cur = s[i];
System.Diagnostics.Debug.Assert((cur >= '0' && cur <= '9') || (cur >= 'a' && cur <= 'v'));
if (cur >= '0' && cur <= '9')
{
result = (result << 5) + System.Convert.ToInt32(cur) - System.Convert.ToInt32('0');
}
else if (cur >= 'a' && cur <= 'v')
{
result = (result << 5) + System.Convert.ToInt32(cur) - System.Convert.ToInt32('a') + 10;
}
else
{
throw new System.ArgumentOutOfRangeException(); // exception
}
}
if (s[0] == '-')
{
result = -result;
}
else if (s[0] != '+')
{
throw new System.ArgumentOutOfRangeException(); // exception
}
return result;
}
//Example showing setting the image description so the output map would be 200x200 pixels:
routeParams.ImageDescription.Display.Width = 200;
routeParams.ImageDescription.Display.Height = 200;
RenderingRule renderRule = new RenderingRule();
NDVIFunction function = new NDVIFunction();
NDVIFunctionArguments argument = new NDVIFunctionArguments();
argument.Names = new string[] { "VisibleBandID", "InfraredBandID" };
argument.Values = new object[] { visualBand, infBand }; //0-based integer
renderRule.Arguments = argument;
renderRule.Function = function;
renderRule.VariableName = "Raster";
geoImgDesc.RenderingRule = renderRule;
PointN pnt1 = new PointN();
pnt1.X = 500000;
pnt1.Y = 500000;
PointN pnt2 = new PointN();
pnt2.X = 600000;
pnt2.Y = 500000;
PointN pnt3 = new PointN();
pnt3.X = 700000;
pnt3.Y = 500000;
PointN[] pntarray1 = new PointN[] { pnt1, pnt2, pnt3 };
Path path1 = new Path();
path1.PointArray = pntarray1;
// Ring 1
PointN pnt1a = new PointN();
pnt1a.X = 10.0;
pnt1a.Y = 30.0;
PointN pnt2a = new PointN();
pnt2a.X = 10.0;
pnt2a.Y = 45.0;
PointN pnt3a = new PointN();
pnt3a.X = 25.0;
pnt3a.Y = 45.0;
PointN pnt4a = new PointN();
pnt4a.X = 25.0;
pnt4a.Y = 30.0;
PointN pnt5a = new PointN();
pnt5a.X = 10.0;
pnt5a.Y = 30.0;
PointN[] pnts1a = new PointN[] { pnt1a, pnt2a, pnt3a, pnt4a, pnt5a };
Ring ring1 = new Ring();
ring1.PointArray = pnts1a;
// Ring 2
PointN pnt1b = new PointN();
pnt1b.X = 15.0;
pnt1b.Y = 35.0;
PointN pnt2b = new PointN();
pnt2b.X = 15.0;
pnt2b.Y = 50.0;
PointN pnt3b = new PointN();
pnt3b.X = 30.0;
pnt3b.Y = 50.0;
PointN pnt4b = new PointN();
pnt4b.X = 30.0;
pnt4b.Y = 35.0;
PointN pnt5b = new PointN();
pnt5b.X = 15.0;
pnt5b.Y = 35.0;
PointN[] pnts1b = new PointN[] { pnt1b, pnt2b, pnt3b, pnt4b, pnt5b };
Ring ring2 = new Ring();
ring2.PointArray = pnts1b;
// Multipart Polygon (2 overlapping rings)
Ring[] rings = new Ring[] { ring1, ring2 };
PolygonN polygon1 = new PolygonN();
polygon1.RingArray = rings;
//general setting
sampleImage_ImageServer imageSrv = new sampleImage_ImageServer();
imageSrv.Url = url;
sampleImage.GeoImageDescription geoImgDesc = new SOAPRasterFunctionTemplate.sampleImage.GeoImageDescription();
geoImgDesc.Height = 600;
geoImgDesc.Width = 800;
geoImgDesc.Interpolation = SOAPRasterFunctionTemplate.sampleImage.rstResamplingTypes.RSP_BilinearInterpolation;
ImageServiceInfo isInfo = imageSrv.GetServiceInfo();
geoImgDesc.Extent = isInfo.Extent;
//raster function variable
RasterFunctionVariable rfv = new RasterFunctionVariable();
rfv.Name = "ClipRaster1";
rfv.IsDataset = true;
rfv.IsDatasetSpecified = true;
//clip 1
ClipFunction clipFunction1 = new ClipFunction();
ClipFunctionArguments clipArgument1 = new ClipFunctionArguments();
EnvelopeN clipEnvelope1 = new EnvelopeN();
double xmin, xmax, ymin, ymax;
xmin = ((EnvelopeN)isInfo.Extent).XMin;
xmax = ((EnvelopeN)isInfo.Extent).XMax;
ymin = ((EnvelopeN)isInfo.Extent).YMin;
ymax = ((EnvelopeN)isInfo.Extent).YMax;
clipEnvelope1.XMin = xmin + (xmax - xmin) / 5;
clipEnvelope1.XMax = xmin + (xmax - xmin) * 4 / 5;
clipEnvelope1.YMin = ymin + (ymax - ymin) / 5;
clipEnvelope1.YMax = ymin + (ymax - ymin) * 4 / 5;
clipEnvelope1.SpatialReference = ((EnvelopeN)isInfo.Extent).SpatialReference;
clipArgument1.Names = new string[] { "ClippingGeometry", "ClippingType", "Raster" };
clipArgument1.Values = new object[] { clipEnvelope1, 1, rfv };
RasterFunctionTemplate rftClip1 = new RasterFunctionTemplate();
rftClip1.Name = "ExtractTemplate";
rftClip1.Function = clipFunction1;
rftClip1.Arguments = clipArgument1;
//clip 2
ClipFunction clipFunction = new ClipFunction();
ClipFunctionArguments clipArgument = new ClipFunctionArguments();
EnvelopeN clipEnvelope = new EnvelopeN();
//double xmin, xmax, ymin, ymax;
xmin = ((EnvelopeN)isInfo.Extent).XMin;
xmax = ((EnvelopeN)isInfo.Extent).XMax;
ymin = ((EnvelopeN)isInfo.Extent).YMin;
ymax = ((EnvelopeN)isInfo.Extent).YMax;
clipEnvelope.XMin = xmin;
clipEnvelope.XMax = (xmin + xmax) / 2;
clipEnvelope.YMin = ymin;
clipEnvelope.YMax = (ymin + ymax) / 2;
clipEnvelope.SpatialReference = ((EnvelopeN)isInfo.Extent).SpatialReference;
clipArgument.Names = new string[] { "ClippingGeometry", "ClippingType", "Raster" };//{ "ColorRamp", "Raster" };
clipArgument.Values = new object[] { clipEnvelope, 1, rftClip1 }; //1 inside, 2 outside
RasterFunctionTemplate rftClip = new RasterFunctionTemplate();
rftClip.Function = clipFunction;
rftClip.Arguments = clipArgument;
rftClip.Name = "RFTName";
//rendering rule
RenderingRule renderRule = new RenderingRule();
renderRule.Function = rftClip;
renderRule.VariableName = "ClipRaster1";
geoImgDesc.RenderingRule = renderRule;
ImageType imageType = new ImageType();
imageType.ImageFormat = esriImageFormat.esriImagePNG;
imageType.ImageReturnType = esriImageReturnType.esriImageReturnURL;
ImageResult imgResult = imageSrv.ExportImage(geoImgDesc, imageType);
//Example: Printing a list of all relates a layer or table is participating in.
//Assuming pMTI is a MapTabeInfo passed in to this function.
MapServerWS.RelateInfo[] pRIs = null;
MapServerWS.RelateInfo pRI = null;
if (pMTI is MapServerWS.StandaloneTableInfo)
{
MapServerWS.StandaloneTableInfo pSTI = (MapServerWS.StandaloneTableInfo)pMTI;
pRIs = pSTI.RelateInfos;
}
else if (pMTI is MapServerWS.MapLayerInfo)
{
MapServerWS.MapLayerInfo pMLI = (MapServerWS.MapLayerInfo)pMTI;
pRIs = pMLI.RelateInfos;
}
if (pRIs == null)
{
Console.WriteLine("No relationship is available");
return;
}
for (int j = 0; j < pRIs.Length; j++)
{
pRI = pRIs[j];
Console.WriteLine(pRI.Name + ", " + pRI.RelationshipID + ", " + pRI.RelatedTableID + "\n");
}
PointN pnt1 = new PointN();
pnt1.X = 100000;
pnt1.Y = 300000;
PointN pnt2 = new PointN();
pnt2.X = 100000;
pnt2.Y = 350000;
PointN pnt3 = new PointN();
pnt3.X = 900000;
pnt3.Y
= 350000;
PointN[] pnts1 = new PointN[] { pnt1, pnt2, pnt3 };
Ring ring1 = new Ring();
ring1.PointArray
= pnts1;
RenderingRule renderRule = new RenderingRule();
ShadedReliefFunction function = new ShadedReliefFunction();
ShadedReliefFunctionArguments argument = new ShadedReliefFunctionArguments();
HsvColor fromColor = new HsvColor();
fromColor.Hue = 0; //red
fromColor.Saturation = 100;
fromColor.Value = 100;
HsvColor toColor = new HsvColor();
toColor.Hue = 240; //blue
toColor.Saturation = 100;
toColor.Value = 100;
AlgorithmicColorRamp ramp = new AlgorithmicColorRamp();
ramp.FromColor = fromColor;
ramp.ToColor = toColor;
argument.Names = new string[] {"ColorRamp", "Altitude", "Azimuth", "ZFactor"};
argument.Values = new object[] { (ColorRamp)ramp, altitude, azimuth, zfactor }; //all double numbers
renderRule.Arguments = argument;
renderRule.Function = function;
renderRule.VariableName = "Raster"; //use Raster
RenderingRule renderRule = new RenderingRule();
SlopeFunction function = new SlopeFunction();
SlopeFunctionArguments argument = new SlopeFunctionArguments();
argument.Names = new string[] { "ZFactor" };
argument.Values = new object[] {zfactor }; //a double
renderRule.Arguments = argument;
renderRule.Function = function;
renderRule.VariableName = "DEM";
geoImgDesc.RenderingRule = renderRule;
RenderingRule renderRule = new RenderingRule();
StatisticsFunction function = new StatisticsFunction();
StatisticsFunctionArguments argument = new StatisticsFunctionArguments();
argument.Names = new string[] { "Columns", "Rows", "Type" };
//col and row are int and focalstatstype is 1,2,3, or 4: one of the four possible esriFocalStatisticType
argument.Values = new object[] { col, row, focalstatstype };
renderRule.Arguments = argument;
renderRule.Function = function;
renderRule.VariableName = "Raster";
geoImgDesc.RenderingRule = renderRule;
//Example: getting a list of all available standalone table in the MapService:
MapServerWS.StandaloneTableInfo[] pSTIs = pMapServerInfo.StandaloneTableInfos;
for (int i = 0; i < pSTIs.Length; i++)
{
Console.WriteLine("Table Name:" + pSTIs[i].Name + ", Table Id:" + pSTIs[i].ID + "\n");
}
StretchFunction function = new StretchFunction();
StretchFunctionArguments argument = new StretchFunctionArguments();
double[] gamma = new double[] { 1 };
RasterStatistics stats = new RasterStatistics();
stats.Max = 98.558349609375;
stats.Min = 0.24400000274181366;
stats.Mean = 30.839803164430656;
stats.StandardDeviation = 14.28627433903563;
object[] statsArray = new object[] { stats, stats, stats };
argument.Names = new string[] { "Min", "Max", "UseGamma", "Gamma", "Statistics", "NumberOfStandardDeviations", "StretchType";
//stretch type is esriRasterStretchType, possible values: 0, 3, 4, 5
argument.Values = new object[] { min, max, false, gamma, statsArray, numberofstandevs, stretchType };
RenderingRule renderRule = new RenderingRule();
renderRule.Arguments = argument;
renderRule.Function = function;
renderRule.VariableName = "Raster";
//get the service
wsmap.mapservice1_MapServer mapservice = new wsmap.mapservice1_MapServer();
mapservice.Url = "http://srver/ArcGIS/services/mapservice1/MapServer";
//get the server info
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
//subtypes information for a layer
//get the layer info from the server info
MapLayerInfo lyrinfo = mapinfo.MapLayerInfos[0];
//get the subtype info
SubtypeInfo[] subtypeinfos = lyrinfo.SubtypeInfos;
if (subtypeinfos.Length > 0)
{
SubtypeInfo subtypeinfo = subtypeinfos[0];
System.Diagnostics.Debug.WriteLine(subtypeinfo.SubtypeCode + ", " + subtypeinfo.SubtypeName);
}
//subtypes for a standalone table
//get the standalone table info from the server info if exist
StandaloneTableInfo[] stinfos = mapinfo.StandaloneTableInfos;
if (stinfos != null)
{
StandaloneTableInfo stinfo = stinfos[0];
SubtypeInfo[] stsubtypeinfos = stinfo.SubtypeInfos;
SubtypeInfo stsubtypeinfo = stsubtypeinfos[0];
System.Diagnostics.Debug.WriteLine(stsubtypeinfo.SubtypeCode + ", " + stsubtypeinfo.SubtypeName);
}