com.esri.adf.web.ve.data.geocode
Class VEGeocodeFunctionality

java.lang.Object
  extended by com.esri.adf.web.ve.data.geocode.VEGeocodeFunctionality
All Implemented Interfaces:
GeocodeFunctionality, GISFunctionality, VEConstants, Serializable

public class VEGeocodeFunctionality
extends Object
implements GeocodeFunctionality, VEConstants, Serializable

This class provides the geocoding and reverse geocoding abilities of VEGeocodeResource.

It gives the ability to specify which address fields should be used. You can also specify what aliases to use for the address fields. The GeocodeTask uses these address fields and aliases to build a user interface. If no address fields are specified, one all-purpose address field is used. If no aliases are specified, the default labels are retrieved from the Res.properties file of the web application.
When an address is geocoded, a zoom factor is applied on the map to display the address. This zoom factor can be customized. See example below of how these properties can be customized through faces-config.xml.

 <managed-bean>
   <managed-bean-name>veGeocode</managed-bean-name>
   <managed-bean-class>com.esri.adf.web.ve.data.geocode.VEGeocodeFunctionality</managed-bean-class>
   <managed-bean-scope>none</managed-bean-scope>
   <managed-property>
     <property-name>addressFields</property-name>
     <list-entries>
       <value>AddressLine</value>
       <value>PostalCode</value>
       <value>PostalTown</value>
     </list-entries>
   </managed-property>
   <managed-property>
     <property-name>aliases</property-name>
     <map-entries>
       <map-entry>
         <key>AddressLine</key>
         <value>Street</value>
       </map-entry>
     </map-entries>
   </managed-property>
   <managed-property>
     <property-name>zoomFactor</property-name>
     <value>10000.0</value>
   </managed-property>
 </managed-bean>
 

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.esri.adf.web.data.GeocodeFunctionality
FUNCTIONALITY_NAME
 
Fields inherited from interface com.esri.adf.web.ve.data.VEConstants
MAP_STYLE_AERIAL, MAP_STYLE_AERIAL_WITH_LABEL, MAP_STYLE_ROAD, MAX_LEVEL_OF_DETAIL, MIN_LEVEL_OF_DETAIL, TILE_HEIGHT, TILE_WIDTH, VIRTUAL_EARTH_GEOCODE_WKID, VIRTUAL_EARTH_SPATIAL_REFERENCE_WKID, VIRTUAL_EARTH_XMAX, VIRTUAL_EARTH_XMIN, VIRTUAL_EARTH_YMAX, VIRTUAL_EARTH_YMIN
 
Constructor Summary
VEGeocodeFunctionality()
           
 
Method Summary
 void destroyFunctionality()
           The cleanup chores (such as releasing held resources) for the functionality must be performed in this method.
 List<AddressCandidate> findAddressCandidates()
           Returns a List of AddressCandidates based on the current set of address field values.
 AddressCandidate geocodeAddress()
           Geocodes a single address based on the current set of address field values.
 String getAddressFieldAlias(String fieldName)
           Returns an alias for the given address field.
 String[] getAddressFields()
           Returns an array of address fields for this geocoder.
 String getAddressFieldValue(String fieldName)
           Returns the value for a given address field.
 int getMinScore()
           
 VEGeocodeResource getResource()
           Returns the GISResource associated with this functionality.
 int getScoreHigh()
          Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score.
 int getScoreLow()
          Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score.
 int getScoreMedium()
          Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score.
 double getZoomFactor()
          Returns the zoom factor to which the map will be zoomed to to display a result
 void initFunctionality(GISResource resource)
           The initialization chores for the functionality must be performed in this method.
 List<AddressCandidate> reverseGeocodeAddress(WebPoint point)
          This method returns a list of possible addresses for a given location.
 void setAddressFields(String[] addressFields)
          Sets the address fields to be used by this GeocodeFunctionality.
 void setAddressFieldValue(String fieldName, String value)
           Sets the value for a given address field.
 void setAliases(HashMap<String,String> aliases)
          Sets the aliases for the address fields used by this GeocodeFunctionality.
 void setMinScore(int userDefinedMinScore)
           
 void setScoreHigh(int scoreHigh)
          Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score.
 void setScoreLow(int scoreLow)
          Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score.
 void setScoreMedium(int scoreMedium)
          Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score.
 void setZoomFactor(double zoomFactor)
          Sets the zoom factor to which the map will be zoomed to to display a result
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VEGeocodeFunctionality

public VEGeocodeFunctionality()
Method Detail

getScoreHigh

public int getScoreHigh()
Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score. Returns the score value (1-100) corresponding to a HIGH confidence level.

Returns:
the score

getScoreMedium

public int getScoreMedium()
Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score. Returns the score value (1-100) corresponding to a MEDIUM confidence level.

Returns:
the score

getScoreLow

public int getScoreLow()
Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score. Returns the score value (1-100) corresponding to a LOW confidence level.

Returns:
the score

setScoreHigh

public void setScoreHigh(int scoreHigh)
Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score. Sets the score value (1-100) corresponding to a HIGH confidence level. The default value is 80.

Parameters:
scoreHigh - the score to set

setScoreMedium

public void setScoreMedium(int scoreMedium)
Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score. Sets the score value (1-100) corresponding to a MEDIUM confidence level. The default value is 50.

Parameters:
scoreMedium - the score to set

setScoreLow

public void setScoreLow(int scoreLow)
Defines the mapping between Bing Maps Geocode service's confidence level and the corresponding AddressCandidate score. Sets the score value (1-100) corresponding to a LOW confidence level. The default value is 20.

Parameters:
scoreLow - the score to set

getZoomFactor

