diff options
Diffstat (limited to 'src/test/regress/expected/geometry.out')
-rw-r--r-- | src/test/regress/expected/geometry.out | 4892 |
1 files changed, 4892 insertions, 0 deletions
diff --git a/src/test/regress/expected/geometry.out b/src/test/regress/expected/geometry.out new file mode 100644 index 0000000..5b9d370 --- /dev/null +++ b/src/test/regress/expected/geometry.out @@ -0,0 +1,4892 @@ +-- +-- GEOMETRY +-- +-- Back off displayed precision a little bit to reduce platform-to-platform +-- variation in results. +SET extra_float_digits TO -3; +-- +-- Points +-- +SELECT '' AS four, center(f1) AS center + FROM BOX_TBL; + four | center +------+--------- + | (1,1) + | (2,2) + | (-5,-4) + | (2.5,3) + | (3,3) +(5 rows) + +SELECT '' AS four, (@@ f1) AS center + FROM BOX_TBL; + four | center +------+--------- + | (1,1) + | (2,2) + | (-5,-4) + | (2.5,3) + | (3,3) +(5 rows) + +SELECT '' AS six, point(f1) AS center + FROM CIRCLE_TBL; + six | center +-----+----------- + | (5,1) + | (1,2) + | (1,3) + | (1,2) + | (100,200) + | (100,1) + | (3,5) + | (3,5) +(8 rows) + +SELECT '' AS six, (@@ f1) AS center + FROM CIRCLE_TBL; + six | center +-----+----------- + | (5,1) + | (1,2) + | (1,3) + | (1,2) + | (100,200) + | (100,1) + | (3,5) + | (3,5) +(8 rows) + +SELECT '' AS two, (@@ f1) AS center + FROM POLYGON_TBL + WHERE (# f1) > 2; + two | center +-----+------------------------------- + | (1.33333333333,1.33333333333) + | (2.33333333333,1.33333333333) + | (4,5) + | (4,5) + | (4,3) +(5 rows) + +-- "is horizontal" function +SELECT '' AS two, p1.f1 + FROM POINT_TBL p1 + WHERE ishorizontal(p1.f1, point '(0,0)'); + two | f1 +-----+------------------ + | (0,0) + | (-10,0) + | (1e-300,-1e-300) +(3 rows) + +-- "is horizontal" operator +SELECT '' AS two, p1.f1 + FROM POINT_TBL p1 + WHERE p1.f1 ?- point '(0,0)'; + two | f1 +-----+------------------ + | (0,0) + | (-10,0) + | (1e-300,-1e-300) +(3 rows) + +-- "is vertical" function +SELECT '' AS one, p1.f1 + FROM POINT_TBL p1 + WHERE isvertical(p1.f1, point '(5.1,34.5)'); + one | f1 +-----+------------ + | (5.1,34.5) +(1 row) + +-- "is vertical" operator +SELECT '' AS one, p1.f1 + FROM POINT_TBL p1 + WHERE p1.f1 ?| point '(5.1,34.5)'; + one | f1 +-----+------------ + | (5.1,34.5) +(1 row) + +-- Slope +SELECT p1.f1, p2.f1, slope(p1.f1, p2.f1) FROM POINT_TBL p1, POINT_TBL p2; + f1 | f1 | slope +-------------------+-------------------+-------------------- + (0,0) | (0,0) | 1.79769313486e+308 + (0,0) | (-10,0) | 0 + (0,0) | (-3,4) | -1.33333333333 + (0,0) | (5.1,34.5) | 6.76470588235 + (0,0) | (-5,-12) | 2.4 + (0,0) | (1e-300,-1e-300) | 1.79769313486e+308 + (0,0) | (1e+300,Infinity) | Infinity + (0,0) | (NaN,NaN) | NaN + (0,0) | (10,10) | 1 + (-10,0) | (0,0) | 0 + (-10,0) | (-10,0) | 1.79769313486e+308 + (-10,0) | (-3,4) | 0.571428571429 + (-10,0) | (5.1,34.5) | 2.28476821192 + (-10,0) | (-5,-12) | -2.4 + (-10,0) | (1e-300,-1e-300) | 0 + (-10,0) | (1e+300,Infinity) | Infinity + (-10,0) | (NaN,NaN) | NaN + (-10,0) | (10,10) | 0.5 + (-3,4) | (0,0) | -1.33333333333 + (-3,4) | (-10,0) | 0.571428571429 + (-3,4) | (-3,4) | 1.79769313486e+308 + (-3,4) | (5.1,34.5) | 3.76543209877 + (-3,4) | (-5,-12) | 8 + (-3,4) | (1e-300,-1e-300) | -1.33333333333 + (-3,4) | (1e+300,Infinity) | Infinity + (-3,4) | (NaN,NaN) | NaN + (-3,4) | (10,10) | 0.461538461538 + (5.1,34.5) | (0,0) | 6.76470588235 + (5.1,34.5) | (-10,0) | 2.28476821192 + (5.1,34.5) | (-3,4) | 3.76543209877 + (5.1,34.5) | (5.1,34.5) | 1.79769313486e+308 + (5.1,34.5) | (-5,-12) | 4.60396039604 + (5.1,34.5) | (1e-300,-1e-300) | 6.76470588235 + (5.1,34.5) | (1e+300,Infinity) | Infinity + (5.1,34.5) | (NaN,NaN) | NaN + (5.1,34.5) | (10,10) | -5 + (-5,-12) | (0,0) | 2.4 + (-5,-12) | (-10,0) | -2.4 + (-5,-12) | (-3,4) | 8 + (-5,-12) | (5.1,34.5) | 4.60396039604 + (-5,-12) | (-5,-12) | 1.79769313486e+308 + (-5,-12) | (1e-300,-1e-300) | 2.4 + (-5,-12) | (1e+300,Infinity) | Infinity + (-5,-12) | (NaN,NaN) | NaN + (-5,-12) | (10,10) | 1.46666666667 + (1e-300,-1e-300) | (0,0) | 1.79769313486e+308 + (1e-300,-1e-300) | (-10,0) | 0 + (1e-300,-1e-300) | (-3,4) | -1.33333333333 + (1e-300,-1e-300) | (5.1,34.5) | 6.76470588235 + (1e-300,-1e-300) | (-5,-12) | 2.4 + (1e-300,-1e-300) | (1e-300,-1e-300) | 1.79769313486e+308 + (1e-300,-1e-300) | (1e+300,Infinity) | Infinity + (1e-300,-1e-300) | (NaN,NaN) | NaN + (1e-300,-1e-300) | (10,10) | 1 + (1e+300,Infinity) | (0,0) | Infinity + (1e+300,Infinity) | (-10,0) | Infinity + (1e+300,Infinity) | (-3,4) | Infinity + (1e+300,Infinity) | (5.1,34.5) | Infinity + (1e+300,Infinity) | (-5,-12) | Infinity + (1e+300,Infinity) | (1e-300,-1e-300) | Infinity + (1e+300,Infinity) | (1e+300,Infinity) | 1.79769313486e+308 + (1e+300,Infinity) | (NaN,NaN) | NaN + (1e+300,Infinity) | (10,10) | Infinity + (NaN,NaN) | (0,0) | NaN + (NaN,NaN) | (-10,0) | NaN + (NaN,NaN) | (-3,4) | NaN + (NaN,NaN) | (5.1,34.5) | NaN + (NaN,NaN) | (-5,-12) | NaN + (NaN,NaN) | (1e-300,-1e-300) | NaN + (NaN,NaN) | (1e+300,Infinity) | NaN + (NaN,NaN) | (NaN,NaN) | NaN + (NaN,NaN) | (10,10) | NaN + (10,10) | (0,0) | 1 + (10,10) | (-10,0) | 0.5 + (10,10) | (-3,4) | 0.461538461538 + (10,10) | (5.1,34.5) | -5 + (10,10) | (-5,-12) | 1.46666666667 + (10,10) | (1e-300,-1e-300) | 1 + (10,10) | (1e+300,Infinity) | Infinity + (10,10) | (NaN,NaN) | NaN + (10,10) | (10,10) | 1.79769313486e+308 +(81 rows) + +-- Add point +SELECT p1.f1, p2.f1, p1.f1 + p2.f1 FROM POINT_TBL p1, POINT_TBL p2; + f1 | f1 | ?column? +-------------------+-------------------+------------------- + (0,0) | (0,0) | (0,0) + (0,0) | (-10,0) | (-10,0) + (0,0) | (-3,4) | (-3,4) + (0,0) | (5.1,34.5) | (5.1,34.5) + (0,0) | (-5,-12) | (-5,-12) + (0,0) | (1e-300,-1e-300) | (1e-300,-1e-300) + (0,0) | (1e+300,Infinity) | (1e+300,Infinity) + (0,0) | (NaN,NaN) | (NaN,NaN) + (0,0) | (10,10) | (10,10) + (-10,0) | (0,0) | (-10,0) + (-10,0) | (-10,0) | (-20,0) + (-10,0) | (-3,4) | (-13,4) + (-10,0) | (5.1,34.5) | (-4.9,34.5) + (-10,0) | (-5,-12) | (-15,-12) + (-10,0) | (1e-300,-1e-300) | (-10,-1e-300) + (-10,0) | (1e+300,Infinity) | (1e+300,Infinity) + (-10,0) | (NaN,NaN) | (NaN,NaN) + (-10,0) | (10,10) | (0,10) + (-3,4) | (0,0) | (-3,4) + (-3,4) | (-10,0) | (-13,4) + (-3,4) | (-3,4) | (-6,8) + (-3,4) | (5.1,34.5) | (2.1,38.5) + (-3,4) | (-5,-12) | (-8,-8) + (-3,4) | (1e-300,-1e-300) | (-3,4) + (-3,4) | (1e+300,Infinity) | (1e+300,Infinity) + (-3,4) | (NaN,NaN) | (NaN,NaN) + (-3,4) | (10,10) | (7,14) + (5.1,34.5) | (0,0) | (5.1,34.5) + (5.1,34.5) | (-10,0) | (-4.9,34.5) + (5.1,34.5) | (-3,4) | (2.1,38.5) + (5.1,34.5) | (5.1,34.5) | (10.2,69) + (5.1,34.5) | (-5,-12) | (0.1,22.5) + (5.1,34.5) | (1e-300,-1e-300) | (5.1,34.5) + (5.1,34.5) | (1e+300,Infinity) | (1e+300,Infinity) + (5.1,34.5) | (NaN,NaN) | (NaN,NaN) + (5.1,34.5) | (10,10) | (15.1,44.5) + (-5,-12) | (0,0) | (-5,-12) + (-5,-12) | (-10,0) | (-15,-12) + (-5,-12) | (-3,4) | (-8,-8) + (-5,-12) | (5.1,34.5) | (0.1,22.5) + (-5,-12) | (-5,-12) | (-10,-24) + (-5,-12) | (1e-300,-1e-300) | (-5,-12) + (-5,-12) | (1e+300,Infinity) | (1e+300,Infinity) + (-5,-12) | (NaN,NaN) | (NaN,NaN) + (-5,-12) | (10,10) | (5,-2) + (1e-300,-1e-300) | (0,0) | (1e-300,-1e-300) + (1e-300,-1e-300) | (-10,0) | (-10,-1e-300) + (1e-300,-1e-300) | (-3,4) | (-3,4) + (1e-300,-1e-300) | (5.1,34.5) | (5.1,34.5) + (1e-300,-1e-300) | (-5,-12) | (-5,-12) + (1e-300,-1e-300) | (1e-300,-1e-300) | (2e-300,-2e-300) + (1e-300,-1e-300) | (1e+300,Infinity) | (1e+300,Infinity) + (1e-300,-1e-300) | (NaN,NaN) | (NaN,NaN) + (1e-300,-1e-300) | (10,10) | (10,10) + (1e+300,Infinity) | (0,0) | (1e+300,Infinity) + (1e+300,Infinity) | (-10,0) | (1e+300,Infinity) + (1e+300,Infinity) | (-3,4) | (1e+300,Infinity) + (1e+300,Infinity) | (5.1,34.5) | (1e+300,Infinity) + (1e+300,Infinity) | (-5,-12) | (1e+300,Infinity) + (1e+300,Infinity) | (1e-300,-1e-300) | (1e+300,Infinity) + (1e+300,Infinity) | (1e+300,Infinity) | (2e+300,Infinity) + (1e+300,Infinity) | (NaN,NaN) | (NaN,NaN) + (1e+300,Infinity) | (10,10) | (1e+300,Infinity) + (NaN,NaN) | (0,0) | (NaN,NaN) + (NaN,NaN) | (-10,0) | (NaN,NaN) + (NaN,NaN) | (-3,4) | (NaN,NaN) + (NaN,NaN) | (5.1,34.5) | (NaN,NaN) + (NaN,NaN) | (-5,-12) | (NaN,NaN) + (NaN,NaN) | (1e-300,-1e-300) | (NaN,NaN) + (NaN,NaN) | (1e+300,Infinity) | (NaN,NaN) + (NaN,NaN) | (NaN,NaN) | (NaN,NaN) + (NaN,NaN) | (10,10) | (NaN,NaN) + (10,10) | (0,0) | (10,10) + (10,10) | (-10,0) | (0,10) + (10,10) | (-3,4) | (7,14) + (10,10) | (5.1,34.5) | (15.1,44.5) + (10,10) | (-5,-12) | (5,-2) + (10,10) | (1e-300,-1e-300) | (10,10) + (10,10) | (1e+300,Infinity) | (1e+300,Infinity) + (10,10) | (NaN,NaN) | (NaN,NaN) + (10,10) | (10,10) | (20,20) +(81 rows) + +-- Subtract point +SELECT p1.f1, p2.f1, p1.f1 - p2.f1 FROM POINT_TBL p1, POINT_TBL p2; + f1 | f1 | ?column? +-------------------+-------------------+--------------------- + (0,0) | (0,0) | (0,0) + (0,0) | (-10,0) | (10,0) + (0,0) | (-3,4) | (3,-4) + (0,0) | (5.1,34.5) | (-5.1,-34.5) + (0,0) | (-5,-12) | (5,12) + (0,0) | (1e-300,-1e-300) | (-1e-300,1e-300) + (0,0) | (1e+300,Infinity) | (-1e+300,-Infinity) + (0,0) | (NaN,NaN) | (NaN,NaN) + (0,0) | (10,10) | (-10,-10) + (-10,0) | (0,0) | (-10,0) + (-10,0) | (-10,0) | (0,0) + (-10,0) | (-3,4) | (-7,-4) + (-10,0) | (5.1,34.5) | (-15.1,-34.5) + (-10,0) | (-5,-12) | (-5,12) + (-10,0) | (1e-300,-1e-300) | (-10,1e-300) + (-10,0) | (1e+300,Infinity) | (-1e+300,-Infinity) + (-10,0) | (NaN,NaN) | (NaN,NaN) + (-10,0) | (10,10) | (-20,-10) + (-3,4) | (0,0) | (-3,4) + (-3,4) | (-10,0) | (7,4) + (-3,4) | (-3,4) | (0,0) + (-3,4) | (5.1,34.5) | (-8.1,-30.5) + (-3,4) | (-5,-12) | (2,16) + (-3,4) | (1e-300,-1e-300) | (-3,4) + (-3,4) | (1e+300,Infinity) | (-1e+300,-Infinity) + (-3,4) | (NaN,NaN) | (NaN,NaN) + (-3,4) | (10,10) | (-13,-6) + (5.1,34.5) | (0,0) | (5.1,34.5) + (5.1,34.5) | (-10,0) | (15.1,34.5) + (5.1,34.5) | (-3,4) | (8.1,30.5) + (5.1,34.5) | (5.1,34.5) | (0,0) + (5.1,34.5) | (-5,-12) | (10.1,46.5) + (5.1,34.5) | (1e-300,-1e-300) | (5.1,34.5) + (5.1,34.5) | (1e+300,Infinity) | (-1e+300,-Infinity) + (5.1,34.5) | (NaN,NaN) | (NaN,NaN) + (5.1,34.5) | (10,10) | (-4.9,24.5) + (-5,-12) | (0,0) | (-5,-12) + (-5,-12) | (-10,0) | (5,-12) + (-5,-12) | (-3,4) | (-2,-16) + (-5,-12) | (5.1,34.5) | (-10.1,-46.5) + (-5,-12) | (-5,-12) | (0,0) + (-5,-12) | (1e-300,-1e-300) | (-5,-12) + (-5,-12) | (1e+300,Infinity) | (-1e+300,-Infinity) + (-5,-12) | (NaN,NaN) | (NaN,NaN) + (-5,-12) | (10,10) | (-15,-22) + (1e-300,-1e-300) | (0,0) | (1e-300,-1e-300) + (1e-300,-1e-300) | (-10,0) | (10,-1e-300) + (1e-300,-1e-300) | (-3,4) | (3,-4) + (1e-300,-1e-300) | (5.1,34.5) | (-5.1,-34.5) + (1e-300,-1e-300) | (-5,-12) | (5,12) + (1e-300,-1e-300) | (1e-300,-1e-300) | (0,0) + (1e-300,-1e-300) | (1e+300,Infinity) | (-1e+300,-Infinity) + (1e-300,-1e-300) | (NaN,NaN) | (NaN,NaN) + (1e-300,-1e-300) | (10,10) | (-10,-10) + (1e+300,Infinity) | (0,0) | (1e+300,Infinity) + (1e+300,Infinity) | (-10,0) | (1e+300,Infinity) + (1e+300,Infinity) | (-3,4) | (1e+300,Infinity) + (1e+300,Infinity) | (5.1,34.5) | (1e+300,Infinity) + (1e+300,Infinity) | (-5,-12) | (1e+300,Infinity) + (1e+300,Infinity) | (1e-300,-1e-300) | (1e+300,Infinity) + (1e+300,Infinity) | (1e+300,Infinity) | (0,NaN) + (1e+300,Infinity) | (NaN,NaN) | (NaN,NaN) + (1e+300,Infinity) | (10,10) | (1e+300,Infinity) + (NaN,NaN) | (0,0) | (NaN,NaN) + (NaN,NaN) | (-10,0) | (NaN,NaN) + (NaN,NaN) | (-3,4) | (NaN,NaN) + (NaN,NaN) | (5.1,34.5) | (NaN,NaN) + (NaN,NaN) | (-5,-12) | (NaN,NaN) + (NaN,NaN) | (1e-300,-1e-300) | (NaN,NaN) + (NaN,NaN) | (1e+300,Infinity) | (NaN,NaN) + (NaN,NaN) | (NaN,NaN) | (NaN,NaN) + (NaN,NaN) | (10,10) | (NaN,NaN) + (10,10) | (0,0) | (10,10) + (10,10) | (-10,0) | (20,10) + (10,10) | (-3,4) | (13,6) + (10,10) | (5.1,34.5) | (4.9,-24.5) + (10,10) | (-5,-12) | (15,22) + (10,10) | (1e-300,-1e-300) | (10,10) + (10,10) | (1e+300,Infinity) | (-1e+300,-Infinity) + (10,10) | (NaN,NaN) | (NaN,NaN) + (10,10) | (10,10) | (0,0) +(81 rows) + +-- Multiply with point +SELECT p1.f1, p2.f1, p1.f1 * p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p1.f1[0] BETWEEN 1 AND 1000; + f1 | f1 | ?column? +------------+-------------------+----------------------- + (5.1,34.5) | (0,0) | (0,0) + (10,10) | (0,0) | (0,0) + (5.1,34.5) | (-10,0) | (-51,-345) + (10,10) | (-10,0) | (-100,-100) + (5.1,34.5) | (-3,4) | (-153.3,-83.1) + (10,10) | (-3,4) | (-70,10) + (5.1,34.5) | (5.1,34.5) | (-1164.24,351.9) + (10,10) | (5.1,34.5) | (-294,396) + (5.1,34.5) | (-5,-12) | (388.5,-233.7) + (10,10) | (-5,-12) | (70,-170) + (5.1,34.5) | (1e-300,-1e-300) | (3.96e-299,2.94e-299) + (10,10) | (1e-300,-1e-300) | (2e-299,0) + (5.1,34.5) | (1e+300,Infinity) | (-Infinity,Infinity) + (10,10) | (1e+300,Infinity) | (-Infinity,Infinity) + (5.1,34.5) | (NaN,NaN) | (NaN,NaN) + (10,10) | (NaN,NaN) | (NaN,NaN) + (5.1,34.5) | (10,10) | (-294,396) + (10,10) | (10,10) | (0,200) +(18 rows) + +-- Underflow error +SELECT p1.f1, p2.f1, p1.f1 * p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p1.f1[0] < 1; +ERROR: value out of range: underflow +-- Divide by point +SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p2.f1[0] BETWEEN 1 AND 1000; + f1 | f1 | ?column? +-------------------+------------+------------------------------------------- + (0,0) | (5.1,34.5) | (0,0) + (0,0) | (10,10) | (0,0) + (-10,0) | (5.1,34.5) | (-0.0419318237877,0.283656455034) + (-10,0) | (10,10) | (-0.5,0.5) + (-3,4) | (5.1,34.5) | (0.100883034877,0.101869666025) + (-3,4) | (10,10) | (0.05,0.35) + (5.1,34.5) | (5.1,34.5) | (1,0) + (5.1,34.5) | (10,10) | (1.98,1.47) + (-5,-12) | (5.1,34.5) | (-0.361353657935,0.0915100389719) + (-5,-12) | (10,10) | (-0.85,-0.35) + (1e-300,-1e-300) | (5.1,34.5) | (-2.41724631247e-302,-3.25588278822e-302) + (1e-300,-1e-300) | (10,10) | (0,-1e-301) + (1e+300,Infinity) | (5.1,34.5) | (Infinity,Infinity) + (1e+300,Infinity) | (10,10) | (Infinity,Infinity) + (NaN,NaN) | (5.1,34.5) | (NaN,NaN) + (NaN,NaN) | (10,10) | (NaN,NaN) + (10,10) | (5.1,34.5) | (0.325588278822,-0.241724631247) + (10,10) | (10,10) | (1,0) +(18 rows) + +-- Overflow error +SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p2.f1[0] > 1000; +ERROR: value out of range: overflow +-- Division by 0 error +SELECT p1.f1, p2.f1, p1.f1 / p2.f1 FROM POINT_TBL p1, POINT_TBL p2 WHERE p2.f1 ~= '(0,0)'::point; +ERROR: division by zero +-- Distance to line +SELECT p.f1, l.s, p.f1 <-> l.s AS dist_pl, l.s <-> p.f1 AS dist_lp FROM POINT_TBL p, LINE_TBL l; + f1 | s | dist_pl | dist_lp +-------------------+---------------------------------------+--------------------+-------------------- + (0,0) | {0,-1,5} | 5 | 5 + (0,0) | {1,0,5} | 5 | 5 + (0,0) | {0,3,0} | 0 | 0 + (0,0) | {1,-1,0} | 0 | 0 + (0,0) | {-0.4,-1,-6} | 5.57086014531 | 5.57086014531 + (0,0) | {-0.000184615384615,-1,15.3846153846} | 15.3846151224 | 15.3846151224 + (0,0) | {3,NaN,5} | NaN | NaN + (0,0) | {NaN,NaN,NaN} | NaN | NaN + (0,0) | {0,-1,3} | 3 | 3 + (0,0) | {-1,0,3} | 3 | 3 + (-10,0) | {0,-1,5} | 5 | 5 + (-10,0) | {1,0,5} | 5 | 5 + (-10,0) | {0,3,0} | 0 | 0 + (-10,0) | {1,-1,0} | 7.07106781187 | 7.07106781187 + (-10,0) | {-0.4,-1,-6} | 1.85695338177 | 1.85695338177 + (-10,0) | {-0.000184615384615,-1,15.3846153846} | 15.3864612763 | 15.3864612763 + (-10,0) | {3,NaN,5} | NaN | NaN + (-10,0) | {NaN,NaN,NaN} | NaN | NaN + (-10,0) | {0,-1,3} | 3 | 3 + (-10,0) | {-1,0,3} | 13 | 13 + (-3,4) | {0,-1,5} | 1 | 1 + (-3,4) | {1,0,5} | 2 | 2 + (-3,4) | {0,3,0} | 4 | 4 + (-3,4) | {1,-1,0} | 4.94974746831 | 4.94974746831 + (-3,4) | {-0.4,-1,-6} | 8.17059487979 | 8.17059487979 + (-3,4) | {-0.000184615384615,-1,15.3846153846} | 11.3851690368 | 11.3851690368 + (-3,4) | {3,NaN,5} | NaN | NaN + (-3,4) | {NaN,NaN,NaN} | NaN | NaN + (-3,4) | {0,-1,3} | 1 | 1 + (-3,4) | {-1,0,3} | 6 | 6 + (5.1,34.5) | {0,-1,5} | 29.5 | 29.5 + (5.1,34.5) | {1,0,5} | 10.1 | 10.1 + (5.1,34.5) | {0,3,0} | 34.5 | 34.5 + (5.1,34.5) | {1,-1,0} | 20.7889393669 | 20.7889393669 + (5.1,34.5) | {-0.4,-1,-6} | 39.4973984303 | 39.4973984303 + (5.1,34.5) | {-0.000184615384615,-1,15.3846153846} | 19.1163258281 | 19.1163258281 + (5.1,34.5) | {3,NaN,5} | NaN | NaN + (5.1,34.5) | {NaN,NaN,NaN} | NaN | NaN + (5.1,34.5) | {0,-1,3} | 31.5 | 31.5 + (5.1,34.5) | {-1,0,3} | 2.1 | 2.1 + (-5,-12) | {0,-1,5} | 17 | 17 + (-5,-12) | {1,0,5} | 0 | 0 + (-5,-12) | {0,3,0} | 12 | 12 + (-5,-12) | {1,-1,0} | 4.94974746831 | 4.94974746831 + (-5,-12) | {-0.4,-1,-6} | 7.42781352708 | 7.42781352708 + (-5,-12) | {-0.000184615384615,-1,15.3846153846} | 27.3855379948 | 27.3855379948 + (-5,-12) | {3,NaN,5} | NaN | NaN + (-5,-12) | {NaN,NaN,NaN} | NaN | NaN + (-5,-12) | {0,-1,3} | 15 | 15 + (-5,-12) | {-1,0,3} | 8 | 8 + (1e-300,-1e-300) | {0,-1,5} | 5 | 5 + (1e-300,-1e-300) | {1,0,5} | 5 | 5 + (1e-300,-1e-300) | {0,3,0} | 1e-300 | 1e-300 + (1e-300,-1e-300) | {1,-1,0} | 1.41421356237e-300 | 1.41421356237e-300 + (1e-300,-1e-300) | {-0.4,-1,-6} | 5.57086014531 | 5.57086014531 + (1e-300,-1e-300) | {-0.000184615384615,-1,15.3846153846} | 15.3846151224 | 15.3846151224 + (1e-300,-1e-300) | {3,NaN,5} | NaN | NaN + (1e-300,-1e-300) | {NaN,NaN,NaN} | NaN | NaN + (1e-300,-1e-300) | {0,-1,3} | 3 | 3 + (1e-300,-1e-300) | {-1,0,3} | 3 | 3 + (1e+300,Infinity) | {0,-1,5} | Infinity | Infinity + (1e+300,Infinity) | {1,0,5} | NaN | NaN + (1e+300,Infinity) | {0,3,0} | Infinity | Infinity + (1e+300,Infinity) | {1,-1,0} | Infinity | Infinity + (1e+300,Infinity) | {-0.4,-1,-6} | Infinity | Infinity + (1e+300,Infinity) | {-0.000184615384615,-1,15.3846153846} | Infinity | Infinity + (1e+300,Infinity) | {3,NaN,5} | NaN | NaN + (1e+300,Infinity) | {NaN,NaN,NaN} | NaN | NaN + (1e+300,Infinity) | {0,-1,3} | Infinity | Infinity + (1e+300,Infinity) | {-1,0,3} | NaN | NaN + (NaN,NaN) | {0,-1,5} | NaN | NaN + (NaN,NaN) | {1,0,5} | NaN | NaN + (NaN,NaN) | {0,3,0} | NaN | NaN + (NaN,NaN) | {1,-1,0} | NaN | NaN + (NaN,NaN) | {-0.4,-1,-6} | NaN | NaN + (NaN,NaN) | {-0.000184615384615,-1,15.3846153846} | NaN | NaN + (NaN,NaN) | {3,NaN,5} | NaN | NaN + (NaN,NaN) | {NaN,NaN,NaN} | NaN | NaN + (NaN,NaN) | {0,-1,3} | NaN | NaN + (NaN,NaN) | {-1,0,3} | NaN | NaN + (10,10) | {0,-1,5} | 5 | 5 + (10,10) | {1,0,5} | 15 | 15 + (10,10) | {0,3,0} | 10 | 10 + (10,10) | {1,-1,0} | 0 | 0 + (10,10) | {-0.4,-1,-6} | 18.5695338177 | 18.5695338177 + (10,10) | {-0.000184615384615,-1,15.3846153846} | 5.38276913903 | 5.38276913903 + (10,10) | {3,NaN,5} | NaN | NaN + (10,10) | {NaN,NaN,NaN} | NaN | NaN + (10,10) | {0,-1,3} | 7 | 7 + (10,10) | {-1,0,3} | 7 | 7 +(90 rows) + +-- Distance to line segment +SELECT p.f1, l.s, p.f1 <-> l.s AS dist_ps, l.s <-> p.f1 AS dist_sp FROM POINT_TBL p, LSEG_TBL l; + f1 | s | dist_ps | dist_sp +-------------------+-------------------------------+--------------------+-------------------- + (0,0) | [(1,2),(3,4)] | 2.2360679775 | 2.2360679775 + (0,0) | [(0,0),(6,6)] | 0 | 0 + (0,0) | [(10,-10),(-3,-4)] | 4.88901207039 | 4.88901207039 + (0,0) | [(-1000000,200),(300000,-40)] | 15.3846151224 | 15.3846151224 + (0,0) | [(11,22),(33,44)] | 24.5967477525 | 24.5967477525 + (0,0) | [(-10,2),(-10,3)] | 10.1980390272 | 10.1980390272 + (0,0) | [(0,-20),(30,-20)] | 20 | 20 + (0,0) | [(NaN,1),(NaN,90)] | NaN | NaN + (-10,0) | [(1,2),(3,4)] | 11.1803398875 | 11.1803398875 + (-10,0) | [(0,0),(6,6)] | 10 | 10 + (-10,0) | [(10,-10),(-3,-4)] | 8.0622577483 | 8.0622577483 + (-10,0) | [(-1000000,200),(300000,-40)] | 15.3864612763 | 15.3864612763 + (-10,0) | [(11,22),(33,44)] | 30.4138126515 | 30.4138126515 + (-10,0) | [(-10,2),(-10,3)] | 2 | 2 + (-10,0) | [(0,-20),(30,-20)] | 22.360679775 | 22.360679775 + (-10,0) | [(NaN,1),(NaN,90)] | NaN | NaN + (-3,4) | [(1,2),(3,4)] | 4.472135955 | 4.472135955 + (-3,4) | [(0,0),(6,6)] | 4.94974746831 | 4.94974746831 + (-3,4) | [(10,-10),(-3,-4)] | 8 | 8 + (-3,4) | [(-1000000,200),(300000,-40)] | 11.3851690367 | 11.3851690367 + (-3,4) | [(11,22),(33,44)] | 22.803508502 | 22.803508502 + (-3,4) | [(-10,2),(-10,3)] | 7.07106781187 | 7.07106781187 + (-3,4) | [(0,-20),(30,-20)] | 24.1867732449 | 24.1867732449 + (-3,4) | [(NaN,1),(NaN,90)] | NaN | NaN + (5.1,34.5) | [(1,2),(3,4)] | 30.5722096028 | 30.5722096028 + (5.1,34.5) | [(0,0),(6,6)] | 28.5142069853 | 28.5142069853 + (5.1,34.5) | [(10,-10),(-3,-4)] | 39.3428519556 | 39.3428519556 + (5.1,34.5) | [(-1000000,200),(300000,-40)] | 19.1163258281 | 19.1163258281 + (5.1,34.5) | [(11,22),(33,44)] | 13.0107647738 | 13.0107647738 + (5.1,34.5) | [(-10,2),(-10,3)] | 34.932220084 | 34.932220084 + (5.1,34.5) | [(0,-20),(30,-20)] | 54.5 | 54.5 + (5.1,34.5) | [(NaN,1),(NaN,90)] | NaN | NaN + (-5,-12) | [(1,2),(3,4)] | 15.2315462117 | 15.2315462117 + (-5,-12) | [(0,0),(6,6)] | 13 | 13 + (-5,-12) | [(10,-10),(-3,-4)] | 8.10179143093 | 8.10179143093 + (-5,-12) | [(-1000000,200),(300000,-40)] | 27.3855379949 | 27.3855379949 + (-5,-12) | [(11,22),(33,44)] | 37.5765884561 | 37.5765884561 + (-5,-12) | [(-10,2),(-10,3)] | 14.8660687473 | 14.8660687473 + (-5,-12) | [(0,-20),(30,-20)] | 9.43398113206 | 9.43398113206 + (-5,-12) | [(NaN,1),(NaN,90)] | NaN | NaN + (1e-300,-1e-300) | [(1,2),(3,4)] | 2.2360679775 | 2.2360679775 + (1e-300,-1e-300) | [(0,0),(6,6)] | 1.41421356237e-300 | 1.41421356237e-300 + (1e-300,-1e-300) | [(10,-10),(-3,-4)] | 4.88901207039 | 4.88901207039 + (1e-300,-1e-300) | [(-1000000,200),(300000,-40)] | 15.3846151224 | 15.3846151224 + (1e-300,-1e-300) | [(11,22),(33,44)] | 24.5967477525 | 24.5967477525 + (1e-300,-1e-300) | [(-10,2),(-10,3)] | 10.1980390272 | 10.1980390272 + (1e-300,-1e-300) | [(0,-20),(30,-20)] | 20 | 20 + (1e-300,-1e-300) | [(NaN,1),(NaN,90)] | NaN | NaN + (1e+300,Infinity) | [(1,2),(3,4)] | Infinity | Infinity + (1e+300,Infinity) | [(0,0),(6,6)] | Infinity | Infinity + (1e+300,Infinity) | [(10,-10),(-3,-4)] | Infinity | Infinity + (1e+300,Infinity) | [(-1000000,200),(300000,-40)] | Infinity | Infinity + (1e+300,Infinity) | [(11,22),(33,44)] | Infinity | Infinity + (1e+300,Infinity) | [(-10,2),(-10,3)] | Infinity | Infinity + (1e+300,Infinity) | [(0,-20),(30,-20)] | Infinity | Infinity + (1e+300,Infinity) | [(NaN,1),(NaN,90)] | Infinity | Infinity + (NaN,NaN) | [(1,2),(3,4)] | NaN | NaN + (NaN,NaN) | [(0,0),(6,6)] | NaN | NaN + (NaN,NaN) | [(10,-10),(-3,-4)] | NaN | NaN + (NaN,NaN) | [(-1000000,200),(300000,-40)] | NaN | NaN + (NaN,NaN) | [(11,22),(33,44)] | NaN | NaN + (NaN,NaN) | [(-10,2),(-10,3)] | NaN | NaN + (NaN,NaN) | [(0,-20),(30,-20)] | NaN | NaN + (NaN,NaN) | [(NaN,1),(NaN,90)] | NaN | NaN + (10,10) | [(1,2),(3,4)] | 9.21954445729 | 9.21954445729 + (10,10) | [(0,0),(6,6)] | 5.65685424949 | 5.65685424949 + (10,10) | [(10,-10),(-3,-4)] | 18.15918769 | 18.15918769 + (10,10) | [(-1000000,200),(300000,-40)] | 5.38276913904 | 5.38276913904 + (10,10) | [(11,22),(33,44)] | 12.0415945788 | 12.0415945788 + (10,10) | [(-10,2),(-10,3)] | 21.1896201004 | 21.1896201004 + (10,10) | [(0,-20),(30,-20)] | 30 | 30 + (10,10) | [(NaN,1),(NaN,90)] | NaN | NaN +(72 rows) + +-- Distance to box +SELECT p.f1, b.f1, p.f1 <-> b.f1 AS dist_pb, b.f1 <-> p.f1 AS dist_bp FROM POINT_TBL p, BOX_TBL b; + f1 | f1 | dist_pb | dist_bp +-------------------+---------------------+--------------------+-------------------- + (0,0) | (2,2),(0,0) | 0 | 0 + (0,0) | (3,3),(1,1) | 1.41421356237 | 1.41421356237 + (0,0) | (-2,2),(-8,-10) | 2 | 2 + (0,0) | (2.5,3.5),(2.5,2.5) | 3.53553390593 | 3.53553390593 + (0,0) | (3,3),(3,3) | 4.24264068712 | 4.24264068712 + (-10,0) | (2,2),(0,0) | 10 | 10 + (-10,0) | (3,3),(1,1) | 11.0453610172 | 11.0453610172 + (-10,0) | (-2,2),(-8,-10) | 2 | 2 + (-10,0) | (2.5,3.5),(2.5,2.5) | 12.747548784 | 12.747548784 + (-10,0) | (3,3),(3,3) | 13.3416640641 | 13.3416640641 + (-3,4) | (2,2),(0,0) | 3.60555127546 | 3.60555127546 + (-3,4) | (3,3),(1,1) | 4.12310562562 | 4.12310562562 + (-3,4) | (-2,2),(-8,-10) | 2 | 2 + (-3,4) | (2.5,3.5),(2.5,2.5) | 5.52268050859 | 5.52268050859 + (-3,4) | (3,3),(3,3) | 6.0827625303 | 6.0827625303 + (5.1,34.5) | (2,2),(0,0) | 32.6475113906 | 32.6475113906 + (5.1,34.5) | (3,3),(1,1) | 31.5699223946 | 31.5699223946 + (5.1,34.5) | (-2,2),(-8,-10) | 33.2664996656 | 33.2664996656 + (5.1,34.5) | (2.5,3.5),(2.5,2.5) | 31.108841187 | 31.108841187 + (5.1,34.5) | (3,3),(3,3) | 31.5699223946 | 31.5699223946 + (-5,-12) | (2,2),(0,0) | 13 | 13 + (-5,-12) | (3,3),(1,1) | 14.3178210633 | 14.3178210633 + (-5,-12) | (-2,2),(-8,-10) | 2 | 2 + (-5,-12) | (2.5,3.5),(2.5,2.5) | 16.3248277173 | 16.3248277173 + (-5,-12) | (3,3),(3,3) | 17 | 17 + (1e-300,-1e-300) | (2,2),(0,0) | 1.41421356237e-300 | 1.41421356237e-300 + (1e-300,-1e-300) | (3,3),(1,1) | 1.41421356237 | 1.41421356237 + (1e-300,-1e-300) | (-2,2),(-8,-10) | 2 | 2 + (1e-300,-1e-300) | (2.5,3.5),(2.5,2.5) | 3.53553390593 | 3.53553390593 + (1e-300,-1e-300) | (3,3),(3,3) | 4.24264068712 | 4.24264068712 + (1e+300,Infinity) | (2,2),(0,0) | Infinity | Infinity + (1e+300,Infinity) | (3,3),(1,1) | Infinity | Infinity + (1e+300,Infinity) | (-2,2),(-8,-10) | Infinity | Infinity + (1e+300,Infinity) | (2.5,3.5),(2.5,2.5) | Infinity | Infinity + (1e+300,Infinity) | (3,3),(3,3) | Infinity | Infinity + (NaN,NaN) | (2,2),(0,0) | NaN | NaN + (NaN,NaN) | (3,3),(1,1) | NaN | NaN + (NaN,NaN) | (-2,2),(-8,-10) | NaN | NaN + (NaN,NaN) | (2.5,3.5),(2.5,2.5) | NaN | NaN + (NaN,NaN) | (3,3),(3,3) | NaN | NaN + (10,10) | (2,2),(0,0) | 11.313708499 | 11.313708499 + (10,10) | (3,3),(1,1) | 9.89949493661 | 9.89949493661 + (10,10) | (-2,2),(-8,-10) | 14.4222051019 | 14.4222051019 + (10,10) | (2.5,3.5),(2.5,2.5) | 9.92471662064 | 9.92471662064 + (10,10) | (3,3),(3,3) | 9.89949493661 | 9.89949493661 +(45 rows) + +-- Distance to path +SELECT p.f1, p1.f1, p.f1 <-> p1.f1 AS dist_ppath, p1.f1 <-> p.f1 AS dist_pathp FROM POINT_TBL p, PATH_TBL p1; + f1 | f1 | dist_ppath | dist_pathp +-------------------+---------------------------+--------------------+-------------------- + (0,0) | [(1,2),(3,4)] | 2.2360679775 | 2.2360679775 + (0,0) | ((1,2),(3,4)) | 2.2360679775 | 2.2360679775 + (0,0) | [(0,0),(3,0),(4,5),(1,6)] | 0 | 0 + (0,0) | ((1,2),(3,4)) | 2.2360679775 | 2.2360679775 + (0,0) | ((1,2),(3,4)) | 2.2360679775 | 2.2360679775 + (0,0) | [(1,2),(3,4)] | 2.2360679775 | 2.2360679775 + (0,0) | ((10,20)) | 22.360679775 | 22.360679775 + (0,0) | [(11,12),(13,14)] | 16.2788205961 | 16.2788205961 + (0,0) | ((11,12),(13,14)) | 16.2788205961 | 16.2788205961 + (-10,0) | [(1,2),(3,4)] | 11.1803398875 | 11.1803398875 + (-10,0) | ((1,2),(3,4)) | 11.1803398875 | 11.1803398875 + (-10,0) | [(0,0),(3,0),(4,5),(1,6)] | 10 | 10 + (-10,0) | ((1,2),(3,4)) | 11.1803398875 | 11.1803398875 + (-10,0) | ((1,2),(3,4)) | 11.1803398875 | 11.1803398875 + (-10,0) | [(1,2),(3,4)] | 11.1803398875 | 11.1803398875 + (-10,0) | ((10,20)) | 28.2842712475 | 28.2842712475 + (-10,0) | [(11,12),(13,14)] | 24.1867732449 | 24.1867732449 + (-10,0) | ((11,12),(13,14)) | 24.1867732449 | 24.1867732449 + (-3,4) | [(1,2),(3,4)] | 4.472135955 | 4.472135955 + (-3,4) | ((1,2),(3,4)) | 4.472135955 | 4.472135955 + (-3,4) | [(0,0),(3,0),(4,5),(1,6)] | 4.472135955 | 4.472135955 + (-3,4) | ((1,2),(3,4)) | 4.472135955 | 4.472135955 + (-3,4) | ((1,2),(3,4)) | 4.472135955 | 4.472135955 + (-3,4) | [(1,2),(3,4)] | 4.472135955 | 4.472135955 + (-3,4) | ((10,20)) | 20.6155281281 | 20.6155281281 + (-3,4) | [(11,12),(13,14)] | 16.1245154966 | 16.1245154966 + (-3,4) | ((11,12),(13,14)) | 16.1245154966 | 16.1245154966 + (5.1,34.5) | [(1,2),(3,4)] | 30.5722096028 | 30.5722096028 + (5.1,34.5) | ((1,2),(3,4)) | 30.5722096028 | 30.5722096028 + (5.1,34.5) | [(0,0),(3,0),(4,5),(1,6)] | 28.793402022 | 28.793402022 + (5.1,34.5) | ((1,2),(3,4)) | 30.5722096028 | 30.5722096028 + (5.1,34.5) | ((1,2),(3,4)) | 30.5722096028 | 30.5722096028 + (5.1,34.5) | [(1,2),(3,4)] | 30.5722096028 | 30.5722096028 + (5.1,34.5) | ((10,20)) | 15.3055545473 | 15.3055545473 + (5.1,34.5) | [(11,12),(13,14)] | 21.9695243462 | 21.9695243462 + (5.1,34.5) | ((11,12),(13,14)) | 21.9695243462 | 21.9695243462 + (-5,-12) | [(1,2),(3,4)] | 15.2315462117 | 15.2315462117 + (-5,-12) | ((1,2),(3,4)) | 15.2315462117 | 15.2315462117 + (-5,-12) | [(0,0),(3,0),(4,5),(1,6)] | 13 | 13 + (-5,-12) | ((1,2),(3,4)) | 15.2315462117 | 15.2315462117 + (-5,-12) | ((1,2),(3,4)) | 15.2315462117 | 15.2315462117 + (-5,-12) | [(1,2),(3,4)] | 15.2315462117 | 15.2315462117 + (-5,-12) | ((10,20)) | 35.3411940941 | 35.3411940941 + (-5,-12) | [(11,12),(13,14)] | 28.8444102037 | 28.8444102037 + (-5,-12) | ((11,12),(13,14)) | 28.8444102037 | 28.8444102037 + (1e-300,-1e-300) | [(1,2),(3,4)] | 2.2360679775 | 2.2360679775 + (1e-300,-1e-300) | ((1,2),(3,4)) | 2.2360679775 | 2.2360679775 + (1e-300,-1e-300) | [(0,0),(3,0),(4,5),(1,6)] | 1.41421356237e-300 | 1.41421356237e-300 + (1e-300,-1e-300) | ((1,2),(3,4)) | 2.2360679775 | 2.2360679775 + (1e-300,-1e-300) | ((1,2),(3,4)) | 2.2360679775 | 2.2360679775 + (1e-300,-1e-300) | [(1,2),(3,4)] | 2.2360679775 | 2.2360679775 + (1e-300,-1e-300) | ((10,20)) | 22.360679775 | 22.360679775 + (1e-300,-1e-300) | [(11,12),(13,14)] | 16.2788205961 | 16.2788205961 + (1e-300,-1e-300) | ((11,12),(13,14)) | 16.2788205961 | 16.2788205961 + (1e+300,Infinity) | [(1,2),(3,4)] | Infinity | Infinity + (1e+300,Infinity) | ((1,2),(3,4)) | Infinity | Infinity + (1e+300,Infinity) | [(0,0),(3,0),(4,5),(1,6)] | Infinity | Infinity + (1e+300,Infinity) | ((1,2),(3,4)) | Infinity | Infinity + (1e+300,Infinity) | ((1,2),(3,4)) | Infinity | Infinity + (1e+300,Infinity) | [(1,2),(3,4)] | Infinity | Infinity + (1e+300,Infinity) | ((10,20)) | Infinity | Infinity + (1e+300,Infinity) | [(11,12),(13,14)] | Infinity | Infinity + (1e+300,Infinity) | ((11,12),(13,14)) | Infinity | Infinity + (NaN,NaN) | [(1,2),(3,4)] | NaN | NaN + (NaN,NaN) | ((1,2),(3,4)) | NaN | NaN + (NaN,NaN) | [(0,0),(3,0),(4,5),(1,6)] | NaN | NaN + (NaN,NaN) | ((1,2),(3,4)) | NaN | NaN + (NaN,NaN) | ((1,2),(3,4)) | NaN | NaN + (NaN,NaN) | [(1,2),(3,4)] | NaN | NaN + (NaN,NaN) | ((10,20)) | NaN | NaN + (NaN,NaN) | [(11,12),(13,14)] | NaN | NaN + (NaN,NaN) | ((11,12),(13,14)) | NaN | NaN + (10,10) | [(1,2),(3,4)] | 9.21954445729 | 9.21954445729 + (10,10) | ((1,2),(3,4)) | 9.21954445729 | 9.21954445729 + (10,10) | [(0,0),(3,0),(4,5),(1,6)] | 7.81024967591 | 7.81024967591 + (10,10) | ((1,2),(3,4)) | 9.21954445729 | 9.21954445729 + (10,10) | ((1,2),(3,4)) | 9.21954445729 | 9.21954445729 + (10,10) | [(1,2),(3,4)] | 9.21954445729 | 9.21954445729 + (10,10) | ((10,20)) | 10 | 10 + (10,10) | [(11,12),(13,14)] | 2.2360679775 | 2.2360679775 + (10,10) | ((11,12),(13,14)) | 2.2360679775 | 2.2360679775 +(81 rows) + +-- Distance to polygon +SELECT p.f1, p1.f1, p.f1 <-> p1.f1 AS dist_ppoly, p1.f1 <-> p.f1 AS dist_polyp FROM POINT_TBL p, POLYGON_TBL p1; + f1 | f1 | dist_ppoly | dist_polyp +-------------------+----------------------------+---------------+--------------- + (0,0) | ((2,0),(2,4),(0,0)) | 0 | 0 + (0,0) | ((3,1),(3,3),(1,0)) | 1 | 1 + (0,0) | ((1,2),(3,4),(5,6),(7,8)) | 2.2360679775 | 2.2360679775 + (0,0) | ((7,8),(5,6),(3,4),(1,2)) | 2.2360679775 | 2.2360679775 + (0,0) | ((1,2),(7,8),(5,6),(3,-4)) | 1.58113883008 | 1.58113883008 + (0,0) | ((0,0)) | 0 | 0 + (0,0) | ((0,1),(0,1)) | 1 | 1 + (-10,0) | ((2,0),(2,4),(0,0)) | 10 | 10 + (-10,0) | ((3,1),(3,3),(1,0)) | 11 | 11 + (-10,0) | ((1,2),(3,4),(5,6),(7,8)) | 11.1803398875 | 11.1803398875 + (-10,0) | ((7,8),(5,6),(3,4),(1,2)) | 11.1803398875 | 11.1803398875 + (-10,0) | ((1,2),(7,8),(5,6),(3,-4)) | 11.1803398875 | 11.1803398875 + (-10,0) | ((0,0)) | 10 | 10 + (-10,0) | ((0,1),(0,1)) | 10.0498756211 | 10.0498756211 + (-3,4) | ((2,0),(2,4),(0,0)) | 4.472135955 | 4.472135955 + (-3,4) | ((3,1),(3,3),(1,0)) | 5.54700196225 | 5.54700196225 + (-3,4) | ((1,2),(3,4),(5,6),(7,8)) | 4.472135955 | 4.472135955 + (-3,4) | ((7,8),(5,6),(3,4),(1,2)) | 4.472135955 | 4.472135955 + (-3,4) | ((1,2),(7,8),(5,6),(3,-4)) | 4.472135955 | 4.472135955 + (-3,4) | ((0,0)) | 5 | 5 + (-3,4) | ((0,1),(0,1)) | 4.24264068712 | 4.24264068712 + (5.1,34.5) | ((2,0),(2,4),(0,0)) | 30.6571362002 | 30.6571362002 + (5.1,34.5) | ((3,1),(3,3),(1,0)) | 31.5699223946 | 31.5699223946 + (5.1,34.5) | ((1,2),(3,4),(5,6),(7,8)) | 26.5680258958 | 26.5680258958 + (5.1,34.5) | ((7,8),(5,6),(3,4),(1,2)) | 26.5680258958 | 26.5680258958 + (5.1,34.5) | ((1,2),(7,8),(5,6),(3,-4)) | 26.5680258958 | 26.5680258958 + (5.1,34.5) | ((0,0)) | 34.8749193547 | 34.8749193547 + (5.1,34.5) | ((0,1),(0,1)) | 33.8859853037 | 33.8859853037 + (-5,-12) | ((2,0),(2,4),(0,0)) | 13 | 13 + (-5,-12) | ((3,1),(3,3),(1,0)) | 13.416407865 | 13.416407865 + (-5,-12) | ((1,2),(3,4),(5,6),(7,8)) | 15.2315462117 | 15.2315462117 + (-5,-12) | ((7,8),(5,6),(3,4),(1,2)) | 15.2315462117 | 15.2315462117 + (-5,-12) | ((1,2),(7,8),(5,6),(3,-4)) | 11.313708499 | 11.313708499 + (-5,-12) | ((0,0)) | 13 | 13 + (-5,-12) | ((0,1),(0,1)) | 13.9283882772 | 13.9283882772 + (1e-300,-1e-300) | ((2,0),(2,4),(0,0)) | 0 | 0 + (1e-300,-1e-300) | ((3,1),(3,3),(1,0)) | 1 | 1 + (1e-300,-1e-300) | ((1,2),(3,4),(5,6),(7,8)) | 2.2360679775 | 2.2360679775 + (1e-300,-1e-300) | ((7,8),(5,6),(3,4),(1,2)) | 2.2360679775 | 2.2360679775 + (1e-300,-1e-300) | ((1,2),(7,8),(5,6),(3,-4)) | 1.58113883008 | 1.58113883008 + (1e-300,-1e-300) | ((0,0)) | 0 | 0 + (1e-300,-1e-300) | ((0,1),(0,1)) | 1 | 1 + (1e+300,Infinity) | ((2,0),(2,4),(0,0)) | Infinity | Infinity + (1e+300,Infinity) | ((3,1),(3,3),(1,0)) | Infinity | Infinity + (1e+300,Infinity) | ((1,2),(3,4),(5,6),(7,8)) | Infinity | Infinity + (1e+300,Infinity) | ((7,8),(5,6),(3,4),(1,2)) | Infinity | Infinity + (1e+300,Infinity) | ((1,2),(7,8),(5,6),(3,-4)) | Infinity | Infinity + (1e+300,Infinity) | ((0,0)) | Infinity | Infinity + (1e+300,Infinity) | ((0,1),(0,1)) | Infinity | Infinity + (NaN,NaN) | ((2,0),(2,4),(0,0)) | 0 | 0 + (NaN,NaN) | ((3,1),(3,3),(1,0)) | 0 | 0 + (NaN,NaN) | ((1,2),(3,4),(5,6),(7,8)) | 0 | 0 + (NaN,NaN) | ((7,8),(5,6),(3,4),(1,2)) | 0 | 0 + (NaN,NaN) | ((1,2),(7,8),(5,6),(3,-4)) | 0 | 0 + (NaN,NaN) | ((0,0)) | 0 | 0 + (NaN,NaN) | ((0,1),(0,1)) | 0 | 0 + (10,10) | ((2,0),(2,4),(0,0)) | 10 | 10 + (10,10) | ((3,1),(3,3),(1,0)) | 9.89949493661 | 9.89949493661 + (10,10) | ((1,2),(3,4),(5,6),(7,8)) | 3.60555127546 | 3.60555127546 + (10,10) | ((7,8),(5,6),(3,4),(1,2)) | 3.60555127546 | 3.60555127546 + (10,10) | ((1,2),(7,8),(5,6),(3,-4)) | 3.60555127546 | 3.60555127546 + (10,10) | ((0,0)) | 14.1421356237 | 14.1421356237 + (10,10) | ((0,1),(0,1)) | 13.4536240471 | 13.4536240471 +(63 rows) + +-- Closest point to line +SELECT p.f1, l.s, p.f1 ## l.s FROM POINT_TBL p, LINE_TBL l; + f1 | s | ?column? +-------------------+---------------------------------------+---------------------------------- + (0,0) | {0,-1,5} | (0,5) + (0,0) | {1,0,5} | (-5,0) + (0,0) | {0,3,0} | (0,0) + (0,0) | {1,-1,0} | (0,0) + (0,0) | {-0.4,-1,-6} | (-2.06896551724,-5.1724137931) + (0,0) | {-0.000184615384615,-1,15.3846153846} | (0.00284023658959,15.3846148603) + (0,0) | {3,NaN,5} | + (0,0) | {NaN,NaN,NaN} | + (0,0) | {0,-1,3} | (0,3) + (0,0) | {-1,0,3} | (3,0) + (-10,0) | {0,-1,5} | (-10,5) + (-10,0) | {1,0,5} | (-5,0) + (-10,0) | {0,3,0} | (-10,0) + (-10,0) | {1,-1,0} | (-5,-5) + (-10,0) | {-0.4,-1,-6} | (-10.6896551724,-1.72413793103) + (-10,0) | {-0.000184615384615,-1,15.3846153846} | (-9.99715942258,15.386461014) + (-10,0) | {3,NaN,5} | + (-10,0) | {NaN,NaN,NaN} | + (-10,0) | {0,-1,3} | (-10,3) + (-10,0) | {-1,0,3} | (3,0) + (-3,4) | {0,-1,5} | (-3,5) + (-3,4) | {1,0,5} | (-5,4) + (-3,4) | {0,3,0} | (-3,0) + (-3,4) | {1,-1,0} | (0.5,0.5) + (-3,4) | {-0.4,-1,-6} | (-6.03448275862,-3.58620689655) + (-3,4) | {-0.000184615384615,-1,15.3846153846} | (-2.99789812268,15.3851688427) + (-3,4) | {3,NaN,5} | + (-3,4) | {NaN,NaN,NaN} | + (-3,4) | {0,-1,3} | (-3,3) + (-3,4) | {-1,0,3} | (3,4) + (5.1,34.5) | {0,-1,5} | (5.1,5) + (5.1,34.5) | {1,0,5} | (-5,34.5) + (5.1,34.5) | {0,3,0} | (5.1,0) + (5.1,34.5) | {1,-1,0} | (19.8,19.8) + (5.1,34.5) | {-0.4,-1,-6} | (-9.56896551724,-2.1724137931) + (5.1,34.5) | {-0.000184615384615,-1,15.3846153846} | (5.09647083221,15.3836744977) + (5.1,34.5) | {3,NaN,5} | + (5.1,34.5) | {NaN,NaN,NaN} | + (5.1,34.5) | {0,-1,3} | (5.1,3) + (5.1,34.5) | {-1,0,3} | (3,34.5) + (-5,-12) | {0,-1,5} | (-5,5) + (-5,-12) | {1,0,5} | (-5,-12) + (-5,-12) | {0,3,0} | (-5,0) + (-5,-12) | {1,-1,0} | (-8.5,-8.5) + (-5,-12) | {-0.4,-1,-6} | (-2.24137931034,-5.10344827586) + (-5,-12) | {-0.000184615384615,-1,15.3846153846} | (-4.99494420846,15.3855375282) + (-5,-12) | {3,NaN,5} | + (-5,-12) | {NaN,NaN,NaN} | + (-5,-12) | {0,-1,3} | (-5,3) + (-5,-12) | {-1,0,3} | (3,-12) + (1e-300,-1e-300) | {0,-1,5} | (1e-300,5) + (1e-300,-1e-300) | {1,0,5} | (-5,-1e-300) + (1e-300,-1e-300) | {0,3,0} | (1e-300,0) + (1e-300,-1e-300) | {1,-1,0} | (0,0) + (1e-300,-1e-300) | {-0.4,-1,-6} | (-2.06896551724,-5.1724137931) + (1e-300,-1e-300) | {-0.000184615384615,-1,15.3846153846} | (0.00284023658959,15.3846148603) + (1e-300,-1e-300) | {3,NaN,5} | + (1e-300,-1e-300) | {NaN,NaN,NaN} | + (1e-300,-1e-300) | {0,-1,3} | (1e-300,3) + (1e-300,-1e-300) | {-1,0,3} | (3,-1e-300) + (1e+300,Infinity) | {0,-1,5} | (1e+300,5) + (1e+300,Infinity) | {1,0,5} | + (1e+300,Infinity) | {0,3,0} | (1e+300,0) + (1e+300,Infinity) | {1,-1,0} | (Infinity,NaN) + (1e+300,Infinity) | {-0.4,-1,-6} | (-Infinity,NaN) + (1e+300,Infinity) | {-0.000184615384615,-1,15.3846153846} | (-Infinity,NaN) + (1e+300,Infinity) | {3,NaN,5} | + (1e+300,Infinity) | {NaN,NaN,NaN} | + (1e+300,Infinity) | {0,-1,3} | (1e+300,3) + (1e+300,Infinity) | {-1,0,3} | + (NaN,NaN) | {0,-1,5} | + (NaN,NaN) | {1,0,5} | + (NaN,NaN) | {0,3,0} | + (NaN,NaN) | {1,-1,0} | + (NaN,NaN) | {-0.4,-1,-6} | + (NaN,NaN) | {-0.000184615384615,-1,15.3846153846} | + (NaN,NaN) | {3,NaN,5} | + (NaN,NaN) | {NaN,NaN,NaN} | + (NaN,NaN) | {0,-1,3} | + (NaN,NaN) | {-1,0,3} | + (10,10) | {0,-1,5} | (10,5) + (10,10) | {1,0,5} | (-5,10) + (10,10) | {0,3,0} | (10,0) + (10,10) | {1,-1,0} | (10,10) + (10,10) | {-0.4,-1,-6} | (3.10344827586,-7.24137931034) + (10,10) | {-0.000184615384615,-1,15.3846153846} | (10.000993742,15.3827690473) + (10,10) | {3,NaN,5} | + (10,10) | {NaN,NaN,NaN} | + (10,10) | {0,-1,3} | (10,3) + (10,10) | {-1,0,3} | (3,10) +(90 rows) + +-- Closest point to line segment +SELECT p.f1, l.s, p.f1 ## l.s FROM POINT_TBL p, LSEG_TBL l; + f1 | s | ?column? +-------------------+-------------------------------+---------------------------------- + (0,0) | [(1,2),(3,4)] | (1,2) + (0,0) | [(0,0),(6,6)] | (0,0) + (0,0) | [(10,-10),(-3,-4)] | (-2.0487804878,-4.43902439024) + (0,0) | [(-1000000,200),(300000,-40)] | (0.00284023658959,15.3846148603) + (0,0) | [(11,22),(33,44)] | (11,22) + (0,0) | [(-10,2),(-10,3)] | (-10,2) + (0,0) | [(0,-20),(30,-20)] | (0,-20) + (0,0) | [(NaN,1),(NaN,90)] | + (-10,0) | [(1,2),(3,4)] | (1,2) + (-10,0) | [(0,0),(6,6)] | (0,0) + (-10,0) | [(10,-10),(-3,-4)] | (-3,-4) + (-10,0) | [(-1000000,200),(300000,-40)] | (-9.99715942258,15.386461014) + (-10,0) | [(11,22),(33,44)] | (11,22) + (-10,0) | [(-10,2),(-10,3)] | (-10,2) + (-10,0) | [(0,-20),(30,-20)] | (0,-20) + (-10,0) | [(NaN,1),(NaN,90)] | + (-3,4) | [(1,2),(3,4)] | (1,2) + (-3,4) | [(0,0),(6,6)] | (0.5,0.5) + (-3,4) | [(10,-10),(-3,-4)] | (-3,-4) + (-3,4) | [(-1000000,200),(300000,-40)] | (-2.99789812268,15.3851688427) + (-3,4) | [(11,22),(33,44)] | (11,22) + (-3,4) | [(-10,2),(-10,3)] | (-10,3) + (-3,4) | [(0,-20),(30,-20)] | (0,-20) + (-3,4) | [(NaN,1),(NaN,90)] | + (5.1,34.5) | [(1,2),(3,4)] | (3,4) + (5.1,34.5) | [(0,0),(6,6)] | (6,6) + (5.1,34.5) | [(10,-10),(-3,-4)] | (-3,-4) + (5.1,34.5) | [(-1000000,200),(300000,-40)] | (5.09647083221,15.3836744977) + (5.1,34.5) | [(11,22),(33,44)] | (14.3,25.3) + (5.1,34.5) | [(-10,2),(-10,3)] | (-10,3) + (5.1,34.5) | [(0,-20),(30,-20)] | (5.1,-20) + (5.1,34.5) | [(NaN,1),(NaN,90)] | + (-5,-12) | [(1,2),(3,4)] | (1,2) + (-5,-12) | [(0,0),(6,6)] | (0,0) + (-5,-12) | [(10,-10),(-3,-4)] | (-1.60487804878,-4.64390243902) + (-5,-12) | [(-1000000,200),(300000,-40)] | (-4.99494420846,15.3855375282) + (-5,-12) | [(11,22),(33,44)] | (11,22) + (-5,-12) | [(-10,2),(-10,3)] | (-10,2) + (-5,-12) | [(0,-20),(30,-20)] | (0,-20) + (-5,-12) | [(NaN,1),(NaN,90)] | + (1e-300,-1e-300) | [(1,2),(3,4)] | (1,2) + (1e-300,-1e-300) | [(0,0),(6,6)] | (0,0) + (1e-300,-1e-300) | [(10,-10),(-3,-4)] | (-2.0487804878,-4.43902439024) + (1e-300,-1e-300) | [(-1000000,200),(300000,-40)] | (0.00284023658959,15.3846148603) + (1e-300,-1e-300) | [(11,22),(33,44)] | (11,22) + (1e-300,-1e-300) | [(-10,2),(-10,3)] | (-10,2) + (1e-300,-1e-300) | [(0,-20),(30,-20)] | (0,-20) + (1e-300,-1e-300) | [(NaN,1),(NaN,90)] | + (1e+300,Infinity) | [(1,2),(3,4)] | (3,4) + (1e+300,Infinity) | [(0,0),(6,6)] | (6,6) + (1e+300,Infinity) | [(10,-10),(-3,-4)] | (-3,-4) + (1e+300,Infinity) | [(-1000000,200),(300000,-40)] | (300000,-40) + (1e+300,Infinity) | [(11,22),(33,44)] | (33,44) + (1e+300,Infinity) | [(-10,2),(-10,3)] | (-10,3) + (1e+300,Infinity) | [(0,-20),(30,-20)] | (30,-20) + (1e+300,Infinity) | [(NaN,1),(NaN,90)] | (NaN,90) + (NaN,NaN) | [(1,2),(3,4)] | + (NaN,NaN) | [(0,0),(6,6)] | + (NaN,NaN) | [(10,-10),(-3,-4)] | + (NaN,NaN) | [(-1000000,200),(300000,-40)] | + (NaN,NaN) | [(11,22),(33,44)] | + (NaN,NaN) | [(-10,2),(-10,3)] | + (NaN,NaN) | [(0,-20),(30,-20)] | + (NaN,NaN) | [(NaN,1),(NaN,90)] | + (10,10) | [(1,2),(3,4)] | (3,4) + (10,10) | [(0,0),(6,6)] | (6,6) + (10,10) | [(10,-10),(-3,-4)] | (2.39024390244,-6.48780487805) + (10,10) | [(-1000000,200),(300000,-40)] | (10.000993742,15.3827690473) + (10,10) | [(11,22),(33,44)] | (11,22) + (10,10) | [(-10,2),(-10,3)] | (-10,3) + (10,10) | [(0,-20),(30,-20)] | (10,-20) + (10,10) | [(NaN,1),(NaN,90)] | +(72 rows) + +-- Closest point to box +SELECT p.f1, b.f1, p.f1 ## b.f1 FROM POINT_TBL p, BOX_TBL b; + f1 | f1 | ?column? +-------------------+---------------------+-------------- + (0,0) | (2,2),(0,0) | (0,0) + (0,0) | (3,3),(1,1) | (1,1) + (0,0) | (-2,2),(-8,-10) | (-2,0) + (0,0) | (2.5,3.5),(2.5,2.5) | (2.5,2.5) + (0,0) | (3,3),(3,3) | (3,3) + (-10,0) | (2,2),(0,0) | (0,0) + (-10,0) | (3,3),(1,1) | (1,1) + (-10,0) | (-2,2),(-8,-10) | (-8,0) + (-10,0) | (2.5,3.5),(2.5,2.5) | (2.5,2.5) + (-10,0) | (3,3),(3,3) | (3,3) + (-3,4) | (2,2),(0,0) | (0,2) + (-3,4) | (3,3),(1,1) | (1,3) + (-3,4) | (-2,2),(-8,-10) | (-3,2) + (-3,4) | (2.5,3.5),(2.5,2.5) | (2.5,3.5) + (-3,4) | (3,3),(3,3) | (3,3) + (5.1,34.5) | (2,2),(0,0) | (2,2) + (5.1,34.5) | (3,3),(1,1) | (3,3) + (5.1,34.5) | (-2,2),(-8,-10) | (-2,2) + (5.1,34.5) | (2.5,3.5),(2.5,2.5) | (2.5,3.5) + (5.1,34.5) | (3,3),(3,3) | (3,3) + (-5,-12) | (2,2),(0,0) | (0,0) + (-5,-12) | (3,3),(1,1) | (1,1) + (-5,-12) | (-2,2),(-8,-10) | (-5,-10) + (-5,-12) | (2.5,3.5),(2.5,2.5) | (2.5,2.5) + (-5,-12) | (3,3),(3,3) | (3,3) + (1e-300,-1e-300) | (2,2),(0,0) | (0,0) + (1e-300,-1e-300) | (3,3),(1,1) | (1,1) + (1e-300,-1e-300) | (-2,2),(-8,-10) | (-2,-1e-300) + (1e-300,-1e-300) | (2.5,3.5),(2.5,2.5) | (2.5,2.5) + (1e-300,-1e-300) | (3,3),(3,3) | (3,3) + (1e+300,Infinity) | (2,2),(0,0) | (0,2) + (1e+300,Infinity) | (3,3),(1,1) | (1,3) + (1e+300,Infinity) | (-2,2),(-8,-10) | (-8,2) + (1e+300,Infinity) | (2.5,3.5),(2.5,2.5) | (2.5,3.5) + (1e+300,Infinity) | (3,3),(3,3) | (3,3) + (NaN,NaN) | (2,2),(0,0) | + (NaN,NaN) | (3,3),(1,1) | + (NaN,NaN) | (-2,2),(-8,-10) | + (NaN,NaN) | (2.5,3.5),(2.5,2.5) | + (NaN,NaN) | (3,3),(3,3) | + (10,10) | (2,2),(0,0) | (2,2) + (10,10) | (3,3),(1,1) | (3,3) + (10,10) | (-2,2),(-8,-10) | (-2,2) + (10,10) | (2.5,3.5),(2.5,2.5) | (2.5,3.5) + (10,10) | (3,3),(3,3) | (3,3) +(45 rows) + +-- On line +SELECT p.f1, l.s FROM POINT_TBL p, LINE_TBL l WHERE p.f1 <@ l.s; + f1 | s +------------------+---------- + (0,0) | {0,3,0} + (0,0) | {1,-1,0} + (-10,0) | {0,3,0} + (-5,-12) | {1,0,5} + (1e-300,-1e-300) | {0,3,0} + (1e-300,-1e-300) | {1,-1,0} + (10,10) | {1,-1,0} +(7 rows) + +-- On line segment +SELECT p.f1, l.s FROM POINT_TBL p, LSEG_TBL l WHERE p.f1 <@ l.s; + f1 | s +------------------+--------------- + (0,0) | [(0,0),(6,6)] + (1e-300,-1e-300) | [(0,0),(6,6)] +(2 rows) + +-- On path +SELECT p.f1, p1.f1 FROM POINT_TBL p, PATH_TBL p1 WHERE p.f1 <@ p1.f1; + f1 | f1 +------------------+--------------------------- + (0,0) | [(0,0),(3,0),(4,5),(1,6)] + (1e-300,-1e-300) | [(0,0),(3,0),(4,5),(1,6)] + (NaN,NaN) | ((1,2),(3,4)) + (NaN,NaN) | ((1,2),(3,4)) + (NaN,NaN) | ((1,2),(3,4)) + (NaN,NaN) | ((10,20)) + (NaN,NaN) | ((11,12),(13,14)) +(7 rows) + +-- +-- Lines +-- +-- Vertical +SELECT s FROM LINE_TBL WHERE ?| s; + s +---------- + {1,0,5} + {-1,0,3} +(2 rows) + +-- Horizontal +SELECT s FROM LINE_TBL WHERE ?- s; + s +---------- + {0,-1,5} + {0,3,0} + {0,-1,3} +(3 rows) + +-- Same as line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s = l2.s; + s | s +---------------------------------------+--------------------------------------- + {0,-1,5} | {0,-1,5} + {1,0,5} | {1,0,5} + {0,3,0} | {0,3,0} + {1,-1,0} | {1,-1,0} + {-0.4,-1,-6} | {-0.4,-1,-6} + {-0.000184615384615,-1,15.3846153846} | {-0.000184615384615,-1,15.3846153846} + {3,NaN,5} | {3,NaN,5} + {NaN,NaN,NaN} | {NaN,NaN,NaN} + {0,-1,3} | {0,-1,3} + {-1,0,3} | {-1,0,3} +(10 rows) + +-- Parallel to line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?|| l2.s; + s | s +---------------------------------------+--------------------------------------- + {0,-1,5} | {0,-1,5} + {0,-1,5} | {0,3,0} + {0,-1,5} | {0,-1,3} + {1,0,5} | {1,0,5} + {1,0,5} | {-1,0,3} + {0,3,0} | {0,-1,5} + {0,3,0} | {0,3,0} + {0,3,0} | {0,-1,3} + {1,-1,0} | {1,-1,0} + {-0.4,-1,-6} | {-0.4,-1,-6} + {-0.000184615384615,-1,15.3846153846} | {-0.000184615384615,-1,15.3846153846} + {0,-1,3} | {0,-1,5} + {0,-1,3} | {0,3,0} + {0,-1,3} | {0,-1,3} + {-1,0,3} | {1,0,5} + {-1,0,3} | {-1,0,3} +(16 rows) + +-- Perpendicular to line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?-| l2.s; + s | s +----------+---------- + {0,-1,5} | {1,0,5} + {0,-1,5} | {-1,0,3} + {1,0,5} | {0,-1,5} + {1,0,5} | {0,3,0} + {1,0,5} | {0,-1,3} + {0,3,0} | {1,0,5} + {0,3,0} | {-1,0,3} + {0,-1,3} | {1,0,5} + {0,-1,3} | {-1,0,3} + {-1,0,3} | {0,-1,5} + {-1,0,3} | {0,3,0} + {-1,0,3} | {0,-1,3} +(12 rows) + +-- Distance to line +SELECT l1.s, l2.s, l1.s <-> l2.s FROM LINE_TBL l1, LINE_TBL l2; + s | s | ?column? +---------------------------------------+---------------------------------------+---------- + {0,-1,5} | {0,-1,5} | 0 + {0,-1,5} | {1,0,5} | 0 + {0,-1,5} | {0,3,0} | 5 + {0,-1,5} | {1,-1,0} | 0 + {0,-1,5} | {-0.4,-1,-6} | 0 + {0,-1,5} | {-0.000184615384615,-1,15.3846153846} | 0 + {0,-1,5} | {3,NaN,5} | 0 + {0,-1,5} | {NaN,NaN,NaN} | 0 + {0,-1,5} | {0,-1,3} | 2 + {0,-1,5} | {-1,0,3} | 0 + {1,0,5} | {0,-1,5} | 0 + {1,0,5} | {1,0,5} | 0 + {1,0,5} | {0,3,0} | 0 + {1,0,5} | {1,-1,0} | 0 + {1,0,5} | {-0.4,-1,-6} | 0 + {1,0,5} | {-0.000184615384615,-1,15.3846153846} | 0 + {1,0,5} | {3,NaN,5} | 0 + {1,0,5} | {NaN,NaN,NaN} | 0 + {1,0,5} | {0,-1,3} | 0 + {1,0,5} | {-1,0,3} | 8 + {0,3,0} | {0,-1,5} | 5 + {0,3,0} | {1,0,5} | 0 + {0,3,0} | {0,3,0} | 0 + {0,3,0} | {1,-1,0} | 0 + {0,3,0} | {-0.4,-1,-6} | 0 + {0,3,0} | {-0.000184615384615,-1,15.3846153846} | 0 + {0,3,0} | {3,NaN,5} | 0 + {0,3,0} | {NaN,NaN,NaN} | 0 + {0,3,0} | {0,-1,3} | 3 + {0,3,0} | {-1,0,3} | 0 + {1,-1,0} | {0,-1,5} | 0 + {1,-1,0} | {1,0,5} | 0 + {1,-1,0} | {0,3,0} | 0 + {1,-1,0} | {1,-1,0} | 0 + {1,-1,0} | {-0.4,-1,-6} | 0 + {1,-1,0} | {-0.000184615384615,-1,15.3846153846} | 0 + {1,-1,0} | {3,NaN,5} | 0 + {1,-1,0} | {NaN,NaN,NaN} | 0 + {1,-1,0} | {0,-1,3} | 0 + {1,-1,0} | {-1,0,3} | 0 + {-0.4,-1,-6} | {0,-1,5} | 0 + {-0.4,-1,-6} | {1,0,5} | 0 + {-0.4,-1,-6} | {0,3,0} | 0 + {-0.4,-1,-6} | {1,-1,0} | 0 + {-0.4,-1,-6} | {-0.4,-1,-6} | 0 + {-0.4,-1,-6} | {-0.000184615384615,-1,15.3846153846} | 0 + {-0.4,-1,-6} | {3,NaN,5} | 0 + {-0.4,-1,-6} | {NaN,NaN,NaN} | 0 + {-0.4,-1,-6} | {0,-1,3} | 0 + {-0.4,-1,-6} | {-1,0,3} | 0 + {-0.000184615384615,-1,15.3846153846} | {0,-1,5} | 0 + {-0.000184615384615,-1,15.3846153846} | {1,0,5} | 0 + {-0.000184615384615,-1,15.3846153846} | {0,3,0} | 0 + {-0.000184615384615,-1,15.3846153846} | {1,-1,0} | 0 + {-0.000184615384615,-1,15.3846153846} | {-0.4,-1,-6} | 0 + {-0.000184615384615,-1,15.3846153846} | {-0.000184615384615,-1,15.3846153846} | 0 + {-0.000184615384615,-1,15.3846153846} | {3,NaN,5} | 0 + {-0.000184615384615,-1,15.3846153846} | {NaN,NaN,NaN} | 0 + {-0.000184615384615,-1,15.3846153846} | {0,-1,3} | 0 + {-0.000184615384615,-1,15.3846153846} | {-1,0,3} | 0 + {3,NaN,5} | {0,-1,5} | 0 + {3,NaN,5} | {1,0,5} | 0 + {3,NaN,5} | {0,3,0} | 0 + {3,NaN,5} | {1,-1,0} | 0 + {3,NaN,5} | {-0.4,-1,-6} | 0 + {3,NaN,5} | {-0.000184615384615,-1,15.3846153846} | 0 + {3,NaN,5} | {3,NaN,5} | 0 + {3,NaN,5} | {NaN,NaN,NaN} | 0 + {3,NaN,5} | {0,-1,3} | 0 + {3,NaN,5} | {-1,0,3} | 0 + {NaN,NaN,NaN} | {0,-1,5} | 0 + {NaN,NaN,NaN} | {1,0,5} | 0 + {NaN,NaN,NaN} | {0,3,0} | 0 + {NaN,NaN,NaN} | {1,-1,0} | 0 + {NaN,NaN,NaN} | {-0.4,-1,-6} | 0 + {NaN,NaN,NaN} | {-0.000184615384615,-1,15.3846153846} | 0 + {NaN,NaN,NaN} | {3,NaN,5} | 0 + {NaN,NaN,NaN} | {NaN,NaN,NaN} | 0 + {NaN,NaN,NaN} | {0,-1,3} | 0 + {NaN,NaN,NaN} | {-1,0,3} | 0 + {0,-1,3} | {0,-1,5} | 2 + {0,-1,3} | {1,0,5} | 0 + {0,-1,3} | {0,3,0} | 3 + {0,-1,3} | {1,-1,0} | 0 + {0,-1,3} | {-0.4,-1,-6} | 0 + {0,-1,3} | {-0.000184615384615,-1,15.3846153846} | 0 + {0,-1,3} | {3,NaN,5} | 0 + {0,-1,3} | {NaN,NaN,NaN} | 0 + {0,-1,3} | {0,-1,3} | 0 + {0,-1,3} | {-1,0,3} | 0 + {-1,0,3} | {0,-1,5} | 0 + {-1,0,3} | {1,0,5} | 8 + {-1,0,3} | {0,3,0} | 0 + {-1,0,3} | {1,-1,0} | 0 + {-1,0,3} | {-0.4,-1,-6} | 0 + {-1,0,3} | {-0.000184615384615,-1,15.3846153846} | 0 + {-1,0,3} | {3,NaN,5} | 0 + {-1,0,3} | {NaN,NaN,NaN} | 0 + {-1,0,3} | {0,-1,3} | 0 + {-1,0,3} | {-1,0,3} | 0 +(100 rows) + +-- Distance to box +SELECT l.s, b.f1, l.s <-> b.f1 FROM LINE_TBL l, BOX_TBL b; +ERROR: function "dist_lb" not implemented +SELECT l.s, b.f1, b.f1 <-> l.s FROM LINE_TBL l, BOX_TBL b; +ERROR: function "dist_bl" not implemented +-- Intersect with line +SELECT l1.s, l2.s FROM LINE_TBL l1, LINE_TBL l2 WHERE l1.s ?# l2.s; + s | s +---------------------------------------+--------------------------------------- + {0,-1,5} | {1,0,5} + {0,-1,5} | {1,-1,0} + {0,-1,5} | {-0.4,-1,-6} + {0,-1,5} | {-0.000184615384615,-1,15.3846153846} + {0,-1,5} | {3,NaN,5} + {0,-1,5} | {NaN,NaN,NaN} + {0,-1,5} | {-1,0,3} + {1,0,5} | {0,-1,5} + {1,0,5} | {0,3,0} + {1,0,5} | {1,-1,0} + {1,0,5} | {-0.4,-1,-6} + {1,0,5} | {-0.000184615384615,-1,15.3846153846} + {1,0,5} | {3,NaN,5} + {1,0,5} | {NaN,NaN,NaN} + {1,0,5} | {0,-1,3} + {0,3,0} | {1,0,5} + {0,3,0} | {1,-1,0} + {0,3,0} | {-0.4,-1,-6} + {0,3,0} | {-0.000184615384615,-1,15.3846153846} + {0,3,0} | {3,NaN,5} + {0,3,0} | {NaN,NaN,NaN} + {0,3,0} | {-1,0,3} + {1,-1,0} | {0,-1,5} + {1,-1,0} | {1,0,5} + {1,-1,0} | {0,3,0} + {1,-1,0} | {-0.4,-1,-6} + {1,-1,0} | {-0.000184615384615,-1,15.3846153846} + {1,-1,0} | {3,NaN,5} + {1,-1,0} | {NaN,NaN,NaN} + {1,-1,0} | {0,-1,3} + {1,-1,0} | {-1,0,3} + {-0.4,-1,-6} | {0,-1,5} + {-0.4,-1,-6} | {1,0,5} + {-0.4,-1,-6} | {0,3,0} + {-0.4,-1,-6} | {1,-1,0} + {-0.4,-1,-6} | {-0.000184615384615,-1,15.3846153846} + {-0.4,-1,-6} | {3,NaN,5} + {-0.4,-1,-6} | {NaN,NaN,NaN} + {-0.4,-1,-6} | {0,-1,3} + {-0.4,-1,-6} | {-1,0,3} + {-0.000184615384615,-1,15.3846153846} | {0,-1,5} + {-0.000184615384615,-1,15.3846153846} | {1,0,5} + {-0.000184615384615,-1,15.3846153846} | {0,3,0} + {-0.000184615384615,-1,15.3846153846} | {1,-1,0} + {-0.000184615384615,-1,15.3846153846} | {-0.4,-1,-6} + {-0.000184615384615,-1,15.3846153846} | {3,NaN,5} + {-0.000184615384615,-1,15.3846153846} | {NaN,NaN,NaN} + {-0.000184615384615,-1,15.3846153846} | {0,-1,3} + {-0.000184615384615,-1,15.3846153846} | {-1,0,3} + {3,NaN,5} | {0,-1,5} + {3,NaN,5} | {1,0,5} + {3,NaN,5} | {0,3,0} + {3,NaN,5} | {1,-1,0} + {3,NaN,5} | {-0.4,-1,-6} + {3,NaN,5} | {-0.000184615384615,-1,15.3846153846} + {3,NaN,5} | {3,NaN,5} + {3,NaN,5} | {NaN,NaN,NaN} + {3,NaN,5} | {0,-1,3} + {3,NaN,5} | {-1,0,3} + {NaN,NaN,NaN} | {0,-1,5} + {NaN,NaN,NaN} | {1,0,5} + {NaN,NaN,NaN} | {0,3,0} + {NaN,NaN,NaN} | {1,-1,0} + {NaN,NaN,NaN} | {-0.4,-1,-6} + {NaN,NaN,NaN} | {-0.000184615384615,-1,15.3846153846} + {NaN,NaN,NaN} | {3,NaN,5} + {NaN,NaN,NaN} | {NaN,NaN,NaN} + {NaN,NaN,NaN} | {0,-1,3} + {NaN,NaN,NaN} | {-1,0,3} + {0,-1,3} | {1,0,5} + {0,-1,3} | {1,-1,0} + {0,-1,3} | {-0.4,-1,-6} + {0,-1,3} | {-0.000184615384615,-1,15.3846153846} + {0,-1,3} | {3,NaN,5} + {0,-1,3} | {NaN,NaN,NaN} + {0,-1,3} | {-1,0,3} + {-1,0,3} | {0,-1,5} + {-1,0,3} | {0,3,0} + {-1,0,3} | {1,-1,0} + {-1,0,3} | {-0.4,-1,-6} + {-1,0,3} | {-0.000184615384615,-1,15.3846153846} + {-1,0,3} | {3,NaN,5} + {-1,0,3} | {NaN,NaN,NaN} + {-1,0,3} | {0,-1,3} +(84 rows) + +-- Intersect with box +SELECT l.s, b.f1 FROM LINE_TBL l, BOX_TBL b WHERE l.s ?# b.f1; + s | f1 +--------------+--------------------- + {1,0,5} | (-2,2),(-8,-10) + {0,3,0} | (2,2),(0,0) + {0,3,0} | (-2,2),(-8,-10) + {1,-1,0} | (2,2),(0,0) + {1,-1,0} | (3,3),(1,1) + {1,-1,0} | (-2,2),(-8,-10) + {1,-1,0} | (2.5,3.5),(2.5,2.5) + {1,-1,0} | (3,3),(3,3) + {-0.4,-1,-6} | (-2,2),(-8,-10) + {0,-1,3} | (3,3),(1,1) + {0,-1,3} | (2.5,3.5),(2.5,2.5) + {0,-1,3} | (3,3),(3,3) + {-1,0,3} | (3,3),(1,1) +(13 rows) + +-- Intersection point with line +SELECT l1.s, l2.s, l1.s # l2.s FROM LINE_TBL l1, LINE_TBL l2; + s | s | ?column? +---------------------------------------+---------------------------------------+----------------------------------- + {0,-1,5} | {0,-1,5} | + {0,-1,5} | {1,0,5} | (-5,5) + {0,-1,5} | {0,3,0} | + {0,-1,5} | {1,-1,0} | (5,5) + {0,-1,5} | {-0.4,-1,-6} | (-27.5,5) + {0,-1,5} | {-0.000184615384615,-1,15.3846153846} | (56250,5) + {0,-1,5} | {3,NaN,5} | (NaN,NaN) + {0,-1,5} | {NaN,NaN,NaN} | (NaN,NaN) + {0,-1,5} | {0,-1,3} | + {0,-1,5} | {-1,0,3} | (3,5) + {1,0,5} | {0,-1,5} | (-5,5) + {1,0,5} | {1,0,5} | + {1,0,5} | {0,3,0} | (-5,0) + {1,0,5} | {1,-1,0} | (-5,-5) + {1,0,5} | {-0.4,-1,-6} | (-5,-4) + {1,0,5} | {-0.000184615384615,-1,15.3846153846} | (-5,15.3855384615) + {1,0,5} | {3,NaN,5} | (NaN,NaN) + {1,0,5} | {NaN,NaN,NaN} | (NaN,NaN) + {1,0,5} | {0,-1,3} | (-5,3) + {1,0,5} | {-1,0,3} | + {0,3,0} | {0,-1,5} | + {0,3,0} | {1,0,5} | (-5,0) + {0,3,0} | {0,3,0} | + {0,3,0} | {1,-1,0} | (0,0) + {0,3,0} | {-0.4,-1,-6} | (-15,0) + {0,3,0} | {-0.000184615384615,-1,15.3846153846} | (83333.3333333,0) + {0,3,0} | {3,NaN,5} | (NaN,NaN) + {0,3,0} | {NaN,NaN,NaN} | (NaN,NaN) + {0,3,0} | {0,-1,3} | + {0,3,0} | {-1,0,3} | (3,0) + {1,-1,0} | {0,-1,5} | (5,5) + {1,-1,0} | {1,0,5} | (-5,-5) + {1,-1,0} | {0,3,0} | (0,0) + {1,-1,0} | {1,-1,0} | + {1,-1,0} | {-0.4,-1,-6} | (-4.28571428571,-4.28571428571) + {1,-1,0} | {-0.000184615384615,-1,15.3846153846} | (15.3817756722,15.3817756722) + {1,-1,0} | {3,NaN,5} | (NaN,NaN) + {1,-1,0} | {NaN,NaN,NaN} | (NaN,NaN) + {1,-1,0} | {0,-1,3} | (3,3) + {1,-1,0} | {-1,0,3} | (3,3) + {-0.4,-1,-6} | {0,-1,5} | (-27.5,5) + {-0.4,-1,-6} | {1,0,5} | (-5,-4) + {-0.4,-1,-6} | {0,3,0} | (-15,0) + {-0.4,-1,-6} | {1,-1,0} | (-4.28571428571,-4.28571428571) + {-0.4,-1,-6} | {-0.4,-1,-6} | + {-0.4,-1,-6} | {-0.000184615384615,-1,15.3846153846} | (-53.4862244113,15.3944897645) + {-0.4,-1,-6} | {3,NaN,5} | (NaN,NaN) + {-0.4,-1,-6} | {NaN,NaN,NaN} | (NaN,NaN) + {-0.4,-1,-6} | {0,-1,3} | (-22.5,3) + {-0.4,-1,-6} | {-1,0,3} | (3,-7.2) + {-0.000184615384615,-1,15.3846153846} | {0,-1,5} | (56250,5) + {-0.000184615384615,-1,15.3846153846} | {1,0,5} | (-5,15.3855384615) + {-0.000184615384615,-1,15.3846153846} | {0,3,0} | (83333.3333333,-1.7763568394e-15) + {-0.000184615384615,-1,15.3846153846} | {1,-1,0} | (15.3817756722,15.3817756722) + {-0.000184615384615,-1,15.3846153846} | {-0.4,-1,-6} | (-53.4862244113,15.3944897645) + {-0.000184615384615,-1,15.3846153846} | {-0.000184615384615,-1,15.3846153846} | + {-0.000184615384615,-1,15.3846153846} | {3,NaN,5} | (NaN,NaN) + {-0.000184615384615,-1,15.3846153846} | {NaN,NaN,NaN} | (NaN,NaN) + {-0.000184615384615,-1,15.3846153846} | {0,-1,3} | (67083.3333333,3) + {-0.000184615384615,-1,15.3846153846} | {-1,0,3} | (3,15.3840615385) + {3,NaN,5} | {0,-1,5} | (NaN,NaN) + {3,NaN,5} | {1,0,5} | (NaN,NaN) + {3,NaN,5} | {0,3,0} | (NaN,NaN) + {3,NaN,5} | {1,-1,0} | (NaN,NaN) + {3,NaN,5} | {-0.4,-1,-6} | (NaN,NaN) + {3,NaN,5} | {-0.000184615384615,-1,15.3846153846} | (NaN,NaN) + {3,NaN,5} | {3,NaN,5} | (NaN,NaN) + {3,NaN,5} | {NaN,NaN,NaN} | (NaN,NaN) + {3,NaN,5} | {0,-1,3} | (NaN,NaN) + {3,NaN,5} | {-1,0,3} | (NaN,NaN) + {NaN,NaN,NaN} | {0,-1,5} | (NaN,NaN) + {NaN,NaN,NaN} | {1,0,5} | (NaN,NaN) + {NaN,NaN,NaN} | {0,3,0} | (NaN,NaN) + {NaN,NaN,NaN} | {1,-1,0} | (NaN,NaN) + {NaN,NaN,NaN} | {-0.4,-1,-6} | (NaN,NaN) + {NaN,NaN,NaN} | {-0.000184615384615,-1,15.3846153846} | (NaN,NaN) + {NaN,NaN,NaN} | {3,NaN,5} | (NaN,NaN) + {NaN,NaN,NaN} | {NaN,NaN,NaN} | (NaN,NaN) + {NaN,NaN,NaN} | {0,-1,3} | (NaN,NaN) + {NaN,NaN,NaN} | {-1,0,3} | (NaN,NaN) + {0,-1,3} | {0,-1,5} | + {0,-1,3} | {1,0,5} | (-5,3) + {0,-1,3} | {0,3,0} | + {0,-1,3} | {1,-1,0} | (3,3) + {0,-1,3} | {-0.4,-1,-6} | (-22.5,3) + {0,-1,3} | {-0.000184615384615,-1,15.3846153846} | (67083.3333333,3) + {0,-1,3} | {3,NaN,5} | (NaN,NaN) + {0,-1,3} | {NaN,NaN,NaN} | (NaN,NaN) + {0,-1,3} | {0,-1,3} | + {0,-1,3} | {-1,0,3} | (3,3) + {-1,0,3} | {0,-1,5} | (3,5) + {-1,0,3} | {1,0,5} | + {-1,0,3} | {0,3,0} | (3,0) + {-1,0,3} | {1,-1,0} | (3,3) + {-1,0,3} | {-0.4,-1,-6} | (3,-7.2) + {-1,0,3} | {-0.000184615384615,-1,15.3846153846} | (3,15.3840615385) + {-1,0,3} | {3,NaN,5} | (NaN,NaN) + {-1,0,3} | {NaN,NaN,NaN} | (NaN,NaN) + {-1,0,3} | {0,-1,3} | (3,3) + {-1,0,3} | {-1,0,3} | +(100 rows) + +-- Closest point to line segment +SELECT l.s, l1.s, l.s ## l1.s FROM LINE_TBL l, LSEG_TBL l1; + s | s | ?column? +---------------------------------------+-------------------------------+----------------------------------- + {0,-1,5} | [(1,2),(3,4)] | (3,4) + {0,-1,5} | [(0,0),(6,6)] | (5,5) + {0,-1,5} | [(10,-10),(-3,-4)] | (-3,-4) + {0,-1,5} | [(-1000000,200),(300000,-40)] | (56250,5) + {0,-1,5} | [(11,22),(33,44)] | (11,22) + {0,-1,5} | [(-10,2),(-10,3)] | (-10,3) + {0,-1,5} | [(0,-20),(30,-20)] | + {0,-1,5} | [(NaN,1),(NaN,90)] | + {1,0,5} | [(1,2),(3,4)] | (1,2) + {1,0,5} | [(0,0),(6,6)] | (0,0) + {1,0,5} | [(10,-10),(-3,-4)] | (-3,-4) + {1,0,5} | [(-1000000,200),(300000,-40)] | (-5,15.3855384615) + {1,0,5} | [(11,22),(33,44)] | (11,22) + {1,0,5} | [(-10,2),(-10,3)] | + {1,0,5} | [(0,-20),(30,-20)] | (0,-20) + {1,0,5} | [(NaN,1),(NaN,90)] | + {0,3,0} | [(1,2),(3,4)] | (1,2) + {0,3,0} | [(0,0),(6,6)] | (0,0) + {0,3,0} | [(10,-10),(-3,-4)] | (-3,-4) + {0,3,0} | [(-1000000,200),(300000,-40)] | (83333.3333333,-1.7763568394e-15) + {0,3,0} | [(11,22),(33,44)] | (11,22) + {0,3,0} | [(-10,2),(-10,3)] | (-10,2) + {0,3,0} | [(0,-20),(30,-20)] | + {0,3,0} | [(NaN,1),(NaN,90)] | + {1,-1,0} | [(1,2),(3,4)] | + {1,-1,0} | [(0,0),(6,6)] | + {1,-1,0} | [(10,-10),(-3,-4)] | (-3,-4) + {1,-1,0} | [(-1000000,200),(300000,-40)] | (15.3817756722,15.3817756722) + {1,-1,0} | [(11,22),(33,44)] | + {1,-1,0} | [(-10,2),(-10,3)] | (-10,2) + {1,-1,0} | [(0,-20),(30,-20)] | (0,-20) + {1,-1,0} | [(NaN,1),(NaN,90)] | + {-0.4,-1,-6} | [(1,2),(3,4)] | (1,2) + {-0.4,-1,-6} | [(0,0),(6,6)] | (0,0) + {-0.4,-1,-6} | [(10,-10),(-3,-4)] | (10,-10) + {-0.4,-1,-6} | [(-1000000,200),(300000,-40)] | (-53.4862244113,15.3944897645) + {-0.4,-1,-6} | [(11,22),(33,44)] | (11,22) + {-0.4,-1,-6} | [(-10,2),(-10,3)] | (-10,2) + {-0.4,-1,-6} | [(0,-20),(30,-20)] | (30,-20) + {-0.4,-1,-6} | [(NaN,1),(NaN,90)] | + {-0.000184615384615,-1,15.3846153846} | [(1,2),(3,4)] | (3,4) + {-0.000184615384615,-1,15.3846153846} | [(0,0),(6,6)] | (6,6) + {-0.000184615384615,-1,15.3846153846} | [(10,-10),(-3,-4)] | (-3,-4) + {-0.000184615384615,-1,15.3846153846} | [(-1000000,200),(300000,-40)] | + {-0.000184615384615,-1,15.3846153846} | [(11,22),(33,44)] | (11,22) + {-0.000184615384615,-1,15.3846153846} | [(-10,2),(-10,3)] | (-10,3) + {-0.000184615384615,-1,15.3846153846} | [(0,-20),(30,-20)] | (30,-20) + {-0.000184615384615,-1,15.3846153846} | [(NaN,1),(NaN,90)] | + {3,NaN,5} | [(1,2),(3,4)] | + {3,NaN,5} | [(0,0),(6,6)] | + {3,NaN,5} | [(10,-10),(-3,-4)] | + {3,NaN,5} | [(-1000000,200),(300000,-40)] | + {3,NaN,5} | [(11,22),(33,44)] | + {3,NaN,5} | [(-10,2),(-10,3)] | + {3,NaN,5} | [(0,-20),(30,-20)] | + {3,NaN,5} | [(NaN,1),(NaN,90)] | + {NaN,NaN,NaN} | [(1,2),(3,4)] | + {NaN,NaN,NaN} | [(0,0),(6,6)] | + {NaN,NaN,NaN} | [(10,-10),(-3,-4)] | + {NaN,NaN,NaN} | [(-1000000,200),(300000,-40)] | + {NaN,NaN,NaN} | [(11,22),(33,44)] | + {NaN,NaN,NaN} | [(-10,2),(-10,3)] | + {NaN,NaN,NaN} | [(0,-20),(30,-20)] | + {NaN,NaN,NaN} | [(NaN,1),(NaN,90)] | + {0,-1,3} | [(1,2),(3,4)] | (2,3) + {0,-1,3} | [(0,0),(6,6)] | (3,3) + {0,-1,3} | [(10,-10),(-3,-4)] | (-3,-4) + {0,-1,3} | [(-1000000,200),(300000,-40)] | (67083.3333333,3) + {0,-1,3} | [(11,22),(33,44)] | (11,22) + {0,-1,3} | [(-10,2),(-10,3)] | (-10,3) + {0,-1,3} | [(0,-20),(30,-20)] | + {0,-1,3} | [(NaN,1),(NaN,90)] | + {-1,0,3} | [(1,2),(3,4)] | (3,4) + {-1,0,3} | [(0,0),(6,6)] | (3,3) + {-1,0,3} | [(10,-10),(-3,-4)] | (3,-6.76923076923) + {-1,0,3} | [(-1000000,200),(300000,-40)] | (3,15.3840615385) + {-1,0,3} | [(11,22),(33,44)] | (11,22) + {-1,0,3} | [(-10,2),(-10,3)] | + {-1,0,3} | [(0,-20),(30,-20)] | (3,-20) + {-1,0,3} | [(NaN,1),(NaN,90)] | +(80 rows) + +-- Closest point to box +SELECT l.s, b.f1, l.s ## b.f1 FROM LINE_TBL l, BOX_TBL b; +ERROR: function "close_lb" not implemented +-- +-- Line segments +-- +-- intersection +SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection + FROM LSEG_TBL l, POINT_TBL p; +ERROR: operator does not exist: lseg # point +LINE 1: SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection + ^ +HINT: No operator matches the given name and argument types. You might need to add explicit type casts. +-- Length +SELECT s, @-@ s FROM LSEG_TBL; + s | ?column? +-------------------------------+--------------- + [(1,2),(3,4)] | 2.82842712475 + [(0,0),(6,6)] | 8.48528137424 + [(10,-10),(-3,-4)] | 14.3178210633 + [(-1000000,200),(300000,-40)] | 1300000.02215 + [(11,22),(33,44)] | 31.1126983722 + [(-10,2),(-10,3)] | 1 + [(0,-20),(30,-20)] | 30 + [(NaN,1),(NaN,90)] | NaN +(8 rows) + +-- Vertical +SELECT s FROM LSEG_TBL WHERE ?| s; + s +------------------- + [(-10,2),(-10,3)] +(1 row) + +-- Horizontal +SELECT s FROM LSEG_TBL WHERE ?- s; + s +-------------------- + [(0,-20),(30,-20)] +(1 row) + +-- Center +SELECT s, @@ s FROM LSEG_TBL; + s | ?column? +-------------------------------+-------------- + [(1,2),(3,4)] | (2,3) + [(0,0),(6,6)] | (3,3) + [(10,-10),(-3,-4)] | (3.5,-7) + [(-1000000,200),(300000,-40)] | (-350000,80) + [(11,22),(33,44)] | (22,33) + [(-10,2),(-10,3)] | (-10,2.5) + [(0,-20),(30,-20)] | (15,-20) + [(NaN,1),(NaN,90)] | (NaN,45.5) +(8 rows) + +-- To point +SELECT s, s::point FROM LSEG_TBL; + s | s +-------------------------------+-------------- + [(1,2),(3,4)] | (2,3) + [(0,0),(6,6)] | (3,3) + [(10,-10),(-3,-4)] | (3.5,-7) + [(-1000000,200),(300000,-40)] | (-350000,80) + [(11,22),(33,44)] | (22,33) + [(-10,2),(-10,3)] | (-10,2.5) + [(0,-20),(30,-20)] | (15,-20) + [(NaN,1),(NaN,90)] | (NaN,45.5) +(8 rows) + +-- Has points less than line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s < l2.s; + s | s +--------------------+------------------------------- + [(1,2),(3,4)] | [(0,0),(6,6)] + [(1,2),(3,4)] | [(10,-10),(-3,-4)] + [(1,2),(3,4)] | [(-1000000,200),(300000,-40)] + [(1,2),(3,4)] | [(11,22),(33,44)] + [(1,2),(3,4)] | [(0,-20),(30,-20)] + [(0,0),(6,6)] | [(10,-10),(-3,-4)] + [(0,0),(6,6)] | [(-1000000,200),(300000,-40)] + [(0,0),(6,6)] | [(11,22),(33,44)] + [(0,0),(6,6)] | [(0,-20),(30,-20)] + [(10,-10),(-3,-4)] | [(-1000000,200),(300000,-40)] + [(10,-10),(-3,-4)] | [(11,22),(33,44)] + [(10,-10),(-3,-4)] | [(0,-20),(30,-20)] + [(11,22),(33,44)] | [(-1000000,200),(300000,-40)] + [(-10,2),(-10,3)] | [(1,2),(3,4)] + [(-10,2),(-10,3)] | [(0,0),(6,6)] + [(-10,2),(-10,3)] | [(10,-10),(-3,-4)] + [(-10,2),(-10,3)] | [(-1000000,200),(300000,-40)] + [(-10,2),(-10,3)] | [(11,22),(33,44)] + [(-10,2),(-10,3)] | [(0,-20),(30,-20)] + [(0,-20),(30,-20)] | [(-1000000,200),(300000,-40)] + [(0,-20),(30,-20)] | [(11,22),(33,44)] +(21 rows) + +-- Has points less than or equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s <= l2.s; + s | s +-------------------------------+------------------------------- + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | [(0,0),(6,6)] + [(1,2),(3,4)] | [(10,-10),(-3,-4)] + [(1,2),(3,4)] | [(-1000000,200),(300000,-40)] + [(1,2),(3,4)] | [(11,22),(33,44)] + [(1,2),(3,4)] | [(0,-20),(30,-20)] + [(0,0),(6,6)] | [(0,0),(6,6)] + [(0,0),(6,6)] | [(10,-10),(-3,-4)] + [(0,0),(6,6)] | [(-1000000,200),(300000,-40)] + [(0,0),(6,6)] | [(11,22),(33,44)] + [(0,0),(6,6)] | [(0,-20),(30,-20)] + [(10,-10),(-3,-4)] | [(10,-10),(-3,-4)] + [(10,-10),(-3,-4)] | [(-1000000,200),(300000,-40)] + [(10,-10),(-3,-4)] | [(11,22),(33,44)] + [(10,-10),(-3,-4)] | [(0,-20),(30,-20)] + [(-1000000,200),(300000,-40)] | [(-1000000,200),(300000,-40)] + [(11,22),(33,44)] | [(-1000000,200),(300000,-40)] + [(11,22),(33,44)] | [(11,22),(33,44)] + [(-10,2),(-10,3)] | [(1,2),(3,4)] + [(-10,2),(-10,3)] | [(0,0),(6,6)] + [(-10,2),(-10,3)] | [(10,-10),(-3,-4)] + [(-10,2),(-10,3)] | [(-1000000,200),(300000,-40)] + [(-10,2),(-10,3)] | [(11,22),(33,44)] + [(-10,2),(-10,3)] | [(-10,2),(-10,3)] + [(-10,2),(-10,3)] | [(0,-20),(30,-20)] + [(0,-20),(30,-20)] | [(-1000000,200),(300000,-40)] + [(0,-20),(30,-20)] | [(11,22),(33,44)] + [(0,-20),(30,-20)] | [(0,-20),(30,-20)] +(28 rows) + +-- Has points equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s = l2.s; + s | s +-------------------------------+------------------------------- + [(1,2),(3,4)] | [(1,2),(3,4)] + [(0,0),(6,6)] | [(0,0),(6,6)] + [(10,-10),(-3,-4)] | [(10,-10),(-3,-4)] + [(-1000000,200),(300000,-40)] | [(-1000000,200),(300000,-40)] + [(11,22),(33,44)] | [(11,22),(33,44)] + [(-10,2),(-10,3)] | [(-10,2),(-10,3)] + [(0,-20),(30,-20)] | [(0,-20),(30,-20)] + [(NaN,1),(NaN,90)] | [(NaN,1),(NaN,90)] +(8 rows) + +-- Has points greater than or equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s >= l2.s; + s | s +-------------------------------+------------------------------- + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | [(-10,2),(-10,3)] + [(0,0),(6,6)] | [(1,2),(3,4)] + [(0,0),(6,6)] | [(0,0),(6,6)] + [(0,0),(6,6)] | [(-10,2),(-10,3)] + [(10,-10),(-3,-4)] | [(1,2),(3,4)] + [(10,-10),(-3,-4)] | [(0,0),(6,6)] + [(10,-10),(-3,-4)] | [(10,-10),(-3,-4)] + [(10,-10),(-3,-4)] | [(-10,2),(-10,3)] + [(-1000000,200),(300000,-40)] | [(1,2),(3,4)] + [(-1000000,200),(300000,-40)] | [(0,0),(6,6)] + [(-1000000,200),(300000,-40)] | [(10,-10),(-3,-4)] + [(-1000000,200),(300000,-40)] | [(-1000000,200),(300000,-40)] + [(-1000000,200),(300000,-40)] | [(11,22),(33,44)] + [(-1000000,200),(300000,-40)] | [(-10,2),(-10,3)] + [(-1000000,200),(300000,-40)] | [(0,-20),(30,-20)] + [(11,22),(33,44)] | [(1,2),(3,4)] + [(11,22),(33,44)] | [(0,0),(6,6)] + [(11,22),(33,44)] | [(10,-10),(-3,-4)] + [(11,22),(33,44)] | [(11,22),(33,44)] + [(11,22),(33,44)] | [(-10,2),(-10,3)] + [(11,22),(33,44)] | [(0,-20),(30,-20)] + [(-10,2),(-10,3)] | [(-10,2),(-10,3)] + [(0,-20),(30,-20)] | [(1,2),(3,4)] + [(0,-20),(30,-20)] | [(0,0),(6,6)] + [(0,-20),(30,-20)] | [(10,-10),(-3,-4)] + [(0,-20),(30,-20)] | [(-10,2),(-10,3)] + [(0,-20),(30,-20)] | [(0,-20),(30,-20)] +(28 rows) + +-- Has points greater than line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s > l2.s; + s | s +-------------------------------+-------------------- + [(1,2),(3,4)] | [(-10,2),(-10,3)] + [(0,0),(6,6)] | [(1,2),(3,4)] + [(0,0),(6,6)] | [(-10,2),(-10,3)] + [(10,-10),(-3,-4)] | [(1,2),(3,4)] + [(10,-10),(-3,-4)] | [(0,0),(6,6)] + [(10,-10),(-3,-4)] | [(-10,2),(-10,3)] + [(-1000000,200),(300000,-40)] | [(1,2),(3,4)] + [(-1000000,200),(300000,-40)] | [(0,0),(6,6)] + [(-1000000,200),(300000,-40)] | [(10,-10),(-3,-4)] + [(-1000000,200),(300000,-40)] | [(11,22),(33,44)] + [(-1000000,200),(300000,-40)] | [(-10,2),(-10,3)] + [(-1000000,200),(300000,-40)] | [(0,-20),(30,-20)] + [(11,22),(33,44)] | [(1,2),(3,4)] + [(11,22),(33,44)] | [(0,0),(6,6)] + [(11,22),(33,44)] | [(10,-10),(-3,-4)] + [(11,22),(33,44)] | [(-10,2),(-10,3)] + [(11,22),(33,44)] | [(0,-20),(30,-20)] + [(0,-20),(30,-20)] | [(1,2),(3,4)] + [(0,-20),(30,-20)] | [(0,0),(6,6)] + [(0,-20),(30,-20)] | [(10,-10),(-3,-4)] + [(0,-20),(30,-20)] | [(-10,2),(-10,3)] +(21 rows) + +-- Has points not equal to line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s != l2.s; + s | s +-------------------------------+------------------------------- + [(1,2),(3,4)] | [(0,0),(6,6)] + [(1,2),(3,4)] | [(10,-10),(-3,-4)] + [(1,2),(3,4)] | [(-1000000,200),(300000,-40)] + [(1,2),(3,4)] | [(11,22),(33,44)] + [(1,2),(3,4)] | [(-10,2),(-10,3)] + [(1,2),(3,4)] | [(0,-20),(30,-20)] + [(1,2),(3,4)] | [(NaN,1),(NaN,90)] + [(0,0),(6,6)] | [(1,2),(3,4)] + [(0,0),(6,6)] | [(10,-10),(-3,-4)] + [(0,0),(6,6)] | [(-1000000,200),(300000,-40)] + [(0,0),(6,6)] | [(11,22),(33,44)] + [(0,0),(6,6)] | [(-10,2),(-10,3)] + [(0,0),(6,6)] | [(0,-20),(30,-20)] + [(0,0),(6,6)] | [(NaN,1),(NaN,90)] + [(10,-10),(-3,-4)] | [(1,2),(3,4)] + [(10,-10),(-3,-4)] | [(0,0),(6,6)] + [(10,-10),(-3,-4)] | [(-1000000,200),(300000,-40)] + [(10,-10),(-3,-4)] | [(11,22),(33,44)] + [(10,-10),(-3,-4)] | [(-10,2),(-10,3)] + [(10,-10),(-3,-4)] | [(0,-20),(30,-20)] + [(10,-10),(-3,-4)] | [(NaN,1),(NaN,90)] + [(-1000000,200),(300000,-40)] | [(1,2),(3,4)] + [(-1000000,200),(300000,-40)] | [(0,0),(6,6)] + [(-1000000,200),(300000,-40)] | [(10,-10),(-3,-4)] + [(-1000000,200),(300000,-40)] | [(11,22),(33,44)] + [(-1000000,200),(300000,-40)] | [(-10,2),(-10,3)] + [(-1000000,200),(300000,-40)] | [(0,-20),(30,-20)] + [(-1000000,200),(300000,-40)] | [(NaN,1),(NaN,90)] + [(11,22),(33,44)] | [(1,2),(3,4)] + [(11,22),(33,44)] | [(0,0),(6,6)] + [(11,22),(33,44)] | [(10,-10),(-3,-4)] + [(11,22),(33,44)] | [(-1000000,200),(300000,-40)] + [(11,22),(33,44)] | [(-10,2),(-10,3)] + [(11,22),(33,44)] | [(0,-20),(30,-20)] + [(11,22),(33,44)] | [(NaN,1),(NaN,90)] + [(-10,2),(-10,3)] | [(1,2),(3,4)] + [(-10,2),(-10,3)] | [(0,0),(6,6)] + [(-10,2),(-10,3)] | [(10,-10),(-3,-4)] + [(-10,2),(-10,3)] | [(-1000000,200),(300000,-40)] + [(-10,2),(-10,3)] | [(11,22),(33,44)] + [(-10,2),(-10,3)] | [(0,-20),(30,-20)] + [(-10,2),(-10,3)] | [(NaN,1),(NaN,90)] + [(0,-20),(30,-20)] | [(1,2),(3,4)] + [(0,-20),(30,-20)] | [(0,0),(6,6)] + [(0,-20),(30,-20)] | [(10,-10),(-3,-4)] + [(0,-20),(30,-20)] | [(-1000000,200),(300000,-40)] + [(0,-20),(30,-20)] | [(11,22),(33,44)] + [(0,-20),(30,-20)] | [(-10,2),(-10,3)] + [(0,-20),(30,-20)] | [(NaN,1),(NaN,90)] + [(NaN,1),(NaN,90)] | [(1,2),(3,4)] + [(NaN,1),(NaN,90)] | [(0,0),(6,6)] + [(NaN,1),(NaN,90)] | [(10,-10),(-3,-4)] + [(NaN,1),(NaN,90)] | [(-1000000,200),(300000,-40)] + [(NaN,1),(NaN,90)] | [(11,22),(33,44)] + [(NaN,1),(NaN,90)] | [(-10,2),(-10,3)] + [(NaN,1),(NaN,90)] | [(0,-20),(30,-20)] +(56 rows) + +-- Parallel with line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s ?|| l2.s; + s | s +-------------------------------+------------------------------- + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | [(0,0),(6,6)] + [(1,2),(3,4)] | [(11,22),(33,44)] + [(0,0),(6,6)] | [(1,2),(3,4)] + [(0,0),(6,6)] | [(0,0),(6,6)] + [(0,0),(6,6)] | [(11,22),(33,44)] + [(10,-10),(-3,-4)] | [(10,-10),(-3,-4)] + [(-1000000,200),(300000,-40)] | [(-1000000,200),(300000,-40)] + [(11,22),(33,44)] | [(1,2),(3,4)] + [(11,22),(33,44)] | [(0,0),(6,6)] + [(11,22),(33,44)] | [(11,22),(33,44)] + [(-10,2),(-10,3)] | [(-10,2),(-10,3)] + [(0,-20),(30,-20)] | [(0,-20),(30,-20)] +(13 rows) + +-- Perpendicular with line segment +SELECT l1.s, l2.s FROM LSEG_TBL l1, LSEG_TBL l2 WHERE l1.s ?-| l2.s; + s | s +--------------------+-------------------- + [(-10,2),(-10,3)] | [(0,-20),(30,-20)] + [(0,-20),(30,-20)] | [(-10,2),(-10,3)] +(2 rows) + +-- Distance to line +SELECT l.s, l1.s, l.s <-> l1.s AS dist_sl, l1.s <-> l.s AS dist_ls FROM LSEG_TBL l, LINE_TBL l1; + s | s | dist_sl | dist_ls +-------------------------------+---------------------------------------+----------------+---------------- + [(1,2),(3,4)] | {0,-1,5} | 1 | 1 + [(0,0),(6,6)] | {0,-1,5} | 0 | 0 + [(10,-10),(-3,-4)] | {0,-1,5} | 9 | 9 + [(-1000000,200),(300000,-40)] | {0,-1,5} | 0 | 0 + [(11,22),(33,44)] | {0,-1,5} | 17 | 17 + [(-10,2),(-10,3)] | {0,-1,5} | 2 | 2 + [(0,-20),(30,-20)] | {0,-1,5} | 25 | 25 + [(NaN,1),(NaN,90)] | {0,-1,5} | NaN | NaN + [(1,2),(3,4)] | {1,0,5} | 6 | 6 + [(0,0),(6,6)] | {1,0,5} | 5 | 5 + [(10,-10),(-3,-4)] | {1,0,5} | 2 | 2 + [(-1000000,200),(300000,-40)] | {1,0,5} | 0 | 0 + [(11,22),(33,44)] | {1,0,5} | 16 | 16 + [(-10,2),(-10,3)] | {1,0,5} | 5 | 5 + [(0,-20),(30,-20)] | {1,0,5} | 5 | 5 + [(NaN,1),(NaN,90)] | {1,0,5} | NaN | NaN + [(1,2),(3,4)] | {0,3,0} | 2 | 2 + [(0,0),(6,6)] | {0,3,0} | 0 | 0 + [(10,-10),(-3,-4)] | {0,3,0} | 4 | 4 + [(-1000000,200),(300000,-40)] | {0,3,0} | 0 | 0 + [(11,22),(33,44)] | {0,3,0} | 22 | 22 + [(-10,2),(-10,3)] | {0,3,0} | 2 | 2 + [(0,-20),(30,-20)] | {0,3,0} | 20 | 20 + [(NaN,1),(NaN,90)] | {0,3,0} | NaN | NaN + [(1,2),(3,4)] | {1,-1,0} | 0.707106781187 | 0.707106781187 + [(0,0),(6,6)] | {1,-1,0} | 0 | 0 + [(10,-10),(-3,-4)] | {1,-1,0} | 0.707106781187 | 0.707106781187 + [(-1000000,200),(300000,-40)] | {1,-1,0} | 0 | 0 + [(11,22),(33,44)] | {1,-1,0} | 7.77817459305 | 7.77817459305 + [(-10,2),(-10,3)] | {1,-1,0} | 8.48528137424 | 8.48528137424 + [(0,-20),(30,-20)] | {1,-1,0} | 14.1421356237 | 14.1421356237 + [(NaN,1),(NaN,90)] | {1,-1,0} | NaN | NaN + [(1,2),(3,4)] | {-0.4,-1,-6} | 7.79920420344 | 7.79920420344 + [(0,0),(6,6)] | {-0.4,-1,-6} | 5.57086014531 | 5.57086014531 + [(10,-10),(-3,-4)] | {-0.4,-1,-6} | 0 | 0 + [(-1000000,200),(300000,-40)] | {-0.4,-1,-6} | 0 | 0 + [(11,22),(33,44)] | {-0.4,-1,-6} | 30.0826447847 | 30.0826447847 + [(-10,2),(-10,3)] | {-0.4,-1,-6} | 3.71390676354 | 3.71390676354 + [(0,-20),(30,-20)] | {-0.4,-1,-6} | 1.85695338177 | 1.85695338177 + [(NaN,1),(NaN,90)] | {-0.4,-1,-6} | NaN | NaN + [(1,2),(3,4)] | {-0.000184615384615,-1,15.3846153846} | 11.3840613445 | 11.3840613445 + [(0,0),(6,6)] | {-0.000184615384615,-1,15.3846153846} | 9.3835075324 | 9.3835075324 + [(10,-10),(-3,-4)] | {-0.000184615384615,-1,15.3846153846} | 19.3851689004 | 19.3851689004 + [(-1000000,200),(300000,-40)] | {-0.000184615384615,-1,15.3846153846} | 0 | 0 + [(11,22),(33,44)] | {-0.000184615384615,-1,15.3846153846} | 6.61741527185 | 6.61741527185 + [(-10,2),(-10,3)] | {-0.000184615384615,-1,15.3846153846} | 12.3864613274 | 12.3864613274 + [(0,-20),(30,-20)] | {-0.000184615384615,-1,15.3846153846} | 35.3790763202 | 35.3790763202 + [(NaN,1),(NaN,90)] | {-0.000184615384615,-1,15.3846153846} | NaN | NaN + [(1,2),(3,4)] | {3,NaN,5} | NaN | NaN + [(0,0),(6,6)] | {3,NaN,5} | NaN | NaN + [(10,-10),(-3,-4)] | {3,NaN,5} | NaN | NaN + [(-1000000,200),(300000,-40)] | {3,NaN,5} | NaN | NaN + [(11,22),(33,44)] | {3,NaN,5} | NaN | NaN + [(-10,2),(-10,3)] | {3,NaN,5} | NaN | NaN + [(0,-20),(30,-20)] | {3,NaN,5} | NaN | NaN + [(NaN,1),(NaN,90)] | {3,NaN,5} | NaN | NaN + [(1,2),(3,4)] | {NaN,NaN,NaN} | NaN | NaN + [(0,0),(6,6)] | {NaN,NaN,NaN} | NaN | NaN + [(10,-10),(-3,-4)] | {NaN,NaN,NaN} | NaN | NaN + [(-1000000,200),(300000,-40)] | {NaN,NaN,NaN} | NaN | NaN + [(11,22),(33,44)] | {NaN,NaN,NaN} | NaN | NaN + [(-10,2),(-10,3)] | {NaN,NaN,NaN} | NaN | NaN + [(0,-20),(30,-20)] | {NaN,NaN,NaN} | NaN | NaN + [(NaN,1),(NaN,90)] | {NaN,NaN,NaN} | NaN | NaN + [(1,2),(3,4)] | {0,-1,3} | 0 | 0 + [(0,0),(6,6)] | {0,-1,3} | 0 | 0 + [(10,-10),(-3,-4)] | {0,-1,3} | 7 | 7 + [(-1000000,200),(300000,-40)] | {0,-1,3} | 0 | 0 + [(11,22),(33,44)] | {0,-1,3} | 19 | 19 + [(-10,2),(-10,3)] | {0,-1,3} | 0 | 0 + [(0,-20),(30,-20)] | {0,-1,3} | 23 | 23 + [(NaN,1),(NaN,90)] | {0,-1,3} | NaN | NaN + [(1,2),(3,4)] | {-1,0,3} | 0 | 0 + [(0,0),(6,6)] | {-1,0,3} | 0 | 0 + [(10,-10),(-3,-4)] | {-1,0,3} | 0 | 0 + [(-1000000,200),(300000,-40)] | {-1,0,3} | 0 | 0 + [(11,22),(33,44)] | {-1,0,3} | 8 | 8 + [(-10,2),(-10,3)] | {-1,0,3} | 13 | 13 + [(0,-20),(30,-20)] | {-1,0,3} | 0 | 0 + [(NaN,1),(NaN,90)] | {-1,0,3} | NaN | NaN +(80 rows) + +-- Distance to line segment +SELECT l1.s, l2.s, l1.s <-> l2.s FROM LSEG_TBL l1, LSEG_TBL l2; + s | s | ?column? +-------------------------------+-------------------------------+---------------- + [(1,2),(3,4)] | [(1,2),(3,4)] | 0 + [(1,2),(3,4)] | [(0,0),(6,6)] | 0.707106781187 + [(1,2),(3,4)] | [(10,-10),(-3,-4)] | 7.12398901685 + [(1,2),(3,4)] | [(-1000000,200),(300000,-40)] | 11.3840613445 + [(1,2),(3,4)] | [(11,22),(33,44)] | 19.6977156036 + [(1,2),(3,4)] | [(-10,2),(-10,3)] | 11 + [(1,2),(3,4)] | [(0,-20),(30,-20)] | 22 + [(1,2),(3,4)] | [(NaN,1),(NaN,90)] | NaN + [(0,0),(6,6)] | [(1,2),(3,4)] | 0.707106781187 + [(0,0),(6,6)] | [(0,0),(6,6)] | 0 + [(0,0),(6,6)] | [(10,-10),(-3,-4)] | 4.88901207039 + [(0,0),(6,6)] | [(-1000000,200),(300000,-40)] | 9.3835075324 + [(0,0),(6,6)] | [(11,22),(33,44)] | 16.7630546142 + [(0,0),(6,6)] | [(-10,2),(-10,3)] | 10.1980390272 + [(0,0),(6,6)] | [(0,-20),(30,-20)] | 20 + [(0,0),(6,6)] | [(NaN,1),(NaN,90)] | NaN + [(10,-10),(-3,-4)] | [(1,2),(3,4)] | 7.12398901685 + [(10,-10),(-3,-4)] | [(0,0),(6,6)] | 4.88901207039 + [(10,-10),(-3,-4)] | [(10,-10),(-3,-4)] | 0 + [(10,-10),(-3,-4)] | [(-1000000,200),(300000,-40)] | 19.3851689004 + [(10,-10),(-3,-4)] | [(11,22),(33,44)] | 29.4737584815 + [(10,-10),(-3,-4)] | [(-10,2),(-10,3)] | 9.21954445729 + [(10,-10),(-3,-4)] | [(0,-20),(30,-20)] | 10 + [(10,-10),(-3,-4)] | [(NaN,1),(NaN,90)] | NaN + [(-1000000,200),(300000,-40)] | [(1,2),(3,4)] | 11.3840613445 + [(-1000000,200),(300000,-40)] | [(0,0),(6,6)] | 9.3835075324 + [(-1000000,200),(300000,-40)] | [(10,-10),(-3,-4)] | 19.3851689004 + [(-1000000,200),(300000,-40)] | [(-1000000,200),(300000,-40)] | 0 + [(-1000000,200),(300000,-40)] | [(11,22),(33,44)] | 6.61741527185 + [(-1000000,200),(300000,-40)] | [(-10,2),(-10,3)] | 12.3864613274 + [(-1000000,200),(300000,-40)] | [(0,-20),(30,-20)] | 35.3790763202 + [(-1000000,200),(300000,-40)] | [(NaN,1),(NaN,90)] | NaN + [(11,22),(33,44)] | [(1,2),(3,4)] | 19.6977156036 + [(11,22),(33,44)] | [(0,0),(6,6)] | 16.7630546142 + [(11,22),(33,44)] | [(10,-10),(-3,-4)] | 29.4737584815 + [(11,22),(33,44)] | [(-1000000,200),(300000,-40)] | 6.61741527185 + [(11,22),(33,44)] | [(11,22),(33,44)] | 0 + [(11,22),(33,44)] | [(-10,2),(-10,3)] | 28.319604517 + [(11,22),(33,44)] | [(0,-20),(30,-20)] | 42 + [(11,22),(33,44)] | [(NaN,1),(NaN,90)] | NaN + [(-10,2),(-10,3)] | [(1,2),(3,4)] | 11 + [(-10,2),(-10,3)] | [(0,0),(6,6)] | 10.1980390272 + [(-10,2),(-10,3)] | [(10,-10),(-3,-4)] | 9.21954445729 + [(-10,2),(-10,3)] | [(-1000000,200),(300000,-40)] | 12.3864613274 + [(-10,2),(-10,3)] | [(11,22),(33,44)] | 28.319604517 + [(-10,2),(-10,3)] | [(-10,2),(-10,3)] | 0 + [(-10,2),(-10,3)] | [(0,-20),(30,-20)] | 24.1660919472 + [(-10,2),(-10,3)] | [(NaN,1),(NaN,90)] | NaN + [(0,-20),(30,-20)] | [(1,2),(3,4)] | 22 + [(0,-20),(30,-20)] | [(0,0),(6,6)] | 20 + [(0,-20),(30,-20)] | [(10,-10),(-3,-4)] | 10 + [(0,-20),(30,-20)] | [(-1000000,200),(300000,-40)] | 35.3790763202 + [(0,-20),(30,-20)] | [(11,22),(33,44)] | 42 + [(0,-20),(30,-20)] | [(-10,2),(-10,3)] | 24.1660919472 + [(0,-20),(30,-20)] | [(0,-20),(30,-20)] | 0 + [(0,-20),(30,-20)] | [(NaN,1),(NaN,90)] | NaN + [(NaN,1),(NaN,90)] | [(1,2),(3,4)] | NaN + [(NaN,1),(NaN,90)] | [(0,0),(6,6)] | NaN + [(NaN,1),(NaN,90)] | [(10,-10),(-3,-4)] | NaN + [(NaN,1),(NaN,90)] | [(-1000000,200),(300000,-40)] | NaN + [(NaN,1),(NaN,90)] | [(11,22),(33,44)] | NaN + [(NaN,1),(NaN,90)] | [(-10,2),(-10,3)] | NaN + [(NaN,1),(NaN,90)] | [(0,-20),(30,-20)] | NaN + [(NaN,1),(NaN,90)] | [(NaN,1),(NaN,90)] | NaN +(64 rows) + +-- Distance to box +SELECT l.s, b.f1, l.s <-> b.f1 AS dist_sb, b.f1 <-> l.s AS dist_bs FROM LSEG_TBL l, BOX_TBL b; + s | f1 | dist_sb | dist_bs +-------------------------------+---------------------+----------------+---------------- + [(1,2),(3,4)] | (2,2),(0,0) | 0 | 0 + [(1,2),(3,4)] | (3,3),(1,1) | 0 | 0 + [(1,2),(3,4)] | (-2,2),(-8,-10) | 3 | 3 + [(1,2),(3,4)] | (2.5,3.5),(2.5,2.5) | 0 | 0 + [(1,2),(3,4)] | (3,3),(3,3) | 0.707106781187 | 0.707106781187 + [(0,0),(6,6)] | (2,2),(0,0) | 0 | 0 + [(0,0),(6,6)] | (3,3),(1,1) | 0 | 0 + [(0,0),(6,6)] | (-2,2),(-8,-10) | 2 | 2 + [(0,0),(6,6)] | (2.5,3.5),(2.5,2.5) | 0 | 0 + [(0,0),(6,6)] | (3,3),(3,3) | 0 | 0 + [(10,-10),(-3,-4)] | (2,2),(0,0) | 4.88901207039 | 4.88901207039 + [(10,-10),(-3,-4)] | (3,3),(1,1) | 6.21602963235 | 6.21602963235 + [(10,-10),(-3,-4)] | (-2,2),(-8,-10) | 0 | 0 + [(10,-10),(-3,-4)] | (2.5,3.5),(2.5,2.5) | 8.20655597529 | 8.20655597529 + [(10,-10),(-3,-4)] | (3,3),(3,3) | 8.87006475627 | 8.87006475627 + [(-1000000,200),(300000,-40)] | (2,2),(0,0) | 13.3842459258 | 13.3842459258 + [(-1000000,200),(300000,-40)] | (3,3),(1,1) | 12.3840613274 | 12.3840613274 + [(-1000000,200),(300000,-40)] | (-2,2),(-8,-10) | 13.3849843873 | 13.3849843873 + [(-1000000,200),(300000,-40)] | (2.5,3.5),(2.5,2.5) | 11.8841536436 | 11.8841536436 + [(-1000000,200),(300000,-40)] | (3,3),(3,3) | 12.3840613274 | 12.3840613274 + [(11,22),(33,44)] | (2,2),(0,0) | 21.9317121995 | 21.9317121995 + [(11,22),(33,44)] | (3,3),(1,1) | 20.6155281281 | 20.6155281281 + [(11,22),(33,44)] | (-2,2),(-8,-10) | 23.8537208838 | 23.8537208838 + [(11,22),(33,44)] | (2.5,3.5),(2.5,2.5) | 20.3592730715 | 20.3592730715 + [(11,22),(33,44)] | (3,3),(3,3) | 20.6155281281 | 20.6155281281 + [(-10,2),(-10,3)] | (2,2),(0,0) | 10 | 10 + [(-10,2),(-10,3)] | (3,3),(1,1) | 11 | 11 + [(-10,2),(-10,3)] | (-2,2),(-8,-10) | 2 | 2 + [(-10,2),(-10,3)] | (2.5,3.5),(2.5,2.5) | 12.5 | 12.5 + [(-10,2),(-10,3)] | (3,3),(3,3) | 13 | 13 + [(0,-20),(30,-20)] | (2,2),(0,0) | 20 | 20 + [(0,-20),(30,-20)] | (3,3),(1,1) | 21 | 21 + [(0,-20),(30,-20)] | (-2,2),(-8,-10) | 10.1980390272 | 10.1980390272 + [(0,-20),(30,-20)] | (2.5,3.5),(2.5,2.5) | 22.5 | 22.5 + [(0,-20),(30,-20)] | (3,3),(3,3) | 23 | 23 + [(NaN,1),(NaN,90)] | (2,2),(0,0) | NaN | NaN + [(NaN,1),(NaN,90)] | (3,3),(1,1) | NaN | NaN + [(NaN,1),(NaN,90)] | (-2,2),(-8,-10) | NaN | NaN + [(NaN,1),(NaN,90)] | (2.5,3.5),(2.5,2.5) | NaN | NaN + [(NaN,1),(NaN,90)] | (3,3),(3,3) | NaN | NaN +(40 rows) + +-- Intersect with line segment +SELECT l.s, l1.s FROM LSEG_TBL l, LINE_TBL l1 WHERE l.s ?# l1.s; + s | s +-------------------------------+-------------- + [(0,0),(6,6)] | {0,-1,5} + [(-1000000,200),(300000,-40)] | {0,-1,5} + [(-1000000,200),(300000,-40)] | {1,0,5} + [(0,0),(6,6)] | {0,3,0} + [(-1000000,200),(300000,-40)] | {0,3,0} + [(-1000000,200),(300000,-40)] | {1,-1,0} + [(10,-10),(-3,-4)] | {-0.4,-1,-6} + [(-1000000,200),(300000,-40)] | {-0.4,-1,-6} + [(1,2),(3,4)] | {0,-1,3} + [(0,0),(6,6)] | {0,-1,3} + [(-1000000,200),(300000,-40)] | {0,-1,3} + [(-10,2),(-10,3)] | {0,-1,3} + [(1,2),(3,4)] | {-1,0,3} + [(0,0),(6,6)] | {-1,0,3} + [(10,-10),(-3,-4)] | {-1,0,3} + [(-1000000,200),(300000,-40)] | {-1,0,3} + [(0,-20),(30,-20)] | {-1,0,3} +(17 rows) + +-- Intersect with box +SELECT l.s, b.f1 FROM LSEG_TBL l, BOX_TBL b WHERE l.s ?# b.f1; + s | f1 +--------------------+--------------------- + [(1,2),(3,4)] | (2,2),(0,0) + [(1,2),(3,4)] | (3,3),(1,1) + [(1,2),(3,4)] | (2.5,3.5),(2.5,2.5) + [(0,0),(6,6)] | (2,2),(0,0) + [(0,0),(6,6)] | (3,3),(1,1) + [(0,0),(6,6)] | (2.5,3.5),(2.5,2.5) + [(0,0),(6,6)] | (3,3),(3,3) + [(10,-10),(-3,-4)] | (-2,2),(-8,-10) +(8 rows) + +-- Intersection point with line segment +SELECT l1.s, l2.s, l1.s # l2.s FROM LSEG_TBL l1, LSEG_TBL l2; + s | s | ?column? +-------------------------------+-------------------------------+---------- + [(1,2),(3,4)] | [(1,2),(3,4)] | + [(1,2),(3,4)] | [(0,0),(6,6)] | + [(1,2),(3,4)] | [(10,-10),(-3,-4)] | + [(1,2),(3,4)] | [(-1000000,200),(300000,-40)] | + [(1,2),(3,4)] | [(11,22),(33,44)] | + [(1,2),(3,4)] | [(-10,2),(-10,3)] | + [(1,2),(3,4)] | [(0,-20),(30,-20)] | + [(1,2),(3,4)] | [(NaN,1),(NaN,90)] | + [(0,0),(6,6)] | [(1,2),(3,4)] | + [(0,0),(6,6)] | [(0,0),(6,6)] | + [(0,0),(6,6)] | [(10,-10),(-3,-4)] | + [(0,0),(6,6)] | [(-1000000,200),(300000,-40)] | + [(0,0),(6,6)] | [(11,22),(33,44)] | + [(0,0),(6,6)] | [(-10,2),(-10,3)] | + [(0,0),(6,6)] | [(0,-20),(30,-20)] | + [(0,0),(6,6)] | [(NaN,1),(NaN,90)] | + [(10,-10),(-3,-4)] | [(1,2),(3,4)] | + [(10,-10),(-3,-4)] | [(0,0),(6,6)] | + [(10,-10),(-3,-4)] | [(10,-10),(-3,-4)] | + [(10,-10),(-3,-4)] | [(-1000000,200),(300000,-40)] | + [(10,-10),(-3,-4)] | [(11,22),(33,44)] | + [(10,-10),(-3,-4)] | [(-10,2),(-10,3)] | + [(10,-10),(-3,-4)] | [(0,-20),(30,-20)] | + [(10,-10),(-3,-4)] | [(NaN,1),(NaN,90)] | + [(-1000000,200),(300000,-40)] | [(1,2),(3,4)] | + [(-1000000,200),(300000,-40)] | [(0,0),(6,6)] | + [(-1000000,200),(300000,-40)] | [(10,-10),(-3,-4)] | + [(-1000000,200),(300000,-40)] | [(-1000000,200),(300000,-40)] | + [(-1000000,200),(300000,-40)] | [(11,22),(33,44)] | + [(-1000000,200),(300000,-40)] | [(-10,2),(-10,3)] | + [(-1000000,200),(300000,-40)] | [(0,-20),(30,-20)] | + [(-1000000,200),(300000,-40)] | [(NaN,1),(NaN,90)] | + [(11,22),(33,44)] | [(1,2),(3,4)] | + [(11,22),(33,44)] | [(0,0),(6,6)] | + [(11,22),(33,44)] | [(10,-10),(-3,-4)] | + [(11,22),(33,44)] | [(-1000000,200),(300000,-40)] | + [(11,22),(33,44)] | [(11,22),(33,44)] | + [(11,22),(33,44)] | [(-10,2),(-10,3)] | + [(11,22),(33,44)] | [(0,-20),(30,-20)] | + [(11,22),(33,44)] | [(NaN,1),(NaN,90)] | + [(-10,2),(-10,3)] | [(1,2),(3,4)] | + [(-10,2),(-10,3)] | [(0,0),(6,6)] | + [(-10,2),(-10,3)] | [(10,-10),(-3,-4)] | + [(-10,2),(-10,3)] | [(-1000000,200),(300000,-40)] | + [(-10,2),(-10,3)] | [(11,22),(33,44)] | + [(-10,2),(-10,3)] | [(-10,2),(-10,3)] | + [(-10,2),(-10,3)] | [(0,-20),(30,-20)] | + [(-10,2),(-10,3)] | [(NaN,1),(NaN,90)] | + [(0,-20),(30,-20)] | [(1,2),(3,4)] | + [(0,-20),(30,-20)] | [(0,0),(6,6)] | + [(0,-20),(30,-20)] | [(10,-10),(-3,-4)] | + [(0,-20),(30,-20)] | [(-1000000,200),(300000,-40)] | + [(0,-20),(30,-20)] | [(11,22),(33,44)] | + [(0,-20),(30,-20)] | [(-10,2),(-10,3)] | + [(0,-20),(30,-20)] | [(0,-20),(30,-20)] | + [(0,-20),(30,-20)] | [(NaN,1),(NaN,90)] | + [(NaN,1),(NaN,90)] | [(1,2),(3,4)] | + [(NaN,1),(NaN,90)] | [(0,0),(6,6)] | + [(NaN,1),(NaN,90)] | [(10,-10),(-3,-4)] | + [(NaN,1),(NaN,90)] | [(-1000000,200),(300000,-40)] | + [(NaN,1),(NaN,90)] | [(11,22),(33,44)] | + [(NaN,1),(NaN,90)] | [(-10,2),(-10,3)] | + [(NaN,1),(NaN,90)] | [(0,-20),(30,-20)] | + [(NaN,1),(NaN,90)] | [(NaN,1),(NaN,90)] | +(64 rows) + +-- Closest point to line +SELECT l.s, l1.s, l.s ## l1.s FROM LSEG_TBL l, LINE_TBL l1; +ERROR: function "close_sl" not implemented +-- Closest point to line segment +SELECT l1.s, l2.s, l1.s ## l2.s FROM LSEG_TBL l1, LSEG_TBL l2; + s | s | ?column? +-------------------------------+-------------------------------+--------------------------------- + [(1,2),(3,4)] | [(1,2),(3,4)] | + [(1,2),(3,4)] | [(0,0),(6,6)] | + [(1,2),(3,4)] | [(10,-10),(-3,-4)] | (-1.98536585366,-4.46829268293) + [(1,2),(3,4)] | [(-1000000,200),(300000,-40)] | (3.00210167283,15.3840611505) + [(1,2),(3,4)] | [(11,22),(33,44)] | + [(1,2),(3,4)] | [(-10,2),(-10,3)] | (-10,2) + [(1,2),(3,4)] | [(0,-20),(30,-20)] | (1,-20) + [(1,2),(3,4)] | [(NaN,1),(NaN,90)] | + [(0,0),(6,6)] | [(1,2),(3,4)] | + [(0,0),(6,6)] | [(0,0),(6,6)] | + [(0,0),(6,6)] | [(10,-10),(-3,-4)] | (-2.0487804878,-4.43902439024) + [(0,0),(6,6)] | [(-1000000,200),(300000,-40)] | (6.00173233982,15.3835073725) + [(0,0),(6,6)] | [(11,22),(33,44)] | + [(0,0),(6,6)] | [(-10,2),(-10,3)] | (-10,2) + [(0,0),(6,6)] | [(0,-20),(30,-20)] | (0,-20) + [(0,0),(6,6)] | [(NaN,1),(NaN,90)] | + [(10,-10),(-3,-4)] | [(1,2),(3,4)] | (1,2) + [(10,-10),(-3,-4)] | [(0,0),(6,6)] | (0,0) + [(10,-10),(-3,-4)] | [(10,-10),(-3,-4)] | + [(10,-10),(-3,-4)] | [(-1000000,200),(300000,-40)] | (-2.99642119965,15.3851685701) + [(10,-10),(-3,-4)] | [(11,22),(33,44)] | (11,22) + [(10,-10),(-3,-4)] | [(-10,2),(-10,3)] | (-10,2) + [(10,-10),(-3,-4)] | [(0,-20),(30,-20)] | (10,-20) + [(10,-10),(-3,-4)] | [(NaN,1),(NaN,90)] | + [(-1000000,200),(300000,-40)] | [(1,2),(3,4)] | (3,4) + [(-1000000,200),(300000,-40)] | [(0,0),(6,6)] | (6,6) + [(-1000000,200),(300000,-40)] | [(10,-10),(-3,-4)] | (-3,-4) + [(-1000000,200),(300000,-40)] | [(-1000000,200),(300000,-40)] | + [(-1000000,200),(300000,-40)] | [(11,22),(33,44)] | (11,22) + [(-1000000,200),(300000,-40)] | [(-10,2),(-10,3)] | (-10,3) + [(-1000000,200),(300000,-40)] | [(0,-20),(30,-20)] | (30,-20) + [(-1000000,200),(300000,-40)] | [(NaN,1),(NaN,90)] | + [(11,22),(33,44)] | [(1,2),(3,4)] | + [(11,22),(33,44)] | [(0,0),(6,6)] | + [(11,22),(33,44)] | [(10,-10),(-3,-4)] | (-1.3512195122,-4.76097560976) + [(11,22),(33,44)] | [(-1000000,200),(300000,-40)] | (10.9987783234,15.3825848409) + [(11,22),(33,44)] | [(11,22),(33,44)] | + [(11,22),(33,44)] | [(-10,2),(-10,3)] | (-10,3) + [(11,22),(33,44)] | [(0,-20),(30,-20)] | (11,-20) + [(11,22),(33,44)] | [(NaN,1),(NaN,90)] | + [(-10,2),(-10,3)] | [(1,2),(3,4)] | (1,2) + [(-10,2),(-10,3)] | [(0,0),(6,6)] | (0,0) + [(-10,2),(-10,3)] | [(10,-10),(-3,-4)] | (-3,-4) + [(-10,2),(-10,3)] | [(-1000000,200),(300000,-40)] | (-9.99771326872,15.3864611163) + [(-10,2),(-10,3)] | [(11,22),(33,44)] | (11,22) + [(-10,2),(-10,3)] | [(-10,2),(-10,3)] | + [(-10,2),(-10,3)] | [(0,-20),(30,-20)] | (0,-20) + [(-10,2),(-10,3)] | [(NaN,1),(NaN,90)] | + [(0,-20),(30,-20)] | [(1,2),(3,4)] | (1,2) + [(0,-20),(30,-20)] | [(0,0),(6,6)] | (0,0) + [(0,-20),(30,-20)] | [(10,-10),(-3,-4)] | (10,-10) + [(0,-20),(30,-20)] | [(-1000000,200),(300000,-40)] | (30.0065315217,15.3790757173) + [(0,-20),(30,-20)] | [(11,22),(33,44)] | (11,22) + [(0,-20),(30,-20)] | [(-10,2),(-10,3)] | (-10,2) + [(0,-20),(30,-20)] | [(0,-20),(30,-20)] | + [(0,-20),(30,-20)] | [(NaN,1),(NaN,90)] | + [(NaN,1),(NaN,90)] | [(1,2),(3,4)] | + [(NaN,1),(NaN,90)] | [(0,0),(6,6)] | + [(NaN,1),(NaN,90)] | [(10,-10),(-3,-4)] | + [(NaN,1),(NaN,90)] | [(-1000000,200),(300000,-40)] | + [(NaN,1),(NaN,90)] | [(11,22),(33,44)] | + [(NaN,1),(NaN,90)] | [(-10,2),(-10,3)] | + [(NaN,1),(NaN,90)] | [(0,-20),(30,-20)] | + [(NaN,1),(NaN,90)] | [(NaN,1),(NaN,90)] | +(64 rows) + +-- Closest point to box +SELECT l.s, b.f1, l.s ## b.f1 FROM LSEG_TBL l, BOX_TBL b; + s | f1 | ?column? +-------------------------------+---------------------+------------- + [(1,2),(3,4)] | (2,2),(0,0) | (1,2) + [(1,2),(3,4)] | (3,3),(1,1) | (1.5,2.5) + [(1,2),(3,4)] | (-2,2),(-8,-10) | (-2,2) + [(1,2),(3,4)] | (2.5,3.5),(2.5,2.5) | (2.25,3.25) + [(1,2),(3,4)] | (3,3),(3,3) | (3,3) + [(0,0),(6,6)] | (2,2),(0,0) | (1,1) + [(0,0),(6,6)] | (3,3),(1,1) | (2,2) + [(0,0),(6,6)] | (-2,2),(-8,-10) | (-2,0) + [(0,0),(6,6)] | (2.5,3.5),(2.5,2.5) | (2.75,2.75) + [(0,0),(6,6)] | (3,3),(3,3) | (3,3) + [(10,-10),(-3,-4)] | (2,2),(0,0) | (0,0) + [(10,-10),(-3,-4)] | (3,3),(1,1) | (1,1) + [(10,-10),(-3,-4)] | (-2,2),(-8,-10) | (-3,-4) + [(10,-10),(-3,-4)] | (2.5,3.5),(2.5,2.5) | (2.5,2.5) + [(10,-10),(-3,-4)] | (3,3),(3,3) | (3,3) + [(-1000000,200),(300000,-40)] | (2,2),(0,0) | (2,2) + [(-1000000,200),(300000,-40)] | (3,3),(1,1) | (3,3) + [(-1000000,200),(300000,-40)] | (-2,2),(-8,-10) | (-2,2) + [(-1000000,200),(300000,-40)] | (2.5,3.5),(2.5,2.5) | (2.5,3.5) + [(-1000000,200),(300000,-40)] | (3,3),(3,3) | (3,3) + [(11,22),(33,44)] | (2,2),(0,0) | (2,2) + [(11,22),(33,44)] | (3,3),(1,1) | (3,3) + [(11,22),(33,44)] | (-2,2),(-8,-10) | (-2,2) + [(11,22),(33,44)] | (2.5,3.5),(2.5,2.5) | (2.5,3.5) + [(11,22),(33,44)] | (3,3),(3,3) | (3,3) + [(-10,2),(-10,3)] | (2,2),(0,0) | (0,2) + [(-10,2),(-10,3)] | (3,3),(1,1) | (1,2) + [(-10,2),(-10,3)] | (-2,2),(-8,-10) | (-8,2) + [(-10,2),(-10,3)] | (2.5,3.5),(2.5,2.5) | (2.5,3) + [(-10,2),(-10,3)] | (3,3),(3,3) | (3,3) + [(0,-20),(30,-20)] | (2,2),(0,0) | (0,0) + [(0,-20),(30,-20)] | (3,3),(1,1) | (1,1) + [(0,-20),(30,-20)] | (-2,2),(-8,-10) | (-2,-10) + [(0,-20),(30,-20)] | (2.5,3.5),(2.5,2.5) | (2.5,2.5) + [(0,-20),(30,-20)] | (3,3),(3,3) | (3,3) + [(NaN,1),(NaN,90)] | (2,2),(0,0) | + [(NaN,1),(NaN,90)] | (3,3),(1,1) | + [(NaN,1),(NaN,90)] | (-2,2),(-8,-10) | + [(NaN,1),(NaN,90)] | (2.5,3.5),(2.5,2.5) | + [(NaN,1),(NaN,90)] | (3,3),(3,3) | +(40 rows) + +-- On line +SELECT l.s, l1.s FROM LSEG_TBL l, LINE_TBL l1 WHERE l.s <@ l1.s; + s | s +-------------------------------+--------------------------------------- + [(0,0),(6,6)] | {1,-1,0} + [(-1000000,200),(300000,-40)] | {-0.000184615384615,-1,15.3846153846} +(2 rows) + +-- On box +SELECT l.s, b.f1 FROM LSEG_TBL l, BOX_TBL b WHERE l.s <@ b.f1; + s | f1 +---+---- +(0 rows) + +-- +-- Boxes +-- +SELECT '' as six, box(f1) AS box FROM CIRCLE_TBL; + six | box +-----+---------------------------------------------------------------- + | (7.12132034356,3.12132034356),(2.87867965644,-1.12132034356) + | (71.7106781187,72.7106781187),(-69.7106781187,-68.7106781187) + | (4.53553390593,6.53553390593),(-2.53553390593,-0.535533905933) + | (3.12132034356,4.12132034356),(-1.12132034356,-0.12132034356) + | (107.071067812,207.071067812),(92.9289321881,192.928932188) + | (181.317279836,82.3172798365),(18.6827201635,-80.3172798365) + | (3,5),(3,5) + | (NaN,NaN),(NaN,NaN) +(8 rows) + +-- translation +SELECT '' AS twentyfour, b.f1 + p.f1 AS translation + FROM BOX_TBL b, POINT_TBL p; + twentyfour | translation +------------+------------------------------------- + | (2,2),(0,0) + | (3,3),(1,1) + | (-2,2),(-8,-10) + | (2.5,3.5),(2.5,2.5) + | (3,3),(3,3) + | (-8,2),(-10,0) + | (-7,3),(-9,1) + | (-12,2),(-18,-10) + | (-7.5,3.5),(-7.5,2.5) + | (-7,3),(-7,3) + | (-1,6),(-3,4) + | (0,7),(-2,5) + | (-5,6),(-11,-6) + | (-0.5,7.5),(-0.5,6.5) + | (0,7),(0,7) + | (7.1,36.5),(5.1,34.5) + | (8.1,37.5),(6.1,35.5) + | (3.1,36.5),(-2.9,24.5) + | (7.6,38),(7.6,37) + | (8.1,37.5),(8.1,37.5) + | (-3,-10),(-5,-12) + | (-2,-9),(-4,-11) + | (-7,-10),(-13,-22) + | (-2.5,-8.5),(-2.5,-9.5) + | (-2,-9),(-2,-9) + | (2,2),(1e-300,-1e-300) + | (3,3),(1,1) + | (-2,2),(-8,-10) + | (2.5,3.5),(2.5,2.5) + | (3,3),(3,3) + | (1e+300,Infinity),(1e+300,Infinity) + | (1e+300,Infinity),(1e+300,Infinity) + | (1e+300,Infinity),(1e+300,Infinity) + | (1e+300,Infinity),(1e+300,Infinity) + | (1e+300,Infinity),(1e+300,Infinity) + | (NaN,NaN),(NaN,NaN) + | (NaN,NaN),(NaN,NaN) + | (NaN,NaN),(NaN,NaN) + | (NaN,NaN),(NaN,NaN) + | (NaN,NaN),(NaN,NaN) + | (12,12),(10,10) + | (13,13),(11,11) + | (8,12),(2,0) + | (12.5,13.5),(12.5,12.5) + | (13,13),(13,13) +(45 rows) + +SELECT '' AS twentyfour, b.f1 - p.f1 AS translation + FROM BOX_TBL b, POINT_TBL p; + twentyfour | translation +------------+----------------------------------------- + | (2,2),(0,0) + | (3,3),(1,1) + | (-2,2),(-8,-10) + | (2.5,3.5),(2.5,2.5) + | (3,3),(3,3) + | (12,2),(10,0) + | (13,3),(11,1) + | (8,2),(2,-10) + | (12.5,3.5),(12.5,2.5) + | (13,3),(13,3) + | (5,-2),(3,-4) + | (6,-1),(4,-3) + | (1,-2),(-5,-14) + | (5.5,-0.5),(5.5,-1.5) + | (6,-1),(6,-1) + | (-3.1,-32.5),(-5.1,-34.5) + | (-2.1,-31.5),(-4.1,-33.5) + | (-7.1,-32.5),(-13.1,-44.5) + | (-2.6,-31),(-2.6,-32) + | (-2.1,-31.5),(-2.1,-31.5) + | (7,14),(5,12) + | (8,15),(6,13) + | (3,14),(-3,2) + | (7.5,15.5),(7.5,14.5) + | (8,15),(8,15) + | (2,2),(-1e-300,1e-300) + | (3,3),(1,1) + | (-2,2),(-8,-10) + | (2.5,3.5),(2.5,2.5) + | (3,3),(3,3) + | (-1e+300,-Infinity),(-1e+300,-Infinity) + | (-1e+300,-Infinity),(-1e+300,-Infinity) + | (-1e+300,-Infinity),(-1e+300,-Infinity) + | (-1e+300,-Infinity),(-1e+300,-Infinity) + | (-1e+300,-Infinity),(-1e+300,-Infinity) + | (NaN,NaN),(NaN,NaN) + | (NaN,NaN),(NaN,NaN) + | (NaN,NaN),(NaN,NaN) + | (NaN,NaN),(NaN,NaN) + | (NaN,NaN),(NaN,NaN) + | (-8,-8),(-10,-10) + | (-7,-7),(-9,-9) + | (-12,-8),(-18,-20) + | (-7.5,-6.5),(-7.5,-7.5) + | (-7,-7),(-7,-7) +(45 rows) + +-- Multiply with point +SELECT b.f1, p.f1, b.f1 * p.f1 FROM BOX_TBL b, POINT_TBL p WHERE p.f1[0] BETWEEN 1 AND 1000; + f1 | f1 | ?column? +---------------------+------------+----------------------------- + (2,2),(0,0) | (5.1,34.5) | (0,79.2),(-58.8,0) + (2,2),(0,0) | (10,10) | (0,40),(0,0) + (3,3),(1,1) | (5.1,34.5) | (-29.4,118.8),(-88.2,39.6) + (3,3),(1,1) | (10,10) | (0,60),(0,20) + (-2,2),(-8,-10) | (5.1,34.5) | (304.2,-58.8),(-79.2,-327) + (-2,2),(-8,-10) | (10,10) | (20,0),(-40,-180) + (2.5,3.5),(2.5,2.5) | (5.1,34.5) | (-73.5,104.1),(-108,99) + (2.5,3.5),(2.5,2.5) | (10,10) | (0,60),(-10,50) + (3,3),(3,3) | (5.1,34.5) | (-88.2,118.8),(-88.2,118.8) + (3,3),(3,3) | (10,10) | (0,60),(0,60) +(10 rows) + +-- Overflow error +SELECT b.f1, p.f1, b.f1 * p.f1 FROM BOX_TBL b, POINT_TBL p WHERE p.f1[0] > 1000; + f1 | f1 | ?column? +---------------------+-------------------+-------------------------------------------- + (2,2),(0,0) | (1e+300,Infinity) | (NaN,NaN),(-Infinity,Infinity) + (2,2),(0,0) | (NaN,NaN) | (NaN,NaN),(NaN,NaN) + (3,3),(1,1) | (1e+300,Infinity) | (-Infinity,Infinity),(-Infinity,Infinity) + (3,3),(1,1) | (NaN,NaN) | (NaN,NaN),(NaN,NaN) + (-2,2),(-8,-10) | (1e+300,Infinity) | (Infinity,-Infinity),(-Infinity,-Infinity) + (-2,2),(-8,-10) | (NaN,NaN) | (NaN,NaN),(NaN,NaN) + (2.5,3.5),(2.5,2.5) | (1e+300,Infinity) | (-Infinity,Infinity),(-Infinity,Infinity) + (2.5,3.5),(2.5,2.5) | (NaN,NaN) | (NaN,NaN),(NaN,NaN) + (3,3),(3,3) | (1e+300,Infinity) | (-Infinity,Infinity),(-Infinity,Infinity) + (3,3),(3,3) | (NaN,NaN) | (NaN,NaN),(NaN,NaN) +(10 rows) + +-- Divide by point +SELECT b.f1, p.f1, b.f1 / p.f1 FROM BOX_TBL b, POINT_TBL p WHERE p.f1[0] BETWEEN 1 AND 1000; + f1 | f1 | ?column? +---------------------+------------+---------------------------------------------------------------------- + (2,2),(0,0) | (5.1,34.5) | (0.0651176557644,0),(0,-0.0483449262493) + (2,2),(0,0) | (10,10) | (0.2,0),(0,0) + (3,3),(1,1) | (5.1,34.5) | (0.0976764836466,-0.0241724631247),(0.0325588278822,-0.072517389374) + (3,3),(1,1) | (10,10) | (0.3,0),(0.1,0) + (-2,2),(-8,-10) | (5.1,34.5) | (0.0483449262493,0.18499334024),(-0.317201914064,0.0651176557644) + (-2,2),(-8,-10) | (10,10) | (0,0.2),(-0.9,-0.1) + (2.5,3.5),(2.5,2.5) | (5.1,34.5) | (0.109762715209,-0.0562379754329),(0.0813970697055,-0.0604311578117) + (2.5,3.5),(2.5,2.5) | (10,10) | (0.3,0.05),(0.25,0) + (3,3),(3,3) | (5.1,34.5) | (0.0976764836466,-0.072517389374),(0.0976764836466,-0.072517389374) + (3,3),(3,3) | (10,10) | (0.3,0),(0.3,0) +(10 rows) + +-- To box +SELECT f1::box + FROM POINT_TBL; + f1 +------------------------------------- + (0,0),(0,0) + (-10,0),(-10,0) + (-3,4),(-3,4) + (5.1,34.5),(5.1,34.5) + (-5,-12),(-5,-12) + (1e-300,-1e-300),(1e-300,-1e-300) + (1e+300,Infinity),(1e+300,Infinity) + (NaN,NaN),(NaN,NaN) + (10,10),(10,10) +(9 rows) + +SELECT bound_box(a.f1, b.f1) + FROM BOX_TBL a, BOX_TBL b; + bound_box +--------------------- + (2,2),(0,0) + (3,3),(0,0) + (2,2),(-8,-10) + (2.5,3.5),(0,0) + (3,3),(0,0) + (3,3),(0,0) + (3,3),(1,1) + (3,3),(-8,-10) + (3,3.5),(1,1) + (3,3),(1,1) + (2,2),(-8,-10) + (3,3),(-8,-10) + (-2,2),(-8,-10) + (2.5,3.5),(-8,-10) + (3,3),(-8,-10) + (2.5,3.5),(0,0) + (3,3.5),(1,1) + (2.5,3.5),(-8,-10) + (2.5,3.5),(2.5,2.5) + (3,3.5),(2.5,2.5) + (3,3),(0,0) + (3,3),(1,1) + (3,3),(-8,-10) + (3,3.5),(2.5,2.5) + (3,3),(3,3) +(25 rows) + +-- Below box +SELECT b1.f1, b2.f1, b1.f1 <^ b2.f1 FROM BOX_TBL b1, BOX_TBL b2; + f1 | f1 | ?column? +---------------------+---------------------+---------- + (2,2),(0,0) | (2,2),(0,0) | f + (2,2),(0,0) | (3,3),(1,1) | f + (2,2),(0,0) | (-2,2),(-8,-10) | f + (2,2),(0,0) | (2.5,3.5),(2.5,2.5) | t + (2,2),(0,0) | (3,3),(3,3) | t + (3,3),(1,1) | (2,2),(0,0) | f + (3,3),(1,1) | (3,3),(1,1) | f + (3,3),(1,1) | (-2,2),(-8,-10) | f + (3,3),(1,1) | (2.5,3.5),(2.5,2.5) | f + (3,3),(1,1) | (3,3),(3,3) | t + (-2,2),(-8,-10) | (2,2),(0,0) | f + (-2,2),(-8,-10) | (3,3),(1,1) | f + (-2,2),(-8,-10) | (-2,2),(-8,-10) | f + (-2,2),(-8,-10) | (2.5,3.5),(2.5,2.5) | t + (-2,2),(-8,-10) | (3,3),(3,3) | t + (2.5,3.5),(2.5,2.5) | (2,2),(0,0) | f + (2.5,3.5),(2.5,2.5) | (3,3),(1,1) | f + (2.5,3.5),(2.5,2.5) | (-2,2),(-8,-10) | f + (2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5) | f + (2.5,3.5),(2.5,2.5) | (3,3),(3,3) | f + (3,3),(3,3) | (2,2),(0,0) | f + (3,3),(3,3) | (3,3),(1,1) | f + (3,3),(3,3) | (-2,2),(-8,-10) | f + (3,3),(3,3) | (2.5,3.5),(2.5,2.5) | f + (3,3),(3,3) | (3,3),(3,3) | t +(25 rows) + +-- Above box +SELECT b1.f1, b2.f1, b1.f1 >^ b2.f1 FROM BOX_TBL b1, BOX_TBL b2; + f1 | f1 | ?column? +---------------------+---------------------+---------- + (2,2),(0,0) | (2,2),(0,0) | f + (2,2),(0,0) | (3,3),(1,1) | f + (2,2),(0,0) | (-2,2),(-8,-10) | f + (2,2),(0,0) | (2.5,3.5),(2.5,2.5) | f + (2,2),(0,0) | (3,3),(3,3) | f + (3,3),(1,1) | (2,2),(0,0) | f + (3,3),(1,1) | (3,3),(1,1) | f + (3,3),(1,1) | (-2,2),(-8,-10) | f + (3,3),(1,1) | (2.5,3.5),(2.5,2.5) | f + (3,3),(1,1) | (3,3),(3,3) | f + (-2,2),(-8,-10) | (2,2),(0,0) | f + (-2,2),(-8,-10) | (3,3),(1,1) | f + (-2,2),(-8,-10) | (-2,2),(-8,-10) | f + (-2,2),(-8,-10) | (2.5,3.5),(2.5,2.5) | f + (-2,2),(-8,-10) | (3,3),(3,3) | f + (2.5,3.5),(2.5,2.5) | (2,2),(0,0) | t + (2.5,3.5),(2.5,2.5) | (3,3),(1,1) | f + (2.5,3.5),(2.5,2.5) | (-2,2),(-8,-10) | t + (2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5) | f + (2.5,3.5),(2.5,2.5) | (3,3),(3,3) | f + (3,3),(3,3) | (2,2),(0,0) | t + (3,3),(3,3) | (3,3),(1,1) | t + (3,3),(3,3) | (-2,2),(-8,-10) | t + (3,3),(3,3) | (2.5,3.5),(2.5,2.5) | f + (3,3),(3,3) | (3,3),(3,3) | t +(25 rows) + +-- Intersection point with box +SELECT b1.f1, b2.f1, b1.f1 # b2.f1 FROM BOX_TBL b1, BOX_TBL b2; + f1 | f1 | ?column? +---------------------+---------------------+--------------------- + (2,2),(0,0) | (2,2),(0,0) | (2,2),(0,0) + (2,2),(0,0) | (3,3),(1,1) | (2,2),(1,1) + (2,2),(0,0) | (-2,2),(-8,-10) | + (2,2),(0,0) | (2.5,3.5),(2.5,2.5) | + (2,2),(0,0) | (3,3),(3,3) | + (3,3),(1,1) | (2,2),(0,0) | (2,2),(1,1) + (3,3),(1,1) | (3,3),(1,1) | (3,3),(1,1) + (3,3),(1,1) | (-2,2),(-8,-10) | + (3,3),(1,1) | (2.5,3.5),(2.5,2.5) | (2.5,3),(2.5,2.5) + (3,3),(1,1) | (3,3),(3,3) | (3,3),(3,3) + (-2,2),(-8,-10) | (2,2),(0,0) | + (-2,2),(-8,-10) | (3,3),(1,1) | + (-2,2),(-8,-10) | (-2,2),(-8,-10) | (-2,2),(-8,-10) + (-2,2),(-8,-10) | (2.5,3.5),(2.5,2.5) | + (-2,2),(-8,-10) | (3,3),(3,3) | + (2.5,3.5),(2.5,2.5) | (2,2),(0,0) | + (2.5,3.5),(2.5,2.5) | (3,3),(1,1) | (2.5,3),(2.5,2.5) + (2.5,3.5),(2.5,2.5) | (-2,2),(-8,-10) | + (2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5) + (2.5,3.5),(2.5,2.5) | (3,3),(3,3) | + (3,3),(3,3) | (2,2),(0,0) | + (3,3),(3,3) | (3,3),(1,1) | (3,3),(3,3) + (3,3),(3,3) | (-2,2),(-8,-10) | + (3,3),(3,3) | (2.5,3.5),(2.5,2.5) | + (3,3),(3,3) | (3,3),(3,3) | (3,3),(3,3) +(25 rows) + +-- Diagonal +SELECT f1, diagonal(f1) FROM BOX_TBL; + f1 | diagonal +---------------------+----------------------- + (2,2),(0,0) | [(2,2),(0,0)] + (3,3),(1,1) | [(3,3),(1,1)] + (-2,2),(-8,-10) | [(-2,2),(-8,-10)] + (2.5,3.5),(2.5,2.5) | [(2.5,3.5),(2.5,2.5)] + (3,3),(3,3) | [(3,3),(3,3)] +(5 rows) + +-- Distance to box +SELECT b1.f1, b2.f1, b1.f1 <-> b2.f1 FROM BOX_TBL b1, BOX_TBL b2; + f1 | f1 | ?column? +---------------------+---------------------+--------------- + (2,2),(0,0) | (2,2),(0,0) | 0 + (2,2),(0,0) | (3,3),(1,1) | 1.41421356237 + (2,2),(0,0) | (-2,2),(-8,-10) | 7.81024967591 + (2,2),(0,0) | (2.5,3.5),(2.5,2.5) | 2.5 + (2,2),(0,0) | (3,3),(3,3) | 2.82842712475 + (3,3),(1,1) | (2,2),(0,0) | 1.41421356237 + (3,3),(1,1) | (3,3),(1,1) | 0 + (3,3),(1,1) | (-2,2),(-8,-10) | 9.21954445729 + (3,3),(1,1) | (2.5,3.5),(2.5,2.5) | 1.11803398875 + (3,3),(1,1) | (3,3),(3,3) | 1.41421356237 + (-2,2),(-8,-10) | (2,2),(0,0) | 7.81024967591 + (-2,2),(-8,-10) | (3,3),(1,1) | 9.21954445729 + (-2,2),(-8,-10) | (-2,2),(-8,-10) | 0 + (-2,2),(-8,-10) | (2.5,3.5),(2.5,2.5) | 10.2591422643 + (-2,2),(-8,-10) | (3,3),(3,3) | 10.6301458127 + (2.5,3.5),(2.5,2.5) | (2,2),(0,0) | 2.5 + (2.5,3.5),(2.5,2.5) | (3,3),(1,1) | 1.11803398875 + (2.5,3.5),(2.5,2.5) | (-2,2),(-8,-10) | 10.2591422643 + (2.5,3.5),(2.5,2.5) | (2.5,3.5),(2.5,2.5) | 0 + (2.5,3.5),(2.5,2.5) | (3,3),(3,3) | 0.5 + (3,3),(3,3) | (2,2),(0,0) | 2.82842712475 + (3,3),(3,3) | (3,3),(1,1) | 1.41421356237 + (3,3),(3,3) | (-2,2),(-8,-10) | 10.6301458127 + (3,3),(3,3) | (2.5,3.5),(2.5,2.5) | 0.5 + (3,3),(3,3) | (3,3),(3,3) | 0 +(25 rows) + +-- +-- Paths +-- +-- Points +SELECT f1, npoints(f1) FROM PATH_TBL; + f1 | npoints +---------------------------+--------- + [(1,2),(3,4)] | 2 + ((1,2),(3,4)) | 2 + [(0,0),(3,0),(4,5),(1,6)] | 4 + ((1,2),(3,4)) | 2 + ((1,2),(3,4)) | 2 + [(1,2),(3,4)] | 2 + ((10,20)) | 1 + [(11,12),(13,14)] | 2 + ((11,12),(13,14)) | 2 +(9 rows) + +-- Area +SELECT f1, area(f1) FROM PATH_TBL; + f1 | area +---------------------------+------ + [(1,2),(3,4)] | + ((1,2),(3,4)) | 0 + [(0,0),(3,0),(4,5),(1,6)] | + ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | 0 + [(1,2),(3,4)] | + ((10,20)) | 0 + [(11,12),(13,14)] | + ((11,12),(13,14)) | 0 +(9 rows) + +-- Length +SELECT f1, @-@ f1 FROM PATH_TBL; + f1 | ?column? +---------------------------+--------------- + [(1,2),(3,4)] | 2.82842712475 + ((1,2),(3,4)) | 5.65685424949 + [(0,0),(3,0),(4,5),(1,6)] | 11.2612971738 + ((1,2),(3,4)) | 5.65685424949 + ((1,2),(3,4)) | 5.65685424949 + [(1,2),(3,4)] | 2.82842712475 + ((10,20)) | 0 + [(11,12),(13,14)] | 2.82842712475 + ((11,12),(13,14)) | 5.65685424949 +(9 rows) + +-- Center +SELECT f1, @@ f1 FROM PATH_TBL; +ERROR: function "path_center" not implemented +-- To polygon +SELECT f1, f1::polygon FROM PATH_TBL WHERE isclosed(f1); + f1 | f1 +-------------------+------------------- + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((10,20)) | ((10,20)) + ((11,12),(13,14)) | ((11,12),(13,14)) +(5 rows) + +-- Open path cannot be converted to polygon error +SELECT f1, f1::polygon FROM PATH_TBL WHERE isopen(f1); +ERROR: open path cannot be converted to polygon +-- Has points less than path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 < p2.f1; + f1 | f1 +-------------------+--------------------------- + [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] + [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6)] + ((10,20)) | [(1,2),(3,4)] + ((10,20)) | ((1,2),(3,4)) + ((10,20)) | [(0,0),(3,0),(4,5),(1,6)] + ((10,20)) | ((1,2),(3,4)) + ((10,20)) | ((1,2),(3,4)) + ((10,20)) | [(1,2),(3,4)] + ((10,20)) | [(11,12),(13,14)] + ((10,20)) | ((11,12),(13,14)) + [(11,12),(13,14)] | [(0,0),(3,0),(4,5),(1,6)] + ((11,12),(13,14)) | [(0,0),(3,0),(4,5),(1,6)] +(15 rows) + +-- Has points less than or equal to path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 <= p2.f1; + f1 | f1 +---------------------------+--------------------------- + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6)] + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | [(11,12),(13,14)] + [(1,2),(3,4)] | ((11,12),(13,14)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | [(11,12),(13,14)] + ((1,2),(3,4)) | ((11,12),(13,14)) + [(0,0),(3,0),(4,5),(1,6)] | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | [(11,12),(13,14)] + ((1,2),(3,4)) | ((11,12),(13,14)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | [(11,12),(13,14)] + ((1,2),(3,4)) | ((11,12),(13,14)) + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6)] + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | [(11,12),(13,14)] + [(1,2),(3,4)] | ((11,12),(13,14)) + ((10,20)) | [(1,2),(3,4)] + ((10,20)) | ((1,2),(3,4)) + ((10,20)) | [(0,0),(3,0),(4,5),(1,6)] + ((10,20)) | ((1,2),(3,4)) + ((10,20)) | ((1,2),(3,4)) + ((10,20)) | [(1,2),(3,4)] + ((10,20)) | ((10,20)) + ((10,20)) | [(11,12),(13,14)] + ((10,20)) | ((11,12),(13,14)) + [(11,12),(13,14)] | [(1,2),(3,4)] + [(11,12),(13,14)] | ((1,2),(3,4)) + [(11,12),(13,14)] | [(0,0),(3,0),(4,5),(1,6)] + [(11,12),(13,14)] | ((1,2),(3,4)) + [(11,12),(13,14)] | ((1,2),(3,4)) + [(11,12),(13,14)] | [(1,2),(3,4)] + [(11,12),(13,14)] | [(11,12),(13,14)] + [(11,12),(13,14)] | ((11,12),(13,14)) + ((11,12),(13,14)) | [(1,2),(3,4)] + ((11,12),(13,14)) | ((1,2),(3,4)) + ((11,12),(13,14)) | [(0,0),(3,0),(4,5),(1,6)] + ((11,12),(13,14)) | ((1,2),(3,4)) + ((11,12),(13,14)) | ((1,2),(3,4)) + ((11,12),(13,14)) | [(1,2),(3,4)] + ((11,12),(13,14)) | [(11,12),(13,14)] + ((11,12),(13,14)) | ((11,12),(13,14)) +(66 rows) + +-- Has points equal to path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 = p2.f1; + f1 | f1 +---------------------------+--------------------------- + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | [(11,12),(13,14)] + [(1,2),(3,4)] | ((11,12),(13,14)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | [(11,12),(13,14)] + ((1,2),(3,4)) | ((11,12),(13,14)) + [(0,0),(3,0),(4,5),(1,6)] | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | [(11,12),(13,14)] + ((1,2),(3,4)) | ((11,12),(13,14)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | [(11,12),(13,14)] + ((1,2),(3,4)) | ((11,12),(13,14)) + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | [(11,12),(13,14)] + [(1,2),(3,4)] | ((11,12),(13,14)) + ((10,20)) | ((10,20)) + [(11,12),(13,14)] | [(1,2),(3,4)] + [(11,12),(13,14)] | ((1,2),(3,4)) + [(11,12),(13,14)] | ((1,2),(3,4)) + [(11,12),(13,14)] | ((1,2),(3,4)) + [(11,12),(13,14)] | [(1,2),(3,4)] + [(11,12),(13,14)] | [(11,12),(13,14)] + [(11,12),(13,14)] | ((11,12),(13,14)) + ((11,12),(13,14)) | [(1,2),(3,4)] + ((11,12),(13,14)) | ((1,2),(3,4)) + ((11,12),(13,14)) | ((1,2),(3,4)) + ((11,12),(13,14)) | ((1,2),(3,4)) + ((11,12),(13,14)) | [(1,2),(3,4)] + ((11,12),(13,14)) | [(11,12),(13,14)] + ((11,12),(13,14)) | ((11,12),(13,14)) +(51 rows) + +-- Has points greater than or equal to path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 >= p2.f1; + f1 | f1 +---------------------------+--------------------------- + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | ((10,20)) + [(1,2),(3,4)] | [(11,12),(13,14)] + [(1,2),(3,4)] | ((11,12),(13,14)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((10,20)) + ((1,2),(3,4)) | [(11,12),(13,14)] + ((1,2),(3,4)) | ((11,12),(13,14)) + [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4)] + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | [(0,0),(3,0),(4,5),(1,6)] + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4)] + [(0,0),(3,0),(4,5),(1,6)] | ((10,20)) + [(0,0),(3,0),(4,5),(1,6)] | [(11,12),(13,14)] + [(0,0),(3,0),(4,5),(1,6)] | ((11,12),(13,14)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((10,20)) + ((1,2),(3,4)) | [(11,12),(13,14)] + ((1,2),(3,4)) | ((11,12),(13,14)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | ((1,2),(3,4)) + ((1,2),(3,4)) | [(1,2),(3,4)] + ((1,2),(3,4)) | ((10,20)) + ((1,2),(3,4)) | [(11,12),(13,14)] + ((1,2),(3,4)) | ((11,12),(13,14)) + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | ((1,2),(3,4)) + [(1,2),(3,4)] | [(1,2),(3,4)] + [(1,2),(3,4)] | ((10,20)) + [(1,2),(3,4)] | [(11,12),(13,14)] + [(1,2),(3,4)] | ((11,12),(13,14)) + ((10,20)) | ((10,20)) + [(11,12),(13,14)] | [(1,2),(3,4)] + [(11,12),(13,14)] | ((1,2),(3,4)) + [(11,12),(13,14)] | ((1,2),(3,4)) + [(11,12),(13,14)] | ((1,2),(3,4)) + [(11,12),(13,14)] | [(1,2),(3,4)] + [(11,12),(13,14)] | ((10,20)) + [(11,12),(13,14)] | [(11,12),(13,14)] + [(11,12),(13,14)] | ((11,12),(13,14)) + ((11,12),(13,14)) | [(1,2),(3,4)] + ((11,12),(13,14)) | ((1,2),(3,4)) + ((11,12),(13,14)) | ((1,2),(3,4)) + ((11,12),(13,14)) | ((1,2),(3,4)) + ((11,12),(13,14)) | [(1,2),(3,4)] + ((11,12),(13,14)) | ((10,20)) + ((11,12),(13,14)) | [(11,12),(13,14)] + ((11,12),(13,14)) | ((11,12),(13,14)) +(66 rows) + +-- Has points greater than path +SELECT p1.f1, p2.f1 FROM PATH_TBL p1, PATH_TBL p2 WHERE p1.f1 > p2.f1; + f1 | f1 +---------------------------+------------------- + [(1,2),(3,4)] | ((10,20)) + ((1,2),(3,4)) | ((10,20)) + [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4)] + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4)] + [(0,0),(3,0),(4,5),(1,6)] | ((10,20)) + [(0,0),(3,0),(4,5),(1,6)] | [(11,12),(13,14)] + [(0,0),(3,0),(4,5),(1,6)] | ((11,12),(13,14)) + ((1,2),(3,4)) | ((10,20)) + ((1,2),(3,4)) | ((10,20)) + [(1,2),(3,4)] | ((10,20)) + [(11,12),(13,14)] | ((10,20)) + ((11,12),(13,14)) | ((10,20)) +(15 rows) + +-- Add path +SELECT p1.f1, p2.f1, p1.f1 + p2.f1 FROM PATH_TBL p1, PATH_TBL p2; + f1 | f1 | ?column? +---------------------------+---------------------------+--------------------------------------------------- + [(1,2),(3,4)] | [(1,2),(3,4)] | [(1,2),(3,4),(1,2),(3,4)] + [(1,2),(3,4)] | ((1,2),(3,4)) | + [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4),(0,0),(3,0),(4,5),(1,6)] + [(1,2),(3,4)] | ((1,2),(3,4)) | + [(1,2),(3,4)] | ((1,2),(3,4)) | + [(1,2),(3,4)] | [(1,2),(3,4)] | [(1,2),(3,4),(1,2),(3,4)] + [(1,2),(3,4)] | ((10,20)) | + [(1,2),(3,4)] | [(11,12),(13,14)] | [(1,2),(3,4),(11,12),(13,14)] + [(1,2),(3,4)] | ((11,12),(13,14)) | + ((1,2),(3,4)) | [(1,2),(3,4)] | + ((1,2),(3,4)) | ((1,2),(3,4)) | + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] | + ((1,2),(3,4)) | ((1,2),(3,4)) | + ((1,2),(3,4)) | ((1,2),(3,4)) | + ((1,2),(3,4)) | [(1,2),(3,4)] | + ((1,2),(3,4)) | ((10,20)) | + ((1,2),(3,4)) | [(11,12),(13,14)] | + ((1,2),(3,4)) | ((11,12),(13,14)) | + [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6),(1,2),(3,4)] + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) | + [(0,0),(3,0),(4,5),(1,6)] | [(0,0),(3,0),(4,5),(1,6)] | [(0,0),(3,0),(4,5),(1,6),(0,0),(3,0),(4,5),(1,6)] + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) | + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) | + [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6),(1,2),(3,4)] + [(0,0),(3,0),(4,5),(1,6)] | ((10,20)) | + [(0,0),(3,0),(4,5),(1,6)] | [(11,12),(13,14)] | [(0,0),(3,0),(4,5),(1,6),(11,12),(13,14)] + [(0,0),(3,0),(4,5),(1,6)] | ((11,12),(13,14)) | + ((1,2),(3,4)) | [(1,2),(3,4)] | + ((1,2),(3,4)) | ((1,2),(3,4)) | + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] | + ((1,2),(3,4)) | ((1,2),(3,4)) | + ((1,2),(3,4)) | ((1,2),(3,4)) | + ((1,2),(3,4)) | [(1,2),(3,4)] | + ((1,2),(3,4)) | ((10,20)) | + ((1,2),(3,4)) | [(11,12),(13,14)] | + ((1,2),(3,4)) | ((11,12),(13,14)) | + ((1,2),(3,4)) | [(1,2),(3,4)] | + ((1,2),(3,4)) | ((1,2),(3,4)) | + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] | + ((1,2),(3,4)) | ((1,2),(3,4)) | + ((1,2),(3,4)) | ((1,2),(3,4)) | + ((1,2),(3,4)) | [(1,2),(3,4)] | + ((1,2),(3,4)) | ((10,20)) | + ((1,2),(3,4)) | [(11,12),(13,14)] | + ((1,2),(3,4)) | ((11,12),(13,14)) | + [(1,2),(3,4)] | [(1,2),(3,4)] | [(1,2),(3,4),(1,2),(3,4)] + [(1,2),(3,4)] | ((1,2),(3,4)) | + [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4),(0,0),(3,0),(4,5),(1,6)] + [(1,2),(3,4)] | ((1,2),(3,4)) | + [(1,2),(3,4)] | ((1,2),(3,4)) | + [(1,2),(3,4)] | [(1,2),(3,4)] | [(1,2),(3,4),(1,2),(3,4)] + [(1,2),(3,4)] | ((10,20)) | + [(1,2),(3,4)] | [(11,12),(13,14)] | [(1,2),(3,4),(11,12),(13,14)] + [(1,2),(3,4)] | ((11,12),(13,14)) | + ((10,20)) | [(1,2),(3,4)] | + ((10,20)) | ((1,2),(3,4)) | + ((10,20)) | [(0,0),(3,0),(4,5),(1,6)] | + ((10,20)) | ((1,2),(3,4)) | + ((10,20)) | ((1,2),(3,4)) | + ((10,20)) | [(1,2),(3,4)] | + ((10,20)) | ((10,20)) | + ((10,20)) | [(11,12),(13,14)] | + ((10,20)) | ((11,12),(13,14)) | + [(11,12),(13,14)] | [(1,2),(3,4)] | [(11,12),(13,14),(1,2),(3,4)] + [(11,12),(13,14)] | ((1,2),(3,4)) | + [(11,12),(13,14)] | [(0,0),(3,0),(4,5),(1,6)] | [(11,12),(13,14),(0,0),(3,0),(4,5),(1,6)] + [(11,12),(13,14)] | ((1,2),(3,4)) | + [(11,12),(13,14)] | ((1,2),(3,4)) | + [(11,12),(13,14)] | [(1,2),(3,4)] | [(11,12),(13,14),(1,2),(3,4)] + [(11,12),(13,14)] | ((10,20)) | + [(11,12),(13,14)] | [(11,12),(13,14)] | [(11,12),(13,14),(11,12),(13,14)] + [(11,12),(13,14)] | ((11,12),(13,14)) | + ((11,12),(13,14)) | [(1,2),(3,4)] | + ((11,12),(13,14)) | ((1,2),(3,4)) | + ((11,12),(13,14)) | [(0,0),(3,0),(4,5),(1,6)] | + ((11,12),(13,14)) | ((1,2),(3,4)) | + ((11,12),(13,14)) | ((1,2),(3,4)) | + ((11,12),(13,14)) | [(1,2),(3,4)] | + ((11,12),(13,14)) | ((10,20)) | + ((11,12),(13,14)) | [(11,12),(13,14)] | + ((11,12),(13,14)) | ((11,12),(13,14)) | +(81 rows) + +-- Add point +SELECT p.f1, p1.f1, p.f1 + p1.f1 FROM PATH_TBL p, POINT_TBL p1; + f1 | f1 | ?column? +---------------------------+-------------------+--------------------------------------------------------------------------- + [(1,2),(3,4)] | (0,0) | [(1,2),(3,4)] + ((1,2),(3,4)) | (0,0) | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | (0,0) | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | (0,0) | ((1,2),(3,4)) + ((1,2),(3,4)) | (0,0) | ((1,2),(3,4)) + [(1,2),(3,4)] | (0,0) | [(1,2),(3,4)] + ((10,20)) | (0,0) | ((10,20)) + [(11,12),(13,14)] | (0,0) | [(11,12),(13,14)] + ((11,12),(13,14)) | (0,0) | ((11,12),(13,14)) + [(1,2),(3,4)] | (-10,0) | [(-9,2),(-7,4)] + ((1,2),(3,4)) | (-10,0) | ((-9,2),(-7,4)) + [(0,0),(3,0),(4,5),(1,6)] | (-10,0) | [(-10,0),(-7,0),(-6,5),(-9,6)] + ((1,2),(3,4)) | (-10,0) | ((-9,2),(-7,4)) + ((1,2),(3,4)) | (-10,0) | ((-9,2),(-7,4)) + [(1,2),(3,4)] | (-10,0) | [(-9,2),(-7,4)] + ((10,20)) | (-10,0) | ((0,20)) + [(11,12),(13,14)] | (-10,0) | [(1,12),(3,14)] + ((11,12),(13,14)) | (-10,0) | ((1,12),(3,14)) + [(1,2),(3,4)] | (-3,4) | [(-2,6),(0,8)] + ((1,2),(3,4)) | (-3,4) | ((-2,6),(0,8)) + [(0,0),(3,0),(4,5),(1,6)] | (-3,4) | [(-3,4),(0,4),(1,9),(-2,10)] + ((1,2),(3,4)) | (-3,4) | ((-2,6),(0,8)) + ((1,2),(3,4)) | (-3,4) | ((-2,6),(0,8)) + [(1,2),(3,4)] | (-3,4) | [(-2,6),(0,8)] + ((10,20)) | (-3,4) | ((7,24)) + [(11,12),(13,14)] | (-3,4) | [(8,16),(10,18)] + ((11,12),(13,14)) | (-3,4) | ((8,16),(10,18)) + [(1,2),(3,4)] | (5.1,34.5) | [(6.1,36.5),(8.1,38.5)] + ((1,2),(3,4)) | (5.1,34.5) | ((6.1,36.5),(8.1,38.5)) + [(0,0),(3,0),(4,5),(1,6)] | (5.1,34.5) | [(5.1,34.5),(8.1,34.5),(9.1,39.5),(6.1,40.5)] + ((1,2),(3,4)) | (5.1,34.5) | ((6.1,36.5),(8.1,38.5)) + ((1,2),(3,4)) | (5.1,34.5) | ((6.1,36.5),(8.1,38.5)) + [(1,2),(3,4)] | (5.1,34.5) | [(6.1,36.5),(8.1,38.5)] + ((10,20)) | (5.1,34.5) | ((15.1,54.5)) + [(11,12),(13,14)] | (5.1,34.5) | [(16.1,46.5),(18.1,48.5)] + ((11,12),(13,14)) | (5.1,34.5) | ((16.1,46.5),(18.1,48.5)) + [(1,2),(3,4)] | (-5,-12) | [(-4,-10),(-2,-8)] + ((1,2),(3,4)) | (-5,-12) | ((-4,-10),(-2,-8)) + [(0,0),(3,0),(4,5),(1,6)] | (-5,-12) | [(-5,-12),(-2,-12),(-1,-7),(-4,-6)] + ((1,2),(3,4)) | (-5,-12) | ((-4,-10),(-2,-8)) + ((1,2),(3,4)) | (-5,-12) | ((-4,-10),(-2,-8)) + [(1,2),(3,4)] | (-5,-12) | [(-4,-10),(-2,-8)] + ((10,20)) | (-5,-12) | ((5,8)) + [(11,12),(13,14)] | (-5,-12) | [(6,0),(8,2)] + ((11,12),(13,14)) | (-5,-12) | ((6,0),(8,2)) + [(1,2),(3,4)] | (1e-300,-1e-300) | [(1,2),(3,4)] + ((1,2),(3,4)) | (1e-300,-1e-300) | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | (1e-300,-1e-300) | [(1e-300,-1e-300),(3,-1e-300),(4,5),(1,6)] + ((1,2),(3,4)) | (1e-300,-1e-300) | ((1,2),(3,4)) + ((1,2),(3,4)) | (1e-300,-1e-300) | ((1,2),(3,4)) + [(1,2),(3,4)] | (1e-300,-1e-300) | [(1,2),(3,4)] + ((10,20)) | (1e-300,-1e-300) | ((10,20)) + [(11,12),(13,14)] | (1e-300,-1e-300) | [(11,12),(13,14)] + ((11,12),(13,14)) | (1e-300,-1e-300) | ((11,12),(13,14)) + [(1,2),(3,4)] | (1e+300,Infinity) | [(1e+300,Infinity),(1e+300,Infinity)] + ((1,2),(3,4)) | (1e+300,Infinity) | ((1e+300,Infinity),(1e+300,Infinity)) + [(0,0),(3,0),(4,5),(1,6)] | (1e+300,Infinity) | [(1e+300,Infinity),(1e+300,Infinity),(1e+300,Infinity),(1e+300,Infinity)] + ((1,2),(3,4)) | (1e+300,Infinity) | ((1e+300,Infinity),(1e+300,Infinity)) + ((1,2),(3,4)) | (1e+300,Infinity) | ((1e+300,Infinity),(1e+300,Infinity)) + [(1,2),(3,4)] | (1e+300,Infinity) | [(1e+300,Infinity),(1e+300,Infinity)] + ((10,20)) | (1e+300,Infinity) | ((1e+300,Infinity)) + [(11,12),(13,14)] | (1e+300,Infinity) | [(1e+300,Infinity),(1e+300,Infinity)] + ((11,12),(13,14)) | (1e+300,Infinity) | ((1e+300,Infinity),(1e+300,Infinity)) + [(1,2),(3,4)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN)] + ((1,2),(3,4)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + [(0,0),(3,0),(4,5),(1,6)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN),(NaN,NaN),(NaN,NaN)] + ((1,2),(3,4)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + ((1,2),(3,4)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + [(1,2),(3,4)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN)] + ((10,20)) | (NaN,NaN) | ((NaN,NaN)) + [(11,12),(13,14)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN)] + ((11,12),(13,14)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + [(1,2),(3,4)] | (10,10) | [(11,12),(13,14)] + ((1,2),(3,4)) | (10,10) | ((11,12),(13,14)) + [(0,0),(3,0),(4,5),(1,6)] | (10,10) | [(10,10),(13,10),(14,15),(11,16)] + ((1,2),(3,4)) | (10,10) | ((11,12),(13,14)) + ((1,2),(3,4)) | (10,10) | ((11,12),(13,14)) + [(1,2),(3,4)] | (10,10) | [(11,12),(13,14)] + ((10,20)) | (10,10) | ((20,30)) + [(11,12),(13,14)] | (10,10) | [(21,22),(23,24)] + ((11,12),(13,14)) | (10,10) | ((21,22),(23,24)) +(81 rows) + +-- Subtract point +SELECT p.f1, p1.f1, p.f1 - p1.f1 FROM PATH_TBL p, POINT_TBL p1; + f1 | f1 | ?column? +---------------------------+-------------------+----------------------------------------------------------------------------------- + [(1,2),(3,4)] | (0,0) | [(1,2),(3,4)] + ((1,2),(3,4)) | (0,0) | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | (0,0) | [(0,0),(3,0),(4,5),(1,6)] + ((1,2),(3,4)) | (0,0) | ((1,2),(3,4)) + ((1,2),(3,4)) | (0,0) | ((1,2),(3,4)) + [(1,2),(3,4)] | (0,0) | [(1,2),(3,4)] + ((10,20)) | (0,0) | ((10,20)) + [(11,12),(13,14)] | (0,0) | [(11,12),(13,14)] + ((11,12),(13,14)) | (0,0) | ((11,12),(13,14)) + [(1,2),(3,4)] | (-10,0) | [(11,2),(13,4)] + ((1,2),(3,4)) | (-10,0) | ((11,2),(13,4)) + [(0,0),(3,0),(4,5),(1,6)] | (-10,0) | [(10,0),(13,0),(14,5),(11,6)] + ((1,2),(3,4)) | (-10,0) | ((11,2),(13,4)) + ((1,2),(3,4)) | (-10,0) | ((11,2),(13,4)) + [(1,2),(3,4)] | (-10,0) | [(11,2),(13,4)] + ((10,20)) | (-10,0) | ((20,20)) + [(11,12),(13,14)] | (-10,0) | [(21,12),(23,14)] + ((11,12),(13,14)) | (-10,0) | ((21,12),(23,14)) + [(1,2),(3,4)] | (-3,4) | [(4,-2),(6,0)] + ((1,2),(3,4)) | (-3,4) | ((4,-2),(6,0)) + [(0,0),(3,0),(4,5),(1,6)] | (-3,4) | [(3,-4),(6,-4),(7,1),(4,2)] + ((1,2),(3,4)) | (-3,4) | ((4,-2),(6,0)) + ((1,2),(3,4)) | (-3,4) | ((4,-2),(6,0)) + [(1,2),(3,4)] | (-3,4) | [(4,-2),(6,0)] + ((10,20)) | (-3,4) | ((13,16)) + [(11,12),(13,14)] | (-3,4) | [(14,8),(16,10)] + ((11,12),(13,14)) | (-3,4) | ((14,8),(16,10)) + [(1,2),(3,4)] | (5.1,34.5) | [(-4.1,-32.5),(-2.1,-30.5)] + ((1,2),(3,4)) | (5.1,34.5) | ((-4.1,-32.5),(-2.1,-30.5)) + [(0,0),(3,0),(4,5),(1,6)] | (5.1,34.5) | [(-5.1,-34.5),(-2.1,-34.5),(-1.1,-29.5),(-4.1,-28.5)] + ((1,2),(3,4)) | (5.1,34.5) | ((-4.1,-32.5),(-2.1,-30.5)) + ((1,2),(3,4)) | (5.1,34.5) | ((-4.1,-32.5),(-2.1,-30.5)) + [(1,2),(3,4)] | (5.1,34.5) | [(-4.1,-32.5),(-2.1,-30.5)] + ((10,20)) | (5.1,34.5) | ((4.9,-14.5)) + [(11,12),(13,14)] | (5.1,34.5) | [(5.9,-22.5),(7.9,-20.5)] + ((11,12),(13,14)) | (5.1,34.5) | ((5.9,-22.5),(7.9,-20.5)) + [(1,2),(3,4)] | (-5,-12) | [(6,14),(8,16)] + ((1,2),(3,4)) | (-5,-12) | ((6,14),(8,16)) + [(0,0),(3,0),(4,5),(1,6)] | (-5,-12) | [(5,12),(8,12),(9,17),(6,18)] + ((1,2),(3,4)) | (-5,-12) | ((6,14),(8,16)) + ((1,2),(3,4)) | (-5,-12) | ((6,14),(8,16)) + [(1,2),(3,4)] | (-5,-12) | [(6,14),(8,16)] + ((10,20)) | (-5,-12) | ((15,32)) + [(11,12),(13,14)] | (-5,-12) | [(16,24),(18,26)] + ((11,12),(13,14)) | (-5,-12) | ((16,24),(18,26)) + [(1,2),(3,4)] | (1e-300,-1e-300) | [(1,2),(3,4)] + ((1,2),(3,4)) | (1e-300,-1e-300) | ((1,2),(3,4)) + [(0,0),(3,0),(4,5),(1,6)] | (1e-300,-1e-300) | [(-1e-300,1e-300),(3,1e-300),(4,5),(1,6)] + ((1,2),(3,4)) | (1e-300,-1e-300) | ((1,2),(3,4)) + ((1,2),(3,4)) | (1e-300,-1e-300) | ((1,2),(3,4)) + [(1,2),(3,4)] | (1e-300,-1e-300) | [(1,2),(3,4)] + ((10,20)) | (1e-300,-1e-300) | ((10,20)) + [(11,12),(13,14)] | (1e-300,-1e-300) | [(11,12),(13,14)] + ((11,12),(13,14)) | (1e-300,-1e-300) | ((11,12),(13,14)) + [(1,2),(3,4)] | (1e+300,Infinity) | [(-1e+300,-Infinity),(-1e+300,-Infinity)] + ((1,2),(3,4)) | (1e+300,Infinity) | ((-1e+300,-Infinity),(-1e+300,-Infinity)) + [(0,0),(3,0),(4,5),(1,6)] | (1e+300,Infinity) | [(-1e+300,-Infinity),(-1e+300,-Infinity),(-1e+300,-Infinity),(-1e+300,-Infinity)] + ((1,2),(3,4)) | (1e+300,Infinity) | ((-1e+300,-Infinity),(-1e+300,-Infinity)) + ((1,2),(3,4)) | (1e+300,Infinity) | ((-1e+300,-Infinity),(-1e+300,-Infinity)) + [(1,2),(3,4)] | (1e+300,Infinity) | [(-1e+300,-Infinity),(-1e+300,-Infinity)] + ((10,20)) | (1e+300,Infinity) | ((-1e+300,-Infinity)) + [(11,12),(13,14)] | (1e+300,Infinity) | [(-1e+300,-Infinity),(-1e+300,-Infinity)] + ((11,12),(13,14)) | (1e+300,Infinity) | ((-1e+300,-Infinity),(-1e+300,-Infinity)) + [(1,2),(3,4)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN)] + ((1,2),(3,4)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + [(0,0),(3,0),(4,5),(1,6)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN),(NaN,NaN),(NaN,NaN)] + ((1,2),(3,4)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + ((1,2),(3,4)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + [(1,2),(3,4)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN)] + ((10,20)) | (NaN,NaN) | ((NaN,NaN)) + [(11,12),(13,14)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN)] + ((11,12),(13,14)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + [(1,2),(3,4)] | (10,10) | [(-9,-8),(-7,-6)] + ((1,2),(3,4)) | (10,10) | ((-9,-8),(-7,-6)) + [(0,0),(3,0),(4,5),(1,6)] | (10,10) | [(-10,-10),(-7,-10),(-6,-5),(-9,-4)] + ((1,2),(3,4)) | (10,10) | ((-9,-8),(-7,-6)) + ((1,2),(3,4)) | (10,10) | ((-9,-8),(-7,-6)) + [(1,2),(3,4)] | (10,10) | [(-9,-8),(-7,-6)] + ((10,20)) | (10,10) | ((0,10)) + [(11,12),(13,14)] | (10,10) | [(1,2),(3,4)] + ((11,12),(13,14)) | (10,10) | ((1,2),(3,4)) +(81 rows) + +-- Multiply with point +SELECT p.f1, p1.f1, p.f1 * p1.f1 FROM PATH_TBL p, POINT_TBL p1; + f1 | f1 | ?column? +---------------------------+-------------------+---------------------------------------------------------------------- + [(1,2),(3,4)] | (0,0) | [(0,0),(0,0)] + ((1,2),(3,4)) | (0,0) | ((0,0),(0,0)) + [(0,0),(3,0),(4,5),(1,6)] | (0,0) | [(0,0),(0,0),(0,0),(0,0)] + ((1,2),(3,4)) | (0,0) | ((0,0),(0,0)) + ((1,2),(3,4)) | (0,0) | ((0,0),(0,0)) + [(1,2),(3,4)] | (0,0) | [(0,0),(0,0)] + ((10,20)) | (0,0) | ((0,0)) + [(11,12),(13,14)] | (0,0) | [(0,0),(0,0)] + ((11,12),(13,14)) | (0,0) | ((0,0),(0,0)) + [(1,2),(3,4)] | (-10,0) | [(-10,-20),(-30,-40)] + ((1,2),(3,4)) | (-10,0) | ((-10,-20),(-30,-40)) + [(0,0),(3,0),(4,5),(1,6)] | (-10,0) | [(-0,0),(-30,0),(-40,-50),(-10,-60)] + ((1,2),(3,4)) | (-10,0) | ((-10,-20),(-30,-40)) + ((1,2),(3,4)) | (-10,0) | ((-10,-20),(-30,-40)) + [(1,2),(3,4)] | (-10,0) | [(-10,-20),(-30,-40)] + ((10,20)) | (-10,0) | ((-100,-200)) + [(11,12),(13,14)] | (-10,0) | [(-110,-120),(-130,-140)] + ((11,12),(13,14)) | (-10,0) | ((-110,-120),(-130,-140)) + [(1,2),(3,4)] | (-3,4) | [(-11,-2),(-25,0)] + ((1,2),(3,4)) | (-3,4) | ((-11,-2),(-25,0)) + [(0,0),(3,0),(4,5),(1,6)] | (-3,4) | [(-0,0),(-9,12),(-32,1),(-27,-14)] + ((1,2),(3,4)) | (-3,4) | ((-11,-2),(-25,0)) + ((1,2),(3,4)) | (-3,4) | ((-11,-2),(-25,0)) + [(1,2),(3,4)] | (-3,4) | [(-11,-2),(-25,0)] + ((10,20)) | (-3,4) | ((-110,-20)) + [(11,12),(13,14)] | (-3,4) | [(-81,8),(-95,10)] + ((11,12),(13,14)) | (-3,4) | ((-81,8),(-95,10)) + [(1,2),(3,4)] | (5.1,34.5) | [(-63.9,44.7),(-122.7,123.9)] + ((1,2),(3,4)) | (5.1,34.5) | ((-63.9,44.7),(-122.7,123.9)) + [(0,0),(3,0),(4,5),(1,6)] | (5.1,34.5) | [(0,0),(15.3,103.5),(-152.1,163.5),(-201.9,65.1)] + ((1,2),(3,4)) | (5.1,34.5) | ((-63.9,44.7),(-122.7,123.9)) + ((1,2),(3,4)) | (5.1,34.5) | ((-63.9,44.7),(-122.7,123.9)) + [(1,2),(3,4)] | (5.1,34.5) | [(-63.9,44.7),(-122.7,123.9)] + ((10,20)) | (5.1,34.5) | ((-639,447)) + [(11,12),(13,14)] | (5.1,34.5) | [(-357.9,440.7),(-416.7,519.9)] + ((11,12),(13,14)) | (5.1,34.5) | ((-357.9,440.7),(-416.7,519.9)) + [(1,2),(3,4)] | (-5,-12) | [(19,-22),(33,-56)] + ((1,2),(3,4)) | (-5,-12) | ((19,-22),(33,-56)) + [(0,0),(3,0),(4,5),(1,6)] | (-5,-12) | [(0,-0),(-15,-36),(40,-73),(67,-42)] + ((1,2),(3,4)) | (-5,-12) | ((19,-22),(33,-56)) + ((1,2),(3,4)) | (-5,-12) | ((19,-22),(33,-56)) + [(1,2),(3,4)] | (-5,-12) | [(19,-22),(33,-56)] + ((10,20)) | (-5,-12) | ((190,-220)) + [(11,12),(13,14)] | (-5,-12) | [(89,-192),(103,-226)] + ((11,12),(13,14)) | (-5,-12) | ((89,-192),(103,-226)) + [(1,2),(3,4)] | (1e-300,-1e-300) | [(3e-300,1e-300),(7e-300,1e-300)] + ((1,2),(3,4)) | (1e-300,-1e-300) | ((3e-300,1e-300),(7e-300,1e-300)) + [(0,0),(3,0),(4,5),(1,6)] | (1e-300,-1e-300) | [(0,0),(3e-300,-3e-300),(9e-300,1e-300),(7e-300,5e-300)] + ((1,2),(3,4)) | (1e-300,-1e-300) | ((3e-300,1e-300),(7e-300,1e-300)) + ((1,2),(3,4)) | (1e-300,-1e-300) | ((3e-300,1e-300),(7e-300,1e-300)) + [(1,2),(3,4)] | (1e-300,-1e-300) | [(3e-300,1e-300),(7e-300,1e-300)] + ((10,20)) | (1e-300,-1e-300) | ((3e-299,1e-299)) + [(11,12),(13,14)] | (1e-300,-1e-300) | [(2.3e-299,1e-300),(2.7e-299,1e-300)] + ((11,12),(13,14)) | (1e-300,-1e-300) | ((2.3e-299,1e-300),(2.7e-299,1e-300)) + [(1,2),(3,4)] | (1e+300,Infinity) | [(-Infinity,Infinity),(-Infinity,Infinity)] + ((1,2),(3,4)) | (1e+300,Infinity) | ((-Infinity,Infinity),(-Infinity,Infinity)) + [(0,0),(3,0),(4,5),(1,6)] | (1e+300,Infinity) | [(NaN,NaN),(NaN,Infinity),(-Infinity,Infinity),(-Infinity,Infinity)] + ((1,2),(3,4)) | (1e+300,Infinity) | ((-Infinity,Infinity),(-Infinity,Infinity)) + ((1,2),(3,4)) | (1e+300,Infinity) | ((-Infinity,Infinity),(-Infinity,Infinity)) + [(1,2),(3,4)] | (1e+300,Infinity) | [(-Infinity,Infinity),(-Infinity,Infinity)] + ((10,20)) | (1e+300,Infinity) | ((-Infinity,Infinity)) + [(11,12),(13,14)] | (1e+300,Infinity) | [(-Infinity,Infinity),(-Infinity,Infinity)] + ((11,12),(13,14)) | (1e+300,Infinity) | ((-Infinity,Infinity),(-Infinity,Infinity)) + [(1,2),(3,4)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN)] + ((1,2),(3,4)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + [(0,0),(3,0),(4,5),(1,6)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN),(NaN,NaN),(NaN,NaN)] + ((1,2),(3,4)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + ((1,2),(3,4)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + [(1,2),(3,4)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN)] + ((10,20)) | (NaN,NaN) | ((NaN,NaN)) + [(11,12),(13,14)] | (NaN,NaN) | [(NaN,NaN),(NaN,NaN)] + ((11,12),(13,14)) | (NaN,NaN) | ((NaN,NaN),(NaN,NaN)) + [(1,2),(3,4)] | (10,10) | [(-10,30),(-10,70)] + ((1,2),(3,4)) | (10,10) | ((-10,30),(-10,70)) + [(0,0),(3,0),(4,5),(1,6)] | (10,10) | [(0,0),(30,30),(-10,90),(-50,70)] + ((1,2),(3,4)) | (10,10) | ((-10,30),(-10,70)) + ((1,2),(3,4)) | (10,10) | ((-10,30),(-10,70)) + [(1,2),(3,4)] | (10,10) | [(-10,30),(-10,70)] + ((10,20)) | (10,10) | ((-100,300)) + [(11,12),(13,14)] | (10,10) | [(-10,230),(-10,270)] + ((11,12),(13,14)) | (10,10) | ((-10,230),(-10,270)) +(81 rows) + +-- Divide by point +SELECT p.f1, p1.f1, p.f1 / p1.f1 FROM PATH_TBL p, POINT_TBL p1 WHERE p1.f1[0] BETWEEN 1 AND 1000; + f1 | f1 | ?column? +---------------------------+------------+----------------------------------------------------------------------------------------------------------------- + [(1,2),(3,4)] | (5.1,34.5) | [(0.0609244733856,-0.0199792807459),(0.12604212915,-0.0683242069952)] + [(1,2),(3,4)] | (10,10) | [(0.15,0.05),(0.35,0.05)] + ((1,2),(3,4)) | (5.1,34.5) | ((0.0609244733856,-0.0199792807459),(0.12604212915,-0.0683242069952)) + ((1,2),(3,4)) | (10,10) | ((0.15,0.05),(0.35,0.05)) + [(0,0),(3,0),(4,5),(1,6)] | (5.1,34.5) | [(0,0),(0.0125795471363,-0.0850969365103),(0.158600957032,-0.0924966701199),(0.174387055399,-0.00320655123082)] + [(0,0),(3,0),(4,5),(1,6)] | (10,10) | [(0,0),(0.15,-0.15),(0.45,0.05),(0.35,0.25)] + ((1,2),(3,4)) | (5.1,34.5) | ((0.0609244733856,-0.0199792807459),(0.12604212915,-0.0683242069952)) + ((1,2),(3,4)) | (10,10) | ((0.15,0.05),(0.35,0.05)) + ((1,2),(3,4)) | (5.1,34.5) | ((0.0609244733856,-0.0199792807459),(0.12604212915,-0.0683242069952)) + ((1,2),(3,4)) | (10,10) | ((0.15,0.05),(0.35,0.05)) + [(1,2),(3,4)] | (5.1,34.5) | [(0.0609244733856,-0.0199792807459),(0.12604212915,-0.0683242069952)] + [(1,2),(3,4)] | (10,10) | [(0.15,0.05),(0.35,0.05)] + ((10,20)) | (5.1,34.5) | ((0.609244733856,-0.199792807459)) + ((10,20)) | (10,10) | ((1.5,0.5)) + [(11,12),(13,14)] | (5.1,34.5) | [(0.386512752208,-0.261703911993),(0.451630407972,-0.310048838242)] + [(11,12),(13,14)] | (10,10) | [(1.15,0.05),(1.35,0.05)] + ((11,12),(13,14)) | (5.1,34.5) | ((0.386512752208,-0.261703911993),(0.451630407972,-0.310048838242)) + ((11,12),(13,14)) | (10,10) | ((1.15,0.05),(1.35,0.05)) +(18 rows) + +-- Division by 0 error +SELECT p.f1, p1.f1, p.f1 / p1.f1 FROM PATH_TBL p, POINT_TBL p1 WHERE p1.f1 ~= '(0,0)'::point; +ERROR: division by zero +-- Distance to path +SELECT p1.f1, p2.f1, p1.f1 <-> p2.f1 FROM PATH_TBL p1, PATH_TBL p2; + f1 | f1 | ?column? +---------------------------+---------------------------+---------------- + [(1,2),(3,4)] | [(1,2),(3,4)] | 0 + [(1,2),(3,4)] | ((1,2),(3,4)) | 0 + [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6)] | 0.784464540553 + [(1,2),(3,4)] | ((1,2),(3,4)) | 0 + [(1,2),(3,4)] | ((1,2),(3,4)) | 0 + [(1,2),(3,4)] | [(1,2),(3,4)] | 0 + [(1,2),(3,4)] | ((10,20)) | 17.4642491966 + [(1,2),(3,4)] | [(11,12),(13,14)] | 11.313708499 + [(1,2),(3,4)] | ((11,12),(13,14)) | 11.313708499 + ((1,2),(3,4)) | [(1,2),(3,4)] | 0 + ((1,2),(3,4)) | ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] | 0.784464540553 + ((1,2),(3,4)) | ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | [(1,2),(3,4)] | 0 + ((1,2),(3,4)) | ((10,20)) | 17.4642491966 + ((1,2),(3,4)) | [(11,12),(13,14)] | 11.313708499 + ((1,2),(3,4)) | ((11,12),(13,14)) | 11.313708499 + [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4)] | 0.784464540553 + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) | 0.784464540553 + [(0,0),(3,0),(4,5),(1,6)] | [(0,0),(3,0),(4,5),(1,6)] | 0 + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) | 0.784464540553 + [(0,0),(3,0),(4,5),(1,6)] | ((1,2),(3,4)) | 0.784464540553 + [(0,0),(3,0),(4,5),(1,6)] | [(1,2),(3,4)] | 0.784464540553 + [(0,0),(3,0),(4,5),(1,6)] | ((10,20)) | 16.1554944214 + [(0,0),(3,0),(4,5),(1,6)] | [(11,12),(13,14)] | 9.89949493661 + [(0,0),(3,0),(4,5),(1,6)] | ((11,12),(13,14)) | 9.89949493661 + ((1,2),(3,4)) | [(1,2),(3,4)] | 0 + ((1,2),(3,4)) | ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] | 0.784464540553 + ((1,2),(3,4)) | ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | [(1,2),(3,4)] | 0 + ((1,2),(3,4)) | ((10,20)) | 17.4642491966 + ((1,2),(3,4)) | [(11,12),(13,14)] | 11.313708499 + ((1,2),(3,4)) | ((11,12),(13,14)) | 11.313708499 + ((1,2),(3,4)) | [(1,2),(3,4)] | 0 + ((1,2),(3,4)) | ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | [(0,0),(3,0),(4,5),(1,6)] | 0.784464540553 + ((1,2),(3,4)) | ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | ((1,2),(3,4)) | 0 + ((1,2),(3,4)) | [(1,2),(3,4)] | 0 + ((1,2),(3,4)) | ((10,20)) | 17.4642491966 + ((1,2),(3,4)) | [(11,12),(13,14)] | 11.313708499 + ((1,2),(3,4)) | ((11,12),(13,14)) | 11.313708499 + [(1,2),(3,4)] | [(1,2),(3,4)] | 0 + [(1,2),(3,4)] | ((1,2),(3,4)) | 0 + [(1,2),(3,4)] | [(0,0),(3,0),(4,5),(1,6)] | 0.784464540553 + [(1,2),(3,4)] | ((1,2),(3,4)) | 0 + [(1,2),(3,4)] | ((1,2),(3,4)) | 0 + [(1,2),(3,4)] | [(1,2),(3,4)] | 0 + [(1,2),(3,4)] | ((10,20)) | 17.4642491966 + [(1,2),(3,4)] | [(11,12),(13,14)] | 11.313708499 + [(1,2),(3,4)] | ((11,12),(13,14)) | 11.313708499 + ((10,20)) | [(1,2),(3,4)] | 17.4642491966 + ((10,20)) | ((1,2),(3,4)) | 17.4642491966 + ((10,20)) | [(0,0),(3,0),(4,5),(1,6)] | 16.1554944214 + ((10,20)) | ((1,2),(3,4)) | 17.4642491966 + ((10,20)) | ((1,2),(3,4)) | 17.4642491966 + ((10,20)) | [(1,2),(3,4)] | 17.4642491966 + ((10,20)) | ((10,20)) | 0 + ((10,20)) | [(11,12),(13,14)] | 6.7082039325 + ((10,20)) | ((11,12),(13,14)) | 6.7082039325 + [(11,12),(13,14)] | [(1,2),(3,4)] | 11.313708499 + [(11,12),(13,14)] | ((1,2),(3,4)) | 11.313708499 + [(11,12),(13,14)] | [(0,0),(3,0),(4,5),(1,6)] | 9.89949493661 + [(11,12),(13,14)] | ((1,2),(3,4)) | 11.313708499 + [(11,12),(13,14)] | ((1,2),(3,4)) | 11.313708499 + [(11,12),(13,14)] | [(1,2),(3,4)] | 11.313708499 + [(11,12),(13,14)] | ((10,20)) | 6.7082039325 + [(11,12),(13,14)] | [(11,12),(13,14)] | 0 + [(11,12),(13,14)] | ((11,12),(13,14)) | 0 + ((11,12),(13,14)) | [(1,2),(3,4)] | 11.313708499 + ((11,12),(13,14)) | ((1,2),(3,4)) | 11.313708499 + ((11,12),(13,14)) | [(0,0),(3,0),(4,5),(1,6)] | 9.89949493661 + ((11,12),(13,14)) | ((1,2),(3,4)) | 11.313708499 + ((11,12),(13,14)) | ((1,2),(3,4)) | 11.313708499 + ((11,12),(13,14)) | [(1,2),(3,4)] | 11.313708499 + ((11,12),(13,14)) | ((10,20)) | 6.7082039325 + ((11,12),(13,14)) | [(11,12),(13,14)] | 0 + ((11,12),(13,14)) | ((11,12),(13,14)) | 0 +(81 rows) + +-- +-- Polygons +-- +-- containment +SELECT '' AS twentyfour, p.f1, poly.f1, poly.f1 @> p.f1 AS contains + FROM POLYGON_TBL poly, POINT_TBL p; + twentyfour | f1 | f1 | contains +------------+-------------------+----------------------------+---------- + | (0,0) | ((2,0),(2,4),(0,0)) | t + | (0,0) | ((3,1),(3,3),(1,0)) | f + | (0,0) | ((1,2),(3,4),(5,6),(7,8)) | f + | (0,0) | ((7,8),(5,6),(3,4),(1,2)) | f + | (0,0) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (0,0) | ((0,0)) | t + | (0,0) | ((0,1),(0,1)) | f + | (-10,0) | ((2,0),(2,4),(0,0)) | f + | (-10,0) | ((3,1),(3,3),(1,0)) | f + | (-10,0) | ((1,2),(3,4),(5,6),(7,8)) | f + | (-10,0) | ((7,8),(5,6),(3,4),(1,2)) | f + | (-10,0) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (-10,0) | ((0,0)) | f + | (-10,0) | ((0,1),(0,1)) | f + | (-3,4) | ((2,0),(2,4),(0,0)) | f + | (-3,4) | ((3,1),(3,3),(1,0)) | f + | (-3,4) | ((1,2),(3,4),(5,6),(7,8)) | f + | (-3,4) | ((7,8),(5,6),(3,4),(1,2)) | f + | (-3,4) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (-3,4) | ((0,0)) | f + | (-3,4) | ((0,1),(0,1)) | f + | (5.1,34.5) | ((2,0),(2,4),(0,0)) | f + | (5.1,34.5) | ((3,1),(3,3),(1,0)) | f + | (5.1,34.5) | ((1,2),(3,4),(5,6),(7,8)) | f + | (5.1,34.5) | ((7,8),(5,6),(3,4),(1,2)) | f + | (5.1,34.5) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (5.1,34.5) | ((0,0)) | f + | (5.1,34.5) | ((0,1),(0,1)) | f + | (-5,-12) | ((2,0),(2,4),(0,0)) | f + | (-5,-12) | ((3,1),(3,3),(1,0)) | f + | (-5,-12) | ((1,2),(3,4),(5,6),(7,8)) | f + | (-5,-12) | ((7,8),(5,6),(3,4),(1,2)) | f + | (-5,-12) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (-5,-12) | ((0,0)) | f + | (-5,-12) | ((0,1),(0,1)) | f + | (1e-300,-1e-300) | ((2,0),(2,4),(0,0)) | t + | (1e-300,-1e-300) | ((3,1),(3,3),(1,0)) | f + | (1e-300,-1e-300) | ((1,2),(3,4),(5,6),(7,8)) | f + | (1e-300,-1e-300) | ((7,8),(5,6),(3,4),(1,2)) | f + | (1e-300,-1e-300) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (1e-300,-1e-300) | ((0,0)) | t + | (1e-300,-1e-300) | ((0,1),(0,1)) | f + | (1e+300,Infinity) | ((2,0),(2,4),(0,0)) | f + | (1e+300,Infinity) | ((3,1),(3,3),(1,0)) | f + | (1e+300,Infinity) | ((1,2),(3,4),(5,6),(7,8)) | f + | (1e+300,Infinity) | ((7,8),(5,6),(3,4),(1,2)) | f + | (1e+300,Infinity) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (1e+300,Infinity) | ((0,0)) | f + | (1e+300,Infinity) | ((0,1),(0,1)) | f + | (NaN,NaN) | ((2,0),(2,4),(0,0)) | t + | (NaN,NaN) | ((3,1),(3,3),(1,0)) | t + | (NaN,NaN) | ((1,2),(3,4),(5,6),(7,8)) | t + | (NaN,NaN) | ((7,8),(5,6),(3,4),(1,2)) | t + | (NaN,NaN) | ((1,2),(7,8),(5,6),(3,-4)) | t + | (NaN,NaN) | ((0,0)) | t + | (NaN,NaN) | ((0,1),(0,1)) | t + | (10,10) | ((2,0),(2,4),(0,0)) | f + | (10,10) | ((3,1),(3,3),(1,0)) | f + | (10,10) | ((1,2),(3,4),(5,6),(7,8)) | f + | (10,10) | ((7,8),(5,6),(3,4),(1,2)) | f + | (10,10) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (10,10) | ((0,0)) | f + | (10,10) | ((0,1),(0,1)) | f +(63 rows) + +SELECT '' AS twentyfour, p.f1, poly.f1, p.f1 <@ poly.f1 AS contained + FROM POLYGON_TBL poly, POINT_TBL p; + twentyfour | f1 | f1 | contained +------------+-------------------+----------------------------+----------- + | (0,0) | ((2,0),(2,4),(0,0)) | t + | (0,0) | ((3,1),(3,3),(1,0)) | f + | (0,0) | ((1,2),(3,4),(5,6),(7,8)) | f + | (0,0) | ((7,8),(5,6),(3,4),(1,2)) | f + | (0,0) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (0,0) | ((0,0)) | t + | (0,0) | ((0,1),(0,1)) | f + | (-10,0) | ((2,0),(2,4),(0,0)) | f + | (-10,0) | ((3,1),(3,3),(1,0)) | f + | (-10,0) | ((1,2),(3,4),(5,6),(7,8)) | f + | (-10,0) | ((7,8),(5,6),(3,4),(1,2)) | f + | (-10,0) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (-10,0) | ((0,0)) | f + | (-10,0) | ((0,1),(0,1)) | f + | (-3,4) | ((2,0),(2,4),(0,0)) | f + | (-3,4) | ((3,1),(3,3),(1,0)) | f + | (-3,4) | ((1,2),(3,4),(5,6),(7,8)) | f + | (-3,4) | ((7,8),(5,6),(3,4),(1,2)) | f + | (-3,4) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (-3,4) | ((0,0)) | f + | (-3,4) | ((0,1),(0,1)) | f + | (5.1,34.5) | ((2,0),(2,4),(0,0)) | f + | (5.1,34.5) | ((3,1),(3,3),(1,0)) | f + | (5.1,34.5) | ((1,2),(3,4),(5,6),(7,8)) | f + | (5.1,34.5) | ((7,8),(5,6),(3,4),(1,2)) | f + | (5.1,34.5) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (5.1,34.5) | ((0,0)) | f + | (5.1,34.5) | ((0,1),(0,1)) | f + | (-5,-12) | ((2,0),(2,4),(0,0)) | f + | (-5,-12) | ((3,1),(3,3),(1,0)) | f + | (-5,-12) | ((1,2),(3,4),(5,6),(7,8)) | f + | (-5,-12) | ((7,8),(5,6),(3,4),(1,2)) | f + | (-5,-12) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (-5,-12) | ((0,0)) | f + | (-5,-12) | ((0,1),(0,1)) | f + | (1e-300,-1e-300) | ((2,0),(2,4),(0,0)) | t + | (1e-300,-1e-300) | ((3,1),(3,3),(1,0)) | f + | (1e-300,-1e-300) | ((1,2),(3,4),(5,6),(7,8)) | f + | (1e-300,-1e-300) | ((7,8),(5,6),(3,4),(1,2)) | f + | (1e-300,-1e-300) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (1e-300,-1e-300) | ((0,0)) | t + | (1e-300,-1e-300) | ((0,1),(0,1)) | f + | (1e+300,Infinity) | ((2,0),(2,4),(0,0)) | f + | (1e+300,Infinity) | ((3,1),(3,3),(1,0)) | f + | (1e+300,Infinity) | ((1,2),(3,4),(5,6),(7,8)) | f + | (1e+300,Infinity) | ((7,8),(5,6),(3,4),(1,2)) | f + | (1e+300,Infinity) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (1e+300,Infinity) | ((0,0)) | f + | (1e+300,Infinity) | ((0,1),(0,1)) | f + | (NaN,NaN) | ((2,0),(2,4),(0,0)) | t + | (NaN,NaN) | ((3,1),(3,3),(1,0)) | t + | (NaN,NaN) | ((1,2),(3,4),(5,6),(7,8)) | t + | (NaN,NaN) | ((7,8),(5,6),(3,4),(1,2)) | t + | (NaN,NaN) | ((1,2),(7,8),(5,6),(3,-4)) | t + | (NaN,NaN) | ((0,0)) | t + | (NaN,NaN) | ((0,1),(0,1)) | t + | (10,10) | ((2,0),(2,4),(0,0)) | f + | (10,10) | ((3,1),(3,3),(1,0)) | f + | (10,10) | ((1,2),(3,4),(5,6),(7,8)) | f + | (10,10) | ((7,8),(5,6),(3,4),(1,2)) | f + | (10,10) | ((1,2),(7,8),(5,6),(3,-4)) | f + | (10,10) | ((0,0)) | f + | (10,10) | ((0,1),(0,1)) | f +(63 rows) + +SELECT '' AS four, npoints(f1) AS npoints, f1 AS polygon + FROM POLYGON_TBL; + four | npoints | polygon +------+---------+---------------------------- + | 3 | ((2,0),(2,4),(0,0)) + | 3 | ((3,1),(3,3),(1,0)) + | 4 | ((1,2),(3,4),(5,6),(7,8)) + | 4 | ((7,8),(5,6),(3,4),(1,2)) + | 4 | ((1,2),(7,8),(5,6),(3,-4)) + | 1 | ((0,0)) + | 2 | ((0,1),(0,1)) +(7 rows) + +SELECT '' AS four, polygon(f1) + FROM BOX_TBL; + four | polygon +------+------------------------------------------- + | ((0,0),(0,2),(2,2),(2,0)) + | ((1,1),(1,3),(3,3),(3,1)) + | ((-8,-10),(-8,2),(-2,2),(-2,-10)) + | ((2.5,2.5),(2.5,3.5),(2.5,3.5),(2.5,2.5)) + | ((3,3),(3,3),(3,3),(3,3)) +(5 rows) + +SELECT '' AS four, polygon(f1) + FROM PATH_TBL WHERE isclosed(f1); + four | polygon +------+------------------- + | ((1,2),(3,4)) + | ((1,2),(3,4)) + | ((1,2),(3,4)) + | ((10,20)) + | ((11,12),(13,14)) +(5 rows) + +SELECT '' AS four, f1 AS open_path, polygon( pclose(f1)) AS polygon + FROM PATH_TBL + WHERE isopen(f1); + four | open_path | polygon +------+---------------------------+--------------------------- + | [(1,2),(3,4)] | ((1,2),(3,4)) + | [(0,0),(3,0),(4,5),(1,6)] | ((0,0),(3,0),(4,5),(1,6)) + | [(1,2),(3,4)] | ((1,2),(3,4)) + | [(11,12),(13,14)] | ((11,12),(13,14)) +(4 rows) + +-- To box +SELECT f1, f1::box FROM POLYGON_TBL; + f1 | f1 +----------------------------+-------------- + ((2,0),(2,4),(0,0)) | (2,4),(0,0) + ((3,1),(3,3),(1,0)) | (3,3),(1,0) + ((1,2),(3,4),(5,6),(7,8)) | (7,8),(1,2) + ((7,8),(5,6),(3,4),(1,2)) | (7,8),(1,2) + ((1,2),(7,8),(5,6),(3,-4)) | (7,8),(1,-4) + ((0,0)) | (0,0),(0,0) + ((0,1),(0,1)) | (0,1),(0,1) +(7 rows) + +-- To path +SELECT f1, f1::path FROM POLYGON_TBL; + f1 | f1 +----------------------------+---------------------------- + ((2,0),(2,4),(0,0)) | ((2,0),(2,4),(0,0)) + ((3,1),(3,3),(1,0)) | ((3,1),(3,3),(1,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(3,4),(5,6),(7,8)) + ((7,8),(5,6),(3,4),(1,2)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((0,0)) + ((0,1),(0,1)) | ((0,1),(0,1)) +(7 rows) + +-- Same as polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 ~= p2.f1; + f1 | f1 +----------------------------+---------------------------- + ((2,0),(2,4),(0,0)) | ((2,0),(2,4),(0,0)) + ((3,1),(3,3),(1,0)) | ((3,1),(3,3),(1,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(3,4),(5,6),(7,8)) | ((7,8),(5,6),(3,4),(1,2)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(3,4),(5,6),(7,8)) + ((7,8),(5,6),(3,4),(1,2)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((0,0)) + ((0,1),(0,1)) | ((0,1),(0,1)) +(9 rows) + +-- Contained by polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 <@ p2.f1; + f1 | f1 +----------------------------+---------------------------- + ((2,0),(2,4),(0,0)) | ((2,0),(2,4),(0,0)) + ((3,1),(3,3),(1,0)) | ((3,1),(3,3),(1,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(3,4),(5,6),(7,8)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(7,8),(5,6),(3,-4)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(3,4),(5,6),(7,8)) + ((7,8),(5,6),(3,4),(1,2)) | ((7,8),(5,6),(3,4),(1,2)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((2,0),(2,4),(0,0)) + ((0,0)) | ((0,0)) + ((0,1),(0,1)) | ((0,1),(0,1)) +(12 rows) + +-- Contains polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 @> p2.f1; + f1 | f1 +----------------------------+---------------------------- + ((2,0),(2,4),(0,0)) | ((2,0),(2,4),(0,0)) + ((2,0),(2,4),(0,0)) | ((0,0)) + ((3,1),(3,3),(1,0)) | ((3,1),(3,3),(1,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(3,4),(5,6),(7,8)) | ((7,8),(5,6),(3,4),(1,2)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(3,4),(5,6),(7,8)) + ((7,8),(5,6),(3,4),(1,2)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(7,8),(5,6),(3,-4)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((0,0)) + ((0,1),(0,1)) | ((0,1),(0,1)) +(12 rows) + +-- Overlap with polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 && p2.f1; + f1 | f1 +----------------------------+---------------------------- + ((2,0),(2,4),(0,0)) | ((2,0),(2,4),(0,0)) + ((2,0),(2,4),(0,0)) | ((3,1),(3,3),(1,0)) + ((2,0),(2,4),(0,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((2,0),(2,4),(0,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((2,0),(2,4),(0,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((2,0),(2,4),(0,0)) | ((0,0)) + ((3,1),(3,3),(1,0)) | ((2,0),(2,4),(0,0)) + ((3,1),(3,3),(1,0)) | ((3,1),(3,3),(1,0)) + ((3,1),(3,3),(1,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(3,4),(5,6),(7,8)) | ((2,0),(2,4),(0,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(3,4),(5,6),(7,8)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(7,8),(5,6),(3,-4)) + ((7,8),(5,6),(3,4),(1,2)) | ((2,0),(2,4),(0,0)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(3,4),(5,6),(7,8)) + ((7,8),(5,6),(3,4),(1,2)) | ((7,8),(5,6),(3,4),(1,2)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(7,8),(5,6),(3,-4)) | ((2,0),(2,4),(0,0)) + ((1,2),(7,8),(5,6),(3,-4)) | ((3,1),(3,3),(1,0)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(7,8),(5,6),(3,-4)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((2,0),(2,4),(0,0)) + ((0,0)) | ((0,0)) + ((0,1),(0,1)) | ((0,1),(0,1)) +(25 rows) + +-- Left of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 << p2.f1; + f1 | f1 +---------------+---------------------------- + ((0,0)) | ((3,1),(3,3),(1,0)) + ((0,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((0,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((0,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,1),(0,1)) | ((3,1),(3,3),(1,0)) + ((0,1),(0,1)) | ((1,2),(3,4),(5,6),(7,8)) + ((0,1),(0,1)) | ((7,8),(5,6),(3,4),(1,2)) + ((0,1),(0,1)) | ((1,2),(7,8),(5,6),(3,-4)) +(8 rows) + +-- Overlap of left of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 &< p2.f1; + f1 | f1 +----------------------------+---------------------------- + ((2,0),(2,4),(0,0)) | ((2,0),(2,4),(0,0)) + ((2,0),(2,4),(0,0)) | ((3,1),(3,3),(1,0)) + ((2,0),(2,4),(0,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((2,0),(2,4),(0,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((2,0),(2,4),(0,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((3,1),(3,3),(1,0)) | ((3,1),(3,3),(1,0)) + ((3,1),(3,3),(1,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((3,1),(3,3),(1,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((3,1),(3,3),(1,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(3,4),(5,6),(7,8)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(7,8),(5,6),(3,-4)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(3,4),(5,6),(7,8)) + ((7,8),(5,6),(3,4),(1,2)) | ((7,8),(5,6),(3,4),(1,2)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(7,8),(5,6),(3,-4)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((2,0),(2,4),(0,0)) + ((0,0)) | ((3,1),(3,3),(1,0)) + ((0,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((0,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((0,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((0,0)) + ((0,0)) | ((0,1),(0,1)) + ((0,1),(0,1)) | ((2,0),(2,4),(0,0)) + ((0,1),(0,1)) | ((3,1),(3,3),(1,0)) + ((0,1),(0,1)) | ((1,2),(3,4),(5,6),(7,8)) + ((0,1),(0,1)) | ((7,8),(5,6),(3,4),(1,2)) + ((0,1),(0,1)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,1),(0,1)) | ((0,0)) + ((0,1),(0,1)) | ((0,1),(0,1)) +(32 rows) + +-- Right of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 >> p2.f1; + f1 | f1 +----------------------------+--------------- + ((3,1),(3,3),(1,0)) | ((0,0)) + ((3,1),(3,3),(1,0)) | ((0,1),(0,1)) + ((1,2),(3,4),(5,6),(7,8)) | ((0,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((0,1),(0,1)) + ((7,8),(5,6),(3,4),(1,2)) | ((0,0)) + ((7,8),(5,6),(3,4),(1,2)) | ((0,1),(0,1)) + ((1,2),(7,8),(5,6),(3,-4)) | ((0,0)) + ((1,2),(7,8),(5,6),(3,-4)) | ((0,1),(0,1)) +(8 rows) + +-- Overlap of right of polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 &> p2.f1; + f1 | f1 +----------------------------+---------------------------- + ((2,0),(2,4),(0,0)) | ((2,0),(2,4),(0,0)) + ((2,0),(2,4),(0,0)) | ((0,0)) + ((2,0),(2,4),(0,0)) | ((0,1),(0,1)) + ((3,1),(3,3),(1,0)) | ((2,0),(2,4),(0,0)) + ((3,1),(3,3),(1,0)) | ((3,1),(3,3),(1,0)) + ((3,1),(3,3),(1,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((3,1),(3,3),(1,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((3,1),(3,3),(1,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((3,1),(3,3),(1,0)) | ((0,0)) + ((3,1),(3,3),(1,0)) | ((0,1),(0,1)) + ((1,2),(3,4),(5,6),(7,8)) | ((2,0),(2,4),(0,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((3,1),(3,3),(1,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(3,4),(5,6),(7,8)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(3,4),(5,6),(7,8)) | ((0,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((0,1),(0,1)) + ((7,8),(5,6),(3,4),(1,2)) | ((2,0),(2,4),(0,0)) + ((7,8),(5,6),(3,4),(1,2)) | ((3,1),(3,3),(1,0)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(3,4),(5,6),(7,8)) + ((7,8),(5,6),(3,4),(1,2)) | ((7,8),(5,6),(3,4),(1,2)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(7,8),(5,6),(3,-4)) + ((7,8),(5,6),(3,4),(1,2)) | ((0,0)) + ((7,8),(5,6),(3,4),(1,2)) | ((0,1),(0,1)) + ((1,2),(7,8),(5,6),(3,-4)) | ((2,0),(2,4),(0,0)) + ((1,2),(7,8),(5,6),(3,-4)) | ((3,1),(3,3),(1,0)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(7,8),(5,6),(3,-4)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(7,8),(5,6),(3,-4)) | ((0,0)) + ((1,2),(7,8),(5,6),(3,-4)) | ((0,1),(0,1)) + ((0,0)) | ((2,0),(2,4),(0,0)) + ((0,0)) | ((0,0)) + ((0,0)) | ((0,1),(0,1)) + ((0,1),(0,1)) | ((2,0),(2,4),(0,0)) + ((0,1),(0,1)) | ((0,0)) + ((0,1),(0,1)) | ((0,1),(0,1)) +(37 rows) + +-- Below polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 <<| p2.f1; + f1 | f1 +---------------+--------------------------- + ((0,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((0,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((0,0)) | ((0,1),(0,1)) + ((0,1),(0,1)) | ((1,2),(3,4),(5,6),(7,8)) + ((0,1),(0,1)) | ((7,8),(5,6),(3,4),(1,2)) +(5 rows) + +-- Overlap or below polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 &<| p2.f1; + f1 | f1 +----------------------------+---------------------------- + ((2,0),(2,4),(0,0)) | ((2,0),(2,4),(0,0)) + ((2,0),(2,4),(0,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((2,0),(2,4),(0,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((2,0),(2,4),(0,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((3,1),(3,3),(1,0)) | ((2,0),(2,4),(0,0)) + ((3,1),(3,3),(1,0)) | ((3,1),(3,3),(1,0)) + ((3,1),(3,3),(1,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((3,1),(3,3),(1,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((3,1),(3,3),(1,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(3,4),(5,6),(7,8)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(7,8),(5,6),(3,-4)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(3,4),(5,6),(7,8)) + ((7,8),(5,6),(3,4),(1,2)) | ((7,8),(5,6),(3,4),(1,2)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(7,8),(5,6),(3,-4)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((2,0),(2,4),(0,0)) + ((0,0)) | ((3,1),(3,3),(1,0)) + ((0,0)) | ((1,2),(3,4),(5,6),(7,8)) + ((0,0)) | ((7,8),(5,6),(3,4),(1,2)) + ((0,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((0,0)) + ((0,0)) | ((0,1),(0,1)) + ((0,1),(0,1)) | ((2,0),(2,4),(0,0)) + ((0,1),(0,1)) | ((3,1),(3,3),(1,0)) + ((0,1),(0,1)) | ((1,2),(3,4),(5,6),(7,8)) + ((0,1),(0,1)) | ((7,8),(5,6),(3,4),(1,2)) + ((0,1),(0,1)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,1),(0,1)) | ((0,1),(0,1)) +(31 rows) + +-- Above polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 |>> p2.f1; + f1 | f1 +---------------------------+--------------- + ((1,2),(3,4),(5,6),(7,8)) | ((0,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((0,1),(0,1)) + ((7,8),(5,6),(3,4),(1,2)) | ((0,0)) + ((7,8),(5,6),(3,4),(1,2)) | ((0,1),(0,1)) + ((0,1),(0,1)) | ((0,0)) +(5 rows) + +-- Overlap or above polygon +SELECT p1.f1, p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2 WHERE p1.f1 |&> p2.f1; + f1 | f1 +----------------------------+---------------------------- + ((2,0),(2,4),(0,0)) | ((2,0),(2,4),(0,0)) + ((2,0),(2,4),(0,0)) | ((3,1),(3,3),(1,0)) + ((2,0),(2,4),(0,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((2,0),(2,4),(0,0)) | ((0,0)) + ((3,1),(3,3),(1,0)) | ((2,0),(2,4),(0,0)) + ((3,1),(3,3),(1,0)) | ((3,1),(3,3),(1,0)) + ((3,1),(3,3),(1,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((3,1),(3,3),(1,0)) | ((0,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((2,0),(2,4),(0,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((3,1),(3,3),(1,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(3,4),(5,6),(7,8)) + ((1,2),(3,4),(5,6),(7,8)) | ((7,8),(5,6),(3,4),(1,2)) + ((1,2),(3,4),(5,6),(7,8)) | ((1,2),(7,8),(5,6),(3,-4)) + ((1,2),(3,4),(5,6),(7,8)) | ((0,0)) + ((1,2),(3,4),(5,6),(7,8)) | ((0,1),(0,1)) + ((7,8),(5,6),(3,4),(1,2)) | ((2,0),(2,4),(0,0)) + ((7,8),(5,6),(3,4),(1,2)) | ((3,1),(3,3),(1,0)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(3,4),(5,6),(7,8)) + ((7,8),(5,6),(3,4),(1,2)) | ((7,8),(5,6),(3,4),(1,2)) + ((7,8),(5,6),(3,4),(1,2)) | ((1,2),(7,8),(5,6),(3,-4)) + ((7,8),(5,6),(3,4),(1,2)) | ((0,0)) + ((7,8),(5,6),(3,4),(1,2)) | ((0,1),(0,1)) + ((1,2),(7,8),(5,6),(3,-4)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((2,0),(2,4),(0,0)) + ((0,0)) | ((3,1),(3,3),(1,0)) + ((0,0)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,0)) | ((0,0)) + ((0,1),(0,1)) | ((2,0),(2,4),(0,0)) + ((0,1),(0,1)) | ((3,1),(3,3),(1,0)) + ((0,1),(0,1)) | ((1,2),(7,8),(5,6),(3,-4)) + ((0,1),(0,1)) | ((0,0)) + ((0,1),(0,1)) | ((0,1),(0,1)) +(32 rows) + +-- Distance to polygon +SELECT p1.f1, p2.f1, p1.f1 <-> p2.f1 FROM POLYGON_TBL p1, POLYGON_TBL p2; +ERROR: function "poly_distance" not implemented +-- +-- Circles +-- +SELECT '' AS six, circle(f1, 50.0) + FROM POINT_TBL; + six | circle +-----+------------------------ + | <(0,0),50> + | <(-10,0),50> + | <(-3,4),50> + | <(5.1,34.5),50> + | <(-5,-12),50> + | <(1e-300,-1e-300),50> + | <(1e+300,Infinity),50> + | <(NaN,NaN),50> + | <(10,10),50> +(9 rows) + +SELECT '' AS four, circle(f1) + FROM BOX_TBL; + four | circle +------+------------------------ + | <(1,1),1.41421356237> + | <(2,2),1.41421356237> + | <(-5,-4),6.7082039325> + | <(2.5,3),0.5> + | <(3,3),0> +(5 rows) + +SELECT '' AS two, circle(f1) + FROM POLYGON_TBL + WHERE (# f1) >= 3; + two | circle +-----+----------------------------------------------- + | <(1.33333333333,1.33333333333),2.04168905064> + | <(2.33333333333,1.33333333333),1.47534300379> + | <(4,5),2.82842712475> + | <(4,5),2.82842712475> + | <(4,3),4.80664375676> +(5 rows) + +SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS distance + FROM CIRCLE_TBL c1, POINT_TBL p1 + WHERE (p1.f1 <-> c1.f1) > 0 + ORDER BY distance, area(c1.f1), p1.f1[0]; + twentyfour | circle | point | distance +------------+----------------+-------------------+--------------- + | <(1,2),3> | (-3,4) | 1.472135955 + | <(5,1),3> | (0,0) | 2.09901951359 + | <(5,1),3> | (1e-300,-1e-300) | 2.09901951359 + | <(5,1),3> | (-3,4) | 5.54400374532 + | <(3,5),0> | (0,0) | 5.83095189485 + | <(3,5),0> | (1e-300,-1e-300) | 5.83095189485 + | <(3,5),0> | (-3,4) | 6.0827625303 + | <(1,3),5> | (-10,0) | 6.40175425099 + | <(1,3),5> | (10,10) | 6.40175425099 + | <(5,1),3> | (10,10) | 7.29563014099 + | <(1,2),3> | (-10,0) | 8.1803398875 + | <(3,5),0> | (10,10) | 8.60232526704 + | <(1,2),3> | (10,10) | 9.04159457879 + | <(1,3),5> | (-5,-12) | 11.1554944214 + | <(5,1),3> | (-10,0) | 12.0332963784 + | <(1,2),3> | (-5,-12) | 12.2315462117 + | <(5,1),3> | (-5,-12) | 13.4012194669 + | <(3,5),0> | (-10,0) | 13.9283882772 + | <(3,5),0> | (-5,-12) | 18.7882942281 + | <(1,3),5> | (5.1,34.5) | 26.7657047773 + | <(3,5),0> | (5.1,34.5) | 29.5746513082 + | <(1,2),3> | (5.1,34.5) | 29.7575945393 + | <(5,1),3> | (5.1,34.5) | 30.5001492534 + | <(100,200),10> | (5.1,34.5) | 180.778038568 + | <(100,200),10> | (10,10) | 200.237960416 + | <(100,200),10> | (-3,4) | 211.415898255 + | <(100,200),10> | (0,0) | 213.60679775 + | <(100,200),10> | (1e-300,-1e-300) | 213.60679775 + | <(100,200),10> | (-10,0) | 218.25424421 + | <(100,200),10> | (-5,-12) | 226.577682802 + | <(3,5),0> | (1e+300,Infinity) | Infinity + | <(1,2),3> | (1e+300,Infinity) | Infinity + | <(5,1),3> | (1e+300,Infinity) | Infinity + | <(1,3),5> | (1e+300,Infinity) | Infinity + | <(100,200),10> | (1e+300,Infinity) | Infinity + | <(1,2),100> | (1e+300,Infinity) | Infinity + | <(100,1),115> | (1e+300,Infinity) | Infinity + | <(3,5),0> | (NaN,NaN) | NaN + | <(1,2),3> | (NaN,NaN) | NaN + | <(5,1),3> | (NaN,NaN) | NaN + | <(1,3),5> | (NaN,NaN) | NaN + | <(100,200),10> | (NaN,NaN) | NaN + | <(1,2),100> | (NaN,NaN) | NaN + | <(100,1),115> | (NaN,NaN) | NaN + | <(3,5),NaN> | (-10,0) | NaN + | <(3,5),NaN> | (-5,-12) | NaN + | <(3,5),NaN> | (-3,4) | NaN + | <(3,5),NaN> | (0,0) | NaN + | <(3,5),NaN> | (1e-300,-1e-300) | NaN + | <(3,5),NaN> | (5.1,34.5) | NaN + | <(3,5),NaN> | (10,10) | NaN + | <(3,5),NaN> | (1e+300,Infinity) | NaN + | <(3,5),NaN> | (NaN,NaN) | NaN +(53 rows) + +-- To polygon +SELECT f1, f1::polygon FROM CIRCLE_TBL WHERE f1 >= '<(0,0),1>'; + f1 | f1 +----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + <(5,1),3> | ((2,1),(2.40192378865,2.5),(3.5,3.59807621135),(5,4),(6.5,3.59807621135),(7.59807621135,2.5),(8,1),(7.59807621135,-0.5),(6.5,-1.59807621135),(5,-2),(3.5,-1.59807621135),(2.40192378865,-0.5)) + <(1,2),100> | ((-99,2),(-85.6025403784,52),(-49,88.6025403784),(1,102),(51,88.6025403784),(87.6025403784,52),(101,2),(87.6025403784,-48),(51,-84.6025403784),(1,-98),(-49,-84.6025403784),(-85.6025403784,-48)) + <(1,3),5> | ((-4,3),(-3.33012701892,5.5),(-1.5,7.33012701892),(1,8),(3.5,7.33012701892),(5.33012701892,5.5),(6,3),(5.33012701892,0.5),(3.5,-1.33012701892),(1,-2),(-1.5,-1.33012701892),(-3.33012701892,0.5)) + <(1,2),3> | ((-2,2),(-1.59807621135,3.5),(-0.5,4.59807621135),(1,5),(2.5,4.59807621135),(3.59807621135,3.5),(4,2),(3.59807621135,0.5),(2.5,-0.598076211353),(1,-1),(-0.5,-0.598076211353),(-1.59807621135,0.5)) + <(100,200),10> | ((90,200),(91.3397459622,205),(95,208.660254038),(100,210),(105,208.660254038),(108.660254038,205),(110,200),(108.660254038,195),(105,191.339745962),(100,190),(95,191.339745962),(91.3397459622,195)) + <(100,1),115> | ((-15,1),(0.40707856479,58.5),(42.5,100.592921435),(100,116),(157.5,100.592921435),(199.592921435,58.5),(215,1),(199.592921435,-56.5),(157.5,-98.5929214352),(100,-114),(42.5,-98.5929214352),(0.40707856479,-56.5)) +(6 rows) + +-- To polygon with less points +SELECT f1, polygon(8, f1) FROM CIRCLE_TBL WHERE f1 >= '<(0,0),1>'; + f1 | polygon +----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------ + <(5,1),3> | ((2,1),(2.87867965644,3.12132034356),(5,4),(7.12132034356,3.12132034356),(8,1),(7.12132034356,-1.12132034356),(5,-2),(2.87867965644,-1.12132034356)) + <(1,2),100> | ((-99,2),(-69.7106781187,72.7106781187),(1,102),(71.7106781187,72.7106781187),(101,2),(71.7106781187,-68.7106781187),(1,-98),(-69.7106781187,-68.7106781187)) + <(1,3),5> | ((-4,3),(-2.53553390593,6.53553390593),(1,8),(4.53553390593,6.53553390593),(6,3),(4.53553390593,-0.535533905933),(1,-2),(-2.53553390593,-0.535533905933)) + <(1,2),3> | ((-2,2),(-1.12132034356,4.12132034356),(1,5),(3.12132034356,4.12132034356),(4,2),(3.12132034356,-0.12132034356),(1,-1),(-1.12132034356,-0.12132034356)) + <(100,200),10> | ((90,200),(92.9289321881,207.071067812),(100,210),(107.071067812,207.071067812),(110,200),(107.071067812,192.928932188),(100,190),(92.9289321881,192.928932188)) + <(100,1),115> | ((-15,1),(18.6827201635,82.3172798365),(100,116),(181.317279836,82.3172798365),(215,1),(181.317279836,-80.3172798365),(100,-114),(18.6827201635,-80.3172798365)) +(6 rows) + +-- Too less points error +SELECT f1, polygon(1, f1) FROM CIRCLE_TBL WHERE f1 >= '<(0,0),1>'; +ERROR: must request at least 2 points +-- Zero radius error +SELECT f1, polygon(10, f1) FROM CIRCLE_TBL WHERE f1 < '<(0,0),1>'; +ERROR: cannot convert circle with radius zero to polygon +-- Same as circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 ~= c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(1,2),100> | <(1,2),100> + <(1,3),5> | <(1,3),5> + <(1,2),3> | <(1,2),3> + <(100,200),10> | <(100,200),10> + <(100,1),115> | <(100,1),115> + <(3,5),0> | <(3,5),0> + <(3,5),NaN> | <(3,5),0> + <(3,5),NaN> | <(3,5),NaN> +(9 rows) + +-- Overlap with circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 && c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(1,3),5> + <(5,1),3> | <(1,2),3> + <(5,1),3> | <(100,1),115> + <(1,2),100> | <(5,1),3> + <(1,2),100> | <(1,2),100> + <(1,2),100> | <(1,3),5> + <(1,2),100> | <(1,2),3> + <(1,2),100> | <(100,1),115> + <(1,2),100> | <(3,5),0> + <(1,3),5> | <(5,1),3> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(1,3),5> + <(1,3),5> | <(1,2),3> + <(1,3),5> | <(100,1),115> + <(1,3),5> | <(3,5),0> + <(1,2),3> | <(5,1),3> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(1,2),3> + <(1,2),3> | <(100,1),115> + <(100,200),10> | <(100,200),10> + <(100,1),115> | <(5,1),3> + <(100,1),115> | <(1,2),100> + <(100,1),115> | <(1,3),5> + <(100,1),115> | <(1,2),3> + <(100,1),115> | <(100,1),115> + <(100,1),115> | <(3,5),0> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(100,1),115> + <(3,5),0> | <(3,5),0> +(33 rows) + +-- Overlap or left of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 &< c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(100,200),10> + <(5,1),3> | <(100,1),115> + <(1,2),100> | <(1,2),100> + <(1,2),100> | <(100,200),10> + <(1,2),100> | <(100,1),115> + <(1,3),5> | <(5,1),3> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(1,3),5> + <(1,3),5> | <(100,200),10> + <(1,3),5> | <(100,1),115> + <(1,2),3> | <(5,1),3> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(1,2),3> + <(1,2),3> | <(100,200),10> + <(1,2),3> | <(100,1),115> + <(100,200),10> | <(100,200),10> + <(100,200),10> | <(100,1),115> + <(100,1),115> | <(100,1),115> + <(3,5),0> | <(5,1),3> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(1,2),3> + <(3,5),0> | <(100,200),10> + <(3,5),0> | <(100,1),115> + <(3,5),0> | <(3,5),0> +(28 rows) + +-- Left of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 << c2.f1; + f1 | f1 +-----------+---------------- + <(5,1),3> | <(100,200),10> + <(1,3),5> | <(100,200),10> + <(1,2),3> | <(100,200),10> + <(3,5),0> | <(100,200),10> +(4 rows) + +-- Right of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 >> c2.f1; + f1 | f1 +----------------+----------- + <(100,200),10> | <(5,1),3> + <(100,200),10> | <(1,3),5> + <(100,200),10> | <(1,2),3> + <(100,200),10> | <(3,5),0> +(4 rows) + +-- Overlap or right of circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 &> c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(1,3),5> + <(5,1),3> | <(1,2),3> + <(5,1),3> | <(100,1),115> + <(1,2),100> | <(1,2),100> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(1,3),5> + <(1,3),5> | <(100,1),115> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(1,2),3> + <(1,2),3> | <(100,1),115> + <(100,200),10> | <(5,1),3> + <(100,200),10> | <(1,2),100> + <(100,200),10> | <(1,3),5> + <(100,200),10> | <(1,2),3> + <(100,200),10> | <(100,200),10> + <(100,200),10> | <(100,1),115> + <(100,200),10> | <(3,5),0> + <(100,1),115> | <(1,2),100> + <(100,1),115> | <(100,1),115> + <(3,5),0> | <(5,1),3> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(1,2),3> + <(3,5),0> | <(100,1),115> + <(3,5),0> | <(3,5),0> +(28 rows) + +-- Contained by circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 <@ c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(100,1),115> + <(1,2),100> | <(1,2),100> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(1,3),5> + <(1,3),5> | <(100,1),115> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(1,2),3> + <(1,2),3> | <(100,1),115> + <(100,200),10> | <(100,200),10> + <(100,1),115> | <(100,1),115> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(100,1),115> + <(3,5),0> | <(3,5),0> +(17 rows) + +-- Contain by circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 @> c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(1,2),100> | <(5,1),3> + <(1,2),100> | <(1,2),100> + <(1,2),100> | <(1,3),5> + <(1,2),100> | <(1,2),3> + <(1,2),100> | <(3,5),0> + <(1,3),5> | <(1,3),5> + <(1,3),5> | <(1,2),3> + <(1,3),5> | <(3,5),0> + <(1,2),3> | <(1,2),3> + <(100,200),10> | <(100,200),10> + <(100,1),115> | <(5,1),3> + <(100,1),115> | <(1,3),5> + <(100,1),115> | <(1,2),3> + <(100,1),115> | <(100,1),115> + <(100,1),115> | <(3,5),0> + <(3,5),0> | <(3,5),0> +(17 rows) + +-- Below circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 <<| c2.f1; + f1 | f1 +---------------+---------------- + <(5,1),3> | <(100,200),10> + <(5,1),3> | <(3,5),0> + <(1,2),100> | <(100,200),10> + <(1,3),5> | <(100,200),10> + <(1,2),3> | <(100,200),10> + <(100,1),115> | <(100,200),10> + <(3,5),0> | <(100,200),10> +(7 rows) + +-- Above circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 |>> c2.f1; + f1 | f1 +----------------+--------------- + <(100,200),10> | <(5,1),3> + <(100,200),10> | <(1,2),100> + <(100,200),10> | <(1,3),5> + <(100,200),10> | <(1,2),3> + <(100,200),10> | <(100,1),115> + <(100,200),10> | <(3,5),0> + <(3,5),0> | <(5,1),3> +(7 rows) + +-- Overlap or below circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 &<| c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(1,3),5> + <(5,1),3> | <(1,2),3> + <(5,1),3> | <(100,200),10> + <(5,1),3> | <(100,1),115> + <(5,1),3> | <(3,5),0> + <(1,2),100> | <(1,2),100> + <(1,2),100> | <(100,200),10> + <(1,2),100> | <(100,1),115> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(1,3),5> + <(1,3),5> | <(100,200),10> + <(1,3),5> | <(100,1),115> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(1,2),3> + <(1,2),3> | <(100,200),10> + <(1,2),3> | <(100,1),115> + <(1,2),3> | <(3,5),0> + <(100,200),10> | <(100,200),10> + <(100,1),115> | <(100,200),10> + <(100,1),115> | <(100,1),115> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(1,2),3> + <(3,5),0> | <(100,200),10> + <(3,5),0> | <(100,1),115> + <(3,5),0> | <(3,5),0> +(29 rows) + +-- Overlap or above circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 |&> c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(1,3),5> + <(5,1),3> | <(100,1),115> + <(1,2),100> | <(1,2),100> + <(1,2),100> | <(100,1),115> + <(1,3),5> | <(5,1),3> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(1,3),5> + <(1,3),5> | <(100,1),115> + <(1,2),3> | <(5,1),3> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(1,2),3> + <(1,2),3> | <(100,1),115> + <(100,200),10> | <(5,1),3> + <(100,200),10> | <(1,2),100> + <(100,200),10> | <(1,3),5> + <(100,200),10> | <(1,2),3> + <(100,200),10> | <(100,200),10> + <(100,200),10> | <(100,1),115> + <(100,200),10> | <(3,5),0> + <(100,1),115> | <(100,1),115> + <(3,5),0> | <(5,1),3> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(1,2),3> + <(3,5),0> | <(100,1),115> + <(3,5),0> | <(3,5),0> +(29 rows) + +-- Area equal with circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 = c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(5,1),3> | <(1,2),3> + <(1,2),100> | <(1,2),100> + <(1,3),5> | <(1,3),5> + <(1,2),3> | <(5,1),3> + <(1,2),3> | <(1,2),3> + <(100,200),10> | <(100,200),10> + <(100,1),115> | <(100,1),115> + <(3,5),0> | <(3,5),0> +(9 rows) + +-- Area not equal with circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 != c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(1,3),5> + <(5,1),3> | <(100,200),10> + <(5,1),3> | <(100,1),115> + <(5,1),3> | <(3,5),0> + <(1,2),100> | <(5,1),3> + <(1,2),100> | <(1,3),5> + <(1,2),100> | <(1,2),3> + <(1,2),100> | <(100,200),10> + <(1,2),100> | <(100,1),115> + <(1,2),100> | <(3,5),0> + <(1,3),5> | <(5,1),3> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(1,2),3> + <(1,3),5> | <(100,200),10> + <(1,3),5> | <(100,1),115> + <(1,3),5> | <(3,5),0> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(100,200),10> + <(1,2),3> | <(100,1),115> + <(1,2),3> | <(3,5),0> + <(100,200),10> | <(5,1),3> + <(100,200),10> | <(1,2),100> + <(100,200),10> | <(1,3),5> + <(100,200),10> | <(1,2),3> + <(100,200),10> | <(100,1),115> + <(100,200),10> | <(3,5),0> + <(100,1),115> | <(5,1),3> + <(100,1),115> | <(1,2),100> + <(100,1),115> | <(1,3),5> + <(100,1),115> | <(1,2),3> + <(100,1),115> | <(100,200),10> + <(100,1),115> | <(3,5),0> + <(3,5),0> | <(5,1),3> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(1,2),3> + <(3,5),0> | <(100,200),10> + <(3,5),0> | <(100,1),115> +(40 rows) + +-- Area less than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 < c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(1,3),5> + <(5,1),3> | <(100,200),10> + <(5,1),3> | <(100,1),115> + <(1,2),100> | <(100,1),115> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(100,200),10> + <(1,3),5> | <(100,1),115> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(100,200),10> + <(1,2),3> | <(100,1),115> + <(100,200),10> | <(1,2),100> + <(100,200),10> | <(100,1),115> + <(3,5),0> | <(5,1),3> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(1,2),3> + <(3,5),0> | <(100,200),10> + <(3,5),0> | <(100,1),115> +(20 rows) + +-- Area greater than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 > c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(3,5),0> + <(1,2),100> | <(5,1),3> + <(1,2),100> | <(1,3),5> + <(1,2),100> | <(1,2),3> + <(1,2),100> | <(100,200),10> + <(1,2),100> | <(3,5),0> + <(1,3),5> | <(5,1),3> + <(1,3),5> | <(1,2),3> + <(1,3),5> | <(3,5),0> + <(1,2),3> | <(3,5),0> + <(100,200),10> | <(5,1),3> + <(100,200),10> | <(1,3),5> + <(100,200),10> | <(1,2),3> + <(100,200),10> | <(3,5),0> + <(100,1),115> | <(5,1),3> + <(100,1),115> | <(1,2),100> + <(100,1),115> | <(1,3),5> + <(100,1),115> | <(1,2),3> + <(100,1),115> | <(100,200),10> + <(100,1),115> | <(3,5),0> +(20 rows) + +-- Area less than or equal circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 <= c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(1,3),5> + <(5,1),3> | <(1,2),3> + <(5,1),3> | <(100,200),10> + <(5,1),3> | <(100,1),115> + <(1,2),100> | <(1,2),100> + <(1,2),100> | <(100,1),115> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(1,3),5> + <(1,3),5> | <(100,200),10> + <(1,3),5> | <(100,1),115> + <(1,2),3> | <(5,1),3> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(1,2),3> + <(1,2),3> | <(100,200),10> + <(1,2),3> | <(100,1),115> + <(100,200),10> | <(1,2),100> + <(100,200),10> | <(100,200),10> + <(100,200),10> | <(100,1),115> + <(100,1),115> | <(100,1),115> + <(3,5),0> | <(5,1),3> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(1,2),3> + <(3,5),0> | <(100,200),10> + <(3,5),0> | <(100,1),115> + <(3,5),0> | <(3,5),0> +(29 rows) + +-- Area greater than or equal circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 >= c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(5,1),3> + <(5,1),3> | <(1,2),3> + <(5,1),3> | <(3,5),0> + <(1,2),100> | <(5,1),3> + <(1,2),100> | <(1,2),100> + <(1,2),100> | <(1,3),5> + <(1,2),100> | <(1,2),3> + <(1,2),100> | <(100,200),10> + <(1,2),100> | <(3,5),0> + <(1,3),5> | <(5,1),3> + <(1,3),5> | <(1,3),5> + <(1,3),5> | <(1,2),3> + <(1,3),5> | <(3,5),0> + <(1,2),3> | <(5,1),3> + <(1,2),3> | <(1,2),3> + <(1,2),3> | <(3,5),0> + <(100,200),10> | <(5,1),3> + <(100,200),10> | <(1,3),5> + <(100,200),10> | <(1,2),3> + <(100,200),10> | <(100,200),10> + <(100,200),10> | <(3,5),0> + <(100,1),115> | <(5,1),3> + <(100,1),115> | <(1,2),100> + <(100,1),115> | <(1,3),5> + <(100,1),115> | <(1,2),3> + <(100,1),115> | <(100,200),10> + <(100,1),115> | <(100,1),115> + <(100,1),115> | <(3,5),0> + <(3,5),0> | <(3,5),0> +(29 rows) + +-- Area less than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 < c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(1,3),5> + <(5,1),3> | <(100,200),10> + <(5,1),3> | <(100,1),115> + <(1,2),100> | <(100,1),115> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(100,200),10> + <(1,3),5> | <(100,1),115> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(100,200),10> + <(1,2),3> | <(100,1),115> + <(100,200),10> | <(1,2),100> + <(100,200),10> | <(100,1),115> + <(3,5),0> | <(5,1),3> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(1,2),3> + <(3,5),0> | <(100,200),10> + <(3,5),0> | <(100,1),115> +(20 rows) + +-- Area greater than circle +SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 < c2.f1; + f1 | f1 +----------------+---------------- + <(5,1),3> | <(1,2),100> + <(5,1),3> | <(1,3),5> + <(5,1),3> | <(100,200),10> + <(5,1),3> | <(100,1),115> + <(1,2),100> | <(100,1),115> + <(1,3),5> | <(1,2),100> + <(1,3),5> | <(100,200),10> + <(1,3),5> | <(100,1),115> + <(1,2),3> | <(1,2),100> + <(1,2),3> | <(1,3),5> + <(1,2),3> | <(100,200),10> + <(1,2),3> | <(100,1),115> + <(100,200),10> | <(1,2),100> + <(100,200),10> | <(100,1),115> + <(3,5),0> | <(5,1),3> + <(3,5),0> | <(1,2),100> + <(3,5),0> | <(1,3),5> + <(3,5),0> | <(1,2),3> + <(3,5),0> | <(100,200),10> + <(3,5),0> | <(100,1),115> +(20 rows) + +-- Add point +SELECT c.f1, p.f1, c.f1 + p.f1 FROM CIRCLE_TBL c, POINT_TBL p; + f1 | f1 | ?column? +----------------+-------------------+------------------------- + <(5,1),3> | (0,0) | <(5,1),3> + <(1,2),100> | (0,0) | <(1,2),100> + <(1,3),5> | (0,0) | <(1,3),5> + <(1,2),3> | (0,0) | <(1,2),3> + <(100,200),10> | (0,0) | <(100,200),10> + <(100,1),115> | (0,0) | <(100,1),115> + <(3,5),0> | (0,0) | <(3,5),0> + <(3,5),NaN> | (0,0) | <(3,5),NaN> + <(5,1),3> | (-10,0) | <(-5,1),3> + <(1,2),100> | (-10,0) | <(-9,2),100> + <(1,3),5> | (-10,0) | <(-9,3),5> + <(1,2),3> | (-10,0) | <(-9,2),3> + <(100,200),10> | (-10,0) | <(90,200),10> + <(100,1),115> | (-10,0) | <(90,1),115> + <(3,5),0> | (-10,0) | <(-7,5),0> + <(3,5),NaN> | (-10,0) | <(-7,5),NaN> + <(5,1),3> | (-3,4) | <(2,5),3> + <(1,2),100> | (-3,4) | <(-2,6),100> + <(1,3),5> | (-3,4) | <(-2,7),5> + <(1,2),3> | (-3,4) | <(-2,6),3> + <(100,200),10> | (-3,4) | <(97,204),10> + <(100,1),115> | (-3,4) | <(97,5),115> + <(3,5),0> | (-3,4) | <(0,9),0> + <(3,5),NaN> | (-3,4) | <(0,9),NaN> + <(5,1),3> | (5.1,34.5) | <(10.1,35.5),3> + <(1,2),100> | (5.1,34.5) | <(6.1,36.5),100> + <(1,3),5> | (5.1,34.5) | <(6.1,37.5),5> + <(1,2),3> | (5.1,34.5) | <(6.1,36.5),3> + <(100,200),10> | (5.1,34.5) | <(105.1,234.5),10> + <(100,1),115> | (5.1,34.5) | <(105.1,35.5),115> + <(3,5),0> | (5.1,34.5) | <(8.1,39.5),0> + <(3,5),NaN> | (5.1,34.5) | <(8.1,39.5),NaN> + <(5,1),3> | (-5,-12) | <(0,-11),3> + <(1,2),100> | (-5,-12) | <(-4,-10),100> + <(1,3),5> | (-5,-12) | <(-4,-9),5> + <(1,2),3> | (-5,-12) | <(-4,-10),3> + <(100,200),10> | (-5,-12) | <(95,188),10> + <(100,1),115> | (-5,-12) | <(95,-11),115> + <(3,5),0> | (-5,-12) | <(-2,-7),0> + <(3,5),NaN> | (-5,-12) | <(-2,-7),NaN> + <(5,1),3> | (1e-300,-1e-300) | <(5,1),3> + <(1,2),100> | (1e-300,-1e-300) | <(1,2),100> + <(1,3),5> | (1e-300,-1e-300) | <(1,3),5> + <(1,2),3> | (1e-300,-1e-300) | <(1,2),3> + <(100,200),10> | (1e-300,-1e-300) | <(100,200),10> + <(100,1),115> | (1e-300,-1e-300) | <(100,1),115> + <(3,5),0> | (1e-300,-1e-300) | <(3,5),0> + <(3,5),NaN> | (1e-300,-1e-300) | <(3,5),NaN> + <(5,1),3> | (1e+300,Infinity) | <(1e+300,Infinity),3> + <(1,2),100> | (1e+300,Infinity) | <(1e+300,Infinity),100> + <(1,3),5> | (1e+300,Infinity) | <(1e+300,Infinity),5> + <(1,2),3> | (1e+300,Infinity) | <(1e+300,Infinity),3> + <(100,200),10> | (1e+300,Infinity) | <(1e+300,Infinity),10> + <(100,1),115> | (1e+300,Infinity) | <(1e+300,Infinity),115> + <(3,5),0> | (1e+300,Infinity) | <(1e+300,Infinity),0> + <(3,5),NaN> | (1e+300,Infinity) | <(1e+300,Infinity),NaN> + <(5,1),3> | (NaN,NaN) | <(NaN,NaN),3> + <(1,2),100> | (NaN,NaN) | <(NaN,NaN),100> + <(1,3),5> | (NaN,NaN) | <(NaN,NaN),5> + <(1,2),3> | (NaN,NaN) | <(NaN,NaN),3> + <(100,200),10> | (NaN,NaN) | <(NaN,NaN),10> + <(100,1),115> | (NaN,NaN) | <(NaN,NaN),115> + <(3,5),0> | (NaN,NaN) | <(NaN,NaN),0> + <(3,5),NaN> | (NaN,NaN) | <(NaN,NaN),NaN> + <(5,1),3> | (10,10) | <(15,11),3> + <(1,2),100> | (10,10) | <(11,12),100> + <(1,3),5> | (10,10) | <(11,13),5> + <(1,2),3> | (10,10) | <(11,12),3> + <(100,200),10> | (10,10) | <(110,210),10> + <(100,1),115> | (10,10) | <(110,11),115> + <(3,5),0> | (10,10) | <(13,15),0> + <(3,5),NaN> | (10,10) | <(13,15),NaN> +(72 rows) + +-- Subtract point +SELECT c.f1, p.f1, c.f1 - p.f1 FROM CIRCLE_TBL c, POINT_TBL p; + f1 | f1 | ?column? +----------------+-------------------+--------------------------- + <(5,1),3> | (0,0) | <(5,1),3> + <(1,2),100> | (0,0) | <(1,2),100> + <(1,3),5> | (0,0) | <(1,3),5> + <(1,2),3> | (0,0) | <(1,2),3> + <(100,200),10> | (0,0) | <(100,200),10> + <(100,1),115> | (0,0) | <(100,1),115> + <(3,5),0> | (0,0) | <(3,5),0> + <(3,5),NaN> | (0,0) | <(3,5),NaN> + <(5,1),3> | (-10,0) | <(15,1),3> + <(1,2),100> | (-10,0) | <(11,2),100> + <(1,3),5> | (-10,0) | <(11,3),5> + <(1,2),3> | (-10,0) | <(11,2),3> + <(100,200),10> | (-10,0) | <(110,200),10> + <(100,1),115> | (-10,0) | <(110,1),115> + <(3,5),0> | (-10,0) | <(13,5),0> + <(3,5),NaN> | (-10,0) | <(13,5),NaN> + <(5,1),3> | (-3,4) | <(8,-3),3> + <(1,2),100> | (-3,4) | <(4,-2),100> + <(1,3),5> | (-3,4) | <(4,-1),5> + <(1,2),3> | (-3,4) | <(4,-2),3> + <(100,200),10> | (-3,4) | <(103,196),10> + <(100,1),115> | (-3,4) | <(103,-3),115> + <(3,5),0> | (-3,4) | <(6,1),0> + <(3,5),NaN> | (-3,4) | <(6,1),NaN> + <(5,1),3> | (5.1,34.5) | <(-0.1,-33.5),3> + <(1,2),100> | (5.1,34.5) | <(-4.1,-32.5),100> + <(1,3),5> | (5.1,34.5) | <(-4.1,-31.5),5> + <(1,2),3> | (5.1,34.5) | <(-4.1,-32.5),3> + <(100,200),10> | (5.1,34.5) | <(94.9,165.5),10> + <(100,1),115> | (5.1,34.5) | <(94.9,-33.5),115> + <(3,5),0> | (5.1,34.5) | <(-2.1,-29.5),0> + <(3,5),NaN> | (5.1,34.5) | <(-2.1,-29.5),NaN> + <(5,1),3> | (-5,-12) | <(10,13),3> + <(1,2),100> | (-5,-12) | <(6,14),100> + <(1,3),5> | (-5,-12) | <(6,15),5> + <(1,2),3> | (-5,-12) | <(6,14),3> + <(100,200),10> | (-5,-12) | <(105,212),10> + <(100,1),115> | (-5,-12) | <(105,13),115> + <(3,5),0> | (-5,-12) | <(8,17),0> + <(3,5),NaN> | (-5,-12) | <(8,17),NaN> + <(5,1),3> | (1e-300,-1e-300) | <(5,1),3> + <(1,2),100> | (1e-300,-1e-300) | <(1,2),100> + <(1,3),5> | (1e-300,-1e-300) | <(1,3),5> + <(1,2),3> | (1e-300,-1e-300) | <(1,2),3> + <(100,200),10> | (1e-300,-1e-300) | <(100,200),10> + <(100,1),115> | (1e-300,-1e-300) | <(100,1),115> + <(3,5),0> | (1e-300,-1e-300) | <(3,5),0> + <(3,5),NaN> | (1e-300,-1e-300) | <(3,5),NaN> + <(5,1),3> | (1e+300,Infinity) | <(-1e+300,-Infinity),3> + <(1,2),100> | (1e+300,Infinity) | <(-1e+300,-Infinity),100> + <(1,3),5> | (1e+300,Infinity) | <(-1e+300,-Infinity),5> + <(1,2),3> | (1e+300,Infinity) | <(-1e+300,-Infinity),3> + <(100,200),10> | (1e+300,Infinity) | <(-1e+300,-Infinity),10> + <(100,1),115> | (1e+300,Infinity) | <(-1e+300,-Infinity),115> + <(3,5),0> | (1e+300,Infinity) | <(-1e+300,-Infinity),0> + <(3,5),NaN> | (1e+300,Infinity) | <(-1e+300,-Infinity),NaN> + <(5,1),3> | (NaN,NaN) | <(NaN,NaN),3> + <(1,2),100> | (NaN,NaN) | <(NaN,NaN),100> + <(1,3),5> | (NaN,NaN) | <(NaN,NaN),5> + <(1,2),3> | (NaN,NaN) | <(NaN,NaN),3> + <(100,200),10> | (NaN,NaN) | <(NaN,NaN),10> + <(100,1),115> | (NaN,NaN) | <(NaN,NaN),115> + <(3,5),0> | (NaN,NaN) | <(NaN,NaN),0> + <(3,5),NaN> | (NaN,NaN) | <(NaN,NaN),NaN> + <(5,1),3> | (10,10) | <(-5,-9),3> + <(1,2),100> | (10,10) | <(-9,-8),100> + <(1,3),5> | (10,10) | <(-9,-7),5> + <(1,2),3> | (10,10) | <(-9,-8),3> + <(100,200),10> | (10,10) | <(90,190),10> + <(100,1),115> | (10,10) | <(90,-9),115> + <(3,5),0> | (10,10) | <(-7,-5),0> + <(3,5),NaN> | (10,10) | <(-7,-5),NaN> +(72 rows) + +-- Multiply with point +SELECT c.f1, p.f1, c.f1 * p.f1 FROM CIRCLE_TBL c, POINT_TBL p; + f1 | f1 | ?column? +----------------+-------------------+-------------------------------------------- + <(5,1),3> | (0,0) | <(0,0),0> + <(1,2),100> | (0,0) | <(0,0),0> + <(1,3),5> | (0,0) | <(0,0),0> + <(1,2),3> | (0,0) | <(0,0),0> + <(100,200),10> | (0,0) | <(0,0),0> + <(100,1),115> | (0,0) | <(0,0),0> + <(3,5),0> | (0,0) | <(0,0),0> + <(3,5),NaN> | (0,0) | <(0,0),NaN> + <(5,1),3> | (-10,0) | <(-50,-10),30> + <(1,2),100> | (-10,0) | <(-10,-20),1000> + <(1,3),5> | (-10,0) | <(-10,-30),50> + <(1,2),3> | (-10,0) | <(-10,-20),30> + <(100,200),10> | (-10,0) | <(-1000,-2000),100> + <(100,1),115> | (-10,0) | <(-1000,-10),1150> + <(3,5),0> | (-10,0) | <(-30,-50),0> + <(3,5),NaN> | (-10,0) | <(-30,-50),NaN> + <(5,1),3> | (-3,4) | <(-19,17),15> + <(1,2),100> | (-3,4) | <(-11,-2),500> + <(1,3),5> | (-3,4) | <(-15,-5),25> + <(1,2),3> | (-3,4) | <(-11,-2),15> + <(100,200),10> | (-3,4) | <(-1100,-200),50> + <(100,1),115> | (-3,4) | <(-304,397),575> + <(3,5),0> | (-3,4) | <(-29,-3),0> + <(3,5),NaN> | (-3,4) | <(-29,-3),NaN> + <(5,1),3> | (5.1,34.5) | <(-9,177.6),104.624758064> + <(1,2),100> | (5.1,34.5) | <(-63.9,44.7),3487.49193547> + <(1,3),5> | (5.1,34.5) | <(-98.4,49.8),174.374596774> + <(1,2),3> | (5.1,34.5) | <(-63.9,44.7),104.624758064> + <(100,200),10> | (5.1,34.5) | <(-6390,4470),348.749193547> + <(100,1),115> | (5.1,34.5) | <(475.5,3455.1),4010.6157258> + <(3,5),0> | (5.1,34.5) | <(-157.2,129),0> + <(3,5),NaN> | (5.1,34.5) | <(-157.2,129),NaN> + <(5,1),3> | (-5,-12) | <(-13,-65),39> + <(1,2),100> | (-5,-12) | <(19,-22),1300> + <(1,3),5> | (-5,-12) | <(31,-27),65> + <(1,2),3> | (-5,-12) | <(19,-22),39> + <(100,200),10> | (-5,-12) | <(1900,-2200),130> + <(100,1),115> | (-5,-12) | <(-488,-1205),1495> + <(3,5),0> | (-5,-12) | <(45,-61),0> + <(3,5),NaN> | (-5,-12) | <(45,-61),NaN> + <(5,1),3> | (1e-300,-1e-300) | <(6e-300,-4e-300),4.24264068712e-300> + <(1,2),100> | (1e-300,-1e-300) | <(3e-300,1e-300),1.41421356237e-298> + <(1,3),5> | (1e-300,-1e-300) | <(4e-300,2e-300),7.07106781187e-300> + <(1,2),3> | (1e-300,-1e-300) | <(3e-300,1e-300),4.24264068712e-300> + <(100,200),10> | (1e-300,-1e-300) | <(3e-298,1e-298),1.41421356237e-299> + <(100,1),115> | (1e-300,-1e-300) | <(1.01e-298,-9.9e-299),1.62634559673e-298> + <(3,5),0> | (1e-300,-1e-300) | <(8e-300,2e-300),0> + <(3,5),NaN> | (1e-300,-1e-300) | <(8e-300,2e-300),NaN> + <(5,1),3> | (1e+300,Infinity) | <(-Infinity,Infinity),Infinity> + <(1,2),100> | (1e+300,Infinity) | <(-Infinity,Infinity),Infinity> + <(1,3),5> | (1e+300,Infinity) | <(-Infinity,Infinity),Infinity> + <(1,2),3> | (1e+300,Infinity) | <(-Infinity,Infinity),Infinity> + <(100,200),10> | (1e+300,Infinity) | <(-Infinity,Infinity),Infinity> + <(100,1),115> | (1e+300,Infinity) | <(-Infinity,Infinity),Infinity> + <(3,5),0> | (1e+300,Infinity) | <(-Infinity,Infinity),NaN> + <(3,5),NaN> | (1e+300,Infinity) | <(-Infinity,Infinity),NaN> + <(5,1),3> | (NaN,NaN) | <(NaN,NaN),NaN> + <(1,2),100> | (NaN,NaN) | <(NaN,NaN),NaN> + <(1,3),5> | (NaN,NaN) | <(NaN,NaN),NaN> + <(1,2),3> | (NaN,NaN) | <(NaN,NaN),NaN> + <(100,200),10> | (NaN,NaN) | <(NaN,NaN),NaN> + <(100,1),115> | (NaN,NaN) | <(NaN,NaN),NaN> + <(3,5),0> | (NaN,NaN) | <(NaN,NaN),NaN> + <(3,5),NaN> | (NaN,NaN) | <(NaN,NaN),NaN> + <(5,1),3> | (10,10) | <(40,60),42.4264068712> + <(1,2),100> | (10,10) | <(-10,30),1414.21356237> + <(1,3),5> | (10,10) | <(-20,40),70.7106781187> + <(1,2),3> | (10,10) | <(-10,30),42.4264068712> + <(100,200),10> | (10,10) | <(-1000,3000),141.421356237> + <(100,1),115> | (10,10) | <(990,1010),1626.34559673> + <(3,5),0> | (10,10) | <(-20,80),0> + <(3,5),NaN> | (10,10) | <(-20,80),NaN> +(72 rows) + +-- Divide by point +SELECT c.f1, p.f1, c.f1 / p.f1 FROM CIRCLE_TBL c, POINT_TBL p WHERE p.f1[0] BETWEEN 1 AND 1000; + f1 | f1 | ?column? +----------------+------------+------------------------------------------------------ + <(5,1),3> | (5.1,34.5) | <(0.0493315573973,-0.137635045138),0.0860217042937> + <(5,1),3> | (10,10) | <(0.3,-0.2),0.212132034356> + <(1,2),100> | (5.1,34.5) | <(0.0609244733856,-0.0199792807459),2.86739014312> + <(1,2),100> | (10,10) | <(0.15,0.05),7.07106781187> + <(1,3),5> | (5.1,34.5) | <(0.0892901188891,-0.0157860983671),0.143369507156> + <(1,3),5> | (10,10) | <(0.2,0.1),0.353553390593> + <(1,2),3> | (5.1,34.5) | <(0.0609244733856,-0.0199792807459),0.0860217042937> + <(1,2),3> | (10,10) | <(0.15,0.05),0.212132034356> + <(100,200),10> | (5.1,34.5) | <(6.09244733856,-1.99792807459),0.286739014312> + <(100,200),10> | (10,10) | <(15,5),0.707106781187> + <(100,1),115> | (5.1,34.5) | <(0.44768388338,-2.83237136796),3.29749866459> + <(100,1),115> | (10,10) | <(5.05,-4.95),8.13172798365> + <(3,5),0> | (5.1,34.5) | <(0.154407774653,-0.0641310246164),0> + <(3,5),0> | (10,10) | <(0.4,0.1),0> + <(3,5),NaN> | (5.1,34.5) | <(0.154407774653,-0.0641310246164),NaN> + <(3,5),NaN> | (10,10) | <(0.4,0.1),NaN> +(16 rows) + +-- Overflow error +SELECT c.f1, p.f1, c.f1 / p.f1 FROM CIRCLE_TBL c, POINT_TBL p WHERE p.f1[0] > 1000; +ERROR: value out of range: overflow +-- Division by 0 error +SELECT c.f1, p.f1, c.f1 / p.f1 FROM CIRCLE_TBL c, POINT_TBL p WHERE p.f1 ~= '(0,0)'::point; +ERROR: division by zero +-- Distance to polygon +SELECT c.f1, p.f1, c.f1 <-> p.f1 FROM CIRCLE_TBL c, POLYGON_TBL p; + f1 | f1 | ?column? +----------------+----------------------------+---------------- + <(5,1),3> | ((2,0),(2,4),(0,0)) | 0 + <(5,1),3> | ((3,1),(3,3),(1,0)) | 0 + <(5,1),3> | ((1,2),(3,4),(5,6),(7,8)) | 0.535533905933 + <(5,1),3> | ((7,8),(5,6),(3,4),(1,2)) | 0.535533905933 + <(5,1),3> | ((1,2),(7,8),(5,6),(3,-4)) | 0 + <(5,1),3> | ((0,0)) | 2.09901951359 + <(5,1),3> | ((0,1),(0,1)) | 2 + <(1,2),100> | ((2,0),(2,4),(0,0)) | 0 + <(1,2),100> | ((3,1),(3,3),(1,0)) | 0 + <(1,2),100> | ((1,2),(3,4),(5,6),(7,8)) | 0 + <(1,2),100> | ((7,8),(5,6),(3,4),(1,2)) | 0 + <(1,2),100> | ((1,2),(7,8),(5,6),(3,-4)) | 0 + <(1,2),100> | ((0,0)) | 0 + <(1,2),100> | ((0,1),(0,1)) | 0 + <(1,3),5> | ((2,0),(2,4),(0,0)) | 0 + <(1,3),5> | ((3,1),(3,3),(1,0)) | 0 + <(1,3),5> | ((1,2),(3,4),(5,6),(7,8)) | 0 + <(1,3),5> | ((7,8),(5,6),(3,4),(1,2)) | 0 + <(1,3),5> | ((1,2),(7,8),(5,6),(3,-4)) | 0 + <(1,3),5> | ((0,0)) | 0 + <(1,3),5> | ((0,1),(0,1)) | 0 + <(1,2),3> | ((2,0),(2,4),(0,0)) | 0 + <(1,2),3> | ((3,1),(3,3),(1,0)) | 0 + <(1,2),3> | ((1,2),(3,4),(5,6),(7,8)) | 0 + <(1,2),3> | ((7,8),(5,6),(3,4),(1,2)) | 0 + <(1,2),3> | ((1,2),(7,8),(5,6),(3,-4)) | 0 + <(1,2),3> | ((0,0)) | 0 + <(1,2),3> | ((0,1),(0,1)) | 0 + <(100,200),10> | ((2,0),(2,4),(0,0)) | 209.134661795 + <(100,200),10> | ((3,1),(3,3),(1,0)) | 209.585974051 + <(100,200),10> | ((1,2),(3,4),(5,6),(7,8)) | 203.337760371 + <(100,200),10> | ((7,8),(5,6),(3,4),(1,2)) | 203.337760371 + <(100,200),10> | ((1,2),(7,8),(5,6),(3,-4)) | 203.337760371 + <(100,200),10> | ((0,0)) | 213.60679775 + <(100,200),10> | ((0,1),(0,1)) | 212.712819568 + <(100,1),115> | ((2,0),(2,4),(0,0)) | 0 + <(100,1),115> | ((3,1),(3,3),(1,0)) | 0 + <(100,1),115> | ((1,2),(3,4),(5,6),(7,8)) | 0 + <(100,1),115> | ((7,8),(5,6),(3,4),(1,2)) | 0 + <(100,1),115> | ((1,2),(7,8),(5,6),(3,-4)) | 0 + <(100,1),115> | ((0,0)) | 0 + <(100,1),115> | ((0,1),(0,1)) | 0 + <(3,5),0> | ((2,0),(2,4),(0,0)) | 1.41421356237 + <(3,5),0> | ((3,1),(3,3),(1,0)) | 2 + <(3,5),0> | ((1,2),(3,4),(5,6),(7,8)) | 0.707106781187 + <(3,5),0> | ((7,8),(5,6),(3,4),(1,2)) | 0.707106781187 + <(3,5),0> | ((1,2),(7,8),(5,6),(3,-4)) | 0.707106781187 + <(3,5),0> | ((0,0)) | 5.83095189485 + <(3,5),0> | ((0,1),(0,1)) | 5 + <(3,5),NaN> | ((2,0),(2,4),(0,0)) | NaN + <(3,5),NaN> | ((3,1),(3,3),(1,0)) | NaN + <(3,5),NaN> | ((1,2),(3,4),(5,6),(7,8)) | NaN + <(3,5),NaN> | ((7,8),(5,6),(3,4),(1,2)) | NaN + <(3,5),NaN> | ((1,2),(7,8),(5,6),(3,-4)) | NaN + <(3,5),NaN> | ((0,0)) | NaN + <(3,5),NaN> | ((0,1),(0,1)) | NaN +(56 rows) + |