VB.NET code examples for proxy methods

This page contains VB.NET code examples for ArcGIS Server SOAP proxy class methods and the value objects used for input and output types. 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 be ServiceName_<service type>.

Catalog

GetFolders

Dim catalog As Catalog = New Catalog()

catalog.Url = "http://localhost:6080/arcgis/services"

 

Dim folders() As String = catalog.GetFolders()

Dim index As Integer

 

For index = 0 To folders.Length- 1

      Dim foldername As String = folders(index)

Next

GetMessageFormats

Dim catalog As Catalog = New Catalog()

catalog.Url = "http://localhost:6080/arcgis/services"

 

Dim messageformat As esriServiceCatalogMessageFormat = catalog.GetMessageFormats()

GetMessageVersion

Dim catalog As Catalog = New Catalog()

catalog.Url = "http://localhost:6080/arcgis/services"

 

Dim arcgisversion As esriArcGISVersion = catalog.GetMessageVersion()

GetServiceDescriptions

Dim catalog As Catalog = New Catalog()

catalog.Url = "http://localhost:6080/arcgis/services"

 

Dim servicedescriptions() As ServiceDescription = catalog.GetServiceDescriptions()

Dim servicedesc As ServiceDescription

 

For Each servicedesc In servicedescriptions

      Dim name As String = servicedesc.Name

      Dim type As String = servicedesc.Type

      Dim parenttype As String = servicedesc.ParentType

      Dim capabilities As String = servicedesc.Capabilities

      Dim url As String = servicedesc.Url

Next

GetServiceDescriptionsEx

Dim catalog As Catalog = New Catalog()

catalog.Url = "http://localhost:6080/arcgis/services"

 

Dim servicedescriptions() As ServiceDescription = catalog.GetServiceDescriptionsEx("SecureDirectory")

Dim servicedesc As ServiceDescription

 

For Each servicedesc In servicedescriptions

      Dim name As String = servicedesc.Name

      Dim type As String = servicedesc.Type

      Dim parenttype As String = servicedesc.ParentType

      Dim capabilities As String = servicedesc.Capabilities

      Dim url As String = servicedesc.Url

Next

GetTokenServiceURL

Dim url As String = "http://localhost:6080/arcgis/services"

Dim catalog As Catalog = New Catalog(url)

 

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim tokenurl As String = catalog.GetTokenServiceURL()

Dim tokenrequesturl As String = tokenurl + "?request=getToken&username=myuser&password=secret"

Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(tokenrequesturl)

Dim response As System.Net.WebResponse = request.GetResponse()

Dim responseStream As System.IO.Stream = response.GetResponseStream()

Dim readStream As System.IO.StreamReader = New System.IO.StreamReader(responseStream)

Dim myToken As String = readStream.ReadToEnd()

 

mapservice.Url = mapservice.Url + "token=" + myToken

Dim mapname As String = mapservice.GetDefaultMapName()

RequiresTokens

Dim catalog As Catalog = New Catalog()

catalog.Url = "http://localhost:6080/arcgis/services"

 

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

If catalog.RequiresTokens() Then

      Dim tokenurl As String = catalog.GetTokenServiceURL()

      Dim tokenrequesturl As String = tokenurl + "?request=getToken&username=myuser&password=secret"

      Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(tokenrequesturl)

      Dim response As System.Net.WebResponse = request.GetResponse()

      Dim responseStream As System.IO.Stream = response.GetResponseStream()

      Dim readStream As System.IO.StreamReader = New System.IO.StreamReader(responseStream)

      Dim myToken As String = readStream.ReadToEnd()

      mapservice.Url = mapservice.Url + "?token=" + myToken

End If

 

Dim mapname As String = mapservice.GetDefaultMapName()

MapServer

ComputeDistance

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim pnt0 As wsmap.PointN = New PointN()

pnt0.X = -120.0

pnt0.Y = 30.0

 

Dim pnt1 As wsmap.PointN = New PointN()

pnt1.X = -110.0

pnt1.Y = 35.0

 

Dim distance As Double = mapservice.ComputeDistance(mapname, pnt0, pnt1, esriUnits.esriMiles)

ComputeScale

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim imgdisp As ImageDisplay = New ImageDisplay()

imgdisp.ImageHeight = 500 'pixels

imgdisp.ImageWidth = 500 'pixels

imgdisp.ImageDPI = 96

 

Dim scale As Double = mapservice.ComputeScale(mapdesc, imgdisp)

ExportMapImage

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim imgtype As ImageType = New ImageType()

imgtype.ImageFormat = esriImageFormat.esriImagePNG

imgtype.ImageReturnType = esriImageReturnType.esriImageReturnURL

 

Dim imgdisp As ImageDisplay = New ImageDisplay()

imgdisp.ImageHeight = 500 'pixels

imgdisp.ImageWidth = 500 'pixels

imgdisp.ImageDPI = 96

 

Dim imgdesc As ImageDescription = New ImageDescription()

imgdesc.ImageDisplay = imgdisp

imgdesc.ImageType = imgtype

 

Dim mapimg As MapImage = mapservice.ExportMapImage(mapdesc, imgdesc)

ExportScaleBar

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

' Define scale bar properties

Dim scalebar As AlternatingScaleBar = New AlternatingScaleBar()

 

' Define Unit label

scalebar.Units = esriUnits.esriMiles

scalebar.UnitsSpecified = True

Dim unittextsymbol As TextSymbol = 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

 

Dim fillsymbol As SimpleFillSymbol = New SimpleFillSymbol()

Dim fillcolor As wsmap.RgbColor = New wsmap.RgbColor()

fillcolor.Red = 255

fillcolor.Green = 0

fillcolor.Blue = 0

fillsymbol.Color = fillcolor

 

scalebar.FillSymbol1 = fillsymbol

 

' Define division labels

Dim textsymbol As 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)

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

Dim imgdispmap As ImageDisplay = New ImageDisplay()

imgdispmap.ImageWidth = 500

imgdispmap.ImageHeight = 500

imgdispmap.ImageDPI = 96

 

' Define scale bar image properties (ImageDescription)

Dim imgtype As ImageType = New ImageType()

imgtype.ImageFormat = esriImageFormat.esriImagePNG

imgtype.ImageReturnType = esriImageReturnType.esriImageReturnURL

Dim imgdispscalebar As ImageDisplay = New ImageDisplay()

imgdispscalebar.ImageHeight = 75 'pixels

imgdispscalebar.ImageWidth = 400 'pixels

Dim imgdescscalebar As ImageDescription = New ImageDescription()

imgdescscalebar.ImageDisplay = imgdispscalebar

imgdescscalebar.ImageType = imgtype

 

' Define background color

Dim backcolor As wsmap.RgbColor = New wsmap.RgbColor()

backcolor.Red = 255

backcolor.Green = 255

backcolor.Blue = 255

 

' Create scale bar image

Dim imgresult As ImageResult = mapservice.ExportScaleBar(scalebar, mapdesc, imgdispmap, backcolor, imgdescscalebar)

Find

