subrascasse

Sub Rascasse: an iPhone dive log for Subsurface cloud storage, with a pure-Swift git client (GPL-2.0)
git clone https://git.schurger.org/subrascasse.git
Log | Files | Refs | README | LICENSE

commit 83afdc642a1e9cc5bd26e366db604a4a1804f4d6
parent 14a5b133c8acffc9c131ca9ecd6092dabd4a643b
Author: Jean Schurger <jean@schurger.org>
Date:   Sat, 14 Nov 2026 11:05:09 -0500

Open Rémora import: points marked by the diver go into the dive notes

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K7deYJa9LG8PgUSQ5UR5LY

Diffstat:
MApp/Localizable.xcstrings | 10++++++++++
MApp/Model/AppModel.swift | 3++-
MPackages/DiveKit/Sources/SubsurfaceLog/RemoraImport.swift | 15++++++++++++++-
MPackages/DiveKit/Tests/SubsurfaceLogTests/ImportTests.swift | 5+++++
4 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/App/Localizable.xcstrings b/App/Localizable.xcstrings @@ -1591,6 +1591,16 @@ } } }, + "Marks: ": { + "localizations": { + "fr": { + "stringUnit": { + "state": "translated", + "value": "Repères : " + } + } + } + }, "Max depth": { "localizations": { "fr": { diff --git a/App/Model/AppModel.swift b/App/Model/AppModel.swift @@ -358,7 +358,8 @@ final class AppModel { for file in files { do { let dive = try RemoraImport.dive(fromJSON: try Data(contentsOf: file), timeZone: .current, - alarmLabels: alarmLabels, alarmsPrefix: alarmsPrefix) + alarmLabels: alarmLabels, alarmsPrefix: alarmsPrefix, + marksPrefix: String(localized: "Marks: ")) added += try await repository.importDives([dive]) RemoraImport.consume(file) // imported, or already in the logbook: it is no longer pending } catch { diff --git a/Packages/DiveKit/Sources/SubsurfaceLog/RemoraImport.swift b/Packages/DiveKit/Sources/SubsurfaceLog/RemoraImport.swift @@ -20,6 +20,8 @@ public enum RemoraImport { let stopMinutes: Int? } struct Event: Decodable { let time: Double; let warning: String } + /// Point marked by the diver (Action button of the watch); `heading` in magnetic degrees. + struct Mark: Decodable { let time: Double; let depth: Double; let heading: Double? } let id: UUID let source: String? @@ -31,6 +33,7 @@ public enum RemoraImport { let water: String? let samples: [Sample] let events: [Event]? + let marks: [Mark]? let site: String? let notes: String? let latitude: Double? @@ -47,9 +50,11 @@ public enum RemoraImport { /// time, hence the time zone to apply (by default, the device's at the time of the dive). /// The alarms are appended to the notes as `alarmsPrefix` followed by "m:ss label" entries; `alarmLabels` maps /// each warning identifier to its label (an identifier missing from the dictionary is written as is). + /// The points marked by the diver follow, as `marksPrefix` and "m:ss depth heading" entries. public static func dive(fromJSON data: Data, timeZone: TimeZone = .current, alarmLabels: [String: String] = RemoraImport.defaultAlarmLabels, - alarmsPrefix: String = "Alarms: ") throws -> ImportedDive { + alarmsPrefix: String = "Alarms: ", + marksPrefix: String = "Marks: ") throws -> ImportedDive { let decoder = JSONDecoder() decoder.dateDecodingStrategy = .iso8601 let log = try decoder.decode(Log.self, from: data) @@ -96,6 +101,14 @@ public enum RemoraImport { return "\(seconds / 60):" + String(format: "%02d", seconds % 60) + " \(alarmLabels[event.warning] ?? event.warning)" } if !alarms.isEmpty { notes.append(alarmsPrefix + alarms.joined(separator: ", ")) } + // The points marked by the diver, as "m:ss depth m heading°" entries. + let marks = (log.marks ?? []).map { mark -> String in + let seconds = Int(mark.time.rounded()) + let heading = mark.heading.map { " \(Int($0.rounded()) % 360)°" } ?? "" + return "\(seconds / 60):" + String(format: "%02d", seconds % 60) + + " " + String(format: "%.1f", mark.depth) + " m" + heading + } + if !marks.isEmpty { notes.append(marksPrefix + marks.joined(separator: ", ")) } dive.notes = notes.joined(separator: "\n") return dive } diff --git a/Packages/DiveKit/Tests/SubsurfaceLogTests/ImportTests.swift b/Packages/DiveKit/Tests/SubsurfaceLogTests/ImportTests.swift @@ -312,6 +312,11 @@ final class ImportTests: XCTestCase { XCTAssertEqual(RemoraImport.defaultAlarmLabels.keys.sorted(), ["ascentFast", "ascentTooFast", "ceilingViolated", "missedSafetyStop", "ppO2Critical", "ppO2High"]) + // Points marked by the diver with the Action button of the watch go into the notes too. + let marked = json.replacingOccurrences(of: "\"number\":3", with: "\"number\":3,\"marks\":[{\"time\":605,\"depth\":18.24,\"heading\":237.4},{\"time\":900,\"depth\":25}]") + XCTAssertEqual(try RemoraImport.dive(fromJSON: Data(marked.utf8), timeZone: montreal, marksPrefix: "Repères : ").notes, + "Première sortie\nAlarms: 10:00 fast ascent, 21:00 ceiling violated\nRepères : 10:05 18.2 m 237°, 15:00 25.0 m") + // A demo dive must never enter the logbook. XCTAssertThrowsError(try RemoraImport.dive(fromJSON: Data(json.replacingOccurrences(of: "\"source\":\"remora\"", with: "\"source\":\"simulation\"").utf8)))