Nota
O acesso a esta página requer autorização. Pode tentar iniciar sessão ou alterar os diretórios.
O acesso a esta página requer autorização. Pode tentar alterar os diretórios.
Aplica-se a:SQL Server
Azure SQL Database
Azure SQL Managed Instance
Endpoint de análise SQL no Microsoft Fabric
Armazém no Microsoft Fabric
Base de dados SQL no Microsoft Fabric
Uma GeometryCollection é uma coleção de zero ou mais de instâncias de geometria ou geografia. Uma GeometryCollection pode estar vazia.
Instâncias da GeometryCollection
Instâncias aceitadas
Para que uma instância GeometryCollection seja aceita, ela deve ser uma instância GeometryCollection vazia ou todas as instâncias que compõem a instância GeometryCollection devem ser instâncias aceitas. O exemplo seguinte apresenta exemplos aceites.
DECLARE @g1 geometry = 'GEOMETRYCOLLECTION EMPTY';
DECLARE @g2 geometry = 'GEOMETRYCOLLECTION(LINESTRING EMPTY,POLYGON((-1 -1, -1 -5, -5 -5, -5 -1, -1 -1)))';
DECLARE @g3 geometry = 'GEOMETRYCOLLECTION(LINESTRING(1 1, 3 5),POLYGON((-1 -1, -1 -5, -5 -5, -5 -1, -1 -1)))';
O exemplo a seguir lança um System.FormatException porque a instância LinesString na instância GeometryCollection não é aceita.
DECLARE @g geometry = 'GEOMETRYCOLLECTION(LINESTRING(1 1), POLYGON((-1 -1, -1 -5, -5 -5, -5 -1, -1 -1)))';
Instâncias válidas
Uma instância GeometryCollection é válida quando todas as instâncias que compõem a instância GeometryCollection são válidas. A seguir mostra três instâncias GeometryCollection válidas e uma instância que não é válida.
DECLARE @g1 geometry = 'GEOMETRYCOLLECTION EMPTY';
DECLARE @g2 geometry = 'GEOMETRYCOLLECTION(LINESTRING EMPTY,POLYGON((-1 -1, -1 -5, -5 -5, -5 -1, -1 -1)))';
DECLARE @g3 geometry = 'GEOMETRYCOLLECTION(LINESTRING(1 1, 3 5),POLYGON((-1 -1, -1 -5, -5 -5, -5 -1, -1 -1)))';
DECLARE @g4 geometry = 'GEOMETRYCOLLECTION(LINESTRING(1 1, 3 5),POLYGON((-1 -1, 1 -5, -5 5, -5 -1, -1 -1)))';
SELECT @g1.STIsValid(), @g2.STIsValid(), @g3.STIsValid(), @g4.STIsValid();
@g4 não é válido porque a instância Polygon na instância GeometryCollection não é válida.
Para obter mais informações sobre instâncias aceitas e válidas, consulte Point, MultiPoint, LineString, MultiLineString, Polygon e MultiPolygon.
Example
O exemplo a seguir instancia um geometryGeometryCollection com valores Z em SRID 1 contendo uma Point instância e uma Polygon instância.
DECLARE @g geometry;
SET @g = geometry::STGeomCollFromText('GEOMETRYCOLLECTION(POINT(3 3 1), POLYGON((0 0 2, 1 10 3, 1 0 4, 0 0 2)))', 1);