{"id":570,"date":"2019-09-16T14:31:35","date_gmt":"2019-09-16T14:31:35","guid":{"rendered":"http:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/?p=570"},"modified":"2019-09-16T14:31:35","modified_gmt":"2019-09-16T14:31:35","slug":"nam-tran-maquette","status":"publish","type":"post","link":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/nhtranngoc\/nam-tran-maquette\/","title":{"rendered":"Nam Tran &#8211; Maquette"},"content":{"rendered":"\n<p>This week, I worked on the software side of the Lightning Globe. The goal is to find out if the project is feasible and how would I go approaching it.<\/p>\n\n\n\n<p>First, I tracked down the source of the lightning data. Since <a href=\"https:\/\/www.lightningmaps.org\">Lightning Map<\/a>, does not offer any Application Programming Interface (API), that I could connect to, I had to find a different source. I stumbled upon the WWLLN (World Wide Lightning Location Network), which Lightning Map used data from. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"619\" src=\"http:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-23-1024x619.png\" alt=\"\" class=\"wp-image-571\" srcset=\"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-23-1024x619.png 1024w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-23-800x483.png 800w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-23-768x464.png 768w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-23-497x300.png 497w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-23.png 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>After a bit more digging I came upon the JSON data that the website is using:  <a href=\"http:\/\/wwlln.net\/new\/map\/data\/current.json\">http:\/\/wwlln.net\/new\/map\/data\/current.json<\/a>. The data is a collection of the most recent 5000 lightning strikes, along with latitudes, longitudes, and timestamp. A quick calculation shows that on average this file alone could provide 13 minutes of lightning data!<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"372\" height=\"1024\" src=\"http:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-24-372x1024.png\" alt=\"\" class=\"wp-image-572\" srcset=\"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-24-372x1024.png 372w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-24-109x300.png 109w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-24.png 373w\" sizes=\"auto, (max-width: 372px) 100vw, 372px\" \/><\/figure>\n\n\n\n<p>I chose NodeJS to process the data &#8211; mostly because I am familiar with it, and Javascript offers an easy way to talk to LED strips via <a href=\"http:\/\/johnny-five.io\">Johnny-Five<\/a>, and my own previously written code. I will need to turn this big block of text into events that can be sent off to the LED strip.<\/p>\n\n\n\n<p>I quickly ran into my first problem, since JSON data is unordered, which means that the moment I import the data in Javascript, it will reorder itself and the lightning timeframe will be out of sorts. To remedy this I had to do some data finagling by splicing each entry, then importing them as an array.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"206\" src=\"http:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-25.png\" alt=\"\" class=\"wp-image-573\" srcset=\"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-25.png 644w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-25-600x192.png 600w\" sizes=\"auto, (max-width: 644px) 100vw, 644px\" \/><\/figure>\n\n\n\n<p>Next up is to convert Longitudes and Latitudes on to a 2D surface. Since the data used Google Maps API, they would have to follow something called Spherical Mercator Projection. This involves some complex calculations &#8211; thankfully our good friend @mapbox wrote a Javascript library for it.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/upload.wikimedia.org\/wikipedia\/commons\/thumb\/7\/73\/Mercator_projection_Square.JPG\/1024px-Mercator_projection_Square.JPG\" alt=\"\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"247\" src=\"http:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-26.png\" alt=\"\" class=\"wp-image-574\" srcset=\"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-26.png 849w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-26-800x233.png 800w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-26-768x223.png 768w, https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/image-26-600x175.png 600w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><\/figure>\n\n\n\n<p>With everything put together, the code outputs a 17&#215;17 matrix, with &#8220;-&#8221; for no lightnings, and &#8220;X&#8221; for lightning strikes.<\/p>\n\n\n\n<p>Next I will try to translate software data into flashing lights!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week, I worked on the software side of the Lightning Globe. The goal is to find out if the project is feasible and how would I go approaching it. First, I tracked down the source of the lightning data. Since Lightning Map, does not offer any Application Programming Interface (API), that I could connect&#8230; <\/p>\n<div class=\"link-more\"><a href=\"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/nhtranngoc\/nam-tran-maquette\/\">Read More<\/a><\/div>\n","protected":false},"author":134,"featured_media":575,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"cybocfi_hide_featured_image":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-570","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"jetpack_featured_media_url":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-content\/uploads\/sites\/11\/2019\/09\/1024px-Mercator_projection_Square.jpg","_links":{"self":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/posts\/570","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/users\/134"}],"replies":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/comments?post=570"}],"version-history":[{"count":1,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/posts\/570\/revisions"}],"predecessor-version":[{"id":576,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/posts\/570\/revisions\/576"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/media\/575"}],"wp:attachment":[{"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/media?parent=570"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/categories?post=570"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.joshuarosenstock.com\/teaching\/lightart-a19\/wp-json\/wp\/v2\/tags?post=570"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}