The aggregate function
spoly( | edge) ; |
spoint edge
;
can be used to create a polygon from a set of spherical points.
There are the same restrictions as for using the input function of
spherical polygon (see Section 3.8). The function
returns
NULL
, if the polygon couldn't be created.
Example 4.7. Create a spherical polygon using a set of spherical points
Create a table and put in some spherical points with a unique ID. Then, create two polygons with different edge sequences.
sql> SELECT set_sphere_output('DEG'); set_sphere_output ------------------- SET DEG (1 row) sql> CREATE TABLE points ( i int PRIMARY KEY, p spoint ); sql> INSERT INTO points VALUES (1, '( 0d, 0d)'); sql> INSERT INTO points VALUES (2, '(10d, 0d)'); sql> INSERT INTO points VALUES (3, '( 0d,10d)'); sql> SELECT spoly(data.p) FROM ( SELECT p FROM points ORDER BY i ASC ) AS data ; spoly ----------------------------------- {(0d , 0d),(10d , 0d),(0d , 10d)} (1 row) sql> SELECT spoly(data.p) FROM ( SELECT p FROM points ORDER BY i DESC ) AS data ; spoly ----------------------------------- {(0d , 10d),(10d , 0d),(0d , 0d)} (1 row)