A LineString is a one-dimensional object representing a sequence of points and the line segments connecting them in SQL Database Engine spatial data.
LineString instances
The following illustration shows examples of LineString instances.
As shown in the illustration:
Figure 1 is a simple, nonclosed LineString instance.
Figure 2 is a nonsimple, nonclosed LineString instance.
Figure 3 is a closed, simple LineString instance, and therefore is a ring.
Figure 4 is a closed, nonsimple LineString instance, and therefore is not a ring.
Accepted instances
Accepted LineString instances can be input into a geometry variable, but they might not be valid LineString instances. The following criteria must be met for a LineString instance to be accepted. The instance must be formed of at least two points or it must be empty. The following LineString instances are accepted.
Each point in the LineString instance can contain Z (elevation) and M (measure) values. This example adds M values to the LineString instance created in the previous example. M and Z can be NULL values.
The following example shows how to create a geometry LineString instance with two points that are the same. A call to IsValid indicates that the LineString instance is not valid. A call to MakeValid converts the LineString instance into a Point.
DECLARE @g geometry
SET @g = geometry::STGeomFromText('LINESTRING(1 3, 1 3)',0);
IF @g.STIsValid() = 1
BEGIN
SELECT @g.ToString() + ' is a valid LineString.';
END
ELSE
BEGIN
SELECT @g.ToString() + ' is not a valid LineString.';
SET @g = @g.MakeValid();
SELECT @g.ToString() + ' is a valid Point.';
END
Here's the result set.
LINESTRING(1 3, 1 3) is not a valid LineString
POINT(1 3) is a valid Point.
Polygon is a two-dimensional surface stored as a sequence of points defining an exterior bounding ring and zero or more interior rings, in SQL Server spatial data.
Geometry instances represent data in a Euclidean (flat) coordinate system. Learn how to create, construct, and query geometry data in SQL Database Engine spatial data.
CurvePolygon is a topologically closed surface defined by an exterior bounding ring and zero or more interior rings in SQL Database Engine spatial data.