在圆中查找坐标 [英] Finding a coordinate in a circle

查看:158
本文介绍了在圆中查找坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Grails下使用Google Maps进行混搭,用户可以通过选择 geofences 来创建地图上的一个点和一个半径。这存储在我的数据库和应用程序不断从GPS设备接收一组坐标。



我想比较接收的坐标和存储在圆圈中的区域。如果该点位于圆圈内部(或外部),程序将触发一个动作。但是,我想知道如何找出坐标位于圆圈内部还是外部。有一个Javascript库允许这样做,但我需要在服务器上执行此操作。



是否有Java(甚至是Groovy)库?
如何实现它?

如果从的距离 圆的圆心为<= 圆的半径,则它位于圆内。

如果区域由多于一个圆组成,圆圈......它不会花费那么长时间。



java.awt.geom.Point2D.Double是完美的。


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?

解决方案

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.

这篇关于在圆中查找坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