SqlGeometry LineString STIsValid IsValidDetailed strange behaviour

Henning Mæland 1 Reputation point
2020-10-08T15:15:49.23+00:00

Hi

Apparently IsValidDetailed (and STIsValid) gives different results when two equal coords are located in the beginning vs. end of a line string.

Is this a bug?

select geometry::STGeomFromText('LINESTRING (7 8, 7 8, 5 5)', 0).IsValidDetailed() -- 24400: Valid
select geometry::STGeomFromText('LINESTRING (5 5, 7 8, 7 8)', 0).IsValidDetailed() -- 24406: Not valid because curve (2) degenerates to a point.

SQL Server version: Microsoft SQL Server 2019 (RTM) - 15.0.2000.5 (X64) Sep 24 2019 13:48:23 Copyright (C) 2019 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2019 Datacenter 10.0 <X64> (Build 17763: ) (Hypervisor)

SSMS version: 18.6

Same thing can be reproduced programmatically in C# using Microsoft.SqlServer.Types.dll (14.0.1016.290).

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,158 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cris Zhan-MSFT 6,641 Reputation points
    2020-10-09T08:00:36.18+00:00

    Hi @Henning Mæland ,

    The message returned by IsValidDetailed explains why the spatial object is not valid.

    I tested and got the same result as you on the SQL Server 2019(RTM-CU8) instance . I don't think this is a bug. I think this is related to the coordinates in LINESTRING, the criteria to make the LineString instance valid are not met.

    It is also recommended to install the latest CU for your SQL Server 2019 instances.


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.