名称

ST_3DLongestLine — 返回两个几何体之间的最长 3D 线

语法

geometry ST_3DLongestLine(geometry g1, geometry g2);

说明

返回两个几何体之间的最长 3D 线。如果有多条最长线,则该函数返回第一条最长线。返回的线从 g1 开始,在 g2 结束。线的 3D 长度等于 ST_3DMaxDistance 返回的距离。

可用性:2.0.0

已更改:2.2.0 - 如果输入 2 个 2D 几何体,则返回一个 2D 点(而不是旧行为,即假设缺少 Z 时为 0)。如果为 2D 和 3D,则不再假设缺少 Z 时 Z 为 0。

此函数支持 3d,并且不会丢弃 z 索引。

此函数支持多面体曲面。

示例

线串和点 -- 3d 和 2d 最长线

SELECT ST_AsEWKT(ST_3DLongestLine(line,pt)) AS lol3d_line_pt,
		ST_AsEWKT(ST_LongestLine(line,pt)) As lol2d_line_pt
	FROM (SELECT 'POINT(100 100 30)'::geometry As pt,
			'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 1000)'::geometry As line
		) As foo;


           lol3d_line_pt           |       lol2d_line_pt
-----------------------------------+----------------------------
 LINESTRING(50 75 1000,100 100 30) | LINESTRING(98 190,100 100)
					

线串和多点 -- 3d 和 2d 最长线

SELECT ST_AsEWKT(ST_3DLongestLine(line,pt)) AS lol3d_line_pt,
		ST_AsEWKT(ST_LongestLine(line,pt)) As lol2d_line_pt
	FROM (SELECT 'MULTIPOINT(100 100 30, 50 74 1000)'::geometry As pt,
			'LINESTRING (20 80 20, 98 190 1, 110 180 3, 50 75 900)'::geometry As line
		) As foo;


          lol3d_line_pt          |      lol2d_line_pt
---------------------------------+--------------------------
 LINESTRING(98 190 1,50 74 1000) | LINESTRING(98 190,50 74)
					

多线串和多边形 -- 3d 和 2d 最长线

SELECT ST_AsEWKT(ST_3DLongestLine(poly, mline)) As lol3d,
    ST_AsEWKT(ST_LongestLine(poly, mline)) As lol2d
        FROM (SELECT  ST_GeomFromEWKT('POLYGON((175 150 5, 20 40 5, 35 45 5, 50 60 5, 100 100 5, 175 150 5))') As poly,
                ST_GeomFromEWKT('MULTILINESTRING((175 155 2, 20 40 20, 50 60 -2, 125 100 1, 175 155 1),
                (1 10 2, 5 20 1))') As mline ) As foo;
            lol3d             |          lol2d
------------------------------+--------------------------
 LINESTRING(175 150 5,1 10 2) | LINESTRING(175 150,1 10)
             

另请参阅

ST_3DClosestPointST_3DDistanceST_LongestLineST_3DShortestLineST_3DMaxDistance