Dim mapservice As MapService_MapServer = New MapService_MapServer(

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

 

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim imgdisp As ImageDisplay = New ImageDisplay()

imgdisp.ImageHeight = 500 'pixels

imgdisp.ImageWidth = 500 'pixels

imgdisp.ImageDPI = 96

 

Dim searchstring As String = "Washington"

Dim contains_searchstring As Boolean = True

Dim fieldname As String = String.Empty ' all fields

Dim findoption As esriFindOption = esriFindOption.esriFindAllLayers

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerids(layerdescriptions.Length-1) As Integer

Dim i As Integer = 0

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

      layerids.SetValue(layerdesc.LayerID, i)

      i = i + 1

Next

 

Dim findresults As MapServerFindResult() = mapservice.Find(mapdesc, imgdisp, searchstring, contains_searchstring, fieldname, findoption, layerids)

FromMapPoints

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim imgdisp As ImageDisplay = New ImageDisplay()

imgdisp.ImageHeight = 500 'pixels

imgdisp.ImageWidth = 500 'pixels

imgdisp.ImageDPI = 96

 

Dim multipoint As MultipointN = New MultipointN()

Dim points() As PointN = New PointN(1) {}

Dim pnt0 As wsmap.PointN = New PointN()

pnt0.X = -120.0

pnt0.Y = 35.0

points(0) = pnt0

multipoint.PointArray = points

 

Dim screeny() As Integer = Nothing

Dim screenx() As Integer = mapservice.FromMapPoints(mapdesc, imgdisp, multipoint, screeny)

GetCacheName

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

 

      If mapservice.HasLayerCache(mapname, layerdesc.LayerID) Then

            Dim layercachename As String = mapservice.GetCacheName(mapname, layerdesc.LayerID)

      End If

GetCacheControlInfo

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim cachecontrolinfo As CacheControlInfo = mapservice.GetCacheControlInfo(mapname)

GetCacheDescriptionInfo

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim cachedescinfo As CacheDescriptionInfo = mapservice.GetCacheDescriptionInfo(mapname)

Dim cachecontrolinfo As CacheControlInfo = cachedescinfo.CacheControlInfo

Dim tilecacheinfo As TileCacheInfo = cachedescinfo.TileCacheInfo

Dim tileimginfo As TileImageInfo = cachedescinfo.TileImageInfo

 

Dim cachetype As esriCachedMapServiceType = cachedescinfo.ServiceType

GetDefaultMapName

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

GetDocumentInfo

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim documentproperties As PropertySet = mapservice.GetDocumentInfo()

Dim propertyarray() As PropertySetProperty = documentproperties.PropertyArray

Dim documentprop As PropertySetProperty

Dim key As String

Dim value As String

 

For Each documentprop In propertyarray

      key = documentprop.Key.ToString()

      value = documentprop.Value.ToString()

Next

GetLayerTile

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

 

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

 

' Pixel height and width of map display on the client. In this case, a Windows Form

' PictureBox control.

Dim picturewidth As Integer = pictureBox1.Width

Dim pictureheight As Integer = pictureBox1.Height

 

Dim mapextent As EnvelopeN = CType(mapdesc.MapArea.Extent, EnvelopeN)

' Use map scale resolution (map units per pixel) to determine tile level

Dim mapresolution As Double = Math.Abs(mapextent.XMax - mapextent.XMin) / picturewidth

Dim imgbitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(picturewidth, pictureheight)

Dim imggraphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(imgbitmap)

imggraphics.FillRectangle(New System.Drawing.SolidBrush(System.Drawing.Color.LightGray), 0, 0, _

picturewidth, pictureheight)

 

Dim layerdesc_maxindex As Integer = layerdescriptions.Length - 1

' Iterate through layers bottom up. Polygons on bottom, then lines, then points.

Dim d As Integer

For d = layerdesc_maxindex To 0 Step d - 1

      Dim layerdesc As LayerDescription = layerdescriptions(d)

      If mapservice.HasLayerCache(mapname, layerdesc.LayerID) Then

            Dim tci As TileCacheInfo = mapservice.GetTileCacheInfo(mapservice.GetDefaultMapName())

            Dim tcis() As LODInfo = tci.LODInfos

 

            ' Map units per pixel

            Dim tileresolution As Double = 0

 

            ' Scale level

                  Dim tilelevel As Integer = 0

            Dim ldi As LODInfo

            For Each ldi In tcis

                  Dim ldi_resolution As Double = ldi.Resolution

                  tileresolution = ldi_resolution

                  tilelevel = ldi.LevelID

                        If mapresolution >= ldi_resolution Then

                              Exit For

                        End If

            Next

 

            ' Measured from the origin

            Dim minx As Double = mapextent.XMin

            Dim miny As Double = mapextent.YMin

            Dim maxx As Double = mapextent.XMax

            Dim maxy As Double = mapextent.YMax

 

            ' Origin of the cache (upper left corner)

            Dim xorigin As Double = (CType(tci.TileOrigin, PointN)).X

            Dim yorigin As Double = (CType(tci.TileOrigin, PointN)).Y

 

            ' Get minimum tile column

            Dim minxtile As Double = (minx - xorigin) / (tci.TileCols * tileresolution)

 

            ' Get minimum tile row

            ' From the origin, maxy is minimum y

            Dim minytile As Double = (yorigin - maxy) / (tci.TileRows * tileresolution)

 

            ' Get maximum tile column

            Dim maxxtile As Double = (maxx - xorigin) / (tci.TileCols * tileresolution)

 

            ' Get maximum tile row

            ' From the origin, miny is maximum y

            Dim maxytile As Double = (yorigin - miny) / (tci.TileRows * tileresolution)

 

            ' Return integer value for min and max, row and column

            Dim mintilecolumn As Integer = CType(Math.Floor(minxtile), Integer)

            Dim mintilerow As Integer = CType(Math.Floor(minytile), Integer)

            Dim maxtilecolumn As Integer = CType(Math.Floor(maxxtile), Integer)

            Dim maxtilerow As Integer = CType(Math.Floor(maxytile), Integer)

 

            ' Origin of the min tile

            Dim xmintileorigin As Double = xorigin + (mintilecolumn * (tci.TileCols * tileresolution))

            Dim ymintileorigin As Double = 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

            Dim xadjust As Double = Math.Abs(minx - xmintileorigin)

            Dim yadjust As Double = Math.Abs(maxy - ymintileorigin)

            Dim xpixadjust As Integer = CType((xadjust / tileresolution), Integer)

            Dim ypixadjust As Integer = CType((yadjust / tileresolution), Integer)

            Dim tii As TileImageInfo = mapservice.GetTileImageInfo(mapservice.GetDefaultMapName())

            Dim rowindex As Integer = 0

 

            ' for each row in the map extent

            Dim row As Integer

            For row = mintilerow To maxtilerow Step row + 1

                  Dim colindex As Integer = 0

 

                  ' for each column in the row, in the map extent

                  Dim col As Integer

                  For col = mintilecolumn To maxtilecolumn Step col + 1

                        Dim myByteArray() As Byte = Nothing

                              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

                        End Try

 

                        ' If Tile was found, add it to the consolidated image graphic

                        If Not myByteArray Is Nothing Then

                              Dim NewImage As System.Drawing.Image

                              Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream(myByteArray, 0, _ myByteArray.Length)

 

                              Try

                                    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)

                              Finally

                                    ms.Dispose()

                              End Try

 

                        End If

 

                        colindex = colindex + 1

                  Next

 

                  rowindex = rowindex + 1

            Next

      End If

Next

 

' Post-processing, if necessary... otherwise just use imgbitmap with PictureBox

Dim picturebitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(picturewidth, pictureheight)

Dim graphicsimage As System.Drawing.Graphics = 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

GetLegendInfo

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim imgtype As ImageType = New ImageType()

imgtype.ImageFormat = esriImageFormat.esriImagePNG

imgtype.ImageReturnType = esriImageReturnType.esriImageReturnURL

 

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerids(layerdescriptions.Length-1) As Integer

Dim i As Integer = 0

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

      layerids.SetValue(layerdesc.LayerID, i)

      i = i + 1

Next

 

Dim legendpatch As MapServerLegendPatch = New MapServerLegendPatch()

legendpatch.ImageDPI = 96

legendpatch.Height = 24

legendpatch.Width = 24

 

Dim legendinfo As MapServerLegendInfo() = mapservice.GetLegendInfo(mapname, layerids, legendpatch, imgtype)

GetMapCount

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapcount As Integer = mapservice.GetMapCount()

GetMapName

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapcount As Integer = mapservice.GetMapCount()

Dim i As Integer

For i = 0 To mapcount - 1 Step i + 1

      Dim mapname As String = mapservice.GetMapName(i)

Next

GetMapTile

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

' Pixel height and width of map display on the client. In this case, a Windows Form

' PictureBox control.

Dim picturewidth As Integer = pictureBox1.Width

Dim pictureheight As Integer = pictureBox1.Height

 

Dim mapextent As EnvelopeN = CType(mapdesc.MapArea.Extent, EnvelopeN)

 

' Use map scale resolution (map units per pixel) to determine tile level

Dim mapresolution As Double = Math.Abs(mapextent.XMax - mapextent.XMin) / picturewidth

Dim imgbitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(picturewidth, pictureheight)

Dim imggraphics As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(imgbitmap)

imggraphics.FillRectangle(New System.Drawing.SolidBrush(System.Drawing.Color.LightGray), _

0, 0, picturewidth, pictureheight)

 

