Advertisement
Guest User

Untitled

a guest
May 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. Location l1 = new Location("One");
  2. l1.setLatitude(cur_latitude);
  3. l1.setLongitude(cur_longitude);
  4.  
  5. for (int i = 0; i < lctn.size(); i++) {
  6. Location l2 = new Location("LocationB");
  7. l2.setLatitude(lctn.get(i).getLocation_lat());
  8. l2.setLongitude(lctn.get(i).getLocation_lng());
  9. float distance = l1.distanceTo(l2);
  10. distance =Float.parseFloat(new DecimalFormat("##.####").format( distance / 1000.0f));
  11. Double mile = Double.parseDouble(new DecimalFormat("##.####").format(distance * 0.6214));
  12.  
  13. Log.e("km_", "" + distance);
  14. Log.e("miles_", "" + mile);
  15.  
  16. int accuracy = 20;
  17.  
  18. if(l2.getAccuracy() <= accuracy ) {
  19. Log.e("km_", "" + distance);
  20. Log.e("miles_", "" + mile);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement