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

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

问题描述

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

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.

我想将接收到的坐标与圆圈中存储的区域进行比较.如果该点在圆圈内(或外),程序将触发一个动作.但是,我想知道如何确定坐标是否位于圆的内部/外部.有一个 Javascript 库可以执行此操作,但我需要在服务器上执行此操作.

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.

是否有用于此的 Java(甚至 Groovy)库?你将如何实现它?

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 非常适合.

java.awt.geom.Point2D.Double is perfect for this.

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

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