名称

ST_DistanceSpheroid — 使用椭球地球模型返回两个经纬度几何图形之间的最小距离。

概要

float ST_DistanceSpheroid(geometry geomlonlatA, geometry geomlonlatB, spheroid measurement_spheroid=WGS84);

描述

返回给定特定椭球体的两个经纬度几何图形之间的最小距离,单位为米。请参阅ST_LengthSpheroid 中给出的椭球体解释。

[Note]

此函数不查看几何图形的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