Finding a coordinate in a circle
geolocation, google-maps, grails, groovy, java
Solution
if distance from point to center of circle is <= radius of circle then it is inside the circle. if the area is made of more than one circle than compare to all the circles... it won't take that long.
java.awt.geom.Point2D.Double is perfect for this.
Problem
I am doing a mashup using Google Maps under Grails where users can create geofences by selecting a point on the map and a radius. This get stored on my database and the application receives constantly a set of coordinates from a GPS device. I would like to compare the received coordinates with the area stored in the circles. If the point is inside (or outside) the circle the program will fire an action. However, I would like to know how I can find out if the coordinates are located inside/outside the circle. There is a Javascript library which allows doing this but I need to do this on the server. Is there a Java (or even Groovy) library for this? How would you implement it?