The functions described below are implemented without having an operator. If you are missing some functions, see Section 5 and use the operators.
The area
function returns the area of a
spherical object in square radians. Supported data types are:
scircle, spolygon (if the polygon
is convex), sbox, and smoc.
The functions
returns the longitude or latitude value of a
spherical position p
in radians.
The functions
return the Cartesian
x, y or
z value of a spherical position
p
. The returned values are always
between -1.0 and +1.0.
Example 41. Get the Cartesian z-value of a spherical point
sql> SELECT z ( spoint '(10d,-90d)' ) AS z; z ---- -1 (1 row)
You can get a float8 array of Cartesian values using the function
Using the function
strans_zxz(strans),
you can convert
an Euler transformation to ZXZ axes
transformation.
It is possible to get the components of an Euler transformation.
Table 4. Getting Euler transformation attributes
function | description |
---|---|
phi
| first angle of a transformation |
theta
| second angle of a transformation |
psi
| third angle of a transformation |
axes
| transformation axes as a three letter code |
The angles will always returned as a float8 value in radians. The axes are returned as a three letter code.
You can get the radius of a spherical circle in radians using
the radius
function. The center of the
circle is available with
the operator @@ (Section 5.7).
pgSphere provides 4 functions to get the parameters of a spherical ellipse:
Table 5. Getting spherical ellipse attributes
function | description |
---|---|
lrad
| the major radius of the ellipse |
srad
| the minor radius of the ellipse |
center
| the center of the ellipse |
inc
| the inclination of the ellipse |
To get the ellipse center, you can use the
operator @@ (Section 5.7)
instead of using the function
center(sellipse)
.
To get the beginning and the end of a line, pgSphere provides two functions:
You can create a meridian as a line using the function
The function returns a line starting at a latitude of
-90° and ending at a latitude of 90°. The line goes
along the given longitude lng
in
radians.
You can get the count of points of a spherical path using the function:
pgSphere provides two functions to get points at a path.
The first function returns the i
-th
point of a path. If i
is less than 1
or larger than the count of spath points, the
function returns NULL. The second
function does nearly the same, but does linear interpolation
between edge positions.
Similar to an spath (Section 6.7.1), you can get the count of edges of a spherical polygon using the function:
The functions
return the corresponding southwest, northeast, southeast, or northwest edge. The returned value will be a spherical point.
Returns information about the internal representation of the smoc.
Example 53. A circle
sql> SELECT smoc_info('0/4 1/0 2 12-13 34-35 45 47 2/4 6 12 14 56-57 60-61 88 90-91 116-117 119 130-131 134-135 177 179 185 187'); smoc_info -------------------------------------------------------------------------------------------------------------------------------- version: 0, order: 2, depth: 1, first: 0, last: 3458764513820540928, area: 1261007895663738880, tree_begin: 48, data_begin: 72
Adjusts the order of an smoc to be more or less precise.
When order is smaller than smoc's maximal order, the MOC resolution is degraded to the new order, and its maximal order is set to that order. When order is larger than the smoc's maximal order, smoc's shape is not modified, but its maximal order is raised to order.
smoc union and intersection are available as aggregate functions that compute the aggretated coverage over a given column.
double precision[6]
epoch_prop
(spoint pos, double precision parallax, double precision pm_long, double precision pm_lat, double precision radial_velocity, double precision delta_t);
Propagates a spherical phase vector in time (in particular, applies proper motion to positions)
Following both pg_sphere and, where missing, astronomical conventions makes units somewhat eclectic here; pm_long and pm_lat need to be in rad/yr, whereas parallax is in mas, and radial_velocity in km/s. The time difference must be in (Julian) years.
This function returns a 6-array of [long, lat, parallax, pm_long, pm_lat, radial_velocity] of the corresponding values delta_t years after the reference epoch for the original position. As in the function arguments, long and lat are in rad, pm_lon and pm_lat are in rad/yr, parallax is in mas, and radial_velocity is in km/s. If you are only interested in the position, consider the epoch_prop_pos functions below that have a somewhat less contorted signature.
It is an error to have either pos or delta_t NULL. For all other arguments, NULLs are turned into 0s, except for parallax, where some very small default is put in. In that case, both parallax and radial_velocity will be NULL in the output array.
This uses the rigorous method derived in "The Hipparcos and Tycho Catalogues", ESA Special Publication 1200 (1997), p 94f. It does not take into account relativistic effects, and it also does not account for secular aberration.
Example 55. Propagating Barnard's star into the past
SELECT to_char(DEGREES(tp[1]), '999D9999999999'), to_char(DEGREES(tp[2]), '999D9999999999'), to_char(tp[3], '999D999'), to_char(DEGREES(tp[4])*3.6e6, '999D999'), to_char(DEGREES(tp[5])*3.6e6, '99999D999'), to_char(tp[6], '999D999') FROM ( SELECT epoch_prop( spoint(radians(269.45207695), radians(4.693364966)), 546.9759, RADIANS(-801.551/3.6e6), RADIANS(10362/3.6e6), -110, -100) AS tp) AS q; to_char | to_char | to_char | to_char | to_char | to_char -----------------+-----------------+----------+----------+------------+---------- 269.4742714391 | 4.4072939987 | 543.624 | -791.442 | 10235.412 | -110.450
spoint
epoch_prop_pos
(spoint pos, double precision parallax, double precision pm_long, double precision pm_lat, double precision radial_velocity, double precision delta_t);
spoint
epoch_prop_pos
(spoint pos, double precision pm_long, double precision pm_lat, double precision delta_t);
These are simplified versions of epoch_prop returning only spoints; the propagated values for the other coordinates are discarded (but still internallay computed; these functions do not run any faster than epoch_prop itself).
As with epoch_prop itself, missing values (except for pos and delta_t) are substituted by 0 (or a very small value in the case of parallax).