2

I'm writing a server side java application that takes location updates from an android device. The device is traveling along a route and I want to be able to determine if it had arrived at its location. The obvious solution is to define a geo-fence...of the current location of the android device is within this fence then it has arrived at its location.

My question is whether this is possible to do in serverside java. I know there are probably ways to do it with google maps API on the client side but that's not possible for me. Are there any libraries out there that will provide this functionality?

Thanks in advance

B

Brian Boyle
  • 2,849
  • 5
  • 27
  • 35
  • Could the geo-fence simply be a bounding box around the destination defined by the latitude and longitude of the final destination and a delta which represents the height and width of the bounding box. The server side simply needs to perform some math to determine if the current location is within the bounding box surrounding the final destination. – ditkin Nov 21 '11 at 01:30
  • Do you have lat/long of destination? If so, it's just a distance calculation. – Dave Newton Nov 21 '11 at 01:30
  • I do have the long/lat and it's possible fence could just be a bounding box. How would I calculate distance using just the longitude and latitude? Apologies for my lack of geo spatial knowledge! – Brian Boyle Nov 21 '11 at 01:38
  • I found this on another question. Souls do the trick. Thanks for all your help. http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in-java – Brian Boyle Nov 21 '11 at 01:44
  • This should cover it: http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in-java – Brian Boyle Nov 21 '11 at 21:33

1 Answers1

2

Actually, most of these answers don't solve the problem. A geofence is a regular n-gon and the original question isn't trying to determine the distance to a point within the fence (i.e. am I close to a lat/lon) but rather whether or not they are within a box of geometry.

For that, the best answer is to do the following:

http://www.codeproject.com/Articles/62482/A-Simple-Geo-Fencing-Using-Polygon-Method

AfroRick
  • 610
  • 5
  • 17