Consider the following test case:

SELECT ST_Equals(Foo.a, Foo.b), ST_Distance(Foo.a, Foo.c)
    FROM (SELECT ST_GeomFromText('LINESTRING(2 0, 0 1)') As a,
    ST_GeomFromText('LINESTRING(2 0, 0.2 0.9, 0 1)') As b,
    ST_GeomFromText('POINT( 0.2 0.9)') As c) As Foo; -- expected: {t}, actual: {f}

The distance from point **c** ('POINT( 0.2 0.9)') to line **a** ('LINESTRING(2 0, 0 1)') is 0. Line b ('LINESTRING(2 0, 0.2 0.9, 0 1)') is plus .

Untitled

Line a should equal line b because they have the same points set. { (x,y) | 2*x + y = 0 }

Actual behavior: PostGIS doesn’t consider LINE a to be equal to LINE b. The result of st_equals is false which means Postgis doesn’t consider they are the same line, although the distance between them calculated is 0.

The issue cannot be reproduced with integers only, indicating a potential floating-point issue. After all coordinate points are magnified ten times, the results are in line with expectations.

SELECT ST_Equals(Foo.a, Foo.b), ST_Distance(Foo.a, Foo.c)
    FROM (SELECT ST_GeomFromText('LINESTRING(20 0, 0 10)') As a,
    ST_GeomFromText('LINESTRING(20 0, 2 9, 0 10)') As b,
    ST_GeomFromText('POINT( 2 9)') As c) As Foo; -- res: {t}

Additional Information

Unlike PostGIS, SQLServer considers the two LINESTRINGs equal, which is the behavior I would expect.

DECLARE @g1 geometry;DECLARE @g2 geometry;DECLARE @g3 geometry;DECLARE @g2t geometry;
SET @g1 = geometry::STGeomFromText ('LINESTRING(4 0, 0 1)',0);
SET @g2 = geometry::STGeomFromText ('LINESTRING(4 0, 0.4 0.9, 0 1)',0);
SELECT @g1.STEquals(@g2) As g1Equalsg2

g1Equalsg2
----------
         1

(1 rows affected)

Meanwhile, the example in the document link has the expected behavior:

SELECT ST_Equals(ST_GeomFromText('LINESTRING(0 0, 10 10)'),
    ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)'));
 st_equals
-----------
 t
(1 row)