【问题标题】:Appcelerator Titanium ACS Order place by nearest the userAppcelerator Titanium ACS 离用户最近的地方
【发布时间】:2012-06-16 11:28:37
【问题描述】:

我正在尝试按最近的地点列表订购。这段代码可以正常工作:

    Cloud.Places.query({
page: 1,
per_page: 20,
where: {
    lnglat: { '$nearSphere': [latitudefast,longitudefast],  }
    },

order: {
    lnglat: { '$nearSphere': [latitudefast,longitudefast],  }
    },

latitudefast 和 longitudefast 代表用户的实际位置。它已在查询之前定义。

但它是“倒置”的,也就是说最近的地方在列表的底部,最远的地方在列表的顶部!怎么会?我如何反向订购?我订购错了吗? 谢谢!

【问题讨论】:

    标签: iphone cloud titanium appcelerator


    【解决方案1】:

    您是否尝试过不指定订单? $nearSphere 默认返回按距离排序的结果。

    来自 MongoDB 的文档(ACS 将其用作其数据存储)描述 $near:

    上面的查询找到离(50,50)最近的点并返回它们 按距离排序(无需额外排序 参数)。

    这也适用于 $nearSphere。

    http://www.mongodb.org/display/DOCS/Geospatial+Indexing

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-29
      • 2011-11-20
      • 2011-08-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多