[postgis-devel] JSON Fn Name

Regina Obe lr at pcorp.us
Fri Apr 19 05:23:54 PDT 2019


> -----Original Message-----
> From: postgis-devel [mailto:postgis-devel-bounces at lists.osgeo.org] On
> Behalf Of Sandro Santilli
> Sent: Friday, April 19, 2019 6:42 AM
> To: PostGIS Development Discussion <postgis-devel at lists.osgeo.org>
> Subject: Re: [postgis-devel] JSON Fn Name
> 
> On Thu, Apr 18, 2019 at 12:06:07PM -0700, Paul Ramsey wrote:
> > Quick temperature-of-the-room
> >
> > ST_AsGeoJSON(record)
> >
> > or
> >
> > row_to_geojson(record)
> >
> > The latter apes the existing pgsql json pattern row_to_json().
> 
> I'd like if the pgsql json converter would allow specifying "canonical forms",
> like it is for TEXT and BINARY (text and bitea outputs).
> 
> Is there any chance such a thing exists or we can at least suggest it upstream
> ? If that was possible, we'd just rely on `row_to_json` and that function
> would do the right thing when facing geometries, does that sound possible in
> theory or am I missing some specific characteristics of a "geojson" ?
> 
> --strk;
[Regina Obe] 
You are missing something -- the geosjon spec says non-geometry things go into a 
Properties subattribute so  row_to_json or row_to_jsonb would never work to give you a geojson row.
http://geojson.org/

I had assumed from pramsey's last blog entry he was moving towards that and ultimately 
a feature collection which is way more useful than a row in my opinion and a bit more clearer in purpose as people not knowing about the geojson spec would assume what you assumed. http://blog.cleverelephant.ca/2019/03/geojson.html

That said let's stay away from aping the PostgreSQL api

As its way too easy for people to get confused by the fact it's off by a few letters.

If you are building your own api, you may not want a GeoJSON and DO WANT a row_to_json (with a geometry formulated as a geojson).

Way back when I looked into what you were describing about canonical forms, I know I asked Andrew Dunstan who was leading the JSON work.  I forget what he said something about the data types being hard-coded or something -- it wasn't possible back then in 9.2/9.3 but I recall changes being made that would make it possible now.





More information about the postgis-devel mailing list