[MDEV-11882] Support for GeometryCollection in GeoJSON Created: 2017-01-23  Updated: 2017-11-10  Resolved: 2017-11-10

Status: Closed
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2
Fix Version/s: 10.2.11

Type: Bug Priority: Major
Reporter: Andrii Nikitin (Inactive) Assignee: Alexey Botchkov
Resolution: Cannot Reproduce Votes: 0
Labels: None

Sprint: 10.2.11

 Description   

GeometryCollection is valid Geometry object:

MariaDB [(none)]> select st_astext(st_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))'));
+-------------------------------------------------------------------------------------+
| st_astext(st_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')) |
+-------------------------------------------------------------------------------------+
| GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))                                |
+-------------------------------------------------------------------------------------+

GeoJson should handle it , e.g. with query:

SELECT length(st_astext(st_geomfromgeojson('
{
    "type": "GeometryCollection",
    "geometries": [
        {
            "type": "Point",
            "coordinates": [0,0]
        },
        {
            "type": "LineString",
            "coordinates": [[0,0],[10,10]]
        }
    ]
}'))) as a;

MariaDB [(none)]> SELECT length(st_astext(st_geomfromgeojson('
    '> {
    '>     "type": "GeometryCollection",
    '>     "geometries": [
    '>         {
    '>             "type": "Point",
    '>             "coordinates": [0,0]
    '>         },
    '>         {
    '>             "type": "LineString",
    '>             "coordinates": [[0,0],[10,10]]
    '>         }
    '>     ]
    '> }'))) as a;
+------+
| a    |
+------+
| NULL |
+------+

MySQL 5.7 handles it properly

mysql> SELECT length(st_astext(st_geomfromgeojson('
    '> {
    '>     "type": "GeometryCollection",
    '>     "geometries": [
    '>         {
    '>             "type": "Point",
    '>             "coordinates": [0,0]
    '>         },
    '>         {
    '>             "type": "LineString",
    '>             "coordinates": [[0,0],[10,10]]
    '>         }
    '>     ]
    '> }'))) as a;
+------+
| a    |
+------+
|   52 |
+------+


Generated at Thu Feb 08 07:53:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.