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

Paul Ramsey pramsey at cleverelephant.ca
Mon Mar 30 09:42:37 PDT 2020


So in 2.x we could do 

'geojson'::text::geometry ? 

That seems... odd.

P

> On Mar 30, 2020, at 9:40 AM, rmrodriguez at carto.com wrote:
> 
> It contains a big polygon:
> ```
> [{"geomref" : "48061", "value" :
> {"type":"MultiPolygon","coordinates":[[[[-97.167369,26.413108], ... ,
> [-97.223544,26.411478],[-97.167369,26.413108]]]]}}]
> ```
> 
> It comes from a series of functions calls
> (https://github.com/CartoDB/observatory-extension/blob/6a063ca0eb33043f22e47171fc328aa50a6efc39/src/pg/sql/44_observatory_geometries.sql#L127)
> so I've tried to extract a smaller example that works with Postgis 2.5
> and it doesn't in 3.0 but I still haven't been able to.
> 
> Note that both 2.5 and 3.0 and running under PG12
> (https://travis-ci.org/github/CartoDB/observatory-extension/builds/668806964)
> so I'm discarding a change there. I'll share a smaller testable repro
> once I get it.
> 
> On Mon, Mar 30, 2020 at 5:58 PM Paul Ramsey <pramsey at cleverelephant.ca> wrote:
>> 
>> Wait, what? what is in 'value'?
>> 
>>> On Mar 30, 2020, at 8:56 AM, rmrodriguez at carto.com wrote:
>>> 
>>> I've been bitten by this today. This code used to work in Postgis 2.x:
>>> ```
>>> SELECT (data->0->>'value')::Geometry
>>> ```
>>> But it now requires to be called as:
>>> ```
>>> ST_GeomFromGeoJSON(data->0->>'value')
>>> ```
>>> 
>>> So I wouldn't be opposed to backporting this to 3.0 if it were to be
>>> implemented.
>>> 
>>> --
>>> Raúl Marín Rodríguez
>>> carto.com
>>> _______________________________________________
>>> postgis-devel mailing list
>>> postgis-devel at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/postgis-devel
>> 
>> _______________________________________________
>> postgis-devel mailing list
>> postgis-devel at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/postgis-devel
> 
> 
> 
> -- 
> Raúl Marín Rodríguez
> carto.com
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-devel



More information about the postgis-devel mailing list