# Rhumbe line (loxodrome) or Great Circle?? • ### Question

• 1) How are the lines between points in a polygon/linestring interpretated, will it be Rhumb line or Great Circle?

2) Is it possible (in the feature) to manipulate the behavour of a polygon/Linestring to use Rhumb line or Great Circle

3) Are calculations (STDistance/STIntersection/EnvelopeCenter) based on Great Circle?

Tuesday, July 22, 2008 6:57 PM

• Hi Eric,

For the geography type we use great circles.  (Well, actually, great elliptic arcs---I've written about this here.)  We use this definition for all calculations, including distances, areas, intersections, etc.

With geometry, we just use straight lines.  If you work with a Mercator projection, this means you'll get rhumb lines, but we're agnostic.

Cheers,
-Isaac
Tuesday, July 22, 2008 10:21 PM

### All replies

• Hi Eric,

For the geography type we use great circles.  (Well, actually, great elliptic arcs---I've written about this here.)  We use this definition for all calculations, including distances, areas, intersections, etc.

With geometry, we just use straight lines.  If you work with a Mercator projection, this means you'll get rhumb lines, but we're agnostic.

Cheers,
-Isaac
Tuesday, July 22, 2008 10:21 PM
• 1. In a polygoon or linestring, the only lines are those are part of the geometry. Are you asking "how is the distance between two polygons or linestrings computed?" That's great circle.

2. *anything* is possible. Connect (http://connect.microsoft.com) would be a great place to make that suggestion.

3. Distance and Interesection appear to be. Not sure about "EnvelopCenter," can you provide an example of what you mean by that (I'd assume Centroid but you know what they say about assumptions...)

Tuesday, July 22, 2008 10:36 PM
• Hi Isaac,

just to be informative.... The project we are working on is based on Mercator projection.

The problem I encounter is that I want to calculating if a polygons using rhumb lines (actually sea charts) intersects a linestring (the route of a vessel) with a buffer of 5 Nautical Miles.

If we didn't have to deal with the buffer, I could use the polygons in geometry, but sinds I'll have to deal with the buffer, I need geography.

The more you move the equator the more the distance will be between the same longitude values, and that means in geometry that you'll need to make the buffer more widther if you come close to the equator (y=0)

hmmmm.....wait en let's play a little bit.....

I think I'll use geometry, make my own buffer for the linestring and should do the job that way....

(I'll still have to work around polygons (of sea charts) and  lines (routes) that are covering the date border)

I haven't test the code but I think this will create (after debugging) a raw buffer (I hope):

declare @lat1 float,@lon1 float,@lat2 float,@lon2 float,@buffer float

-- Set coordinated for the route

set @lat1 = 0

set @lon1 = 0

set @lat2 = 50

set @lon2 = 50

set @buffer = 5 -- distance in KM

declare @P1 nvarchar(20),@P2 nvarchar(20),@P3 nvarchar(20),@P4 nvarchar(20),@P5 nvarchar(20),@P6 nvarchar(20),@brng float

declare @RouteWithbuffer nvarchar(180)

--Calculate Bearing

declare @dLon float,@dPhi float

IF ABS(@dLon) > PI()

BEGIN

if @dLon>0

set @dLon = -(2*PI()-@dLon)

else

set @dLon = (2*PI()+@dLon)

END

set @brng = ATN2(@dLon, @dPhi)

set @P1 = Exec destPoint @Lon1, @Lat1, (@brng+90), @buffer

set @P2 = Exec destPoint @Lon1,@Lat1,(@brng+180),@buffer

set @P3 = Exec destPoint @Lon1,@Lat1,(@brng+270),@buffer

set @P4 = Exec destPoint @Lon2,@Lat2,(@brng+270),@buffer

set @P5 = Exec destPoint @Lon2,@Lat2,(@brng+180),@buffer

set @P6 = Exec destPoint @Lon2,@Lat2,(@brng+90),@buffer

set @RouteWithbuffer = 'Polygon(('+@P1 + ', '+@P2 + ', '+@P3 + ', '+@P4 + ', '+@P5 + ', '+@P6 +', '+@P1 + '))'

Code for procedure destPoint

ALTER PROCEDURE [dbo].[destPoint]

-- Add the parameters for the stored procedure here

@lon float,

@lat float,

@brng float,

@d float

AS

BEGIN

declare @R int

set @R = 6371 -- earth's mean radius in km

declare @lat1 float, @lon1 float

declare @brng1 float

declare @lon2 float,@lat2 float

set @lat2 = asin( sin(@lat1)*cos(@d/@R) + cos(@lat1)*sin(@d/@R)*cos(@brng1) )

set @lon2 = @lon1 + atn2(sin(@brng1)*sin(d/@R)*cos(@lat1), cos(@d/@R)-sin(@lat1)*sin(@lat2))

set @lon2 = (@lon2+PI())%(2*PI()) - PI()

return CAST(lat2 AS NVARCHAR) + ' ' + CAST(lon2 AS NVARCHAR

END

Wednesday, July 23, 2008 10:14 AM
• Hi Eric,

Interesting application.  Let me encourage you to follow Kent's advice and file an issue through Connect.  One thing we're considering for the next round is support for curves other than straight lines (w/ geometry) and great circles (w/ geography).  This definitely falls in that bucket of work, but isn't something I'd thought of before.

Cheers,
-Isaac
Wednesday, July 23, 2008 4:03 PM
• Suggestion is posted through connect.....

Thanks both to point me in the right direction.

Wednesday, July 23, 2008 6:48 PM