If mapservice.HasSingleFusedMapCache(mapname) Then

      Dim tci As TileCacheInfo = mapservice.GetTileCacheInfo(mapname)

      Dim tcis() As LODInfo = tci.LODInfos

 

      ' Map units per pixel

      Dim tileresolution As Double = 0

 

      ' Scale level

      Dim tilelevel As Integer = 0

      Dim ldi As LODInfo

 

      For Each ldi In tcis

            Dim ldi_resolution As Double = ldi.Resolution

            tileresolution = ldi_resolution

            tilelevel = ldi.LevelID

 

            If mapresolution >= ldi_resolution Then

                  Exit For

            End If

      Next

 

      ' Measured from the origin

      Dim minx As Double = mapextent.XMin

      Dim miny As Double = mapextent.YMin

      Dim maxx As Double = mapextent.XMax

      Dim maxy As Double = mapextent.YMax

 

      ' Origin of the cache (upper left corner)

      Dim xorigin As Double = (CType(tci.TileOrigin, PointN)).X

      Dim yorigin As Double = (CType(tci.TileOrigin, PointN)).Y

 

      ' Get minimum tile column

      Dim minxtile As Double = (minx - xorigin) / (tci.TileCols * tileresolution)

 

      ' Get minimum tile row

      ' From the origin, maxy is minimum y

      Dim minytile As Double = (yorigin - maxy) / (tci.TileRows * tileresolution)

 

      ' Get maximum tile column

      Dim maxxtile As Double = (maxx - xorigin) / (tci.TileCols * tileresolution)

 

      ' Get maximum tile row

      ' From the origin, miny is maximum y

      Dim maxytile As Double = (yorigin - miny) / (tci.TileRows * tileresolution)

 

      ' Return integer value for min and max, row and column

      Dim mintilecolumn As Integer = CType(Math.Floor(minxtile), Integer)

      Dim mintilerow As Integer = CType(Math.Floor(minytile), Integer)

      Dim maxtilecolumn As Integer = CType(Math.Floor(maxxtile), Integer)

      Dim maxtilerow As Integer = CType(Math.Floor(maxytile), Integer)

 

      ' Origin of the min tile

      Dim xmintileorigin As Double = xorigin + (mintilecolumn * (tci.TileCols * tileresolution))

      Dim ymintileorigin As Double = 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

      Dim xadjust As Double = Math.Abs(minx - xmintileorigin)

      Dim yadjust As Double = Math.Abs(maxy - ymintileorigin)

      Dim xpixadjust As Integer = CType((xadjust / tileresolution), Integer)

      Dim ypixadjust As Integer = CType((yadjust / tileresolution), Integer)

      Dim tii As TileImageInfo = mapservice.GetTileImageInfo(mapservice.GetDefaultMapName())

 

      Dim rowindex As Integer = 0

      ' for each row in the map extent

      Dim row As Integer

      For row = mintilerow To maxtilerow Step row + 1

            Dim colindex As Integer = 0

            ' for each column in the row, in the map extent

            Dim col As Integer

            For col = mintilecolumn To maxtilecolumn Step col + 1

                  Dim myByteArray() As Byte = Nothing

                  Dim cacheUrl As String = Nothing

 

                  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"c) + "/R" + row.ToString("x").PadLeft(8, "0"c) + "/C"+ col.ToString("x").PadLeft(8, "0"c) + imgType

                        Dim webreq As HttpWebRequest = CType(WebRequest.Create(cacheUrl), HttpWebRequest)

                        Dim webresp As HttpWebResponse = CType(webreq.GetResponse(), HttpWebResponse)

 

                        ' Can also use: System.Drawing.Image.FromStream(webresp.GetResponseStream()) to

                        ' read http response with image data

                        Dim theStream As System.IO.Stream = webresp.GetResponseStream()

                        Dim byte1 As Integer

                        Dim tempStream As System.IO.MemoryStream = New System.IO.MemoryStream()

 

                        While (byte1 = theStream.ReadByte()) <> -1

                              tempStream.WriteByte((CType(byte1, Byte)))

                        End While

 

                        myByteArray = tempStream.ToArray()

                  Catch

                        ' Tile may not be available because no data was present when creating the cache

                  End Try

 

                  ' If Tile was found, add it to the consolidated image graphic

                  If Not myByteArray Is Nothing Then

                        Dim NewImage As System.Drawing.Image

                        Dim ms As System.IO.MemoryStream = New System.IO.MemoryStream(myByteArray, 0, myByteArray.Length)

 

                        Try

                              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)

                        Finally

                              ms.Dispose()

                        End Try

 

                  End If

                  colindex = colindex + 1

            Next

            rowindex = rowindex + 1

      Next

End If

 

' Post-processing, if necessary... otherwise just use imgbitmap with PictureBox

Dim picturebitmap As System.Drawing.Bitmap = New System.Drawing.Bitmap(picturewidth, pictureheight)

Dim graphicsimage As System.Drawing.Graphics = 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

GetServerInfo

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

GetServiceConfigurationInfo

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim serviceproperties As PropertySet = mapservice.GetServiceConfigurationInfo()

Dim propertyarray() As PropertySetProperty = serviceproperties.PropertyArray

Dim serviceprop As PropertySetProperty

 

For Each serviceprop In propertyarray

      Dim key As String = serviceprop.Key.ToString()

      Dim value As String = serviceprop.Value.ToString()

Next

GetSQLSyntaxInfo

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

      Dim sqlsyntaxinfo As SQLSyntaxInfo = mapservice.GetSQLSyntaxInfo(mapname, layerdesc.LayerID)

Next

GetSupportedImageReturnTypes

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

' Mime or Url

Dim imgReturntype As esriImageReturnType = mapservice.GetSupportedImageReturnTypes()

GetTileCacheInfo

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

If mapservice.HasSingleFusedMapCache(mapname) Then

      Dim tilecacheinfo As TileCacheInfo = mapservice.GetTileCacheInfo(mapname)

End If

GetTileImageInfo

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

If mapservice.HasSingleFusedMapCache(mapname) Then

      Dim tileimageinfo As TileImageInfo = mapservice.GetTileImageInfo(mapname)

End If

GetVirtualCacheDirectory

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

 

' Use -1 for fused caches

Dim virtualcachedirectory As String = mapservice.GetVirtualCacheDirectory(mapname, -1)

HasLayerCache

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescrifption

 

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerids(layerdescriptions.Length-1) As Integer

Dim i As Integer = 0

Dim layerdesc As LayerDescription

For Each layerdesc In layerdescriptions

      If mapservice.HasLayerCache(mapname, layerdesc.LayerID) Then

            Dim layercachename As String = mapservice.GetCacheName(mapname, layerdesc.LayerID)

      End If

Next

HasSingleFusedMapCache

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

If mapservice.HasSingleFusedMapCache(mapname) Then

      Dim fusedcachename As String = mapservice.GetCacheName(mapname, -1)

End If

Identify

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim imgdisp As ImageDisplay = New ImageDisplay()

imgdisp.ImageHeight = 500 'pixels

imgdisp.ImageWidth = 500 'pixels

imgdisp.ImageDPI = 96

 

Dim inputpoint As PointN = 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.

Dim tolerance As Integer = 3

Dim dentifyoption As esriIdentifyOption = esriIdentifyOption.esriIdentifyAllLayers

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerids(layerdescriptions.Length-1) As Integer

Dim i As Integer = 0

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

      layerids.SetValue(layerdesc.LayerID, i)

      i = i + 1

Next

 

Dim identifyresults As MapServerIdentifyResult() = mapservice.Identify(mapdesc, imgdisp, inputpoint, _

tolerance, identifyoption, layerids)

IsFixedScaleMap

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

 

If mapservice.IsFixedScaleMap(mapname) Then

      Dim tilecacheinfo As TileCacheInfo = mapservice.GetTileCacheInfo(mapname)

End If

QueryFeatureCount

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

Dim maplayerinfos() As MapLayerInfo = mapinfo.MapLayerInfos

 

Dim layerid As Integer = 0

Dim geomeTryfieldname As String = String.Empty

Dim layerinfo As MapLayerInfo

 

