All Products
Search
Document Center

PolarDB:ST_GeometryMatch

Last Updated:Mar 28, 2026

Maps a 2D geometry object onto the surface of a 3D meshgeom object, returning a 3D geometry object.

Syntax

geometry ST_GeometryMatch(meshgeom geom3d, geometry geom2d, cstring direction, float8 sample);

Parameters

ParameterTypeDescription
geom3dmeshgeomThe 3D meshgeom object that serves as the target surface.
geom2dgeometryThe 2D geometry to project onto the mesh. Supported types: Point, MultiPoint, LineString, MultiLineString.
directioncstringThe matching direction. Valid values: TOP and BOTTOM.
samplefloat8The sampling interval for the 2D geometry object.

Description

ST_GeometryMatch absorbs or maps a 2D point or line geometry onto the surface of a 3D meshgeom object. The following adsorption or matching directions are supported: top adsorption or matching and bottom adsorption or matching.

The sample parameter controls the spacing between inserted intermediate points along line geometries before projection.

Effect diagram

A 2D line is matched to a 3D meshgeom object along the TOP direction to generate a 3D line. Effect diagram

Examples

Map a LineString onto a mesh from below (BOTTOM)

SELECT ST_AsText(
  ST_GeometryMatch(
    'MESHGEOM(PATCH(TRIANGLESTRIP Z(0 0 0,10 0 0,0 10 0,0 0 10)))'::mesh,
    'LINESTRING(1 1, 1.1 1.1)',
    'BOTTOM',
    0.02
  )
);

Expected output:

LINESTRING Z (1 1 0,1.01414213562373 1.01414213562373 0,1.02828427124746 1.02828427124746 0,1.04242640687119 1.04242640687119 0,1.05656854249492 1.05656854249492 0,1.07071067811866 1.07071067811866 0,1.08485281374239 1.08485281374239 0,1.09899494936612 1.09899494936612 0,1.1 1.1 0)

The output is a LINESTRING Z where each vertex carries a Z coordinate. The sampling interval of 0.02 controls the spacing between inserted vertices along the input line.