How do I get the County from the address?
You can always determine the County for an address from its last line. The last line of every address is either a County, a County Town or a Dublin Postal District.
County | County Town | Dublin Postal District |
---|---|---|
8 Silver Birches Millfarm Dunboyne, Co. Meath |
37 Springdale Tullow Road Carlow |
4 Inns Court Winetavern Street Dublin 8 |
To determine the County from the last line you just need to handle the three possible scenarios:
Last Line | How to get County |
---|---|
Starts with "Co. *" | Remove the "Co. " and you have the County name. |
Starts with "Dublin *" | The County is Dublin |
All others | The last line is a County name as it is the name of a County Town, e.g. Carlow. |
If you need the corresponding ECAD County ID you can use the look-up table here County ID Lookup.
Addresses in some towns straddle more than one County, e.g., Athlone straddles Counties Westmeath and Roscommon. If FindAddress hasn't matched to a sufficient level to determine the County it will return the provided County information if it is valid. If it isn't valid, or is missing, then it returns the default County for a match. In the case of Athlone the default County is Westmeath.
The address examples in the following table illustrate the logic:
Input Address | Last Line of Address Returned |
---|---|
Athlone | Co. Westmeath |
6 Streetwontmatch, Athlone, Westmeath | Co. Westmeath |
6 Streetwontmatch, Athlone, Roscommon | Co. Roscommon |
6 Hillside Close, Athlone, Westmeath | Co. Roscommon (The building is in Roscommon, not Westmeath) |
8 Silver Birches, Millfarm, Dunboyne, Meath | Co. Meath |
8 Silver Birches, Millfarm, Dunboyne | Co. Meath |
8 Silver Birches, Millfarm, Dunboyne, Wexford | Co. Meath |
Dunboyne, Wexford | Co. Wexford |
6 Streetwontmatch, Dunboyne, Wexford | Co. Wexford |
Getting the address information
Where are we "looking at the last line of an address"? The matched address is in a simple unstructured array format, and if you've supplied an address profile it is also available in a structured reformatted address.
Unstructured Address
If you're using Preferred Address (vanityMode=true), then the address object is vanityAddress
.
If you're using Geographic Addresses (geographicAddress=true), then the address object is geographicAddress
.
If you're using Postal Address (default) then the address object is postalAddress
.
N.B. The County in a Postal address may not be the Geographic County in which the address is located. In cases where the Post Town in the address differs from the Geographic County of the address, the County in the address is the County associated with the Post Town. For this reason, it is not advisable to use postalAddress
as a method of determining the County for an address.
Structured Formatted Address
The address object is reformattedAddress
If you have a dedicated County field in your reformattedAddress it may not be populated in the case where the last line of an address is a Town with the same name as its County, or a Dublin Postal District. You can force an address profile to always return a County, but this will make your addresses appear as Dublin 15, Co. Dublin or Tipperary, Co. Tipperary. Use the logic at the top of this page to determine the County.
Anything Else I Should Know?
If you call GetECADData with your addressId
it will return a countyId
in the administrativeInfo
object. However, this is not always populated and could be different to the value returned by FindAddress if you have only matched to Town level.
Let's look at a few examples where we only match to Town to show why this is the case:
- 15 Streetwontmatch, Dunboyne, Meath
FindAddress matches to Dunboyne, and returns Meath as the County. If we pass the addressId
of Dunboyne to GetECADData it will return Meath as the County in the administrativeInfo
object.
- 15 Streetwontmatch, Athlone, Roscommon
- 15 Streetwontmatch, Athlone, Westmeath
In the first address, FindAddress matches to Athlone, and returns Roscommon as the County. In the second FindAddress matches to Athlone and returns Westmeath as the County. In both cases if we pass the addressId
of Athlone to GetECADData it won't return a County. Why? Addresses in Athlone straddle Counties Westmeath and Roscommon.
If addresses associated with an addressId
(thoroughfare, locality, etc.) are in one County only then you get a result in administrativeInfo
. If they are in two or more Counties, then you don't get a result.