-
Notifications
You must be signed in to change notification settings - Fork 91
Re-introduce GeoJSON conversion under a flag #1020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jason-fox
wants to merge
11
commits into
telefonicaid:master
Choose a base branch
from
jason-fox:feature/geo-json2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6a8fa69
Revert hotfix
jason-fox a8456b2
Re-add functionality under a flag
jason-fox 3892f4f
Add autocastGeoJSON
jason-fox 3d6ec0b
Revert debug flag
jason-fox f4795e8
Switch to parameter based approach
jason-fox d8506fd
Add an attribute flag
jason-fox 5d82f8e
Update templates
jason-fox 41333d5
Update descriptions
jason-fox 9417381
autocastGeoJSON to autocast
jason-fox 9d01da9
Merge branch 'master' into feature/geo-json2
jason-fox 2370063
Merge branch 'master' into feature/geo-json2
jason-fox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,10 +70,10 @@ curl http://${KEYSTONE_HOST}/v3/OS-TRUST/trusts \ | |
| Apart from the generation of the trust, the use of secured Context Brokers should be transparent to the user of the IoT | ||
| Agent. | ||
|
|
||
| ### GeoJSON support (this only applies for NGSI-LD, not for NGSI-v1 and NGSI-v2) | ||
| ### GeoJSON support | ||
|
|
||
| The defined `type` of any GeoJSON attribute can be any set to any of the standard NGSI-v2 GeoJSON types - (e.g. | ||
| `geo:json`, `geo:point`). NGSI-LD formats such as `GeoProperty`, `Point` and `LineString` are also accepted `type` | ||
| The defined `type` of any GeoJSON attribute can be any set to any of the standard **NGSI-v2** GeoJSON types - (e.g. | ||
| `geo:json`, `geo:point`). **NGSI-LD** formats such as `GeoProperty`, `Point` and `LineString` are also accepted `type` | ||
| values. If the latitude and longitude are received as separate measures, the | ||
| [expression language](expressionLanguage.md) can be used to concatenate them. | ||
|
|
||
|
|
@@ -93,15 +93,16 @@ values. If the latitude and longitude are received as separate measures, the | |
| } | ||
| ``` | ||
|
|
||
| For `attributes` and `static_attributes` which need to be formatted as GeoJSON values, three separate input formats are | ||
| accepted. Provided the `type` is provisioned correctly, the `value` may be defined using any of the following formats: | ||
| For `attributes` and `static_attributes` which need to be formatted as GeoJSON values, three separate input | ||
| formats are accepted. Provided the `type` is provisioned correctly, the `value` may be defined using any of | ||
| the following formats: | ||
|
|
||
| - a comma delimited string | ||
| - a comma delimited string | ||
|
|
||
| ```json | ||
| { | ||
| "name": "location", | ||
| "value": "23, 12.5" | ||
| "name": "location", | ||
| "value": "23, 12.5" | ||
| } | ||
| ``` | ||
|
|
||
|
|
@@ -126,6 +127,27 @@ accepted. Provided the `type` is provisioned correctly, the `value` may be defin | |
| } | ||
| ``` | ||
|
|
||
| Because GeoJSON types (e.g. `Point`, `LineString` etc.) are native types in **NGSI-LD**, automatic GeoJSON conversion is switched on for NGSI-LD by default. | ||
|
|
||
| With **NGSI-v2**, for backwards compatibility reasons, automatic GeoJSON conversion for types other than `geo:json` is turned off by default. | ||
| Add the `autocast` configuration to the attribute to enable GeoJSON conversion. Each GeoJSON attribute can be provisioned as shown: | ||
|
|
||
| ```json | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This example in documentation is for a configuration group. However, the templates modified in this PR are only about devices: The behavior should be as follow:
|
||
| { | ||
| "entity_type": "GPS", | ||
| "resource": "/iot/d", | ||
| "protocol": "PDI-IoTA-JSON", | ||
| ..etc | ||
| "attributes": [ | ||
| { | ||
| "name": "observationSpace", | ||
| "type": "Polygon", | ||
| "autocast" : "true" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### Metadata support | ||
|
|
||
| Both `attributes` and `static_attributes` may be supplied with metadata when provisioning an IoT Agent, so that the | ||
|
|
@@ -173,7 +195,7 @@ following: | |
| - Temporal Properties (e.g. `Datetime`, `Date` , `Time`) | ||
| - GeoJSON types (e.g `Point`, `LineString`, `Polygon`, `MultiPoint`, `MultiLineString`, `MultiPolygon`) | ||
|
|
||
| Most NGSI-LD attributes are sent to the Context Broker as _properties_. If a GeoJSON type or native JSON type is | ||
| Most **NGSI-LD** attributes are sent to the Context Broker as _properties_. If a GeoJSON type or native JSON type is | ||
| defined, the data will be converted to the appropriate type. Temporal properties should always be expressed in UTC, | ||
| using ISO 8601. This ISO 8601 conversion is applied automatically for the `observedAt` _property-of-a-property_ metadata | ||
| where present. | ||
|
|
@@ -207,12 +229,11 @@ Other unrecognised `type` attributes will be passed as NGSI-LD data using the fo | |
| } | ||
| ``` | ||
|
|
||
|
|
||
| ### NGSI-LD Linked Data support | ||
|
|
||
| `static_attributes` may be supplied with an additional `link` data element when provisioning an IoT Agent to ensure that | ||
| active attributes from the provisioned IoT Device may be maintained in parallel with a linked data entity . Take for | ||
| example a temperature gauge placed within a building. The **Device** data model literally represents the IoT device | ||
| itself, but the `temperature` attribute also needs to be shared with the **Building** entity | ||
| `static_attributes` may be supplied with an additional `link` data element when provisioning an IoT Agent to ensure that active attributes from the provisioned IoT Device may be maintained in parallel with a linked data entity . Take for example a temperature gauge placed within a building. | ||
| The **Device** data model literally represents the IoT device itself, but the `temperature` attribute also needs to be shared with the **Building** entity | ||
|
|
||
| A `link` between them can be provisioned as shown: | ||
|
|
||
|
|
@@ -246,8 +267,7 @@ e.g.: | |
| } | ||
| ``` | ||
|
|
||
| Whenever a `temperature` measure is received **Device** is updated, and entity `urn:ngsi-ld:Building:001` is also | ||
| updated as shown: | ||
| Whenever a `temperature` measure is received **Device** is updated, and entity `urn:ngsi-ld:Building:001` is also updated as shown: | ||
|
|
||
| ```json | ||
| "temperature": { | ||
|
|
@@ -263,25 +283,25 @@ updated as shown: | |
|
|
||
| ### Autoprovision configuration (autoprovision) | ||
|
|
||
| By default, when a measure arrives to the IoTAgent, if the `device_id` does not match with an existing one, then, the IoTA | ||
| creates a new device and a new entity according to the group config. Defining the field `autoprovision` to `false` | ||
| when provisioning the device group, the IoTA to reject the measure at the southbound, allowing only to persist the | ||
| data to devices that are already provisioned. It makes no sense to use this field in device provisioning since it is | ||
| By default, when a measure arrives to the IoTAgent, if the `device_id` does not match with an existing one, then, the IoTA | ||
| creates a new device and a new entity according to the group config. Defining the field `autoprovision` to `false` | ||
| when provisioning the device group, the IoTA to reject the measure at the southbound, allowing only to persist the | ||
| data to devices that are already provisioned. It makes no sense to use this field in device provisioning since it is | ||
| intended to avoid provisioning devices (and for it to be effective, it would have to be provisional). | ||
|
|
||
| ### Explicitly defined attributes (explicitAttrs) | ||
|
|
||
| If a given measure element (object_id) is not defined in the mappings of the device or group provision, the measure is stored | ||
| If a given measure element (object_id) is not defined in the mappings of the device or group provision, the measure is stored | ||
| in the Context Broker by adding a new attribute to the entity with the same name of the undefined measure element. By adding the | ||
| field `explicitAttrs` with `true` value to device or group provision, the IoTAgent rejects the measure elements that are not defined | ||
| field `explicitAttrs` with `true` value to device or group provision, the IoTAgent rejects the measure elements that are not defined | ||
| in the mappings of device or group provision, persisting only the one defined in the mappings of the provision. If `explicitAttrs` | ||
| is provided both at device and group level, the device level takes precedence. | ||
|
|
||
| ### Configuring operation to persist the data in Context Broker (appendMode) | ||
|
|
||
| This is a flag that can be enabled by activating the parameter `appendMode` in the configuration file or by using the `IOTA_APPEND_MODE` | ||
| environment variable (more info [here](https://github.com/telefonicaid/iotagent-node-lib/blob/master/doc/installationguide.md)). | ||
| If this flag is activated, the update requests to the Context Broker will be performed always with APPEND type, instead of the | ||
| environment variable (more info [here](https://github.com/telefonicaid/iotagent-node-lib/blob/master/doc/installationguide.md)). | ||
| If this flag is activated, the update requests to the Context Broker will be performed always with APPEND type, instead of the | ||
| default UPDATE. This have implications in the use of attributes with Context Providers, so this flag should be used with care. | ||
|
|
||
| ### Data mapping plugins | ||
|
|
@@ -339,7 +359,7 @@ The library provides some plugins out of the box, in the `dataPlugins` collectio | |
| use the `addQueryMiddleware` and `addUpdateMiddleware` functions with the selected plugin, as in the example: | ||
|
|
||
| ```javascript | ||
| var iotaLib = require('iotagent-node-lib'); | ||
| var iotaLib = require("iotagent-node-lib"); | ||
|
|
||
| iotaLib.addUpdateMiddleware(iotaLib.dataPlugins.compressTimestamp.update); | ||
| iotaLib.addQueryMiddleware(iotaLib.dataPlugins.compressTimestamp.query); | ||
|
|
@@ -349,7 +369,7 @@ iotaLib.addQueryMiddleware(iotaLib.dataPlugins.compressTimestamp.query); | |
|
|
||
| This plugins change all the timestamp attributes found in the entity, and all the timestamp metadata found in any | ||
| attribute, from the basic complete calendar timestamp of the ISO8601 (e.g.: 20071103T131805) to the extended complete | ||
| calendar timestamp (e.g.: +002007-11-03T13:18). The middleware expects to receive the basic format in updates and return | ||
| calendar timestamp (e.g.: `+002007-11-03T13:18`). The middleware expects to receive the basic format in updates and return | ||
| it in queries (and viceversa, receive the extended one in queries and return it in updates). | ||
|
|
||
| ##### Attribute Alias plugin (attributeAlias) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/unit/ngsiv2/examples/contextRequests/updateContextGeopropertiesAsString.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "location": { | ||
| "value": "23,12.5", | ||
| "type": "Point" | ||
| } | ||
| } | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand this PR provides "the definitive fix" mentioned in #1012 (comment)
Thus, an entry in CHANGES_NEXT_RELEASE relating issue #1012 should be included.