空间查询bug?

irq001 2019-01-17 04:55:03
sql server2014版本,脚本如下:



declare @geo1 geography;
declare @geo2 geography;
declare @location geography;

set @geo1 = geography::Parse('POLYGON ((123.398815 41.745468, 123.404743 41.747406, 123.408013 41.739925, 123.400863 41.740544, 123.400827 41.740544, 123.398815 41.745468, 123.398815 41.745468))');
set @geo2 = geography::Parse('POLYGON ((123.43333 41.762615, 123.435755 41.76392, 123.440948 41.763315, 123.43854 41.7594, 123.43333 41.762615, 123.43333 41.762615))');
set @location = geography::Parse('POINT (123.415183 41.756125)');

select @location.STIntersects(@geo1), @location.STIntersects(@geo2);
select @geo1.STIntersects(@location), @geo2.STIntersects(@location);
select @geo1.STContains(@location), @geo2.STContains(@location);


查询结果均为相交:


但用openlayers将2个区域和定位点结果绘制如下:


请问这种情况是啥原因造成的?怎么解决?

...全文
322 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
唐诗三百首 2019-01-26
  • 打赏
  • 举报
回复
Try this,

declare @geo1 geography;
declare @geo2 geography;
declare @location geography;

set @geo1 = geography::Parse('POLYGON ((123.398815 41.745468, 123.404743 41.747406, 123.408013 41.739925, 123.400863 41.740544, 123.400827 41.740544, 123.398815 41.745468, 123.398815 41.745468))');
set @geo2 = geography::Parse('POLYGON ((123.43333 41.762615, 123.435755 41.76392, 123.440948 41.763315, 123.43854 41.7594, 123.43333 41.762615, 123.43333 41.762615))');
set @location = geography::Parse('POINT (123.415183 41.756125)');

set @geo1 = @geo1.ReorientObject();
set @geo2 = @geo2.ReorientObject();

select @location.STIntersects(@geo1), @location.STIntersects(@geo2);
select @geo1.STIntersects(@location), @geo2.STIntersects(@location);
select @geo1.STContains(@location), @geo2.STContains(@location);
fxcl2006 2019-01-17
  • 打赏
  • 举报
回复
追加信息:
奇怪的是,两个地理对象区域显示结果都如下图所示

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