For Each layerinfo In maplayerinfos

      If layerinfo.Name = "countries" Then

            layerid = layerinfo.LayerID

            Dim fields() As Field = layerinfo.Fields.FieldArray

            Dim field As Field

            For Each field In fields

                  If field.Type = esriFieldType.esriFieldTypeGeometry Then

                        geomeTryfieldname = field.Name

                        Exit For

                  End If

            Next

      End If

Next

 

Dim envelope As EnvelopeN = New EnvelopeN()

envelope.XMin = 0.0

envelope.YMin = 0.0

envelope.XMax = 180.0

envelope.YMax = 90.0

 

Dim spatialfilter As SpatialFilter = New SpatialFilter()

spatialfilter.FilterGeometry = envelope

spatialfilter.GeometryFieldName = geomeTryfieldname

spatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects

spatialfilter.WhereClause = "POP_CNTRY > 50000000"

 

Dim featurecount As Integer = mapservice.QueryFeatureCount(mapname, layerid, spatialfilter)

QueryFeatureCount2

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim maplayerinfos() As MapLayerInfo = mapinfo.MapLayerInfos

Dim layerid As Integer = 0

Dim geomeTryfieldname As String = String.Empty

Dim layerinfo As MapLayerInfo

 

For Each layerinfo In maplayerinfos

      If layerinfo.Name = "countries" Then

            layerid = layerinfo.LayerID

            Dim fields() As Field = layerinfo.Fields.FieldArray

            Dim field As Field

            For Each field In fields

                  If field.Type = esriFieldType.esriFieldTypeGeometry Then

                        geomeTryfieldname = field.Name

                        Exit For

                  End If

            Next

      End If

Next

 

Dim layerdescs() As LayerDescription = mapdesc.LayerDescriptions

Dim activelayerdesc As LayerDescription = Nothing

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescs

      If layerdesc.LayerID = layerid Then

            activelayerdesc = layerdesc

            Exit For

      End If

Next

 

activelayerdesc.DefinitionExpression = "POP_CNTRY > 50000000"

 

Dim envelope As EnvelopeN = New EnvelopeN()

envelope.XMin = 0.0

envelope.YMin = 0.0

envelope.XMax = 180.0

envelope.YMax = 90.0

 

Dim spatialfilter As SpatialFilter = New SpatialFilter()

spatialfilter.FilterGeometry = envelope

spatialfilter.GeometryFieldName = geomeTryfieldname

spatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects

 

Dim featurecount As Integer = mapservice.QueryFeatureCount2(mapname, activelayerdesc, spatialfilter)

QueryFeatureData

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

Dim maplayerinfos() As MapLayerInfo = mapinfo.MapLayerInfos

 

Dim layerid As Integer = 0

Dim geomeTryfieldname As String = String.Empty

Dim layerinfo As MapLayerInfo

 

For Each layerinfo In maplayerinfos

      If layerinfo.Name = "countries" Then

            layerid = layerinfo.LayerID

            Dim fields() As Field = layerinfo.Fields.FieldArray

            Dim field As Field

 

            For Each field In fields

                  If field.Type = esriFieldType.esriFieldTypeGeometry Then

                        geomeTryfieldname = field.Name

                        Exit For

                  End If

            Next

      End If

Next

 

Dim queryfilter As QueryFilter = New QueryFilter()

queryfilter.WhereClause = "CNTRY_NAME LIKE '%United%'"

Dim recordset As RecordSet = Nothing

 

Try

      recordset = mapservice.QueryFeatureData(mapname, layerid, queryfilter)

Catch ex As Exception

' Improper format of where clause will cause exception

End Try

 

If Not recordset Is Nothing Then

      Dim fieldsoutput As String = String.Empty

      Dim field As Field

 

      For Each field In recordset.Fields.FieldArray

            fieldsoutput += field.Name + vbTab

      Next

 

      Dim record As Record

      For Each record In recordset.Records

            Dim valuesoutput As String = String.Empty

            Dim values() As Object = record.Values

            Dim v As Integer = 0

            Dim field2 As Field

            For Each field2 In recordset.Fields.FieldArray

                  valuesoutput += values(v).ToString() + vbTab

                  v = v + 1

            Next

      Next

End If

QueryFeatureData2

class=codesample>Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

Dim maplayerinfos() As MapLayerInfo = mapinfo.MapLayerInfos

 

Dim layerid As Integer = 0

Dim geomeTryfieldname As String = String.Empty

Dim layerinfo As MapLayerInfo

 

For Each layerinfo In maplayerinfos

      If layerinfo.Name = "countries" Then

            layerid = layerinfo.LayerID

            Dim fields() As Field = layerinfo.Fields.FieldArray

            Dim field As Field

            For Each field In fields

                  If field.Type = esriFieldType.esriFieldTypeGeometry Then

                        geomeTryfieldname = field.Name

                        Exit For

                  End If

            Next

      End If

Next

 

Dim layerdescs() As LayerDescription = mapdesc.LayerDescriptions

Dim activelayerdesc As LayerDescription = Nothing

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescs

      If layerdesc.LayerID = layerid Then

            activelayerdesc = layerdesc

            Exit For

      End If

Next

 

' Probably defined by a call to QueryFeatureIDs

activelayerdesc.DefinitionExpression = "FID IN (214, 228, 235, 245)"

Dim queryfilter As QueryFilter = New QueryFilter()

queryfilter.WhereClause = "CNTRY_NAME LIKE '%United%'"

Dim queryresultoptions As QueryResultOptions = New QueryResultOptions()

queryresultoptions.Format = esriQueryResultFormat.esriQueryResultRecordSetAsObject

Dim queryresult As QueryResult = Nothing

 

Try

      queryresult = mapservice.QueryFeatureData2(mapname, activelayerdesc, queryfilter,queryresultoptions)

Catch ex As Exception

      ' Improper format of where clause will cause exception

End Try

 

Dim recordset As RecordSet = CType(queryresult.Object, RecordSet)

      queryresultoptions.Format = esriQueryResultFormat.esriQueryResultKMLAsURL

 

Try

      queryresult = mapservice.QueryFeatureData2(mapname, activelayerdesc, queryfilter, queryresultoptions)

Catch ex As Exception

      ' Improper format of where clause will cause exception

End Try

 

Dim kmlurl As String = queryresult.URL

QueryFeatureIDs

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

Dim maplayerinfos() As MapLayerInfo = mapinfo.MapLayerInfos

 

Dim layerid As Integer = 0

Dim geomeTryfieldname As String = String.Empty

Dim layerinfo As MapLayerInfo

 

For Each layerinfo In maplayerinfos

      If layerinfo.Name = "countries" Then

            layerid = layerinfo.LayerID

            Dim fields() As Field = layerinfo.Fields.FieldArray

            Dim field As Field

            For Each field In fields

                  If field.Type = esriFieldType.esriFieldTypeGeometry Then

                        geomeTryfieldname = field.Name

                        Exit For

                  End If

            Next

      End If

Next

 

Dim queryfilter As QueryFilter = New QueryFilter()

queryfilter.WhereClause = "CNTRY_NAME LIKE '%United%'"

Dim fidset As FIDSet = Nothing

 

Try

      fidset = mapservice.QueryFeatureIDs(mapname, layerid, queryfilter)

Catch ex As Exception

      ' Improper format of where clause will cause exception

End Try

 

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

      If layerdesc.LayerID = layerid Then

            layerdesc.SelectionFeatures = fidset.FIDArray

      End If

Next

QueryFeatureIDs2

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapname)

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

Dim maplayerinfos() As MapLayerInfo = mapinfo.MapLayerInfos

 

Dim layerid As Integer = 0

Dim geomeTryfieldname As String = String.Empty

Dim layerinfo As MapLayerInfo

 

For Each layerinfo In maplayerinfos

      If layerinfo.Name = "countries" Then

            layerid = layerinfo.LayerID

            Dim fields() As Field = layerinfo.Fields.FieldArray

            Dim field As Field

            For Each field In fields

                  If field.Type = esriFieldType.esriFieldTypeGeometry Then

                        geomeTryfieldname = field.Name

                        Exit For

                  End If

            Next

      End If

Next

 

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim activelayerdesc As LayerDescription = Nothing

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

      If layerdesc.LayerID = layerid Then

            activelayerdesc = layerdesc

            Exit For

      End If

Next

 

activelayerdesc.DefinitionExpression = "POP_CNTRY > 50000000"

 

