Skip to main content

fgsmdb — FlightGear Scenemodels Database Tools

Command-line tools for the FlightGear scenemodels database.

Installation

pip install fgsmdb

Or install from source:

cd fgsmdb
pip install .

For development:

cd fgsmdb
pip install -e .

Configuration

Copy .env.example to .env and fill in your values:

cp .env.example .env
Variable Description Default
PGURI PostgreSQL connection URI (required) —
FGELEV_PATH Path to the fgelev binary (local mode) /usr/local/bin/fgelev
FGELEV_DOCKER_IMAGE Docker image to run fgelev in (Docker mode) —
FGELEV_TCP_HOST Hostname of a remote fgelev TCP service (TCP mode) —
FGELEV_TCP_PORT Port of the remote fgelev TCP service 9000
FG_ROOT FlightGear data root — not needed in TCP mode /app/data
FG_SCENERY Local scenery path (Terrain, Airports, etc.) — not needed in TCP mode ./fgscenery
FG_SCENERY_EXPORT Working directory for exported files ./export
GROUNDNETS_PATH Path to groundnets git repository ./groundnets
MIN_UPDATES Minimum pending updates to trigger export 1
SYNC_TARGETS Comma-separated rsync target URIs —
CDN_INVALIDATE_CMD Shell command to run after distribution —

For remote distribution, rsync uses your ~/.ssh/config for host aliases, usernames, and identity files.

fgelev modes

The gndelev step needs to reach a running fgelev binary. Three modes are supported; the first one configured wins:

TCP service (recommended for server deployments)

Run the fgelev Docker image as a persistent service, for example in a Docker Compose stack:

services:
  fgelev:
    build:
      context: ./export/fgelev
    restart: unless-stopped
    ports:
      - "127.0.0.1:9000:9000"
    volumes:
      - ${FG_ROOT}:/fg/root:ro
      - ${FG_SCENERY}:/fg/scenery:ro
    environment:
      FG_ROOT: /fg/root
      FG_SCENERY: /fg/scenery

Then point fgsmdb at the service — no local terrain data needed:

FGELEV_TCP_HOST=fgelev    # service name in Compose, or any hostname/IP
FGELEV_TCP_PORT=9000      # default, can be omitted

The service speaks the same line-oriented protocol as the local binary (id lon lat\n in, id:elevation\n out) via socat on port 9000. fgelev's terrain-tile cache persists for the lifetime of the connection, which covers the entire export run.

Docker run (one-shot container per export run)

FGELEV_DOCKER_IMAGE=fgelev:latest
FG_ROOT=/path/to/fg/data
FG_SCENERY=/path/to/scenery

fgsmdb will call docker run --rm --interactive with fg_root and fg_scenery bind-mounted read-only into the container.

Local binary

FGELEV_PATH=/usr/local/bin/fgelev
FG_ROOT=/path/to/fg/data
FG_SCENERY=/path/to/scenery

Usage

# Run the export pipeline
python3 -m fgsmdb export

# Or use the installed command
fgsmdb export

Export Command

Exports the scenemodels database to a TerraSync-compatible file tree.

# Full pipeline (all steps except distribute)
python3 -m fgsmdb export

# With a specific .env file
python3 -m fgsmdb export --env-file /path/to/.env

# Run specific steps only
python3 -m fgsmdb export --steps sanitize,export,mkdiridx

# Include distribution to mirrors
python3 -m fgsmdb export --steps sanitize,gndelev,export,mkdiridx,upload,distribute

# Skip the pending-updates threshold check
python3 -m fgsmdb export --skip-check

# Override the minimum updates threshold
python3 -m fgsmdb export --min-updates 10

# Enable verbose (debug) logging
python3 -m fgsmdb export -v

Pipeline Steps

Step Description
sanitize Fix data integrity: update tile numbers, nullify zero elevation offsets
gndelev Compute ground elevation for new objects using fgelev (local binary, Docker, or TCP service)
export Export shared/per-hemisphere models and generate .stg files from the database
mkdiridx Create .dirindex files for TerraSync and the Airports archive
upload Sync exported files to the local scenery tree (hash-based, copies only changes)
distribute Rsync scenery to remote mirror servers (parallel)

By default, all steps except distribute are run. Distribution must be explicitly requested via --steps.

Before any steps execute, the pipeline calls fn_update_statistics() and checks whether the number of objects pending ground elevation meets the configured threshold. Use --skip-check to bypass this gate.

