React library for physical address localization - reactjs

My team wants to implement a feature for physical addresses to be localized from navigator.language, for example, in the US this is a physical address:
919 Stimple Ct, Fairbanks, Alaska 99712, USA
in other countries like Italy, the address is:
Rossi Gianni, VIA GARIBALDI 26, 70043 MONOPOLI BA, ITALIA
and each country or region have a different format for physical address.
The thing is the address display is based on US physical address for the street number and name, the state, the city, and then is displayed in another screen. But for other countries is different, so the street number and name depends on how the user writes them, but the other fields for state, city and Postal Code will show with the US address format. Changing the input fields will do the same, changing the variables for each input means creating code for each language (not an option).
I've been searching for a library for React to format physical address but all I've found are libraries to parse the address in an object, but it doesn't format the address by location.
So I'm looking for a master who may know a library (or maybe a license to pay for) to format physical address by location.
We may use only 5 address format by continent if there is no library to localize them.
Thanks !

Related

Filter an address column to only show the city

I have a retail database in Arabic, the addresses are written in Arabic, I have found a way to turn the letters to numbers to maybe make it easier for me, however, I am struggling to filter only the city name from the columns.
The problem is that the address is very specific, they are more of directions and they are generally written in the format of ( city, street, building name, nearby landmark ) but most of the time it's only written as the city only.
Is there a way to extract only the city from all the addresses?

What Data Structure is best suited to store differences

I have a set of pre defined properties I want to store. For example:
PersonNr,Gender,Name,Surname, Address, Zip,City.
Now I have different sources for these data sets, which share the PersonNr but have different value for the other properties:
EXAMPLE:
From Database A I get
123456,M,Hudson,James,Fakestr 123, 12345, West City
From Database B i get
123456,M,Hudson,Jameson,Fakestr123, 12345, East City
Instead of storing both values I want to store the data from Database A as a reference and only store the data from B that are different to A.
In my Example I would like to store something like:
Database B, Jameson, East City
What data structure can I use for the given problem?
Thanks in advance
The solution you choose depends a lot on the nature of your data, how you're going to store it, and what you want to do with it. If all you want is an abbreviated record that only stores the deltas, then you could write a comma-separated line that has empty fields. That is, given:
Database A
123456,M,Hudson,James,Fakestr 123, 12345, West City
Database B
123456,M,Hudson,Jameson,Fakestr123, 12345, East City
You could write a separate record showing the deltas:
123456,,,Jameson,,,East City
If you're storing the deltas in a database, then you'll probably want records that give the record identifier, the field name, and the changed value. That representation would be:
123456,Surname,Jameson
123456,City,East City
That's probably how I'd represent it in memory, too: a hash map keyed by record identifier (i.e. 123456), with a list of field name / value pairs for each ID.

How to find the name of a place from latitude and longitude value

I am analysing app data which contains lat value and lon value of a user visited places. I was able to export the data to tableau and plot it on the map but I want to find the name of place for each pair of lat and lon.
One solution could be, if I get a table of three columns (Lat, Lon, Place) then I can join it with my user data table to find the name of a place at a given Lat and Lon.
My question is, do we have a ready made table with the above three columns which I can import in my SQL-Server? I am interested in places of UK or London. Is there any other approach to achieve it?
You can get this from the Ordinance Survey which should get you lat, long, postcode;
https://www.ordnancesurvey.co.uk/business-and-government/products/code-point-open.html
You'll then need another data source to map the postcode to location name (e.g. town, county etc). See the similar post below;
Where can I find a list of all UK _full_ postcodes including street name and their precise coordinates?
It might take a little fiddling about, and you're always going to have the issue with data being a little out of date but it should be good enough.
I wrote an API wrapper in R for postcodes.io, which is a free UK postcode database. Check the original documentation so that you could create an API wrapper in your language of choice. Wrappers in languages other than R are also available.
If you use R, then type you can get the place names in the following way:
if (!require("devtools")) install.packages("devtools")
devtools::install_github("erzk/PostcodesioR")
library(PostcodesioR)
rev_geo <- reverse_geocoding(0.127, 51.507)
It will return a list with extensive information about the latitude and longitude, e.g. wards, NUTS, administrative district, county, parish, consituency, CCG and many more.
There is also a bulk_reverse_geocoding() function which takes several lat and lon inputs.

Converting Address (Street Address, City, State, Zip Code) to FIPS Code

I am trying to convert an address of the type:
24 Willie Mays Plaza, San Francisco, CA 94107
to a FIPS code (in this case, it would be 075).
Does anyone know any tools that can do this? Would even be happy to pay for a service that can convert.
You can do a one-time lookup here:
http://www.zipinfo.com/search/zipcode.htm
Or, you can purchase a product to use:
http://www.zip-info.com/products/products.htm

