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