Nome

ST_PointOnSurface — Calcola un punto che si trova in un poligono o su una geometria.

Sinossi

geometry ST_PointOnSurface(geometry g1);

Descrizione

Returns a POINT which is guaranteed to lie in the interior of a surface (POLYGON, MULTIPOLYGON, and CURVEPOLYGON). In PostGIS this function also works on line and point geometries.

Questo metodo implementa le OGC Simple Features Implementation Specification for SQL 1.1. s3.2.14.2 // s3.2.18.2

Questo metodo implementa la specifica SQL/MM. SQL-MM 3: 8.1.5, 9.5.6. Le specifiche definiscono ST_PointOnSurface solo per le geometrie di superficie. PostGIS estende la funzione per supportare tutti i tipi di geometria più comuni. Altri database (Oracle, DB2, ArcSDE) sembrano supportare questa funzione solo per le superfici. SQL Server 2008 supporta tutti i tipi di geometria più comuni.

Questa funzione supporta il 3d e non distrugge gli z-index.

Esempi

Point on surface of a MultiPoint.

Code
SELECT ST_PointOnSurface(
  'MULTIPOINT (8 24,10 92,12 154,17 68,28 10,29 52,29 84,55 50,56 24,131 14,160 180,189 180)');
Output
POINT(55 50)
Figure
Geometry figure for st-pointonsurface-multipoint

Point on surface of a LineString.

Code
SELECT ST_PointOnSurface(
  'LINESTRING (190 160,10 190,40 90,20 70,10 10,30 40,30 10,110 40,70 10,110 10,140 40,140 10,160 30,180 10)');
Output
POINT(40 90)
Figure
Geometry figure for visual-st-pointonsurface-02

Point on surface of a Polygon.

Code
SELECT ST_PointOnSurface(
  'POLYGON ((190 190,10 190,10 10,190 10,190 20,160 30,60 30,60 130,190 140,190 190))');
Output
POINT(35 80)
Figure
Geometry figure for visual-st-pointonsurface-03

Point on surface of the highest-dimension components of a GeometryCollection.

Code
SELECT ST_PointOnSurface(
  'GEOMETRYCOLLECTION (POLYGON ((190 170,180 100,80 140,80 160,130 160,110 180,110 190,180 180,190 170)),
    LINESTRING (80 120,120 20,140 70,150 30,180 50,190 10),
    MULTIPOINT (19 150,22 49,30 13,32 101,45 35,67 88,75 16))');
Output
POINT(133.571 150)
Figure
Geometry figure for visual-st-pointonsurface-04
Code
SELECT ST_PointOnSurface('LINESTRING(0 5 1,0 0 1,0 10 2)');
Output
st_asewkt
--------------
 POINT(0 0 1)
(1 row)
Figure
Geometry figure for visual-st-pointonsurface-05

Esempio: Il risultato di ST_PointOnSurface è garantito all'interno dei poligoni, mentre il punto calcolato da ST_Centroid può essere esterno.

Code
SELECT ST_PointOnSurface(geom) AS pt_on_surf, ST_Centroid(geom) AS centroid
    FROM (SELECT 'POLYGON ((130 120,120 190,30 140,50 20,190 20,
                      170 100,90 60,90 130,130 120))'::geometry AS geom) AS t;
Output
pt_on_surf    |                  centroid
-----------------+---------------------------------------------
 POINT(62.5 110) | POINT(100.18264840182648 85.11415525114155)
Figure
Geometry figure for visual-st-pointonsurface-06