From 373010be532616b89f4c3e9fef0a972f7cf539f5 Mon Sep 17 00:00:00 2001 From: marwolaethblack Date: Thu, 30 Nov 2017 12:34:56 +0100 Subject: aqi --- src/AppBundle/Utils/Aqi.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/AppBundle/Utils/Aqi.php (limited to 'src/AppBundle/Utils/Aqi.php') diff --git a/src/AppBundle/Utils/Aqi.php b/src/AppBundle/Utils/Aqi.php new file mode 100644 index 0000000..6451c77 --- /dev/null +++ b/src/AppBundle/Utils/Aqi.php @@ -0,0 +1,43 @@ +{$gasName} ->{'breakpoints'}; + foreach ($arr as $index => $value) { + if ($value < $concentration && $table->{$gasName}->{'breakpoints'}[$index + 1] > $concentration) { + $bpLow = $value; + $bpLowIndex = $index; + } + + if ($value > $concentration && $table->{$gasName}->{'breakpoints'}[$index - 1] < $concentration) { + $bpHi = $value; + $bpHiIndex = $index; + } + + }; + + + + $airQualityIndex = (($table->{$gasName}->{'aq'}[$bpHiIndex] - $table->{$gasName}->{'aq'}[$bpLowIndex]) / ($bpHi - $bpLow)) * ($concentration - $bpLow) + $table->{$gasName}->{'aq'}[$bpLowIndex]; + + return $airQualityIndex; + + } +} + +?> \ No newline at end of file -- cgit v1.2.3