A class that provides geocoding as a service.
| Interfaces | Description |
|---|---|
| IGeocodeServer | Provides access to members for geocoding addresses. |
| IGeocodeServerObjects | Provides access to the objects used by the geocode server. |
| IInitGeocodeServer | Provides access to members for initializing a geocode server. |
| IObjectConstruct (esriSystem) | Provides access to methods for constructing an object. |
| IRequestHandler (esriSystem) | Provides access to members that control handing of request messages. |
| IRequestHandler2 (esriSystem) | Provides access to members that control handing of request messages. |
| IServerObject (esriServer) | Provides access to properties of a map or geocode server object. |
| IServerObjectExtensionManager (esriServer) | Provides access to members that help locate installed server object extensions. |
A GeocodeServer object uses an address locator to provide coarse-grained geocoding functionality either in Desktop and Engine applications, or using ArcGIS Server over the network. In a Desktop or Engine environment, developers can use the GeocodeServer to perform coarse-grained geocoding tasks, such as geocoding a table of addresses, more easily than with the finer-grained geocoding ArcObjects. In an ArcGIS Server environment, GeocodeServer objects can be accessed over the network to provide geocoding functionality hosted by a remote server.
All of the coarse-grained functionality of the GeocodeServer can be accessed through the IGeocodeServer interface. Using this interface, you can geocode single addresses, geocode tables of addresses, find the address closest to a point, and access all of the support functionality required to accomplish these tasks.
In order to access the fine-grained ArcObjects that support the geocoding functionality of the GeocodeServer, use the IGeocodeServerObjects to obtain a reference to the address locator on which the GeocodeServer is based. From this address locator, developers can access all of the fine-grained ArcObjects associated with the address locator, such as the reference data used by the address locator. Note that the fine-grained objects that support the GeocodeServer are stateful, and so you should only use a non-pooled GeocodeServer when modifying these objects.
For more information on accessing ArcGIS Server objects in stateful and stateless applications, refer to the ArcGIS Server Administrator and Developer Guide.
To create a new GeocodeServer in a Desktop or Engine environment, simply create a new GeocodeServer object and attach the address locator on which you want to base the GeocodeServer. Using this GeocodeServer, you can access the functionality of the address locator at a coarse-grained level:
Dim pLocatorManager As esriLocation.ILocatorManager
Dim pLocatorWorkspace As esriGeoDatabase.ILocatorWorkspace
Dim pLocatorName As esriGeoDatabase.ILocatorName
Dim pInitGeocodeServer As esriLocation.IInitGeocodeServer
'+++ get a reference to the locator on which to base the GeocodeServer
Set pLocatorManager = New esriLocation.LocatorManager
Set pLocatorWorkspace = _
pLocatorManager.GetLocatorWorkspaceFromPath("D:\Workspace\ArcGIS Developer Help\GeocodeServer")
Set pLocatorName = pLocatorWorkspace.GetLocatorName("Redlands Streets")
'+++ create a new GeocodeServer
Set pInitGeocodeServer = New esriLocation.GeocodeServer
pInitGeocodeServer.AttachToLocator pLocatorName
To create a new GeocodeServer configuration to be served using ArcGIS Server, use the ArcGIS Server administration objects:
Dim pGISServerConnection As esriServer.IGISServerConnection
Dim pServerObjectAdmin As esriServer.IServerObjectAdmin
Dim pServerObjectConfiguration As esriServer.IServerObjectConfiguration
Dim pProperties As esriSystem.IPropertySet
'+++ connect to an ArcGIS Server and create a new server object configuration
Set pGISServerConnection = New esriServer.GISServerConnection
pGISServerConnection.Connect "napanee"
Set pServerObjectAdmin = pGISServerConnection.ServerObjectAdmin
Set pServerObjectConfiguration = pServerObjectAdmin.CreateConfiguration
'+++ define the properties of the new server object configuration
pServerObjectConfiguration.Name = "RedlandsStreets"
pServerObjectConfiguration.TypeName = "GeocodeServer"
Set pProperties = pServerObjectConfiguration.Properties
pProperties.SetProperty "LocatorWorkspacePath", "D:\Workspace\ArcGIS Developer Help\GeocodeServer"
pProperties.SetProperty "Locator", "Redlands Streets"
'+++ add the server object configuration and start the GeocodeServer
pServerObjectAdmin.AddConfiguration pServerObjectConfiguration
pServerObjectAdmin.StartConfiguration pServerObjectConfiguration.Name, _
pServerObjectConfiguration.TypeName
Once the GeocodeServer is created, it can be accessed in several ways. To access a GeocodeServer for use in a stateless manner, use the GIS Client object library to access the ArcGIS Server and obtain a reference to the GeocodeServer:
Dim pConnectionProperties As esriSystem.IPropertySet
Dim pAGSServerConnectionFactory As esriGISClient.IAGSServerConnectionFactory
Dim pAGSServerConnection As esriGISClient.IAGSServerConnection
Dim pAGSEnumServerObjectName As esriGISClient.IAGSEnumServerObjectName
Dim pAGSServerObjectName As esriGISClient.IAGSServerObjectName
Dim pName As esriSystem.IName
Dim pGeocodeServer As esriLocation.IGeocodeServer
'+++ connect to an ArcGIS Server
Set pConnectionProperties = New esriSystem.PropertySet
pConnectionProperties.SetProperty "machine", "napanee"
Set pAGSServerConnectionFactory = New esriGISClient.AGSServerConnectionFactory
Set pAGSServerConnection = pAGSServerConnectionFactory.Open(pConnectionProperties, 0)
'+++ get a specific GeocodeServer from the server
Set pAGSEnumServerObjectName = pAGSServerConnection.ServerObjectNames
pAGSEnumServerObjectName.Reset
Set pAGSServerObjectName = pAGSEnumServerObjectName.Next
Do While Not pAGSServerObjectName Is Nothing
If
pAGSServerObjectName.Name = "RedlandsStreets" And pAGSServerObjectName.Type = "GeocodeServer" Then
Set pName = pAGSServerObjectName
Exit Do
End If
Set pAGSServerObjectName = pAGSEnumServerObjectName.Next
Loop
If pName Is Nothing Then Exit Sub
Set pGeocodeServer = pName.Open
To access a GeocodeServer for use in a stateful manner, use the Server object library to access the ArcGIS Server and obtain a reference to the GeocodeServer:
Dim pGISServerConnection As esriServer.IGISServerConnection
Dim pServerObjectManager As esriServer.IServerObjectManager
Dim pServerContext As esriServer.IServerContext
Dim pGeocodeServer As esriLocation.IGeocodeServer
'+++ connect to an ArcGIS Server and get the server object manager
Set pGISServerConnection = New esriServer.GISServerConnection
pGISServerConnection.Connect ("napanee")
Set pServerObjectManager = pGISServerConnection.ServerObjectManager
'+++ get a GeocodeServer object from its server context
Set pServerContext = pServerObjectManager.CreateServerContext("RedlandsStreets", "GeocodeServer")
Set pGeocodeServer = pServerContext.ServerObject
'+++ release the server context after completing work with the GeocodeServer
pServerContext.ReleaseContext