st_pointonsurface Fonction

S’applique à :check marqué oui Databricks Runtime 18.3 et versions ultérieures

Important

Cette fonctionnalité est disponible en préversion publique.

Retourne un point garanti sur ou à l’intérieur de la valeur d’entrée GEOMETRY .

Syntax

st_pointonsurface ( geoExpr )

Arguments

  • geoExpr: une valeur de GEOMETRY.

Returns

Valeur de point GEOMETRY 2D garantie sur ou à l’intérieur de la valeur d’entrée GEOMETRY . Plus précisément :

  • Si la valeur d’entrée GEOMETRY est vide, le point vide 2D est retourné.
  • Si la valeur d’entrée GEOMETRY est un point non vide, la projection 2D du point est retournée.
  • Si la valeur d’entrée GEOMETRY est une chaîne de ligne non vide, le vertex médian est retourné.
  • Si la valeur d’entrée GEOMETRY est un polygone non vide, un point à l’intérieur du polygone est retourné lorsque cela est possible ; sinon, un point sur sa limite.
  • Si la valeur d’entrée GEOMETRY est un multipoint, le point non vide le plus proche du centre de zone englobante est retourné.
  • Si la valeur d’entrée GEOMETRY est une chaîne multiligne, un point sur la surface de la chaîne de traits avec la plus grande longueur est retournée.
  • Si la valeur d’entrée GEOMETRY est un multipolygon, un point sur la surface du polygone avec la plus grande zone est retournée.
  • Si la valeur d’entrée GEOMETRY est une collection géométrique, un point sur la surface d’un des éléments de dimension maximale de la collection est retourné.

La valeur SRID de la valeur de sortie GEOMETRY est la même que celle de la valeur d’entrée.

Exemples

-- Example taking a 2D polygon.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('POLYGON((0 0,10 0,10 10,0 10,0 0))')));
  POINT(5 5)

-- Example taking a 2D polygon with a hole: the result lies in the donut region.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('POLYGON((0 0,30 0,30 30,0 30,0 0),(5 5,25 5,25 25,5 25,5 5))')));
  POINT(3.75 3.75)

-- Example taking a 3DZ linestring: the median vertex is returned and the Z coordinate is dropped.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('LINESTRING Z (1 2 -1,3 4 -2,5 6 -3)')));
  POINT(3 4)

-- Example taking a multipolygon: a point on the polygon with the largest area is returned.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)),((100 100,101 100,101 101,100 101,100 100)))')));
  POINT(5 5)

-- Example showing that the SRID is preserved.
> SELECT st_asewkt(st_pointonsurface(st_geomfromtext('POLYGON((0 0,10 0,10 10,0 10,0 0))', 3857)));
  SRID=3857;POINT(5 5)

-- Example taking a NULL input.
> SELECT st_pointonsurface(NULL);
  NULL