How many address fields would you use for a UK database?

Address records are probably used in most database, but I've seen a number of slightly different sets of fields used to store them. The number of fields seems to vary from 3-7, and sometimes all fields are simple labelled address1..addressN, other times given specific meaning (town, city, etc).
This is UK specific, though I'm open to comments about the rest of the world too. Here you need the first line of the address (actually just the number) and the post code to identify the address - everything else is mostly an added bonus.
I'm currently favouring:
Address 1
Address 2
Address 3
Town
County
Post Code
We could add Country if we ever needed it (unlikely).
What do you think? Is this too little, too much?
The Post Office suggests (http://www.postoffice.co.uk/portal/po/content1?catId=19100182&mediaId=19100267) 7 lines:
Addressees Name
Company/Organisation
Building Name
Number of building and name of thoroughfare
Locality Name
Post Town
Post Code
They then say you do not need to include a County name provided the Post Town and Postcode are used.
The BSI have BS 7666 - that covers all addressing. I recommend you look there.
The 2000 version recommends
An address shall be based upon a logical data model comprising the following entities:
addressable object, with sub-types:
primary addressable object;
secondary addressable object;
street;
locality;
town;
administrative area, a.k.a. district;
county;
postcode.
See: http://landregistry.data.gov.uk/def/common/BS7666Address
I don't know whether this is minimal (I doubt it) but the heading on my cheque book says something pretty close to:
Lloyds TSB
Isle of Man Offshore Centre
Peveril Buildings
Peveril Square
Douglas
Isle of Man
IM99 0XX
United Kingdom
This causes fits when I try to enter it into the US banking system.
If I were you, I'd call Royal Mail and ask them... or look on their website for postcode lookup as a best practice.
There's different types of addresses, and each different type has a slightly different structure. Forward sorting offices have a different postal address structure than a residential home with a street number. What if the house has a name instead of a number? There are so many factors to consider.
Since I moved to Canada I had to do something similar and it's far more complicated than a straightforward residential address which generally has:
Street Number if applicable
Street Number Suffix if applicable
House Name
Street Name
Street Type
Street Direction if applicable
Unit Number for flats, townhouses or other types of building/location
Minor Municipality (Village)
Major Municipality (Major Town/City)
County
PostCode
Country if you include Scotland, Wales, Northern Ireland (and now I noticed Eire)
Then you get businesses that have their own Delivery Route, PO Boxes, Forward Sortation Offices...
It gets complicated in a real hurry.
Best bet - give Royal Mail a call and they should be able to give you information on their standard address templates.
EDIT: Your 3 field method isn't a bad one...particularly. However, data sanitization may be a significant issue using the field setup you have and you may need a fairly complex strategy for making sure that the address entered is valid. It's far easier to sanitize single dedicated fields to make sure input is correct than it is to parse various address tokens out of combined fields.
Another simpler way to gain this info is to go on the Royal Mail website and check their postcode lookup page.
On their main postcode lookup, they use 4 fields and I guess they have some form of validation on the street name/type field. They separate the house number and name and I guess they only allow major municipality. I'm assuming the county/country are assumed. If you break out their advanced search, they give you two extra fields for flat number and business name.
Given that some fields are combined on their site, you have to assume that there's some amount of validation to make sure that data entered can be gainfully used.
Premises elements
Sub Building Name
Building Name
Building Number
Organisation Name
Department Name
PO Box Number
Thoroughfare elements
Dependent Thoroughfare Name
Dependent Thoroughfare Descriptor
Thoroughfare Name
Thoroughfare Descriptor
Locality elements
Double Dependent Locality
Dependent Locality
Post Town
Postcode element
Postcode
This answer may be a few years late, but it's aimed at those like myself looking for guidance on how to correctly format postal addresses for both storing in a database (or the likes of it) and for printing purposes.
Taken from Royal Mail Doc, link below - conveniently titled the 'Programmers Guide'
Technical specififcation for users of PAF
Page 27 - 42 was most helpful for me.
It's very likely that a "UK" will be opened to Eire as well, and in some lines of business there will be legal differences, generally between Scotland / NI / the channel islands and England and Wales.
In short, I would add country to the list. Otherwise it's fine (no fewer certainly), though of course any address is traceable from a building reference, a post code and a country alone.
Where we live in France its just 3 lines:-
myname
village/location name
6 digit postcode followed by post town name in uppercase
Even from UK that's all that is required

Resources