ST_DistanceSpheroid — 使用球体模型返回两个经度/纬度几何形状之间的最小距离。
float ST_DistanceSpheroid(
geometry geomlonlatA, geometry geomlonlatB, spheroid measurement_spheroid=WGS84)
;
返回给定特定球体的两个经度/纬度几何形状之间的最小距离(以米为单位)。 请参阅 ST_LengthSpheroid给出的椭球体的解释。
此函数不查看几何体的 SRID。 它假设几何坐标基于提供的球体。 |
可用性:1.5 - 引入了对除点之外的其他几何类型的支持。 之前的版本仅适用于点。
更改:2.2.0 在之前的版本中,这称为 ST_Distance_Spheroid
SELECT round(CAST( ST_DistanceSpheroid(ST_Centroid(geom), ST_GeomFromText('POINT(-118 38)',4326), 'SPHEROID["WGS 84",6378137,298.257223563]') As numeric),2) As dist_meters_spheroid, round(CAST(ST_DistanceSphere(ST_Centroid(geom), ST_GeomFromText('POINT(-118 38)',4326)) As numeric),2) As dist_meters_sphere, round(CAST(ST_Distance(ST_Transform(ST_Centroid(geom),32611), ST_Transform(ST_GeomFromText('POINT(-118 38)', 4326),32611)) As numeric),2) As dist_utm11_meters FROM (SELECT ST_GeomFromText('LINESTRING(-118.584 38.374,-118.583 38.5)', 4326) As geom) as foo; dist_meters_spheroid | dist_meters_sphere | dist_utm11_meters ----------------------+--------------------+------------------- 70454.92 | 70424.47 | 70438.00