Orion Context Broker - 按位置查询

Orion Context Broker - Query By Location

在 Orion v0.24 中进行查询。

List of coordinates (separated by ;) are interpreted depending on the geometry

我尝试了以下方法但未成功:

//Call 1
http://<some-ip>:<some-ip>/v2/entities/?type=Test&geometry=polygon&coords=35.46064,-9.93164;35.46066,3.07617;44.33956,3.07617;44.33955,-9.93164
//Result
{
  "error": "BadRequest",
  "description": "invalid character in URI parameter"
}

我尝试了类似的组合,使用 encodeURIComponent 过滤特殊字符,但没有任何效果。

猎户座中的实体具有以下属性'coordenadas':

{
    "id": "Test.1",
    "type": "Test",
    "coordenadas": {
        "type": "geo:point",
        "value": "43.7723705, -7.6784461"
     },
     "fecha": 1440108000000,
     "regiones": [
       "ES"
      ]
}

编辑 2015 年 3 月 11 日

我们已将 Orion 更新到版本 0.25,其中几何查询预计将使用 NGSI v2 实现。

电话

http://<some-ip>:<some-ip>/version

报告我们更新已正确完成:

<orion>
    <version>0.25.0</version>
    <uptime>0 d, 2 h, 23 m, 17 s</uptime>
    <git_hash>a8cf800d4e9fdd7b4293a886490c40309a5bb58c</git_hash>
    <compile_time>Mon Nov 2 09:13:05 CET 2015</compile_time>
    <compiled_by>fermin</compiled_by>
    <compiled_in>centollo</compiled_in>
</orion>

尽管如此,查询似乎无法正常工作。按照上面使用的示例,像这样的几何查询应该 return 一个实体:

http://<some-ip>:<some-ip>/v2/entities?type=Test&geometry=circle;radius:6000&coords=43.7723705,-7.6784461

很遗憾,响应是一个空数组。

我们还尝试了使用多边形的几何查询:

http://<some-ip>:<some-ip>/v2/entities?type=Test&geometry=polygon&coords=40.199854,-4.045715;40.643135,-4.045715;40.643135,-3.350830;40.199854,-3.350830

同样,响应是空数组。

似乎未检测到实体 "coordenadas" 的位置 属性。所以我尝试创建一个新实体,看看问题是不是所有实体都是在更新到 v0.25 之前创建的,但是没有用。

编辑 2015 年 4 月 11 日

我们正在构建的实体创建请求如下:

POST /v2/entities/ HTTP/1.1
Accept: application/json, application/*+json
Content-Type: application/json;charset=UTF-8
User-Agent: Java/1.7.0_71
Host: 127.0.0.1:1026
Connection: keep-alive
Content-Length: 379

 {
    "id":"Test.1",
    "type":"Test",
    "nombreEspecie":"especietest",
    "coordenadas":{
        "type":"geo:point",
        "value":"3.21456, 41.2136"
    },
    "fecha":1446624226632,
    "gradoSeguridad":1,
    "palabrasClave":"test, test, test",
    "comentarios":"comentarios, comentarios",
    "nombreImagen":"ImagenTest",
    "alertas":[],
    "regiones":[],
    "validacionesPositivas":0,
    "validacionesNegativas":0,
    "validacionesDenunciadas":0
}

正如您所建议的,我们在一个新的干净的 Orion 实例中测试了实体创建。创建已正确完成,但位置查询仍然无法正常工作...

示例是正确的,但该功能在 Orion 0.24.0 或任何以前的版本中尚不可用。它已经在开发分支中实现(参见 corresponding issue at github.com repository,现已关闭)。到 2015 年 9 月底,它将在 0.24.0 之后的版本中可用,即 0.24.1 或 0.25.0(在撰写本文时尚未确定数量)。

编辑: Orion 0.25.0 实现了 geometrycoord URL 参数,但位置定义仍然基于 in NGSIv1 mechanism.因此,不使用 geo:point,而是使用名为 location 的元数据来标记关联的属性是位置:

"coordenadas": {
     "location": {
        "type": "string",
        "value": "WGS84"
    },
    "type": "geo:point",
    "value": "3.21456, 41.2136"
}

这个"asymmetry"(即定义位置的 NGSIv1 但 NGSIv2 地理查询支持)将随着我们在 NGSIv2 实施中的进展而消失(考虑到在 Orion 0.25.0 中,NGSIv2 仍处于测试状态) .