jfgodoy / knex-postgis

postgis extension for knex
MIT License
183 stars 25 forks source link

geomFromGeoJSON not working with GeometryCollection ? #53

Closed IdoiaWildsense closed 2 years ago

IdoiaWildsense commented 2 years ago

Hi,

I'm new to postgis, and I'm using it with AdonisJs. I'm trying the method geomFromGeoJSON and the following :

{ "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [100.0, 0.0] }, { "type": "LineString", "coordinates": [ [101.0, 0.0], [102.0, 1.0] ] } ] }

taken from there : https://docs.teradata.com/r/Teradata-Database-JSON-Data-Type/June-2017/JSON-Functions-and-Operators/GeomFromGeoJSON/Examples-GeomFromGeoJSON

All the other Geometry examples are working, but with GeometryCollection i'm getting this error :

Unable to find 'geometries' in GeoJSON string

I'm wondering why this example doesnt work ?

Putting the json in another column, and using geomFromGeoJSON(colName) works, but not putting the json directly in geomFromGeoJSON.

I hope this can help

Thanks !

jfgodoy commented 2 years ago

hi @IdoiaWildsense, thank you very much for the report. I just realease a new version that fixes the problem. Your example is right, I wasn't handling this case correctly.