Gps dashboard for live location

Dont know if its that simple dave - its a strange format.

@steve i agree with your statement that math has to be applied onto the functional node.could u pls send us ur complete flow with maths function on it so that it will be easy for me to see the coordinates on map.Or modify the flow that i am sending so it gives the desired output.flows.json (5.1 KB)

The info was all there in your PDF - simple maths!

//example data  {lat: 5007.4965 , lon:838.1157 }

function floatToGPScoord(num) {
    var d = parseInt (num / 100)
    var m = parseInt(num) - (d*100)
    var s = num -  parseInt(num)
    var coord = d+((m+s)/60)
    return coord
}
msg.origPayload = {
    lat: msg.payload.lat,
    lon: msg.payload.lon
}
msg.payload.lat = floatToGPScoord(msg.payload.lat);
msg.payload.lon = floatToGPScoord(msg.payload.lon);
return msg;

test flow...

[{"id":"530d0a36.40cd24","type":"function","z":"6ca7c67d.98d848","name":"floatToGPScoord","func":"//example data  {lat: 5007.4965 , lon:838.1157 }\n\nfunction floatToGPScoord(num) {\n    var d = parseInt (num / 100)\n    var m = parseInt(num) - (d*100)\n    var s = num -  parseInt(num)\n    var coord = d+((m+s)/60)\n    return coord\n}\nmsg.origPayload = {\n    lat: msg.payload.lat,\n    lon: msg.payload.lon\n}\nmsg.payload.lat = floatToGPScoord(msg.payload.lat);\nmsg.payload.lon = floatToGPScoord(msg.payload.lon);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1270,"y":140,"wires":[["84cf7119.e970e"]]},{"id":"99b86a91.cc8f18","type":"inject","z":"6ca7c67d.98d848","name":"test data AgH5e5xFaIdRRA==","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"data\":\"AgH5e5xFaIdRRA==\"}","payloadType":"json","x":720,"y":80,"wires":[["88fc873f.c086c8"]]},{"id":"2bb51028.cbdab","type":"buffer-parser","z":"6ca7c67d.98d848","name":"","data":"payload.data","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"lat","offset":2,"length":1,"offsetbit":0,"scale":1,"mask":""},{"type":"floatle","name":"lon","offset":6,"length":1,"offsetbit":0,"scale":1,"mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"output","multipleResult":false,"setTopic":true,"x":1070,"y":140,"wires":[["530d0a36.40cd24","ed6ed918.3daa58"]]},{"id":"2057e639.f3a49a","type":"debug","z":"6ca7c67d.98d848","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1250,"y":200,"wires":[]},{"id":"363f26cc.7e8fda","type":"inject","z":"6ca7c67d.98d848","name":"click me","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":660,"y":140,"wires":[["2b6a66d1.86484a"]]},{"id":"2b6a66d1.86484a","type":"function","z":"6ca7c67d.98d848","name":"test data 02 01 F9 7B 9C 45 68 87 51 44","func":"msg.payload = { data: Buffer.from(\"0201F97B9C4568875144\", \"hex\") }\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":200,"wires":[["2bb51028.cbdab","29572a95.8942b6"]]},{"id":"88fc873f.c086c8","type":"base64","z":"6ca7c67d.98d848","name":"","action":"","property":"payload.data","x":940,"y":80,"wires":[["2bb51028.cbdab"]]},{"id":"29572a95.8942b6","type":"debug","z":"6ca7c67d.98d848","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":890,"y":240,"wires":[]},{"id":"84cf7119.e970e","type":"change","z":"6ca7c67d.98d848","name":"set name","rules":[{"t":"set","p":"payload.name","pt":"msg","to":"apple","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":200,"wires":[["2057e639.f3a49a"]]},{"id":"ed6ed918.3daa58","type":"debug","z":"6ca7c67d.98d848","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1250,"y":80,"wires":[]}]
2 Likes

Thanks Steve I am receiving this output but final step to plot them on world map.For which i added the world map node but it is not plotting the coordinates received in real time.Also would like to add some information this sensor is sending data every 3 minutes,also it is sending two packets of data as u can see in the sidebar or debug window.



I dont know much about this node - cant help.

Again, I dont know much about this node - cant help.

put a debug on the output of the MQTT node - are 2 MQTT payloads being sent (that will be the reason for 2 outputs) i.e. it is probably NOT a problem with this flow (i.e. the 2 message problem lies external to this flow)

1 Like

Anyways Thanks Steve :blush:

The values you show should now plot on the map
image
(though the second is a bit strange...)
The map needs to be connected (Yes - I can see the green dot so that's ok) - you may need to zoom/scroll the map to find it... or maybe set the map to auto-pan to the marker.

@dceejay Yes it is near my location now.but how can i add a marker to repsent it?

If I set the auto pan enabled
image
and zoom to 10
and then send in the data you had above (manually as I don't have your flow)

Then I get a map like

can u share ur flow please?

It's your flow ! I just added one inject as I don't have live data

[{"id":"36242835.3b7ff8","type":"inject","z":"e9b4dddd.70115","name":"{\"lat\":28.3196,\"lon\":76.96}","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"lat\":28.3196,\"lon\":76.96}","payloadType":"json","x":530,"y":920,"wires":[["84cf7119.e970e"]]}]
1 Like

Thank you dceejay.i had use case that i want to build regarding worldmap
1)If I want to track the path of a moving truck or forklifter as well as show its all history of data(latitude and longitude) along with other information(such as speed,fuel etc) from one particurlar date to another on a using table.wanted to know that what are other features that world map provides that one can use in his or her application on Node Red.

could u share your complete flow not just inject node ?as i wanted to see how it works

Why do you need the full flow? You have the full flow, it is your flow. All Dave has done is wired in an inject node. He has provided you the inject node and you can see in the screenshot exactly how it is wired in.

yes that would work.sorry :innocent:

The worldmap is just a map to display the location of objects. How you get and feed it data is up to you. - the README for the node tells you all the things it can do (as a map).

@dceejay instead of marker if we want to see the truck icon on world map and we also want lines on map showing path of truck moved for this scenario?
Is there any dashboard node which can show all data history?
Also checked readme of worldmap but nothing is written specific to this.Favicons would work but how to add the truck instead of marker.


The icons can be set as per the readme.
The recent history/path can be shown by using the worldmap tracks node.
But that will only show history for data that is received "live" - if you need it to save history over restarts and be queryable you will need to store it in a database and then retrieve it and send it to the map. That is not part of the worldmap node.

@dceejay suppose we want to store history in a database (sqlite,mongodb)etc and retreive from databse by use of apis to show history on a table then which node-red node can show databse history on a table?

The flows.nodered.org site has a load of nodes that talk to different databases.
(but you know that already as you have viewed all the starter videos that you have previously been pointed at haven't you :wink:

1 Like