refactor: Create an enum for pastquake intensities

This commit is contained in:
Andrea Busi
2021-03-13 17:04:21 +01:00
parent 6b6f189eda
commit 4ff2b75121
5 changed files with 14 additions and 6 deletions
@@ -102,7 +102,7 @@ class SegnalazioniMapViewController: EQNBaseMapViewController {
let vector_latitude = reports.map { $0.coordinate.coordinate.latitude }
let vector_longitude = reports.map { $0.coordinate.coordinate.longitude }
let vector_date = reports.map { $0.date }
let vector_state = reports.map { $0.magnitude }
let vector_state = reports.map { $0.intensity.rawValue }
let minutes: TimeInterval = filter.minutes
+7
View File
@@ -131,6 +131,13 @@ typedef NS_ENUM(NSInteger, EQNTipoMappa) {
EQNTipoMappaSegnalazioniUtenti
};
// Intensità terremoti segnalazioni utente
typedef NS_CLOSED_ENUM(NSInteger, EQNPastquakeIntensity) {
EQNPastquakeIntensityMild = 1,
EQNPastquakeIntensityStrong = 2,
EQNPastquakeIntensityVeryStrong = 3
};
#define MESSAGGIO @"MESSAGGIO_ERRORE"
@@ -8,6 +8,7 @@
@import Foundation;
@import CoreLocation;
#import "Costanti.h"
NS_ASSUME_NONNULL_BEGIN
@@ -17,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) NSString *address;
@property (nonatomic, strong) NSDate *date;
@property (nonatomic) NSInteger difference;
@property (nonatomic) NSInteger magnitude;
@property (nonatomic) EQNPastquakeIntensity intensity;
@property (nonatomic, strong) NSString *message;
- (instancetype)initWithDictionary:(NSDictionary *)dictionary;
@@ -23,7 +23,7 @@
_address = dictionary[@"address"];
_date = [EQNUtility getDateFromString:dictionary[@"date"]];
_difference = [dictionary[@"difference"] integerValue];
_magnitude = [dictionary[@"magnitude"] integerValue];
_intensity = [dictionary[@"magnitude"] integerValue];
_message = dictionary[@"msg"];
}
return self;
@@ -37,7 +37,7 @@
[encoder encodeObject:self.date forKey:@"date"];
[encoder encodeInteger:self.difference forKey:@"difference"];
[encoder encodeObject:self.coordinate forKey:@"coordinate"];
[encoder encodeInteger:self.magnitude forKey:@"magnitude"];
[encoder encodeInteger:self.intensity forKey:@"intensity"];
[encoder encodeObject:self.message forKey:@"message"];
}
@@ -49,7 +49,7 @@
self.date = [decoder decodeObjectForKey:@"date"];
self.difference = [decoder decodeIntegerForKey:@"difference"];
self.coordinate = [decoder decodeObjectForKey:@"coordinate"];
self.magnitude = [decoder decodeIntegerForKey:@"magnitude"];
self.intensity = [decoder decodeIntegerForKey:@"intensity"];
self.message = [decoder decodeObjectForKey:@"message"];
}
return self;
@@ -21,7 +21,7 @@ class EQNMapAnnotationUserReport: NSObject, MKAnnotation {
convenience init(report: EQNSegnalazione) {
let coordinate = CLLocationCoordinate2D(latitude: report.coordinate.coordinate.latitude, longitude: report.coordinate.coordinate.longitude)
let magnitude = report.magnitude
let magnitude = report.intensity.rawValue
let title = EQNUtility.formattedTimeDifference(from: report.date)
self.init(title: title, coordinate: coordinate, magnitude: magnitude)