“Get out form smog” – looking for the purest air

Get out from smog – part VI

Today, my application show you where is the cleanest air within 100km from my current localization(Kraków).

First, I focus only on pollution dust – PM10. So, I modyficated class ParseStringToArray.

foreach (var item2 in valuesMeasurements)
{
    if (item2.Key == "PM10")
    {
        Dictionary<string, string> dictionary = new Dictionary<string, string>();
        dictionary.Add(item2.Key, item2.Value.ToString());
        valuesList.Add(dictionary);
    }
}

To not download unnecessary data.

Now, let’s see how my class to calculate where is the smallest dust pollution(PM10), around 100km from my place – looks.

public class CleanestAir : ICleanestAir
{
    public ParseJsonToList CalculateCleanestAir(List<ParseJsonToList> model)
    {
        ParseJsonToList mod=null;
        float LowestValue = 0f;
        foreach (var item in model)
        {
            float currentValue = 0f;
            foreach (var item2 in item.ListMeasurements)
            {
                currentValue = float.Parse(item2.FirstOrDefault().Value);
            }
            if(currentValue< LowestValue || LowestValue==0)
            {
                LowestValue = currentValue;
                mod = item;
            }
        }
        return mod;
    }
}

It takes a list of all measurement stations and return one measuring station where it’s the smalles dust pollution(PM10).

After launching the application, turned out that – within a 100km radius of me. Smalles dust pollution PM10 is in … Zakopane. It is caused by the mountain wind. What a suprise. 😉

This is caused by the mountain wind

getoutfromsmog

Link to the project- HERE

Leave a Reply

Your email address will not be published. Required fields are marked *