ST_LENGTHSPHEROID
📄字数 946
👁️阅读量 加载中...
功能描述
返回椭球体面上几何图形的周长。
语法格式
sql
DOUBLE ST_LENGTHSPHEROID(GEOMETRY a_geometry, spheroid a_spheroid);参数说明
- a_3dlinestring:目标 GEOMETRY 对象。
- a_spheroid:椭球体由文本值指定。
- 格式:
SPHEROID[<NAME>,<SEMI-MAJOR AXIS>,<INVERSE FLATTENING>] - 例如:SPHEROID["GRS_1980",6378137,298.257222101]
- 格式:
函数返回类型
DOUBLE 类型
使用说明
- 当几何图形的坐标为经度/纬度并且您希望查找没有投影的长度时,请使用此函数。
- 该函数支持 3d 并且不会丢失 z-index。
示例
sql
SQL> SELECT ST_LengthSpheroid( geom, sph_m ) As tot_len,
ST_LengthSpheroid(ST_GeometryN(geom,1), sph_m) As len_line1,
ST_LengthSpheroid(ST_GeometryN(geom,2), sph_m) As len_line2
FROM (SELECT ST_GeomFromText('MULTILINESTRING((-118.584 38.374,-118.583 38.5),
(-71.05957 42.3589 , -71.061 43))') As geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo;
+--------------+--------------+--------------+
| TOT_LEN | LEN_LINE1 | LEN_LINE2 |
+--------------+--------------+--------------+
| 8.520452e+04 | 1.398687e+04 | 7.121765e+04 |
+--------------+--------------+--------------+
(1 row)
--3D
SQL> SELECT ST_LengthSpheroid( geom, sph_m ) As tot_len,
ST_LengthSpheroid(ST_GeometryN(geom,1), sph_m) As len_line1,
ST_LengthSpheroid(ST_GeometryN(geom,2), sph_m) As len_line2
FROM (SELECT ST_GeomFromEWKT('MULTILINESTRING((-118.584 38.374 20,-118.583 38.5 30),
(-71.05957 42.3589 75, -71.061 43 90))') As geom,
CAST('SPHEROID["GRS_1980",6378137,298.257222101]' As spheroid) As sph_m) as foo;
+--------------+--------------+--------------+
| TOT_LEN | LEN_LINE1 | LEN_LINE2 |
+--------------+--------------+--------------+
| 8.520453e+04 | 1.398688e+04 | 7.121765e+04 |
+--------------+--------------+--------------+
(1 row)