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 Line a
plus Point c
.
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;
Line a
should equal Line b
. As the example in the document [link](https://postgis.net/docs/ST_Equals.html):
SELECT ST_Equals(g1, g2) As g1Equalsg2
FROM (SELECT ST_GeomFromText('LINESTRING(0 0, 10 10)') As g1,
ST_GeomFromText('LINESTRING(0 0, 5 5, 10 10)') As g2) As Foo;
g1equalsg2
------------
t
(1 row)
PostGIS doesn’t think Line a
equals Line b
. The following statement is the same as the statement in the geometry description. The result of st_equals is false which means Postgis doesn’t think they are the same line.
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;
st_equals | st_distance
-----------+-------------
f | 0
(1 row)
SQLServer thinks the two LINESTRINGs are equal.
DECLARE @g1 geometry;DECLARE @g2 geometry;DECLARE @g3 geometry;
SET @g1 = geometry::STGeomFromText ('LINESTRING(2 0, 0 1)',0);
SET @g2 = geometry::STGeomFromText ('LINESTRING(2 0, 0.2 0.9, 0 1)',0);
SET @g3 = geometry::STGeomFromText ('POINT(0.2 0.9)',0);
SELECT @g1.STEquals(@g2) As g1Equalsg2
g1Equalsg2
----------
1
(1 rows affected)