Class GeoDistance

java.lang.Object
com.ehealthsystem.map.GeoDistance

public class GeoDistance extends Object
  • Constructor Details

    • GeoDistance

      public GeoDistance()
  • Method Details

    • getDistances

      public static com.google.maps.model.DistanceMatrix getDistances(String userGeoData, String[] doctorGeoData) throws IOException, InterruptedException, com.google.maps.errors.ApiException
      Calculate driving distance from one source to several destinations using Google Maps DistanceMatrix API
      Parameters:
      userGeoData - source address, can be as textual address or in coordinates
      doctorGeoData - array of destinations to determine distances to
      Returns:
      the requested distances
      Throws:
      IOException
      InterruptedException
      com.google.maps.errors.ApiException
    • filterDoctorsInRangeIndividualRequests

      public static ArrayList<DoctorDistance> filterDoctorsInRangeIndividualRequests(ArrayList<Doctor> doctors, String userGeoData, double range) throws IOException, InterruptedException, com.google.maps.errors.ApiException
      Reduce a list of doctors to only include ones that are in a specific range from the user, determining the distance using Google Maps DistanceMatrix API, requests sent individually
      Parameters:
      userGeoData - user location
      range - maximum distance, in km (DRIVING DISTANCE because Google Maps API)
      Returns:
      a list of doctors that are in the range
      Throws:
      IOException
      InterruptedException
      com.google.maps.errors.ApiException
    • filterDoctorsInRangeBatchRequest

      public static ArrayList<DoctorDistance> filterDoctorsInRangeBatchRequest(ArrayList<Doctor> doctors, String userGeoData, double range) throws IOException, InterruptedException, com.google.maps.errors.ApiException
      Reduce a list of doctors to only include ones that are in a specific range from the user, determining the distance using Google Maps DistanceMatrix API, sent in a single batch request
      Parameters:
      userGeoData - user location
      range - maximum distance, in km (DRIVING DISTANCE because Google Maps API)
      Returns:
      a list of doctors that are in the range
      Throws:
      IOException
      InterruptedException
      com.google.maps.errors.ApiException
    • filterDoctorsInRangeWithLocalCalculation

      public static ArrayList<DoctorDistance> filterDoctorsInRangeWithLocalCalculation(ArrayList<Doctor> doctors, com.google.maps.model.LatLng location, double range) throws SQLException, IOException, InterruptedException, com.google.maps.errors.ApiException
      Reduce a list of doctors to only include ones that are in a specific range from the user, determining the distance using local calculation (Haversine formula)
      Returns:
      a list of doctors that are in the range (LINEAR DISTANCE)
      Throws:
      SQLException - see getDoctors()
      IOException
      InterruptedException
      com.google.maps.errors.ApiException
    • main

      public static void main(String[] args) throws SQLException, IOException, InterruptedException, com.google.maps.errors.ApiException
      Throws:
      SQLException
      IOException
      InterruptedException
      com.google.maps.errors.ApiException