5.1.  Casting #

pgSphere provides some casting operators. So, you can transform an object to another data type. A cast is done using a CAST(x AS typename), x::typename or typename(x) construct.

Table 5.1. Castings

casting argumenttype targetreturns
spoint scircle circle with center position spoint and radius 0.0
spoint sellipse an ellipse at position spoint and radius 0.0
spoint sline a line with length 0.0 at position spoint
scircle sellipse the scircle as sellipse
sline strans the Euler transformation of sline
sellipse scircle the bounding circle of sellipse
sellipse strans the Euler transformation of sellipse

Example 5.1. Cast a spherical point as a circle

sql> SELECT CAST ( spoint '(10d,20d)' AS scircle );
      scircle
--------------------
 <(10d , 20d) , 0d>
(1 row)