Skip to content

Provisioning an Individual Device with GeoJson Attribute #961

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
rezendel opened this issue Dec 10, 2020 · 4 comments
Open

Provisioning an Individual Device with GeoJson Attribute #961

rezendel opened this issue Dec 10, 2020 · 4 comments

Comments

@rezendel
Copy link

rezendel commented Dec 10, 2020

Hello,

I am trying to integrate a device with the maps widget on wirecloud.(mashups). I want to make sure that the data format is right

Is this the right syntax when provisioning a device?

      sudo curl -iX POST \
  'http://localhost:4041/iot/devices' \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: openiot' \
  -H 'fiware-servicepath: /' \
  -d '{
 "devices": [
   {
     "device_id":   "gps0022",
     "entity_name": "urn:ngsi-ld:Gps:0022",
     "entity_type": "Gps18",
     "transport":   "MQTT",
     "timezone":    "America/Sao_Paulo",
     "attributes": [
       **{ "object_id": "l", "name":"coordinates","type":"Point"}**
     ]
   }
 ]
}'

I get this result:

 {
  "id":"urn:ngsi-ld:Gps:0023",
  "type":"Gps18",
  "TimeInstant":{
  	"type":"DateTime",
  	"value":"2020-12-10T16:33:13.366Z",
  	"metadata":{}
  		},
  **"coordinates":{
  	"type":"Point",
  	"value":[10.2424,45.5642],**
  	"metadata":{"TimeInstant":{"type":"DateTime","value":"2020-12-10T16:33:13.366Z"}}}}

I have also tried the following:

     **{ "object_id": "l", "name":"location","type":"Geojson"}**

then the result is:

{"id":"urn:ngsi-ld:Gps:0023","type":"Gps18","TimeInstant":{"type":"DateTime","value":"2020-12-10T17:58:21.706Z","metadata":{}},

          **"location":{"type":"Geojson",
           "value":[66.2424,45.5642],**
                      "metadata":{"TimeInstant":{"type":"DateTime","value":"2020-12-10T17:58:21.706Z"}}}}
**note: geo.json didn't work**

the geolocation attribute structure is different from the example the fiware documentation.

 **"location": {
        "type": "geo:json",
        "value": {
             "type": "Point",
             "coordinates": [13.3986, 52.5547]
        }
    },**

Should the data be like this so I can integrate with the application map mashups? If so, how should I defined the attributes?

Note: I am not a JSON expert :D

thank you

@jason-fox
Copy link
Contributor

jason-fox commented Dec 15, 2020

This is perfectly possible in NGSI-LD - The provisioned Animal collars in the NGSI-LD subscriptions tutorial provide an example of a GPS unit set up as a Geoproperty. There is an outstanding PR #854 needs to be merge to simplify this on NGSI-v2 using geo:json or geo:point. GPS coordinates maybe possible to create using the JEXL parser as well. You can look at the PR to see how I envisage lat/lng pairs to be provisioned.

There is no problem with creating static attributes of a GeoJSON type of course.

@rezendel
Copy link
Author

Thanks Jason.

If I understood correctly, I should not be getting this issue since the PR #854 fixes this.

I will check my application settings

@jason-fox
Copy link
Contributor

@rezendel - PR #854 is currently open and not merged. You won't be getting this issue with NGSI-LD, but the back-port to NGSI-v2 is awaiting review.

@fgalan
Copy link
Member

fgalan commented Dec 18, 2020

PR #854 has been just merged.

@rezendel could you test again and tell us how it goes, please? Not sure how do you have installed the IOTA, but maybe you need to rebuild your docker container to get the new version of the iotagent-node-lib from master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants