Skip to content

[#61] Accept SRIDs as args to ST_Transform #62

Merged
jiayuasu merged 6 commits intoapache:mainfrom
jesspav:srid
Sep 12, 2025
Merged

[#61] Accept SRIDs as args to ST_Transform #62
jiayuasu merged 6 commits intoapache:mainfrom
jesspav:srid

Conversation

@jesspav
Copy link
Collaborator

@jesspav jesspav commented Sep 11, 2025

Currently, ST_Transform is only accepting utf8 args.
This change allows for SRIDs to be passed in as ints. It also adds some better argument checks.

Issue: #61

I tried going through a CRS and passing the to_json() output as the CRS args to the transform, but proj was failing to parse the json. I'll need to figure that out separately, but accepting the SRID seemed like a P0 issue, so fixing that first.

Testing

Unit tests and manual tests.

Examples

> SELECT ST_Transform(ST_SetSrid(ST_GeomFromText('POINT (1 1)'), 4326), 3857) as geom;
┌─────────────────────────────────────────────┐
│                     geom                    │
│                   geometry                  │
╞═════════════════════════════════════════════╡
│ POINT(111319.49079327357 111325.1428663851) │
└─────────────────────────────────────────────┘

> SELECT ST_Transform(ST_SetSrid(ST_GeomFromText('POINT (1 1)'), 4326), 'EPSG:3857') as geom;
┌─────────────────────────────────────────────┐
│                     geom                    │
│                   geometry                  │
╞═════════════════════════════════════════════╡
│ POINT(111319.49079327357 111325.1428663851) │
└─────────────────────────────────────────────┘

@paleolimbot
Copy link
Member

but proj was failing to parse the json. I'll need to figure that out separately, but accepting the SRID seemed like a P0 issue, so fixing that first.

Agreed!

I think what's happening is that AuthorityCode::to_json() spits out "EPSG:1234" (with the quotes), and perhaps PROJ was expecting EPSG:1234 (no quotes). The way in this PR is great too!

@jesspav jesspav marked this pull request as ready for review September 12, 2025 16:40
Copy link
Member

@paleolimbot paleolimbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@jiayuasu jiayuasu merged commit b380e30 into apache:main Sep 12, 2025
12 checks passed
@jesspav jesspav deleted the srid branch November 14, 2025 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants