In the postgis documentation it's mentioned that ST_collect returns a MULTI* or a GEOMETRYCOLLECTION. But how can i force the function to only return a geometrycollection not depending on it's input argument.
For Example: I have a postegreSQL database with a column of type GeometryCollection. And it should store geometries wich a user has drawn. This can by any combination of geometries of points, lines, polygons etc.. If the combination is a point a line and a polygon ST_collect returns a GeometryCollection. But if the combination is two polygons it returns a MultiPolygon. Is it possible that ST_collect returns only GeometryCollections even if the input is a single polygon?
SELECT ST_AsText(ST_Collect(ST_GeomFromGeoJSON(feat->>'geometry')))FROM ( SELECT json_array_elements('{ "type":"FeatureCollection", "features":[ { "type":"Feature", "properties":{ }, "geometry":{ "type":"Polygon", "coordinates":[ [ [ 14.845962524414062, 46.96830518448586 ], [ 14.845962524414062, 47.02309964439266 ], [ 14.976425170898438, 47.02309964439266 ], [ 14.976425170898438, 46.96830518448586 ], [ 14.845962524414062, 46.96830518448586 ] ] ] } } ]}'::json->'features') AS feat) as f;
أكثر...
For Example: I have a postegreSQL database with a column of type GeometryCollection. And it should store geometries wich a user has drawn. This can by any combination of geometries of points, lines, polygons etc.. If the combination is a point a line and a polygon ST_collect returns a GeometryCollection. But if the combination is two polygons it returns a MultiPolygon. Is it possible that ST_collect returns only GeometryCollections even if the input is a single polygon?
SELECT ST_AsText(ST_Collect(ST_GeomFromGeoJSON(feat->>'geometry')))FROM ( SELECT json_array_elements('{ "type":"FeatureCollection", "features":[ { "type":"Feature", "properties":{ }, "geometry":{ "type":"Polygon", "coordinates":[ [ [ 14.845962524414062, 46.96830518448586 ], [ 14.845962524414062, 47.02309964439266 ], [ 14.976425170898438, 47.02309964439266 ], [ 14.976425170898438, 46.96830518448586 ], [ 14.845962524414062, 46.96830518448586 ] ] ] } } ]}'::json->'features') AS feat) as f;
أكثر...