bitvijays / AirPollutionDataPlatform

Platform for air pollution
0 stars 2 forks source link

Color in View All Sensor | Click on sensor #57

Open bitvijays opened 3 years ago

bitvijays commented 3 years ago

In map.js file there's a function processAllResult process each records and calls buildMarkPopRecord where each marker is processed. So, in the buildMarkPopRecord, you should be able to figure out the color of the marker.

Now, if we see

We can get the AQI values like below (hopefully), haven't tested it

const eu_aqi = JSON.parse($("#eu_aqi").text());

Now, It seems that there are two ways to find the color based on the value of the either PM2.5, PM10, or NO2.

There are two functions

findColorFeature

which takes input as

properties = {pm25: 6.82, pm10: 7.55}, aqi = (5) [{…}, {…}, {…}, {…}, {…}

and outputs the color as mentioned in line 792

return aqi[0].index_levels[colorValue].color;

If you notice, it always sends back the color for the PM2.5 value, which should be displayed

#50f0e6

getAQIValue

which takes three values as input

e.g. (pm2.5, 10.0, aqi)

which outputs an array

0: "Good"
1: 0
2: "#50f0e6"

So, what I would suggest is

in the buildMarkPopRecord ,

check what pollutant value is available (PM2.5, PM10, NO2, NO, NOx etc) in that priority. If PM2.5 is available good, if not check PM10, If not NO2, if not NO)

Based on what is available , call the get AQIValue function and display the color of it.

We give preference to PM2.5.

Feel free to get on call with me.. I will probably explain it better on call.

Debug the code a bit and it would help you to understand.