Name

ST_3DClosestPoint — Gibt den 3-dimensionalen Punkt auf g1 zurück, der den kürzesten Abstand zu g2 hat. Dies ist der Anfangspunkt des kürzesten Abstands in 3D.

Übersicht

geometry ST_3DClosestPoint(geometry g1, geometry g2);

Beschreibung

Gibt den 3-dimensionalen Punkt auf g1 zurück, der den kürzesten Abstand zu g2 hat. Dies ist der Anfangspunkt des kürzesten Abstands in 3D. Die Länge des kürzesten Abstands in 3D ergibt sich aus der 3D-Distanz.

Diese Funktion unterstützt 3d und lässt den Z-Index nicht fallen.

Diese Funktion unterstützt polyedrische Flächen.

Verfügbarkeit: 2.0.0

Änderung: 2.2.0 - Wenn 2 geometrische Objekte in 2D übergegeben werden, wird ein 2D-Punkt zurückgegeben (anstelle wie früher 0 für ein fehlendes Z). Im Falle von 2D und 3D, wird für fehlende Z nicht länger 0 angenommen.

Beispiele

Compare the 3D closest point to the 2D closest point for a LineString and a Point.

Code
WITH input AS (
  SELECT 'POINT(100 100 30)'::geometry AS pt,
         'LINESTRING (20 80 20,98 190 1,110 180 3,50 75 1000)'::geometry AS line
)
SELECT ST_3DClosestPoint(line, pt) AS cp3d_line_pt,
       ST_ClosestPoint(line, pt) AS cp2d_line_pt
FROM input;
Ausgabe von Rastern
-[ RECORD 1 ]--+--------------------------------------------------------
cp3d_line_pt   | POINT(54.69937988676193 128.93502291722837 11.547586950660556)
cp2d_line_pt   | POINT(73.07692307692307 115.38461538461539)
Figure
Geometry figure for visual-st-3dclosestpoint-01

Compare the 3D closest point to the 2D closest point for a LineString and a MultiPoint.

Code
WITH input AS (
  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
)
SELECT ST_3DClosestPoint(line, pt) AS cp3d_line_pt,
       ST_ClosestPoint(line, pt) AS cp2d_line_pt
FROM input;
Ausgabe von Rastern
-[ RECORD 1 ]--+--------------------------------------------------------
cp3d_line_pt   | POINT(54.69937988676193 128.93502291722837 11.547586950660556)
cp2d_line_pt   | POINT(50 75)
Figure
Geometry figure for visual-st-3dclosestpoint-02

Compare the 3D closest point to the 2D closest point for a Polygon and a MultiLineString.

Code
WITH input AS (
  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
)
SELECT ST_3DClosestPoint(poly, mline) AS cp3d,
       ST_ClosestPoint(poly, mline) AS cp2d
FROM input;
Ausgabe von Rastern
-[ RECORD 1 ]--+---------------------------------------
cp3d           | POINT(40.45454545454545 53.63636363636364 5)
cp2d           | POINT(20 40)
Figure
Geometry figure for visual-st-3dclosestpoint-03