spath functions
#You can get the count of points of a spherical path using the function:
npoints( | path); |
spath path;Example 6.13. Count of spath's points
sql> SELECT npoints ( spath '{(0,0),(1,0)}' );
npoints
---------
2
(1 row)
pgSphere provides three functions to get points at a path.
spoint( | path, | |
i); |
spath path;int4 i;spoint( | path, | |
f); |
spath path;float8 f;spath_as_array( | path); |
spath 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.
Example 6.14.
Get the “center” of a one segment spath
sql> SELECT spoint ( spath '{(0d,0d),(30d,0d)}', 1.5 );
spoint
------------
(15d , 0d)
(1 row)
Example 6.15. Get i-th point of a path
sql> SELECT spoint( spath '{(0, 0),(1, 1)}', 1 );
spoint
------------
(0 , 0)
(1 row)
sql> SELECT spoint( spath '{(0, 0),(1, 1)}', 2 );
spoint
------------
(1 , 1)
(1 row)
Example 6.16. Get array representation of points
sql> SELECT spath_as_array( spath '{(0, 0),(1, 1)}');
spath_as_array
-----------------------
{"(0 , 0)","(1 , 1)"}
(1 row)