Skip to content

Commit 9e2a87b

Browse files
committed
Major patch from Thomas Lockhart <Thomas.G.Lockhart@jpl.nasa.gov>
OK, here are a passel of patches for the geometric data types. These add a "circle" data type, new operators and functions for the existing data types, and change the default formats for some of the existing types to make them consistant with each other. Current formatting conventions (e.g. compatible with v6.0 to allow dump/reload) are supported, but the new conventions should be an improvement and we can eventually drop the old conventions entirely. For example, there are two kinds of paths (connected line segments), open and closed, and the old format was '(1,2,1,2,3,4)' for a closed path with two points (1,2) and (3,4) '(0,2,1,2,3,4)' for an open path with two points (1,2) and (3,4) Pretty arcane, huh? The new format for paths is '((1,2),(3,4))' for a closed path with two points (1,2) and (3,4) '[(1,2),(3,4)]' for an open path with two points (1,2) and (3,4) For polygons, the old convention is '(0,4,2,0,4,3)' for a triangle with points at (0,0),(4,4), and (2,3) and the new convention is '((0,0),(4,4),(2,3))' for a triangle with points at (0,0),(4,4), and (2,3) Other data types which are also represented as lists of points (e.g. boxes, line segments, and polygons) have similar representations (they surround each point with parens). For v6.1, any format which can be interpreted as the old style format is decoded as such; we can remove that backwards compatibility but ugly convention for v7.0. This will allow dump/reloads from v6.0. These include some updates to the regression test files to change the test for creating a data type from "circle" to "widget" to keep the test from trashing the new builtin circle type.
1 parent 051b421 commit 9e2a87b

File tree

13 files changed

+2241
-718
lines changed

13 files changed

+2241
-718
lines changed

src/backend/access/rtree/rtproc.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.6 1997/03/14 23:17:41 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.7 1997/04/22 17:31:23 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -30,10 +30,10 @@ BOX
3030
if ((n = (BOX *) palloc(sizeof (*n))) == (BOX *) NULL)
3131
elog(WARN, "Cannot allocate box for union");
3232

33-
n->xh = Max(a->xh, b->xh);
34-
n->yh = Max(a->yh, b->yh);
35-
n->xl = Min(a->xl, b->xl);
36-
n->yl = Min(a->yl, b->yl);
33+
n->high.x = Max(a->high.x, b->high.x);
34+
n->high.y = Max(a->high.y, b->high.y);
35+
n->low.x = Min(a->low.x, b->low.x);
36+
n->low.y = Min(a->low.y, b->low.y);
3737

3838
return (n);
3939
}
@@ -46,12 +46,12 @@ rt_box_inter(BOX *a, BOX *b)
4646
if ((n = (BOX *) palloc(sizeof (*n))) == (BOX *) NULL)
4747
elog(WARN, "Cannot allocate box for union");
4848

49-
n->xh = Min(a->xh, b->xh);
50-
n->yh = Min(a->yh, b->yh);
51-
n->xl = Max(a->xl, b->xl);
52-
n->yl = Max(a->yl, b->yl);
49+
n->high.x = Min(a->high.x, b->high.x);
50+
n->high.y = Min(a->high.y, b->high.y);
51+
n->low.x = Max(a->low.x, b->low.x);
52+
n->low.y = Max(a->low.y, b->low.y);
5353

54-
if (n->xh < n->xl || n->yh < n->yl) {
54+
if (n->high.x < n->low.x || n->high.y < n->low.y) {
5555
pfree(n);
5656
return ((BOX *) NULL);
5757
}
@@ -62,10 +62,10 @@ rt_box_inter(BOX *a, BOX *b)
6262
void
6363
rt_box_size(BOX *a, float *size)
6464
{
65-
if (a == (BOX *) NULL || a->xh <= a->xl || a->yh <= a->yl)
65+
if (a == (BOX *) NULL || a->high.x <= a->low.x || a->high.y <= a->low.y)
6666
*size = 0.0;
6767
else
68-
*size = (float) ((a->xh - a->xl) * (a->yh - a->yl));
68+
*size = (float) ((a->high.x - a->low.x) * (a->high.y - a->low.y));
6969

7070
return;
7171
}
@@ -97,10 +97,10 @@ rt_poly_union(POLYGON *a, POLYGON *b)
9797
memset((char *) p, 0, sizeof(POLYGON)); /* zero any holes */
9898
p->size = sizeof(POLYGON);
9999
p->npts = 0;
100-
p->boundbox.xh = Max(a->boundbox.xh, b->boundbox.xh);
101-
p->boundbox.yh = Max(a->boundbox.yh, b->boundbox.yh);
102-
p->boundbox.xl = Min(a->boundbox.xl, b->boundbox.xl);
103-
p->boundbox.yl = Min(a->boundbox.yl, b->boundbox.yl);
100+
p->boundbox.high.x = Max(a->boundbox.high.x, b->boundbox.high.x);
101+
p->boundbox.high.y = Max(a->boundbox.high.y, b->boundbox.high.y);
102+
p->boundbox.low.x = Min(a->boundbox.low.x, b->boundbox.low.x);
103+
p->boundbox.low.y = Min(a->boundbox.low.y, b->boundbox.low.y);
104104
return p;
105105
}
106106

@@ -111,12 +111,12 @@ rt_poly_size(POLYGON *a, float *size)
111111

112112
size = (float *) palloc(sizeof(float));
113113
if (a == (POLYGON *) NULL ||
114-
a->boundbox.xh <= a->boundbox.xl ||
115-
a->boundbox.yh <= a->boundbox.yl)
114+
a->boundbox.high.x <= a->boundbox.low.x ||
115+
a->boundbox.high.y <= a->boundbox.low.y)
116116
*size = 0.0;
117117
else {
118-
xdim = (a->boundbox.xh - a->boundbox.xl);
119-
ydim = (a->boundbox.yh - a->boundbox.yl);
118+
xdim = (a->boundbox.high.x - a->boundbox.low.x);
119+
ydim = (a->boundbox.high.y - a->boundbox.low.y);
120120

121121
*size = (float) (xdim * ydim);
122122
}
@@ -137,12 +137,12 @@ rt_poly_inter(POLYGON *a, POLYGON *b)
137137
memset((char *) p, 0, sizeof(POLYGON)); /* zero any holes */
138138
p->size = sizeof(POLYGON);
139139
p->npts = 0;
140-
p->boundbox.xh = Min(a->boundbox.xh, b->boundbox.xh);
141-
p->boundbox.yh = Min(a->boundbox.yh, b->boundbox.yh);
142-
p->boundbox.xl = Max(a->boundbox.xl, b->boundbox.xl);
143-
p->boundbox.yl = Max(a->boundbox.yl, b->boundbox.yl);
140+
p->boundbox.high.x = Min(a->boundbox.high.x, b->boundbox.high.x);
141+
p->boundbox.high.y = Min(a->boundbox.high.y, b->boundbox.high.y);
142+
p->boundbox.low.x = Max(a->boundbox.low.x, b->boundbox.low.x);
143+
p->boundbox.low.y = Max(a->boundbox.low.y, b->boundbox.low.y);
144144

145-
if (p->boundbox.xh < p->boundbox.xl || p->boundbox.yh < p->boundbox.yl)
145+
if (p->boundbox.high.x < p->boundbox.low.x || p->boundbox.high.y < p->boundbox.low.y)
146146
{
147147
pfree(p);
148148
return ((POLYGON *) NULL);

0 commit comments

Comments
 (0)