Peristiwa
31 Mac, 11 PTG - 2 Apr, 11 PTG
Acara pembelajaran SQL, Fabric dan Power BI terbesar. 31 Mac - 2 April. Gunakan kod FABINSIDER untuk menjimatkan $400.
Daftar hari iniPelayar ini tidak lagi disokong.
Naik taraf kepada Microsoft Edge untuk memanfaatkan ciri, kemas kini keselamatan dan sokongan teknikal yang terkini.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
SQL analytics endpoint in Microsoft Fabric
Warehouse in Microsoft Fabric
SQL database in Microsoft Fabric
A LineString is a one-dimensional object representing a sequence of points and the line segments connecting them in SQL Database Engine spatial data.
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 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.
DECLARE @g1 geometry = 'LINESTRING EMPTY';
DECLARE @g2 geometry = 'LINESTRING(1 1,2 3,4 8, -6 3)';
DECLARE @g3 geometry = 'LINESTRING(1 1, 1 1)';
@g3
shows that a LineString instance can be accepted, but not valid.
The following LineString instance is not accepted. It throws a System.FormatException
.
DECLARE @g geometry = 'LINESTRING(1 1)';
For a LineString instance to be valid, it must meet the following criteria.
The following LineString instances are valid.
DECLARE @g1 geometry= 'LINESTRING EMPTY';
DECLARE @g2 geometry= 'LINESTRING(1 1, 3 3)';
DECLARE @g3 geometry= 'LINESTRING(1 1, 3 3, 2 4, 2 0)';
DECLARE @g4 geometry= 'LINESTRING(1 1, 3 3, 2 4, 2 0, 1 1)';
SELECT @g1.STIsValid(), @g2.STIsValid(), @g3.STIsValid(), @g4.STIsValid();
The following LineString instances are not valid.
DECLARE @g1 geometry = 'LINESTRING(1 4, 3 4, 2 4, 2 0)';
DECLARE @g2 geometry = 'LINESTRING(1 1, 1 1)';
SELECT @g1.STIsValid(), @g2.STIsValid();
Amaran
The detection of LineString overlaps is based on floating-point calculations, which are not exact.
The following example shows how to create a geometry LineString
instance with three points and an SRID of 0:
DECLARE @g geometry;
SET @g = geometry::STGeomFromText('LINESTRING(1 1, 2 4, 3 9)', 0);
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.
DECLARE @g geometry;
SET @g = geometry::STGeomFromText('LINESTRING(1 1 NULL 0, 2 4 NULL 12.3, 3 9 NULL 24.5)', 0);
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.
Peristiwa
31 Mac, 11 PTG - 2 Apr, 11 PTG
Acara pembelajaran SQL, Fabric dan Power BI terbesar. 31 Mac - 2 April. Gunakan kod FABINSIDER untuk menjimatkan $400.
Daftar hari iniDokumentasi
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.
GeometryCollection - SQL Server
GeometryCollection is a collection of zero or more geometry or geography instances in SQL Database Engine spatial data.
MultiPoint is a collection of zero or more points. The boundary of a **MultiPoint** instance is empty in SQL Database Engine spatial data.