Spatial - polygon with holes in is converted to linestring?

  • My problem is that when im trying to join 2 polygons, where at least one of them have a hole in then the result is broken.

    I join the geometry like this:

    DECLARE @a0 geometry;

    DECLARE @a1 geometry;

    SET @a0 = geometry::STGeomFromText('POLYGON', 25832).MakeValid();

    SET @a1 = geometry::STGeomFromText('POLYGON', 25832).MakeValid();

    SELECT @a0.STUnion(@a1);

    The i found out of that when a polygon has holes then the MakeValid() command converts the POLYGON to a LINESTRING?

    DECLARE @a0 geometry;

    SET @a0 = geometry::STGeomFromText('POLYGON((polygon cordinates),(hole cordinates))', 25832).MakeValid();

    select @a0.ToString()

    Result : LINESTRING((Cordinates))

    DECLARE @a0 geometry;

    SET @a0 = geometry::STGeomFromText('POLYGON((polygon cordinates))', 25832).MakeValid();

    select @a0.ToString()

    Result : POLYGON((Cordinates))

    Now my problem is that i cant draw the LINSTRING to look like the POLYGON incl. holes?

    Does anybody know a solution to my problem og just a hint 🙂

  • No. We're hitting issues with the tool that generates our geographic shapes not properly closing all the polygons it generates (and occasionally generating polygons with lines that cross...). We can't get them into the DB due to errors during the insert and the only way we've been able to fix it is to go back to the generating tool and have it repair the polygon to make it right.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply