【问题标题】:SQL Server - GeographySQL Server - 地理
【发布时间】:2017-02-28 13:42:45
【问题描述】:

给定一个线串,如果我围绕所述线串的起点构造一个圆,我希望该圆与线串相交。

declare @startPoint geography = geography::Point(51.947859,3.986790,4326)
declare @endPoint geography = geography::Point(51.956383,3.995908,4326)
declare @g geography = geography::STGeomFromText('LINESTRING(51.947859 3.986790, 55.956383 3.995908)', 4326).MakeValid()  -- The linestring

select 
    @startPoint.STDistance(@endPoint) -- is 1136.88182010473 metres

declare @h geography = @startPoint.STBuffer(50) -- The Circle

select 
    @g.STIntersection(@h).STEndPoint().Long,@g.STIntersection(@h).STStartPoint().Long

select 
    @g.STIntersects(@h) -- Why is this false(0)?

我需要一些帮助来理解为什么圆和线串不相交。谢谢。

【问题讨论】:

    标签: sql-server tsql gis geography


    【解决方案1】:

    想通了。 当我将@startPoint 定义为:

    set  @startPoint = geography::Point(51.947859,3.986790,4326) 
    

    重点是:

    select @startpoint.ToString() -- result= POINT (3.98679 51.947859)
    

    当我将@startPoint 定义为:

    set @startPoint= geography::STGeomFromText('POINT(51.947859 3.986790)',4326) 
    

    作为文本的点是:

    select @startpoint.ToString() -- POINT (51.947859 3.98679)
    

    换句话说,第一种语法采用纬度,经度,而第二种语法采用经度,纬度。 第二种语法是要使用的一种。 无论是有意还是无意,这对开发人员来说简直就是一个陷阱。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多