The illustration below shows examples of Polygon instances.
As shown in the illustration:
-
Figure 1 is a Polygon instance whose boundary is defined by an exterior ring.
-
Figure 2 is a Polygon instance whose boundary is defined by an exterior ring and two interior rings. The area inside the interior rings is part of the exterior of the Polygon instance.
-
Figure 3 is a valid Polygon instance because its interior rings intersect at a single tangent point.
The following example creates a simple geometry Polygon instance with a hole and SRID 10.
|
DECLARE @g geometry;
SET @g = geometry::STPolyFromText('POLYGON((0 0, 0 3, 3 3, 3 0, 0 0), (1 1, 1 2, 2 1, 1 1))', 10); |
An instance that is not valid may be entered and converted to a valid geometry instance. In the following example of a Polygon, the interior and exterior rings overlap and the instance is not valid.
|
DECLARE @g geometry;
SET @g = geometry::Parse('POLYGON((1 0, 0 1, 1 2, 2 1, 1 0), (2 0, 1 1, 2 2, 3 1, 2 0))'); |
In the following example, the invalid instance is made valid with MakeValid().
|
SET @g = @g.MakeValid();
SELECT @g.ToString(); |
The geometry instance returned from the above example is a MultiPolygon.
|
MULTIPOLYGON (((2 0, 3 1, 2 2, 1.5 1.5, 2 1, 1.5 0.5, 2 0)), ((1 0, 1.5 0.5, 1 1, 1.5 1.5, 1 2, 0 1, 1 0))) |