(2017-08-04, 01:57 PM)jim321 Wrote: [{"longitude":-80.******,"latitude":28.***********}.....
Try this one.. that lat and long won't work though as they aren't numbers I had to get rid of all the "***" to get it to work just with an inject node.
Code:
[
{
"id": "9b9b0cf3.9bca4",
"type": "worldmap",
"z": "3f30ea31.da3756",
"name": "map",
"lat": "37",
"lon": "-7",
"zoom": "10",
"layer": "Esri Ocean",
"cluster": "10",
"maxage": "",
"usermenu": "show",
"panit": "true",
"x": 575,
"y": 105,
"wires": []
},
{
"id": "f7e4c77.e7a5438",
"type": "switch",
"z": "3f30ea31.da3756",
"name": "Is it nav data?",
"property": "msg.payload.updates.source.sentence",
"propertyType": "jsonata",
"rules": [
{
"t": "cont",
"v": "RMC",
"vt": "str"
}
],
"checkall": "false",
"outputs": 1,
"x": 200,
"y": 225,
"wires": [
[
"f2aa41f7.ef5bc"
]
]
},
{
"id": "f2aa41f7.ef5bc",
"type": "change",
"z": "3f30ea31.da3756",
"name": "create msg.lat etc",
"rules": [
{
"t": "set",
"p": "LAT",
"pt": "msg",
"to": "payload.updates.values[path=\"navigation.position\"].value.longitude",
"tot": "jsonata"
},
{
"t": "set",
"p": "LONG",
"pt": "msg",
"to": "payload.updates.values[path=\"navigation.position\"].value.latitude",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 285,
"y": 315,
"wires": [
[
"5ca44ad8.da2324",
"e008225d.50fb7"
]
]
},
{
"id": "5ca44ad8.da2324",
"type": "function",
"z": "3f30ea31.da3756",
"name": "Make JSON",
"func": "var mymsg = {\"name\":\"MyPlace\",\"lat\":msg.LAT,\"lon\":msg.LONG, icon:\"ship\",\niconColor:\"red\"};\n\nmsg.payload=mymsg;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 445,
"y": 195,
"wires": [
[
"9b9b0cf3.9bca4"
]
]
},
{
"id": "e008225d.50fb7",
"type": "debug",
"z": "3f30ea31.da3756",
"name": "",
"active": true,
"console": "false",
"complete": "true",
"x": 550,
"y": 300,
"wires": []
},
{
"id": "641b0e3f.64a87",
"type": "inject",
"z": "3f30ea31.da3756",
"name": "",
"topic": "",
"payload": "{\"updates\":[{\"source\":{\"type\":\"NMEA0183\",\"sentence\":\"RMC\",\"label\":\"OPkplex\",\"talker\":\"GP\"},\"timestamp\":\"2017-08-04T12:41:56.000Z\",\"values\":[{\"path\":\"navigation.position\",\"value\":{\"longitude\":52,\"latitude\":-1}},{\"path\":\"navigation.courseOverGroundTrue\",\"value\":1.024333737995472},{\"path\":\"navigation.speedOverGround\",\"value\":0.036011120233928245},{\"path\":\"navigation.datetime\",\"value\":\"2017-08-04T12:41:56Z\"},{\"path\":\"navigation.magneticVariation\",\"value\":0}]}],\"context\":\"vessels.urn:mrn:imo:mmsi:98765432\"}",
"payloadType": "json",
"repeat": "",
"crontab": "",
"once": false,
"x": 110,
"y": 150,
"wires": [
[
"f7e4c77.e7a5438"
]
]
}
]
HAndy site here for playing around with json & jsonata -
http://try.jsonata.org/