https://github.com/telefonicaid/fiware-orion2cartodb
NGSI connector to CARTODB
https://github.com/telefonicaid/fiware-orion2cartodb
Last synced: 8 days ago
JSON representation
NGSI connector to CARTODB
- Host: GitHub
- URL: https://github.com/telefonicaid/fiware-orion2cartodb
- Owner: telefonicaid
- License: agpl-3.0
- Created: 2015-03-17T08:56:33.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-23T10:37:59.000Z (about 9 years ago)
- Last Synced: 2024-04-12T19:30:51.306Z (about 1 year ago)
- Language: Python
- Size: 2.61 MB
- Stars: 3
- Watchers: 12
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE.txt
Awesome Lists containing this project
README
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
```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.
### Add TimeStamp to the table
https://gist.github.com/iriberri/0d5481560644f9bd5fed
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.