tzf
Fast lookup timezone name by GPS coordinates
Repository
ringsaturn/pg-tzf
https://github.com/ringsaturn/pg-tzf
Source
pg-tzf-0.2.3.tar.gz
pg-tzf-0.2.3.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_tzf | 0.2.3 | GIS | MIT | Rust |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 1680 | tzf | No | Yes | No | Yes | No | No | - |
| Related | postgis geoip pg_cron postgis_topology postgis_raster postgis_sfcgal postgis_tiger_geocoder address_standardizer |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.2.3 | 1817161514 | pg_tzf | - |
| RPM | PIGSTY | 0.2.3 | 1817161514 | pg_tzf_$v | - |
| DEB | PIGSTY | 0.2.3 | 1817161514 | postgresql-$v-tzf | - |
Build
You can build the RPM / DEB packages for pg_tzf using pig build:
pig build pkg pg_tzf # build RPM / DEB packages
Install
You can install pg_tzf directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_tzf; # Install for current active PG version
pig ext install -y pg_tzf -v 18 # PG 18
pig ext install -y pg_tzf -v 17 # PG 17
pig ext install -y pg_tzf -v 16 # PG 16
pig ext install -y pg_tzf -v 15 # PG 15
pig ext install -y pg_tzf -v 14 # PG 14
dnf install -y pg_tzf_18 # PG 18
dnf install -y pg_tzf_17 # PG 17
dnf install -y pg_tzf_16 # PG 16
dnf install -y pg_tzf_15 # PG 15
dnf install -y pg_tzf_14 # PG 14
apt install -y postgresql-18-tzf # PG 18
apt install -y postgresql-17-tzf # PG 17
apt install -y postgresql-16-tzf # PG 16
apt install -y postgresql-15-tzf # PG 15
apt install -y postgresql-14-tzf # PG 14
Create Extension:
CREATE EXTENSION tzf;
Usage
Find timezone names from coordinates. Built on tzf-rs with timezone boundary data from timezone-boundary-builder.
CREATE EXTENSION tzf;
Functions
Look up timezone for a coordinate (longitude, latitude):
SELECT tzf_tzname(116.3883, 39.9289) AS timezone;
-- Asia/Shanghai
Look up timezone for a batch of coordinates:
SELECT unnest(
tzf_tzname_batch(
ARRAY[-74.0060, -118.2437, 139.6917],
ARRAY[40.7128, 34.0522, 35.6895]
)
) AS timezones;
-- America/New_York
-- America/Los_Angeles
-- Asia/Tokyo
Look up timezone for a point:
SELECT tzf_tzname_point(point(-74.0060, 40.7128)) AS timezone;
-- America/New_York
Look up timezone for a batch of points:
SELECT unnest(
tzf_tzname_batch_points(
ARRAY[
point(-74.0060, 40.7128),
point(-118.2437, 34.0522),
point(139.6917, 35.6895)
]
)
) AS timezones;
-- America/New_York
-- America/Los_Angeles
-- Asia/Tokyo
Performance
| Function | TPS | Note |
|---|---|---|
tzf_tzname | ~17,700 | Single coordinate lookup |
tzf_tzname_point | ~17,600 | Single point lookup |
tzf_tzname_batch | ~51 | Batch of 1000 = ~51,000 TPS |
tzf_tzname_batch_points | ~32 | Batch of 1000 = ~32,000 TPS |
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.