feat: Refactoring climate zone.

This commit is contained in:
2025-03-03 15:52:34 -05:00
parent 8e0860af8e
commit 1727e9a905
6 changed files with 73 additions and 30 deletions

View File

@@ -1,33 +1,67 @@
public enum ClimateZone: String, CaseIterable, Codable, Equatable, Sendable {
// NOTE: Keep in this order.
// TODO: This should be renamed to ClimateZoneType.
case hotHumid
case moist
case dry
case marine
public enum ClimateZone {
public var zoneIdentifiers: [String] {
switch self {
case .dry:
return ["2B", "3B", "4B", "5B", "6B", "7B"]
case .hotHumid:
return ["1A", "2A"]
case .marine:
return ["3C", "4C"]
case .moist:
return ["3A", "4A", "5A", "6A", "7A"]
public enum ZoneType: String, CaseIterable, Codable, Equatable, Sendable {
// NOTE: Keep in this order.
case hotHumid
case moist
case dry
case marine
// FIX: Return ZoneIdentifiers.
public var zoneIdentifiers: [String] {
switch self {
case .dry:
return ["2B", "3B", "4B", "5B", "6B", "7B"]
case .hotHumid:
return ["1A", "2A"]
case .marine:
return ["3C", "4C"]
case .moist:
return ["3A", "4A", "5A", "6A", "7A"]
}
}
}
public var cfmPerTon: Int {
switch self {
case .dry: return 450
case .hotHumid: return 350
case .marine, .moist: return 400
public var cfmPerTon: Int {
switch self {
case .dry: return 450
case .hotHumid: return 350
case .marine, .moist: return 400
}
}
}
public var label: String {
return "\(self == .hotHumid ? "Hot Humid" : rawValue.capitalized) (\(zoneIdentifiers.joined(separator: ", ")))"
public var label: String {
return "\(self == .hotHumid ? "Hot Humid" : rawValue.capitalized) (\(zoneIdentifiers.joined(separator: ", ")))"
}
/// Represents climate zone identifiers.
public enum ZoneIdentifier: String, CaseIterable, Codable, Equatable, Sendable {
// A zones (hotHumid)
case oneA = "1A"
case twoA = "2A"
// A zones (moist)
case threeA = "3A"
case fourA = "4A"
case fiveA = "5A"
case sixA = "6A"
case sevenA = "7A"
// B zones (dry)
case twoB = "2B"
case threeB = "3B"
case fourB = "4B"
case fiveB = "5B"
case sixB = "6B"
case sevenB = "7B"
// C zones (marine)
case threeC = "3C"
case fourC = "4C"
public var label: String { rawValue }
}
}
}

View File

@@ -16,14 +16,14 @@ public enum FilterPressureDrop {
public struct Basic: Codable, Equatable, Sendable {
public let systemSize: Double
public let climateZone: ClimateZone
public let climateZone: ClimateZone.ZoneType
public let filterType: FilterType
public let filterWidth: Double
public let filterHeight: Double
public init(
systemSize: Double,
climateZone: ClimateZone,
climateZone: ClimateZone.ZoneType,
filterType: FilterPressureDrop.FilterType,
filterWidth: Double,
filterHeight: Double

View File

@@ -255,7 +255,7 @@ public extension SiteRoute {
OneOf {
FormData {
Field("systemSize") { Double.parser() }
Field("climateZone") { ClimateZone.parser() }
Field("climateZone") { ClimateZone.ZoneType.parser() }
Field("filterType") { Routes.FilterPressureDrop.FilterType.parser() }
Field("filterWidth") { Double.parser() }
Field("filterHeight") { Double.parser() }