GeoLocation API调用EVE RESTful API [英] GeoLocation API Calls against an EVE RESTful API

查看:98
本文介绍了GeoLocation API调用EVE RESTful API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行Eve RESTful API服务器的情况下,我可以轻松地将地理位置数据存储到MongoDB中. 所以我将数据存储为:

I easily can store geolocation Data into MongoDB with an Eve RESTful API Server running. So I store data like:

loc : {
  lng: 13.01111,
  lat: 51.01111
}

验证等效果很好.

但是:我无法找到一种从REST API中获取地理位置数据的方法. 在那儿有示例查询命令行,但似乎没有办法以适当的方式查询API.

But: I was unable to find a way to get geolocation data out of the REST API. There are sample queries over there working fine at the command-line, but there seems to be no way to query the API a appropriate way.

  1. 是否有一种方法可以将Query之类的MongoDB扔向REST API或
  2. 这是为此目的定制API的首选方法.

弄清楚点:已经有一个2d索引,mongo-cmd处的geoWithin查询工作正常. 这只是关于如何通过REST API进行查询.

To make things clear: There is already a 2d index and geoWithin queriey at the mongo-cmd are working fine. It's just about how to query via the REST API.

推荐答案

未提及,但应予以支持.我不喜欢地理资源,但是我只是尝试发出$near查询,并且由于我的数据库缺少必要的2dindex,它返回了操作失败.这意味着命令已正确传递到数据库.

It's not mentioned but it should be supported. I'm not into geo stuff but I just tried to issue a $near query and it returned an operation failure because my database was missing the necessary 2dindex. This means that the command was correctly passed to the database.

如果您使用的是诸如Postman之类的其他客户端,则语法应如下所示(为简单起见,我使用$near):

If you are using a rest client like Postman the syntax should be something like this (I'm using $near for simplicity):

?where={"loc": {"$near": {"$geometry":{"type": "Point", "coordinates": [13,51]}}, "$maxDistance": 100}}

如果您使用的是app.get方法,请记住要json.loads您的查询.希望这会有所帮助.

If you are using app.get method remember to json.loads your query. Hope this helps.

这篇关于GeoLocation API调用EVE RESTful API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