0

My database has a list of Pet Stores in UK as follows:

ID: 1, Name: Store A, Location: Manchester, Postcode: ABC123, Phone: 1234567890

ID: 2, Name: Store B, Location: London, Postcode: XYZ123, Phone: 1234567890

ID: 3, Name: Store C, Location: Westchester, Postcode: YEQ84, Phone: 1234567890

ID: 4, Name: Store D, Location: Westchester, Postcode: YMC84, Phone: 1234567890

User enters the Post-code [Example: CR02BX] and the system is supposed to return all the stores [Sorted by nearest Stores first]. How can this be achieved? In short, how are distance between post-codes calculated?

  • Could use a service like e.g. https://postcodes.io/ to get the lon/lat of each postcode and then calculate the lon/lat distances. What have you actually tried so far? – apokryfos Jun 11 '18 at 10:07
  • My db does not have lat long values for each stores - only the postcode. So, do you mean I calculate distance between user entered postcode and each postcode available in db records and then sort them? – Prabhat Dawadi Jun 11 '18 at 10:10
  • There's a good API link in my initial comment and a few more in the question that this one duplicates. There's many option of what to do with these libraries but the bottom line is you can't calculate distance between postcodes without finding where the postcodes actually are first. – apokryfos Jun 11 '18 at 10:14

0 Answers0