Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ jobs:
- name: Run TCD validation tests
run: npm run test -w tcd

sqlite:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "24"

- name: Install dependencies
run: npm install

- name: Build project
run: npm run build

- name: Build SQLite database
run: npm run build -w sqlite

- name: Run SQLite validation tests
run: npm run test -w sqlite

lint:
runs-on: ubuntu-latest
steps:
Expand Down
70 changes: 70 additions & 0 deletions packages/sqlite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Neaps Tide Database - TideBase (SQLite)

This package generates a [TideBase](./spec.md) file — an SQLite database containing all stations from the Neaps Tide Database with harmonic constituents, tidal datums, subordinate station offsets, and precomputed equilibrium arguments and node factors for tide prediction.

TideBase is a modern, portable, and queryable database containing everything needed for tide prediction in an SQLite database.

## Usage

Download the latest `*.tidebase` file from [GitHub Releases](https://github.com/openwatersio/tide-database/releases) and query it with any SQLite client:

```sh
sqlite3 neaps*.tidebase
```

### Find a station

```sql
SELECT station_id, name, latitude, longitude
FROM stations
WHERE station_id = 'noaa/9414290';
```

### Find nearby stations

```sql
SELECT station_id, name, latitude, longitude
FROM stations
WHERE latitude BETWEEN 37.5 AND 38.0
AND longitude BETWEEN -122.6 AND -122.2
ORDER BY name;
```

### Get prediction data for a station and year

```sql
SELECT sc.constituent, c.speed, sc.amplitude, sc.phase,
ea.value AS eq_argument, nf.value AS node_factor
FROM station_constituents sc
JOIN stations s ON s.id = sc.station_id
JOIN constituents c ON c.name = sc.constituent
LEFT JOIN equilibrium_arguments ea
ON ea.constituent = sc.constituent AND ea.year = 2026
LEFT JOIN node_factors nf
ON nf.constituent = sc.constituent AND nf.year = 2026
WHERE s.station_id = 'noaa/9414290'
ORDER BY c.speed;
```

See [examples/](./examples/) for more queries. See [spec.md](./spec.md) for the full specification.

## Contributing

Build the database:

```sh
npm run build
```

### Testing

The test suite validates that the built database correctly preserves all station data from the source JSON files, and that all example queries execute successfully.

```sh
npm test
```

## References

- [TideBase Specification](./spec.md)
- [@neaps/tide-predictor](https://github.com/openwatersio/neaps/tree/main/packages/tide-predictor)
5 changes: 5 additions & 0 deletions packages/sqlite/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e
cd "$(dirname "$0")"
rm -rf dist && mkdir -p dist
node build.ts
Loading