Click or drag to resize

AddressFormatter Class

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
Contains methods that use IAddressData objects to format address data by culture.
Inheritance Hierarchy
SystemObject
  Telogis.GeoBase.AddressesAddressFormatter

Namespace:  Telogis.GeoBase.Addresses
Assembly:  geobase.net (in geobase.net.dll) Version: 4.99.0.0
Syntax
public class AddressFormatter : IAddressFormatter

The AddressFormatter type exposes the following members.

Constructors
  NameDescription
Public methodAddressFormatter
Creates a default instance of an IAddressFormatter.
Public methodAddressFormatter(String)
Creates a new instance of an IAddressFormatter that is configured using the given string.
Top
Properties
  NameDescription
Public propertyStatic memberDefault
Gets the default IAddressFormatter.
Top
Methods
  NameDescription
Public methodStatic memberCreateFromConfig
Creates an IAddressFormatter from a string. The string needs to be valid xml.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetCountryString
Converts the given Country into a well-formatted string for the given culture.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetLabelNames
Returns a dictionary of LabelNames mapping to the label name in the given culture.
Public methodGetLines
Gets the lines format of the given IAddressData with the given culture.
Public methodGetLinesWithCountry
Gets the lines format with the country of the given IAddressData with the given culture.
Public methodGetLocalizedUnitString(AddressUnit, String)
Converts the given AddressUnit array into a well-formatted string for the given culture.
Public methodGetLocalizedUnitString(AddressUnit, Country)
Converts the given AddressUnit array into a well-formatted string for the given country.
Public methodGetLongLineForm
Gets the long line format of the given IAddressData with the given culture.
Public methodGetLongLineFormWithCountry
Gets the long line format with the country name of the given IAddressData with the given culture.
Public methodGetOrderedComponents
Returns the order of the properties that represent parts of an address, as a user in the given culture might expect to enter them.
Public methodGetShortLineForm
Gets the short line format of the given IAddressData with the given culture.
Public methodGetShortLineFormWithCity
Gets the short line format with the City of the given IAddressData with the given culture.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Examples
C#
   // Geocode an address in USA. This will be used for the following GetShortLineForm, GetLongLineForm examples
   GeocodeAddress[] address = GeoCoder.GeoCode("5537 Pine Crest Dr, Happy Jack, Coconina, Arizona, 86024", Country.USA);
   IGeocodeResult result = address[0].ToGeocodeResult();

   // 
   // ** Examples of address components formatted for different cultures
   // 
   // Format the geocoded result as a short line address for a viewer in the USA
   string shortFormAddress = AddressFormatter.Default.GetShortLineForm(result.FoundAddress, "en-US");
   Console.WriteLine("Address found, USA format: {0}", shortFormAddress);
   // 'Address found, USA format: 5537 Pine Crest Dr'

   // Format the address to appear as it would be expected in Ireland, as a full long-form address
   string longFormAddress = AddressFormatter.Default.GetLongLineForm(result.FoundAddress, "en-IE");
   Console.WriteLine("Full address found, Irish English format: {0}", longFormAddress);
   // 'Full address found, Irish English format: Pine Crest Dr, Happy Jack'

// If an empty string is used in place of a culture, GeoBase will infer an appropriate culture based
// on the country of the address.with a default culture determined by the country of the address.

   // 
   // ** Examples of addresses in UK and France formatted for Canadian and German cultures 
   // 
   // Format an address in the UK as a viewer in Canada might expect it to appear
   GeocodeAddress[] addressUK = GeoCoder.GeoCode("11 Station Road, Chinley, High Peak", Country.UK);
   IGeocodeResult resultUK = addressUK[0].ToGeocodeResult();
   string longFormAddressUK = AddressFormatter.Default.GetLongLineForm(resultUK.FoundAddress, "en-CA");
   Console.WriteLine("Full address found in UK formatted for Canada: {0}", longFormAddressUK);
   // 'Full address found in UK formatted for Canada: 11 Station Road, High Peak, England, SK23 6AR'

   // Format an address in France as a viewer in Germany might expect it to appear
   GeocodeAddress[] addressFR = GeoCoder.GeoCode("34 Rue Barbet De Jouy, 7e Arrondissement, Paris, Île-De-France, 75007", Country.France);
   IGeocodeResult resultFR = addressFR[0].ToGeocodeResult();
   string longFormAddressFR = AddressFormatter.Default.GetLongLineForm(resultFR.FoundAddress, "DE");
   Console.WriteLine("Full address found in France formatted for Germany: {0}", longFormAddressFR);
   // 'Full address found in France formatted for Germany: Rue Barbet De Jouy 34, 75007, Paris'

   // 
   // ** Examples of default address formatting for different culture. These do not require a geocode.
   // 
   // Format a country name (Brazil) for a given region -- first for en-US users:  
   string countryStringForUS = AddressFormatter.Default.GetCountryString(Country.Brazil, "en-US");
   Console.WriteLine("Brazil formatted for USA English: {0}", countryStringForUS);
   // 'Brazil formatted for USA English: Brazil'

   // Next display the same country name, 'Brazil', for br-PT (Brazilian) users. Note the spelling:
   string countryStringForBR = AddressFormatter.Default.GetCountryString(Country.Brazil, "br-PT");
   Console.WriteLine("Brazil formatted for Brazilian Portuguese: {0}", countryStringForBR);
   // 'Brazil formatted for Brazilian Portuguese: Brasil'

   // Get the address format expected by users in a specified culture -- here en-US (USA)
   IEnumerable<string> ordered_components_for_region = AddressFormatter.Default.GetOrderedComponents("en-US");
   IEnumerator<string> components = ordered_components_for_region.GetEnumerator();
   while (components.MoveNext())
       Console.WriteLine(components.Current);
   Console.ReadLine();
   // Prints:
   // Number
   // Name
   // City
   // County
   // State
   // PostCode
   // Country
   // -- If the region is changed to Germany (DE), the component format result is changed to:
   // Name
   // Number
   // PostCode
   // City
   // Country
See Also