Python Eve 0.8:如何使用 $centerSphere 执行 $geowithin?

Python Eve 0.8: how to perform a $geowithin with a $centerSphere?

我们部署了一个 docker 容器,其中有一个 MongoDB 数据库 运行。这是一个简单的数据库,我们在其中存储地理参考传感器数据(例如温度、风速)。由于我们想查询这些基于搜索半径的地理参考观测,我们启用了这样的空间查询:

db.ObsStationTemp.createIndex({point:"2dsphere"})
db.ObsStationTemp.ensureIndex({"geometry":'2dsphere'})

数据在 MongoDB 中被正确摄取,我们实际上可以执行如下空间查询:

db.ObsStationTemp.find({geometry:{$geoWithin:{$centerSphere:[[4.925922,51.969035],2/3963.2]}}})

现在我们想使用 Eve 从 HTTP 接口访问这些观察结果。我们将之前的查询转换为 HTTP。我们尝试了很多组合,比如:

 http://127.0.0.1:5000/ObsStationTemp?where={"geometry": {"$geoWithin": {"$centerSphere": [ [4.92592, 51.969035],0.02]}}}

但其中 none 有效。 这是Eve服务器的回复:

{
   "_status": "ERR",
   "_error": {
       "code": 400,
       "message": "Query contains unknown or unsupported operators: $centerSphere"
   }
}

我们在当前的 HTTP 查询中缺少什么?任何帮助或分享一个例子?我们使用的是 Eve 0.8,查询是使用 PostMan 执行的。谢谢。

We are using Eve 0.8 and the query is performed using PostMan.

这是因为PyEve (currently version 0.8) does not support the $centerSphere operator. See eve/io/mongo/mongo.py#L94-L102. You may submit a request on PyEve's issue tracker对于运营商的支持。

此外,值得注意的是 $geoWithin$centerSphere 的使用仅适用于 MongoDB v3.4+。