Updated on 2023-04-03 GMT+08:00

Geometric Functions

area(object)

Description: Area calculation

Return type: double precision

Example:

1
2
3
4
5
SELECT area(box '((0,0),(1,1))') AS RESULT;
 result 
--------
      1
(1 row)

center(object)

Description: Figure center calculation

Return type: point

Example:

1
2
3
4
5
SELECT center(box '((0,0),(1,2))') AS RESULT;
 result  
---------
 (0.5,1)
(1 row)

diameter(circle)

Description: Circle diameter calculation

Return type: double precision

Example:

1
2
3
4
5
SELECT diameter(circle '((0,0),2.0)') AS RESULT;
 result 
--------
      4
(1 row)

height(box)

Description: Vertical size of box

Return type: double precision

Example:

1
2
3
4
5
SELECT height(box '((0,0),(1,1))') AS RESULT;
 result 
--------
      1
(1 row)

isclosed(path)

Description: A closed path?

Return type: boolean

Example:

1
2
3
4
5
SELECT isclosed(path '((0,0),(1,1),(2,0))') AS RESULT;
 result 
--------
 t
(1 row)

isopen(path)

Description: An open path?

Return type: boolean

Example:

1
2
3
4
5
SELECT isopen(path '[(0,0),(1,1),(2,0)]') AS RESULT;
 result 
--------
 t
(1 row)

length(object)

Description: Length calculation

Return type: double precision

Example:

1
2
3
4
5
SELECT length(path '((-1,0),(1,0))') AS RESULT;
 result 
--------
      4
(1 row)

npoints(path)

Description: Number of points in path

Return type: int

Example:

1
2
3
4
5
SELECT npoints(path '[(0,0),(1,1),(2,0)]') AS RESULT;
 result 
--------
      3
(1 row)

npoints(polygon)

Description: Number of points in polygon

Return type: int

Example:

1
2
3
4
5
SELECT npoints(polygon '((1,1),(0,0))') AS RESULT;
 result 
--------
      2
(1 row)

pclose(path)

Description: Converts path to closed.

Return type: path

Example:

1
2
3
4
5
SELECT pclose(path '[(0,0),(1,1),(2,0)]') AS RESULT;
       result        
---------------------
 ((0,0),(1,1),(2,0))
(1 row)

popen(path)

Description: Converts path to open.

Return type: path

Example:

1
2
3
4
5
SELECT popen(path '((0,0),(1,1),(2,0))') AS RESULT;
       result        
---------------------
 [(0,0),(1,1),(2,0)]
(1 row)

radius(circle)

Description: Circle diameter calculation

Return type: double precision

Example:

1
2
3
4
5
SELECT radius(circle '((0,0),2.0)') AS RESULT;
 result 
--------
      2
(1 row)

width(box)

Description: Horizontal size of box

Return type: double precision

Example:

1
2
3
4
5
SELECT width(box '((0,0),(1,1))') AS RESULT;
 result 
--------
      1
(1 row)