Geocode resources provide access to address matching capabilities of a data source; which includes geocoding and reverse geocoding. The IGeocodeResource interface defines the generic properties used to define matching characteristics, such as minimum and maximum score, and the number of match candidates to return. Geocode resources are available in a Web ADF application via a GeocodeResourceManager control.
Implemented by: ArcGIS Server Local, ArcGIS Server Internet, ArcIMS, ArcWeb
Functionality types created: IGeocodeFunctionality
Data sources expose geocode resources in a number of ways. ArcGIS Server publishes geocode services, ArcIMS exposes geocode capabilities within an image service, and ArcWeb services provides geocoding via the Address Finder Web service at the following url: http://www.arcwebservices.com/services/v2006/AddressFinder.wsdl. In most cases, developers will interact with a geocode resource via a geocode functionality.
GeocodeFunctionality: IGeocodeFunctionality
GeocodeFunctionality is implemented for data sources that provide the ability to perform geocoding and reverse geocoding. As a developer, you will explicitly create a GeocodeFunctionality using the GeocodeResource.CreateFunctionality() method. In most cases, you will only need to work with the Common API reference, IGeocodeFunctionality, instead of explicitly casting to a data source implementation type.
| Property or Method | Description |
|---|---|
| GeocodeAddress() | Return a Web ADF Point of the match with the highest score |
| ReverseGeocode() | Return a list of AddressValue objects. Each has a Value property to store the address string. |
| FindAddressCandidates() | Returns a DataTable. Each row contains a Web ADF point of an address match and the attributes of the feature matched in the geocode reference layer . |
| GetAddressFields() | Return a list of Field objects. Each field is an input for the geocode resource. |
| GetLocatorProperties() | Return a dictionary of string-object pairs. Each pair is a property setting for the geocode resource (locator). |
| MinMatchScore | An integer value between 0-100. Determines how closely an address must match attributes in a geocode reference layer. Used by GeocodeAddress() and FindAddressCandidates(). |
| MinCandidateScore | An integer value between 0-100. Determines how closely an address must match attributes in a geocode reference layer. Used by FindAddressCandidates(). |
| ShowAllCandidates | A boolean. If false, FindAddressCandidates() returns only matches. If true, it returns matches and candidates. |
GeocodeFunctionality is created by a GeocodeResource. Geocode resources are managed by a GeocodeResourceManager. The following code example returns a GeocodeResource from a GeocodeResourceManager, explicitly initializes it, then proceeds to create and work with a GeocodeFunctionality.
Note, a geocode resource must be initialized before a geocode functionality is created.
[C#]
ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisresource = GeocodeResourceManager1.GetResource(0);
gisresource.Initialize();
ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality igf = (ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality)
(gisresource.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IGeocodeFunctionality), null));
The following code illustrates how to get the input address fields and the address locator properties the geocode functionality will use. The input address fields will be used to submit an address to be matched. The locator properties provide default settings for the geocode process.
[C#]
System.Collections.Generic.List<Field> addressfields = igf.GetAddressFields();
foreach (Field f in addressfields)
{
System.Diagnostics.Debug.WriteLine((f.Name));
}
System.Collections.Generic.Dictionary<string, object> dict = igf.GetLocatorProperties();
foreach (System.Collections.Generic.KeyValuePair<string, object> pair in dict)
{
System.Diagnostics.Debug.WriteLine((pair.Key + ": " + pair.Value.ToString()));
}
To submit an address to be geocoded, create a generic list containing an AddressValue object for each input address field. The input address field name is the first parameter in the AddressValue constructor. The second parameter is the input value to geocode.
[C#]
System.Collections.Generic.List<AddressValue> avc = new System.Collections.Generic.List<AddressValue>();
AddressValue av1 = new AddressValue("STREET", "380 New York St");
AddressValue av2 = new AddressValue("ZONE", "92373");
avc.Add(av1);
avc.Add(av2);