You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NetTopologySuite与SqlGeography空间交集结果差异大的原因排查

为何NetTopologySuite与Microsoft.SqlServer.Types的空间交集结果差异显著?

我已按照建议修改了多边形,现在得到的是LineString而非MultiLineString,但坐标差异仍与之前一致。

我正在对比两款空间数据处理库NetTopologySuite与Microsoft.SqlServer.Types(SqlGeography),发现相同输入下两者输出结果差异显著。

Microsoft.SqlServer.Types 测试代码与结果

// 纽约到巴黎的线
SqlGeography line = SqlGeography.STLineFromText(new System.Data.SqlTypes.SqlChars("LINESTRING(-73.935242 40.730610, 2.349014 48.864716)"), 4326);

// 大西洋区域的多边形
SqlGeography polygon = SqlGeography.STPolyFromText(new System.Data.SqlTypes.SqlChars("POLYGON((-40 60,  -40 30, -20 30, -20 60, -40 60))"), 4326);

SqlGeography intersection = line.STIntersection(polygon);

交集结果:

{LINESTRING (-19.99999999999997 52.21038270929611, -39.99999999999993 51.451383473748834)}

NetTopologySuite 测试代码与结果

var polygonText = "POLYGON((-40 60,  -40 30, -20 30, -20 60, -40 60))";
string lineText = "LINESTRING(-73.935242 40.730610, 2.349014 48.864716)";
var rdr = new NetTopologySuite.IO.WKTReader();
var geometryPolygon = rdr.Read(polygonText);
var geometryLine = rdr.Read(lineText);

var polygon =  _geometryFactory.CreatePolygon(geometryPolygon.Coordinates);
var line = _geometryFactory.CreateLineString(geometryLine.Coordinates);

var intersects = line.Intersection(polygon);

交集结果:

{LINESTRING (-40 44.34908739019244, -20 46.48166531033365)}

请问为何两款库的空间交集结果存在如此大的差异?


内容的提问来源于stack exchange,提问作者Q-bertsuit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 05:05:20