Dim pnt1 As PointN = New PointN()

pnt1.X = -120

pnt1.Y = 35

 

Dim pnt2 As PointN = New PointN()

pnt2.X = -60

pnt2.Y = 20

 

Dim pnt3 As PointN = New PointN()

pnt3.X = 80

pnt3.Y = 35

 

Dim pnts(2) As PointN

pnts(0) = pnt1

pnts(1) = pnt2

pnts(2) = pnt3

 

Dim rings(0) As Ring

Dim ring As Ring = New Ring()

ring.PointArray = pnts

rings(0) = ring

 

Dim polygon As PolygonN = New PolygonN()

polygon.RingArray = rings

 

Dim spatialfilter As SpatialFilter = New SpatialFilter()

spatialfilter.FilterGeometry = polygon

spatialfilter.GeometryFieldName = geomeTryfieldname

spatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains

 

Dim fidset As FIDSet = Nothing

 

Try

      fidset = mapservice.QueryFeatureIDs2(mapname, activelayerdesc, spatialfilter)

Catch ex As Exception

' Improper format of where clause will cause exception

End Try

 

activelayerdesc.SelectionFeatures = fidset.FIDArray

QueryHyperlinks

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapname As String = mapservice.GetDefaultMapName()

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim imgdisp As ImageDisplay = New ImageDisplay()

imgdisp.ImageHeight = 500 'pixels

imgdisp.ImageWidth = 500 'pixels

imgdisp.ImageDPI = 96

 

Dim layerdescriptions() As LayerDescription = mapdesc.LayerDescriptions

Dim layerids(layerdescriptions.Length - 1) As Integer

Dim i As Integer = 0

Dim layerdesc As LayerDescription

 

For Each layerdesc In layerdescriptions

      layerids.SetValue(layerdesc.LayerID, i)

      i = i + 1

Next

 

Dim hyperlinkresults as MapServerHyperlink() = mapservice.QueryHyperlinks(mapdesc, imgdisp,layerids)

QueryRelatedRecords

//Layer A (Layer ID = 1) is related to Table B (StandaloneTable ID = 2) and you want to find all rows in

//Table B related to a feature in Layer A whose ObjectID is 3. In this case, you need to do the followings:

//Step 1: create a RelateDescription and populate information

Dim pRD As RelateDescription = New RelateDescription()

pRD.RelationshipID = 2

pRD.RelatedTableFields = "*" 'or you can a pass a subset of fields

pRD.ResultFormat = esriRelateResultFormat.esriRelateResultRelatedRecordSetAsObject

 

'Step 2: create a FIDSet

Dim intOIDs() As Integer = New Integer() {3}

Dim pSrcFIDSet As FIDSet = New FIDSet()

pSrcFIDSet.FIDArray = intOIDs

 

'Step 3: execute the function

Dim pQR As QueryResult = mapservice.QueryRelatedRecords("mapName", 1, pSrcFIDSet, pRD)

 

'Step 4: get result

Dim pRelRecordSet As RelatedRecordSet = pQR.Object

'number of elements in RelatedRecordGroups matches with number of ObjectID passed

'in as SourceFIDSet

Dim pRelRecGroup As RelatedRecordGroup = pRelRecordSet.RelatedRecordGroups(0)

Console.WriteLine("Feature with ObjectID = " + pRelRecGroup.SourceRowID.ToString())

Console.WriteLine("has " + pRelRecGroup.Records.Length.ToString() + " related rows")

ToMapPoints

Dim mea As MouseEventArgs = CType(e, MouseEventArgs)

 

Dim screenx(0) As Integer

Dim screeny(0) As Integer

screenx(0) = mea.X

screeny(0) = mea.Y

 

Dim mapservice As MapService_MapServer = New MapService_MapServer()

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

 

Dim mapinfo As MapServerInfo = mapservice.GetServerInfo(mapservice.GetDefaultMapName())

Dim mapdesc As MapDescription = mapinfo.DefaultMapDescription

 

Dim imgdisp As ImageDisplay = New ImageDisplay()

imgdisp.ImageHeight = 500 'pixels

imgdisp.ImageWidth = 500 'pixels

imgdisp.ImageDPI = 96

 

Dim multipoint As MultipointN = CType(mapservice.ToMapPoints(mapdesc, imgdisp, screenx, screeny), MultipointN)

GeocodeServer

FindAddressCandidates

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

Dim fields As Fields = geocodeservice.GetAddressFields()

Dim address As PropertySet = New PropertySet()

Dim inputfields(fields.FieldArray.Length - 1) As PropertySetProperty

 

Dim index As Integer

For index = 0 To fields.FieldArray.Length - 1 Step index + 1

      Dim field As Field = fields.FieldArray(index)

      Dim property1 As PropertySetProperty = New PropertySetProperty()

      property1.Key = field.Name

 

      Select Case field.Name.ToUpper()

            Case "STREET"

                  property1.Value = "5000 Magnolia Ave."

            Case "ZONE"

                  property1.Value = "92506"

      End Select

 

      inputfields.SetValue(property1, index)

Next

 

address.PropertyArray = inputfields

 

Dim propertymods As PropertySet = geocodeservice.GetLocatorProperties()

Dim locatorArray() As PropertySetProperty = propertymods.PropertyArray

 

' Change locator property value

Dim index2 As Integer

For index2 = 0 To locatorArray.Length - 1 Step index2 + 1

      Dim property2 As PropertySetProperty = locatorArray(index2)

      Select Case property2.Key

            Case "MinimumCandidateScore"

                  property2.Value = "80"

      End Select

Next

 

Dim candidates As RecordSet = geocodeservice.FindAddressCandidates(address, Nothing)

If Not candidates Is Nothing Then

      Dim fieldsoutput As String = String.Empty

      Dim field As Field

 

      For Each field In candidates.Fields.FieldArray

            fieldsoutput += field.Name

      Next

 

      Dim record As Record

      For Each record In candidates.Records

            Dim valuesoutput As String = String.Empty

            Dim values() As Object = record.Values

            Dim v As Integer = 0

            Dim field2 As Field

 

            For Each field2 In candidates.Fields.FieldArray

                  valuesoutput += values(v).ToString()

                  v = v + 1

            Next

      Next

End If

GeocodeAddress

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

' Define address inputs

Dim geocodePropSet As PropertySet = New PropertySet()

Dim propArray(1) As PropertySetProperty

Dim geocodeProp As PropertySetProperty = New PropertySetProperty()

geocodeProp.Key = "Street"

 

' Intersection

'geocodeProp.Value = "Magnolia & Central";

' Address

geocodeProp.Value = "5950 Magnolia Avenue"

propArray(0) = geocodeProp

 

Dim geocodeProp1 As PropertySetProperty = New PropertySetProperty()

geocodeProp1.Key = "Zone"

geocodeProp1.Value = "92506"

propArray(1) = geocodeProp1

 

geocodePropSet.PropertyArray = propArray

 

'Geocode address

Dim results As PropertySet = geocodeservice.GeocodeAddress(geocodePropSet, Nothing)

Dim resultsArray() As PropertySetProperty = results.PropertyArray

Dim geocodePoint As PointN = Nothing

Dim result As PropertySetProperty

 

For Each result In resultsArray

      Dim val As String = result.Key.ToString()

      If result.Key = "Shape" Then

            geocodePoint = CType(result.Value, PointN)

            Dim x As Double = geocodePoint.X

            Dim y As Double = geocodePoint.Y

      End If

GeocodeAddresses

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

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

Dim geocodePropSet As PropertySet = New PropertySet()

Dim propArray(1) As PropertySetProperty

Dim geocodeProp As PropertySetProperty = New PropertySetProperty()

geocodeProp.Key = "Street"

geocodeProp.Value = "Street"

propArray(0) = geocodeProp

 

Dim geocodeProp1 As PropertySetProperty = 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

Dim addressTable As RecordSet = New RecordSet()

 

' Create fields for input address table

Dim fieldarray(2) As Field

 

' Following field properties are required for batch geocode to work:

' Length, Name, Type. There also needs to be a field of type OID.

Dim field0 As Field = New Field()

field0.Name = "OID"

field0.Type = esriFieldType.esriFieldTypeOID

field0.Length = 50

fieldarray(0) = field0

 

Dim field1 As Field = New Field()

