如何使用GeoQuery对位置和特定值进行排序? (安卓) [英] How can I use a GeoQuery to sort by both location and certain value? (Android)

查看:114
本文介绍了如何使用GeoQuery对位置和特定值进行排序? (安卓)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是Firestore的地理查询: https://github.com/imperiumlabs/GeoFirestore-Android 但这不允许进一步排序. 我想按最近和最著名的用户进行排序,我该怎么做?还有其他可能的库吗?

This is a Geoquery for Firestore: https://github.com/imperiumlabs/GeoFirestore-Android But it doesn't allow for further sorting. I want to sort by the nearest and most famous users, how could i do such a thing? Are there any other possible libraries?

推荐答案

Geofire在Firestore上似乎无法完成某些工作:它对两个值(纬度和经度)执行范围查询.它通过创建一个geohash值来做到这一点,该值将纬度和经度合并为一个值,该值可用于选择彼此接近的文档范围.

Geofire already does something seemingly impossible on Firestore: it performs a range query on two values (lat and lon). It does this by creating a geohash value, which combines the latitude and longitude into a single value, that can be used to select a range of documents that are close to each other.

要允许在另一个字段的范围内进行附加选择,您必须找到一种将另一个字段的值合并到Geohash值中的方法.从本质上讲,这意味着您必须找到一种方法来表达名声(您的其他属性)作为位置(距离)的函数的重要性,并以此为基础计算单个字段值.尽管从技术上讲这可能可行,但我怀疑有人能做到这一点.

To allow additionally select on the range of another field, you'd have to find a way to combine the value of that other field into the Geohash value. It essentially means you have to find a way to express the importance of fame (your additional property) as a function of location (the distance), and compute a single field value based on that. While this may technically possible, I doubt anyone has every done it.

要了解位置过滤的工作原理(以及为什么添加一个额外的字段并不像看起来那样简单),请看一下:

To learn how filtering on location works (and why adding an extra field is not as simple as it may seem), have a look at:

  • the video of my talk on geofiltering on Firestore
  • Jeff's much more concise Realtime GeoQueries With Firestore video and article
  • Firebase/GeoFire - Most popular item at location

这篇关于如何使用GeoQuery对位置和特定值进行排序? (安卓)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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