Skip to content

mogipix

PostgreSQL extension exposing HEALPix and MOC Rust functions to SQL.

mogipix · PostgreSQL extension exposing HEALPix and MOC Rust functions to SQL.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101023mogipixmogipix0.0.1GISUnknownRust

PostgreSQL · 13, 14, 15, 16, 17

Usage

Sources:

mogipix version 0.0.1 exposes Rust CDS HEALPix, MOC, BMOC, and sky-region operations inside PostgreSQL. Its SQL functions use the mgx_ prefix and support cell hashing, hierarchy and neighborhood operations, MOC construction and set operations, coverage tests, and range forms suitable for indexed spatial filtering.

Examples

The hash function accepts longitude and latitude in degrees and converts them to radians internally. The range-MOC helpers accept PostgreSQL integer ranges:

CREATE EXTENSION mogipix;

SELECT mgx_hash(13, 36.80105218, 56.78028536);

SELECT mgx_moc_to_ascii(
    mgx_create_range_moc_psql(
        29,
        ARRAY[int8range(100, 200), int8range(300, 400)]
    )
);

The extension also defines PostgreSQL types and operators for MOC and BMOC values. For table searches, upstream demonstrates combining a functional HEALPix index or integer multirange containment with mgx_ conversion and coverage functions.

Validation and compatibility

The reviewed build uses pgrx 0.15.0, defaults to PostgreSQL 17, and declares build features for PostgreSQL 13 through 17. Installation is superuser-only. Version 0.0.1 is still an early interface, so test generated extension SQL and every PostgreSQL major version separately.

Depth, coordinate, hash, and range arguments cross signed PostgreSQL types into unsigned Rust library types. Some implementation paths use unchecked casts, unsafe vector representation conversion, or unchecked BMOC construction. Validate astronomical coordinate units and legal HEALPix depth/range bounds before calling them, and compare boundary and empty-set results with the underlying CDS libraries. The current GitLab project was active in 2025 and is not identified as archived.

Table reader