From 09f769c7a98c44d4877d8bca7fed63f1191c3027 Mon Sep 17 00:00:00 2001 From: Darragh Rogan Date: Tue, 9 Mar 2021 21:28:29 +0000 Subject: [PATCH] fixed bug on ClimaCell primary pollutant added solarghi on ClimaCell dataloader --- .../xcdebugger/Breakpoints_v2.xcbkptlist | 8 ++--- .../xcschemes/xcschememanagement.plist | 4 +-- Miasma/DataLoaderClimaCell.swift | 11 ++++--- Miasma/Menu.swift | 32 +++++++++---------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Miasma.xcodeproj/xcuserdata/darragh.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/Miasma.xcodeproj/xcuserdata/darragh.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 7e1fe5c..8d984e8 100644 --- a/Miasma.xcodeproj/xcuserdata/darragh.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/Miasma.xcodeproj/xcuserdata/darragh.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -62,8 +62,8 @@ filePath = "Miasma/DataLoaderClimaCell.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "87" - endingLineNumber = "87" + startingLineNumber = "88" + endingLineNumber = "88" landmarkName = "loadClimaCellData(lat:lon:)" landmarkType = "7"> @@ -78,8 +78,8 @@ filePath = "Miasma/DataLoaderClimaCell.swift" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "89" - endingLineNumber = "89" + startingLineNumber = "90" + endingLineNumber = "90" landmarkName = "loadClimaCellData(lat:lon:)" landmarkType = "7"> diff --git a/Miasma.xcodeproj/xcuserdata/darragh.xcuserdatad/xcschemes/xcschememanagement.plist b/Miasma.xcodeproj/xcuserdata/darragh.xcuserdatad/xcschemes/xcschememanagement.plist index 8c5ed3f..4b9c173 100644 --- a/Miasma.xcodeproj/xcuserdata/darragh.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Miasma.xcodeproj/xcuserdata/darragh.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,12 +7,12 @@ Miasma WidgetExtension.xcscheme_^#shared#^_ orderHint - 8 + 10 Miasma iOS.xcscheme_^#shared#^_ orderHint - 10 + 8 Miasma.xcscheme_^#shared#^_ diff --git a/Miasma/DataLoaderClimaCell.swift b/Miasma/DataLoaderClimaCell.swift index 6f32706..0b5327d 100644 --- a/Miasma/DataLoaderClimaCell.swift +++ b/Miasma/DataLoaderClimaCell.swift @@ -22,14 +22,14 @@ struct DataClass: Codable { // MARK: - Timeline struct Timeline: Codable { -// var timestep: String? -// var startTime, endTime: Date? + // var timestep: String? + // var startTime, endTime: Date? var intervals: [Interval]? } // MARK: - Interval struct Interval: Codable { -// var startTime: Date? + // var startTime: Date? var values: Values? } @@ -40,6 +40,7 @@ struct Values: Codable { var weatherCode: Int? var windDirection, windSpeed: Double? var epaIndex, epaPrimaryPollutant: Int? + var solarGHI: Double? } @@ -60,7 +61,7 @@ public class DataLoaderClimaCell { ] let request = NSMutableURLRequest(url: NSURL(string: - "https://data.climacell.co/v4/timelines?location=\(lat),\(lon)&fields=treeIndex,grassIndex,weedIndex,temperatureApparent,weatherCode,windDirection,windSpeed,epaIndex,epaPrimaryPollutant&apikey=\(APIKeyClimaCellV4)")! as URL, + "https://data.climacell.co/v4/timelines?location=\(lat),\(lon)&fields=treeIndex,grassIndex,weedIndex,temperatureApparent,weatherCode,windDirection,windSpeed,epaIndex,epaPrimaryPollutant,solarGHI&apikey=\(APIKeyClimaCellV4)")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) @@ -78,7 +79,7 @@ public class DataLoaderClimaCell { let httpResponse = response as? HTTPURLResponse print("Received from the ClimaCell API") if let data = data, - let urlContent = NSString(data: data, encoding: String.Encoding.ascii.rawValue) { + let urlContent = NSString(data: data, encoding: String.Encoding.ascii.rawValue) { print(urlContent) } else { print("error with printing string encoded data") diff --git a/Miasma/Menu.swift b/Miasma/Menu.swift index b4a63a6..28afc76 100644 --- a/Miasma/Menu.swift +++ b/Miasma/Menu.swift @@ -741,15 +741,15 @@ class menuFunctions: NSObject { switch ClimaCellPrimaryPollutant { case _ where ClimaCellPrimaryPollutant == 0: ClimaCellPrimaryPollutantText = "PM₂.₅" - case _ where ClimaCellWeatherCode == 1: + case _ where ClimaCellPrimaryPollutant == 1: ClimaCellPrimaryPollutantText = "PM₁₀" - case _ where ClimaCellWeatherCode == 2: + case _ where ClimaCellPrimaryPollutant == 2: ClimaCellPrimaryPollutantText = "O₃" - case _ where ClimaCellWeatherCode == 3: + case _ where ClimaCellPrimaryPollutant == 3: ClimaCellPrimaryPollutantText = "NO₂" - case _ where ClimaCellWeatherCode == 4: + case _ where ClimaCellPrimaryPollutant == 4: ClimaCellPrimaryPollutantText = "CO" - case _ where ClimaCellWeatherCode == 5: + case _ where ClimaCellPrimaryPollutant == 5: ClimaCellPrimaryPollutantText = "SO₂" default: ClimaCellPrimaryPollutantText = "Unknown" @@ -1182,15 +1182,15 @@ class menuFunctions: NSObject { switch ClimaCellPrimaryPollutant { case _ where ClimaCellPrimaryPollutant == 0: ClimaCellPrimaryPollutantText = "PM₂.₅" - case _ where ClimaCellWeatherCode == 1: + case _ where ClimaCellPrimaryPollutant == 1: ClimaCellPrimaryPollutantText = "PM₁₀" - case _ where ClimaCellWeatherCode == 2: + case _ where ClimaCellPrimaryPollutant == 2: ClimaCellPrimaryPollutantText = "O₃" - case _ where ClimaCellWeatherCode == 3: + case _ where ClimaCellPrimaryPollutant == 3: ClimaCellPrimaryPollutantText = "NO₂" - case _ where ClimaCellWeatherCode == 4: + case _ where ClimaCellPrimaryPollutant == 4: ClimaCellPrimaryPollutantText = "CO" - case _ where ClimaCellWeatherCode == 5: + case _ where ClimaCellPrimaryPollutant == 5: ClimaCellPrimaryPollutantText = "SO₂" default: ClimaCellPrimaryPollutantText = "Unknown" @@ -1496,7 +1496,7 @@ class menuFunctions: NSObject { self.smartCitizenPM2_5.title = "☁️: \(String(aQI_CalculatedRounded)) US EPA AQI PM₂.₅ / \(String(smartCitizenData.data?.sensors?[8].value ?? 0)) μg/m³ PM₂.₅ (Current) \(pM2_5ColourButton)" - self.smartCitizenOtherPollutants.title = "☁️: VOC \(String(smartCitizenData.data?.sensors?[0].value ?? 0))\(String(smartCitizenData.data?.sensors?[0].unit ?? "0")) / CO2 \(String(smartCitizenData.data?.sensors?[1].value ?? 0))\(String(smartCitizenData.data?.sensors?[1].unit ?? "0"))" + self.smartCitizenOtherPollutants.title = "☁️: VOC \(String(smartCitizenData.data?.sensors?[0].value ?? 0))\(String(smartCitizenData.data?.sensors?[0].unit ?? "0")) / CO₂ \(String(smartCitizenData.data?.sensors?[1].value ?? 0))\(String(smartCitizenData.data?.sensors?[1].unit ?? "0"))" self.smartCitizenTemperature.title = "🌡: \(String(smartCitizenData.data?.sensors?[10].value ?? 0))℃" @@ -1680,15 +1680,15 @@ class menuFunctions: NSObject { switch ClimaCellPrimaryPollutant { case _ where ClimaCellPrimaryPollutant == 0: ClimaCellPrimaryPollutantText = "PM₂.₅" - case _ where ClimaCellWeatherCode == 1: + case _ where ClimaCellPrimaryPollutant == 1: ClimaCellPrimaryPollutantText = "PM₁₀" - case _ where ClimaCellWeatherCode == 2: + case _ where ClimaCellPrimaryPollutant == 2: ClimaCellPrimaryPollutantText = "O₃" - case _ where ClimaCellWeatherCode == 3: + case _ where ClimaCellPrimaryPollutant == 3: ClimaCellPrimaryPollutantText = "NO₂" - case _ where ClimaCellWeatherCode == 4: + case _ where ClimaCellPrimaryPollutant == 4: ClimaCellPrimaryPollutantText = "CO" - case _ where ClimaCellWeatherCode == 5: + case _ where ClimaCellPrimaryPollutant == 5: ClimaCellPrimaryPollutantText = "SO₂" default: ClimaCellPrimaryPollutantText = "Unknown"