~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/geometry_2.out

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- GEOMETRY
 
3
--
 
4
-- Back off displayed precision a little bit to reduce platform-to-platform
 
5
-- variation in results.
 
6
SET extra_float_digits TO -3;
 
7
--
 
8
-- Points
 
9
--
 
10
SELECT '' AS four, center(f1) AS center
 
11
   FROM BOX_TBL;
 
12
 four | center  
 
13
------+---------
 
14
      | (1,1)
 
15
      | (2,2)
 
16
      | (2.5,3)
 
17
      | (3,3)
 
18
(4 rows)
 
19
 
 
20
SELECT '' AS four, (@@ f1) AS center
 
21
   FROM BOX_TBL;
 
22
 four | center  
 
23
------+---------
 
24
      | (1,1)
 
25
      | (2,2)
 
26
      | (2.5,3)
 
27
      | (3,3)
 
28
(4 rows)
 
29
 
 
30
SELECT '' AS six, point(f1) AS center
 
31
   FROM CIRCLE_TBL;
 
32
 six |  center   
 
33
-----+-----------
 
34
     | (5,1)
 
35
     | (1,2)
 
36
     | (1,3)
 
37
     | (1,2)
 
38
     | (100,200)
 
39
     | (100,1)
 
40
(6 rows)
 
41
 
 
42
SELECT '' AS six, (@@ f1) AS center
 
43
   FROM CIRCLE_TBL;
 
44
 six |  center   
 
45
-----+-----------
 
46
     | (5,1)
 
47
     | (1,2)
 
48
     | (1,3)
 
49
     | (1,2)
 
50
     | (100,200)
 
51
     | (100,1)
 
52
(6 rows)
 
53
 
 
54
SELECT '' AS two, (@@ f1) AS center
 
55
   FROM POLYGON_TBL
 
