Hacking Oregon Eclipse — story of a side project
Tags: vue, eclipse, node, webdev
Published: 2017-11-22 22:08:19

---
title: "Hacking Oregon Eclipse — story of a side project"
published: true
tags: vuejs,eclipse,nodejs,web-development
canonical_url: https://codeburst.io/hacking-oregon-eclipse-story-of-a-side-project-e0bf779da730
---

![](https://thepracticaldev.s3.amazonaws.com/i/l57s3450czcdiltf09vf.gif)<figcaption>Screencast of eclipse project</figcaption>

Lately, I have been curious about the new “in vogue” Javascript framework: [Vue.js](http://vuejs.org) (it’s a pleonasm, I know). I just needed a side-project idea to discover this new shiny toy everybody is talking&nbsp;about.

The idea of a project came while one night in a bar while sipping a good IPA with my fellow Advocate [Josh](http://twitter.com/dzello). We were talking about the coming Solar Eclipse in the US, and where to go to see it.   
Sadly, I did not personally plan to enjoy one of the many [hippie gathering](http://oregoneclipse2017.com/)happening in Oregon the week of the eclipse. But I am sure I would be able to enjoy this rare phenomenon close to where I live in California.

With some basic googling I found the official [NASA Website](https://eclipse2017.nasa.gov) that is listing all the events organized in the country. Good news: Astronomers, Science Museums, and NASA facilities will be holding tons of event for everybody to enjoy the&nbsp;eclipse.

![](https://cdn-images-1.medium.com/max/749/1*EHYetAr3Yx_nmbf1682jRQ.png)<figcaption>Map of events displayed on NASA website</figcaption>

Unfortunately, the user experience on this NASA website was not super exciting. You would have to point and zoom on a Map to find the different events around you. I thought there should be a better and nicer way: that’s why I’ve built&nbsp;[🌚🌞.ws](https://%F0%9F%8C%9A%F0%9F%8C%9E.ws).

![](https://cdn-images-1.medium.com/max/1024/1*RHLAkdTbworb0QavR_eLTA.png)<figcaption>The <a href="https://%F0%9F%8C%9A%F0%9F%8C%9E.ws">🌚🌞.ws</a> experience</figcaption>

### Provide a better search experience 🔍🗓

My primary goal was to offer a pleasant search experience, where people would put their location and the app will show events nearby.

When it comes to search, my tool of choice is [Algolia](http://Algolia.com). They offer APIs and SDKs to provide intuitive search in websites like [Twitch](http://twitch.tv), [Product Hunt](http://producthunt.com) or [Hacker&nbsp;News](http://news.ycombinator.com).

To be able to use their solution I needed to get all the events data. By checking the source code of NASA website, I’ve found the Google spreadsheet they were using to populate events on the map. I just had to download it and turn this file into JSON.

I created an events index on [Algolia](http://algolia.com), where I would store all the events. To be able to perform a geo-based search I renamed the location field to \_geoloc, and that was it. I could already search for events around a specific point on the globe with its latitude and longitude coordinates.

Then, instead of having a field where people will freely put their address, I have used [Algolia Places](http://community.algolia.com/places/). It’s a text field with auto completion on addresses or city names. This tool uses Open Street Map data so it’s pretty accurate.

![](https://cdn-images-1.medium.com/max/1024/1*0mEqCkEnJRzzlWvZE-q_hA.gif)<figcaption>Algolia Places experience</figcaption>

Using this tool, users could start typing Saand the tool will suggest San Francisco. On a callback function the app will get all the info about this location, like it’s latitude and longitude, as well as its state or its postal code.

That’s how I got my first MVP running in few hours. Catching the change event on the input field, receiving the data about the location, perform a geo search on the event index and display the results.

### Get local Eclipse circumstances 🌒🌘

I was pretty happy about my MVP, but I wanted to add more information regarding local circumstances of the eclipse. Wouldn’t be cool to know how long it will last? Or when will be the maximum?

Naively, I thought that the eclipse was happening everywhere at the same time. So I just had to take the date and convert it to local time zone.

{% youtube xoMgnJDXd3k %}

Looks like I forgot my basic physics knowledge…

The Moon and the Earth are both moving at the same time, so the shadow of the Moon on Earth is also moving.

Check this animation to visualize it&nbsp;better:

{% tweet 889187888797286401 %}

So I had to find a way to get all those local circumstances as I could not guess them.

Well, if I am being 100% honest with you… I could… Through my research, I’ve learned about the [Besselian elements](https://en.wikipedia.org/wiki/Besselian_elements). With some calculations, you can predict all the steps of an eclipse on any point on Earth. It sounds even more crazy when you realize that it was found in 1820 and that other civilizations have used similar techniques thousands of years ago.

The only documents I’ve found were full of endless equations, and I had no faith to deal with them in Javascript…

I finally discovered an API from the [US Naval Observatory](http://aa.usno.navy.mil/data/docs/Eclipse2017.php) that would do that for me. This API is giving back the timing for the different phases of the eclipse as well as the magnitude, the sun azimuth, and some angles.

Once again my naively believed that with all this data, I had enough things to draw a beautiful visualization of the Moon shadow on the Sun.

<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl3978mq7x6nmcMr1m%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl3978mq7x6nmcMr1m%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl3978mq7x6nmcMr1m%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="242" frameborder="0" scrolling="no"><a href="https://medium.com/media/796beafd8fbafbb2d36171c22050f269/href">https://medium.com/media/796beafd8fbafbb2d36171c22050f269/href</a></iframe>

I tried during two days to find the right way of doing it. I used all the trigonometry I remembered from high school. My dream were full of crazy calculations. After many trials I could not get the results other websites were showing. I had to give up&nbsp;😩.

> If anybody has a clue, I would love to try and document a walk through on how to display an eclipse in SVG/CSS depending on latitude, longitude.  
> At the moment, visualizations are coming from [Timeanddate](http://timeanddate.com/eclipse/in/usa/).
### Finding a domain name&nbsp;💻🔗

You can easily bet that all the nice domains for this particular events are squatted by people with business minds, giving you little information in the middle of many popup ads.

I tried variations around eclipse, events,US ; but I did not like anything…

Until a few days ago when [Domainji](https://www.producthunt.com/posts/domainoji) got featured on Product Hunt.  
That was it: I had to get an emoji domain!&nbsp;🎉

I’ve learned a lot about [punny codes](https://www.punycoder.com/), and decided to buy the simple[🌚🌞.ws](http://%F0%9F%8C%9A%F0%9F%8C%9E.ws) on&nbsp;[i❤.ws](https://t.co/cE1K2b3ef2).

> Do you see how the Moon is looking at the Sun with appetite?  
> This is what’s happening during an eclipse.

Emoji domains are a pain when it comes to open graph tags. For example, Facebook OpenGraph debugger doesn’t recognize them as valid URLs. I had some fun times trying to debug this part of the website.

### Vue experience👨‍💻👍

You remember I’ve started this post talking about [Vue](https://vuejs.org)?  
Yeah, so what about it?

To get started I read [Matthias Hager’s](http://matthiashager.com/complete-vuejs-application-tutorial) tutorial, which gave me a pretty good base on how things were working. It was intuitive for the use case I had.  
I did not cut my app into components, until I was sure that everything was working together.  
I was happy to find a lot of resources and existing components like [Places](https://github.com/Gomah/vue-places), [Tooltip](https://github.com/vue-bulma/tooltip) or [Prerender](https://www.npmjs.com/package/prerender-spa-plugin) (for opengraph tags). And I also got to discover [Bulma CSS](http://bulma.io) which is delightful to use compared to Bootstrap.

You can find the code of the project [here](https://github.com/picsoung/eclipse2017)&nbsp;: so if you have any comment on how to make it more “ **Vuesque** ” please let me know.

I hope you enjoyed this hack, feel free to through feedback and feature request.

Please enjoy the Eclipse safely!

* * *