[Fiware-developer-experience] Create a geolocated restaurant with "options=keyValues"

Pablo Fernández Moniz pablofernandezmoniz at gmail.com
Fri Sep 23 16:13:52 CEST 2016


Hi,

We were requested to add an example of how to add a restaurant in the
Tourguide Application using the *options=keyValues*  parameter.

So, we are performing a request like:

POST <orion_host>:<orion_port>/v2/entities?options=keyValues

HEADERS:
{
     "Fiware-Service: "tourguide",
     "Fiware-ServicePath": "/Franchise1",
     "Content-Type": "application/json"
}

PAYLOAD:
{
    "id": "sample-id1",
    "type": "Restaurant",
    "address": {
        "streetAddress": "Cuesta de las Cabras Aldapa 2",
        "addressRegion": "Araba",
        "addressLocality": "Alegría-Dulantzi",
        "postalCode": "01240"
    },
    "aggregateRating": {
        "ratingValue": 3,
        "reviewCount": 98
    },
    "capacity": 100,
    "department": "Franchise4",
    "description": "Sample description",
    *"location": "42.8404625, -2.5123277",*
    "name":"Sample-restaurant",
    "priceRange": 0,
    "telephone": "945 400 868"
}

The problem is that the location field is not interpreted as "geo:point",
it is interpreted as text. We checked it by retrieving the created entity:

GET <orion_host>:<orion_port>/v2/entities/sample-id1

HEADERS:
{
     "Fiware-Service: "tourguide",
     "Fiware-ServicePath": "/Franchise1"
}

RESPONSE PAYLOAD:

{
    "id": "sample-id1",
    "type": "Restaurant",
    "address": {
        "type": "StructuredValue",
        "value": {
            "streetAddress": "Cuesta de las Cabras Aldapa 2",
            "addressRegion": "Araba",
            "addressLocality": "Alegría-Dulantzi",
            "postalCode": "01240"
        },
        "metadata": {}
    },
    "aggregateRating": {
        "type": "StructuredValue",
        "value": {
            "ratingValue": 3,
            "reviewCount": 98
        },
        "metadata": {}
    },
    "capacity": {
        "type": "Number",
        "value": 100,
        "metadata": {}
    },
    "department": {
        "type": "Text",
        "value": "Franchise4",
        "metadata": {}
    },
    "description": {
        "type": "Text",
        "value": "Sample description",
        "metadata": {}
    },




*"location": {        "type": "Text",        "value": "42.8404625,
-2.5123277",        "metadata": {}    },*
    "name": {
        "type": "Text",
        "value": "Sample-restaurant",
        "metadata": {}
    },
    "priceRange": {
        "type": "Number",
        "value": 0,
        "metadata": {}
    },
    "telephone": {
        "type": "Text",
        "value": "945 400 868",
        "metadata": {}
    }
}


We also tried to perform a geoquery and the restaurant is not shown as we
expected:


GET <orion_host>:<orion_port>/v2/entities?georel=near;
maxDistance:10&geometry=point&coords=42.8404625,-2.5123277&attrs=name

HEADERS:
{
     "Fiware-Service: "tourguide",
     "Fiware-ServicePath": "/Franchise1"
}

RESPONSE PAYLOAD:

[{
    "id": "0115206c51f60b48b77e4c937835795c33bb953f",
    "type": "Restaurant",
    "name": {
        "type": "Text",
        "value": "Elizalde",
        "metadata": {}
    }
}]


Is this the expected behaviour? Are we creating the entity wrongly? Should
we add a ticket for Orion in SoF?

Thanks,

ULPGC team
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.fiware.org/private/fiware-developer-experience/attachments/20160923/eab243f2/attachment.html>


More information about the Fiware-developer-experience mailing list

You can get more information about our cookies and privacy policies clicking on the following links: Privacy policy   Cookies policy