home, pet projects, contact me

This small project was inspired during weekend trip planning. I was looking where to go with my friends and ended up with 30 potential locations. One of the main factor was weather. I spent an evening filling the table with temperature and rain chance for every location and ended up with this (don't be scared, all temperature is in °C):

It was very useful data, but it took unacceptable amount of manual work and time to fill it. Oh, and yeah, the "sweetest" part is that in a few weeks this data became outdated and you would need to redo all work to refill the table for every trip. For every trip. For. Every. Trip.

So I decided to simplify my life and create a small program which will grab weather for all specified locations for me. I spent some time looking for an API which I could use and found few good options. And ended up with following flow:

  1. Get place name
  2. Convert provided place name to latitude/longitude coordinates
  3. Using place coords get weather office id
  4. Using weather office id get forecast for the next days
  5. Remove all data which does not match desired travel date
  6. PROFIT!

After some testing I realized that I can improve the logic a little bit, so I backed few small features to improve final data, processing speed, etc. For example I don't need to include temperature/rain chance during deep night and early morning because I will sleep (hopefully inside) during this time and weather is irrelevant. I also realized that I can reduce number of API calls from 3 to 1 by caching some data, So I added caching using SQLite which improved speed, on average response from API provider was way slower than SQLite.

So new flow will be this:

  1. Get place name
  2. Is placed cached? If so, then jump to step 5, otherwise continue
  3. Convert provided place name to latitude/longitude coordinates
  4. Using place coords get weather office id
  5. Using weather office id get forecast for the next days
  6. Remove all data which does not match desired travel date
  7. filter output data!
  8. PROFIT!

Output will have place name (in current output it's airport identifier, want to a hook it up to plane tickets API in the future), temperature, rain chance and sky cover percentage for the next weekend, averaged between Saturday and Sunday. You can download sample .csv formatted table generated by the program here