mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-13 17:39:36 +02:00
ed5003c584
ends to clean up (see my message of same date to pghackers), but mostly it works. INITDB REQUIRED!
533 lines
21 KiB
Plaintext
533 lines
21 KiB
Plaintext
--
|
|
-- GEOMETRY
|
|
--
|
|
--
|
|
-- Points
|
|
--
|
|
SELECT '' AS four, center(f1) AS center
|
|
FROM BOX_TBL;
|
|
four | center
|
|
------+---------
|
|
| (1,1)
|
|
| (2,2)
|
|
| (2.5,3)
|
|
| (3,3)
|
|
(4 rows)
|
|
|
|
SELECT '' AS four, (@@ f1) AS center
|
|
FROM BOX_TBL;
|
|
four | center
|
|
------+---------
|
|
| (1,1)
|
|
| (2,2)
|
|
| (2.5,3)
|
|
| (3,3)
|
|
(4 rows)
|
|
|
|
SELECT '' AS six, point(f1) AS center
|
|
FROM CIRCLE_TBL;
|
|
six | center
|
|
-----+-----------
|
|
| (0,0)
|
|
| (1,2)
|
|
| (1,3)
|
|
| (1,2)
|
|
| (100,200)
|
|
| (100,0)
|
|
(6 rows)
|
|
|
|
SELECT '' AS six, (@@ f1) AS center
|
|
FROM CIRCLE_TBL;
|
|
six | center
|
|
-----+-----------
|
|
| (0,0)
|
|
| (1,2)
|
|
| (1,3)
|
|
| (1,2)
|
|
| (100,200)
|
|
| (100,0)
|
|
(6 rows)
|
|
|
|
SELECT '' AS two, (@@ f1) AS center
|
|
FROM POLYGON_TBL
|
|
WHERE (# f1) > 2;
|
|
two | center
|
|
-----+-------------------------------------
|
|
| (1.33333333333333,1.33333333333333)
|
|
| (2.33333333333333,1.33333333333333)
|
|
(2 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)
|
|
(2 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)
|
|
(2 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)
|
|
|
|
--
|
|
-- Line segments
|
|
--
|
|
-- intersection
|
|
SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
|
|
FROM LSEG_TBL l, POINT_TBL p;
|
|
ERROR: Unable to identify an operator '#' for types 'lseg' and 'point'
|
|
You will have to retype this query using an explicit cast
|
|
-- closest point
|
|
SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
|
|
FROM LSEG_TBL l, POINT_TBL p;
|
|
thirty | f1 | s | closest
|
|
--------+------------+-------------------------------+---------------------------------------
|
|
| (0,0) | [(1,2),(3,4)] | (1,2)
|
|
| (-10,0) | [(1,2),(3,4)] | (1,2)
|
|
| (-3,4) | [(1,2),(3,4)] | (1,2)
|
|
| (5.1,34.5) | [(1,2),(3,4)] | (3,4)
|
|
| (-5,-12) | [(1,2),(3,4)] | (1,2)
|
|
| (10,10) | [(1,2),(3,4)] | (3,4)
|
|
| (0,0) | [(0,0),(6,6)] | (-0,0)
|
|
| (-10,0) | [(0,0),(6,6)] | (0,0)
|
|
| (-3,4) | [(0,0),(6,6)] | (0.5,0.5)
|
|
| (5.1,34.5) | [(0,0),(6,6)] | (6,6)
|
|
| (-5,-12) | [(0,0),(6,6)] | (0,0)
|
|
| (10,10) | [(0,0),(6,6)] | (6,6)
|
|
| (0,0) | [(10,-10),(-3,-4)] | (-2.04878048780488,-4.4390243902439)
|
|
| (-10,0) | [(10,-10),(-3,-4)] | (-3,-4)
|
|
| (-3,4) | [(10,-10),(-3,-4)] | (-3,-4)
|
|
| (5.1,34.5) | [(10,-10),(-3,-4)] | (-3,-4)
|
|
| (-5,-12) | [(10,-10),(-3,-4)] | (-1.60487804878049,-4.64390243902439)
|
|
| (10,10) | [(10,-10),(-3,-4)] | (2.39024390243902,-6.48780487804878)
|
|
| (0,0) | [(-1000000,200),(300000,-40)] | (0.0028402365895872,15.384614860264)
|
|
| (-10,0) | [(-1000000,200),(300000,-40)] | (-9.99715942258202,15.3864610140473)
|
|
| (-3,4) | [(-1000000,200),(300000,-40)] | (-2.99789812267519,15.3851688427303)
|
|
| (5.1,34.5) | [(-1000000,200),(300000,-40)] | (5.09647083221496,15.3836744976925)
|
|
| (-5,-12) | [(-1000000,200),(300000,-40)] | (-4.99494420845634,15.3855375281616)
|
|
| (10,10) | [(-1000000,200),(300000,-40)] | (10.000993741978,15.3827690473092)
|
|
| (0,0) | [(11,22),(33,44)] | (11,22)
|
|
| (-10,0) | [(11,22),(33,44)] | (11,22)
|
|
| (-3,4) | [(11,22),(33,44)] | (11,22)
|
|
| (5.1,34.5) | [(11,22),(33,44)] | (14.3,25.3)
|
|
| (-5,-12) | [(11,22),(33,44)] | (11,22)
|
|
| (10,10) | [(11,22),(33,44)] | (11,22)
|
|
(30 rows)
|
|
|
|
--
|
|
-- Lines
|
|
--
|
|
--
|
|
-- Boxes
|
|
--
|
|
SELECT '' as six, box(f1) AS box FROM CIRCLE_TBL;
|
|
six | box
|
|
-----+----------------------------------------------------------------------------
|
|
| (2.12132034355964,2.12132034355964),(-2.12132034355964,-2.12132034355964)
|
|
| (71.7106781186548,72.7106781186548),(-69.7106781186548,-68.7106781186548)
|
|
| (4.53553390593274,6.53553390593274),(-2.53553390593274,-0.535533905932738)
|
|
| (3.12132034355964,4.12132034355964),(-1.12132034355964,-0.121320343559643)
|
|
| (107.071067811865,207.071067811865),(92.9289321881345,192.928932188135)
|
|
| (170.710678118655,70.7106781186548),(29.2893218813452,-70.7106781186548)
|
|
(6 rows)
|
|
|
|
-- translation
|
|
SELECT '' AS twentyfour, b.f1 + p.f1 AS translation
|
|
FROM BOX_TBL b, POINT_TBL p;
|
|
twentyfour | translation
|
|
------------+-------------------------
|
|
| (2,2),(0,0)
|
|
| (-8,2),(-10,0)
|
|
| (-1,6),(-3,4)
|
|
| (7.1,36.5),(5.1,34.5)
|
|
| (-3,-10),(-5,-12)
|
|
| (12,12),(10,10)
|
|
| (3,3),(1,1)
|
|
| (-7,3),(-9,1)
|
|
| (0,7),(-2,5)
|
|
| (8.1,37.5),(6.1,35.5)
|
|
| (-2,-9),(-4,-11)
|
|
| (13,13),(11,11)
|
|
| (2.5,3.5),(2.5,2.5)
|
|
| (-7.5,3.5),(-7.5,2.5)
|
|
| (-0.5,7.5),(-0.5,6.5)
|
|
| (7.6,38),(7.6,37)
|
|
| (-2.5,-8.5),(-2.5,-9.5)
|
|
| (12.5,13.5),(12.5,12.5)
|
|
| (3,3),(3,3)
|
|
| (-7,3),(-7,3)
|
|
| (0,7),(0,7)
|
|
| (8.1,37.5),(8.1,37.5)
|
|
| (-2,-9),(-2,-9)
|
|
| (13,13),(13,13)
|
|
(24 rows)
|
|
|
|
SELECT '' AS twentyfour, b.f1 - p.f1 AS translation
|
|
FROM BOX_TBL b, POINT_TBL p;
|
|
twentyfour | translation
|
|
------------+---------------------------
|
|
| (2,2),(0,0)
|
|
| (12,2),(10,0)
|
|
| (5,-2),(3,-4)
|
|
| (-3.1,-32.5),(-5.1,-34.5)
|
|
| (7,14),(5,12)
|
|
| (-8,-8),(-10,-10)
|
|
| (3,3),(1,1)
|
|
| (13,3),(11,1)
|
|
| (6,-1),(4,-3)
|
|
| (-2.1,-31.5),(-4.1,-33.5)
|
|
| (8,15),(6,13)
|
|
| (-7,-7),(-9,-9)
|
|
| (2.5,3.5),(2.5,2.5)
|
|
| (12.5,3.5),(12.5,2.5)
|
|
| (5.5,-0.5),(5.5,-1.5)
|
|
| (-2.6,-31),(-2.6,-32)
|
|
| (7.5,15.5),(7.5,14.5)
|
|
| (-7.5,-6.5),(-7.5,-7.5)
|
|
| (3,3),(3,3)
|
|
| (13,3),(13,3)
|
|
| (6,-1),(6,-1)
|
|
| (-2.1,-31.5),(-2.1,-31.5)
|
|
| (8,15),(8,15)
|
|
| (-7,-7),(-7,-7)
|
|
(24 rows)
|
|
|
|
-- scaling and rotation
|
|
SELECT '' AS twentyfour, b.f1 * p.f1 AS rotation
|
|
FROM BOX_TBL b, POINT_TBL p;
|
|
twentyfour | rotation
|
|
------------+-----------------------------
|
|
| (0,0),(0,0)
|
|
| (-0,0),(-20,-20)
|
|
| (-0,2),(-14,0)
|
|
| (0,79.2),(-58.8,0)
|
|
| (14,-0),(0,-34)
|
|
| (0,40),(0,0)
|
|
| (0,0),(0,0)
|
|
| (-10,-10),(-30,-30)
|
|
| (-7,3),(-21,1)
|
|
| (-29.4,118.8),(-88.2,39.6)
|
|
| (21,-17),(7,-51)
|
|
| (0,60),(0,20)
|
|
| (0,0),(0,0)
|
|
| (-25,-25),(-25,-35)
|
|
| (-17.5,2.5),(-21.5,-0.5)
|
|
| (-73.5,104.1),(-108,99)
|
|
| (29.5,-42.5),(17.5,-47.5)
|
|
| (0,60),(-10,50)
|
|
| (0,0),(0,0)
|
|
| (-30,-30),(-30,-30)
|
|
| (-21,3),(-21,3)
|
|
| (-88.2,118.8),(-88.2,118.8)
|
|
| (21,-51),(21,-51)
|
|
| (0,60),(0,60)
|
|
(24 rows)
|
|
|
|
SELECT '' AS twenty, b.f1 / p.f1 AS rotation
|
|
FROM BOX_TBL b, POINT_TBL p
|
|
WHERE (p.f1 <-> point '(0,0)') >= 1;
|
|
twenty | rotation
|
|
--------+-----------------------------------------------------------------------------------
|
|
| (0,-0),(-0.2,-0.2)
|
|
| (-0.1,-0.1),(-0.3,-0.3)
|
|
| (-0.25,-0.25),(-0.25,-0.35)
|
|
| (-0.3,-0.3),(-0.3,-0.3)
|
|
| (0.08,-0),(0,-0.56)
|
|
| (0.12,-0.28),(0.04,-0.84)
|
|
| (0.26,-0.7),(0.1,-0.82)
|
|
| (0.12,-0.84),(0.12,-0.84)
|
|
| (0.0651176557643925,0),(0,-0.0483449262493217)
|
|
| (0.0976764836465887,-0.0241724631246608),(0.0325588278821962,-0.0725173893739825)
|
|
| (0.109762715208919,-0.0562379754328844),(0.0813970697054906,-0.0604311578116521)
|
|
| (0.0976764836465887,-0.0725173893739825),(0.0976764836465887,-0.0725173893739825)
|
|
| (-0,0.0828402366863905),(-0.201183431952663,0)
|
|
| (-0.100591715976331,0.124260355029586),(-0.301775147928994,0.0414201183431953)
|
|
| (-0.251479289940828,0.103550295857988),(-0.322485207100592,0.0739644970414201)
|
|
| (-0.301775147928994,0.124260355029586),(-0.301775147928994,0.124260355029586)
|
|
| (0.2,0),(0,0)
|
|
| (0.3,0),(0.1,0)
|
|
| (0.3,0.05),(0.25,0)
|
|
| (0.3,0),(0.3,0)
|
|
(20 rows)
|
|
|
|
--
|
|
-- Paths
|
|
--
|
|
SET geqo TO 'off';
|
|
SELECT '' AS eight, npoints(f1) AS npoints, f1 AS path FROM PATH_TBL;
|
|
eight | npoints | path
|
|
-------+---------+---------------------------
|
|
| 2 | [(1,2),(3,4)]
|
|
| 2 | ((1,2),(3,4))
|
|
| 4 | [(0,0),(3,0),(4,5),(1,6)]
|
|
| 2 | ((1,2),(3,4))
|
|
| 2 | ((1,2),(3,4))
|
|
| 2 | [(1,2),(3,4)]
|
|
| 2 | [(11,12),(13,14)]
|
|
| 2 | ((11,12),(13,14))
|
|
(8 rows)
|
|
|
|
SELECT '' AS four, path(f1) FROM POLYGON_TBL;
|
|
four | path
|
|
------+---------------------
|
|
| ((2,0),(2,4),(0,0))
|
|
| ((3,1),(3,3),(1,0))
|
|
| ((0,0))
|
|
| ((0,1),(0,1))
|
|
(4 rows)
|
|
|
|
-- translation
|
|
SELECT '' AS eight, p1.f1 + point '(10,10)' AS dist_add
|
|
FROM PATH_TBL p1;
|
|
eight | dist_add
|
|
-------+-----------------------------------
|
|
| [(11,12),(13,14)]
|
|
| ((11,12),(13,14))
|
|
| [(10,10),(13,10),(14,15),(11,16)]
|
|
| ((11,12),(13,14))
|
|
| ((11,12),(13,14))
|
|
| [(11,12),(13,14)]
|
|
| [(21,22),(23,24)]
|
|
| ((21,22),(23,24))
|
|
(8 rows)
|
|
|
|
-- scaling and rotation
|
|
SELECT '' AS eight, p1.f1 * point '(2,-1)' AS dist_mul
|
|
FROM PATH_TBL p1;
|
|
eight | dist_mul
|
|
-------+------------------------------
|
|
| [(4,3),(10,5)]
|
|
| ((4,3),(10,5))
|
|
| [(0,0),(6,-3),(13,6),(8,11)]
|
|
| ((4,3),(10,5))
|
|
| ((4,3),(10,5))
|
|
| [(4,3),(10,5)]
|
|
| [(34,13),(40,15)]
|
|
| ((34,13),(40,15))
|
|
(8 rows)
|
|
|
|
RESET geqo;
|
|
--
|
|
-- 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
|
|
| (-10,0) | ((2,0),(2,4),(0,0)) | f
|
|
| (-3,4) | ((2,0),(2,4),(0,0)) | f
|
|
| (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
|
|
| (-5,-12) | ((2,0),(2,4),(0,0)) | f
|
|
| (10,10) | ((2,0),(2,4),(0,0)) | f
|
|
| (0,0) | ((3,1),(3,3),(1,0)) | f
|
|
| (-10,0) | ((3,1),(3,3),(1,0)) | f
|
|
| (-3,4) | ((3,1),(3,3),(1,0)) | f
|
|
| (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
|
|
| (-5,-12) | ((3,1),(3,3),(1,0)) | f
|
|
| (10,10) | ((3,1),(3,3),(1,0)) | f
|
|
| (0,0) | ((0,0)) | t
|
|
| (-10,0) | ((0,0)) | f
|
|
| (-3,4) | ((0,0)) | f
|
|
| (5.1,34.5) | ((0,0)) | f
|
|
| (-5,-12) | ((0,0)) | f
|
|
| (10,10) | ((0,0)) | f
|
|
| (0,0) | ((0,1),(0,1)) | f
|
|
| (-10,0) | ((0,1),(0,1)) | f
|
|
| (-3,4) | ((0,1),(0,1)) | f
|
|
| (5.1,34.5) | ((0,1),(0,1)) | f
|
|
| (-5,-12) | ((0,1),(0,1)) | f
|
|
| (10,10) | ((0,1),(0,1)) | f
|
|
(24 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
|
|
| (-10,0) | ((2,0),(2,4),(0,0)) | f
|
|
| (-3,4) | ((2,0),(2,4),(0,0)) | f
|
|
| (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
|
|
| (-5,-12) | ((2,0),(2,4),(0,0)) | f
|
|
| (10,10) | ((2,0),(2,4),(0,0)) | f
|
|
| (0,0) | ((3,1),(3,3),(1,0)) | f
|
|
| (-10,0) | ((3,1),(3,3),(1,0)) | f
|
|
| (-3,4) | ((3,1),(3,3),(1,0)) | f
|
|
| (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
|
|
| (-5,-12) | ((3,1),(3,3),(1,0)) | f
|
|
| (10,10) | ((3,1),(3,3),(1,0)) | f
|
|
| (0,0) | ((0,0)) | t
|
|
| (-10,0) | ((0,0)) | f
|
|
| (-3,4) | ((0,0)) | f
|
|
| (5.1,34.5) | ((0,0)) | f
|
|
| (-5,-12) | ((0,0)) | f
|
|
| (10,10) | ((0,0)) | f
|
|
| (0,0) | ((0,1),(0,1)) | f
|
|
| (-10,0) | ((0,1),(0,1)) | f
|
|
| (-3,4) | ((0,1),(0,1)) | f
|
|
| (5.1,34.5) | ((0,1),(0,1)) | f
|
|
| (-5,-12) | ((0,1),(0,1)) | f
|
|
| (10,10) | ((0,1),(0,1)) | f
|
|
(24 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))
|
|
| 1 | ((0,0))
|
|
| 2 | ((0,1),(0,1))
|
|
(4 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))
|
|
| ((2.5,2.5),(2.5,3.5),(2.5,3.5),(2.5,2.5))
|
|
| ((3,3),(3,3),(3,3),(3,3))
|
|
(4 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))
|
|
| ((11,12),(13,14))
|
|
(4 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)
|
|
|
|
-- convert circles to polygons using the default number of points
|
|
SELECT '' AS six, polygon(f1)
|
|
FROM CIRCLE_TBL;
|
|
six | polygon
|
|
-----+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
| ((-3,0),(-2.59807621135332,1.5),(-1.5,2.59807621135332),(-1.83690953073357e-16,3),(1.5,2.59807621135332),(2.59807621135332,1.5),(3,3.67381906146713e-16),(2.59807621135332,-1.5),(1.5,-2.59807621135332),(5.5107285922007e-16,-3),(-1.5,-2.59807621135332),(-2.59807621135332,-1.5))
|
|
| ((-99,2),(-85.6025403784439,52),(-49,88.6025403784439),(0.999999999999994,102),(51,88.6025403784439),(87.6025403784439,52),(101,2.00000000000001),(87.6025403784439,-48),(51,-84.6025403784438),(1.00000000000002,-98),(-49,-84.6025403784439),(-85.6025403784438,-48))
|
|
| ((-4,3),(-3.33012701892219,5.5),(-1.5,7.33012701892219),(1,8),(3.5,7.33012701892219),(5.33012701892219,5.5),(6,3),(5.33012701892219,0.500000000000001),(3.5,-1.33012701892219),(1,-2),(-1.5,-1.33012701892219),(-3.33012701892219,0.499999999999998))
|
|
| ((-2,2),(-1.59807621135332,3.5),(-0.5,4.59807621135332),(1,5),(2.5,4.59807621135332),(3.59807621135332,3.5),(4,2),(3.59807621135332,0.500000000000001),(2.5,-0.598076211353315),(1,-1),(-0.5,-0.598076211353316),(-1.59807621135332,0.499999999999999))
|
|
| ((90,200),(91.3397459621556,205),(95,208.660254037844),(100,210),(105,208.660254037844),(108.660254037844,205),(110,200),(108.660254037844,195),(105,191.339745962156),(100,190),(95,191.339745962156),(91.3397459621556,195))
|
|
| ((0,0),(13.3974596215561,50),(50,86.6025403784439),(100,100),(150,86.6025403784439),(186.602540378444,50),(200,1.22460635382238e-14),(186.602540378444,-50),(150,-86.6025403784438),(100,-100),(50,-86.6025403784439),(13.3974596215562,-50))
|
|
(6 rows)
|
|
|
|
-- convert the circle to an 8-point polygon
|
|
SELECT '' AS six, polygon(8, f1)
|
|
FROM CIRCLE_TBL;
|
|
six | polygon
|
|
-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
| ((-3,0),(-2.12132034355964,2.12132034355964),(-1.83690953073357e-16,3),(2.12132034355964,2.12132034355964),(3,3.67381906146713e-16),(2.12132034355964,-2.12132034355964),(5.5107285922007e-16,-3),(-2.12132034355964,-2.12132034355964))
|
|
| ((-99,2),(-69.7106781186548,72.7106781186548),(0.999999999999994,102),(71.7106781186547,72.7106781186548),(101,2.00000000000001),(71.7106781186548,-68.7106781186547),(1.00000000000002,-98),(-69.7106781186547,-68.7106781186548))
|
|
| ((-4,3),(-2.53553390593274,6.53553390593274),(1,8),(4.53553390593274,6.53553390593274),(6,3),(4.53553390593274,-0.535533905932737),(1,-2),(-2.53553390593274,-0.535533905932738))
|
|
| ((-2,2),(-1.12132034355964,4.12132034355964),(1,5),(3.12132034355964,4.12132034355964),(4,2),(3.12132034355964,-0.121320343559642),(1,-1),(-1.12132034355964,-0.121320343559643))
|
|
| ((90,200),(92.9289321881345,207.071067811865),(100,210),(107.071067811865,207.071067811865),(110,200),(107.071067811865,192.928932188135),(100,190),(92.9289321881345,192.928932188135))
|
|
| ((0,0),(29.2893218813452,70.7106781186548),(100,100),(170.710678118655,70.7106781186548),(200,1.22460635382238e-14),(170.710678118655,-70.7106781186547),(100,-100),(29.2893218813453,-70.7106781186548))
|
|
(6 rows)
|
|
|
|
--
|
|
-- 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>
|
|
| <(10,10),50>
|
|
(6 rows)
|
|
|
|
SELECT '' AS four, circle(f1)
|
|
FROM BOX_TBL;
|
|
four | circle
|
|
------+-------------------------
|
|
| <(1,1),1.4142135623731>
|
|
| <(2,2),1.4142135623731>
|
|
| <(2.5,3),0.5>
|
|
| <(3,3),0>
|
|
(4 rows)
|
|
|
|
SELECT '' AS two, circle(f1)
|
|
FROM POLYGON_TBL
|
|
WHERE (# f1) >= 3;
|
|
two | circle
|
|
-----+--------------------------------------------------------
|
|
| <(1.33333333333333,1.33333333333333),2.04168905063636>
|
|
| <(2.33333333333333,1.33333333333333),1.47534300379185>
|
|
(2 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, circle, point using <<;
|
|
twentyfour | circle | point | distance
|
|
------------+----------------+------------+-------------------
|
|
| <(100,0),100> | (5.1,34.5) | 0.976531926977964
|
|
| <(1,2),3> | (-3,4) | 1.47213595499958
|
|
| <(0,0),3> | (-3,4) | 2
|
|
| <(100,0),100> | (-3,4) | 3.07764064044151
|
|
| <(100,0),100> | (-5,-12) | 5.68348972285122
|
|
| <(1,3),5> | (-10,0) | 6.40175425099138
|
|
| <(1,3),5> | (10,10) | 6.40175425099138
|
|
| <(0,0),3> | (-10,0) | 7
|
|
| <(1,2),3> | (-10,0) | 8.18033988749895
|
|
| <(1,2),3> | (10,10) | 9.0415945787923
|
|
| <(0,0),3> | (-5,-12) | 10
|
|
| <(100,0),100> | (-10,0) | 10
|
|
| <(0,0),3> | (10,10) | 11.142135623731
|
|
| <(1,3),5> | (-5,-12) | 11.1554944214035
|
|
| <(1,2),3> | (-5,-12) | 12.2315462117278
|
|
| <(1,3),5> | (5.1,34.5) | 26.7657047773224
|
|
| <(1,2),3> | (5.1,34.5) | 29.757594539282
|
|
| <(0,0),3> | (5.1,34.5) | 31.8749193547455
|
|
| <(100,200),10> | (5.1,34.5) | 180.778038568384
|
|
| <(100,200),10> | (10,10) | 200.237960416286
|
|
| <(100,200),10> | (-3,4) | 211.415898254845
|
|
| <(100,200),10> | (0,0) | 213.606797749979
|
|
| <(100,200),10> | (-10,0) | 218.254244210267
|
|
| <(100,200),10> | (-5,-12) | 226.577682802077
|
|
(24 rows)
|
|
|