1

我真的不知道该怎么办。。

DECLARE @g geography = geography::STGeomFromText('POLYGON((1 1, 3 1, 3 3, 1 3, 1 1))',4326)
DECLARE @g2 geography =geography::STGeomFromText( 'POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))',4326)
Declare @union  geography  =  @g2.STUnion(@g)   
Declare @diff  geography  =  @g2.STDifference(@g)   

SELECT @g.STArea() + @g2.STArea() - @union.STArea()

SELECT  @union.STArea()+@diff.STArea()

ret: "12306061878,1564" "123060620496,501" 找出 5 个不同点...

额外的:

 select @union.ToString()

ret

POLYGON ((0 2, 0 0, 2 0, 2.0000000000000591 1.0001522971041397, 3 1, 3 3, 1 3, 1.0000000000000655 2.0003044086154023, 0 2))
4

1 回答 1

0

我真的不明白你的问题。我的猜测是,您可能期望使用Geometry而不是提供的结果Geography

DECLARE @g geometry = geometry::STGeomFromText('POLYGON((1 1, 3 1, 3 3, 1 3, 1 1))',4326)
DECLARE @g2 geometry =geometry::STGeomFromText( 'POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))',4326)
Declare @union  geometry  =  @g2.STUnion(@g)   
Declare @diff  geometry  =  @g2.STDifference(@g)   

SELECT @g.STArea() + @g2.STArea() - @union.STArea()    
SELECT  @union.STArea()+@diff.STArea()
select @union.ToString()

返回:

POLYGON ((0 0, 2 0, 2 1, 3 1, 3 3, 1 3, 1 2, 0 2, 0 0))
于 2013-10-11T18:04:03.473 回答