PostgreSQL center() Function
The PostgreSQL center()
function calculates the center point of the specified shape. It works with box
and circle
.
center()
Syntax
This is the syntax of the PostgreSQL center()
function:
center(geometric_type) -> point
Parameters
geometric_type
-
Required. A closed figure. It can be
box
andcircle
.
Return value
The PostgreSQL center()
function returns the center point of the specified shape.
center()
Examples
The following statement shows how to use PostgreSQL to center()
calculate the center point of a rectangle.
SELECT center(box '(2,2),(0,0)');
center
--------
(1,1)
The expression center(box '(2,2),(0,0)')
is equivalent to point(circle '<(0,0),2>')
.
The following statement shows how to calculate the center point of a circle using PostgreSQL center()
.
SELECT center(circle '<(0,0),2>');
center
--------
(0,0)
The expression center(circle '<(0,0),2>')
is equivalent to point(circle '<(0,0),2>')
.