Geometry 如何在SQL Server中填补多多边形中的空白

Geometry 如何在SQL Server中填补多多边形中的空白,geometry,sql-server-2014,spatial,computational-geometry,Geometry,Sql Server 2014,Spatial,Computational Geometry,使用SQL Server 2014 我有下面的自相交几何体,我使用.MakeValid()使其有效,它给出了一个多多边形 declare @geomOrig geometry select @geomOrig = geometry::STGeomFromText('POLYGON((705768.86 6193250.0725,705646.46 6193139.6725,705848.06 6193169.2725,705636.06 6193237.2725,705784.06 619310

使用SQL Server 2014

我有下面的自相交几何体,我使用.MakeValid()使其有效,它给出了一个多多边形

declare @geomOrig geometry
select @geomOrig = geometry::STGeomFromText('POLYGON((705768.86 6193250.0725,705646.46 6193139.6725,705848.06 6193169.2725,705636.06 6193237.2725,705784.06 6193102.0725,705768.86 6193250.0725))', 25832).MakeValid()
select @geomOrig


问题是:如何填充中间的间隙来创建一个单一的星形多边形?

< P> >我知道一种方式引入了一个错误(基于投影的0.0000001个单位)如下所示。它确实会生成您正在寻找的单个多边形星。我删除了原始文件中的十进制值,以便查看引入了多少错误

DECLARE @geomOrig GEOMETRY, @geomText VARCHAR(MAX), @geomOuterPoly GEOMETRY
SELECT @geomOrig = geometry::STGeomFromText('POLYGON((705768 6193250,705646 6193139,705848 6193169,705636 6193237,705784 6193102,705768 6193250))', 25832).MakeValid()

-- buffer the existing polygons by a small amount to join them into one polygon and get the exterior ring (LINESTRING)
SET @geomOuterPoly = @geomOrig.STBuffer(0.0000001).STExteriorRing()

-- get the WKT of the buffered polygon
SET @geomText = @geomOuterPoly.STAsText()

-- replace the word 'LINESTRING' with 'POLYGON' and add an extra parenthese
SET @geomText = REPLACE(@geomText, 'LINESTRING', 'POLYGON')
SET @geomText = REPLACE(@geomText, '(', '((')
SET @geomText = REPLACE(@geomText, ')', '))')

-- build a new geometry from the text
SET @geomOuterPoly = geometry::STGeomFromText(@geomText, 25832)

-- unbuffer the polygon to get back down to the previous shape (small amount of error introduced here)
SET @geomOuterPoly = @geomOuterPoly.STBuffer(-0.0000001)

-- select the final polygon
SELECT @geomOuterPoly

工作完美。这似乎也适用于类似的数字。