- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在构建一个类似于 Uber Eats 的订餐应用。所以,我正在使用 flutter 制作一个应用程序,但是现在我遇到了寻找最近的餐馆的问题。
我目前正在使用 geoflutterfire 包存储位置详细信息。请参阅所附图片。
查看我的代码。
getLocation() async {
// Create a geoFirePoint
GeoFirePoint center =
geo.point(latitude: 28.706707247639613, longitude: 80.58572410373661);
// get the collection reference or query
var collectionReference = _firestore.collection('locations');
double radius = 5;
String field = 'position';
Stream<List<DocumentSnapshot>> stream = geo
.collection(collectionRef: collectionReference)
.within(center: center, radius: radius, field: field);
stream.forEach((element) {
element.forEach((e) {
double fbLat = e.get('position')['geopoint'].latitude;
double fbLng = e.get('position')['geopoint'].longitude;
LatLng loc2 = LatLng(fbLat, fbLng);
LatLng loc1 = LatLng(center.latitude, center.longitude);
final distance =
distanceBetweenTwoLocations(location1: loc1, location2: loc2);
print('=======distance is ======');
print('${distance / 1000}KM');
});
});
}
是的,我正在从数据库中返回最近的位置,但是我返回了 30 多个结果,其中只有 6-7 个是正确的,我认为扩展效率不高,因为它增加了我的阅读量以及在客户端过滤它们的开销。
现在我的问题是,如何实现完美的地理查询来过滤 Cloud firestore 中最近的餐馆和司机?请帮忙。
最佳答案
Firestore 的大多数地理查询实现(例如 documented by Firebase itself)都使用 geohash允许对两个值(纬度/经度)进行范围查询的值。虽然 geohash 值允许地理查询发挥作用,但根据定义它们是不精确的,并且它们匹配矩形区域中的项目。
当您在绿色区域中查找文档时,geohashes 的范围实际上可能会扩展到包括红色区域:
要将返回的项目限制在您想要的圆半径范围内,您需要在执行操作时对结果进行后处理。在我的测试中,查询读取的文档比需要的多 5 倍,有些查询(通常是结果更少的查询)读取的文档多 15 倍。基于此,您的结果似乎是平均水平。
如果您有兴趣了解更多信息,我建议您观看我几年前的演讲视频:Querying Firebase and Firestore based on geographic location or distance .
关于firebase - Flutter Firebase GeoQueries 返回大量虚假数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69839211/
这是一个有趣的: 我有一个包含值“10 公里”、“25 公里”、“50 公里”和“100 公里”的 UIPickerView。选择的任何值都将是值 [queryLocation ... withinK
我正在构建一个类似于 Uber Eats 的订餐应用。所以,我正在使用 flutter 制作一个应用程序,但是现在我遇到了寻找最近的餐馆的问题。 我目前正在使用 geoflutterfire 包存储位
GEOquery是一个很棒的 R 包,用于检索和分析存储在 NCBI Gene Expression Omnibus (GEO) database 中的基因表达数据.我使用了以下提供的代码 GEO2R
所以我已经尝试了一段时间来实现一种方法,如果没有找到商人或者在最大半径内没有商人,我可以更新用户。因此,该应用程序基本上会搜索 Firebase 中可用的商人,并根据纬度和经度与最接近的商人进行匹配。
由于尚不支持原生 GeoQueries,我想到了一个可能的解决方案,但想知道它的有效性和有效性。 我想要的:我收集了大约 2000 个文档,每个文档都包含一个地理点。例如,我想查询距用户当前位置最近的
简而言之,我正在开发一个应用程序,旨在获取当前用户的最后已知位置并显示附近的用户(30 公里半径内)Swipe Cards .我正在使用 FireBase 和 GeoFire 来完成此操作。在我实现位
每次我尝试在 R 3.6 中安装新包时,都会出现错误,因此我需要知道 R 3.6 的“arrayQualityMetrics”和“GEOquery”包的来源 最佳答案 r的生物包(如arrayQual
我正在创建一个 Android 应用程序,一个 Uber 克隆。在此我使用 Firebase 列出用户创建的游乐设施。 Ride 以下列格式存储。 { "category" : "NUVO",
我是一名优秀的程序员,十分优秀!