56
   WHERE (# f1) > 2;
 
57
 two |            center             
 
58
-----+-------------------------------
 
59
     | (1.33333333333,1.33333333333)
 
60
     | (2.33333333333,1.33333333333)
 
61
(2 rows)
 
62
 
 
63
-- "is horizontal" function
 
64
SELECT '' AS two, p1.f1
 
65
   FROM POINT_TBL p1
 
66
   WHERE ishorizontal(p1.f1, point '(0,0)');
 
67
 two |   f1    
 
68
-----+---------
 
69
     | (0,0)
 
70
     | (-10,0)
 
71
(2 rows)
 
72
 
 
73
-- "is horizontal" operator
 
74
SELECT '' AS two, p1.f1
 
75
   FROM POINT_TBL p1
 
76
   WHERE p1.f1 ?- point '(0,0)';
 
77
 two |   f1    
 
78
-----+---------
 
79
     | (0,0)
 
80
     | (-10,0)
 
81
(2 rows)
 
82
 
 
83
-- "is vertical" function
 
84
SELECT '' AS one, p1.f1
 
85
   FROM POINT_TBL p1
 
86
   WHERE isvertical(p1.f1, point '(5.1,34.5)');
 
87
 one |     f1     
 
88
-----+------------
 
89
     | (5.1,34.5)
 
90
(1 row)
 
91
 
 
92
-- "is vertical" operator
 
93
SELECT '' AS one, p1.f1
 
94
   FROM POINT_TBL p1
 
95
   WHERE p1.f1 ?| point '(5.1,34.5)';
 
96
 one |     f1     
 
97
-----+------------
 
98
     | (5.1,34.5)
 
99
(1 row)
 
100
 
 
101
--
 
102
-- Line segments
 
103
--
 
104
-- intersection
 
105
SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
 
106
   FROM LSEG_TBL l, POINT_TBL p;
 
107
ERROR:  operator does not exist: lseg # point
 
108
HINT:  No operator matches the given name and argument type(s). You may need to add explicit type casts.
 
109
-- closest point
 
110
SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
 
111
   FROM LSEG_TBL l, POINT_TBL p;
 
112
 thirty |     f1     |               s               |             closest              
 
113
--------+------------+-------------------------------+----------------------------------
 
114
        | (0,0)      | [(1,2),(3,4)]                 | (1,2)
 
115
        | (0,0)      | [(0,0),(6,6)]                 | (0,0)
 
116
        | (0,0)      | [(10,-10),(-3,-4)]            | (-2.0487804878,-4.43902439024)
 
117
        | (0,0)      | [(-1000000,200),(300000,-40)] | (0.00284023658959,15.3846148603)
 
118
        | (0,0)      | [(11,22),(33,44)]             | (11,22)
 
119
        | (-10,0)    | [(1,2),(3,4)]                 | (1,2)
 
120
        | (-10,0)    | [(0,0),(6,6)]                 | (0,0)
 
121
        | (-10,0)    | [(10,-10),(-3,-4)]            | (-3,-4)
 
122
        | (-10,0)    | [(-1000000,200),(300000,-40)] | (-9.99715942258,15.386461014)
 
123
        | (-10,0)    | [(11,22),(33,44)]             | (11,22)
 
124
        | (-3,4)     | [(1,2),(3,4)]                 | (1,2)
 
125
        | (-3,4)     | [(0,0),(6,6)]                 | (0.5,0.5)
 
126
        | (-3,4)     | [(10,-10),(-3,-4)]            | (-3,-4)
 
127
        | (-3,4)     | [(-1000000,200),(300000,-40)] | (-2.99789812268,15.3851688427)
 
128
        | (-3,4)     | [(11,22),(33,44)]             | (11,22)
 
129
        | (5.1,34.5) | [(1,2),(3,4)]                 | (3,4)
 
130
        | (5.1,34.5) | [(0,0),(6,6)]                 | (6,6)
 
131
        | (5.1,34.5) | [(10,-10),(-3,-4)]            | (-3,-4)
 
132
        | (5.1,34.5) | [(-1000000,200),(300000,-40)] | (5.09647083221,15.3836744977)
 
133
        | (5.1,34.5) | [(11,22),(33,44)]             | (14.3,25.3)
 
134
        | (-5,-12)   | [(1,2),(3,4)]                 | (1,2)
 
135
        | (-5,-12)   | [(0,0),(6,6)]                 | (0,0)
 
136
        | (-5,-12)   | [(10,-10),(-3,-4)]            | (-1.60487804878,-4.64390243902)
 
137
        | (-5,-12)   | [(-1000000,200),(300000,-40)] | (-4.99494420846,15.3855375282)
 
138
        | (-5,-12)   | [(11,22),(33,44)]             | (11,22)
 
139
        | (10,10)    | [(1,2),(3,4)]                 | (3,4)
 
140
        | (10,10)    | [(0,0),(6,6)]                 | (6,6)
 
141
        | (10,10)    | [(10,-10),(-3,-4)]            | (2.39024390244,-6.48780487805)
 
142
        | (10,10)    | [(-1000000,200),(300000,-40)] | (10.000993742,15.3827690473)
 
143
        | (10,10)    | [(11,22),(33,44)]             | (11,22)
 
144
(30 rows)
 
145
 
 
146
--
 
147
-- Lines
 
148
--
 
149
--
 
150
-- Boxes
 
151
--
 
152
SELECT '' as six, box(f1) AS box FROM CIRCLE_TBL;
 
153
 six |                              box                               
 
154
-----+----------------------------------------------------------------
 
155
     | (7.12132034356,3.12132034356),(2.87867965644,-1.12132034356)
 
156
     | (71.7106781187,72.7106781187),(-69.7106781187,-68.7106781187)
 
157
     | (4.53553390593,6.53553390593),(-2.53553390593,-0.535533905933)
 
158
     | (3.12132034356,4.12132034356),(-1.12132034356,-0.12132034356)
 
159
     | (107.071067812,207.071067812),(92.9289321881,192.928932188)
 
160
     | (181.317279836,82.3172798365),(18.6827201635,-80.3172798365)
 
161
(6 rows)
 
162
 
 
163
-- translation
 
164
SELECT '' AS twentyfour, b.f1 + p.f1 AS translation
 
165
   FROM BOX_TBL b, POINT_TBL p;
 
166
 twentyfour |       translation       
 
167
------------+-------------------------
 
168
            | (2,2),(0,0)
 
169
            | (3,3),(1,1)
 
170
            | (2.5,3.5),(2.5,2.5)
 
171
            | (3,3),(3,3)
 
172
            | (-8,2),(-10,0)
 
173
            | (-7,3),(-9,1)
 
174
            | (-7.5,3.5),(-7.5,2.5)
 
175
            | (-7,3),(-7,3)
 
176
            | (-1,6),(-3,4)
 
177
            | (0,7),(-2,5)
 
178
            | (-0.5,7.5),(-0.5,6.5)
 
179
            | (0,7),(0,7)
 
180
            | (7.1,36.5),(5.1,34.5)
 
181
            | (8.1,37.5),(6.1,35.5)
 
182
            | (7.6,38),(7.6,37)
 
183
            | (8.1,37.5),(8.1,37.5)
 
184
            | (-3,-10),(-5,-12)
 
185
            | (-2,-9),(-4,-11)
 
186
            | (-2.5,-8.5),(-2.5,-9.5)
 
187
            | (-2,-9),(-2,-9)
 
188
            | (12,12),(10,10)
 
189
            | (13,13),(11,11)
 
190
            | (12.5,13.5),(12.5,12.5)
 
191
            | (13,13),(13,13)
 
192
(24 rows)
 
193
 
 
194
SELECT '' AS twentyfour, b.f1 - p.f1 AS translation
 
195
   FROM BOX_TBL b, POINT_TBL p;
 
196
 twentyfour |        translation        
 
197
------------+---------------------------
 
198
            | (2,2),(0,0)
 
199
            | (3,3),(1,1)
 
200
            | (2.5,3.5),(2.5,2.5)
 
201
            | (3,3),(3,3)
 
202
            | (12,2),(10,0)
 
203
            | (13,3),(11,1)
 
204
            | (12.5,3.5),(12.5,2.5)
 
205
            | (13,3),(13,3)
 
206
            | (5,-2),(3,-4)
 
207
            | (6,-1),(4,-3)
 
208
            | (5.5,-0.5),(5.5,-1.5)
 
209
            | (6,-1),(6,-1)
 
210
            | (-3.1,-32.5),(-5.1,-34.5)
 
211
            | (-2.1,-31.5),(-4.1,-33.5)
 
212
            | (-2.6,-31),(-2.6,-32)
 
213
            | (-2.1,-31.5),(-2.1,-31.5)
 
214
            | (7,14),(5,12)
 
215
            | (8,15),(6,13)
 
216
            | (7.5,15.5),(7.5,14.5)
 
217
            | (8,15),(8,15)
 
218
            | (-8,-8),(-10,-10)
 
219
            | (-7,-7),(-9,-9)
 
220
            | (-7.5,-6.5),(-7.5,-7.5)
 
221
            | (-7,-7),(-7,-7)
 
222
(24 rows)
 
223
 
 
224
-- scaling and rotation
 
225
SELECT '' AS twentyfour, b.f1 * p.f1 AS rotation
 
226
   FROM BOX_TBL b, POINT_TBL p;
 
227
 twentyfour |          rotation           
 
228
------------+-----------------------------
 
229
            | (0,0),(0,0)
 
230
            | (0,0),(0,0)
 
231
            | (0,0),(0,0)
 
232
            | (0,0),(0,0)
 
233
            | (-0,0),(-20,-20)
 
234
            | (-10,-10),(-30,-30)
 
235
            | (-25,-25),(-25,-35)
 
236
            | (-30,-30),(-30,-30)
 
237
            | (-0,2),(-14,0)
 
238
            | (-7,3),(-21,1)
 
239
            | (-17.5,2.5),(-21.5,-0.5)
 
240
            | (-21,3),(-21,3)
 
241
            | (0,79.2),(-58.8,0)
 
242
            | (-29.4,118.8),(-88.2,39.6)
 
243
            | (-73.5,104.1),(-108,99)
 
244
            | (-88.2,118.8),(-88.2,118.8)
 
245
            | (14,-0),(0,-34)
 
246
            | (21,-17),(7,-51)
 
247
            | (29.5,-42.5),(17.5,-47.5)
 
248
            | (21,-51),(21,-51)
 
249
            | (0,40),(0,0)
 
250
            | (0,60),(0,20)
 
251
            | (0,60),(-10,50)
 
252
            | (0,60),(0,60)
 
253
(24 rows)
 
254
 
 
255
SELECT '' AS twenty, b.f1 / p.f1 AS rotation
 
256
   FROM BOX_TBL b, POINT_TBL p
 
257
   WHERE (p.f1 <-> point '(0,0)') >= 1;
 
258
 twenty |                               rotation                               
 
259
--------+----------------------------------------------------------------------
 
260
        | (0,-0),(-0.2,-0.2)
 
261
        | (0.08,-0),(0,-0.56)
 
262
        | (0.0651176557644,0),(0,-0.0483449262493)
 
263
        | (-0,0.0828402366864),(-0.201183431953,0)
 
264
        | (0.2,0),(0,0)
 
265
        | (-0.1,-0.1),(-0.3,-0.3)
 
266
        | (0.12,-0.28),(0.04,-0.84)
 
267
        | (0.0976764836466,-0.0241724631247),(0.0325588278822,-0.072517389374)
 
268
        | (-0.100591715976,0.12426035503),(-0.301775147929,0.0414201183432)
 
269
        | (0.3,0),(0.1,0)
 
270
        | (-0.25,-0.25),(-0.25,-0.35)
 
271
        | (0.26,-0.7),(0.1,-0.82)
 
272
        | (0.109762715209,-0.0562379754329),(0.0813970697055,-0.0604311578117)
 
273
        | (-0.251479289941,0.103550295858),(-0.322485207101,0.0739644970414)
 
274
        | (0.3,0.05),(0.25,0)
 
275
        | (-0.3,-0.3),(-0.3,-0.3)
 
276
        | (0.12,-0.84),(0.12,-0.84)
 
277
        | (0.0976764836466,-0.072517389374),(0.0976764836466,-0.072517389374)
 
278
        | (-0.301775147929,0.12426035503),(-0.301775147929,0.12426035503)
 
279
        | (0.3,0),(0.3,0)
 
280
(20 rows)
 
281
 
 
282
--
 
283
-- Paths
 
284
--
 
285
SET geqo TO 'off';
 
286
SELECT '' AS eight, npoints(f1) AS npoints, f1 AS path FROM PATH_TBL;
 
287
 eight | npoints |           path            
 
288
-------+---------+---------------------------
 
289
       |       2 | [(1,2),(3,4)]
 
290
       |       2 | ((1,2),(3,4))
 
291
       |       4 | [(0,0),(3,0),(4,5),(1,6)]
 
292
       |       2 | ((1,2),(3,4))
 
293
       |       2 | ((1,2),(3,4))
 
294
       |       2 | [(1,2),(3,4)]
 
295
       |       2 | [(11,12),(13,14)]
 
296
       |       2 | ((11,12),(13,14))
 
297
(8 rows)
 
298
 
 
299
SELECT '' AS four, path(f1) FROM POLYGON_TBL;
 
300
 four |        path         
 
301
------+---------------------
 
302
      | ((2,0),(2,4),(0,0))
 
303
      | ((3,1),(3,3),(1,0))
 
304
      | ((0,0))
 
305
      | ((0,1),(0,1))
 
306
(4 rows)
 
307
 
 
308
-- translation
 
309
SELECT '' AS eight, p1.f1 + point '(10,10)' AS dist_add
 
310
   FROM PATH_TBL p1;
 
311
 eight |             dist_add              
 
312
-------+-----------------------------------
 
313
       | [(11,12),(13,14)]
 
314
       | ((11,12),(13,14))
 
315
       | [(10,10),(13,10),(14,15),(11,16)]
 
316
       | ((11,12),(13,14))
 
317
       | ((11,12),(13,14))
 
318
       | [(11,12),(13,14)]
 
319
       | [(21,22),(23,24)]
 
320
       | ((21,22),(23,24))
 
321
(8 rows)
 
322
 
 
323
-- scaling and rotation
 
324
SELECT '' AS eight, p1.f1 * point '(2,-1)' AS dist_mul
 
325
   FROM PATH_TBL p1;
 
326
 eight |           dist_mul           
 
327
-------+------------------------------
 
328
       | [(4,3),(10,5)]
 
329
       | ((4,3),(10,5))
 
330
       | [(0,0),(6,-3),(13,6),(8,11)]
 
331
       | ((4,3),(10,5))
 
332
       | ((4,3),(10,5))
 
333
       | [(4,3),(10,5)]
 
334
       | [(34,13),(40,15)]
 
335
       | ((34,13),(40,15))
 
336
(8 rows)
 
337
 
 
338
RESET geqo;
 
339
--
 
340
-- Polygons
 
341
--
 
342
-- containment
 
343
SELECT '' AS twentyfour, p.f1, poly.f1, poly.f1 ~ p.f1 AS contains
 
344
   FROM POLYGON_TBL poly, POINT_TBL p;
 
345
 twentyfour |     f1     |         f1          | contains 
 
346
------------+------------+---------------------+----------
 
347
            | (0,0)      | ((2,0),(2,4),(0,0)) | t
 
348
            | (0,0)      | ((3,1),(3,3),(1,0)) | f
 
349
            | (0,0)      | ((0,0))             | t
 
350
            | (0,0)      | ((0,1),(0,1))       | f
 
351
            | (-10,0)    | ((2,0),(2,4),(0,0)) | f
 
352
            | (-10,0)    | ((3,1),(3,3),(1,0)) | f
 
353
            | (-10,0)    | ((0,0))             | f
 
354
            | (-10,0)    | ((0,1),(0,1))       | f
 
355
            | (-3,4)     | ((2,0),(2,4),(0,0)) | f
 
356
            | (-3,4)     | ((3,1),(3,3),(1,0)) | f
 
357
            | (-3,4)     | ((0,0))             | f
 
358
            | (-3,4)     | ((0,1),(0,1))       | f
 
359
            | (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
 
360
            | (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
 
361
            | (5.1,34.5) | ((0,0))             | f
 
362
            | (5.1,34.5) | ((0,1),(0,1))       | f
 
363
            | (-5,-12)   | ((2,0),(2,4),(0,0)) | f
 
364
            | (-5,-12)   | ((3,1),(3,3),(1,0)) | f
 
365
            | (-5,-12)   | ((0,0))             | f
 
366
            | (-5,-12)   | ((0,1),(0,1))       | f
 
367
            | (10,10)    | ((2,0),(2,4),(0,0)) | f
 
368
            | (10,10)    | ((3,1),(3,3),(1,0)) | f
 
369
            | (10,10)    | ((0,0))             | f
 
370
            | (10,10)    | ((0,1),(0,1))       | f
 
371
(24 rows)
 
372
 
 
373
SELECT '' AS twentyfour, p.f1, poly.f1, p.f1 @ poly.f1 AS contained
 
374
   FROM POLYGON_TBL poly, POINT_TBL p;
 
375
 twentyfour |     f1     |         f1          | contained 
 
376
------------+------------+---------------------+-----------
 
377
            | (0,0)      | ((2,0),(2,4),(0,0)) | t
 
378
            | (0,0)      | ((3,1),(3,3),(1,0)) | f
 
379
            | (0,0)      | ((0,0))             | t
 
380
            | (0,0)      | ((0,1),(0,1))       | f
 
381
            | (-10,0)    | ((2,0),(2,4),(0,0)) | f
 
382
            | (-10,0)    | ((3,1),(3,3),(1,0)) | f
 
383
            | (-10,0)    | ((0,0))             | f
 
384
            | (-10,0)    | ((0,1),(0,1))       | f
 
385
            | (-3,4)     | ((2,0),(2,4),(0,0)) | f
 
386
            | (-3,4)     | ((3,1),(3,3),(1,0)) | f
 
387
            | (-3,4)     | ((0,0))             | f
 
388
            | (-3,4)     | ((0,1),(0,1))       | f
 
389
            | (5.1,34.5) | ((2,0),(2,4),(0,0)) | f
 
390
            | (5.1,34.5) | ((3,1),(3,3),(1,0)) | f
 
391
            | (5.1,34.5) | ((0,0))             | f
 
392
            | (5.1,34.5) | ((0,1),(0,1))       | f
 
393
            | (-5,-12)   | ((2,0),(2,4),(0,0)) | f
 
394
            | (-5,-12)   | ((3,1),(3,3),(1,0)) | f
 
395
            | (-5,-12)   | ((0,0))             | f
 
396
            | (-5,-12)   | ((0,1),(0,1))       | f
 
397
            | (10,10)    | ((2,0),(2,4),(0,0)) | f
 
398
            | (10,10)    | ((3,1),(3,3),(1,0)) | f
 
399
            | (10,10)    | ((0,0))             | f
 
400
            | (10,10)    | ((0,1),(0,1))       | f
 
401
(24 rows)
 
402
 
 
403
SELECT '' AS four, npoints(f1) AS npoints, f1 AS polygon
 
404
   FROM POLYGON_TBL;
 
405
 four | npoints |       polygon       
 
406
------+---------+---------------------
 
407
      |       3 | ((2,0),(2,4),(0,0))
 
408
      |       3 | ((3,1),(3,3),(1,0))
 
409
      |       1 | ((0,0))
 
410
      |       2 | ((0,1),(0,1))
 
411
(4 rows)
 
412
 
 
413
SELECT '' AS four, polygon(f1)
 
414
   FROM BOX_TBL;
 
415
 four |                  polygon                  
 
416
------+-------------------------------------------
 
417
      | ((0,0),(0,2),(2,2),(2,0))
 
418
      | ((1,1),(1,3),(3,3),(3,1))
 
419
      | ((2.5,2.5),(2.5,3.5),(2.5,3.5),(2.5,2.5))
 
420
      | ((3,3),(3,3),(3,3),(3,3))
 
421
(4 rows)
 
422
 
 
423
SELECT '' AS four, polygon(f1)
 
424
   FROM PATH_TBL WHERE isclosed(f1);
 
425
 four |      polygon      
 
426
------+-------------------
 
427
      | ((1,2),(3,4))
 
428
      | ((1,2),(3,4))
 
429
      | ((1,2),(3,4))
 
430
      | ((11,12),(13,14))
 
431
(4 rows)
 
432
 
 
433
SELECT '' AS four, f1 AS open_path, polygon( pclose(f1)) AS polygon
 
434
   FROM PATH_TBL
 
435
   WHERE isopen(f1);
 
436
 four |         open_path         |          polygon          
 
437
------+---------------------------+---------------------------
 
438
      | [(1,2),(3,4)]             | ((1,2),(3,4))
 
439
      | [(0,0),(3,0),(4,5),(1,6)] | ((0,0),(3,0),(4,5),(1,6))
 
440
      | [(1,2),(3,4)]             | ((1,2),(3,4))
 
441
      | [(11,12),(13,14)]         | ((11,12),(13,14))
 
442
(4 rows)
 
443
 
 
444
-- convert circles to polygons using the default number of points
 
445
SELECT '' AS six, polygon(f1)
 
446
   FROM CIRCLE_TBL;
 
447
 six |                                                                                                       polygon                                                                                                        
 
448
-----+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
449
     | ((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))
 
450
     | ((-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))
 
451
     | ((-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))
 
452
     | ((-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))
 
453
     | ((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))
 
454
     | ((-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))
 
455
(6 rows)
 
456
 
 
457
-- convert the circle to an 8-point polygon
 
458
SELECT '' AS six, polygon(8, f1)
 
459
   FROM CIRCLE_TBL;
 
460
 six |                                                                             polygon                                                                              
 
461
-----+------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
462
     | ((2,1),(2.87867965644,3.12132034356),(5,4),(7.12132034356,3.12132034356),(8,1),(7.12132034356,-1.12132034356),(5,-2),(2.87867965644,-1.12132034356))
 
463
     | ((-99,2),(-69.7106781187,72.7106781187),(1,102),(71.7106781187,72.7106781187),(101,2),(71.7106781187,-68.7106781187),(1,-98),(-69.7106781187,-68.7106781187))
 
464
     | ((-4,3),(-2.53553390593,6.53553390593),(1,8),(4.53553390593,6.53553390593),(6,3),(4.53553390593,-0.535533905933),(1,-2),(-2.53553390593,-0.535533905933))
 
465
     | ((-2,2),(-1.12132034356,4.12132034356),(1,5),(3.12132034356,4.12132034356),(4,2),(3.12132034356,-0.12132034356),(1,-1),(-1.12132034356,-0.12132034356))
 
466
     | ((90,200),(92.9289321881,207.071067812),(100,210),(107.071067812,207.071067812),(110,200),(107.071067812,192.928932188),(100,190),(92.9289321881,192.928932188))
 
467
     | ((-15,1),(18.6827201635,82.3172798365),(100,116),(181.317279836,82.3172798365),(215,1),(181.317279836,-80.3172798365),(100,-114),(18.6827201635,-80.3172798365))
 
468
(6 rows)
 
469
 
 
470
--
 
471
-- Circles
 
472
--
 
473
SELECT '' AS six, circle(f1, 50.0)
 
474
   FROM POINT_TBL;
 
475
 six |     circle      
 
476
-----+-----------------
 
477
     | <(0,0),50>
 
478
     | <(-10,0),50>
 
479
     | <(-3,4),50>
 
480
     | <(5.1,34.5),50>
 
481
     | <(-5,-12),50>
 
482
     | <(10,10),50>
 
483
(6 rows)
 
484
 
 
485
SELECT '' AS four, circle(f1)
 
486
   FROM BOX_TBL;
 
487
 four |        circle         
 
488
------+-----------------------
 
489
      | <(1,1),1.41421356237>
 
490
      | <(2,2),1.41421356237>
 
491
      | <(2.5,3),0.5>
 
492
      | <(3,3),0>
 
493
(4 rows)
 
494
 
 
495
SELECT '' AS two, circle(f1)
 
496
   FROM POLYGON_TBL
 
497
   WHERE (# f1) >= 3;
 
498
 two |                    circle                     
 
499
-----+-----------------------------------------------
 
500
     | <(1.33333333333,1.33333333333),2.04168905064>
 
501
     | <(2.33333333333,1.33333333333),1.47534300379>
 
502
(2 rows)
 
503
 
 
504
SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS distance
 
505
   FROM CIRCLE_TBL c1, POINT_TBL p1
 
506
   WHERE (p1.f1 <-> c1.f1) > 0
 
507
   ORDER BY distance, circle using <, point using <<;
 
508
 twentyfour |     circle     |   point    |   distance    
 
509
------------+----------------+------------+---------------
 
510
            | <(1,2),3>      | (-3,4)     |   1.472135955
 
511
            | <(5,1),3>      | (0,0)      | 2.09901951359
 
512
            | <(5,1),3>      | (-3,4)     | 5.54400374532
 
513
            | <(1,3),5>      | (-10,0)    | 6.40175425099
 
514
            | <(1,3),5>      | (10,10)    | 6.40175425099
 
515
            | <(5,1),3>      | (10,10)    | 7.29563014099
 
516
            | <(1,2),3>      | (-10,0)    |  8.1803398875
 
517
            | <(1,2),3>      | (10,10)    | 9.04159457879
 
518
            | <(1,3),5>      | (-5,-12)   | 11.1554944214
 
519
            | <(5,1),3>      | (-10,0)    | 12.0332963784
 
520
            | <(1,2),3>      | (-5,-12)   | 12.2315462117
 
521
            | <(5,1),3>      | (-5,-12)   | 13.4012194669
 
522
            | <(1,3),5>      | (5.1,34.5) | 26.7657047773
 
523
            | <(1,2),3>      | (5.1,34.5) | 29.7575945393
 
524
            | <(5,1),3>      | (5.1,34.5) | 30.5001492534
 
525
            | <(100,200),10> | (5.1,34.5) | 180.778038568
 
526
            | <(100,200),10> | (10,10)    | 200.237960416
 
527
            | <(100,200),10> | (-3,4)     | 211.415898255
 
528
            | <(100,200),10> | (0,0)      |  213.60679775
 
529
            | <(100,200),10> | (-10,0)    |  218.25424421
 
530
            | <(100,200),10> | (-5,-12)   | 226.577682802
 
531
(21 rows)
 
532