locked
How to determine if two geometries when unioned exceed a single hemisphere? RRS feed

  • Question

  • Hi

    Is there a way to determine if two geometries when unioned together will exceed the single hemisphere limitation?

    I read about EnvelopeCenter and EnvelopeAngle and know the angle should be less than 90 degrees but these methods only work on existing geography instances so can't be used as a pre-test.

    Here is an example of what I am trying to do. I would like to avoid using TRY/CATCH blocks since I need to use this test in a SELECT statement.

    declare @x geography = 'MULTIPOINT ((0 1), (90 1), (180 1), (270 1))';
    declare @y geography = 'POINT (45 1)';
    
    /* some test with @x and @y here that  */
    
    select @x.STUnion(@y) 
    
    /* This returns NULL because @x union @y > hemisphere */

    Thanks
    Blair
    Friday, June 12, 2009 3:48 PM

All replies

  • How about:
    declare @x geography = 'MULTIPOINT ((0 1), (90 1), (180 1))';
    declare @y geography = 'POINT (270 1)';
    
    /* some test with @x and @y here that  */
    DECLARE @test geography = @x.STUnion(@y)
    IF @test IS NULL PRINT 'Could not create union' ELSE PRINT @x.STAsText();

    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Saturday, June 13, 2009 1:36 PM
    Answerer
  • Perhaps but in the previous thread in which you also replied it could not be determined if this was the best method since STUnion might return NULL on other non-trivial inputs.

    Hopefully someone else might have a better idea.

    Saturday, June 13, 2009 5:08 PM
  • Can you tell me when  STUnion returns null except when union of input objects exceeds a single hemisphere?
    Or at least a link to this thread you've mentioned?
    Tuesday, July 21, 2009 3:00 PM
  • I think the thread in question is: http://social.msdn.microsoft.com/Forums/en-US/sqlspatial/thread/86afca1b-592c-432f-a947-8a378b68e4aa
    Beginning Spatial with SQL Server http://www.apress.com/book/view/1430218290
    Tuesday, July 21, 2009 3:12 PM
    Answerer
  • There's no thread or document confirming the only cases where STUnion will return NULL. AFAIK
    Tuesday, July 21, 2009 3:15 PM