AddressFormatter Class |
Namespace: Telogis.GeoBase.Addresses
The AddressFormatter type exposes the following members.
Name | Description | |
---|---|---|
AddressFormatter |
Creates a default instance of an IAddressFormatter.
| |
AddressFormatter(String) |
Creates a new instance of an IAddressFormatter that is configured using the given string.
|
Name | Description | |
---|---|---|
Default |
Gets the default IAddressFormatter.
|
Name | Description | |
---|---|---|
CreateFromConfig |
Creates an IAddressFormatter from a string.
The string needs to be valid xml.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetCountryString |
Converts the given Country into a well-formatted string for the given culture.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetLabelNames |
Returns a dictionary of LabelNames mapping to the label name in the given culture.
| |
GetLines |
Gets the lines format of the given IAddressData with the given culture.
| |
GetLinesWithCountry |
Gets the lines format with the country of the given IAddressData with the given culture.
| |
GetLocalizedUnitString(AddressUnit, String) |
Converts the given AddressUnit array into a well-formatted string for the given culture.
| |
GetLocalizedUnitString(AddressUnit, Country) |
Converts the given AddressUnit array into a well-formatted string for the given country.
| |
GetLongLineForm |
Gets the long line format of the given IAddressData with the given culture.
| |
GetLongLineFormWithCountry |
Gets the long line format with the country name of the given IAddressData with the given culture.
| |
GetOrderedComponents |
Returns the order of the properties that represent parts of an address, as a user in the
given culture might expect to enter them.
| |
GetShortLineForm |
Gets the short line format of the given IAddressData with the given culture.
| |
GetShortLineFormWithCity |
Gets the short line format with the City of the given IAddressData with the given culture.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
// 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