pg_eviltransform
pg_eviltransform
pg_eviltransform : Coordinate transforms for BD09/GCJ02 via PostGIS ST_Transform
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 1580 | pg_eviltransform
|
pg_eviltransform
|
0.0.2 |
GIS
|
MIT
|
Rust
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r
|
No
|
Yes
|
No
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| Schemas | eviltransform_internal |
| Requires | postgis
|
| See Also | postgis
pgrouting
pg_geohash
h3
q3c
earthdistance
tzf
geoip
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
0.0.2 |
18
17
16
15
14
|
pg_eviltransform |
postgis |
| RPM | PIGSTY
|
0.0.2 |
18
17
16
15
14
|
pg_eviltransform_$v |
postgis36_$v |
| DEB | PIGSTY
|
0.0.2 |
18
17
16
15
14
|
postgresql-$v-eviltransform |
postgresql-$v-postgis |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
el8.aarch64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
el9.x86_64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
el9.aarch64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
el10.x86_64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
el10.aarch64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
d12.x86_64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
d12.aarch64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
d13.x86_64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
d13.aarch64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
u22.x86_64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
u22.aarch64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
u24.x86_64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
u24.aarch64
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
PIGSTY 0.0.2
|
Source
pig build pkg pg_eviltransform; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_eviltransform; # install via package name, for the active PG version
pig install pg_eviltransform -v 18; # install for PG 18
pig install pg_eviltransform -v 17; # install for PG 17
pig install pg_eviltransform -v 16; # install for PG 16
pig install pg_eviltransform -v 15; # install for PG 15
pig install pg_eviltransform -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION pg_eviltransform CASCADE; -- requires postgisUsage
pg_eviltransform: Coordinate transform between WGS84, GCJ02, and BD09
pg_eviltransform extends PostGIS ST_Transform with BD09/GCJ02 support for Chinese coordinate systems. It exposes ST_EvilTransform with the same overload interface as ST_Transform.
Custom SRIDs:
990001: GCJ02990002: BD09
Functions
ST_EvilTransform(geometry, to_srid integer)
ST_EvilTransform(geometry, to_proj text)
ST_EvilTransform(geometry, from_proj text, to_srid integer)
ST_EvilTransform(geometry, from_proj text, to_proj text)If neither side uses custom coordinates, it delegates directly to ST_Transform. If BD09/GCJ02 is involved, it transforms via WGS84 (4326) when needed.
Examples
-- WGS84 to GCJ02 using text literal
SELECT ST_EvilTransform(ST_SetSRID('POINT(120 30)'::geometry, 4326), 'GCJ02');
-- WGS84 to BD09 using text literal
SELECT ST_EvilTransform(ST_SetSRID('POINT(120 30)'::geometry, 4326), 'BD09');
-- WGS84 to GCJ02 using numeric SRID
SELECT ST_EvilTransform(ST_SetSRID('POINT(120 30)'::geometry, 4326), 990001);
-- BD09 to Web Mercator
SELECT ST_EvilTransform(
ST_SetSRID('POINT(120.011070620552 30.0038830555128)'::geometry, 990002), 3857
);
-- from_proj / to_proj overload
SELECT ST_EvilTransform('POINT(120 30)'::geometry, 'EPSG:4326', 'GCJ02');Performance
On PG18 with 200,000 rows, ST_EvilTransform is ~30-45x faster than the regex-based SQL approach.
Last updated on