Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

get distance from latitude and longitude code android

private double distance(double lat1, double lon1, double lat2, double lon2) {
    double theta = lon1 - lon2;
    double dist = Math.sin(deg2rad(lat1)) 
                    * Math.sin(deg2rad(lat2))
                    + Math.cos(deg2rad(lat1))
                    * Math.cos(deg2rad(lat2))
                    * Math.cos(deg2rad(theta));
    dist = Math.acos(dist);
    dist = rad2deg(dist);
    dist = dist * 60 * 1.1515;
    return (dist);
}

private double deg2rad(double deg) {
    return (deg * Math.PI / 180.0);
}

private double rad2deg(double rad) {
    return (rad * 180.0 / Math.PI);
}
Comment

PREVIOUS NEXT
Code Example
Java :: java how to check string is number 
Java :: get request java 
Java :: how to send get request in java 
Java :: toCharArray() method java 
Java :: spigot kill entity 
Java :: java loop array backwards 
Java :: java iso 8601 format 
Java :: java string to lower case 
Java :: comparable on a generic class java 
Java :: regex pattern for date validation 
Java :: how to add input in array java 
Java :: android studio breakpoint not working 
Java :: linux command to see all the java version installed 
Java :: java download file from url 
Java :: java for 
Java :: does set automatically get rid of duplicates in java 
Java :: containskey in java 
Java :: java create map 
Java :: java date to string 
Java :: all possible valid IP addresses leetcode 
Java :: android imageview set image from drawable programmatically 
Java :: find number of occurrences of a substring in a string java 
Java :: date format in java 
Java :: collatz conjecture 
Java :: numbers of digits java 
Java :: reverse int array java 
Java :: formula to calculate area of a triangle java 
Java :: arraylist to array java 
Java :: how to find the size of a queue in java 
Java :: hello world! java 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =