|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.esri.arcgis.location.GeocodeServer
public class GeocodeServer
A class that provides geocoding as a service.
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
| Constructor Summary | |
|---|---|
GeocodeServer()
Constructs a GeocodeServer using ArcGIS Engine. |
|
GeocodeServer(Object obj)
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts. GeocodeServer theGeocodeServer = (GeocodeServer) obj; |
|
| Method Summary | |
|---|---|
void |
attachToLocator(ILocatorName locName)
Attach this service to the locator specified by the locator name. |
void |
construct(IPropertySet props)
Two phase object construction. |
boolean |
equals(Object o)
Compare this object with another |
IRecordSet |
findAddressCandidates(IPropertySet address,
IPropertySet propMods)
Generates candidates for an address (normal or standardized form). |
IServerObjectExtension |
findExtensionByCLSID(String cLSID)
Returns a server object extension found using a string representation of its class ID. |
IServerObjectExtension |
findExtensionByTypeName(String name)
Returns a server object extension found using its type name. |
IPropertySet |
geocodeAddress(IPropertySet address,
IPropertySet propMods)
Geocodes a single address (normal or standardized form). |
IRecordSet |
geocodeAddresses(IRecordSet addressTable,
IPropertySet addressFieldMapping,
IPropertySet propMods)
Geocodes a table of addresses. |
IFields |
getAddressFields()
Fields needed to geocode a table of addresses. |
ILocator |
getAddressLocator()
The address locator used by the geocode server. |
String |
getAdjustableProperties()
The list of properties (comma delimited) that can be modified at runtime (for a given method). |
IFields |
getCandidateFields(IPropertySet propMods)
Fields contained in a list of candidates. |
static String |
getClsid()
getClsid. |
String |
getConfigurationName()
Name of the server object configuration that defines the server object. |
IPropertySet |
getDefaultInputFieldMapping()
Suggested field name mappings for all input fields. |
IFields |
getIntersectionCandidateFields(IPropertySet propMods)
Fields contained by intersection candidates. |
IPropertySet |
getLocatorProperties()
Default properties for a locator. |
IFields |
getResultFields(IPropertySet propMods)
Fields contained in the geocoding result. |
IFields |
getStandardizedFields()
Fields contained in a standardized address. |
IFields |
getStandardizedIntersectionFields()
Fields contained in a standardized intersection. |
int |
getSuggestedBatchSize()
The suggested number of addresses to send to a server in one batch request. |
String |
getTypeName()
Type of the server object (MapServer or GeocodeServer). |
byte[] |
handleBinaryRequest(byte[] request)
Handles a binary request. |
byte[] |
handleBinaryRequest2(String capabilities,
byte[] request)
Handles a binary request with explicit capabilities. |
String |
handleStringRequest(String capabilities,
String request)
Handles a SOAP string request. |
int |
hashCode()
the hashcode for this object |
IPropertySet |
reverseGeocode(IPoint location,
boolean bReturnIntersection,
IPropertySet propMods)
Generates an address for a point. |
void |
setAdjustableProperties(String propertyList)
The list of properties (comma delimited) that can be modified at runtime (for a given method). |
void |
setSuggestedBatchSize(int size)
The suggested number of addresses to send to a server in one batch request. |
IPropertySet |
standardizeAddress(IPropertySet address,
IPropertySet propMods)
Standardizes an address. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.esri.arcgis.interop.RemoteObjRef |
|---|
getJintegraDispatch, release |
| Constructor Detail |
|---|
public GeocodeServer()
throws IOException,
UnknownHostException
IOException - if there are interop problems
UnknownHostException - if there are interop problems
public GeocodeServer(Object obj)
throws IOException
GeocodeServer theGeocodeServer = (GeocodeServer) obj;
obj to GeocodeServer.
obj - an object returned from ArcGIS Engine or Server
IOException - if there are interop problems| Method Detail |
|---|
public static String getClsid()
public boolean equals(Object o)
equals in class Objectpublic int hashCode()
hashCode in class Object
public void construct(IPropertySet props)
throws IOException,
AutomationException
construct in interface IObjectConstructprops - A reference to a com.esri.arcgis.system.IPropertySet (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public byte[] handleBinaryRequest(byte[] request)
throws IOException,
AutomationException
handleBinaryRequest in interface IRequestHandlerrequest - An unsigned byte (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public String handleStringRequest(String capabilities,
String request)
throws IOException,
AutomationException
handleStringRequest in interface IRequestHandlercapabilities - The capabilities (in)request - The request (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public byte[] handleBinaryRequest2(String capabilities,
byte[] request)
throws IOException,
AutomationException
handleBinaryRequest2 in interface IRequestHandler2capabilities - The capabilities (in)request - An unsigned byte (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IPropertySet geocodeAddress(IPropertySet address,
IPropertySet propMods)
throws IOException,
AutomationException
The GeocodeAddress method geocodes a single address defined by the address PropertySet, and returns a PropertySet containing the match property values.
The address parameter is a PropertySet containing the address to be geocoded. The names of the properties in this PropertySet are the names of the address fields used by the GeocodeServer. The most common way to geocode an address using the GeocodeAddress method is to allow the GeocodeServer to standardize the address before searching for a match for the address. In this case, use the GetAddressFields method to retrieve the definitions of the address fields used by the GeocodeServer, and use the names of these fields as the names of the properties defined in the address PropertySet. The Required property on each Field object indicates whether the address field is required by the GeocodeServer. Failing to specify a required address property results in an error. The following Visual Basic code retrieves the address field names from the GetAddressFields method, prompts the user for the address field values, and geocodes the address using the GeocodeAddress method.
Dim pAddressProperties As esriSystem.IPropertySet
Dim pAddressFields As esriGeodatabase.IFields
Dim pGeocodeServer As esriLocation.IGeocodeServer
Dim lngFieldIndex As Long
Dim pField As esriGeodatabase.IField
Dim strFieldValue As String
Dim pMatchProperties As esriSystem.IPropertySet
Set pAddressProperties = New esriSystem.PropertySet
Set pAddressFields = pGeocodeServer.GetAddressFields
For lngFieldIndex = 0 To pAddressFields.FieldCount - 1
Set pField = pAddressFields.Field(lngFieldIndex)
Do
strFieldValue = InputBox("Enter the value for " & pField.AliasName & ":", "GeocodeAddress")
If strFieldValue <> "" Or pField.required = False Then Exit Do
Loop
pAddressProperties.SetProperty pField.Name, strFieldValue
Next lngFieldIndex
Set pMatchProperties = pGeocodeServer.GeocodeAddress(pAddressProperties, Nothing)
In some cases, you may want to geocode an address that has been standardized with the input of the user or through some other method. In these cases, use the GetStandardizedFields or GetStandardizedIntersectionFields methods to retrieve the names of the standardized address fields used by the GeocodeServer , and use the names of these fields as the names of the properties defined in the address PropertySet. You must also add an additional property to the address PropertySet to indicate that the address is a standardized address. The name of this property must be "ADDR_TYPE", and its value must be "A" for a standardized address, or "I" for a standardized intersection. The following Visual Basic code demonstrates how to geocode a standardized address using the GeocodeAddress method.
Dim pAddressProperties As esriSystem.IPropertySet Dim pStandardizedAddressFields As esriGeodatabase.IFields Dim pGeocodeServer As esriLocation.IGeocodeServer Dim lngFieldIndex As Long Dim pField As esriGeodatabase.IField Dim strFieldValue As String Dim pMatchProperties As esriSystem.IPropertySetSet pAddressProperties = New esriSystem.PropertySet pAddressProperties.SetProperty "ADDR_TYPE", "A" Set pStandardizedAddressFields = pGeocodeServer.GetStandardizedFields For lngFieldIndex = 0 To pStandardizedAddressFields.FieldCount - 1 Set pField = pStandardizedAddressFields.Field(lngFieldIndex) strFieldValue = InputBox("Enter the value for " & pField.AliasName & ":", "GeocodeAddress") pAddressProperties.SetProperty pField.Name, strFieldValue Next lngFieldIndex Set pMatchProperties = pGeocodeServer.GeocodeAddress(pAddressProperties, Nothing)
The propMods parameter is a PropertySet containing the GeocodeServer properties to use to geocode the address. The GetLocatorProperties method returns the set of default geocoding properties for the GeocodeServer. In some cases, you may want to modify the geocoding properties used to geocode an address. For example, you may wish to change the spelling sensitivity used to search for a match for the address, or you may want to change the side and end offset applied to the geocoded location. Modify the properties in the PropertySet returned by the GetLocatorProperties method, and pass the modified PropertySet to the propMods parameter. The PropertySet passed to the propMods parameter only needs to contain properties that are different than the default properties for the GeocodeServer. If you don't wish to modify any of the default properties returned used by the GeocodeServer, you can either pass a null value to the propMods parameter, or pass the unmodified PropertySet returned by the GetLocatorProperties method.
The GeocodeAddress method returns a PropertySet that contains a set of properties that define the match found by the GeocodeServer . The names of these properties are defined by the names of the Field objects returned by the GetResultFields method.
geocodeAddress in interface IGeocodeServeraddress - A reference to a com.esri.arcgis.system.IPropertySet (in)propMods - A reference to a com.esri.arcgis.system.IPropertySet (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IRecordSet geocodeAddresses(IRecordSet addressTable,
IPropertySet addressFieldMapping,
IPropertySet propMods)
throws IOException,
AutomationException
The GeocodeAddresses method geocodes a RecordSet of addresses, and returns a RecordSet containing the match properties for each address.
The AddressTable parameter is a RecordSet containing the addresses to be geocoded. To create the RecordSet, first co-create a RecordSet coclass, then use the IRecordSetInit::SetSourceTable method set a reference to the table that contains the addresses to geocode. In order to reduce the amount of data that needs to be sent to the server, use the pFilter parameter on the IRecordSetInit::SetSourceTable method to define a QueryFilter that includes only the ObjectID and address fields from the address table.
The addressFieldMapping parameter defines the mapping of address fields used by the GeocodeServer to fields in the AddressTable RecordSet. The names of the properties in this PropertySet are the names of the address fields used by the GeocodeServer. Use the GetAddressFields method to get the set of fields used by the GeocodeServer. The values of the properties are the names of the corresponding fields in the RecordSet.
The propMods parameter is a PropertySet containing the GeocodeServer properties to use to geocode the address. The GetLocatorProperties method returns the set of default geocoding properties for the GeocodeServer. In some cases, you may want to modify the geocoding properties used to geocode addresses. For example, you may wish to change the spelling sensitivity used to search for matches for addresses, or you may want to change the side and end offset applied to the geocoded locations. Modify the properties in the PropertySet returned by the GetLocatorProperties method, and pass the modified PropertySet to the propMods parameter. The PropertySet passed to the propMods parameter only needs to contain properties that are different than the default properties for the GeocodeServer. If you don't wish to modify any of the default properties returned used by the GeocodeServer, you can either pass a null value to the propMods parameter, or pass the unmodified PropertySet returned by the GetLocatorProperties method.
Note that, when passing objects as parameters to any member of the IGeocodeServer interface, all of the objects should be created from within the server context. Objects are created within a server context if they are retrieved from the ServerContext object corresponding to the GeocodeServer, of if they are created by other objects that belong to the server context.
geocodeAddresses in interface IGeocodeServeraddressTable - A reference to a com.esri.arcgis.geodatabase.IRecordSet (in)addressFieldMapping - A reference to a com.esri.arcgis.system.IPropertySet (in)propMods - A reference to a com.esri.arcgis.system.IPropertySet (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IPropertySet standardizeAddress(IPropertySet address,
IPropertySet propMods)
throws IOException,
AutomationException
The StandardizeAddress method standardizes an address using the geocoding rules used by the GeocodeServer.
The address parameter is a PropertySet that contains the address to standardize. The names of the properties are the input address fields used by the GeocodeServer, as defined by the GetAddressFields method.
The propMods parameter is a PropertySet containing the GeocodeServer properties to use to standardize the address. The GetLocatorProperties method returns the set of default geocoding properties for the GeocodeServer. In some cases, you may want to modify the properties used to standardize an address. Modify the properties in the PropertySet returned by the GetLocatorProperties method, and pass the modified PropertySet to the propMods parameter. The PropertySet passed to the propMods parameter only needs to contain properties that are different than the default properties for the GeocodeServer. If you don't wish to modify any of the default properties returned used by the GeocodeServer, you can either pass a null value to the propMods parameter, or pass the unmodified PropertySet returned by the GetLocatorPropertiesmethod.
The PropertySet returned by the StandardizeAddress method contains the standardized address. In addition to the standardized address components, this PropertySet contains a property named "Addr_type" that indicates the type of address. If the value of this property is "A", then the address was standardized as a non-intersection address. If the value of this property is "I", then the address was standardized as an intersection address. The set of remaining properties will depend on the value of this property. If the standardized address returned is a non-intersection address, then use the names of the fields returned by the GetStandardizedFields method to retrieve the components of the standardized address. If the standardized address returned is an intersection address, then use the names of the fields returned by the GetStandardizedIntersectionFields method to retrieve the components of the standardized address.
The following example demonstrates how to standardize an address and inspect the components of the standardized address:
Dim pGISServerConnection As esriServer.IGISServerConnection
Dim pServerObjectManager As esriServer.IServerObjectManager
Dim pServerContext As esriServer.IServerContext
Dim pGeocodeServer As esriLocation.IGeocodeServer
Dim pAddress As esriSystem.IPropertySet
Dim pStandardizedAddress As esriSystem.IPropertySet
Dim pCandidateFields As esriGeoDatabase.IFields
Dim lngFieldIndex As Long
Dim pField As esriGeoDatabase.IField
'+++ get the GeocodeServer from the ArcGIS Server
Set pGISServerConnection = New esriServer.GISServerConnection
pGISServerConnection.Connect "napanee"
Set pServerObjectManager = pGISServerConnection.ServerObjectManager
Set pServerContext = pServerObjectManager.CreateServerContext("RedlandsStreets", "GeocodeServer")
Set pGeocodeServer = pServerContext.ServerObject
'+++ construct an address to standardize
Set pAddress = pServerContext.CreateObject("esriSystem.PropertySet")
pAddress.SetProperty "Street", "380 New York St."
pAddress.SetProperty "Zone", "92373"
'+++ standardize the address and display the standardized components
Set pStandardizedAddress = pGeocodeServer.StandardizeAddress(pAddress, Nothing)
If pStandardizedAddress.GetProperty("Addr_type") = "A" Then
Set pCandidateFields = pGeocodeServer.GetStandardizedFields
ElseIf pStandardizedAddress.GetProperty("Addr_type") = "I" Then
Set pCandidateFields = pGeocodeServer.GetStandardizedIntersectionFields
End If
For lngFieldIndex = 0 To pCandidateFields.FieldCount - 1
Set pField = pCandidateFields.Field(lngFieldIndex)
Debug.Print pField.AliasName & ": " & pStandardizedAddress.GetProperty(pField.Name)
Next lngFieldIndex
standardizeAddress in interface IGeocodeServeraddress - A reference to a com.esri.arcgis.system.IPropertySet (in)propMods - A reference to a com.esri.arcgis.system.IPropertySet (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IRecordSet findAddressCandidates(IPropertySet address,
IPropertySet propMods)
throws IOException,
AutomationException
The FindAddressCandidates method finds candidates for a single address defined by the address PropertySet, and returns a Recordset containing the candidates.
The address parameter is a PropertySet containing the address for which to find candidates. The names of the properties in this PropertySet are the names of the address fields used by the GeocodeServer. The most common way to find candidates for an address using the FindAddressCandidates method is to allow the GeocodeServer to standardize the address before searching for candidates for the address. In this case, use the GetAddressFields method to retrieve the definitions of the address fields used by the GeocodeServer, and use the names of these fields as the names of the properties defined in the address PropertySet. The Required property on each Field object indicates whether the address field is required by the GeocodeServer. Failing to specify a required address property results in an error. The following Visual Basic code retrieves the address field names from the GetAddressFields method, prompts the user for the address field values, and finds candidates for the address using the GeocodeAddress method.
Dim pAddressProperties As esriSystem.IPropertySet
Dim pAddressFields As esriGeodatabase.IFields
Dim pGeocodeServer As esriLocation.IGeocodeServer
Dim lngFieldIndex As Long
Dim pField As esriGeodatabase.IField
Dim strFieldValue As String
Dim pRecordSet As esriGeodatabase.IRecordSet
Set pAddressProperties = New esriSystem.PropertySet
Set pAddressFields = pGeocodeServer.GetAddressFields
For lngFieldIndex = 0 To pAddressFields.FieldCount - 1
Set pField = pAddressFields.Field(lngFieldIndex)
Do
strFieldValue = InputBox("Enter the value for " & pField.AliasName & ":", "GeocodeAddress")
If strFieldValue <> "" Or pField.required = False Then Exit Do
Loop
pAddressProperties.SetProperty pField.Name, strFieldValue
Next lngFieldIndex
Set pRecordSet = pGeocodeServer.FindAddressCandidates(pAddressProperties, Nothing)
In some cases, you may want to find candidate for an address that has been standardized with the input of the user or through some other method. In these cases, use the GetStandardizedFields or GetStandardizedIntersectionFields methods to retrieve the names of the standardized address fields used by the GeocodeServer , and use the names of these fields as the names of the properties defined in the address PropertySet. You must also add an additional property to the address PropertySet to indicate that the address is a standardized address. The name of this property must be "ADDR_TYPE", and its value must be "A" for a standardized address, or "I" for a standardized intersection. The following Visual Basic code demonstrates how to find candidates for a standardized address using the FindAddressCandidates method.
Dim pAddressProperties As esriSystem.IPropertySet Dim pStandardizedAddressFields As esriGeodatabase.IFields Dim pGeocodeServer As esriLocation.IGeocodeServer Dim lngFieldIndex As Long Dim pField As esriGeodatabase.IField Dim strFieldValue As String Dim pRecordSet As esriGeodatabase.IRecordSetSet pAddressProperties = New esriSystem.PropertySet pAddressProperties.SetProperty "ADDR_TYPE", "A" Set pStandardizedAddressFields = pGeocodeServer.GetStandardizedFields For lngFieldIndex = 0 To pStandardizedAddressFields.FieldCount - 1 Set pField = pStandardizedAddressFields.Field(lngFieldIndex) strFieldValue = InputBox("Enter the value for " & pField.AliasName & ":", "GeocodeAddress") pAddressProperties.SetProperty pField.Name, strFieldValue Next lngFieldIndex Set pRecordSet = pGeocodeServer.FindAddressCandidates(pAddressProperties, Nothing)
The propMods parameter is a PropertySet containing the GeocodeServer properties to use to find candidates for the address. The GetLocatorProperties method returns the set of default geocoding properties for the GeocodeServer. In some cases, you may want to modify the geocoding properties used to find candidates for an address. For example, you may wish to change the spelling sensitivity used to search for candidates for the address, or you may want to change the side and end offset applied to the candidate locations. Modify the properties in the PropertySet returned by the GetLocatorProperties method, and pass the modified PropertySet to the propMods parameter. The PropertySet passed to the propMods parameter only needs to contain properties that are different than the default properties for the GeocodeServer. If you don't wish to modify any of the default properties returned used by the GeocodeServer, you can either pass a null value to the propMods parameter, or pass the unmodified PropertySet returned by the GetLocatorProperties method.
The FindAddressCandidates method returns a Recordset that contains Rows that define candidates for the address found by the GeocodeServer. For non-intersection addresses, use the GetCandidateFields method to get the set of fields contained in the Recordset. For intersection addresses, use the GetIntersectionCandidateFields method to get the set of fields contained in the Recordset.
findAddressCandidates in interface IGeocodeServeraddress - A reference to a com.esri.arcgis.system.IPropertySet (in)propMods - A reference to a com.esri.arcgis.system.IPropertySet (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IFields getAddressFields()
throws IOException,
AutomationException
The GetAddressFields method returns a Fields object containing the input address fields used by the GeocodeServer. The IField::Required property on each Field object indicates if the GeocodeServer requires this field when geocoding addresses.
getAddressFields in interface IGeocodeServerIOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IFields getCandidateFields(IPropertySet propMods)
throws IOException,
AutomationException
The GetCandidateFields object returns a Fields object that contains definitions of the Fields in the Recordset returned by the FindAddressCandidates method for non-intersection addresses.
getCandidateFields in interface IGeocodeServerpropMods - A reference to a com.esri.arcgis.system.IPropertySet (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IFields getIntersectionCandidateFields(IPropertySet propMods)
throws IOException,
AutomationException
The GetIntersectionCandidateFields object returns a Fields object that contains definitions of the Fields in the Recordset returned by the FindAddressCandidates method for intersection addresses.
getIntersectionCandidateFields in interface IGeocodeServerpropMods - A reference to a com.esri.arcgis.system.IPropertySet (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IFields getStandardizedFields()
throws IOException,
AutomationException
The GetStandardizedFields method returns a set of fields that define the elements of a standardized non-intersection address. Use this method when constructing a PropertySet that represents a standardized address to pass to the GeocodeAddress or FindAddressCandidates methods, and when inspecting an address that has been standardized using the StandardizeAddress method.
getStandardizedFields in interface IGeocodeServerIOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IFields getStandardizedIntersectionFields()
throws IOException,
AutomationException
The GetStandardizedIntersectionFields method returns a set of fields that define the elements of a standardized intersection address. Use this method when constructing a PropertySet that represents a standardized address to pass to the GeocodeAddress or FindAddressCandidates methods, and when inspecting an address that has been standardized using the StandardizeAddress method.
getStandardizedIntersectionFields in interface IGeocodeServerIOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IFields getResultFields(IPropertySet propMods)
throws IOException,
AutomationException
The GetResultFields property returns a Fields object that defines the fields returned by the address locator on which the GeocodeServer is based. For more information on the fields returned by address locators, see IAddressGeocoding::MatchFields.
getResultFields in interface IGeocodeServerpropMods - A reference to a com.esri.arcgis.system.IPropertySet (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.IAddressGeocoding.getMatchFields()
public IPropertySet getDefaultInputFieldMapping()
throws IOException,
AutomationException
The GetDefaultInputFieldMapping property returns suggested names for fields in an address table that map to input address fields used by the GeocodeServer. Use this method when preparing a table for the GeocodeAddresses method to automatically detect the fields in the address table that contain address information.
The names of the properties contained in the PropertySet returned by this method are the names of the input address fields. Use the GetAddressFields method to get the names of the input address fields used by the GeocodeServer. The value of each property is a comma-delimited list of suggested field names for each input address field.
getDefaultInputFieldMapping in interface IGeocodeServerIOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IPropertySet getLocatorProperties()
throws IOException,
AutomationException
The GetLocatorProperties method returns a PropertySet containing all of the geocoding properties used by the GeocodeServer. To change the geocoding properties used when calling other methods on the IGeocodeServer interface, modify the properties in this PropertySet, then pass the PropertySet to the method you are calling using the propMods parameter on the method.
The following example illustrates using the GetLocatorProperties method to change the minimum match score used when calling the GeocodeAddress method:
Dim pGISServerConnection As esriServer.IGISServerConnection
Dim pServerObjectManager As esriServer.IServerObjectManager
Dim pServerContext As esriServer.IServerContext
Dim pGeocodeServer As esriLocation.IGeocodeServer
Dim pAddressProperties As esriSystem.IPropertySet
Dim pLocatorProperties As esriSystem.IPropertySet
Dim pMatchProperties As esriSystem.IPropertySet
'+++ get the GeocodeServer from the ArcGIS Server
Set pGISServerConnection = New esriServer.GISServerConnection
pGISServerConnection.Connect "napanee"
Set pServerObjectManager = pGISServerConnection.ServerObjectManager
Set pServerContext = pServerObjectManager.CreateServerContext("RedlandsStreets", "GeocodeServer")
Set pGeocodeServer = pServerContext.ServerObject
'+++ construct a PropertySet containing the address to geocode
Set pAddressProperties = pServerContext.CreateObject("esriSystem.PropertySet")
pAddressProperties.SetProperty "Street", "280 New York St."
pAddressProperties.SetProperty "Zone", "92373"
'+++ get the locator properties and change the minimum match score to 100
Set pLocatorProperties = pGeocodeServer.GetLocatorProperties
pLocatorProperties.SetProperty "MinimumMatchScore", "100"
'+++ geocode the address using the GeocodeServer
Set pMatchProperties = pGeocodeServer.GeocodeAddress(pAddressProperties, pLocatorProperties)
'+++ release the server context
pServerContext.ReleaseContext
The following table describes all of the properties that might be contained in the PropertySet returned by the GetLocatorProperties method:
Name
Description
Values
EndOffset
The end offset used by the address locator.
A long integer value between 0 and 50
IntersectionConnectors
The intersection connectors used by the address locator.
A string value containing the space-delimited list of intersection connectors (e.g., "| & @")
MatchIfScoresTie
Indicates if the GeocodeServer should match an addresses to a candidate if two or more candidates share the same best candidate score.
"TRUE" or "FALSE"
MinimumCandidateScore
The minimum candidate score used by the address locator.
A long integer value between 0 and 100
MinimumMatchScore
The minimum match score used by the address locator.
A long integer value between 0 and 100
ReverseDistance
The search distance to use to search for reference data features when reverse geocoding. The ReverseDistance value is specified in the reverse distance units used by the address locator.
A double floating-point value
ReverseDistanceUnits
The search distance units used by the address locator when reverse geocoding. Valid values include all of the enumeration constant names included in the esriUnits enumeration, without the "esri" prefix (e.g., "Meters").
A string representing the reverse geocoding distance units
SideOffset
The side offset used by the address locator. The SideOffset value is specified in the side offset units used by the address locator.
A double floating-point value
SideOffsetUnits
The side offset units used by the address locator. Valid values include all of the enumeration constant names included in the esriUnits enumeration, without the "esri" prefix (e.g., "Meters").
A string representing the side offset units
SpellingSensitivity
The spelling sensitivity used by the address locator.
A long integer value between 0 and 100
SuggestedBatchSize
The batch size to use when batch geocoding a table of addresses. Refer to the ArcGIS Server Administrator and Developer Guide for more information on the suggested batch size.
A long integer value
UICLSID
The Class ID of the LocatorUI object to use for the GeocodeServer's user interface in desktop applications.
A string value containing the CLSID
For more information on the properties listed above, please refer to the IGeocodingProperties interface.
Product Availability
Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.
Supported Platforms
Windows, Solaris, Linux
- Specified by:
getLocatorProperties in interface IGeocodeServer
- Returns:
- A reference to a com.esri.arcgis.system.IPropertySet
- Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IPropertySet reverseGeocode(IPoint location,
boolean bReturnIntersection,
IPropertySet propMods)
throws IOException,
AutomationException
The ReverseGeocode method returns the address closest to the given point, and within a specified search distance.
The location parameter is a Point object that represents the point at which to search for the closest address. Note that the Point passed to this parameter have the same spatial reference as the GeocodeServer's output. The easiest way to get the spatial reference from the GeocodeServer is to use the GetResultFields method to get the result Fields, and then get the spatial reference from the shape field's GeometryDef object. If the Point is in some other spatial reference (such as a point feature from another feature class), then you must first project the point into the GeocodeServer's output spatial reference. This is most easily done using the IPoint::Project method.
The bReturnIntersection parameter indicates whether the GeocodeServer should return the nearest intersection to the given point. If the value of this parameter is True, then the GeocodeServer will return the nearest intersection to the given point, provided that the GeocodeServer supports intersection geocoding, and provided that there is an intersection within the reverse geocoding search distance. If the value of this parameter is False, then the GeocodeServer will return the nearest address to the given point, provided that there is an address within the GeocodeServer 's reverse geocoding search tolerance.
The propMods parameter is a PropertySet containing the geocoding properties to use for reverse geocoding. There are two properties that are relevant to reverse geocoding. The ReverseDistance and ReverseDistanceUnits properties specify the distance from the given point to which to search for addresses. When specifying the ReverseDistanceUnits property, use a string to indicate the units to use. For example, when searching for an address using a search distance specified in esriMeters, use the string "Meters" to specify the search distance units. Refer to the esriUnits enumeration for a list of all supported search distance units.
The PropertySet returned by the ReverseGeocode method contains properties that describe the address. The names of the properties are the names of the Fields returned by the GetAddressFields method, and their values correspond to the components of the nearest address. In fact, the PropertySet returned by the ReverseGeocode method could be passed to the GeocodeAddress method to get the geometry of the closest address to the given point.
reverseGeocode in interface IGeocodeServerlocation - A reference to a com.esri.arcgis.geometry.IPoint (in)bReturnIntersection - The bReturnIntersection (in)propMods - A reference to a com.esri.arcgis.system.IPropertySet (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public ILocator getAddressLocator()
throws IOException,
AutomationException
This IGeocodeServerObjects interface is available only if the GeocodeServer was obtained for use in a stateful manner (i.e., either by co-creating the GeocodeServer object or by obtaining a reference using a GISServerConnection object.)
The following example illustrates how to obtain a reference to the address locator that provides the geocoding functionality for a GeocodeServer:
Dim pGISServerConnection As esriServer.IGISServerConnection
Dim pServerObjectManager As esriServer.IServerObjectManager
Dim pServerContext As esriServer.IServerContext
Dim pGeocodeServerObjects As esriLocation.IGeocodeServerObjects
Dim pLocator As esriGeoDatabase.ILocator
'+++ 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 pGeocodeServerObjects = pServerContext.ServerObject
'+++ get the address locator from the GeocodeServer
Set pLocator = pGeocodeServerObjects.AddressLocator
'+++ release the server context after completing work with the GeocodeServer
pServerContext.ReleaseContext
getAddressLocator in interface IGeocodeServerObjectsIOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public void attachToLocator(ILocatorName locName)
throws IOException,
AutomationException
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 the AttachToLocator method.
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
attachToLocator in interface IInitGeocodeServerlocName - A reference to a com.esri.arcgis.geodatabase.ILocatorName (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public String getAdjustableProperties()
throws IOException,
AutomationException
The IInitGeocodeServer interface is available only if the GeocodeServer was obtained for use in a stateful manner (i.e., either by co-creating the GeocodeServer object or by obtaining a reference using a GISServerConnection object.)
The AdjustableProperties method returns a comma-delimited string containing the list of properties that a user or developer can modify at runtime when using a GeocodeServer. Use this method to inspect and restrict the set of properties that users and developers can modify. Refer to the IGeocodeServer::GetLocatorProperties method for a list of property names that can be used.
The following example illustrates how to modify the set of adjustable properties so that users and developers cannot change the minimum candidate score used by the GeocodeServer at runtime:
Public Sub SetAdjustableProperties()
Dim pGISServerConnection As esriServer.IGISServerConnection
Dim pServerObjectManager As esriServer.IServerObjectManager
Dim pServerContext As esriServer.IServerContext
Dim pInitGeocodeServer As esriLocation.IInitGeocodeServer
Dim varAdjustableProperties As Variant
Dim strAdjustableProperties() As String
Dim lngPropertyIndex As Long
On Error GoTo ErrorHandler
'+++ 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 pInitGeocodeServer = pServerContext.ServerObject
'+++ get the set of adjustable properties and remove the minimum candidate score
varAdjustableProperties = Split(pInitGeocodeServer.AdjustableProperties, ",")
For lngPropertyIndex = LBound(varAdjustableProperties) To UBound(varAdjustableProperties)
If varAdjustableProperties(lngPropertyIndex) <> "MinimumCandidateScore" Then
ReDim Preserve strAdjustableProperties(0 To UBound(strAdjustableProperties) + 1)
strAdjustableProperties(UBound(strAdjustableProperties)) = _
varAdjustableProperties(lngPropertyIndex)
End If
Next lngPropertyIndex
pInitGeocodeServer.AdjustableProperties = Join(strAdjustableProperties, ",")
'+++ release the server context after completing work with the GeocodeServer
pServerContext.ReleaseContext
Exit Sub
ErrorHandler:
If Err.Number = 9 Then '+++ subscript out of range error
ReDim strAdjustableProperties(0 To 0)
Resume Next
End If
End Sub
getAdjustableProperties in interface IInitGeocodeServerIOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public void setAdjustableProperties(String propertyList)
throws IOException,
AutomationException
setAdjustableProperties in interface IInitGeocodeServerpropertyList - The propertyList (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public int getSuggestedBatchSize()
throws IOException,
AutomationException
Refer to the ArcGIS Server Administrator and Developer Guide for more information on the suggested batch size.
getSuggestedBatchSize in interface IInitGeocodeServerIOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public void setSuggestedBatchSize(int size)
throws IOException,
AutomationException
setSuggestedBatchSize in interface IInitGeocodeServersize - The size (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public String getConfigurationName()
throws IOException,
AutomationException
getConfigurationName in interface IServerObjectIOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public String getTypeName()
throws IOException,
AutomationException
getTypeName in interface IServerObjectIOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IServerObjectExtension findExtensionByCLSID(String cLSID)
throws IOException,
AutomationException
findExtensionByCLSID in interface IServerObjectExtensionManagercLSID - The cLSID (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
public IServerObjectExtension findExtensionByTypeName(String name)
throws IOException,
AutomationException
findExtensionByTypeName in interface IServerObjectExtensionManagername - The name (in)
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||