Fix pg_dump bug in the database-level collation patch. "datcollate" and
[PostgreSQL.git] / src / test / regress / sql / geometry.sql
blob73f8032bb15a6113d61883ee93f190408cbb22a7
1 --
2 -- GEOMETRY
3 --
5 -- Back off displayed precision a little bit to reduce platform-to-platform
6 -- variation in results.
7 SET extra_float_digits TO -3;
9 --
10 -- Points
13 SELECT '' AS four, center(f1) AS center
14    FROM BOX_TBL;
16 SELECT '' AS four, (@@ f1) AS center
17    FROM BOX_TBL;
19 SELECT '' AS six, point(f1) AS center
20    FROM CIRCLE_TBL;
22 SELECT '' AS six, (@@ f1) AS center
23    FROM CIRCLE_TBL;
25 SELECT '' AS two, (@@ f1) AS center
26    FROM POLYGON_TBL
27    WHERE (# f1) > 2;
29 -- "is horizontal" function
30 SELECT '' AS two, p1.f1
31    FROM POINT_TBL p1
32    WHERE ishorizontal(p1.f1, point '(0,0)');
34 -- "is horizontal" operator
35 SELECT '' AS two, p1.f1
36    FROM POINT_TBL p1
37    WHERE p1.f1 ?- point '(0,0)';
39 -- "is vertical" function
40 SELECT '' AS one, p1.f1
41    FROM POINT_TBL p1
42    WHERE isvertical(p1.f1, point '(5.1,34.5)');
44 -- "is vertical" operator
45 SELECT '' AS one, p1.f1
46    FROM POINT_TBL p1
47    WHERE p1.f1 ?| point '(5.1,34.5)';
50 -- Line segments
53 -- intersection
54 SELECT '' AS count, p.f1, l.s, l.s # p.f1 AS intersection
55    FROM LSEG_TBL l, POINT_TBL p;
57 -- closest point
58 SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
59    FROM LSEG_TBL l, POINT_TBL p;
62 -- Lines
66 -- Boxes
69 SELECT '' as six, box(f1) AS box FROM CIRCLE_TBL;
71 -- translation
72 SELECT '' AS twentyfour, b.f1 + p.f1 AS translation
73    FROM BOX_TBL b, POINT_TBL p;
75 SELECT '' AS twentyfour, b.f1 - p.f1 AS translation
76    FROM BOX_TBL b, POINT_TBL p;
78 -- scaling and rotation
79 SELECT '' AS twentyfour, b.f1 * p.f1 AS rotation
80    FROM BOX_TBL b, POINT_TBL p;
82 SELECT '' AS twenty, b.f1 / p.f1 AS rotation
83    FROM BOX_TBL b, POINT_TBL p
84    WHERE (p.f1 <-> point '(0,0)') >= 1;
87 -- Paths
90 SELECT '' AS eight, npoints(f1) AS npoints, f1 AS path FROM PATH_TBL;
92 SELECT '' AS four, path(f1) FROM POLYGON_TBL;
94 -- translation
95 SELECT '' AS eight, p1.f1 + point '(10,10)' AS dist_add
96    FROM PATH_TBL p1;
98 -- scaling and rotation
99 SELECT '' AS eight, p1.f1 * point '(2,-1)' AS dist_mul
100    FROM PATH_TBL p1;
103 -- Polygons
106 -- containment
107 SELECT '' AS twentyfour, p.f1, poly.f1, poly.f1 @> p.f1 AS contains
108    FROM POLYGON_TBL poly, POINT_TBL p;
110 SELECT '' AS twentyfour, p.f1, poly.f1, p.f1 <@ poly.f1 AS contained
111    FROM POLYGON_TBL poly, POINT_TBL p;
113 SELECT '' AS four, npoints(f1) AS npoints, f1 AS polygon
114    FROM POLYGON_TBL;
116 SELECT '' AS four, polygon(f1)
117    FROM BOX_TBL;
119 SELECT '' AS four, polygon(f1)
120    FROM PATH_TBL WHERE isclosed(f1);
122 SELECT '' AS four, f1 AS open_path, polygon( pclose(f1)) AS polygon
123    FROM PATH_TBL
124    WHERE isopen(f1);
126 -- convert circles to polygons using the default number of points
127 SELECT '' AS six, polygon(f1)
128    FROM CIRCLE_TBL;
130 -- convert the circle to an 8-point polygon
131 SELECT '' AS six, polygon(8, f1)
132    FROM CIRCLE_TBL;
135 -- Circles
138 SELECT '' AS six, circle(f1, 50.0)
139    FROM POINT_TBL;
141 SELECT '' AS four, circle(f1)
142    FROM BOX_TBL;
144 SELECT '' AS two, circle(f1)
145    FROM POLYGON_TBL
146    WHERE (# f1) >= 3;
148 SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS distance
149    FROM CIRCLE_TBL c1, POINT_TBL p1
150    WHERE (p1.f1 <-> c1.f1) > 0
151    ORDER BY distance, area(c1.f1), p1.f1[0];