【问题标题】:Using two inequalities in AppEngine query [duplicate]在 AppEngine 查询中使用两个不等式 [重复]
【发布时间】:2013-01-02 14:36:11
【问题描述】:

可能重复:
Google App Engine Geohashing

我正在尝试使用 AppEngine 来存储具有纬度和经度参数的模型。一切似乎都很好,除非我尝试检索两个位置之间的所有用户。我这样做:

 String query = "select from " + TUser.class.getName();
 query += " WHERE ( iLatitude >= " + lat_min + " && iLatitude <= " + lat_max + ")";
 query += " && ( iLongitude >= " + lon_min + " && iLongitude <= " + lon_max + ")";
 List<TUser> obj = (List<TUser>)pm.newQuery(query).execute();

但是,正如 AppEngine 文档中所说,这会引发:

 java.lang.IllegalArgumentException: Only one inequality filter per query is supported.  Encountered both latitude and longitude

我正在尝试为此找到解决方法,但没有运气。使用坐标总是需要至少两个不等式。那怎么解决呢?有什么解决办法吗?或者有谁知道什么时候会在 AppEngine 中实现?

由于数据库有数十万用户,我不能仅按纬度过滤查询,然后使用 FOR 迭代结果以获取具有正确经度的查询。数据过多。

谢谢,

【问题讨论】:

  • @dragonx 注意到他没有询问地理哈希(可能是因为他不知道)。
  • 是的,但是如果他查看副本的答案,那就是全部了。

标签: android google-app-engine


【解决方案1】:

您需要查看geohash,它将图块编码为单个字符串。
查看this blog 了解如何使用它。

【讨论】:

    猜你喜欢
    • 2020-12-18
    • 1970-01-01
    • 2018-11-11
    • 2013-01-01
    • 2019-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多