OpenMarine
world map - Printable Version

+- OpenMarine (https://forum.openmarine.net)
+-- Forum: OpenPlotter (https://forum.openmarine.net/forumdisplay.php?fid=1)
+--- Forum: Node Red (https://forum.openmarine.net/forumdisplay.php?fid=15)
+--- Thread: world map (/showthread.php?tid=661)

Pages: 1 2


world map - jim321 - 2017-08-04

i am tring to get worldmap working
i have 3 functions two getting gps cords from the example websocket that is installed and one to combind the two. the problem is on the message, it  returns lat for both lat lon then the second message it shows lon for both..

msg.payload : Object
object
name: "MyBoat"
lat: 28.***********
lon: 28.***********
icon: "ship"
iconColor: "red"
8/2/2017, 10:46:11 AMnode: 5f6bc82c.0ae8b8

msg.payload : Object
object
name: "MyBoat"
lat: -80.******
lon: -80.******
icon: "ship"
iconColor: "red"
8/2/2017, 10:46:12 AMnode: 5f6bc82c.0ae8b8

first function ..
var lat= msg.payload;
msg.payload = lat;
return msg;

 then same for lon.
the function to wold map .

var name= "MyBoat";
var lat= msg.payload,lat;
var lon= msg.payload,lon;

var map={
name,
lat,
lon,
icon:"ship",
iconColor:"red",
};
msg.payload = map;
return msg;

flow
Code:
[{"id":"51ce9625.f8d018","type":"function","z":"217cab7.d842f54","name":"lat","func":"\nvar lat= msg.payload;\nmsg.payload = lat;\nreturn msg;","outputs":1,"noerr":0,"x":230,"y":500,"wires":[["967072ff.f978f"]]},{"id":"5f6bc82c.0ae8b8","type":"debug","z":"217cab7.d842f54","name":"","active":false,"console":"false","complete":"payload","x":650,"y":580,"wires":[]},{"id":"d985d20b.38da3","type":"function","z":"217cab7.d842f54","name":"lon","func":"\nvar lon= msg.payload;\n\nmsg.payload = lon;\n\nreturn msg;","outputs":1,"noerr":0,"x":230,"y":540,"wires":[["967072ff.f978f"]]},{"id":"967072ff.f978f","type":"function","z":"217cab7.d842f54","name":"return","func":"\nvar name= \"MyBoat\";\nvar lat= msg.payload,lat;\nvar lon= msg.payload,lon;\n\nvar map={\nname,\nlat,\nlon,\nicon:\"ship\",\niconColor:\"red\",\n};\nmsg.payload = map;\nreturn msg;","outputs":"1","noerr":0,"x":450,"y":520,"wires":[["fb529491.2b5f08","5f6bc82c.0ae8b8"]]},{"id":"fb529491.2b5f08","type":"worldmap","z":"217cab7.d842f54","name":"map","lat":"28.56","lon":"-80.80","zoom":"10","layer":"Esri Ocean","cluster":"10","maxage":"","usermenu":"show","panit":"true","x":630,"y":520,"wires":[]}]


any help would be greatly appreciated 
Thanks
Jim


RE: world map - PaddyB - 2017-08-04

Give this a go.. note that the input on this flow is a link to the websocket from signalk, looks like you can maybe just have one websocket going at once so you'll need to edit tha to get it connected to your websocket. This works from signalk data.

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": 555,
       "y": 155,
       "wires": []
   },
   {
       "id": "1996dede.bab381",
       "type": "link in",
       "z": "3f30ea31.da3756",
       "name": "from database",
       "links": [
           "8b385a5c.b0c248",
           "faa85eeb.a9f43"
       ],
       "x": 90,
       "y": 150,
       "wires": [
           [
               "f7e4c77.e7a5438"
           ]
       ]
   },
   {
       "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": "GLL",
               "vt": "str"
           }
       ],
       "checkall": "false",
       "outputs": 1,
       "x": 230,
       "y": 195,
       "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.value.latitude",
               "tot": "jsonata"
           },
           {
               "t": "set",
               "p": "LONG",
               "pt": "msg",
               "to": "payload.updates.values.value.longitude",
               "tot": "jsonata"
           }
       ],
       "action": "",
       "property": "",
       "from": "",
       "to": "",
       "reg": false,
       "x": 315,
       "y": 270,
       "wires": [
           [
               "5ca44ad8.da2324"
           ]
       ]
   },
   {
       "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"
           ]
       ]
   }
]



RE: world map - jim321 - 2017-08-04

i dont get info in the debug for "is it nav data" its connected direct to the ws in example..


RE: world map - PaddyB - 2017-08-04

(2017-08-04, 01:38 PM)jim321 Wrote: i dont get info in the debug for "is it nav data" its connected direct to the ws in example..

Maybe the data isn't in the example web socket data, the node looks for the "GLL" nmea data in a signalk update. Whats the address of the example websocket? I didn't even know there was one, is it signalk data?


RE: world map - jim321 - 2017-08-04

