Stabilize beta release with warning cleanup and edge-case fixes
This commit is contained in:
@@ -128,19 +128,14 @@ actor EVChargingService {
|
||||
let chargerType = detectChargerType(from: name)
|
||||
let estimatedChargeTime = estimateChargeTime(for: chargerType)
|
||||
|
||||
var address: String? = nil
|
||||
if let placemark = item.placemark as MKPlacemark? {
|
||||
var components: [String] = []
|
||||
if let city = placemark.locality { components.append(city) }
|
||||
if let state = placemark.administrativeArea { components.append(state) }
|
||||
address = components.isEmpty ? nil : components.joined(separator: ", ")
|
||||
}
|
||||
let address = formattedAddress(for: item)
|
||||
let coordinate = coordinate(for: item)
|
||||
|
||||
return EVChargingStop(
|
||||
name: name,
|
||||
location: LocationInput(
|
||||
name: name,
|
||||
coordinate: item.placemark.coordinate,
|
||||
coordinate: coordinate,
|
||||
address: address
|
||||
),
|
||||
chargerType: chargerType,
|
||||
@@ -148,6 +143,20 @@ actor EVChargingService {
|
||||
)
|
||||
}
|
||||
|
||||
private func formattedAddress(for item: MKMapItem) -> String? {
|
||||
if let cityContext = item.addressRepresentations?.cityWithContext, !cityContext.isEmpty {
|
||||
return cityContext
|
||||
}
|
||||
if let shortAddress = item.address?.shortAddress, !shortAddress.isEmpty {
|
||||
return shortAddress
|
||||
}
|
||||
return item.address?.fullAddress
|
||||
}
|
||||
|
||||
private func coordinate(for item: MKMapItem) -> CLLocationCoordinate2D {
|
||||
item.location.coordinate
|
||||
}
|
||||
|
||||
/// Detect charger type from name using heuristics
|
||||
private func detectChargerType(from name: String) -> ChargerType {
|
||||
let lowercased = name.lowercased()
|
||||
|
||||
Reference in New Issue
Block a user