简体   繁体   中英

Orion Context Broker - Query By Location

Following with queries in Orion v0.24.

  • As pointed out in previous related questions, documentation is ahead to real implementation. Is filter by location with 'geometry' and 'coord' already implemented?

  • Can anyone provide a query example. I do not understand what/how to pass coordinates. From docs:

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

I tried the following unsuccesfully:

//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"
}

I tried similar combinations, filtering special characters with encodeURIComponent, but nothing.

Entities in orion have following attribute 'coordenadas':

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

EDIT 03/11/2015

We have updated Orion to version 0.25 where geometry queries are expected to be implemented using NGSI v2.

A call to

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

reports us the update has been done correctly:

<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>

Nonetheless, the queries seem to not work properly. Following with the examples used above, a geometrical query like this should return an entity:

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

Unfortunately, the response is an empty array.

We have also tried a geometrical query using a polygon:

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

Again, the response is the empty array.

It seems like the location property of the entity, "coordenadas", is not being detected. So I tried creating a new entity to see if the problem is all entities were created before the update to v0.25, but it did not work.

EDIT 04/11/2015

The request we are building for entity creation is the following:

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
}

As you suggested we tested the entity creation in a new and clean instance of Orion. The creation was done correctly, but location query is still not working...

The examples are correct, but that functionality is not available yet in Orion 0.24.0 or any previous version. It has been already implemented in the develop branch (see corresponding issue at github.com repository , now closed). It will be available in the version next to 0.24.0, either 0.24.1 or 0.25.0 (number not yet decided at the moment of writting this) by the end of september 2015.

EDIT: Orion 0.25.0 implements geometry and coord URL parameters, but the location definition is still based in NGSIv1 mechanism . Thus, instead of using geo:point use a metadata named location to mark that the associated attribute is the location:

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

This "asymmetry" (ie NGSIv1 to define location but NGSIv2 geo-query support) will desappear as we progress in NGSIv2 implementation (take into accoun that in Orion 0.25.0, NGSIv2 is still in beta status).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM