Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.11 KB | None | 0 0
  1. public ArrayList<Double> getPoints (){
  2.     ArrayList<Double> location = new ArrayList<>();
  3.     SQLiteDatabase db = this.getReadableDatabase();
  4.     Cursor cursor = db.rawQuery("select latitude,longitude from "+Table_Name_Location,null);
  5.     if(cursor.getCount() > 0){
  6.         while (cursor.moveToNext()) {
  7.             Double latitude = cursor.getDouble(cursor.getColumnIndex("Lat"));
  8.             Double longitude = cursor.getDouble(cursor.getColumnIndex("Longi"));
  9.             location.add(latitude);
  10.             location.add(longitude);
  11.         }
  12.     }
  13.     cursor.close();
  14.     return location;
  15. }
  16. private double distance(double lat1, double lon1, double lat2, double lon2) {
  17.     double theta = lon1 - lon2;
  18.     double dist = Math.sin(deg2rad(lat1))
  19.     * Math.sin(deg2rad(lat2))
  20.     + Math.cos(deg2rad(lat1))
  21.     * Math.cos(deg2rad(lat2))
  22.     * Math.cos(deg2rad(theta));
  23.     dist = Math.acos(dist);
  24.     dist = rad2deg(dist);
  25.     dist = dist * 60 * 1.1515;
  26.     return (dist);
  27. }
  28. private double deg2rad(double deg) {
  29.     return (deg * Math.PI / 180.0);
  30. }
  31. private double rad2deg(double rad) {
  32.     return
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement