SQL Server提供了一些
aggregate methods on geometries
,包括UnionAggregate和CollectionAggregate,它们在两种以上的形状上运行。
从
UnionAggregate
例子:
-- Setup table variable for UnionAggregate example
DECLARE @Geom TABLE
(
shape geometry,
shapeType nvarchar(50)
);
INSERT INTO @Geom(shape,shapeType)
VALUES
('CURVEPOLYGON(CIRCULARSTRING(2 3, 4 1, 6 3, 4 5, 2 3))', 'Circle'),
('POLYGON((1 1, 4 1, 4 5, 1 5, 1 1))', 'Rectangle');
-- Perform UnionAggregate on @Geom.shape column
SELECT geometry::UnionAggregate(shape).ToString()
FROM @Geom;
这就产生了
CURVEPOLYGON (COMPOUNDCURVE (
(1 1, 4 1, 4.0000000000000071 1.0000000000000218),
CIRCULARSTRING (4.0000000000000071 1.0000000000000218,
5.4142135623730905 1.5857864376269268,
6 3,
5.4142135623730905 4.4142135623730905,
4.0000000000000071 4.9999999999999947),
(4.0000000000000071 4.9999999999999947, 1 5, 1 1))
)