locked
Inconsistent invalid polygons RRS feed

  • Question

  •  

    Can anyone explain why this polygon is valid

     

    Polygon((0 0,0 10,10 10,10 0,0 0),(2 2,6 2,6 2,6 6,2 2))

     

    when it contains this polygon with is invalid 

     

    Polygon((2 2,6 2,6 2,6 6,2 2))

    Sunday, December 9, 2007 11:29 PM

Answers

  • Hi Simon,

     

    You're right, this is a bug.  Can you file it on connect.microsoft.com?

     

    Thanks,

    Steven

     

    Monday, December 10, 2007 4:22 PM

All replies

  • Are you using the geometry or geography type?

     

    In geometry, both of these appear valid.  I.e.,

     

    declare @g geometry = geometry::Parse('Polygon((0 0,0 10,10 10,10 0,0 0),(2 2,6 2,6 2,6 6,2 2))')

    declare @h geometry = geometry::Parse('Polygon((2 2,6 2,6 2,6 6,2 2))')

    select @g.STIsValid(), @h.STIsValid()

     

    returns (1, 1).

     

    If you try this with the geography type, then first polygon is a squarish region on the sphere with a triangular hole in it.  The second one is that same triangular hole in the surface of the earth---it's everything but the region defined.  We currently have a size restriction on geography objects, so this gets rejected.

     

    Cheers,

    -Isaac

    Monday, December 10, 2007 12:27 AM
  • Oops cust and paste error

     

    declare @g geometry = geometry::Parse('Polygon((0 0,0 10,10 10,10 0,0 0),(2 2,6 2,2 6,6 6,2 2))')

    declare @h geometry = geometry::Parse('Polygon((2 2,6 2,2 6,6 6,2 2))')

    select @g.STIsValid(), @h.STIsValid()

     

    The second polygon, crosses itself and so is invalid

    ----

    \  /

     \/

     /\

    /  \

    ----

    Monday, December 10, 2007 7:55 AM
  • Hi Simon,

     

    You're right, this is a bug.  Can you file it on connect.microsoft.com?

     

    Thanks,

    Steven

     

    Monday, December 10, 2007 4:22 PM