|
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 |
|
+------+
|
|