googleappengine python中基于地理空间和位置的搜索

2024-05-14 10:33:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我想实现类似airbnb(https://www.airbnb.com/s/Paris--France?source=ds&page=1&s_tag=PNoY_mlz&allow_override%5B%5D=)上的地图拖动搜索

我在数据存储中保存这样的数据

 user.lat = float(lat)
     user.lon = float(lon)
     user.geoLocation = ndb.GeoPt(float(lat),float(lon))

每当我拖放地图或放大或缩小时,我的控制器中都会有以下参数

^{pr2}$

我的模型课如下所示

class Points(ndb.Model):
    name = ndb.StringProperty(required=True)
    description = ndb.StringProperty(required=True)
    contact = ndb.StringProperty(required=True)
    lat = ndb.FloatProperty(required=True)
    lon = ndb.FloatProperty(required=True)
    geoLocation = ndb.GeoPtProperty()

我想改进查询。

提前谢谢。在


Tags: 数据httpstruewww地图requiredfloatlon
1条回答
网友
1楼 · 发布于 2024-05-14 10:33:54

不,您不能通过检查查询中的所有4个条件来改进解决方案,因为ndb查询不支持对多个属性使用不等筛选器。来自NDB Queries(重点是我的):

Limitations: The Datastore enforces some restrictions on queries. Violating these will cause it to raise exceptions. For example, combining too many filters, using inequalities for multiple properties, or combining an inequality with a sort order on a different property are all currently disallowed. Also filters referencing multiple properties sometimes require secondary indexes to be configured.

以及

Note: As mentioned earlier, the Datastore rejects queries using inequality filtering on more than one property.

相关问题 更多 >

    热门问题