Skip to content

Hotfix/point not geo json #1014

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 8 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
- Add: use getDeviceSilently in checkDuplicates to avoid raise a false mongo alarm.
- Add: expose getConfigurationSilently to enable retrieve a configuration without raise a false mongo alarm (#1007)
- Add: db uri and options in mongo connection log INFO trace
- Set Nodejs 12 as minimum version in packages.json (effectively removing Nodev10 from supported versions)
- Update MongoDB to use lean() for faster retrieval
- Fix: PUT /iot/devices/:deviceId operation to implement proper update of entity_name and entity_type (#770)
- Fix: auto-provision functionality not working as expected when configured at device/group level in NGSIv1 API (#1003)
- Hotfix: avoid automatic conversion from geo:xxxx ('xxxx' diferent from 'json') to geo:json (reverts the work done in PR #854)
- Add: use getDeviceSilently in checkDuplicates to avoid raise a false mongo alarm.
- Add: expose getConfigurationSilently to enable retrieve a configuration without raise a false mongo alarm (#1007)
- Add: db uri and options in mongo connection log INFO trace
- Set Nodejs 12 as minimum version in packages.json (effectively removing Nodev10 from supported versions)
- Update MongoDB to use lean() for faster retrieval
- Fix: PUT /iot/devices/:deviceId operation to implement proper update of entity_name and entity_type (#770)
- Fix: auto-provision functionality not working as expected when configured at device/group level in NGSIv1 API (#1003)
28 changes: 14 additions & 14 deletions doc/advanced-topics.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ 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
### GeoJSON support (this only applies for NGSI-LD, not for NGSIv1 and NGSIv2)

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`
Expand All @@ -69,19 +69,17 @@ 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"
}
````
```

- an array of numbers

Expand Down Expand Up @@ -185,11 +183,12 @@ 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:

Expand Down Expand Up @@ -223,7 +222,8 @@ 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": {
Expand Down Expand Up @@ -292,7 +292,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);
Expand Down
58 changes: 30 additions & 28 deletions lib/services/ngsi/entities-NGSI-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,39 @@ function formatGeoAttrs(attr) {
switch (attr.type.toLowerCase()) {
// GeoProperties
case 'geo:json':
case 'geoproperty':
case 'point':
case 'geo:point':
// FIXME: #1012
// case 'geoproperty':
// case 'point':
// case 'geo:point':
obj.type = 'geo:json';
obj.value = NGSIUtils.getLngLats('Point', attr.value);
break;
case 'linestring':
case 'geo:linestring':
obj.type = 'geo:json';
obj.value = NGSIUtils.getLngLats('LineString', attr.value);
break;
case 'polygon':
case 'geo:polygon':
obj.type = 'geo:json';
obj.value = NGSIUtils.getLngLats('Polygon', attr.value);
break;
case 'multipoint':
case 'geo:multipoint':
obj.type = 'geo:json';
obj.value = NGSIUtils.getLngLats('MultiPoint', attr.value);
break;
case 'multilinestring':
case 'geo:multilinestring':
obj.type = 'geo:json';
obj.value = NGSIUtils.getLngLats('MultiLineString', attr.value);
break;
case 'multipolygon':
case 'geo:multipolygon':
obj.type = 'geo:json';
obj.value = NGSIUtils.getLngLats('MultiPolygon', attr.value);
break;
// FIXME: #1012
// case 'linestring':
// case 'geo:linestring':
// obj.type = 'geo:json';
// obj.value = NGSIUtils.getLngLats('LineString', attr.value);
// break;
// case 'polygon':
// case 'geo:polygon':
// obj.type = 'geo:json';
// obj.value = NGSIUtils.getLngLats('Polygon', attr.value);
// break;
// case 'multipoint':
// case 'geo:multipoint':
// obj.type = 'geo:json';
// obj.value = NGSIUtils.getLngLats('MultiPoint', attr.value);
// break;
// case 'multilinestring':
// case 'geo:multilinestring':
// obj.type = 'geo:json';
// obj.value = NGSIUtils.getLngLats('MultiLineString', attr.value);
// break;
// case 'multipolygon':
// case 'geo:multipolygon':
// obj.type = 'geo:json';
// obj.value = NGSIUtils.getLngLats('MultiPolygon', attr.value);
// break;
}
}
return obj;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
"id": "TheFirstLight",
"type": "TheLightType",
"location": {
"type": "geo:json",
"value": {
"coordinates": [
0,
0
],
"type": "Point"
}
"type": "geo:point",
"value": "0, 0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
"id": "FirstMicroLight",
"type": "MicroLights",
"location": {
"type": "geo:json",
"value": {
"coordinates": [
0,
0
],
"type": "Point"
}
"type": "geo:point",
"value": "0, 0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"type": "boolean"
},
"location":{
"value":{
"type":"Point",
"coordinates":[153,523]
},
"type": "geo:json"
"value": "153,523",
"type": "geo:point"
}
}
}
Loading