refactor: Move method to get string from coordinate in EQNUtility class
This commit is contained in:
@@ -127,6 +127,7 @@
|
||||
DCEFF21324F5821E009D3FE1 /* SettingDetailTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEFF21224F5821E009D3FE1 /* SettingDetailTableViewCell.swift */; };
|
||||
DCEFF21724F58569009D3FE1 /* SettingSectionHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEFF21624F58569009D3FE1 /* SettingSectionHeaderView.swift */; };
|
||||
DCEFF21A24F587E3009D3FE1 /* SettingItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEFF21924F587E3009D3FE1 /* SettingItem.swift */; };
|
||||
DCF0188F252F09C500C783F0 /* EQNUtility+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCF0188E252F09C500C783F0 /* EQNUtility+Extensions.swift */; };
|
||||
DCF10DC624D2B8C7009F34C3 /* EQNPurchaseUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCF10DC524D2B8C7009F34C3 /* EQNPurchaseUtility.swift */; };
|
||||
DCF10DCD24D2C935009F34C3 /* EQNPurchaseAvailability.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCF10DCC24D2C935009F34C3 /* EQNPurchaseAvailability.swift */; };
|
||||
DCF4A54524F8DB8300B17326 /* SettingDateTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCF4A54424F8DB8300B17326 /* SettingDateTableViewCell.swift */; };
|
||||
@@ -331,6 +332,7 @@
|
||||
DCEFF21224F5821E009D3FE1 /* SettingDetailTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingDetailTableViewCell.swift; sourceTree = "<group>"; };
|
||||
DCEFF21624F58569009D3FE1 /* SettingSectionHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingSectionHeaderView.swift; sourceTree = "<group>"; };
|
||||
DCEFF21924F587E3009D3FE1 /* SettingItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingItem.swift; sourceTree = "<group>"; };
|
||||
DCF0188E252F09C500C783F0 /* EQNUtility+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EQNUtility+Extensions.swift"; sourceTree = "<group>"; };
|
||||
DCF10DC524D2B8C7009F34C3 /* EQNPurchaseUtility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNPurchaseUtility.swift; sourceTree = "<group>"; };
|
||||
DCF10DCC24D2C935009F34C3 /* EQNPurchaseAvailability.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EQNPurchaseAvailability.swift; sourceTree = "<group>"; };
|
||||
DCF10DDB24D2E7BE009F34C3 /* Earthquake Network-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Earthquake Network-Prefix.pch"; sourceTree = "<group>"; };
|
||||
@@ -539,8 +541,6 @@
|
||||
8CF4F4DA216D44930057110B /* EQNPastquakes.m */,
|
||||
8C593E88217BA2470008B260 /* EQNSegnalazione.h */,
|
||||
8C593E89217BA2470008B260 /* EQNSegnalazione.m */,
|
||||
8CF05B55218C93BA0055012B /* EQNUtility.h */,
|
||||
8CF05B56218C93BA0055012B /* EQNUtility.m */,
|
||||
);
|
||||
path = model;
|
||||
sourceTree = "<group>";
|
||||
@@ -697,6 +697,9 @@
|
||||
DC4B67602517833F00634277 /* EQNSeismic.swift */,
|
||||
8CAFD7C321825E4A00F8BD29 /* EQNSisma.h */,
|
||||
8CAFD7C421825E4A00F8BD29 /* EQNSisma.m */,
|
||||
8CF05B55218C93BA0055012B /* EQNUtility.h */,
|
||||
8CF05B56218C93BA0055012B /* EQNUtility.m */,
|
||||
DCF0188E252F09C500C783F0 /* EQNUtility+Extensions.swift */,
|
||||
);
|
||||
path = Models;
|
||||
sourceTree = "<group>";
|
||||
@@ -1069,6 +1072,7 @@
|
||||
files = (
|
||||
DCEFF21324F5821E009D3FE1 /* SettingDetailTableViewCell.swift in Sources */,
|
||||
DCC23DEF24D28F58003A2404 /* EQNEdgeInsetLabel.swift in Sources */,
|
||||
DCF0188F252F09C500C783F0 /* EQNUtility+Extensions.swift in Sources */,
|
||||
8CCE165121E7BAEC00173CD9 /* EQNNotificheReteSismiche.m in Sources */,
|
||||
DC52B8A224FC145500ABEBA6 /* SettingsBaseViewController.m in Sources */,
|
||||
DC2814382519C56100C1AFF7 /* SeismicNetworksViewController.swift in Sources */,
|
||||
|
||||
+1
-23
@@ -451,7 +451,7 @@ class SeismicNetworkTableViewCell: UITableViewCell {
|
||||
|
||||
let distanceRounded = Int(round(seismic.userDistance))
|
||||
distanceLabel.text = "📐 \(distanceRounded) km \(NSLocalizedString("dalla tua posizione", comment: ""))"
|
||||
let coordinateText = coordinateString(coordinate: seismic.coordinate.coordinate)
|
||||
let coordinateText = EQNUtility.coordinateString(coordinate: seismic.coordinate.coordinate)
|
||||
coordinateLabel.text = "🌍 \(coordinateText)"
|
||||
|
||||
// evaluate population string
|
||||
@@ -628,28 +628,6 @@ class SeismicNetworkTableViewCell: UITableViewCell {
|
||||
return notified
|
||||
}
|
||||
|
||||
/// Convert coordinates in degrees
|
||||
private func coordinateString(coordinate: CLLocationCoordinate2D) -> String {
|
||||
var latSeconds = Int(coordinate.latitude * 3600)
|
||||
let latDegrees = latSeconds / 3600
|
||||
latSeconds = abs(latSeconds % 3600)
|
||||
let latMinutes = latSeconds / 60
|
||||
latSeconds %= 60
|
||||
var longSeconds = Int(coordinate.longitude * 3600)
|
||||
let longDegrees = longSeconds / 3600
|
||||
longSeconds = abs(longSeconds % 3600)
|
||||
let longMinutes = longSeconds / 60
|
||||
longSeconds %= 60
|
||||
return String(format:"%d°%d'%d\"%@ lat %d°%d'%d\"%@ lon",
|
||||
abs(latDegrees),
|
||||
latMinutes,
|
||||
latSeconds, latDegrees >= 0 ? "N" : "S",
|
||||
abs(longDegrees),
|
||||
longMinutes,
|
||||
longSeconds,
|
||||
longDegrees >= 0 ? "E" : "W" )
|
||||
}
|
||||
|
||||
/// Determines the zoom for the map, based on the involved population
|
||||
private func mapSpanLongitude(population: Double) -> CLLocationDegrees {
|
||||
var zoom: CLLocationDegrees = 1
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// EQNUtility+Extension.swift
|
||||
// Earthquake Network
|
||||
//
|
||||
// Created by Busi Andrea on 08/10/2020.
|
||||
// Copyright © 2020 Earthquake Network. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
extension EQNUtility {
|
||||
|
||||
/// Convert coordinates in degrees
|
||||
/// - Parameter coordinate: The latitude and longitude associated with a location
|
||||
/// - Returns: Formatted coordinates, like
|
||||
class func coordinateString(coordinate: CLLocationCoordinate2D) -> String {
|
||||
var latSeconds = Int(coordinate.latitude * 3600)
|
||||
let latDegrees = latSeconds / 3600
|
||||
latSeconds = abs(latSeconds % 3600)
|
||||
let latMinutes = latSeconds / 60
|
||||
latSeconds %= 60
|
||||
var longSeconds = Int(coordinate.longitude * 3600)
|
||||
let longDegrees = longSeconds / 3600
|
||||
longSeconds = abs(longSeconds % 3600)
|
||||
let longMinutes = longSeconds / 60
|
||||
longSeconds %= 60
|
||||
return String(format:"%d°%d'%d\"%@ lat %d°%d'%d\"%@ lon",
|
||||
abs(latDegrees),
|
||||
latMinutes,
|
||||
latSeconds, latDegrees >= 0 ? "N" : "S",
|
||||
abs(longDegrees),
|
||||
longMinutes,
|
||||
longSeconds,
|
||||
longDegrees >= 0 ? "E" : "W" )
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user