[{"id":"1c8b3d5e.821e43","type":"websocket in","z":"217cab7.d842f54","name":"","server":"bf7d28f7.f45188","client":"","x":200,"y":80,"wires":[["ee667c0b.37b94","109528e2.0185d7","2535d44a.ff5d3c"]]},{"id":"bf7d28f7.f45188","type":"websocket-listener","z":"","path":"ws://localhost:3000/signalk/v1/stream","wholemsg":"false"}]

the data from it from debug for the socket

msg.payload : string[531]
"{"updates":[{"source":{"type":"NMEA0183","sentence":"RMC","label":"OPkplex","talker":"GP"},"timestamp":"2017-08-04T12:41:56.000Z","values":[{"path":"navigation.position","value":{"longitude":-80.******,"latitude":28.***********}},{"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"}"
8/4/2017, 8:41:49 AMnode: 2535d44a.ff5d3c

thank you
jim


RE: world map - PaddyB - 2017-08-04

(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/


RE: world map - jim321 - 2017-08-04

that puts me on GB .. ill have a look at the link thanks..
i put the *** so as not to give my location away . lol
but i do want to use my actual gps cords.
thanks
jim


RE: world map - PaddyB - 2017-08-04

Ah, so if you get rid of the inject node and put back in the web socket that might work then. I just put in the UK lat and long as I new where it would end up just to test.

Sent from my SGP511 using Tapatalk


RE: world map - jim321 - 2017-08-04

the inject works but web socket does not i am at a loss "headbang"
Code:
[{"id":"1c8b3d5e.821e43","type":"websocket in","z":"217cab7.d842f54","name":"","server":"bf7d28f7.f45188","client":"","x":200,"y":80,"wires":[["4edc2490.545e4c"]]},{"id":"2535d44a.ff5d3c","type":"debug","z":"217cab7.d842f54","name":"","active":true,"console":"false","complete":"false","x":650,"y":80,"wires":[]},{"id":"46495324.6e7eec","type":"worldmap","z":"217cab7.d842f54","name":"map","lat":"37","lon":"-7","zoom":"10","layer":"Esri Ocean","cluster":"10","maxage":"","usermenu":"show","panit":"true","x":650,"y":120,"wires":[]},{"id":"4edc2490.545e4c","type":"switch","z":"217cab7.d842f54","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":140,"y":120,"wires":[["715e2030.f76df"]]},{"id":"715e2030.f76df","type":"change","z":"217cab7.d842f54","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":330,"y":120,"wires":[["66af1a7c.5d75d4"]]},{"id":"66af1a7c.5d75d4","type":"function","z":"217cab7.d842f54","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":510,"y":120,"wires":[["46495324.6e7eec","2535d44a.ff5d3c"]]},{"id":"39f69800.ccc6a8","type":"inject","z":"217cab7.d842f54","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":160,"wires":[["4edc2490.545e4c"]]},{"id":"bf7d28f7.f45188","type":"websocket-listener","z":"","path":"ws://localhost:3000/signalk/v1/stream","wholemsg":"false"}]

sent pm


RE: world map - jim321 - 2017-08-21

Code:
[{"id":"5991e9f6.61f1f8","type":"switch","z":"217cab7.d842f54","name":"Is it nav data?","property":"msg.payload.updates.source.sentence","propertyType":"jsonata","rules":[{"t":"cont","v":"GLL","vt":"str"}],"checkall":"false","outputs":1,"x":620,"y":140,"wires":[["83c847e0.93fb68"]]},{"id":"83c847e0.93fb68","type":"change","z":"217cab7.d842f54","name":"create msg.lat etc","rules":[{"t":"set","p":"LAT","pt":"msg","to":"payload.updates.values.value.latitude","tot":"jsonata"},{"t":"set","p":"LONG","pt":"msg","to":"payload.updates.values.value.longitude","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":840,"y":140,"wires":[["2500e5fa.df695a"]]},{"id":"2500e5fa.df695a","type":"function","z":"217cab7.d842f54","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":1050,"y":140,"wires":[["ca9e1453.8d6998"]]},{"id":"a2a899ed.40a7f8","type":"json","z":"217cab7.d842f54","name":"","pretty":true,"x":430,"y":140,"wires":[["5991e9f6.61f1f8"]]},{"id":"ca9e1453.8d6998","type":"worldmap","z":"217cab7.d842f54","name":"","lat":"","lon":"","zoom":"","layer":"Esri Satellite","cluster":"","maxage":"","usermenu":"hide","panit":"true","x":1210,"y":140,"wires":[]},{"id":"ba09b412.2c30e8","type":"ui_template","z":"217cab7.d842f54","group":"96385f21.bb593","name":"world-map","order":4,"width":"6","height":"6","format":"<iframe width=\"300\" height=\"300\" src=\"http://localhost:1880/worldmap\" frameborder=\"0\" allowfullscreen></iframe>","storeOutMessages":true,"fwdInMessages":true,"x":1150,"y":200,"wires":[[]]},{"id":"96385f21.bb593","type":"ui_group","z":"","name":"World","tab":"bdb776e4.17a1e8","order":5,"disp":true,"width":"6"},{"id":"bdb776e4.17a1e8","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]
here is the flow if anyone wants it..needs to be connected to...ws://localhost:3000/signalk/v1/stream
BIG thanks to PattyB..