简体   繁体   中英

SQL Server Geography Data Type - Please tell me why two separate Polygons Intersect ? I don't see it

I have two geometry variables and I want to find out if they intersect.

My first variable is called @orderBounds2.

DECLARE @orderBounds2 geography

I set it to a value

 set @orderBounds2 = 0xE6100000010405000000B81E85EB51F837C07CF2B0506B3A40C0B81E85EB51F837C01283C0CAA1955C4097900F7A363343401283C0CAA1955C4097900F7A363343407CF2B0506B3A40C0B81E85EB51F837C07CF2B0506B3A40C001000000020000000001000000FFFFFFFF0000000003;

I look to see what it is in text.

select   @orderBounds2.STAsText() --POLYGON ((-32.4564 -23.97, 114.338 -23.97, 114.338 38.4001, -32.4564 38.4001, -32.4564 -23.97))

My 2nd variable is @geo

declare @geo geography

I set it to a value.

select @geo = 0xE6100000010405000000A228D027F2C6514033F9669B1B034B40CDCCCCCCCC4C514033F9669B1B034B40CDCCCCCCCC4C51400000000000404F40A228D027F2C651400000000000404F40A228D027F2C6514033F9669B1B034B4001000000020000000001000000FFFFFFFF0000000003;

I look to see what it is in text.

select @geo.STAsText() --POLYGON ((54.02428 71.10853, 54.02428 69.2, 62.5 69.2, 62.5 71.10853, 54.02428 71.10853))

Now I want to find out if the polygons that my two variables represent intersect?

select @geo.STIntersects(@orderBounds2)  --= 1

The answer is 1, so yes the two areas do intersect.

However, I don't understand why. The polygons in text show (longitude.latitude) points and I cannot see how they intersect.

The 2nd Polygon is between latitude 69.2 and 71.1
The 1st Polygon is between latitude -23.4 and 38.4

Hope you can help.

The edges of a geography polygon follow great circle arcs, so the segment from 114.338 38.4001 to -32.4564 38.4001 goes very far north.

  DECLARE @orderBounds2 geography = cast(0xE6100000010405000000B81E85EB51F837C07CF2B0506B3A40C0B81E85EB51F837C01283C0CAA1955C4097900F7A363343401283C0CAA1955C4097900F7A363343407CF2B0506B3A40C0B81E85EB51F837C07CF2B0506B3A40C001000000020000000001000000FFFFFFFF0000000003 as geography)
    declare @geo geography = cast( 0xE6100000010405000000A228D027F2C6514033F9669B1B034B40CDCCCCCCCC4C514033F9669B1B034B40CDCCCCCCCC4C51400000000000404F40A228D027F2C651400000000000404F40A228D027F2C6514033F9669B1B034B4001000000020000000001000000FFFFFFFF0000000003 as geography)
    
    select @orderBounds2
    union all
    select @geo

outputs

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM