qdgc
qdgc : Encode, decode, navigate, and fill Extended Quarter Degree Grid Cell codes in pure SQL.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 1700 | qdgc | qdgc | 0.1.0 |
GIS | Apache-2.0 | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| ----dtr | No | No | No | Yes | yes | yes |
| Relationships | |
|---|---|
| Need By | qdgc_postgis |
| See Also | h3 pgrouting pg_geohash q3c postgis_topology pg_polyline pg_eviltransform mobilitydb earthdistance pointcloud |
| Siblings | qdgc_postgis |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.0 |
18 17 16 15 14 | qdgc |
- |
| RPM | PIGSTY | 0.1.0 |
18 17 16 15 14 | qdgc_$v |
- |
| DEB | PIGSTY | 0.1.0 |
18 17 16 15 14 | postgresql-$v-qdgc |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el8.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el9.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el9.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el10.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| el10.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d12.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d12.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d13.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| d13.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u22.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u22.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u24.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u24.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u26.x86_64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
| u26.aarch64 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 | PIGSTY 0.1.0 |
Source
pgxn.org/dist/qdgc/0.1.0/
qdgc-0.1.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
- PGXN qdgc 0.1.0 release
- Official 0.1.0 README
- Official qdgc control file
- Official qdgc 0.1.0 extension SQL
qdgc 0.1.0 is the trusted, relocatable, pure-SQL core of the QDGC extension family. It encodes longitude and latitude as Extended Quarter Degree Grid Cell codes, decodes their bounds, navigates the prefix hierarchy, reports level metrics, and fills longitude/latitude bounding boxes. It has no PostGIS or compiled-library dependency; geometry, geography, and polygon-fill operations belong to the companion qdgc_postgis extension.
Core Workflow
QDGC hierarchy is encoded directly in the text: a child code begins with its parent code. That makes prefix filtering useful for rollups and descendant lookups:
Bounding Boxes and Level Metrics
The core extension can enumerate rectangular coverage without PostGIS. Pass min_lon > max_lon for a box that crosses the antimeridian.
qdgc_average_cell_area is a spherical estimate. Use qdgc_cell_area_km2 from qdgc_postgis when a cell-specific WGS84 spheroid measurement is required.
Important Objects
qdgc_encode(lon, lat, level)andqdgc_latlng_to_cell(lat, lng, level)create codes; the argument order is intentionally different.qdgc_is_valid_cell,qdgc_get_level,qdgc_cell_to_bounds,qdgc_cell_to_lonlat, andqdgc_cell_to_latlnginspect or decode a code.qdgc_cell_to_parentandqdgc_cell_to_childrennavigate the four-way prefix hierarchy.qdgc_bbox_to_cellsenumerates cells meeting a bounding box, whileqdgc_bbox_cell_countcalculates the count without materializing the set.qdgc_level_degrees,qdgc_get_num_cells, andqdgc_average_cell_areareport grid-level metrics.
Operational Notes
- Upstream requires PostgreSQL 13 or newer and tests PostgreSQL 13 through 17. PostgreSQL 18 is not part of the published 0.1.0 test matrix.
- The control file sets
trusted = trueandrelocatable = true. Noshared_preload_libraries,LOAD, server restart, or native library is required. - Relocatable functions call one another by unqualified name. Install
qdgcinto a schema on the activesearch_path; the defaultpublicschema satisfies this boundary. - Coordinates are longitude/latitude degrees.
qdgc_encodetakes longitude first, whileqdgc_latlng_to_celltakes latitude first. - Result cardinality grows by four for every additional child level. Count a bounding-box fill before materializing it, and avoid requesting deep descendants without a deliberate result-size bound.