field1.Name = "Street"

field1.Type = esriFieldType.esriFieldTypeString

field1.Length = 50

fieldarray(1) = field1

 

Dim field2 As Field = New Field()

field2.Name = "Zone"

field2.Type = esriFieldType.esriFieldTypeString

field2.Length = 50

fieldarray(2) = field2

 

Dim fields As Fields = New Fields()

fields.FieldArray = fieldarray

addressTable.Fields = fields

 

' Add records to input address table

Dim records(1) As Record

Dim record1 As Record = New Record()

record1.Values = New Object(2){0, "5950 Magnolia Ave.", "92506" }

records(0) = record1

 

Dim record2 As Record = New Record()

record2.Values = New Object(2) {1, "5962 Magnolia Ave.", "92506"}

records(1) = record2

 

addressTable.Records = records

 

' Generate results table

Dim results as RecordSet = geocodeservice.GeocodeAddresses(addressTable, geocodePropSet,Nothing)

If Not results Is Nothing Then

      Dim fieldsoutput As String = String.Empty

      Dim fieldResult As Field

 

      For Each fieldResult In results.Fields.FieldArray

            fieldsoutput += fieldResult.Name + vbTab

      Next

 

      Dim record As Record

      For Each record In results.Records

            Dim valuesoutput As String = String.Empty

            Dim values() As Object = record.Values

            Dim v As Integer = 0

            Dim fieldresult2 As Field

 

            For Each fieldresult2 In results.Fields.FieldArray

                  valuesoutput += values(v).ToString() + vbTab

                  v = v + 1

            Next

      Next

End If

GetAddressFields

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

Dim addressfields As Fields = geocodeservice.GetAddressFields()

Dim addressfield As Field

 

For Each 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())

Next

GetCandidateFields

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

Dim propertymods As PropertySet = geocodeservice.GetLocatorProperties()

Dim candidatefields As Fields = geocodeservice.GetCandidateFields(propertymods)

Dim candidatefield As Field

 

For Each 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())

Next

GetDefaultInputFieldMapping

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

Dim fieldmapproperties As PropertySet = geocodeservice.GetDefaultInputFieldMapping()

Dim fieldmaparray() As PropertySetProperty = fieldmapproperties.PropertyArray

Dim fieldmapproperty As PropertySetProperty

 

For Each fieldmapproperty In fieldmaparray

      System.Diagnostics.Debug.WriteLine(fieldmapproperty.Key.ToString())

      System.Diagnostics.Debug.WriteLine(fieldmapproperty.Value.ToString())

Next

GetIntersectionCandidateFields

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

Dim propertymods As PropertySet = geocodeservice.GetLocatorProperties()

Dim candidatefields As Fields = geocodeservice.GetIntersectionCandidateFields(propertymods)

Dim candidatefield As Field

 

For Each 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())

Next

GetLocatorProperties

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

Dim locatorProperties As PropertySet = geocodeservice.GetLocatorProperties()

Dim locatorArray() As PropertySetProperty = locatorProperties.PropertyArray

 

' Display locator properties and default values

Dim locatorProperty As PropertySetProperty

For Each locatorProperty In locatorArray

      System.Diagnostics.Debug.WriteLine(locatorProperty.Key.ToString())

      System.Diagnostics.Debug.WriteLine(locatorProperty.Value.ToString())

Next

 

' Change locator property value

Dim index As Integer

For index = 0 To locatorArray.Length - 1 Step index + 1

      Dim property1 As PropertySetProperty = locatorArray(index)

      Select Case property1.Key

            Case "MinimumMatchScore"

                  property1.Value = "50"

            Case "MinimumCandidateScore"

                  property1.Value = "50"

      End Select

Next

GetResultFields

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

Dim propertymods As PropertySet = geocodeservice.GetLocatorProperties()

Dim candidatefields As Fields = geocodeservice.GetResultFields(propertymods)

 

Dim candidatefield As Field

For Each 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())

Next

GetStandardizedFields

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

Dim standardizedfields As Fields = geocodeservice.GetStandardizedFields()

Dim standardfield As Field

For Each 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())

Next

 

' Define address inputs

Dim stnGeocodePropSet As PropertySet = New PropertySet()

Dim stnPropArray(4) As PropertySetProperty

Dim stngeocodeProp As PropertySetProperty = New PropertySetProperty()

stngeocodeProp.Key = "AHN"

stngeocodeProp.Value = "5950"

stnPropArray(0) = stngeocodeProp

 

Dim stngeocodeProp1 As PropertySetProperty = New PropertySetProperty()

stngeocodeProp1.Key = "ASN"

stngeocodeProp1.Value = "Magnolia"

stnPropArray(1) = stngeocodeProp1

 

Dim stngeocodeProp2 As PropertySetProperty = New PropertySetProperty()

stngeocodeProp2.Key = "AST"

stngeocodeProp2.Value = "AVE"

stnPropArray(2) = stngeocodeProp2

 

Dim stngeocodeProp3 As PropertySetProperty = New PropertySetProperty()

stngeocodeProp3.Key = "AZN"

stngeocodeProp3.Value = "92506"

stnPropArray(3) = stngeocodeProp3

 

Dim stngeocodeProp4 As PropertySetProperty = New PropertySetProperty()

stngeocodeProp4.Key = "Addr_type"

stngeocodeProp4.Value = "A"

stnPropArray(4) = stngeocodeProp4

 

stnGeocodePropSet.PropertyArray = stnPropArray

Dim stnpropertyset As PropertySet = geocodeservice.GeocodeAddress(stnGeocodePropSet, Nothing)

GetStandardizedIntersectionFields

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 
Dim standardizedfields As Fields = geocodeservice.GetStandardizedIntersectionFields()

Dim standardfield As Field

 
For Each 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())

Next

ReverseGeocode

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

' Set reverse geocode search parameters

Dim revGeocodeProp As PropertySetProperty = New PropertySetProperty()

revGeocodeProp.Key = "ReverseDistanceUnits"

revGeocodeProp.Value = "Meters"

 

Dim revGeocodeProp1 As PropertySetProperty = New PropertySetProperty()

revGeocodeProp1.Key = "ReverseDistance"

revGeocodeProp1.Value = "100"

 

' Optionally define output spatial reference for reverse geocoded point

Dim projectedCoordinateSystem As ProjectedCoordinateSystem = New ProjectedCoordinateSystem()

projectedCoordinateSystem.WKID = 54004

projectedCoordinateSystem.WKIDSpecified = True

 

Dim revGeocodeProp2 As PropertySetProperty = New PropertySetProperty()

revGeocodeProp2.Key = "OutputSpatialReference"

revGeocodeProp2.Value = projectedCoordinateSystem

 

Dim propArray As PropertySetProperty() = New PropertySetProperty()

  {revGeocodeProp, revGeocodeProp1, revGeocodeProp2 }

 

Dim revGeocodePropSet As PropertySet = New PropertySet()

revGeocodePropSet.PropertyArray = propArray

 

' Create point to reverse geocode, define input spatial reference

Dim inputPoint As PointN = New PointN()

inputPoint.X = -117.391

inputPoint.Y = 33.961

 

Dim geographicCoordinateSystem As GeographicCoordinateSystem = New GeographicCoordinateSystem()

geographicCoordinateSystem.WKID = 4326

geographicCoordinateSystem.WKIDSpecified = True

 

inputPoint.SpatialReference = geographicCoordinateSystem

 

' Reverse geocode

Dim results As PropertySet = geocodeservice.ReverseGeocode(inputPoint, False, revGeocodePropSet)

 

' Iterate through results

Dim resultsArray As PropertySetProperty() = results.PropertyArray

 

' For each result, print address and matched point

For Each result As PropertySetProperty In resultsArray

      System.Diagnostics.Debug.WriteLine(result.Key.ToString())

      If TypeOf result.Value Is PointN Then

            Dim pn As PointN = CType(result.Value, PointN)

            System.Diagnostics.Debug.WriteLine(pn.X & ", " & pn.Y)

      Else

            System.Diagnostics.Debug.WriteLine(result.Value.ToString())

      End If

Next result

StandardizeAddress

Dim geocodeservice As GeocodeService_GeocodeServer = New GeocodeService_GeocodeServer()

geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer"

 

' Define address inputs

