Using OTC data with a Slackwater Swift database reader

A Swift app that uses the published Slackwater database reader can open the OTC FlatBuffers file. The example also passes its stored constituents to the Slackwater Swift prediction engine.

Get the file

Download OTC_20261130.tcdb, the database report and the export checksums.

Open it with your reader

  1. Keep your existing database. Point your reader's file URL at the downloaded OTC file.
  2. Use the published Swift database reader and the tested Swift engine source. Add their SlackwaterDatabase and SlackwaterKit products to your Swift target.
  3. From the download directory, run this example in your Swift executable target. It verifies the file, opens Plum Island and predicts a water level.
    import Foundation
    import SlackwaterDatabase
    import SlackwaterKit
    
    let url = URL(fileURLWithPath: "OTC_20261130.tcdb")
    let database = try StationDatabase(verifyingContentsOf: url)
    let record = database.station(id: "OTC-000d594d")!
    let constituents = record.constituents.map {
        SlackwaterKit.HarmonicConstituent(name: $0.name, amplitude: $0.amplitude, phase: $0.phase)
    }
    let definitions = (record.constituentDefinitions ?? []).map {
        SlackwaterKit.ConstituentDefinition(name: $0.name, speed: $0.speed, coefficients: $0.coefficients,
                                            aliases: $0.aliases, members: $0.members.map {
            .init(name: $0.name, factor: $0.factor)
        })
    }
    let corrections: SlackwaterKit.NodeCorrections
    switch record.nodeCorrections {
    case .iho: corrections = .iho
    case .schureman: corrections = .schureman
    case .foreman: corrections = .foreman(latitude: record.nodeCorrectionsLatitude!)
    }
    let station = try SlackwaterKit.Station(constituents: constituents,
                                            offset: record.chartDatumShift ?? 0,
                                            definitions: definitions, nodeCorrections: corrections)
    let start = ISO8601DateFormatter().date(from: "2026-11-30T16:00:00-08:00")!
    let height = station.heights(from: start, to: start.addingTimeInterval(3600), step: 3600)[0].height
    print(record.id, record.chartDatum ?? "harmonic mean", height, "m")
  4. Check the printed station ID, datum and units. Display the file's attribution alongside the data.

These steps are for apps using the published Swift reader and prediction engine.

For a subordinate station, the Swift reader's chartDatumShift comes from its reference station. To predict against the subordinate's own published datum, follow the station-JSON reference workflow.

Find a saved station

Download the ID map for the same release. In the map directory, look up your exact saved Slackwater ID.

jq -er --arg saved 'noaa/8440452' '.stations[$saved]' OTC_20261130-slackwater-id-map.json

This example returns OTC-000d594d for Plum Island. Pass that ID to database.station(id:). If either lookup has no result, keep the saved ID and check the database report.

What this file carries

The database covers 14,420 tide and current stations with attribution. The checked Slackwater catalog lists 12,407 tide and current IDs. Across 184 paired mean-level tide heights at 23 stations, the largest difference from the OTC SDK was 64.950 mm.

The file holds tide stations and current stations. Its report lists each station of the release as written, as one the format cannot represent, or as one with no selected prediction. When a saved station is absent, look for it in the report.

  • The database records the default and the references required to predict subordinate stations. See the database report for details.
  • A current is one signed series along the major axis of a depth bin. Motion along the minor axis is not stored.
  • Amplitudes, phases and datums are stored in single precision.
  • A station with no chart-datum or mean-sea-level tie has an empty chart datum. Its heights are relative to the harmonic mean.
  • The export leaves out sets that require daily corrections.

Keep the datum, the quality labels and the attribution text with each result. The release files keep each record and its full values. See Data format.

Next: this file holds a current as one signed series, values in single precision and no daily corrections. Read through a library, the release has the rest. Get started.