Finding a coordinate in a circle(在圆中寻找坐标)
问题描述
我正在使用 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.
这篇关于在圆中寻找坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在圆中寻找坐标


- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01