Dim geocodePropSet As PropertySet = New PropertySet()

Dim propArray(1) As PropertySetProperty

Dim geocodeProp As PropertySetProperty = New PropertySetProperty()

 

geocodeProp.Key = "Street"

geocodeProp.Value = "5950 Magnolia Ave."

propArray(0) = geocodeProp

 

Dim geocodeProp1 As PropertySetProperty = New PropertySetProperty()

geocodeProp1.Key = "Zone"

geocodeProp1.Value = "92506"

propArray(1) = geocodeProp1

 

geocodePropSet.PropertyArray = propArray

Dim standardizedAddress As PropertySet = geocodeservice.StandardizeAddress(geocodePropSet, Nothing)

Dim standardArray() As PropertySetProperty = standardizedAddress.PropertyArray

Dim result As PropertySetProperty

 

For Each result In standardArray

      System.Diagnostics.Debug.WriteLine(result.Key.ToString())

      System.Diagnostics.Debug.WriteLine(result.Value.ToString())

Next

GPServer

GeoDataServer

GetDefaultWorkingVersion

Dim geodataservice As GeodataService_GeoDataServer = New GeodataService_GeoDataServer()

geodataservice.Url = "http://localhost:6080/arcgis/services/GeodataService/GeodataServer"

 

Dim defaultversionname As String = geodataservice.GetDefaultWorkingVersion()

GetMaxRecordCount

Dim geodataservice As GeodataService_GeoDataServer = New GeodataService_GeoDataServer()

geodataservice.Url = "http://localhost:6080/arcgis/services/GeodataService/GeodataServer"

 

Dim maxrecordcount As Integer = geodataservice.GetMaxRecordCount()

GetVersions

Dim geodataservice As GeodataService_GeoDataServer = New GeodataService_GeoDataServer()

geodataservice.Url = "http://localhost:6080/arcgis/services/GeodataService/GeodataServer"

 

Try

      Dim gpversioninfos() As GPVersionInfo = geodataservice.GetVersions()

      Dim gpvi As GPVersionInfo

 

      For Each gpvi In gpversioninfos

            Dim versionname As String = gpvi.VersionName

            Dim access As esriVersionAccess = gpvi.Access

      Next

 

' If not an ArcSDE geodatabase, "Error processing server request" will be returned.

Catch soapex As System.Web.Services.Protocols.SoapException

      Dim message As String = soapex.Message

Finally

      geodataservice.Dispose()

End Try

GetWrappedWorkspaceType

Dim geodataservice As GeodataService_GeoDataServer = New GeodataService_GeoDataServer()

geodataservice.Url = "http://localhost:6080/arcgis/services/GeodataServiceLocal/GeodataServer"

 

Dim workspacetype As esriWorkspaceType = geodataservice.GetWrappedWorkspaceType()

GeometryServer

Buffer

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

Dim inputSpatialReference As SpatialReference = 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]]"

 

Dim bufferSpatialReference As SpatialReference = New ProjectedCoordinateSystem()

' USA_Contiguous_Lambert_Conformal_Conic

bufferSpatialReference.WKID = 102004

bufferSpatialReference.WKIDSpecified = True

 

Dim outputSpatialReference As SpatialReference = inputSpatialReference

Dim inputPoint1 As PointN = New PointN()

inputPoint1.X = -120

inputPoint1.Y = 45

 

Dim inputPoint2 As PointN = New PointN()

inputPoint2.X = -110

inputPoint2.Y = 40

 

Dim inputGeomeTry() As Geometry = New Geometry() {inputPoint1, inputPoint2}

Dim distances() As Double = New Double() {200, 400}

Dim linearUnit As LinearUnit = New LinearUnit()

 

' US survey mile

linearUnit.WKID = 9035

linearUnit.WKIDSpecified = True

 

Dim unionResults As Boolean = False

Dim outputGeomeTry As Geometry() = geomeTryService.Buffer(inputSpatialReference, bufferSpatialReference, _

outputSpatialReference, distances, linearUnit, unionResults, inputGeomeTry)

Densify

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

Dim inputSpatialReference As SpatialReference = New wsgeomeTry.ProjectedCoordinateSystem()

' World Mercator

inputSpatialReference.WKID = 54004

inputSpatialReference.WKIDSpecified = True

 

Dim pnt1 As PointN = New PointN()

pnt1.X = 500000

pnt1.Y = 500000

 

Dim pnt2 As PointN = New PointN()

pnt2.X = 600000

pnt2.Y = 500000

 

Dim pnt3 As PointN = New PointN()

pnt3.X = 700000

pnt3.Y = 500000

 

Dim pntarray1() As PointN = New PointN() {pnt1, pnt2, pnt3}

Dim inputPath As Path = New Path()

inputPath.PointArray = pntarray1

 

Dim paths() As Path = New Path() {inputPath}

Dim inputPolyline As PolylineN = New PolylineN()

inputPolyline.PathArray = paths

 

Dim inputGeomeTry() As Geometry = New Geometry() {inputPolyline}

Dim maxSegmentLength As Double = 10000

Dim useDeviationDensification As Boolean = False

Dim densificationParam As Double = 0

 

Dim outputGeomeTry As Geometry() = geomeTryService.Densify(inputSpatialReference, _

inputGeomeTry, maxSegmentLength, useDeviationDensification, densificationParam)

FindSRByWKID

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

' Geographic WGS84

Dim outputSpatialReference as SpatialReference = geomeTryService.FindSRByWKID("EPSG", 4326,-1, True, True)

Dim isHighPrecision As Boolean = outputSpatialReference.HighPrecision

FindSRByWKT

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

' Geographic WGS84

Dim outputSpatialReference As SpatialReference = 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)

 

Dim predefinedWKID As Integer = outputSpatialReference.WKID

FindUnitsByWKID

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

' International Meter

Dim linearUnit As LinearUnit = CType(geomeTryService.FindUnitsByWKID("EPSG", 9001), LinearUnit)

FindUnitsByWKT

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

' International Meter

Dim linearUnit As LinearUnit = CType(geomeTryService.FindUnitsByWKT("UNIT[""Meter"",1.0,AUTHORITY[""EPSG"",9001]]"), LinearUnit)

GetAreasAndLengths

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

Dim inputSpatialReference As SpatialReference = geomeTryService.FindSRByWKID("EPSG", 54004, -1, True, True)

' New PointN array

Dim pnt1 As PointN = New PointN()

pnt1.X = 100000

pnt1.Y = 300000

 

Dim pnt2 As PointN = New PointN()

pnt2.X = 100000

pnt2.Y = 350000

 

Dim pnt3 As PointN = New PointN()

pnt3.X = 900000

pnt3.Y = 350000

 

Dim pnts1() As PointN = New PointN() {pnt1, pnt2, pnt3}

 

' New PolylineN

Dim path1 As Path = New Path()

path1.PointArray = pnts1

 

Dim paths() As Path = New Path() {path1}

 

Dim polylinen As PolylineN = New PolylineN()

polylinen.PathArray = paths

 

' New PolygonN

Dim ring1 As Ring = New Ring()

ring1.PointArray = pnts1

Dim rings() As Ring = New Ring() {ring1}

 

Dim polygonn As PolygonN = New PolygonN()

polygonn.RingArray = rings

Dim polygonArray() As PolygonN = New PolygonN() {polygonn}

 

Dim lengths() As Double = Nothing

Dim areas As Double() = geomeTryService.GetAreasAndLengths(inputSpatialReference, polygonArray, lengths)

GetLabelPoints

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

' GCS-NAD83

Dim inputSpatialReference as SpatialReference = geomeTryService.FindSRByWKID("EPSG", 4269,-1, True, True)

 

Dim pnt1 As PointN = New PointN()

pnt1.X = 10.0

pnt1.Y = 30.0

 

Dim pnt2 As PointN = New PointN()

pnt2.X = 10.0

pnt2.Y = 40.0

 

Dim pnt3 As PointN = New PointN()

pnt3.X = 20.0

pnt3.Y = 40.0

 

Dim pnt4 As PointN = New PointN()

pnt4.X = 20.0

pnt4.Y = 30.0

 

Dim pnt5 As PointN = New PointN()

pnt5.X = 10.0

pnt5.Y = 30.0

 

