[postgis-devel] Cast GeoJSON to geometry like with WKT

Felix Kunde felix-kunde at gmx.de
Fri Mar 6 01:50:18 PST 2020


Hey there,
 
maybe there's already an open issue/ticket for this - did not search that long. So sorry just in case.
 
I'm happy about the new geometry::jsonb cast feature, but just found out that it breaks my audit trail software where I log changes as JSONB.
One feature is to restore previous versions, so transferring the JSONB logs back to their relational counterparts with jsonb_populate_record function.
 
Before, this was no problem as the WKB ended up in JSONB and could be reused to create PostGIS geometries.
But with the new behavior, I can only use ST_GeomFromGeoJSON if I'm not mistaken.
It would be nice if there would be a more "native" way, e.g. like what we have for WKT where I can write 'POINT(1 1)'::geometry.

So something like: SELECT '{"type":"Point","coordinates":[1,1]}'::geometry

I'm not 100% sure if this would solve my problem ^^
Is it something you like to have and think it's possible?
I might try to implement, if you think it's shouldn't be too hard.

Kind regards
Felix

PS: Btw, was there ever a discussion to do WKB::text = WKT? :)


More information about the postgis-devel mailing list