49 lines
1.6 KiB
Swift
49 lines
1.6 KiB
Swift
//
|
|
// EQNMapAnnotationShakemap.swift
|
|
// Earthquake Network
|
|
//
|
|
// Created by Andrea Busi on 27/02/25.
|
|
// Copyright © 2025 Earthquake Network. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import MapKit
|
|
|
|
class EQNMapAnnotationShakemap: NSObject, MKAnnotation {
|
|
let coordinate: CLLocationCoordinate2D
|
|
let shakemap: EQNShakemap
|
|
var intensityColor: UIColor?
|
|
var intensityTextColor: UIColor?
|
|
|
|
let title: String?
|
|
let subtitle: String? = nil
|
|
|
|
|
|
init(
|
|
coordinate: CLLocationCoordinate2D,
|
|
shakemap: EQNShakemap
|
|
) {
|
|
self.coordinate = coordinate
|
|
self.shakemap = shakemap
|
|
self.title = Self.title(for: shakemap.intensity)
|
|
}
|
|
|
|
// MARK: - Private
|
|
|
|
private static func title(for intensity: Float) -> String {
|
|
return switch intensity {
|
|
case 0..<2.5: NSLocalizedString("mercalli_II", comment: "")
|
|
case 2.5..<3.5: NSLocalizedString("mercalli_III", comment: "")
|
|
case 3.5..<4.5: NSLocalizedString("mercalli_IV", comment: "")
|
|
case 4.5..<5.5: NSLocalizedString("mercalli_V", comment: "")
|
|
case 5.5..<6.5: NSLocalizedString("mercalli_VI", comment: "")
|
|
case 6.5..<7.5: NSLocalizedString("mercalli_VII", comment: "")
|
|
case 7.5..<8.5: NSLocalizedString("mercalli_VIII", comment: "")
|
|
case 8.5..<9.5: NSLocalizedString("mercalli_IX", comment: "")
|
|
case 9.5..<10.5: NSLocalizedString("mercalli_X", comment: "")
|
|
case 10.5..<11.5: NSLocalizedString("mercalli_XI", comment: "")
|
|
default: NSLocalizedString("mercalli_XII", comment: "")
|
|
}
|
|
}
|
|
}
|