public double getZoomFactor()
Returns the zoom factor to which the map will be zoomed to to display a result

Returns:
the zoomFactor

setZoomFactor

public void setZoomFactor(double zoomFactor)
Sets the zoom factor to which the map will be zoomed to to display a result

Parameters:
zoomFactor - the zoomFactor to set

initFunctionality

public void initFunctionality(GISResource resource)
Description copied from interface: GISFunctionality

The initialization chores for the functionality must be performed in this method. This method is called by the resource when the functionality needs to be initialized. This happens either when the resource itself is being initialized or if users add this functionality to the resource using the GISResource.addFunctionality(String, GISFunctionality) method after the resource has already been initialized.

Classes which implement this method should maintain the resource as a class instance variable and return the same in the GISFunctionality.getResource() method. The functionality is ready for use only after this method has been called.

Specified by:
initFunctionality in interface GISFunctionality
Parameters:
resource - the GISResource that this functionality supports
See Also:
GISResource.init(WebContext)

destroyFunctionality

public void destroyFunctionality()
Description copied from interface: GISFunctionality

The cleanup chores (such as releasing held resources) for the functionality must be performed in this method. This method is called by the GISResource when the resource itself is being destroyed.

The functionality is no longer usable after this method has been called.

Specified by:
destroyFunctionality in interface GISFunctionality
See Also:
GISResource.destroy()

reverseGeocodeAddress

public List<AddressCandidate> reverseGeocodeAddress(WebPoint point)
This method returns a list of possible addresses for a given location.

Parameters:
point - a WebPoint to be reverse geocoded. Please ensure the point has a valid spatial reference, especially if it is in a different spatial reference from the WebContext.
Returns:
the list of address candidates. Returns null if nothing is found.

geocodeAddress

public AddressCandidate geocodeAddress()
Description copied from interface: GeocodeFunctionality

Geocodes a single address based on the current set of address field values.

Specified by:
geocodeAddress in interface GeocodeFunctionality
Returns:
a single geocoded address

findAddressCandidates

public List<AddressCandidate> findAddressCandidates()
Description copied from interface: GeocodeFunctionality

Returns a List of AddressCandidates based on the current set of address field values.

Specified by:
findAddressCandidates in interface GeocodeFunctionality
Returns:
a List of AddressCandidates matching the current set of address field values

getResource

public VEGeocodeResource getResource()
Description copied from interface: GISFunctionality

Returns the GISResource associated with this functionality.

The resource passed to GISFunctionality.initFunctionality(GISResource) is maintained as a class variable and is accessible through this method.

Specified by:
getResource in interface GISFunctionality
Returns:
the GISResource associated with this functionality

getAddressFieldAlias

public String getAddressFieldAlias(String fieldName)
Description copied from interface: GeocodeFunctionality

Returns an alias for the given address field.

The GeocodeTask labels the input text box for the address field with this alias.

Specified by:
getAddressFieldAlias in interface GeocodeFunctionality
Parameters:
fieldName - the address field for which the alias is to be returned
Returns:
the alias for the given address field

getAddressFieldValue

public String getAddressFieldValue(String fieldName)
Description copied from interface: GeocodeFunctionality

Returns the value for a given address field.

Specified by:
getAddressFieldValue in interface GeocodeFunctionality
Parameters:
fieldName - the address field for which the value is to be returned
Returns:
the value for the given address field

getAddressFields

public String[] getAddressFields()
Description copied from interface: GeocodeFunctionality

Returns an array of address fields for this geocoder. Every implementation of GeocodeFunctionality defines the address fields that are available.

The GeocodeTask dynamically generates input text box for each address field.

Specified by:
getAddressFields in interface GeocodeFunctionality
Returns:
a String array of address fields for this geocoder

setMinScore

public void setMinScore(int userDefinedMinScore)
Parameters:
userDefinedMinScore - the userDefinedMinScore to set

getMinScore

public int getMinScore()
Returns:
the minScore

setAddressFields

public void setAddressFields(String[] addressFields)
Sets the address fields to be used by this GeocodeFunctionality. The Geocode Task displays these fields in the user interface. By default, one all-purpose address field, "FullAddress", is used which corresponds to the "Query" property on GeocodeRequest object in the Bing Maps Geocode Service. You can override this by specifying which address fields should be used. Possible values are : "AddressLine","AdminDistrict","CountryRegion", "District", "Locality", "PostalCode", "PostalTown". For more information about these fields, please refer to the Address class in the Bing Maps Geocode Service documentation.

Parameters:
addressFields - the address fields

setAddressFieldValue

public void setAddressFieldValue(String fieldName,
                                 String value)
Description copied from interface: GeocodeFunctionality

Sets the value for a given address field.

Specified by:
setAddressFieldValue in interface GeocodeFunctionality
Parameters:
fieldName - the address field for which the value is to be set
value - the value for the given address field

setAliases

public void setAliases(HashMap<String,String> aliases)
Sets the aliases for the address fields used by this GeocodeFunctionality. The Geocode Task uses these aliases as labels on the user interface. The default aliases are specified in Res.properties under keys with the pattern VEGeocodeFunctionality.<addressField> You can override them through faces-config.xml or programatically as follows -
 VEGeocodeFunctionality veGeoFunc = ...;
 HashMap<String, String> aliases = new HashMap<String, String>();
 aliases.put("PostalCode", "Zip Code");
 aliases.put("CountryRegion", "Country");
 veGeoFunc.setAliases(aliases);
 

Parameters:
aliases - the aliases to set. The keys of the HashMap correspond to address fields

toString

public String toString()
Overrides:
toString in class Object