How to update Worldmap with a high frequency data rate

Hi,

I'm reading a ".txt" file containing Latitude,Longitude and trying to update the worldmap according to that location variation.

sample :
7.476141,80.386292
7.475736,80.386968
7.475385,80.387558
7.475034,80.388154
7.474688,80.388765
7.474343,80.389393
7.473949,80.390031

Object is updating correctly according to the Long,Lat variation as below. In this case I have used 54 such different locations along a route to test the icon movement. (Later I'm going to extend this to visualize more location changes with the GPS module data.)

Following are the difficulties occurred while doing this.

  • No out put in the world map, unable to visualize the movement of the icon. - Sometimes only the last location (54th) is visible but not the movement. :disappointed_relieved:
    What i experienced was a map like below. All the time. When I zoom out I found the last location tag.

  • I used a 5s delay to check whether the icon movement is visible. - But seems like it is also not functioning correctly.

My Flow :

[{"id":"bc2576c2.a41208","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d2ee874c.a45078","type":"file in","z":"bc2576c2.a41208","name":"Vehicle1","filename":"/home/pi/Desktop/Project/Node-red/Vehicle1_Kurunegala-Malwapitiya.txt","format":"lines","chunk":false,"sendError":false,"x":160,"y":100,"wires":[["80c229d8.3b8da8","79f04071.17717"]]},{"id":"100cd7a9.b4aae8","type":"inject","z":"bc2576c2.a41208","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":90,"y":40,"wires":[["d2ee874c.a45078"]]},{"id":"9fc0b2f7.ea4aa","type":"debug","z":"bc2576c2.a41208","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":160,"wires":[]},{"id":"80c229d8.3b8da8","type":"function","z":"bc2576c2.a41208","name":"Split > Update object","func":"var lat1 = msg.payload.split(',')[0];\n//node.warn(lon1)\nvar lon1= msg.payload.split(',')[1];\n//node.warn(lat1)\n\nvar lat = lat1;\nvar lon = lon1;\n\nvar v1 = {\n    lon:lon, \n    lat:lat,\n    name:\"Vehicle\", \n    icon:\"tag\", \n};\n\nmsg.payload= v1;\n\nreturn msg;\n","outputs":1,"noerr":0,"x":300,"y":40,"wires":[["22d0f116.28be7e"]]},{"id":"79f04071.17717","type":"debug","z":"bc2576c2.a41208","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":290,"y":160,"wires":[]},{"id":"de9bc0f4.d8209","type":"worldmap","z":"bc2576c2.a41208","name":"","lat":"","lon":"","zoom":"","layer":"OSM","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","path":"/worldmap","x":560,"y":40,"wires":[]},{"id":"22d0f116.28be7e","type":"delay","z":"bc2576c2.a41208","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":460,"y":100,"wires":[["de9bc0f4.d8209","9fc0b2f7.ea4aa"]]},{"id":"63766a75.cbad14","type":"inject","z":"bc2576c2.a41208","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":130,"y":220,"wires":[["844bd00a.c9147"]]},{"id":"10c6e44b.c9cfac","type":"ui_template","z":"bc2576c2.a41208","group":"3ee0e7a8.7bba88","name":"","order":2,"width":"10","height":"9","format":"<div ng-bind-html=\"msg.payload | trusted\"></div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":460,"y":220,"wires":[[]]},{"id":"844bd00a.c9147","type":"template","z":"bc2576c2.a41208","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<iframe src=\"../worldmap\" height=450px width =500px ></iframe>","x":300,"y":220,"wires":[["10c6e44b.c9cfac"]]},{"id":"3ee0e7a8.7bba88","type":"ui_group","z":"","name":"Group 1","tab":"628cff0c.81de4","order":1,"disp":true,"width":"12","collapse":false},{"id":"628cff0c.81de4","type":"ui_tab","z":"","name":"Test Path","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

I'm kindly looking for any suggestions/directions about my flows mistakes or any wrong attempts.

Thank you in advance.

I suspect you may really want to use the delay in rate limit mode - so you can visualise a journey ? I also change the map to auto-pan - which will move the map to the location you want.

Here is my version - I had to change the file location.

[{"id":"83e31bdd.9af328","type":"file in","z":"8d555f56.212b5","name":"Vehicle1","filename":"/tmp/loc.txt","format":"lines","chunk":false,"sendError":false,"x":160,"y":100,"wires":[["34cb63c1.35736c","cd30066a.7421f8"]]},{"id":"1825a64b.98e15a","type":"inject","z":"8d555f56.212b5","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":90,"y":40,"wires":[["83e31bdd.9af328"]]},{"id":"ccdbb0ae.6da6","type":"debug","z":"8d555f56.212b5","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":160,"wires":[]},{"id":"34cb63c1.35736c","type":"function","z":"8d555f56.212b5","name":"Split > Update object","func":"var lat1 = msg.payload.split(',')[0];\n//node.warn(lon1)\nvar lon1= msg.payload.split(',')[1];\n//node.warn(lat1)\n\nvar lat = lat1;\nvar lon = lon1;\n\nvar v1 = {\n    lon:lon, \n    lat:lat,\n    name:\"Vehicle\", \n    icon:\"fa-car\"\n};\n\nmsg.payload= v1;\n\nreturn msg;\n","outputs":1,"noerr":0,"x":300,"y":40,"wires":[["9222f5b7.8820a8"]]},{"id":"cd30066a.7421f8","type":"debug","z":"8d555f56.212b5","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":290,"y":160,"wires":[]},{"id":"849ff6fb.453f38","type":"worldmap","z":"8d555f56.212b5","name":"","lat":"","lon":"","zoom":"","layer":"OSM","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"true","panlock":"false","zoomlock":"false","path":"/worldmap","x":560,"y":40,"wires":[]},{"id":"9222f5b7.8820a8","type":"delay","z":"8d555f56.212b5","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":480,"y":100,"wires":[["849ff6fb.453f38","ccdbb0ae.6da6"]]},{"id":"8a7ad53a.053f38","type":"inject","z":"8d555f56.212b5","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":"","x":130,"y":220,"wires":[["bbfc12ad.213b6"]]},{"id":"67e82aff.f824c4","type":"ui_template","z":"8d555f56.212b5","group":"d3f266ef.82e098","name":"","order":2,"width":"10","height":"9","format":"<div ng-bind-html=\"msg.payload | trusted\"></div>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":460,"y":220,"wires":[[]]},{"id":"bbfc12ad.213b6","type":"template","z":"8d555f56.212b5","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<iframe src=\"../worldmap\" height=450px width =500px ></iframe>","x":300,"y":220,"wires":[["67e82aff.f824c4"]]},{"id":"d3f266ef.82e098","type":"ui_group","z":"","name":"Group 1","tab":"be9e2089.01d44","order":1,"disp":true,"width":"12","collapse":false},{"id":"be9e2089.01d44","type":"ui_tab","z":"","name":"Test Path","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
1 Like

Hello @dceejay ,

Yes you are correct the purpose of the delay element is to visualize the journey. Aaand I understood the modification provided and yes, now it is working. :star_struck:
Thank you very much for your help and guidance. :relaxed:

Thank you.