Verwendung PostgreSQL 9.5.2, PostGIS 2.2, angesichts der folgenden Geo-Koordinaten:PostGIS Nichtübereinstimmung zwischen 2D-Entfernung ("<->" operator; Geometrie) und ST_Distance (Geografie) Sortierungen
'SRID=4326;POINT(24.8713597 60.1600568)' -- Origin
'SRID=4326;POINT(24.87717970 60.19824480)' -- Destination A
'SRID=4326;POINT(24.91281220 60.15821350)' -- Destination B
'SRID=4326;POINT(24.91404950 60.16373390)' -- Destination C
'SRID=4326;POINT(24.91552820 60.16129280)' -- Destination D
Sorting by "geografischen" Abstand (ST_Distance method):
select name, st_distance('SRID=4326;POINT(24.8713597 60.1600568)'::geography, geo)
from (select 'SRID=4326;POINT(24.87717970 60.19824480)'::geography as geo, 'A' as name
union select 'SRID=4326;POINT(24.91281220 60.15821350)'::geography as geo, 'B' as name
union select 'SRID=4326;POINT(24.91404950 60.16373390)'::geography as geo, 'C' as name
union select 'SRID=4326;POINT(24.91552820 60.16129280)'::geography as geo, 'D' as name) tmp
order by 2;
Ergebnisse in:
B,2311.075069284
C,2405.58508757
D,2456.504535795
A,4266.971129052
Der durch "geometrischen" 2D-Abstand Sortierung (<-> Operator):
select name, 'SRID=4326;POINT(24.8713597 60.1600568)'::geometry <-> geom
from (select 'SRID=4326;POINT(24.87717970 60.19824480)'::geometry as geom, 'A' as name
union select 'SRID=4326;POINT(24.91281220 60.15821350)'::geometry as geom, 'B' as name
union select 'SRID=4326;POINT(24.91404950 60.16373390)'::geometry as geom, 'C' as name
union select 'SRID=4326;POINT(24.91552820 60.16129280)'::geometry as geom, 'D' as name) tmp
order by 2;
Ergebnisse in:
A,0.03862894955858695
B,0.041493463474867306
C,0.042847871457636175
D,0.04418579056948194
... Und ich würde die Reihenfolge genau gleich zu sein erwarten.
Was fehlt mir?
Dies ist zu erwarten, da die Erde nicht flach ist und Sie kartesische Entfernungen mit geodätischen Längen auf einem Rotationsellipsoid vergleichen. –