Command Line Options

python3 -m fgsmdb export [-h] [--env-file ENV_FILE] [--steps STEPS] [--all]
                         [--skip-check] [--min-updates N] [-v]

Options:
  --env-file ENV_FILE   Path to .env file (default: auto-detect)
  --steps STEPS         Comma-separated steps: sanitize, gndelev, export,
                        mkdiridx, upload, distribute
  --all                 Run all steps (same as default, without distribute)
  --skip-check          Skip the pending-updates threshold check
  --min-updates N       Override the MIN_UPDATES threshold from .env
  -v, --verbose         Enable debug logging
  -h, --help            Show help message

Output Structure

fgscenery/
├── .dirindex
├── Airports_archive.tgz
├── SharedModels.txz
├── Airports/
│   ├── .dirindex
│   └── ...
├── Models/
│   ├── .dirindex
│   └── <group_path>/
├── Objects/
│   ├── .dirindex
│   └── <e|w>NNN<n|s>NN/
│       └── <e|w>NNN<n|s>NN/
│           ├── <tile>.stg
│           └── <model_files>
└── Terrain/
    └── .dirindex

License

GNU General Public License v2.0 — see LICENCE.

Development

Building and publishing

Requires Python 3.10+ and a venv with build tools:

cd fgsmdb
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip build twine

Bump the version in pyproject.toml, then build:

python -m build

This produces dist/fgsmdb-<version>.tar.gz and dist/fgsmdb-<version>-py3-none-any.whl.

Via GitHub Actions (recommended)

Push a tag matching fgsmdb-v* to trigger the publish workflow, which uses PyPI trusted publishing — no credentials required:

git tag fgsmdb-v0.1.2
git push origin fgsmdb-v0.1.2

The workflow is defined in .github/workflows/publish-fgsmdb.yml. It requires a GitHub environment named pypi and a trusted publisher configured on PyPI at https://pypi.org/manage/project/fgsmdb/settings/ with:

Field Value
Owner FlightGear
Repository scenemodels
Workflow publish-fgsmdb.yml
Environment pypi

Manually via twine

twine upload dist/*

Twine will prompt for credentials. Use __token__ as the username and a PyPI API token as the password. To avoid the prompt, set environment variables:

export TWINE_USERNAME=__token__
export TWINE_PASSWORD=<your-pypi-api-token>
twine upload dist/*

Testing before publishing

To verify the package installs correctly without affecting PyPI:

# Upload to TestPyPI
twine upload --repository testpypi dist/*

# Install from TestPyPI in a fresh venv
python3 -m venv /tmp/test-fgsmdb
source /tmp/test-fgsmdb/bin/activate
pip install --index-url https://test.pypi.org/simple/ fgsmdb
python -m fgsmdb --help

PyPI does not allow overwriting an existing version. If an upload fails partway through, bump the version number before retrying.

Metadata

Release files for fgsmdb 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fgsmdb 0.1.11
File Size Uploaded Provenance Actions
fgsmdb-0.1.11.tar.gz 21.2 kB With provenance Details for fgsmdb-0.1.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fgsmdb 0.1.11
File Interpreter ABI Platform Actions
fgsmdb-0.1.11-py3-none-any.whl Python 3 none any Details for fgsmdb-0.1.11-py3-none-any.whl

Total release size: 43.9 kB

Release files / fgsmdb-0.1.11.tar.gz

Download URL fgsmdb-0.1.11.tar.gz
Size 21.2 kB
Tags Source
SHA-256 checksum
How to use checksums
cc34f75e1d398d76c67675fa41037e430c1938180ff7b97f1c21864f394f9b91
BLAKE2b-256 checksum
How to use checksums
e008fc5f96d6a92b133bc30b4d7e0dd1ed7f61d0fa5e611f8162765d9666f38b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / fgsmdb-0.1.11-py3-none-any.whl

Download URL fgsmdb-0.1.11-py3-none-any.whl
Size 22.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aff40b0f3ed727cc60be387820e3635a0b15fe2ed2afee3a8b05d66140a35110
BLAKE2b-256 checksum
How to use checksums
408f4cfb4d2af2a11a4ab372858483e1a17c6664f1d25839359b04a8020ce4db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for fgsmdb 0.1.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fgsmdb-0.1.11.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page