Reputation: 65
I am trying to implement Geo Location search using Mongo DB and Spring Data.
I set up MongoDB correctly and enabled geo location index
db.track.ensureIndex( { start : "2d" } );
I created the following services :
:http://localhost:8080/secure/track/get/11.53144/48.15672/0.5
http://localhost/secure/track/add
The values are getting added properly as i can see them in the DB.
My question is what test data should i use to test if i am getting list of objects nearby to a location.Since i am not well versed with latitude/longitude ,this will be of great help
Upvotes: 1
Views: 422
Reputation: 813
This is not very clear for me: are you looking for a way to determine if the order of the POI returned is good? If it is the case:
There is a formula that will give you the distance between 2 points from their latitude/longitude.
I found in this stackoverflow answer:
public static float distFrom(float lat1, float lng1, float lat2, float lng2) {
double earthRadius = 6371; //kilometers
double dLat = Math.toRadians(lat2-lat1);
double dLng = 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(dLng/2) * Math.sin(dLng/2);
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
float dist = (float) (earthRadius * c);
return dist;
}
Then the best thing to do is to insert a batch of data that you know to be near your point of interest and check that the order is good.
I hope that answers your question.. Else, do not hesitate to edit or comment!
Upvotes: 1