【问题标题】:Query Haversine with JDO使用 JDO 查询 Haversine
【发布时间】:2013-03-07 23:05:22
【问题描述】:

我需要帮助才能使用 JDO 进行此查询:

SELECT id, ( 3959 * acos( cos( radians(lat_t) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(lng_t) )
   + sin( radians(lat_t) ) * sin( radians( lat ) ) ) ) AS distance 
FROM Stores HAVING distance < 25 
ORDER BY distance

我正在尝试咨询邻近坐标,并通过大量互联网搜索,我发现了这个算法 Haversine。 The source is Google.

这是你需要的:

public static ArrayList<User> getUsers(double lat, double lng, double distance) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    Query query = pm.newQuery(¿?¿?¿?);

    ...

    return users;
}

谢谢!

【问题讨论】:

    标签: google-cloud-datastore geospatial jdo


    【解决方案1】:

    发件人:http://db.apache.org/jdo/jdoql_methods.html

    When writing the "filter" for a JDOQL Query you can make use of some methods on the various Java
    types. The range of methods included as standard in JDOQL is not as flexible as with the true Java
    types, but the ones that are available are typically of much use.
    

    您应该查找您的值并对这些值应用您想要的任何方法。

    对于订购部分,Query 接口有一个名为setOrdering 的方法,传递给它yourColumn ASC|DESC(即ASCDESC

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-07
      • 1970-01-01
      • 2011-06-13
      • 2012-04-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多