[英]Did you manage to run STBuffer on MULTIPOLYGONS ? With SQL Server?
In SQL Server geo-spatial I can't run a STBuffer
for MULTIPOLYGONS
. 在SQL Server地理空间中,我无法为
MULTIPOLYGONS
运行STBuffer
。
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
The error returned is: 返回的错误是:
Msg 6522, Level 16, State 1, Line 64
消息6522,第16层,状态1,第64行
A .NET Framework error occurred during execution of user-defined routine or aggregate "geography":在执行用户定义的例程或聚合“地理位置”期间发生.NET Framework错误:
System.ArgumentException: 24144: This operation cannot be completed because the instance is not valid.
System.ArgumentException:24144:由于实例无效,因此无法完成此操作。 Use MakeValid to convert the instance to a valid instance.
使用MakeValid将实例转换为有效实例。 Note that MakeValid may cause the points of a geometry instance to shift slightly.
请注意,MakeValid可能会导致几何实例的点稍微移动。 System.ArgumentException:
System.ArgumentException:
I think this is happening because the polygons you are creating are not valid geography
polygons. 我认为发生这种情况是因为您创建的多边形不是有效的
geography
多边形。 Try creating the Multi Polygons using a valid set of Latitude/Longitude values. 尝试使用一组有效的纬度/经度值创建“多边形”。
Executing the same code with geometry
data type seems to work. 用
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()
Similarly this one works for geography 同样,这是针对地理的作品
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.