Giter Site home page Giter Site logo

fiware-orion2cartodb's Introduction

Description

orion2cartodb is Python script to parse NGSI Context Brokers (such as Orion) subscriptions and feed a CartoDB Map.

You can get Orion at: https://github.com/telefonicaid/fiware-orion

CartoDB is an open source cloud-based solution for showing maps on a website.

You can create an account at: http://cartodb.com/

Deployment, configuration and running

orion2cartodb must be deployed on a server reachable by the Context Broker.

orion2cartodb is based on webapp2, please see https://webapp-improved.appspot.com for full details, so you will need to install the following dependences on your server:

    $ pip install WebOb
    $ pip install Paste
    $ pip install webapp2
    $ pip install pyyaml

Once webapp2 is installed, you must edit the orion2cartodb configuration file (orion2cartodb.yaml):

  • orion2cartodb_host: your server IP address interface attached IP reachable by the Context Broker.
  • orion2cartodb_port: your server port. Please remember that must be reachable from Context Broker.
  • orion2cartodb_apikey: your private CartoDB API key.

Finally orion2cartodb is ready to be started:

    $ python orion2cartodb

Usage

Create a subscription in ContextBroker

Please, consider using FIGWAY script UpdateEntityAttribute.py to update it, you find it at:

https://github.com/telefonicaid/fiware-figway/tree/master/python/ContextBroker

Anyway, you can create it on your own as follows:

   POST [[HOST]/v1/subscribeContext][]
   Accept: application/json
   Fiware-Service: **your_service**
   Content-Type: application/json

   {
   entities": [
       {
           "type": "device",
           "isPattern": "false",
           "id": "**your_entity**"
       }
   ],
   "attributes": [
       "**attribute1**",
       "**attribute2**"
   ],
    "reference": "[your_machine_service]"
    "duration": "P1M",
    "notifyConditions": [
          {
               "type": "ONCHANGE",
               "condValues": [
               "**attribute1**",
               "**attribute2**"
           ]
       }
   ],
   "throttling": "PT1S"
 }

Based on the subscription, a table will be generated introducing the attributes and their values as column name and value (for each of the assets) respectively. When a new attribute is added within the subscription, a new column will be appended to the table, and the previous values for the new attribute will be considered null in the previous assets.

Update the ContextBroker entities

Please, consider using FIGWAY script SetSubscription.py to create it, you find it at:

https://github.com/telefonicaid/fiware-figway/tree/master/python/ContextBroker

Anyway, you can update it on your own as follows:

   POST [[HOST]/v1/updateContext][]
   Accept: application/json
   Fiware-Service: **your_service**
   Content-Type: application/json

   {
       "contextElements": [
   {
       "type": "**your_type**",
       "isPattern": "false",
       "id": "**your_entity**",
       "attributes": [
          {
               "name":  "**your_attribute**",
               "type":  "**your_id**",
               "value": "**your_value**"
           }] }
       ],
       "updateAction": "APPEND" }

See the results

If everything went well, you should see the attribute updates at the CartoDB data table.

Limitations

  • Your table will be named with your Orion FIWARE Service name. Please, do not change manually your table name, otherwise another table under the former name will be generated by default.

fiware-orion2cartodb's People

Contributors

luisdel87 avatar cayetanobv avatar joser avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.