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