2016-06-08 15 views

Antwort

0

Ich habe keine Ahnung, wie gut das in der Praxis funktionieren wird, aber es kann nur mit eingebauten Funktionen erfolgen.

DECLARE @Distance INT = 10000 
DECLARE @latitude DECIMAL(20,10) = 51.5001524 
DECLARE @longitude DECIMAL(20,10) = -0.1262362 
DECLARE @OriginalPoint GEOGRAPHY = GEOGRAPHY::Point(@latitude, @longitude, 4326) 
--This will create a point at the same longitude but at the south pole. 
DECLARE @DueSouthPoint GEOGRAPHY = GEOGRAPHY::Point(-90, @longitude, 4326) 

DECLARE @SouthLineWithLengthOfDistance GEOGRAPHY = 
    @OriginalPoint.ShortestLineTo(@DueSouthPoint) --This is a line due south 
    .STIntersection(        --This will return the line segment inside the circle 
    @OriginalPoint.STBuffer(@distance)   --This will draw a circle around the original point with a radius of @distance 
)         

    --Now we have to return the lower point on the line. 
    --It seems to be fairly inconsistent in which point is first in the line 
    --I don't want to spend the time to figure it out, so I'm just using a case to determine which point to return. 
    SELECT 
    CASE 
     WHEN @OriginalPoint.STDistance(@SouthLineWithLengthOfDistance.STPointN(1)) = 0 
      THEN @SouthLineWithLengthOfDistance.STPointN(2) 
     ELSE @SouthLineWithLengthOfDistance.STPointN(1) 
    END