ST_Distance is not always commutative
|Reported by:||realityexists||Owned by:||robe|
I've found a case where changing the order of operands for ST_Distance(geog) causes it to return slightly different results:
SELECT ST_Distance('POINT(-40 46.167)'::geography, 'POINT(0 7.167)'::geography) - ST_Distance('POINT(0 7.167)'::geography, 'POINT(-40 46.167)'::geography);
This caused some odd behaviour in my application, which orders sets of points by their distance from each other - the result was different depending on the order in which points were considered. There's an easy workaround, of course - just round the results - but I can imagine other developers scratching their heads over this as well.