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

AspectFunction

RenderingRule renderRule = new RenderingRule();

AspectFunction function = new AspectFunction();

renderRule.Function = function;

geoImgDesc.RenderingRule = renderRule;

CacheControlInfo

MapService_MapServer mapservice = new MapService_MapServer();

mapservice.Url = "http://localhost:6080/arcgis/services/MapFusedCache/MapServer";

 

string mapname = mapservice.GetDefaultMapName();

CacheControlInfo cachecontrlinfo = mapservice.GetCacheControlInfo(mapname);

CenterAndScale

MapService_MapServer mapService = new MapService_MapServer();

mapService.Url = "http://localhost:6080/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);

CenterAndSize

MapService_MapServer mapService = new MapService_MapServer();

mapService.Url = "http://localhost:6080/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);

ClipFunction

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

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 };

ColormapFunction

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

ColormapFunctionArguments argument = new ColormapFunctionArguments();

argument.Names = new string[] {"ColormapName"};

// "Random", "NDVI", "Elevation", and "Gray"

argument.Values = new object[] { "Elevation"};

FieldDomainInfo

//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

GPBoolean gpBool = new GPBoolean();

gpBool.Value = false;

GPDate

GPDate gpDate = new GPDate();

DateTime dateTime = new DateTime(1998, 4, 11);

gpDate.Value = dateTime;

GPDouble

GPDouble gpDouble = new GPDouble();

gpDouble.Value = 55.98;

GPFeatureRecordSetLayer

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

gpLinearUnit.Value = 100;

gpLinearUnit.Units = esriUnits.esriMeters;

GPLong

GPLong gpLong = new GPLong();

gpLong.Value = 90;

GPParameterInfo

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;

GPRecordSet

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;

GPResultOptions

//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 gpString = new GPString();

gpString.Value = "some string";

GPToolInfo

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;

GPValue

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 };

HillshadeFunction

//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;


//define a hillshade function and attach to a rendering rule

RenderingRule renderRule = new RenderingRule();

HillshadeFunction function = new HillshadeFunction();

HillshadeFunctionArguments argument = new HillshadeFunctionArguments();

argument.Names = new string[] { "Altitude", "Azimuth", "ZFactor" };

argument.Values = new object[] { 45, 315, 1.0 };

renderRule.Arguments = argument;

renderRule.Function = function;

renderRule.VariableName = "DEM";

geoImgDesc.RenderingRule = renderRule;

//define export format

ImageType imageType = new ImageType();

imageType.ImageFormat = esriImageFormat.esriImageJPG;

imageType.ImageReturnType = esriImageReturnType.esriImageReturnURL;

ImageResult result = imageSrv.ExportImage(geoImgDesc, imageType);


//download result

string fileName = @"c:\temp\hillshadeFunction.jpg";

System.Net.WebClient webClient = new System.Net.WebClient();

webClient.DownloadFile(result.ImageURL, fileName);

}

ImageQueryFilter

//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);

}

JobMessage

//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);

}

LayerDescription

//Example #1: set a simple render to a layer (assuming you have variables i.e. pMapServer, pMapDescription, pLayerDescription and pImageDescription are referenced correctly)

//symbol for polygon outline
RgbColor pGreyColor = new RgbColor()
{
	Red = 110,
	Green = 110,
	Blue = 110
};

SimpleLineSymbol pOutline = new SimpleLineSymbol()
{
	Style = esriSimpleLineStyle.esriSLSSolid,
	Width = 1,
	Color = pGreyColor
};

//Solid fill symbol with red fill color
RgbColor pRedColor = new RgbColor();
pRedColor.Red = 255;

SimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol()
{
	Style = esriSimpleFillStyle.esriSFSSolid,
	Color = pRedColor,
	Outline = pOutline
};

SimpleRenderer pSimpleRenderer = new SimpleRenderer();
pSimpleRenderer.Symbol = pSimpleFillSymbol;
pSimpleRenderer.Label = "Rivers";

//setting LayerDrawingDescription 
FeatureLayerDrawingDescription pFLDD = new FeatureLayerDrawingDescription();
pFLDD.FeatureRenderer = pSimpleRenderer;

pLayerDescription.DrawingDescription = pFLDD;
MapImage pMapImage = pMapServer.ExportMapImage(pMapDescription, pImageDescription);

//Example #2: changing only the DefaultSymbol for a layer (assuming you have variables i.e. pMapServer, pMapDescription, pLayerDescription, pImageDescription and strCurrentMapName are referenced correctly)

//symbol for polygon outline
RgbColor pGreyColor = new RgbColor()
{
	Red = 110,
	Green = 110,
	Blue = 110
};

SimpleLineSymbol pOutline = new SimpleLineSymbol()
{
	Style = esriSimpleLineStyle.esriSLSSolid,
	Width = 1,
	Color = pGreyColor
};

//Solid fill symbol with red fill color
RgbColor pRedColor = new RgbColor();
pRedColor.Red = 255;

SimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbol()
{
	Style = esriSimpleFillStyle.esriSFSSolid,
	Color = pRedColor,
	Outline = pOutline
};

//getting the default drawing description of the first layer
int[] pLyrIDs = new int[]{intLayerID};
LayerDrawingDescription[] pLDDs = pMapServer.GetDefaultLayerDrawingDescriptions(strDefaultMapName, pLyrIDs, null);
FeatureLayerDrawingDescription pFlyrDD = pLDDs[0] as FeatureLayerDrawingDescription;

//getting the renderer and changing the defaultSymbol to solid fill with red color
UniqueValueRenderer pUVR = pFlyrDD.FeatureRenderer as UniqueValueRenderer;
pUVR.DefaultSymbol = pSimpleFillSymbol;

//setting the renderer and changing the defaultSymbol to solid fill with red color
pLayerDescription.DrawingDescription = pFlyrDD;
MapImage pMapImage = pMapServer.ExportMapImage(pMapDescription, pImageDescription);

MapLayerInfo

//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);

}

MosaicRule

//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;

//define export format
ImageType imgType = new ImageType();
imgType.ImageFormat = esriImageFormat.esriImagePNG;
imgType.ImageReturnType = esriImageReturnType.esriImageReturnURL;

//export scaled image
MapImage mapImage = imageSrv.ExportScaledImage(geoImgDesc, imgType);
}

NACompactStreetDirection

//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;

}

NAServerSolverParams

//Example showing setting the image description so the output map would be 200x200 pixels:

routeParams.ImageDescription.Display.Width = 200;

routeParams.ImageDescription.Display.Height = 200;

NDVIFunction

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;

Path

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;

PolygonN

// 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;

RasterFunctionTemplate

//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);

This is a sample for using a predefined raster function template (rft.xml), as defined by the service publisher . The file structure will vary from service to service.

//define arguments (if necessary to overwrite default values)
RasterFunctionArguments argument = new RasterFunctionTemplateArguments();
argument.Names = new string[] { "Arg1", "Arg2" };
argument.Values = new object[] { "value1", "value2" };
RenderingRule renderRule = new RenderingRule();
renderRule.Arguments = argument;
renderRule.Name = "MyFunctionTemplateName";
renderRule.VariableName = "Raster";
geoImageDesc.RenderingRule = renderRule;

RelateInfo

//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");

}

Ring

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;

ShadedReliefFunction

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

SlopeFunction

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;

StatisticsFunction

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;

StandaloneTableInfo

//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

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";

SubtypeInfo

//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);

}

11/8/2016