S A M P L E S
C# code examples for Proxy Methods
This page contains C# code examples for ArcGIS Server SOAP proxy class
methods. The samples apply to both desktop and
Web applications. 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 use the service
type (e.g. the map service proxy class will be named "MapService_MapServer").
Methods
Catalog catalog = new Catalog();
catalog.Url
= "http://localhost/arcgis/services";
string[] folders = catalog.GetFolders();
for (int index = 0; index < folders.Length; index++)
{
string foldername = folders[index];
}
Catalog catalog = new Catalog();
catalog.Url = "http://localhost/arcgis/services";
esriServiceCatalogMessageFormat
messageformat = catalog.GetMessageFormats();
Catalog catalog = new Catalog();
catalog.Url = "http://localhost/arcgis/services";
esriArcGISVersion
arcgisversion = catalog.GetMessageVersion();
Catalog catalog = new Catalog();
catalog.Url = "http://localhost/arcgis/services";
ServiceDescription[] servicedescriptions = catalog.GetServiceDescriptions();
foreach (ServiceDescription servicedesc in servicedescriptions)
{
string name = servicedesc.Name;
string type = servicedesc.Type;
string parenttype = servicedesc.ParentType;
string capabilities = servicedesc.Capabilities;
string url = servicedesc.Url;
}
GetServiceDescriptionsEx
Catalog catalog = new Catalog();
catalog.Url = "http://localhost/arcgis/services";
ServiceDescription[] servicedescriptions = catalog.GetServiceDescriptionsEx("SecureDirectory");
foreach (ServiceDescription servicedesc in servicedescriptions)
{
string name = servicedesc.Name;
string type = servicedesc.Type;
string parenttype = servicedesc.ParentType;
string capabilities = servicedesc.Capabilities;
string url = servicedesc.Url;
}
GetTokenServiceURL
Catalog catalog = new Catalog();
catalog.Url = "http://localhost/arcgis/services";
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string tokenurl = catalog.GetTokenServiceURL();
string tokenrequesturl = tokenurl + "?request=getToken&username=myuser&password=secret";
System.Net.WebRequest request = System.Net.WebRequest.Create(tokenrequesturl);
System.Net.WebResponse response = request.GetResponse();
System.IO.Stream responseStream = response.GetResponseStream();
System.IO.StreamReader readStream = new System.IO.StreamReader(responseStream);
string myToken = readStream.ReadToEnd();
mapservice.Url = mapservice.Url + "?token=" + myToken;
string
mapname = mapservice.GetDefaultMapName();
RequiresTokens
Catalog catalog = new Catalog();
catalog.Url
= "http://localhost/arcgis/services";
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
if (catalog.RequiresTokens())
{
string tokenurl = catalog.GetTokenServiceURL();
string
tokenrequesturl = tokenurl + "?request=getToken&username=myuser&password=secret";
System.Net.WebRequest request = System.Net.WebRequest.Create(tokenrequesturl);
System.Net.WebResponse response = request.GetResponse();
System.IO.Stream responseStream = response.GetResponseStream();
System.IO.StreamReader readStream = new System.IO.StreamReader(responseStream);
string myToken = readStream.ReadToEnd();
mapservice.Url = mapservice.Url + "?token=" + myToken;
}
string
mapname = mapservice.GetDefaultMapName();
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url
= "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
wsmap.PointN pnt0 = new PointN();
pnt0.X = -120.0;
pnt0.Y
= 30.0;
wsmap.PointN pnt1 = new PointN();
pnt1.X = -110.0;
pnt1.Y = 35.0;
double distance = mapservice.ComputeDistance(mapname, pnt0, pnt1, esriUnits.esriMiles);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
MapServerInfo mapinfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName());
MapDescription mapdesc = mapinfo.DefaultMapDescription;
ImageDisplay imgdisp = new ImageDisplay();
imgdisp.ImageHeight = 500; //pixels
imgdisp.ImageWidth = 500; //pixels
imgdisp.ImageDPI = 96;
double
scale = mapservice.ComputeScale(mapdesc, imgdisp);
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 = 500; //pixels
imgdisp.ImageWidth = 500; //pixels
imgdisp.ImageDPI = 96;
ImageDescription imgdesc = new ImageDescription();
imgdesc.ImageDisplay = imgdisp;
imgdesc.ImageType = imgtype;
MapImage
mapimg = mapservice.ExportMapImage(mapdesc, imgdesc);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
// Define scale bar properties
AlternatingScaleBar scalebar = new AlternatingScaleBar();
// Define Unit label
scalebar.Units = esriUnits.esriMiles;
scalebar.UnitsSpecified = true;
TextSymbol unittextsymbol = new TextSymbol();
unittextsymbol.Size = 20;
unittextsymbol.FontName = "Arial";
scalebar.UnitLabelSymbol = unittextsymbol;
scalebar.UnitLabelPosition = esriScaleBarPos.esriScaleBarAfterBar;
scalebar.UnitLabelPositionSpecified = true;
scalebar.UnitLabelGap = 10;
scalebar.UnitLabelGapSpecified = true;
// Define bar display
scalebar.BarHeight = 8;
scalebar.BarHeightSpecified = true;
scalebar.Divisions = 4;
scalebar.DivisionsSpecified = true;
scalebar.DivisionMarkHeight = 18;
scalebar.DivisionMarkHeightSpecified = true;
scalebar.Subdivisions = 10;
scalebar.SubdivisionsSpecified = true;
scalebar.MarkPosition = esriVertPosEnum.esriBottom;
scalebar.MarkPositionSpecified = true;
SimpleFillSymbol fillsymbol = new SimpleFillSymbol();
wsmap.RgbColor fillcolor = new wsmap.RgbColor();
fillcolor.Red = 255;
fillcolor.Green = 0;
fillcolor.Blue = 0;
fillsymbol.Color = fillcolor;
scalebar.FillSymbol1 = fillsymbol;
// Define division labels
TextSymbol textsymbol = new TextSymbol();
textsymbol.Size = 20;
textsymbol.FontName = "Arial";
textsymbol.TextDirection = esriTextDirection.esriTDAngle;
textsymbol.Angle = 45;
scalebar.LabelSymbol = textsymbol;
scalebar.LabelPosition = esriVertPosEnum.esriAbove;
scalebar.LabelPositionSpecified = true;
scalebar.LabelFrequency = esriScaleBarFrequency.esriScaleBarDivisions;
scalebar.LabelFrequencySpecified = true;
// Define map properties (MapDescription and ImageDisplay)
MapServerInfo mapinfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName());
MapDescription mapdesc = mapinfo.DefaultMapDescription;
ImageDisplay imgdispmap = new ImageDisplay();
imgdispmap.ImageWidth = 500;
imgdispmap.ImageHeight = 500;
imgdispmap.ImageDPI = 96;
// Define scale bar image properties (ImageDescription)
ImageType imgtype = new ImageType();
imgtype.ImageFormat = esriImageFormat.esriImagePNG;
imgtype.ImageReturnType = esriImageReturnType.esriImageReturnURL;
ImageDisplay imgdispscalebar = new ImageDisplay();
imgdispscalebar.ImageHeight = 75; //pixels
imgdispscalebar.ImageWidth = 400; //pixels
ImageDescription imgdescscalebar = new ImageDescription();
imgdescscalebar.ImageDisplay = imgdispscalebar;
imgdescscalebar.ImageType = imgtype;
// Define background color
wsmap.RgbColor backcolor = new wsmap.RgbColor();
backcolor.Red = 255;
backcolor.Green = 255;
backcolor.Blue = 255;
// Create scale bar image
ImageResult imgresult = mapservice.ExportScaleBar(scalebar, mapdesc, imgdispmap, backcolor, imgdescscalebar);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
MapServerInfo mapinfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName());
MapDescription mapdesc = mapinfo.DefaultMapDescription;
ImageDisplay imgdisp = new ImageDisplay();
imgdisp.ImageHeight = 500; //pixels
imgdisp.ImageWidth = 500; //pixels
imgdisp.ImageDPI = 96;
string searchstring = "Washington";
bool contains_searchstring = true;
string fieldname = string.Empty; // all fields
esriFindOption findoption = esriFindOption.esriFindAllLayers;
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
int[] layerids = new int[layerdescriptions.Length];
int i = 0;
foreach (LayerDescription layerdesc in layerdescriptions)
{
layerids.SetValue(layerdesc.LayerID, i++);
}
MapServerFindResult[]
findresults = mapservice.Find(mapdesc, imgdisp, searchstring, contains_searchstring,
fieldname, findoption, layerids);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
MapServerInfo mapinfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName());
MapDescription mapdesc = mapinfo.DefaultMapDescription;
ImageDisplay imgdisp = new ImageDisplay();
imgdisp.ImageHeight = 500; //pixels
imgdisp.ImageWidth = 500; //pixels
imgdisp.ImageDPI = 96;
MultipointN multipoint = new MultipointN();
PointN[] points = new PointN[1];
wsmap.PointN pnt0 = new PointN();
pnt0.X = -120.0;
pnt0.Y = 35.0;
points[0] = pnt0;
multipoint.PointArray = points;
int[] screeny = null;
int[]
screenx = mapservice.FromMapPoints(mapdesc, imgdisp, multipoint, out screeny);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
foreach (LayerDescription layerdesc in layerdescriptions)
{
if (mapservice.HasLayerCache(mapname, layerdesc.LayerID))
{
string layercachename = mapservice.GetCacheName(mapname, layerdesc.LayerID);
}
}
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";
string mapname = mapservice.GetDefaultMapName();
CacheDescriptionInfo cachedescinfo = mapservice.GetCacheDescriptionInfo(mapname);
CacheControlInfo cachecontrolinfo = cachedescinfo.CacheControlInfo;
TileCacheInfo tilecacheinfo = cachedescinfo.TileCacheInfo;
TileImageInfo tileimginfo = cachedescinfo.TileImageInfo;
esriCachedMapServiceType cachetype = cachedescinfo.CacheType;
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapLayerCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapLayerCache/MapServer";
PropertySet documentproperties = mapservice.GetDocumentInfo();
PropertySetProperty[] propertyarray = documentproperties.PropertyArray;
foreach (PropertySetProperty documentprop in propertyarray)
{
string key = documentprop.Key.ToString();
string value = documentprop.Value.ToString();
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapLayerCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
// Pixel height and width of map display on the client. In this case, a Windows Form
// PictureBox control.
int picturewidth = pictureBox1.Width;
int pictureheight = pictureBox1.Height;
EnvelopeN mapextent = (EnvelopeN)mapdesc.MapArea.Extent;
// Use map scale resolution (map units per pixel) to determine tile level
double mapresolution = Math.Abs(mapextent.XMax - mapextent.XMin) / picturewidth;
System.Drawing.Bitmap imgbitmap = new System.Drawing.Bitmap(picturewidth, pictureheight);
System.Drawing.Graphics imggraphics = System.Drawing.Graphics.FromImage(imgbitmap);
imggraphics.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.LightGray), 0, 0, picturewidth, pictureheight);
int layerdesc_maxindex = layerdescriptions.Length - 1;
// Iterate through layers bottom up. Polygons on bottom, then lines, then points.
for (int d = layerdesc_maxindex; d >= 0; d--)
{
LayerDescription layerdesc = layerdescriptions[d];
if (mapservice.HasLayerCache(mapname, layerdesc.LayerID))
{
TileCacheInfo tci = mapservice.GetTileCacheInfo(mapservice.GetDefaultMapName());
LODInfo[] tcis = tci.LODInfos;
// Map units per pixel
double tileresolution = 0;
// Scale level
int tilelevel = 0;
foreach (LODInfo ldi in tcis)
{
double ldi_resolution = ldi.Resolution;
tileresolution = ldi_resolution;
tilelevel = ldi.LevelID;
if (mapresolution >= ldi_resolution)
{
break;
}
}
// Measured from the origin
double minx = mapextent.XMin;
double miny = mapextent.YMin;
double maxx = mapextent.XMax;
double maxy = mapextent.YMax;
// Origin of the cache (upper left corner)
double xorigin = ((PointN)tci.TileOrigin).X;
double yorigin = ((PointN)tci.TileOrigin).Y;
// Get minimum tile column
double minxtile = (minx - xorigin) / (tci.TileCols * tileresolution);
// Get minimum tile row
// From the origin, maxy is minimum y
double minytile = (yorigin - maxy) / (tci.TileRows * tileresolution);
// Get maximum tile column
double maxxtile = (maxx - xorigin) / (tci.TileCols * tileresolution);
// Get maximum tile row
// From the origin, miny is maximum y
double maxytile = (yorigin - miny) / (tci.TileRows * tileresolution);
// Return integer value for min and max, row and column
int mintilecolumn = (int)Math.Floor(minxtile);
int mintilerow = (int)Math.Floor(minytile);
int maxtilecolumn = (int)Math.Floor(maxxtile);
int maxtilerow = (int)Math.Floor(maxytile);
// Origin of the min tile
double xmintileorigin = xorigin + (mintilecolumn * (tci.TileCols * tileresolution));
double ymintileorigin = yorigin - (mintilerow * (tci.TileRows * tileresolution));
// Since the origin of the extent and origin of the min tile are different
// get the difference and use to place consolidated image graphic in correct location
double xadjust = Math.Abs(minx - xmintileorigin);
double yadjust = Math.Abs(maxy - ymintileorigin);
int xpixadjust = (int)(xadjust / tileresolution);
int ypixadjust = (int)(yadjust / tileresolution);
TileImageInfo tii = mapservice.GetTileImageInfo(mapservice.GetDefaultMapName());
int rowindex = 0;
// for each row in the map extent
for (int row = mintilerow; row <= maxtilerow; row++)
{
int colindex = 0;
// for each column in the row, in the map extent
for (int col = mintilecolumn; col <= maxtilecolumn; col++)
{
byte[] myByteArray = null;
try
{
// Return the byte array of the tile image
myByteArray = mapservice.GetLayerTile(mapservice.GetDefaultMapName(), layerdesc.LayerID, tilelevel, row, col, tii.CacheTileFormat);
}
catch
{
// Tile may not be available because no data was present when creating the cache
}
// If Tile was found, add it to the consolidated image graphic
if (myByteArray != null)
{
System.Drawing.Image newImage;
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(myByteArray, 0, myByteArray.Length))
{
ms.Write(myByteArray, 0, myByteArray.Length);
newImage = Image.FromStream(ms, true);
imggraphics.DrawImage
(newImage, (tci.TileCols * colindex) - xpixadjust, (tci.TileRows * rowindex) - ypixadjust, tci.TileCols, tci.TileRows);
}
}
colindex++;
}
rowindex++;
}
}
}
// Post-processing, if necessary... otherwise just use imgbitmap with PictureBox
System.Drawing.Bitmap picturebitmap = new System.Drawing.Bitmap(picturewidth, pictureheight);
System.Drawing.Graphics graphicsimage = System.Drawing.Graphics.FromImage(picturebitmap);
graphicsimage.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.LightGray), 0, 0, picturewidth, pictureheight);
graphicsimage.DrawImage(imgbitmap, 0, 0, picturewidth, pictureheight);
pictureBox1.Image = picturebitmap;
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
ImageType imgtype = new ImageType();
imgtype.ImageFormat = esriImageFormat.esriImagePNG;
imgtype.ImageReturnType = esriImageReturnType.esriImageReturnURL;
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
int[] layerids = new int[layerdescriptions.Length];
int i = 0;
foreach (LayerDescription layerdesc in layerdescriptions)
{
layerids.SetValue(layerdesc.LayerID, i++);
}
MapServerLegendPatch legendpatch = new MapServerLegendPatch();
legendpatch.ImageDPI = 96;
legendpatch.Height = 24;
legendpatch.Width = 24;
MapServerLegendInfo[] legendinfo = mapservice.GetLegendInfo(mapname, layerids, legendpatch, imgtype);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
int mapcount = mapservice.GetMapCount();
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
int mapcount = mapservice.GetMapCount();
for (int i = 0; i < mapcount; i++)
{
string mapname = mapservice.GetMapName(i);
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapFusedCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
// Pixel height and width of map display on the client. In this case, a Windows Form
// PictureBox control.
int picturewidth = pictureBox1.Width;
int pictureheight = pictureBox1.Height;
EnvelopeN mapextent = (EnvelopeN)mapdesc.MapArea.Extent;
// Use map scale resolution (map units per pixel) to determine tile level
double mapresolution = Math.Abs(mapextent.XMax - mapextent.XMin) / picturewidth;
System.Drawing.Bitmap imgbitmap = new System.Drawing.Bitmap(picturewidth, pictureheight);
System.Drawing.Graphics imggraphics = System.Drawing.Graphics.FromImage(imgbitmap);
imggraphics.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.LightGray), 0, 0, picturewidth, pictureheight);
if (mapservice.HasSingleFusedMapCache(mapname))
{
TileCacheInfo tci = mapservice.GetTileCacheInfo(mapname);
LODInfo[] tcis = tci.LODInfos;
// Map units per pixel
double tileresolution = 0;
// Scale level
int tilelevel = 0;
foreach (LODInfo ldi in tcis)
{
double ldi_resolution = ldi.Resolution;
tileresolution = ldi_resolution;
tilelevel = ldi.LevelID;
if (mapresolution >= ldi_resolution)
{
break;
}
}
// Measured from the origin
double minx = mapextent.XMin;
double miny = mapextent.YMin;
double maxx = mapextent.XMax;
double maxy = mapextent.YMax;
// Origin of the cache (upper left corner)
double xorigin = ((PointN)tci.TileOrigin).X;
double yorigin = ((PointN)tci.TileOrigin).Y;
// Get minimum tile column
double minxtile = (minx - xorigin) / (tci.TileCols * tileresolution);
// Get minimum tile row
// From the origin, maxy is minimum y
double minytile = (yorigin - maxy) / (tci.TileRows * tileresolution);
// Get maximum tile column
double maxxtile = (maxx - xorigin) / (tci.TileCols * tileresolution);
// Get maximum tile row
// From the origin, miny is maximum y
double maxytile = (yorigin - miny) / (tci.TileRows * tileresolution);
// Return integer value for min and max, row and column
int mintilecolumn = (int)Math.Floor(minxtile);
int mintilerow = (int)Math.Floor(minytile);
int maxtilecolumn = (int)Math.Floor(maxxtile);
int maxtilerow = (int)Math.Floor(maxytile);
// Origin of the min tile
double xmintileorigin = xorigin + (mintilecolumn * (tci.TileCols * tileresolution));
double ymintileorigin = yorigin - (mintilerow * (tci.TileRows * tileresolution));
// Since the origin of the extent and origin of the min tile are different
// get the difference and use to place consolidated image graphic in correct location
double xadjust = Math.Abs(minx - xmintileorigin);
double yadjust = Math.Abs(maxy - ymintileorigin);
int xpixadjust = (int)(xadjust / tileresolution);
int ypixadjust = (int)(yadjust / tileresolution);
TileImageInfo tii = mapservice.GetTileImageInfo(mapservice.GetDefaultMapName());
int rowindex = 0;
// for each row in the map extent
for (int row = mintilerow; row <= maxtilerow; row++)
{
int colindex = 0;
// for each column in the row, in the map extent
for (int col = mintilecolumn; col <= maxtilecolumn; col++)
{
byte[] myByteArray = null;
string cacheUrl = null;
try
{
// Return the byte array of the tile image
myByteArray = mapservice.GetMapTile(mapname, tilelevel, row, col, tii.CacheTileFormat);
// -or-
// Construct url manually
cacheUrl = virtualCacheDirectory + "/L" + tilelevel.ToString().PadLeft(2, '0')
+ "/R" + row.ToString("x").PadLeft(8, '0') + "/C"
+ col.ToString("x").PadLeft(8, '0') + imgType;
HttpWebRequest webreq = (HttpWebRequest)WebRequest.Create(cacheUrl);
HttpWebResponse webresp = (HttpWebResponse)webreq.GetResponse();
// Can also use: System.Drawing.Image.FromStream(webresp.GetResponseStream()) to
// read http response with image data
System.IO.Stream theStream = webresp.GetResponseStream();
int byte1;
System.IO.MemoryStream tempStream = new System.IO.MemoryStream();
while ((byte1 = theStream.ReadByte()) != -1)
{
tempStream.WriteByte(((byte)byte1));
}
myByteArray = tempStream.ToArray();
}
catch
{
// Tile may not be available because no data was present when creating the cache
}
// If Tile was found, add it to the consolidated image graphic
if (myByteArray != null)
{
System.Drawing.Image newImage;
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(myByteArray, 0, myByteArray.Length))
{
ms.Write(myByteArray, 0, myByteArray.Length);
newImage = Image.FromStream(ms, true);
imggraphics.DrawImage
(newImage, (tci.TileCols * colindex) - xpixadjust, (tci.TileRows * rowindex) - ypixadjust, tci.TileCols, tci.TileRows);
}
}
colindex++;
}
rowindex++;
}
}
// Post-processing, if necessary... otherwise just use imgbitmap with PictureBox
System.Drawing.Bitmap picturebitmap = new System.Drawing.Bitmap(picturewidth, pictureheight);
System.Drawing.Graphics graphicsimage = System.Drawing.Graphics.FromImage(picturebitmap);
graphicsimage.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.Color.LightGray), 0, 0, picturewidth, pictureheight);
graphicsimage.DrawImage(imgbitmap, 0, 0, picturewidth, pictureheight);
pictureBox1.Image = picturebitmap;
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapFusedCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
PropertySet serviceproperties = mapservice.GetServiceConfigurationInfo();
PropertySetProperty[] propertyarray = serviceproperties.PropertyArray;
foreach (PropertySetProperty serviceprop in propertyarray)
{
string key = serviceprop.Key.ToString();
string value = serviceprop.Value.ToString();
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
foreach (LayerDescription layerdesc in layerdescriptions)
{
SQLSyntaxInfo sqlsyntaxinfo = mapservice.GetSQLSyntaxInfo(mapname, layerdesc.LayerID);
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
// Mime or Url
esriImageReturnType imgreturntype = mapservice.GetSupportedImageReturnTypes();
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapFusedCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
if (mapservice.HasSingleFusedMapCache(mapname))
{
TileCacheInfo tilecacheinfo = mapservice.GetTileCacheInfo(mapname);
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapFusedCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
if (mapservice.HasSingleFusedMapCache(mapname))
{
TileImageInfo tileimageinfo = mapservice.GetTileImageInfo(mapname);
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapFusedCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
// Use -1 for fused caches
string virtualcachedirectory = mapservice.GetVirtualCacheDirectory(mapname, -1);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapLayerCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
int[] layerids = new int[layerdescriptions.Length];
int i = 0;
foreach (LayerDescription layerdesc in layerdescriptions)
{
if (mapservice.HasLayerCache(mapname, layerdesc.LayerID))
{
string layercachename = mapservice.GetCacheName(mapname, layerdesc.LayerID);
}
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapFusedCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
if (mapservice.HasSingleFusedMapCache(mapname))
{
string fusedcachename = mapservice.GetCacheName(mapname, -1);
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
MapServerInfo mapinfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName());
MapDescription mapdesc = mapinfo.DefaultMapDescription;
ImageDisplay imgdisp = new ImageDisplay();
imgdisp.ImageHeight = 500; //pixels
imgdisp.ImageWidth = 500; //pixels
imgdisp.ImageDPI = 96;
PointN inputpoint = new PointN();
inputpoint.X = -110.0;
inputpoint.Y = 35.0;
// Value in pixels. Converted to map units using image (pixels) and map (map units) extent.
int tolerance = 3;
esriIdentifyOption identifyoption = esriIdentifyOption.esriIdentifyAllLayers;
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
int[] layerids = new int[layerdescriptions.Length];
int i = 0;
foreach (LayerDescription layerdesc in layerdescriptions)
{
layerids.SetValue(layerdesc.LayerID, i++);
}
MapServerIdentifyResult[] identifyresults = mapservice.Identify(mapdesc, imgdisp, inputpoint, tolerance, identifyoption, layerids);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapLayerCache/MapServer";
string mapname = mapservice.GetDefaultMapName();
if (mapservice.IsFixedScaleMap(mapname))
{
TileCacheInfo tilecacheinfo = mapservice.GetTileCacheInfo(mapname);
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
MapLayerInfo[] maplayerinfos = mapinfo.MapLayerInfos;
int layerid = 0;
string geometryfieldname = string.Empty;
foreach (MapLayerInfo layerinfo in maplayerinfos)
{
if (layerinfo.Name == "countries")
{
layerid = layerinfo.LayerID;
Field[] fields = layerinfo.Fields.FieldArray;
foreach (Field field in fields)
{
if (field.Type == esriFieldType.esriFieldTypeGeometry)
{
geometryfieldname = field.Name;
break;
}
}
}
}
EnvelopeN envelope = new EnvelopeN();
envelope.XMin = 0.0;
envelope.YMin = 0.0;
envelope.XMax = 180.0;
envelope.YMax = 90.0;
SpatialFilter spatialfilter = new SpatialFilter();
spatialfilter.FilterGeometry = envelope;
spatialfilter.GeometryFieldName = geometryfieldname;
spatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
spatialfilter.WhereClause = "POP_CNTRY > 50000000";
int featurecount = mapservice.QueryFeatureCount(mapname, layerid, spatialfilter);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
MapLayerInfo[] maplayerinfos = mapinfo.MapLayerInfos;
int layerid = 0;
string geometryfieldname = string.Empty;
foreach (MapLayerInfo layerinfo in maplayerinfos)
{
if (layerinfo.Name == "countries")
{
layerid = layerinfo.LayerID;
Field[] fields = layerinfo.Fields.FieldArray;
foreach (Field field in fields)
{
if (field.Type == esriFieldType.esriFieldTypeGeometry)
{
geometryfieldname = field.Name;
break;
}
}
}
}
LayerDescription[] layerdescs = mapdesc.LayerDescriptions;
LayerDescription activelayerdesc = null;
foreach (LayerDescription layerdesc in layerdescs)
{
if (layerdesc.LayerID == layerid)
{
activelayerdesc = layerdesc;
break;
}
}
activelayerdesc.DefinitionExpression = "POP_CNTRY > 50000000";
EnvelopeN envelope = new EnvelopeN();
envelope.XMin = 0.0;
envelope.YMin = 0.0;
envelope.XMax = 180.0;
envelope.YMax = 90.0;
SpatialFilter spatialfilter = new SpatialFilter();
spatialfilter.FilterGeometry = envelope;
spatialfilter.GeometryFieldName = geometryfieldname;
spatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
int featurecount = mapservice.QueryFeatureCount2(mapname, activelayerdesc, spatialfilter);
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
MapLayerInfo[] maplayerinfos = mapinfo.MapLayerInfos;
int layerid = 0;
string geometryfieldname = string.Empty;
foreach (MapLayerInfo layerinfo in maplayerinfos)
{
if (layerinfo.Name == "countries")
{
layerid = layerinfo.LayerID;
Field[] fields = layerinfo.Fields.FieldArray;
foreach (Field field in fields)
{
if (field.Type == esriFieldType.esriFieldTypeGeometry)
{
geometryfieldname = field.Name;
break;
}
}
}
}
QueryFilter queryfilter = new QueryFilter();
queryfilter.WhereClause = "CNTRY_NAME LIKE '%United%'";
RecordSet recordset = null;
try
{
recordset = mapservice.QueryFeatureData(mapname, layerid, queryfilter);
}
catch (Exception ex)
{
// Improper format of where clause will cause exception
}
if (recordset != null)
{
string fieldsoutput = string.Empty;
foreach (Field field in recordset.Fields.FieldArray)
{
fieldsoutput += field.Name + "\t";
}
foreach (Record record in recordset.Records)
{
string valuesoutput = string.Empty;
object[] values = record.Values;
int v = 0;
foreach (Field field in recordset.Fields.FieldArray)
{
valuesoutput += values[v].ToString() + "\t";
v++;
}
}
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
MapLayerInfo[] maplayerinfos = mapinfo.MapLayerInfos;
int layerid = 0;
string geometryfieldname = string.Empty;
foreach (MapLayerInfo layerinfo in maplayerinfos)
{
if (layerinfo.Name == "countries")
{
layerid = layerinfo.LayerID;
Field[] fields = layerinfo.Fields.FieldArray;
foreach (Field field in fields)
{
if (field.Type == esriFieldType.esriFieldTypeGeometry)
{
geometryfieldname = field.Name;
break;
}
}
}
}
LayerDescription[] layerdescs = mapdesc.LayerDescriptions;
LayerDescription activelayerdesc = null;
foreach (LayerDescription layerdesc in layerdescs)
{
if (layerdesc.LayerID == layerid)
{
activelayerdesc = layerdesc;
break;
}
}
// Probably defined by a call to QueryFeatureIDs
activelayerdesc.DefinitionExpression = "FID IN (214, 228, 235, 245)";
QueryFilter queryfilter = new QueryFilter();
queryfilter.WhereClause = "CNTRY_NAME LIKE '%United%'";
QueryResultOptions queryresultoptions = new QueryResultOptions();
queryresultoptions.Format = esriQueryResultFormat.esriQueryResultRecordSetAsObject;
QueryResult queryresult = null;
try
{
queryresult = mapservice.QueryFeatureData2(mapname, activelayerdesc, queryfilter, queryresultoptions);
}
catch (Exception ex)
{
// Improper format of where clause will cause exception
}
RecordSet recordset = (RecordSet)queryresult.Object;
queryresultoptions.Format = esriQueryResultFormat.esriQueryResultKMLAsURL;
try
{
queryresult = mapservice.QueryFeatureData2(mapname, activelayerdesc, queryfilter, queryresultoptions);
}
catch (Exception ex)
{
// Improper format of where clause will cause exception
}
string
kmlurl = queryresult.URL;
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
MapLayerInfo[] maplayerinfos = mapinfo.MapLayerInfos;
int layerid = 0;
string geometryfieldname = string.Empty;
foreach (MapLayerInfo layerinfo in maplayerinfos)
{
if (layerinfo.Name == "countries")
{
layerid = layerinfo.LayerID;
Field[] fields = layerinfo.Fields.FieldArray;
foreach (Field field in fields)
{
if (field.Type == esriFieldType.esriFieldTypeGeometry)
{
geometryfieldname = field.Name;
break;
}
}
}
}
QueryFilter queryfilter = new QueryFilter();
queryfilter.WhereClause = "CNTRY_NAME LIKE '%United%'";
FIDSet fidset = null;
try
{
fidset = mapservice.QueryFeatureIDs(mapname, layerid, queryfilter);
}
catch (Exception ex)
{
// Improper format of where clause will cause exception
}
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
foreach (LayerDescription layerdesc in layerdescriptions)
{
if (layerdesc.LayerID == layerid)
{
layerdesc.SelectionFeatures = fidset.FIDArray;
}
}
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapname);
MapDescription mapdesc = mapinfo.DefaultMapDescription;
MapLayerInfo[] maplayerinfos = mapinfo.MapLayerInfos;
int layerid = 0;
string geometryfieldname = string.Empty;
foreach (MapLayerInfo layerinfo in maplayerinfos)
{
if (layerinfo.Name == "countries")
{
layerid = layerinfo.LayerID;
Field[] fields = layerinfo.Fields.FieldArray;
foreach (Field field in fields)
{
if (field.Type == esriFieldType.esriFieldTypeGeometry)
{
geometryfieldname = field.Name;
break;
}
}
}
}
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
LayerDescription activelayerdesc = null;
foreach (LayerDescription layerdesc in layerdescriptions)
{
if (layerdesc.LayerID == layerid)
{
activelayerdesc = layerdesc;
break;
}
}
activelayerdesc.DefinitionExpression = "POP_CNTRY > 50000000";
PointN pnt1 = new PointN();
pnt1.X = -120;
pnt1.Y = 35;
PointN pnt2 = new PointN();
pnt2.X = -60;
pnt2.Y = 20;
PointN pnt3 = new PointN();
pnt3.X = 80;
pnt3.Y = 35;
PointN[] pnts = new PointN[3];
pnts[0] = pnt1;
pnts[1] = pnt2;
pnts[2] = pnt3;
Ring[] rings = new Ring[1];
Ring ring = new Ring();
ring.PointArray = pnts;
rings[0] = ring;
PolygonN polygon = new PolygonN();
polygon.RingArray = rings;
SpatialFilter spatialfilter = new SpatialFilter();
spatialfilter.FilterGeometry = polygon;
spatialfilter.GeometryFieldName = geometryfieldname;
spatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;
FIDSet fidset = null;
try
{
fidset = mapservice.QueryFeatureIDs2(mapname, activelayerdesc, spatialfilter);
}
catch (Exception ex)
{
// Improper format of where clause will cause exception
}
activelayerdesc.SelectionFeatures
= fidset.FIDArray;
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
string mapname = mapservice.GetDefaultMapName();
MapServerInfo mapinfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName());
MapDescription mapdesc = mapinfo.DefaultMapDescription;
ImageDisplay imgdisp = new ImageDisplay();
imgdisp.ImageHeight = 500; //pixels
imgdisp.ImageWidth = 500; //pixels
imgdisp.ImageDPI = 96;
LayerDescription[] layerdescriptions = mapdesc.LayerDescriptions;
int[] layerids = new int[layerdescriptions.Length];
int i = 0;
foreach (LayerDescription layerdesc in layerdescriptions)
{
layerids.SetValue(layerdesc.LayerID, i++);
}
MapServerHyperlink[] hyperlinkresults = mapservice.QueryHyperlinks(mapdesc, imgdisp, layerids);
MouseEventArgs mea = (MouseEventArgs)e;
int[] screenx = new int[1];
int[] screeny = new int[1];
screenx[0] = mea.X;
screeny[0] = mea.Y;
MapService_MapServer mapservice = new MapService_MapServer();
mapservice.Url = "http://localhost/arcgis/services/MapService/MapServer";
MapServerInfo mapinfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName());
MapDescription mapdesc = mapinfo.DefaultMapDescription;
ImageDisplay imgdisp = new ImageDisplay();
imgdisp.ImageHeight = 500; //pixels
imgdisp.ImageWidth = 500; //pixels
imgdisp.ImageDPI = 96;
MultipointN multipoint = (MultipointN)mapservice.ToMapPoints(mapdesc, imgdisp, screenx, screeny);
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
Fields fields = geocodeservice.GetAddressFields();
PropertySet address = new PropertySet();
PropertySetProperty[] inputfields = new PropertySetProperty[fields.FieldArray.Length];
for (int index = 0; index < fields.FieldArray.Length; index++)
{
Field field = fields.FieldArray[index];
PropertySetProperty property = new PropertySetProperty();
property.Key = field.Name;
switch (field.Name.ToUpper())
{
case "STREET":
property.Value = "5000 Magnolia Ave.";
break;
case "ZONE":
property.Value = "92506";
break;
}
inputfields.SetValue(property, index);
}
address.PropertyArray = inputfields;
PropertySet propertymods = geocodeservice.GetLocatorProperties();
PropertySetProperty[] locatorArray = propertymods.PropertyArray;
// Change locator property value
for (int index = 0; index < locatorArray.Length; index++)
{
PropertySetProperty property = locatorArray[index];
switch (property.Key)
{
case "MinimumCandidateScore":
property.Value = "80";
break;
}
}
RecordSet candidates = geocodeservice.FindAddressCandidates(address, null);
if (candidates != null)
{
string fieldsoutput = string.Empty;
foreach (Field field in candidates.Fields.FieldArray)
{
fieldsoutput += field.Name;
}
foreach (Record record in candidates.Records)
{
string valuesoutput = string.Empty;
object[] values = record.Values;
int v = 0;
foreach (Field field in candidates.Fields.FieldArray)
{
valuesoutput += values[v].ToString();
v++;
}
}
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
// Define address inputs
PropertySet geocodePropSet = new PropertySet();
PropertySetProperty[] propArray = new PropertySetProperty[2];
PropertySetProperty geocodeProp = new PropertySetProperty();
geocodeProp.Key = "Street";
// Intersection
//geocodeProp.Value = "Magnolia & Central";
// Address
geocodeProp.Value = "5950 Magnolia Avenue";
propArray[0] = geocodeProp;
PropertySetProperty geocodeProp1 = new PropertySetProperty();
geocodeProp1.Key = "Zone";
geocodeProp1.Value = "92506";
propArray[1] = geocodeProp1;
geocodePropSet.PropertyArray = propArray;
// Geocode address
PropertySet results = geocodeservice.GeocodeAddress(geocodePropSet, null);
PropertySetProperty[] resultsArray = results.PropertyArray;
PointN geocodePoint = null;
foreach (PropertySetProperty result in resultsArray)
{
string val = result.Key.ToString();
if (result.Key == "Shape")
{
geocodePoint = result.Value as PointN;
double x = geocodePoint.X;
double y = geocodePoint.Y;
}
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
// Create property set to map locator address fields (key) to fields in the input
// address table (value). In this example they are the same.
PropertySet geocodePropSet = new PropertySet();
PropertySetProperty[] propArray = new PropertySetProperty[2];
PropertySetProperty geocodeProp = new PropertySetProperty();
geocodeProp.Key = "Street";
geocodeProp.Value = "Street";
propArray[0] = geocodeProp;
PropertySetProperty geocodeProp1 = new PropertySetProperty();
geocodeProp1.Key = "Zone";
geocodeProp1.Value = "Zone";
propArray[1] = geocodeProp1;
geocodePropSet.PropertyArray = propArray;
// Create a new recordset to store input addresses to be batch geocoded
RecordSet addressTable = new RecordSet();
// Create fields for input address table
Field[] fieldarray = new Field[3];
// Following field properties are required for batch geocode to work:
// Length, Name, Type. There also needs to be a field of type OID.
Field field0 = new Field();
field0.Name = "OID";
field0.Type = esriFieldType.esriFieldTypeOID;
field0.Length = 50;
fieldarray[0] = field0;
Field field1 = new Field();
field1.Name = "Street";
field1.Type = esriFieldType.esriFieldTypeString;
field1.Length = 50;
fieldarray[1] = field1;
Field field2 = new Field();
field2.Name = "Zone";
field2.Type = esriFieldType.esriFieldTypeString;
field2.Length = 50;
fieldarray[2] = field2;
Fields fields = new Fields();
fields.FieldArray = fieldarray;
addressTable.Fields = fields;
// Add records to input address table
Record[] records = new Record[2];
Record record1 = new Record();
record1.Values = new object[3] { 0, "5950 Magnolia Ave.", "92506" };
records[0] = record1;
Record record2 = new Record();
record2.Values = new object[3] { 1, "5962 Magnolia Ave.", "92506" };
records[1] = record2;
addressTable.Records = records;
// Generate results table
RecordSet results = geocodeservice.GeocodeAddresses(addressTable, geocodePropSet, null);
if (results != null)
{
string fieldsoutput = string.Empty;
foreach (Field field in results.Fields.FieldArray)
{
fieldsoutput += field.Name + "\t";
}
foreach (Record record in results.Records)
{
string valuesoutput = string.Empty;
object[] values = record.Values;
int v = 0;
foreach (Field field in results.Fields.FieldArray)
{
valuesoutput += values[v].ToString() + "\t";
v++;
}
}
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
Fields addressfields = geocodeservice.GetAddressFields();
foreach (Field addressfield in addressfields.FieldArray)
{
// Input field name
System.Diagnostics.Debug.WriteLine("Name: " + addressfield.Name);
// Descriptive name
System.Diagnostics.Debug.WriteLine("Alias Name: " + addressfield.AliasName);
// Is required?
System.Diagnostics.Debug.WriteLine("Required: " + addressfield.Required.ToString());
// Data type
System.Diagnostics.Debug.WriteLine("Type: " + addressfield.Type.ToString());
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
PropertySet propertymods = geocodeservice.GetLocatorProperties();
Fields candidatefields = geocodeservice.GetCandidateFields(propertymods);
foreach (Field candidatefield in candidatefields.FieldArray)
{
// Descriptive name
System.Diagnostics.Debug.WriteLine("Alias Name: " + candidatefield.AliasName);
// Input field name
System.Diagnostics.Debug.WriteLine("Name: " + candidatefield.Name);
// Is required?
System.Diagnostics.Debug.WriteLine("Required: " + candidatefield.Required.ToString());
// Data type
System.Diagnostics.Debug.WriteLine("Type: " + candidatefield.Type.ToString());
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
PropertySet fieldmapproperties = geocodeservice.GetDefaultInputFieldMapping();
PropertySetProperty[] fieldmaparray = fieldmapproperties.PropertyArray;
foreach (PropertySetProperty fieldmapproperty in fieldmaparray)
{
System.Diagnostics.Debug.WriteLine(fieldmapproperty.Key.ToString());
System.Diagnostics.Debug.WriteLine(fieldmapproperty.Value.ToString());
}
GetIntersectionCandidateFields
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
PropertySet propertymods = geocodeservice.GetLocatorProperties();
Fields candidatefields = geocodeservice.GetIntersectionCandidateFields(propertymods);
foreach (Field candidatefield in candidatefields.FieldArray)
{
// Descriptive name
System.Diagnostics.Debug.WriteLine("Alias Name: " + candidatefield.AliasName);
// Input field name
System.Diagnostics.Debug.WriteLine("Name: " + candidatefield.Name);
// Is required?
System.Diagnostics.Debug.WriteLine("Required: " + candidatefield.Required.ToString());
// Data type
System.Diagnostics.Debug.WriteLine("Type: " + candidatefield.Type.ToString());
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
PropertySet locatorProperties = geocodeservice.GetLocatorProperties();
PropertySetProperty[] locatorArray = locatorProperties.PropertyArray;
// Display locator properties and default values
foreach (PropertySetProperty locatorProperty in locatorArray)
{
System.Diagnostics.Debug.WriteLine(locatorProperty.Key.ToString());
System.Diagnostics.Debug.WriteLine(locatorProperty.Value.ToString());
}
// Change locator property value
for (int index = 0; index < locatorArray.Length; index++)
{
PropertySetProperty property = locatorArray[index];
switch (property.Key)
{
case "MinimumMatchScore":
property.Value = "50";
break;
case "MinimumCandidateScore":
property.Value = "50";
break;
}
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
PropertySet propertymods = geocodeservice.GetLocatorProperties();
Fields candidatefields = geocodeservice.GetResultFields(propertymods);
foreach (Field candidatefield in candidatefields.FieldArray)
{
// Descriptive name
System.Diagnostics.Debug.WriteLine("Alias Name: " + candidatefield.AliasName);
// Input field name
System.Diagnostics.Debug.WriteLine("Name: " + candidatefield.Name);
// Is required?
System.Diagnostics.Debug.WriteLine("Required: " + candidatefield.Required.ToString());
// Data type
System.Diagnostics.Debug.WriteLine("Type: " + candidatefield.Type.ToString());
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
Fields standardizedfields = geocodeservice.GetStandardizedFields();
foreach (Field standardfield in standardizedfields.FieldArray)
{
// Descriptive name
System.Diagnostics.Debug.WriteLine("Alias Name: " + standardfield.AliasName);
// Input field name
System.Diagnostics.Debug.WriteLine("Name: " + standardfield.Name);
// Is required?
System.Diagnostics.Debug.WriteLine("Required: " + standardfield.Required.ToString());
// Data type
System.Diagnostics.Debug.WriteLine("Type: " + standardfield.Type.ToString());
}
// Define address inputs
PropertySet stnGeocodePropSet = new PropertySet();
PropertySetProperty[] stnPropArray = new PropertySetProperty[5];
PropertySetProperty stngeocodeProp = new PropertySetProperty();
stngeocodeProp.Key = "AHN";
stngeocodeProp.Value = "5950";
stnPropArray[0] = stngeocodeProp;
PropertySetProperty stngeocodeProp1 = new PropertySetProperty();
stngeocodeProp1.Key = "ASN";
stngeocodeProp1.Value = "Magnolia";
stnPropArray[1] = stngeocodeProp1;
PropertySetProperty stngeocodeProp2 = new PropertySetProperty();
stngeocodeProp2.Key = "AST";
stngeocodeProp2.Value = "AVE";
stnPropArray[2] = stngeocodeProp2;
PropertySetProperty stngeocodeProp3 = new PropertySetProperty();
stngeocodeProp3.Key = "AZN";
stngeocodeProp3.Value = "92506";
stnPropArray[3] = stngeocodeProp3;
PropertySetProperty stngeocodeProp4 = new PropertySetProperty();
stngeocodeProp4.Key = "Addr_type";
stngeocodeProp4.Value = "A";
stnPropArray[4] = stngeocodeProp4;
stnGeocodePropSet.PropertyArray = stnPropArray;
PropertySet
stnpropertyset = geocodeservice.GeocodeAddress(stnGeocodePropSet, null);
GetStandardizedIntersectionFields
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
Fields standardizedfields = geocodeservice.GetStandardizedIntersectionFields();
foreach (Field standardfield in standardizedfields.FieldArray)
{
// Descriptive name
System.Diagnostics.Debug.WriteLine("Alias Name: " + standardfield.AliasName);
// Input field name
System.Diagnostics.Debug.WriteLine("Name: " + standardfield.Name);
// Is required?
System.Diagnostics.Debug.WriteLine("Required: " + standardfield.Required.ToString());
// Data type
System.Diagnostics.Debug.WriteLine("Type: " + standardfield.Type.ToString());
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
// Set reverse geocode search parameters
PropertySetProperty revGeocodeProp = new PropertySetProperty();
revGeocodeProp.Key = "ReverseDistanceUnits";
revGeocodeProp.Value = "Meters";
PropertySetProperty revGeocodeProp1 = new PropertySetProperty();
revGeocodeProp1.Key = "ReverseDistance";
revGeocodeProp1.Value = "100";
// Optionally define output spatial reference for reverse geocoded point
ProjectedCoordinateSystem projectedCoordinateSystem = new ProjectedCoordinateSystem();
projectedCoordinateSystem.WKID = 54004;
projectedCoordinateSystem.WKIDSpecified = true;
PropertySetProperty revGeocodeProp2 = new PropertySetProperty();
revGeocodeProp2.Key = "OutputSpatialReference";
revGeocodeProp2.Value = projectedCoordinateSystem;
PropertySetProperty[]
propArray = new PropertySetProperty[]
{revGeocodeProp, revGeocodeProp1, revGeocodeProp2 };
PropertySet revGeocodePropSet = new PropertySet();
revGeocodePropSet.PropertyArray = propArray;
// Create point to reverse geocode, define input spatial reference
PointN inputPoint = new PointN();
inputPoint.X = -117.391;
inputPoint.Y = 33.961;
GeographicCoordinateSystem geographicCoordinateSystem = new GeographicCoordinateSystem();
geographicCoordinateSystem.WKID = 4326;
geographicCoordinateSystem.WKIDSpecified = true;
inputPoint.SpatialReference = geographicCoordinateSystem;
// Reverse geocode
PropertySet
results = geocodeservice.ReverseGeocode(inputPoint, false, revGeocodePropSet);
// Iterate through results
PropertySetProperty[] resultsArray = results.PropertyArray;
// For each result, print address and matched point
foreach (PropertySetProperty result in resultsArray)
{
System.Diagnostics.Debug.WriteLine(result.Key.ToString());
if (result.Value is PointN)
{
PointN pn = (PointN)result.Value;
System.Diagnostics.Debug.WriteLine(pn.X + ", " + pn.Y);
}
else
{
System.Diagnostics.Debug.WriteLine(result.Value.ToString());
}
}
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost/arcgis/services/GeocodeService/GeocodeServer";
// Define address inputs
PropertySet geocodePropSet = new PropertySet();
PropertySetProperty[] propArray = new PropertySetProperty[2];
PropertySetProperty geocodeProp = new PropertySetProperty();
geocodeProp.Key = "Street";
geocodeProp.Value = "5950 Magnolia Ave.";
propArray[0] = geocodeProp;
PropertySetProperty geocodeProp1 = new PropertySetProperty();
geocodeProp1.Key = "Zone";
geocodeProp1.Value = "92506";
propArray[1] = geocodeProp1;
geocodePropSet.PropertyArray = propArray;
PropertySet standardizedAddress = geocodeservice.StandardizeAddress(geocodePropSet, null);
PropertySetProperty[] standardArray = standardizedAddress.PropertyArray;
foreach (PropertySetProperty result in standardArray)
{
System.Diagnostics.Debug.WriteLine(result.Key.ToString());
System.Diagnostics.Debug.WriteLine(result.Value.ToString());=
}
GeodataService_GeodataServer geodataservice = new GeodataService_GeodataServer();
geodataservice.Url = "http://localhost/arcgis/services/GeodataService/GeodataServer";
string
defaultversionname = geodataservice.GetDefaultWorkingVersion();
GeodataService_GeodataServer geodataservice = new GeodataService_GeodataServer();
geodataservice.Url = "http://localhost/arcgis/services/GeodataService/GeodataServer";
int
maxrecordcount = geodataservice.GetMaxRecordCount();
GeodataService_GeodataServer geodataservice = new GeodataService_GeodataServer();
geodataservice.Url = "http://localhost/arcgis/services/GeodataService/GeodataServer";
try
{
GPVersionInfo[] gpversioninfos = geodataservice.GetVersions();
foreach (GPVersionInfo gpvi in gpversioninfos)
{
string versionname = gpvi.VersionName;
esriVersionAccess access = gpvi.Access;
}
}
// If not an ArcSDE geodatabase, "Error processing server request" will be returned.
catch (System.Web.Services.Protocols.SoapException soapex)
{
string message = soapex.Message;
}
catch (Exception ex) { }
finally
{
geodataservice.Dispose();
}
GeodataService_GeodataServer geodataservice = new GeodataService_GeodataServer();
geodataservice.Url
= "http://localhost/arcgis/services/GeodataServiceLocal/GeodataServer";
esriWorkspaceType
workspacetype = geodataservice.GetWrappedWorkspaceType();
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url
= "http://localhost/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference.WKT = "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]";
SpatialReference bufferSpatialReference = new ProjectedCoordinateSystem();
// USA_Contiguous_Lambert_Conformal_Conic
bufferSpatialReference.WKID = 102004;
bufferSpatialReference.WKIDSpecified = true;
SpatialReference outputSpatialReference = inputSpatialReference;
PointN inputPoint1 = new PointN();
inputPoint1.X = -120;
inputPoint1.Y = 45;
PointN inputPoint2 = new PointN();
inputPoint2.X = -110;
inputPoint2.Y = 40;
Geometry[] inputGeometry = new Geometry[] { inputPoint1, inputPoint2 };
double[] distances = new double[] { 200, 400 };
LinearUnit linearUnit = new LinearUnit();
// US survey mile
linearUnit.WKID = 9035;
linearUnit.WKIDSpecified = true;
bool unionResults = false;
Geometry[] outputGeometry = geometryService.Buffer(inputSpatialReference, bufferSpatialReference, outputSpatialReference,
distances, linearUnit, unionResults, inputGeometry);
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url
= "http://localhost/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = new wsgeometry.ProjectedCoordinateSystem();
// World Mercator
inputSpatialReference.WKID = 54004;
inputSpatialReference.WKIDSpecified = true;
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 inputPath = new Path();
inputPath.PointArray = pntarray1;
Path[] paths = new Path[] { inputPath };
PolylineN inputPolyline = new PolylineN();
inputPolyline.PathArray = paths;
Geometry[] inputGeometry = new Geometry[] { inputPolyline };
double maxSegmentLength = 10000;
bool useDeviationDensification = false;
double densificationParam = 0;
Geometry[] outputGeometry = geometryService.Densify(inputSpatialReference, inputGeometry, maxSegmentLength,
useDeviationDensification,
densificationParam);
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url
= "http://localhost/arcgis/services/Geometry/GeometryServer";
// Geographic WGS84
SpatialReference outputSpatialReference = geometryService.FindSRByWKID("EPSG", 4326, -1, true, true);
bool
isHighPrecision = outputSpatialReference.HighPrecision;
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost/arcgis/services/Geometry/GeometryServer";
// Geographic WGS84
SpatialReference outputSpatialReference = geometryService.FindSRByWKT("GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]", "", true, true);
int
predefinedWKID = outputSpatialReference.WKID;
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost/arcgis/services/Geometry/GeometryServer";
// International Meter
LinearUnit
linearUnit = (LinearUnit) geometryService.FindUnitsByWKID("EPSG",
9001);
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost/arcgis/services/Geometry/GeometryServer";
// International Meter
LinearUnit
linearUnit = (LinearUnit)geometryService.FindUnitsByWKT("UNIT[\"Meter\",1.0,AUTHORITY[\"EPSG\",9001]]");
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = geometryService.FindSRByWKID("EPSG", 54004, -1, true, true);
// New PointN array
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};
// New PolylineN
Path path1 = new Path();
path1.PointArray = pnts1;
Path[] paths = new Path[] { path1 };
PolylineN polylinen = new PolylineN();
polylinen.PathArray = paths;
// New PolygonN
Ring ring1 = new Ring();
ring1.PointArray = pnts1;
Ring[]
rings = new Ring[] { ring1 };
PolygonN polygonn = new PolygonN();
polygonn.RingArray = rings;
PolygonN[] polygonArray = new PolygonN[] { polygonn };
double[] lengths = null;
double[]
areas = geometryService.GetAreasAndLengths(inputSpatialReference, polygonArray,
out lengths);
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost/arcgis/services/Geometry/GeometryServer";
// GCS-NAD83
SpatialReference inputSpatialReference = geometryService.FindSRByWKID("EPSG", 4269, -1, true, true);
PointN pnt1 = new PointN();
pnt1.X = 10.0;
pnt1.Y = 30.0;
PointN pnt2 = new PointN();
pnt2.X = 10.0;
pnt2.Y = 40.0;
PointN pnt3 = new PointN();
pnt3.X = 20.0;
pnt3.Y = 40.0;
PointN pnt4 = new PointN();
pnt4.X = 20.0;
pnt4.Y = 30.0;
PointN pnt5 = new PointN();
pnt5.X = 10.0;
pnt5.Y = 30.0;
PointN[] pnts1 = new PointN[] { pnt1, pnt2, pnt3, pnt4, pnt5 };
Ring ring1 = new Ring();
ring1.PointArray = pnts1;
Ring[] rings = new Ring[] { ring1 };
PolygonN polygonn = new PolygonN();
polygonn.RingArray = rings;
PolygonN[] polygonArray = new PolygonN[] { polygonn };
Point[]
labelPoints = (Point[])geometryService.GetLabelPoints(inputSpatialReference,
polygonArray);
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = geometryService.FindSRByWKID("EPSG", 54004, -1, true, true);
// New PointN array
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 };
// New PolylineN
Path path1 = new Path();
path1.PointArray = pnts1;
Path[] paths = new Path[] { path1 };
PolylineN polylinen = new PolylineN();
polylinen.PathArray = paths;
PolylineN[] polylineArray = new PolylineN[] { polylinen };
double[]
lengths = geometryService.GetLengths(inputSpatialReference, polylineArray);
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference.WKID = 4326;
inputSpatialReference.WKIDSpecified = true;
SpatialReference outputSpatialReference = new ProjectedCoordinateSystem();
// USA_Contiguous_Lambert_Conformal_Conic
outputSpatialReference.WKID = 102004;
outputSpatialReference.WKIDSpecified = true;
PointN pnt1 = new PointN();
pnt1.X = -120;
pnt1.Y = 50;
PointN pnt2 = new PointN();
pnt2.X = -110;
pnt2.Y = 40;
PointN pnt3 = new PointN();
pnt3.X = -130;
pnt3.Y = 40;
PointN[] pnts1 = new PointN[] { pnt1, pnt2, pnt3 };
Path path1 = new Path();
path1.PointArray = pnts1;
Path[] paths = new Path[] { path1 };
PolylineN polylinen = new PolylineN();
polylinen.PathArray = paths;
Ring ring1 = new Ring();
ring1.PointArray = pnts1;
Ring[] rings = new Ring[] { ring1 };
PolygonN polygonn = new PolygonN();
polygonn.RingArray = rings;
Geometry[] inputGeometry = new Geometry[] { pnt1, polylinen, polygonn };
bool transformForward = false;
GeoTransformation transformation = new GeoTransformation();
// NAD1983_To_WGS1984_1
transformation.WKID = 1188;
transformation.WKIDSpecified = true;
EnvelopeN extent = null;
Geometry[] outputGeometry = geometryService.Project(inputSpatialReference, outputSpatialReference, transformForward,
transformation,
extent, inputGeometry);
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
inputSpatialReference.WKID = 4326;
inputSpatialReference.WKIDSpecified = true;
// First input geometry array - 1 polygon
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[] rings = new Ring[] { ring1 };
PolygonN polygon1 = new PolygonN();
polygon1.RingArray = rings;
Geometry[] inputGeometry1 = new Geometry[] { polygon1 };
// Second input geometry array - 3 points
PointN pnt1b = new PointN();
pnt1b.X = 20.0;
pnt1b.Y = 40.0;
PointN pnt2b = new PointN();
pnt2b.X = 10.0;
pnt2b.Y = 30.0;
PointN pnt3b = new PointN();
pnt3b.X = 50.0;
pnt3b.Y = 50.0;
Geometry[] inputGeometry2 = new Geometry[3];
// Inside polygon
inputGeometry2.SetValue(pnt1b, 0);
// Edge of polygon
inputGeometry2.SetValue(pnt2b, 1);
// Outside polygon
inputGeometry2.SetValue(pnt3b, 2);
// If esriGeometryRelationRelation, define relation parameter
esriGeometryRelationEnum enumRelate = esriGeometryRelationEnum.esriGeometryRelationRelation;
// G1 = first (base) geometry array, G2 = second (comparison) geometry array
string relationParameter = "G2 INTERSECT G1.BOUNDARY";
RelationResult[] relationResults = geometryService.Relation(inputSpatialReference, inputGeometry1, inputGeometry2,
enumRelate,
relationParameter);
Geometry_GeometryServer geometryService = new Geometry_GeometryServer();
geometryService.Url = "http://localhost/arcgis/services/Geometry/GeometryServer";
SpatialReference inputSpatialReference = geometryService.FindSRByWKID("EPSG", 4326, -1, true, true);
// 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;
Geometry[] geometryArray = new Geometry[] { polygon1 };
// Overlapping section removed
Geometry[] simplifiedGeometry = geometryService.Simplify(inputSpatialReference, geometryArray);