2000-01-05 07:06:23 +01:00
|
|
|
--
|
|
|
|
-- CIRCLE
|
|
|
|
--
|
|
|
|
CREATE TABLE CIRCLE_TBL (f1 circle);
|
2002-11-08 21:09:55 +01:00
|
|
|
INSERT INTO CIRCLE_TBL VALUES ('<(5,1),3>');
|
2000-01-05 07:06:23 +01:00
|
|
|
INSERT INTO CIRCLE_TBL VALUES ('<(1,2),100>');
|
|
|
|
INSERT INTO CIRCLE_TBL VALUES ('1,3,5');
|
|
|
|
INSERT INTO CIRCLE_TBL VALUES ('((1,2),3)');
|
|
|
|
INSERT INTO CIRCLE_TBL VALUES ('<(100,200),10>');
|
2002-11-08 21:09:55 +01:00
|
|
|
INSERT INTO CIRCLE_TBL VALUES ('<(100,1),115>');
|
2000-01-05 07:06:23 +01:00
|
|
|
-- bad values
|
|
|
|
INSERT INTO CIRCLE_TBL VALUES ('<(-100,0),-100>');
|
1998-01-05 04:35:55 +01:00
|
|
|
ERROR: Bad circle external representation '<(-100,0),-100>'
|
2000-01-05 07:06:23 +01:00
|
|
|
INSERT INTO CIRCLE_TBL VALUES ('1abc,3,5');
|
1998-01-05 04:35:55 +01:00
|
|
|
ERROR: Bad circle external representation '1abc,3,5'
|
2000-01-05 07:06:23 +01:00
|
|
|
INSERT INTO CIRCLE_TBL VALUES ('(3,(1,2),3)');
|
1998-01-05 04:35:55 +01:00
|
|
|
ERROR: Bad circle external representation '(3,(1,2),3)'
|
2000-01-05 07:06:23 +01:00
|
|
|
SELECT * FROM CIRCLE_TBL;
|
|
|
|
f1
|
|
|
|
----------------
|
2002-11-08 21:09:55 +01:00
|
|
|
<(5,1),3>
|
2000-01-05 07:06:23 +01:00
|
|
|
<(1,2),100>
|
|
|
|
<(1,3),5>
|
|
|
|
<(1,2),3>
|
|
|
|
<(100,200),10>
|
2002-11-08 21:09:55 +01:00
|
|
|
<(100,1),115>
|
1997-05-11 17:42:09 +02:00
|
|
|
(6 rows)
|
|
|
|
|
2000-01-05 07:06:23 +01:00
|
|
|
SELECT '' AS six, center(f1) AS center
|
1997-05-11 17:42:09 +02:00
|
|
|
FROM CIRCLE_TBL;
|
2000-01-05 07:06:23 +01:00
|
|
|
six | center
|
|
|
|
-----+-----------
|
2002-11-08 21:09:55 +01:00
|
|
|
| (5,1)
|
2000-01-05 07:06:23 +01:00
|
|
|
| (1,2)
|
|
|
|
| (1,3)
|
|
|
|
| (1,2)
|
|
|
|
| (100,200)
|
2002-11-08 21:09:55 +01:00
|
|
|
| (100,1)
|
1997-05-11 17:42:09 +02:00
|
|
|
(6 rows)
|
|
|
|
|
2000-01-05 07:06:23 +01:00
|
|
|
SELECT '' AS six, radius(f1) AS radius
|
1997-05-11 17:42:09 +02:00
|
|
|
FROM CIRCLE_TBL;
|
2000-01-05 07:06:23 +01:00
|
|
|
six | radius
|
|
|
|
-----+--------
|
|
|
|
| 3
|
|
|
|
| 100
|
|
|
|
| 5
|
|
|
|
| 3
|
|
|
|
| 10
|
2002-11-08 21:09:55 +01:00
|
|
|
| 115
|
1997-05-11 17:42:09 +02:00
|
|
|
(6 rows)
|
|
|
|
|
2000-01-05 07:06:23 +01:00
|
|
|
SELECT '' AS six, diameter(f1) AS diameter
|
1997-05-11 17:42:09 +02:00
|
|
|
FROM CIRCLE_TBL;
|
2000-01-05 07:06:23 +01:00
|
|
|
six | diameter
|
|
|
|
-----+----------
|
|
|
|
| 6
|
|
|
|
| 200
|
|
|
|
| 10
|
|
|
|
| 6
|
|
|
|
| 20
|
2002-11-08 21:09:55 +01:00
|
|
|
| 230
|
1997-05-11 17:42:09 +02:00
|
|
|
(6 rows)
|
|
|
|
|
2000-01-05 07:06:23 +01:00
|
|
|
SELECT '' AS two, f1 FROM CIRCLE_TBL WHERE radius(f1) < 5;
|
|
|
|
two | f1
|
|
|
|
-----+-----------
|
2002-11-08 21:09:55 +01:00
|
|
|
| <(5,1),3>
|
2000-01-05 07:06:23 +01:00
|
|
|
| <(1,2),3>
|
1997-05-11 17:42:09 +02:00
|
|
|
(2 rows)
|
|
|
|
|
2000-01-05 07:06:23 +01:00
|
|
|
SELECT '' AS four, f1 FROM CIRCLE_TBL WHERE diameter(f1) >= 10;
|
|
|
|
four | f1
|
|
|
|
------+----------------
|
|
|
|
| <(1,2),100>
|
|
|
|
| <(1,3),5>
|
|
|
|
| <(100,200),10>
|
2002-11-08 21:09:55 +01:00
|
|
|
| <(100,1),115>
|
1997-05-11 17:42:09 +02:00
|
|
|
(4 rows)
|
|
|
|
|
2000-01-05 07:06:23 +01:00
|
|
|
SELECT '' as five, c1.f1 AS one, c2.f1 AS two, (c1.f1 <-> c2.f1) AS distance
|
1997-05-11 17:42:09 +02:00
|
|
|
FROM CIRCLE_TBL c1, CIRCLE_TBL c2
|
1997-07-29 18:24:04 +02:00
|
|
|
WHERE (c1.f1 < c2.f1) AND ((c1.f1 <-> c2.f1) > 0)
|
1997-05-11 17:42:09 +02:00
|
|
|
ORDER BY distance, one, two;
|
2000-01-05 07:06:23 +01:00
|
|
|
five | one | two | distance
|
|
|
|
------+----------------+----------------+------------------
|
2002-11-08 21:09:55 +01:00
|
|
|
| <(100,200),10> | <(100,1),115> | 74
|
2000-01-05 07:06:23 +01:00
|
|
|
| <(100,200),10> | <(1,2),100> | 111.370729772479
|
|
|
|
| <(1,3),5> | <(100,200),10> | 205.476756144497
|
2002-11-08 21:09:55 +01:00
|
|
|
| <(5,1),3> | <(100,200),10> | 207.51303816328
|
2000-01-05 07:06:23 +01:00
|
|
|
| <(1,2),3> | <(100,200),10> | 208.370729772479
|
1997-05-11 17:42:09 +02:00
|
|
|
(5 rows)
|
|
|
|
|