gpt4 book ai didi

android - 查询 2 个 GeoPoints 之间的位置

转载 作者:行者123 更新时间:2023-11-29 23:01:36 26 4
gpt4 key购买 nike

GeoFirestore我可以查询一个位置(纬度/经度)以查看我的集合/数据库中是否有任何位置在某个半径内:

val collectionRef = FirebaseFirestore.getInstance().collection("locations")
val geoFirestore = GeoFirestore(collectionRef)

val location1 = GeoPoint(37.7832, -122.4056)
val location2 = GeoPoint(37.3832, -121.4056)
val geoQuery = geoFirestore.queryAtLocation(location1, 0.6)

但是,我想查询 location1location2 之间的第三个位置。

例如,假设 location1 是 Melbourne Central,location2 是 Mantra on the Park - 我可以查询矩形内的位置吗?

enter image description here

最佳答案

GeoFirestore 首先基于 GeoHash 查询文档。这导致大致呈矩形,然后 GeoFirestore 在内存中将其缩小到请求的范围 checking the actual distance of each document from the center .

虽然开箱即用的 GeoFirestore 不支持以矩形返回所有文档,但修改库以不进行距离过滤应该相当容易。

关于android - 查询 2 个 GeoPoints 之间的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56909820/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com