Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!
Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.
public void proximityToEndPoint(String username, String password,
double latitude, double longitude) {
double radius = 6371;
connect2DB();
if (this.conn != null) {
try {
String query = "";
PreparedStatement statement;
@SuppressWarnings("unused")
ResultSet resultSet;
double lat1 = 33.420243;
double long1 = -111.936125;
double lat2 = 33.3070;
double long2 = 111.6783;
query = "SELECT username, password"
+ "FROM endpoint, rs_user\n" + "WHERE lat AND long IN "
+ calculateDistance(lat1, long1, lat2, long2);
statement = this.conn.prepareStatement(query);
statement.setString(1, username);
statement.setString(2, password);
resultSet = statement.executeQuery();
this.conn.commit();
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
closeDBConnection();
}
public static double calculateDistance(double lat1, double lng1,
double lat2, double lng2) {
int r = 6371; // average radius of the earth in km
double dLat = Math.toRadians(lat2 - lat1);
double dLon = Math.toRadians(lng2 - lng1);
double a = Math.sin(dLat / 2) * Math.sin(dLat / 2)
+ Math.cos(Math.toRadians(lat1))
* Math.cos(Math.toRadians(lat2)) * Math.sin(dLon / 2)
* Math.sin(dLon / 2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
double d = r * c;
double e = 0.621371 * d;
return e;
}
How do you determine whether a user in a certain radius of a location (represented by a set of coordinates in latitude and longitude)? If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
JavaFX TableView not displaying correctly | 3 | 54 | |
Detect Closed Loops (circles, figure-8s, etc) in PNG Images | 6 | 56 | |
ejb mdb examples | 1 | 6 | |
Java program running SQL query | 5 | 37 |
Join the community of 500,000 technology professionals and ask your questions.