Skip to content

Commit

Permalink
DifferentialGPSStation -> DGPSStation
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbarela committed Feb 29, 2024
1 parent 85d3c01 commit f03c7fc
Show file tree
Hide file tree
Showing 63 changed files with 481 additions and 533 deletions.
176 changes: 88 additions & 88 deletions Marlin/Marlin.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Marlin/Marlin/BottomSheet/BottomSheetView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ struct MarlinBottomSheet <Content: View>: View {
case DataSources.dgps.key:
let split = itemKey.split(separator: "--")
if split.count == 2 {
DifferentialGPSStationSheetView(
DGPSStationSheetView(
featureNumber: Int(split[0]) ?? -1,
volumeNumber: "\(split[1])",
focusNotification: focusNotification
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// DifferentialGPSStationDefinition.swift
// DGPSStationDefinition.swift
// Marlin
//
// Created by Daniel Barela on 2/28/24.
Expand All @@ -10,8 +10,8 @@ import UIKit
import SwiftUI

extension DataSources {
class DifferentialGPSStationDefinition: DataSourceDefinition {
var filterable: Filterable? = DifferentialGPSStationFilterable()
class DGPSStationDefinition: DataSourceDefinition {
var filterable: Filterable? = DGPSStationFilterable()
var mappable: Bool = true
var color: UIColor = UIColor(argbValue: 0xFF00E676)
var imageName: String? = "dgps"
Expand All @@ -33,7 +33,7 @@ extension DataSources {
UserDefaults.standard.lastSyncTimeSeconds(DataSources.dgps)
}

static let definition = DifferentialGPSStationDefinition()
static let definition = DGPSStationDefinition()
private init() { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enum DataSources {
static let bookmark: BookmarkDefinition = BookmarkDefinition.definition
static let common: CommonDefinition = CommonDefinition.definition
static let chartCorrection: ChartCorrectionDefinition = ChartCorrectionDefinition.definition
static let dgps: DifferentialGPSStationDefinition = DifferentialGPSStationDefinition.definition
static let dgps: DGPSStationDefinition = DGPSStationDefinition.definition
static let epub: PublicationDefinition = PublicationDefinition.definition
static let geoPackage: GeoPackageDefinition = GeoPackageDefinition.definition
static let light: LightDefinition = LightDefinition.definition
Expand All @@ -92,7 +92,7 @@ enum DataSources {
return DataSourceDefinitions.common.filterable
case is DataSources.NoticeToMarinersDefinition:
return DataSourceDefinitions.noticeToMariners.filterable
case is DataSources.DifferentialGPSStationDefinition:
case is DataSources.DGPSStationDefinition:
return DataSourceDefinitions.differentialGPSStation.filterable
case is DataSources.PublicationDefinition:
return DataSourceDefinitions.epub.filterable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum DataSourceDefinitions: String, Identifiable, CaseIterable {
return DataSourceDefinitions.common
case is DataSources.NoticeToMarinersDefinition:
return DataSourceDefinitions.noticeToMariners
case is DataSources.DifferentialGPSStationDefinition:
case is DataSources.DGPSStationDefinition:
return DataSourceDefinitions.differentialGPSStation
case is DataSources.PublicationDefinition:
return DataSourceDefinitions.epub
Expand Down Expand Up @@ -103,7 +103,7 @@ enum DataSourceDefinitions: String, Identifiable, CaseIterable {
case .noticeToMariners:
return NoticeToMarinersFilterable()
case .differentialGPSStation:
return DifferentialGPSStationFilterable()
return DGPSStationFilterable()
case .epub:
return PublicationFilterable()
case .port:
Expand Down Expand Up @@ -137,7 +137,7 @@ enum DataSourceDefinitions: String, Identifiable, CaseIterable {
return DataSourceDefinitions.common.filterable
case is DataSources.NoticeToMarinersDefinition:
return DataSourceDefinitions.noticeToMariners.filterable
case is DataSources.DifferentialGPSStationDefinition:
case is DataSources.DGPSStationDefinition:
return DataSourceDefinitions.differentialGPSStation.filterable
case is DataSources.PublicationDefinition:
return DataSourceDefinitions.epub.filterable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// DifferentialGPSStationFilterable.swift
// DGPSStationFilterable.swift
// Marlin
//
// Created by Daniel Barela on 12/18/23.
//

import Foundation

struct DifferentialGPSStationFilterable: Filterable {
struct DGPSStationFilterable: Filterable {
var definition: any DataSourceDefinition {
DataSourceDefinitions.differentialGPSStation.definition
}
Expand Down Expand Up @@ -56,5 +56,4 @@ struct DifferentialGPSStationFilterable: Filterable {
ascending: true)
]

// var locatableClass: Locatable.Type? = DifferentialGPSStation.self
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import CoreLocation
import mgrs_ios
import GeoJSON

struct DifferentialGPSStationListModel: Hashable, Identifiable {
struct DGPSStationListModel: Hashable, Identifiable {
var id: String {
"\(featureNumber ?? 0)--\(volumeNumber ?? "")"
}
Expand Down Expand Up @@ -51,13 +51,13 @@ struct DifferentialGPSStationListModel: Hashable, Identifiable {
}
}

extension DifferentialGPSStationListModel {
extension DGPSStationListModel {
var itemTitle: String {
return "\(self.name ?? "\(self.featureNumber ?? 0)")"
}
}

extension DifferentialGPSStationListModel: Bookmarkable {
extension DGPSStationListModel: Bookmarkable {
static var definition: any DataSourceDefinition {
DataSources.dgps
}
Expand All @@ -71,22 +71,22 @@ extension DifferentialGPSStationListModel: Bookmarkable {
}
}

extension DifferentialGPSStationListModel {
init(differentialGPSStationModel: DifferentialGPSStationModel) {
self.canBookmark = differentialGPSStationModel.canBookmark
self.featureNumber = differentialGPSStationModel.featureNumber
self.volumeNumber = differentialGPSStationModel.volumeNumber
self.name = differentialGPSStationModel.name
self.geopoliticalHeading = differentialGPSStationModel.geopoliticalHeading
self.sectionHeader = differentialGPSStationModel.sectionHeader
self.stationID = differentialGPSStationModel.stationID
self.remarks = differentialGPSStationModel.remarks
self.latitude = differentialGPSStationModel.latitude
self.longitude = differentialGPSStationModel.longitude
extension DGPSStationListModel {
init(dgpsStationModel: DGPSStationModel) {
self.canBookmark = dgpsStationModel.canBookmark
self.featureNumber = dgpsStationModel.featureNumber
self.volumeNumber = dgpsStationModel.volumeNumber
self.name = dgpsStationModel.name
self.geopoliticalHeading = dgpsStationModel.geopoliticalHeading
self.sectionHeader = dgpsStationModel.sectionHeader
self.stationID = dgpsStationModel.stationID
self.remarks = dgpsStationModel.remarks
self.latitude = dgpsStationModel.latitude
self.longitude = dgpsStationModel.longitude
}
}

struct DifferentialGPSStationModel:
struct DGPSStationModel:
Locatable,
Bookmarkable,
Codable,
Expand Down Expand Up @@ -235,7 +235,7 @@ struct DifferentialGPSStationModel:
let decoder = JSONDecoder()
let jsonData = Data(string.utf8)

if let model = try? decoder.decode(DifferentialGPSStationModel.self, from: jsonData) {
if let model = try? decoder.decode(DGPSStationModel.self, from: jsonData) {
self = model
} else {
return nil
Expand Down Expand Up @@ -304,7 +304,7 @@ struct DifferentialGPSStationModel:
self.transferRate = try? values.decode(Int.self, forKey: .transferRate)

if let position = self.position {
let coordinate = DifferentialGPSStationModel.parsePosition(position: position)
let coordinate = DGPSStationModel.parsePosition(position: position)
self.longitude = coordinate.longitude
self.latitude = coordinate.latitude
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
//
// DifferentialGPSStationPropertyContainer.swift
// DGPSStationPropertyContainer.swift
// Marlin
//
// Created by Daniel Barela on 2/8/24.
//

import Foundation

struct DifferentialGPSStationPropertyContainer: Decodable {
struct DGPSStationPropertyContainer: Decodable {
private enum CodingKeys: String, CodingKey {
case ngalol
}
let ngalol: [DifferentialGPSStationModel]
let ngalol: [DGPSStationModel]

init(dgpss: [DifferentialGPSStationModel]) {
init(dgpss: [DGPSStationModel]) {
ngalol = dgpss
}

init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
ngalol = try container.decode(
[Throwable<DifferentialGPSStationModel>].self, forKey: .ngalol
[Throwable<DGPSStationModel>].self, forKey: .ngalol
)
.compactMap { try? $0.result.get() }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// DifferentialGPSStationMap.swift
// DGPSStationMap.swift
// Marlin
//
// Created by Daniel Barela on 8/30/22.
Expand All @@ -10,7 +10,7 @@ import MapKit
import CoreData
import Combine

class DifferentialGPSStationMap: DataSourceMap {
class DGPSStationMap: DataSourceMap {

override var minZoom: Int {
get {
Expand Down
61 changes: 4 additions & 57 deletions Marlin/Marlin/DataSources/NTM/NoticeToMarinersModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,68 +104,15 @@ struct NoticeToMarinersListModel: Hashable, Identifiable {
}

func dateRange() -> String {
let firstDate = getFirstDay(weekNumber: (noticeNumber ?? 0) % 100, currentYear: (noticeNumber ?? 0) / 100) ?? Date()
let firstDate = getFirstDay(
weekNumber: (noticeNumber ?? 0) % 100,
currentYear: (noticeNumber ?? 0) / 100
) ?? Date()
let lastDate = Calendar.current.date(byAdding: .day, value: 6, to: firstDate) ?? Date()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "MMMM d"
return "\(dateFormatter.string(from: firstDate)) - \(dateFormatter.string(from: lastDate))"
}

func checkFileExists() -> Bool {
return false
// var downloaded = false
// if let destinationUrl = URL(string: self.savePath) {
// downloaded = FileManager().fileExists(atPath: destinationUrl.path)
// }
// if downloaded != self.isDownloaded {
// PersistenceController.current.perform {
// self.objectWillChange.send()
// self.isDownloaded = downloaded
// DispatchQueue.main.async {
// try? PersistenceController.current.save()
// }
// }
// }
// return downloaded
}

func deleteFile() {
// guard let odsKey else {
// return
// }
// let docsUrl = URL.documentsDirectory
// let fileUrl = "\(docsUrl.absoluteString)\(odsKey)"
// let destinationUrl = URL(string: fileUrl)
//
// if let destinationUrl = destinationUrl {
// guard FileManager().fileExists(atPath: destinationUrl.path) else { return }
// do {
// try FileManager().removeItem(atPath: destinationUrl.path)
// } catch let error {
// print("Error while deleting file: ", error)
// }
// }
//
// PersistenceController.current.perform {
// self.objectWillChange.send()
// self.isDownloaded = false
// self.downloadProgress = 0.0
// DispatchQueue.main.async {
// try? PersistenceController.current.save()
// }
// }
}

func downloadFile() {
// if isDownloaded && checkFileExists() {
// return
// }
// DownloadManager.shared.download(downloadable: self)
}

func cancelDownload() {
// DownloadManager.shared.cancel(downloadable: self)
}
}

extension NoticeToMarinersListModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ struct NavigationalWarningModel: Codable, Hashable, Identifiable, Bookmarkable,
var canBookmark: Bool = false
var id: String { self.itemKey }
var itemTitle: String {
return "\(self.navAreaName) \(String(self.msgNumber ?? 0))/\(String(self.msgYear ?? 0)) (\(self.subregion ?? ""))"
return """
\(self.navAreaName) \(String(self.msgNumber ?? 0))/\(String(self.msgYear ?? 0)) (\(self.subregion ?? ""))
"""
}
var itemKey: String {
return "\(msgYear ?? 0)--\(msgNumber ?? 0)--\(navArea)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// DifferentialGPSStationGeoPackageExportable.swift
// DGPSStationGeoPackageExportable.swift
// Marlin
//
// Created by Daniel Barela on 2/9/24.
Expand All @@ -10,11 +10,11 @@ import geopackage_ios
import ExceptionCatcher
import sf_ios

class DifferentialGPSStationGeoPackageExportable: GeoPackageExportable {
class DGPSStationGeoPackageExportable: GeoPackageExportable {
static var definition: any DataSourceDefinition = DataSources.dgps

let differentialGPSStationRepository: DifferentialGPSStationRepository
init(differentialGPSStationRepository: DifferentialGPSStationRepository) {
let differentialGPSStationRepository: DGPSStationRepository
init(differentialGPSStationRepository: DGPSStationRepository) {
self.differentialGPSStationRepository = differentialGPSStationRepository
}

Expand Down
2 changes: 1 addition & 1 deletion Marlin/Marlin/GeoPackage/GeoPackageExportView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct GeoPackageExportView: View {
@EnvironmentObject var moduRepository: ModuRepository
@EnvironmentObject var lightRepository: LightRepository
@EnvironmentObject var portRepository: PortRepository
@EnvironmentObject var dgpsRepository: DifferentialGPSStationRepository
@EnvironmentObject var dgpsRepository: DGPSStationRepository
@EnvironmentObject var radioBeaconRepository: RadioBeaconRepository
@EnvironmentObject var routeRepository: RouteRepository
@EnvironmentObject var navigationalWarningRepository: NavigationalWarningRepository
Expand Down
4 changes: 2 additions & 2 deletions Marlin/Marlin/GeoPackage/GeoPackageExportViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class GeoPackageExportViewModel: ObservableObject {
var moduRepository: ModuRepository?
var lightRepository: LightRepository?
var portRepository: PortRepository?
var dgpsRepository: DifferentialGPSStationRepository?
var dgpsRepository: DGPSStationRepository?
var radioBeaconRepository: RadioBeaconRepository?
var routeRepository: RouteRepository?
var navigationalWarningRepository: NavigationalWarningRepository?
Expand Down Expand Up @@ -364,7 +364,7 @@ class GeoPackageExportViewModel: ObservableObject {
}
case DataSources.dgps.key:
if let dgpsRepository = dgpsRepository {
exportable = DifferentialGPSStationGeoPackageExportable(
exportable = DGPSStationGeoPackageExportable(
differentialGPSStationRepository: dgpsRepository
)
}
Expand Down
9 changes: 7 additions & 2 deletions Marlin/Marlin/GeoPackage/LightGeoPackageExportable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@ class LightGeoPackageExportable: GeoPackageExportable {
await updateProgress(dataSourceProgress: dataSourceProgress, count: exported)
}

func createFeature(model: Encodable, sfGeometry: SFGeometry?, geoPackage: GPKGGeoPackage, table: GPKGFeatureTable, styleRows: [GPKGStyleRow]) {

func createFeature(
model: Encodable,
sfGeometry: SFGeometry?,
geoPackage: GPKGGeoPackage,
table: GPKGFeatureTable,
styleRows: [GPKGStyleRow]
) {
guard let featureDao = geoPackage.featureDao(with: table),
let featureTableStyles = GPKGFeatureTableStyles(geoPackage: geoPackage, andTable: table),
let row = featureDao.newRow() else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import sf_ios
styleRows: [GPKGStyleRow],
dataSourceProgress: DataSourceExportProgress
) async throws {
let models = await navigationalWarningRepository.getNavigationalWarnings(filters: (filters ?? []) + (commonFilters ?? []))
let models = await navigationalWarningRepository.getNavigationalWarnings(
filters: (filters ?? []) + (commonFilters ?? [])
)
var exported = 0
for model in models {
createFeature(
Expand Down
Loading

0 comments on commit f03c7fc

Please sign in to comment.