您是否设法 运行 STBuffer on MULTIPOLYGONS ?使用 SQL 服务器?
Did you manage to run STBuffer on MULTIPOLYGONS ? With SQL Server?
在 SQL 服务器地理空间中,我无法 运行 STBuffer
用于 MULTIPOLYGONS
。
DECLARE @g geography = geography::STMPolyFromText('MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)),((1 1, 3 1, 3 3, 1 1)))', 4326);
SELECT @g -- no problem to run
SELECT @g.ToString() -- no problem to run
SELECT @g.STBuffer(1).ToString(); -- error
返回的错误是:
Msg 6522, Level 16, State 1, Line 64
A .NET Framework error occurred during execution of user-defined
routine or aggregate "geography":
System.ArgumentException: 24144: This operation cannot be completed
because the instance is not valid. Use MakeValid to convert the
instance to a valid instance. Note that MakeValid may cause the points
of a geometry instance to shift slightly. System.ArgumentException:
我认为这是因为您创建的多边形无效 geography
多边形。尝试使用一组有效的 Latitude/Longitude 值创建多边形。
使用 geometry
数据类型执行相同的代码似乎可行。
DECLARE @g geometry = geometry::STMPolyFromText('MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)),((1 1, 3 1, 3 3, 1 1)))', 4326);
select
geoMultiPolys = @g,
geoMultiPolysString = @g.ToString(),
buffered = @g.STBuffer(1),
bufferedString = @g.STBuffer(1).ToString(),
IsValid = @g.STIsValid()
同样适用于地理
DECLARE @g geography = geography::STMPolyFromText('MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20)))', 4326);
select
geoMultiPolys = @g,
geoMultiPolysString = @g.ToString(),
buffered = @g.STBuffer(1),
bufferedString = @g.STBuffer(1).ToString(),
IsValid = @g.STIsValid()
在 SQL 服务器地理空间中,我无法 运行 STBuffer
用于 MULTIPOLYGONS
。
DECLARE @g geography = geography::STMPolyFromText('MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)),((1 1, 3 1, 3 3, 1 1)))', 4326);
SELECT @g -- no problem to run
SELECT @g.ToString() -- no problem to run
SELECT @g.STBuffer(1).ToString(); -- error
返回的错误是:
Msg 6522, Level 16, State 1, Line 64
A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":System.ArgumentException: 24144: This operation cannot be completed because the instance is not valid. Use MakeValid to convert the instance to a valid instance. Note that MakeValid may cause the points of a geometry instance to shift slightly. System.ArgumentException:
我认为这是因为您创建的多边形无效 geography
多边形。尝试使用一组有效的 Latitude/Longitude 值创建多边形。
使用 geometry
数据类型执行相同的代码似乎可行。
DECLARE @g geometry = geometry::STMPolyFromText('MULTIPOLYGON(((1 1, 1 -1, -1 -1, -1 1, 1 1)),((1 1, 3 1, 3 3, 1 1)))', 4326);
select
geoMultiPolys = @g,
geoMultiPolysString = @g.ToString(),
buffered = @g.STBuffer(1),
bufferedString = @g.STBuffer(1).ToString(),
IsValid = @g.STIsValid()
同样适用于地理
DECLARE @g geography = geography::STMPolyFromText('MULTIPOLYGON (((40 40, 20 45, 45 30, 40 40)), ((20 35, 10 30, 10 10, 30 5, 45 20, 20 35), (30 20, 20 15, 20 25, 30 20)))', 4326);
select
geoMultiPolys = @g,
geoMultiPolysString = @g.ToString(),
buffered = @g.STBuffer(1),
bufferedString = @g.STBuffer(1).ToString(),
IsValid = @g.STIsValid()