Geocode service FindAddressCandidates method
Geocodes a single address and returns multiple results (candidates).
FindAddressCandidates(PropertySet Address, PropertySet PropMods)
Parameter |
Description |
---|---|
Address |
Address information stored as a PropertySet to be geocoded. Each property is associated with an address field defined for the geocoding service. Use GetAddressFields to get a list of fields. |
PropMods |
Modifications to the geocode service properties. Use GetLocatorProperties() to get a list of default locator properties. Use GetLocatorProperties() to return default locator properties. |
Return Value
A RecordSet containing match candidates. Each row references an individual candidate. 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. In most cases, the RecordSet will contain the geocoded location (Geometry), score, and matched address.
Remarks
The following diagram illustrates the geocode server proxy methods commonly used when working with the FindAddressCandidates() method. In addition, the diagram also includes the input (address) and output (match) information one can expect when using this method.
![]() |
The input 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 geocode service. Use the GetAddressFields() method to retrieve the definitions of the address fields used by the geocode service, and use the names of these fields as the names of the properties defined in the address PropertySet. Each Field object has a Required property which indicates if the address field is required by the geocode service. Failing to specify a required address property will return an error.
The PropMods parameter is a PropertySet containing the geocode service properties to use to find candidates for the address. The GetLocatorProperties method returns the set of default geocoding properties for the geocode service. In some cases, you may want to modify the geocoding properties used to find candidates for an address. For example, you may 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 object as the PropMods parameter. PropMods only needs to contain properties that are different than the default properties for the geocode service. If you do not need to modify any of the default properties returned used by the geocode service, the PropMods parameter can be null or you can pass the unmodified PropertySet returned by the GetLocatorProperties method.
Using pre-ArcGIS 10 locators
In some cases you may want to find candidates for an address that has already been standardized (thus the geocode service will not standardize any address input). Use the GetStandardizedFields or GetStandardizedIntersectionFields methods to retrieve the names of the standardized address fields used by the geocode service, 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 PropertySet only needs to contain properties that have a value, even if the standardized field is listed as required.
Examples
C#
GeocodeService_GeocodeServer geocodeservice = new GeocodeService_GeocodeServer();
geocodeservice.Url = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
Fields fields = geocodeservice.GetAddressFields();
PropertySet address = new PropertySet();
PropertySetProperty[] inputfields = new PropertySetProperty[fields.FieldArray.Length];
for (int index = 0; index < fields.FieldArray.Length; index++)
{
Field field = fields.FieldArray[index];
PropertySetProperty property = new PropertySetProperty();
property.Key = field.Name;
switch (field.Name.ToUpper())
{
case "STREET":
property.Value = "5000 Magnolia Ave.";
break;
case "ZONE":
property.Value = "92506";
break;
}
inputfields.SetValue(property, index);
}
address.PropertyArray = inputfields;
PropertySet propertymods = geocodeservice.GetLocatorProperties();
PropertySetProperty[] locatorArray = propertymods.PropertyArray;
// Change locator property value
for (int index = 0; index < locatorArray.Length; index++)
{
PropertySetProperty property = locatorArray[index];
switch (property.Key)
{
case "MinimumCandidateScore":
property.Value = "80";
break;
}
}
RecordSet candidates = geocodeservice.FindAddressCandidates(address, null);
if (candidates != null)
{
string fieldsoutput = string.Empty;
foreach (Field field in candidates.Fields.FieldArray)
{
fieldsoutput += field.Name;
}
foreach (Record record in candidates.Records)
{
string valuesoutput = string.Empty;
object[] values = record.Values;
int v = 0;
foreach (Field field in candidates.Fields.FieldArray)
{
valuesoutput += values[v].ToString();
v++;
}
}
}
VB.NET
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
Java
String serviceURL = "http://localhost:6080/arcgis/services/GeocodeService/GeocodeServer";
GeocodeServerBindingStub geocodeService = new GeocodeServerBindingStub(serviceURL);
//Get supported fields
Fields fields = geocodeService.getAddressFields();
//Setup locator properties
PropertySet propertyMods = geocodeService.getLocatorProperties();
PropertySetProperty[] locatorArray = propertyMods.getPropertyArray();
//street,zip
String street = "600 Trabert Ave";
String zip = "30318";
//Input to FindAddressCandidates
PropertySet address = new PropertySet();
//Address to geocode
PropertySetProperty[] inputFields = new PropertySetProperty[fields.getFieldArray().length];
for (int index = 0; index < fields.getFieldArray().length; index++) {
//Set the values for the supported fields
Field field = fields.getFieldArray()[index];
PropertySetProperty property = new PropertySetProperty();
property.setKey(field.getName());
//Set Street
if (field.getName().toUpperCase().equalsIgnoreCase("STREET")) {
property.setValue(street);
inputFields[index] = property;
continue;
}
//Set zip code
if (field.getName().toUpperCase().equalsIgnoreCase("ZONE")) {
property.setValue(zip);
inputFields[index] = property;
continue;
}
}
//Polulate address
address.setPropertyArray(inputFields);
//Change locator property value
for (int index = 0; index < locatorArray.length; index++) {
PropertySetProperty property = locatorArray[index];
if (property.getKey().equalsIgnoreCase("MinimumCandidateScore")) {
property.setValue("20");
}
}
//FindAddressCandidates
RecordSet candidates = geocodeService.findAddressCandidates(address,null);
//Optional parsing of the results
if (candidates != null) {
String fieldsOutput = "";
for (Field candidateField : candidates.getFields().getFieldArray()) {
fieldsOutput += candidateField.getName();
}
}
for (Record record : candidates.getRecords()) {
String valuesOutput = "";
Object[] values = record.getValues();
for (int index = 0; index < candidates.getFields().getFieldArray().length;index++) {
valuesOutput += " " + values[index].toString();
}
System.out.println(valuesOutput);
}