Dim pnts1() As PointN = New PointN() {pnt1, pnt2, pnt3, pnt4, pnt5}

Dim ring1 As Ring = New Ring()

ring1.PointArray = pnts1

Dim rings() As Ring = New Ring() {ring1}

 

Dim polygonn As PolygonN = New PolygonN()

polygonn.RingArray = rings

Dim polygonArray() As PolygonN = New PolygonN() {polygonn}

 

Dim labelPoints As Point() = CType(geomeTryService.GetLabelPoints(inputSpatialReference, polygonArray), Point())

GetLengths

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

Dim inputSpatialReference As SpatialReference = geomeTryService.FindSRByWKID("EPSG", 54004, -1, True, True)

 

' New PointN array

Dim pnt1 As PointN = New PointN()

pnt1.X = 100000

pnt1.Y = 300000

 

Dim pnt2 As PointN = New PointN()

pnt2.X = 100000

pnt2.Y = 350000

 

Dim pnt3 As PointN = New PointN()

pnt3.X = 900000

pnt3.Y = 350000

 

Dim pnts1() As PointN = New PointN() {pnt1, pnt2, pnt3}

 

' New PolylineN

Dim path1 As Path = New Path()

path1.PointArray = pnts1

Dim paths() As Path = New Path() {path1}

Dim polylinen As PolylineN = New PolylineN()

polylinen.PathArray = paths

Dim polylineArray() As PolylineN = New PolylineN() {polylinen}

 

Dim lengths() As Double = geomeTryService.GetLengths(inputSpatialReference, polylineArray)

Project

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

Dim inputSpatialReference As SpatialReference = New GeographicCoordinateSystem()

inputSpatialReference.WKID = 4326

inputSpatialReference.WKIDSpecified = True

 

Dim outputSpatialReference As SpatialReference = New ProjectedCoordinateSystem()

' USA_Contiguous_Lambert_Conformal_Conic

outputSpatialReference.WKID = 102004

outputSpatialReference.WKIDSpecified = True

 

Dim pnt1 As PointN = New PointN()

pnt1.X = -120

pnt1.Y = 50

 

Dim pnt2 As PointN = New PointN()

pnt2.X = -110

pnt2.Y = 40

 

Dim pnt3 As PointN = New PointN()

pnt3.X = -130

pnt3.Y = 40

 

Dim pnts1() As PointN = New PointN() {pnt1, pnt2, pnt3}

 

Dim path1 As Path = New Path()

path1.PointArray = pnts1

Dim paths() As Path = New Path() {path1}

Dim polylinen As PolylineN = New PolylineN()

polylinen.PathArray = paths

 

Dim ring1 As Ring = New Ring()

ring1.PointArray = pnts1

Dim rings() As Ring = New Ring() {ring1}

Dim polygonn As PolygonN = New PolygonN()

polygonn.RingArray = rings

 

Dim inputGeomeTry() As Geometry = New Geometry() {pnt1, polylinen, polygonn}

Dim transformForward As Boolean = False

Dim transformation As GeoTransformation = New GeoTransformation()

' NAD1983_To_WGS1984_1

transformation.WKID = 1188

transformation.WKIDSpecified = True

Dim extent As EnvelopeN = Nothing

 

Dim outputGeomeTry as GeomeTry() = geomeTryService.Project(inputSpatialReference, outputSpatialReference,transformForward,transformation, extent, inputGeomeTry)

Relation

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

Dim inputSpatialReference As SpatialReference = New GeographicCoordinateSystem()

inputSpatialReference.WKID = 4326

inputSpatialReference.WKIDSpecified = True

 

' First input geometry array - 1 polygon

Dim pnt1a As PointN = New PointN()

pnt1a.X = 10.0

pnt1a.Y = 30.0

 

Dim pnt2a As PointN = New PointN()

pnt2a.X = 10.0

pnt2a.Y = 45.0

 

Dim pnt3a As PointN = New PointN()

pnt3a.X = 25.0

pnt3a.Y = 45.0

 

Dim pnt4a As PointN = New PointN()

pnt4a.X = 25.0

pnt4a.Y = 30.0

 

Dim pnt5a As PointN = New PointN()

pnt5a.X = 10.0

pnt5a.Y = 30.0

 

Dim pnts1a() As PointN = New PointN() {pnt1a, pnt2a, pnt3a, pnt4a, pnt5a}

 

Dim ring1 As Ring = New Ring()

ring1.PointArray = pnts1a

Dim rings() As Ring = New Ring() {ring1}

 

Dim polygon1 As PolygonN = New PolygonN()

polygon1.RingArray = rings

Dim inputGeomeTry1() As Geometry = New Geometry() {polygon1}

 

' Second input geometry array - 3 points

Dim pnt1b As PointN = New PointN()

pnt1b.X = 20.0

pnt1b.Y = 40.0

 

Dim pnt2b As PointN = New PointN()

pnt2b.X = 10.0

pnt2b.Y = 30.0

 

Dim pnt3b As PointN = New PointN()

pnt3b.X = 50.0

pnt3b.Y = 50.0

 

Dim inputGeomeTry2(2) As Geometry

' Inside polygon

inputGeomeTry2.SetValue(pnt1b, 0)

' Edge of polygon

inputGeomeTry2.SetValue(pnt2b, 1)

' Outside polygon

inputGeomeTry2.SetValue(pnt3b, 2)

 

' If esriGeometryRelationRelation, define relation parameter

Dim enumRelate As esriGeometryRelationEnum = esriGeometryRelationEnum.esriGeometryRelationRelation

' G1 = first (base) geometry array, G2 = second (comparison) geometry array

Dim relationParameter As String = "G2 INTERSECT G1.BOUNDARY"

 

Dim relationResults as RelationResult() = geomeTryService.Relation(inputSpatialReference,inputGeomeTry1, inputGeomeTry2,enumRelate, relationParameter)

Simplify

Dim geomeTryService As Geometry_GeometryServer = New Geometry_GeometryServer()

geomeTryService.Url = "http://localhost:6080/arcgis/services/Geometry/GeometryServer"

 

Dim inputSpatialReference As SpatialReference = geomeTryService.FindSRByWKID("EPSG", 4326, -1, True, True)

 

' Ring 1

Dim pnt1a As PointN = New PointN()

pnt1a.X = 10.0

pnt1a.Y = 30.0

 

Dim pnt2a As PointN = New PointN()

pnt2a.X = 10.0

pnt2a.Y = 45.0

 

Dim pnt3a As PointN = New PointN()

pnt3a.X = 25.0

pnt3a.Y = 45.0

 

Dim pnt4a As PointN = New PointN()

pnt4a.X = 25.0

pnt4a.Y = 30.0

 

Dim pnt5a As PointN = New PointN()

pnt5a.X = 10.0

pnt5a.Y = 30.0

 

Dim pnts1a() As PointN = New PointN() {pnt1a, pnt2a, pnt3a, pnt4a, pnt5a}

Dim ring1 As Ring = New Ring()

ring1.PointArray = pnts1a

 

' Ring 2

Dim pnt1b As PointN = New PointN()

pnt1b.X = 15.0

pnt1b.Y = 35.0

 

Dim pnt2b As PointN = New PointN()

pnt2b.X = 15.0

pnt2b.Y = 50.0

 

Dim pnt3b As PointN = New PointN()

pnt3b.X = 30.0

pnt3b.Y = 50.0

 

Dim pnt4b As PointN = New PointN()

pnt4b.X = 30.0

pnt4b.Y = 35.0

 

Dim pnt5b As PointN = New PointN()

pnt5b.X = 15.0

pnt5b.Y = 35.0

 

Dim pnts1b() As PointN = New PointN() {pnt1b, pnt2b, pnt3b, pnt4b, pnt5b}

Dim ring2 As Ring = New Ring()

ring2.PointArray = pnts1b

 

' Multipart Polygon (2 overlapping rings)

Dim rings() As Ring = New Ring() {ring1, ring2}

Dim polygon1 As PolygonN = New PolygonN()

polygon1.RingArray = rings

Dim geomeTryArray() As Geometry = New Geometry() {polygon1}

 

' Overlapping section removed

Dim simplifiedGeomeTry() As Geometry = geomeTryService.Simplify(inputSpatialReference, geomeTryArray)

ImageServer

NAServer

2/28/2020