Hi Ron,
It's not at unusual that different sw implementations could give
different
results for the same problem.
As a general rule open source software is usually expected to be more
accurate than proprietary sw simply because anyone can directly correct
any errors or flaws.
let's go into specific details.
there is absolutely nothing wrong or suspect in GeodesicLength():
SELECT GeodesicLength(
GeomFromText('LINESTRING (-70.586729 41.929292, -70.567065
41.937575)', 4326));
----------------
1872
As you can see the shortest line identified by SQL server has the
expected length measured in metres also on SpatiaLite.
So the real problem is in the supposed shortest line.
Yet another step forward:
SELECT ST_Distance(
ST_GeomFromText('LINESTRING (-70.565641 41.936550,
-70.566803 41.937228,-70.567408 41.938029,
-70.567885 41.938888,-70.568366 41.939728,
-70.569003 41.940581,-70.569727 41.941131,
-70.570453 41.941709,-70.571622 41.942286,
-70.572600 41.942735,-70.573164 41.943099,
-70.573327 41.943555,-70.573931 41.943787,
-70.574443 41.944150,-70.575010 41.944433,
-70.575882 41.944722,-70.576708 41.944958,
-70.577261 41.945253,-70.578227 41.945664,
-70.578972 41.945694,-70.579366 41.945698,
-70.579506 41.946013,-70.579331 41.946415,
-70.579087 41.946683,-70.578901 41.947012,
-70.579273 41.947234,-70.579615 41.947320,
-70.580101 41.947449,-70.580844 41.947918)', 4326),
ST_GeomFromText('POINT(-70.586729 41.929293)',4326), 0);
---------------------------
1923
SpatiaLite definitely confirms that the distance between
the line and the point is 1923 metres and not 1872 as
reported by SQL Server.
Last final checks:
SELECT ST_Distance(
ST_GeomFromText('LINESTRING (-70.565641 41.936550,
-70.566803 41.937228,-70.567408 41.938029,
-70.567885 41.938888,-70.568366 41.939728,
-70.569003 41.940581,-70.569727 41.941131,
-70.570453 41.941709,-70.571622 41.942286,
-70.572600 41.942735,-70.573164 41.943099,
-70.573327 41.943555,-70.573931 41.943787,
-70.574443 41.944150,-70.575010 41.944433,
-70.575882 41.944722,-70.576708 41.944958,
-70.577261 41.945253,-70.578227 41.945664,
-70.578972 41.945694,-70.579366 41.945698,
-70.579506 41.946013,-70.579331 41.946415,
-70.579087 41.946683,-70.578901 41.947012,
-70.579273 41.947234,-70.579615 41.947320,
-70.580101 41.947449,-70.580844 41.947918)', 4326),
ST_GeomFromText('POINT(-70.579366 41.945698)', 4326), 0);
----------------------------
0
this is the nearest point on the line identified by
SpatiaLite, and as we were expecting it lays
exactely on the line.
SELECT ST_Distance(
ST_GeomFromText('LINESTRING (-70.565641 41.936550,
-70.566803 41.937228,-70.567408 41.938029,
-70.567885 41.938888,-70.568366 41.939728,
-70.569003 41.940581,-70.569727 41.941131,
-70.570453 41.941709,-70.571622 41.942286,
-70.572600 41.942735,-70.573164 41.943099,
-70.573327 41.943555,-70.573931 41.943787,
-70.574443 41.944150,-70.575010 41.944433,
-70.575882 41.944722,-70.576708 41.944958,
-70.577261 41.945253,-70.578227 41.945664,
-70.578972 41.945694,-70.579366 41.945698,
-70.579506 41.946013,-70.579331 41.946415,
-70.579087 41.946683,-70.578901 41.947012,
-70.579273 41.947234,-70.579615 41.947320,
-70.580101 41.947449,-70.580844 41.947918)', 4326),
ST_GeomFromText('POINT( -70.567065 41.937575)', 4326), 0);
----------------------------
0.00684
this is instead the nearest point on the line identified
by SQL Server.
Unexpected surprise: it doesn't lays at all over the line.
quick conclusiion: SQL Server seems to be affected by
errors in calculating the minimum distance between a
line and a point, presumably caused by rounding issues
in floating point arithmetics.
bye Sandro