java - Java程序中的位置计数问题

标签 java sql jakarta-ee

我正在研究 GPS 位置,我需要转换相应地址中的纬度和经度。我有一个包含所有纬度和经度的数据库(超过 1,50,000 个数据)及其实际地标,即一个主表中的地址。

我们在许多在各个地理位置行驶的车辆上安装了 GPS 设备。该设备每 2 分钟发送一次经纬度的实际位置,我获取该纬度和经度并将其映射到我们的主表,并从我们的主表检查哪个地标附近。为了进行这个计算,我做了一些数学运算,将一些增量值添加到从车辆获取的纬度和经度中,然后从我的主表中找到最近的搜索,一旦我们发现我们显示车辆距离 XYZ 位置 5 公里,我们就可以从主表最近的点。

这个程序基本上需要很多时间来计算位置,因为我们在车辆上安装了 10,000 个 GPS 设备,每个设备在 2 分钟内发送 GPS 数据,所以你可以想象我们得到了多少数据。

您能否帮助我解决此问题并使其具有可扩展性和快速性。

提前致谢。

最佳答案

在数据库上使用 GIS 图层怎么样?像 PostGIS 这样的东西为 sql 添加了一个新层,具有这种功能。来自FAQ :

3.7. What is the best way to find all objects within a radius of another object?

To use the database most efficiently, it is best to do radius queries which combine the radius test with a bounding box test: the bounding box test uses the spatial index, giving fast access to a subset of data which the radius test is then applied to.

The ST_DWithin(geometry, geometry, distance) function is a handy way of performing an indexed distance search. It works by creating a search rectangle large enough to enclose the distance radius, then performing an exact distance search on the indexed subset of results.

For example, to find all objects with 100 meters of POINT(1000 1000) the following query would work well:

SELECT * FROM geotable WHERE ST_DWithin(geocolumn, 'POINT(1000 1000)', 100.0);

关于java - Java程序中的位置计数问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10156037/

相关文章:

java - postgresql 中的 IN 子句可以使用多少个参数?

java - 当你不知道是否有空格时使用 Java 的 exec 命令

asp.net - EF 4.1异常 "The provider did not return a ProviderManifestToken string"

java - Servlet 问题 - 资源不可用

java - 保留 GridBagLayout 组件顺序?

java - 如何控制Guava的Abstract LoadingCache中的堆栈大小?

mysql - 查找连续缺席的天数

php - MySQL 多表更新语句

java - 使用 Maven 进行 Java Web 开发

java - OSGi - 按名称 (id) 获取 ds 服务