Domo may receive GPS coordinates extracted from images uploaded to Domo. Assume the coordinate with the greatest number of coordinates within a specified radius represents the user's home location.
Given a list of latitude and longitude pairs and a radius in meters, return the original coordinate with the largest neighborhood. A coordinate counts itself, and ties must be resolved by returning the coordinate that appears first in the input.
Implement find_home_coordinate(coordinates, radius), where coordinates is a list of [latitude, longitude] pairs and radius is a positive number of meters. Return the original [latitude, longitude] pair with the greatest number of coordinates whose great-circle distance from it is at most radius.
Use Earth's radius as 6,371,000 meters. The comparison must use spherical distance, not Euclidean distance on raw latitude and longitude values.
Example 1:
Input: coordinates = [[0, 0], [0, 0.001], [0, 0.002], [10, 10]], radius = 150
Output: [0, 0.001]
The middle coordinate is within approximately 111 meters of both neighboring coordinates, so its neighborhood is largest.
Example 2:
Input: coordinates = [[0, 0], [0, 0.001], [10, 10], [10, 10.001]], radius = 120
Output: [0, 0]
Both local pairs have the same size, so the first coordinate wins the tie.
def find_home_coordinate(coordinates, radius):