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.
This commit is contained in:
Marc G. Fournier 1997-04-22 17:35:09 +00:00
parent 051b4210e3
commit 9e2a87b62d
13 changed files with 2245 additions and 722 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.6 1997/03/14 23:17:41 scrappy Exp $
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.7 1997/04/22 17:31:23 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@ -30,10 +30,10 @@ BOX
if ((n = (BOX *) palloc(sizeof (*n))) == (BOX *) NULL)
elog(WARN, "Cannot allocate box for union");
n->xh = Max(a->xh, b->xh);
n->yh = Max(a->yh, b->yh);
n->xl = Min(a->xl, b->xl);
n->yl = Min(a->yl, b->yl);
n->high.x = Max(a->high.x, b->high.x);
n->high.y = Max(a->high.y, b->high.y);
n->low.x = Min(a->low.x, b->low.x);
n->low.y = Min(a->low.y, b->low.y);
return (n);
}
@ -46,12 +46,12 @@ rt_box_inter(BOX *a, BOX *b)
if ((n = (BOX *) palloc(sizeof (*n))) == (BOX *) NULL)
elog(WARN, "Cannot allocate box for union");
n->xh = Min(a->xh, b->xh);
n->yh = Min(a->yh, b->yh);
n->xl = Max(a->xl, b->xl);
n->yl = Max(a->yl, b->yl);
n->high.x = Min(a->high.x, b->high.x);
n->high.y = Min(a->high.y, b->high.y);
n->low.x = Max(a->low.x, b->low.x);
n->low.y = Max(a->low.y, b->low.y);
if (n->xh < n->xl || n->yh < n->yl) {
if (n->high.x < n->low.x || n->high.y < n->low.y) {
pfree(n);
return ((BOX *) NULL);
}
@ -62,10 +62,10 @@ rt_box_inter(BOX *a, BOX *b)
void
rt_box_size(BOX *a, float *size)
{
if (a == (BOX *) NULL || a->xh <= a->xl || a->yh <= a->yl)
if (a == (BOX *) NULL || a->high.x <= a->low.x || a->high.y <= a->low.y)
*size = 0.0;
else
*size = (float) ((a->xh - a->xl) * (a->yh - a->yl));
*size = (float) ((a->high.x - a->low.x) * (a->high.y - a->low.y));
return;
}
@ -97,10 +97,10 @@ rt_poly_union(POLYGON *a, POLYGON *b)
memset((char *) p, 0, sizeof(POLYGON)); /* zero any holes */
p->size = sizeof(POLYGON);
p->npts = 0;
p->boundbox.xh = Max(a->boundbox.xh, b->boundbox.xh);
p->boundbox.yh = Max(a->boundbox.yh, b->boundbox.yh);
p->boundbox.xl = Min(a->boundbox.xl, b->boundbox.xl);
p->boundbox.yl = Min(a->boundbox.yl, b->boundbox.yl);
p->boundbox.high.x = Max(a->boundbox.high.x, b->boundbox.high.x);
p->boundbox.high.y = Max(a->boundbox.high.y, b->boundbox.high.y);
p->boundbox.low.x = Min(a->boundbox.low.x, b->boundbox.low.x);
p->boundbox.low.y = Min(a->boundbox.low.y, b->boundbox.low.y);
return p;
}
@ -111,12 +111,12 @@ rt_poly_size(POLYGON *a, float *size)
size = (float *) palloc(sizeof(float));
if (a == (POLYGON *) NULL ||
a->boundbox.xh <= a->boundbox.xl ||
a->boundbox.yh <= a->boundbox.yl)
a->boundbox.high.x <= a->boundbox.low.x ||
a->boundbox.high.y <= a->boundbox.low.y)
*size = 0.0;
else {
xdim = (a->boundbox.xh - a->boundbox.xl);
ydim = (a->boundbox.yh - a->boundbox.yl);
xdim = (a->boundbox.high.x - a->boundbox.low.x);
ydim = (a->boundbox.high.y - a->boundbox.low.y);
*size = (float) (xdim * ydim);
}
@ -137,12 +137,12 @@ rt_poly_inter(POLYGON *a, POLYGON *b)
memset((char *) p, 0, sizeof(POLYGON)); /* zero any holes */
p->size = sizeof(POLYGON);
p->npts = 0;
p->boundbox.xh = Min(a->boundbox.xh, b->boundbox.xh);
p->boundbox.yh = Min(a->boundbox.yh, b->boundbox.yh);
p->boundbox.xl = Max(a->boundbox.xl, b->boundbox.xl);
p->boundbox.yl = Max(a->boundbox.yl, b->boundbox.yl);
p->boundbox.high.x = Min(a->boundbox.high.x, b->boundbox.high.x);
p->boundbox.high.y = Min(a->boundbox.high.y, b->boundbox.high.y);
p->boundbox.low.x = Max(a->boundbox.low.x, b->boundbox.low.x);
p->boundbox.low.y = Max(a->boundbox.low.y, b->boundbox.low.y);
if (p->boundbox.xh < p->boundbox.xl || p->boundbox.yh < p->boundbox.yl)
if (p->boundbox.high.x < p->boundbox.low.x || p->boundbox.high.y < p->boundbox.low.y)
{
pfree(p);
return ((POLYGON *) NULL);

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_operator.h,v 1.8 1997/04/15 17:40:44 scrappy Exp $
* $Id: pg_operator.h,v 1.9 1997/04/22 17:31:49 scrappy Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -185,7 +185,7 @@ DATA(insert OID = 513 ( "@@" PGUID 0 l t f 0 603 600 0 0 0 0 box
DATA(insert OID = 514 ( "*" PGUID 0 b t f 23 23 23 514 0 0 0 int4mul intltsel intltjoinsel ));
DATA(insert OID = 515 ( "!" PGUID 0 r t f 23 0 23 0 0 0 0 int4fac intltsel intltjoinsel ));
DATA(insert OID = 516 ( "!!" PGUID 0 l t f 0 23 23 0 0 0 0 int4fac intltsel intltjoinsel ));
DATA(insert OID = 517 ( "<===>" PGUID 0 b t f 600 600 701 0 0 0 0 point_distance intltsel intltjoinsel ));
DATA(insert OID = 517 ( "<===>" PGUID 0 b t f 600 600 701 517 0 0 0 point_distance intltsel intltjoinsel ));
DATA(insert OID = 518 ( "<>" PGUID 0 b t f 23 23 16 518 96 0 0 int4ne neqsel neqjoinsel ));
DATA(insert OID = 519 ( "<>" PGUID 0 b t f 21 21 16 519 94 0 0 int2ne neqsel neqjoinsel ));
DATA(insert OID = 520 ( ">" PGUID 0 b t f 21 21 16 95 0 0 0 int2gt intgtsel intgtjoinsel ));
@ -279,6 +279,14 @@ DATA(insert OID = 609 ( "<" PGUID 0 b t f 26 26 16 610 612 0 0 int4l
DATA(insert OID = 610 ( ">" PGUID 0 b t f 26 26 16 609 611 0 0 int4gt intgtsel intgtjoinsel ));
DATA(insert OID = 611 ( "<=" PGUID 0 b t f 26 26 16 612 610 0 0 int4le intltsel intltjoinsel ));
DATA(insert OID = 612 ( ">=" PGUID 0 b t f 26 26 16 611 609 0 0 int4ge intgtsel intgtjoinsel ));
DATA(insert OID = 613 ( "<===>" PGUID 0 b t f 600 603 701 613 0 0 0 dist_pl intltsel intltjoinsel ));
DATA(insert OID = 614 ( "<===>" PGUID 0 b t f 600 601 701 614 0 0 0 dist_ps intltsel intltjoinsel ));
DATA(insert OID = 615 ( "<===>" PGUID 0 b t f 600 603 701 615 0 0 0 dist_pb intltsel intltjoinsel ));
DATA(insert OID = 616 ( "<===>" PGUID 0 b t f 600 603 701 616 0 0 0 dist_ps intltsel intltjoinsel ));
DATA(insert OID = 617 ( "<===>" PGUID 0 b t f 601 603 701 617 0 0 0 dist_sb intltsel intltjoinsel ));
DATA(insert OID = 618 ( "<===>" PGUID 0 b t f 600 602 701 618 0 0 0 dist_ppth intltsel intltjoinsel ));
DATA(insert OID = 620 ( "=" PGUID 0 b t t 700 700 16 620 621 622 622 float4eq eqsel eqjoinsel ));
DATA(insert OID = 621 ( "<>" PGUID 0 b t f 700 700 16 621 620 0 0 float4ne neqsel neqjoinsel ));
DATA(insert OID = 622 ( "<" PGUID 0 b t f 700 700 16 623 625 0 0 float4lt intltsel intltjoinsel ));
@ -341,6 +349,11 @@ DATA(insert OID = 681 ( "<>" PGUID 0 b t f 911 911 16 681 678 0 0 oidn
DATA(insert OID = 697 ( "~" PGUID 0 b t f 411 25 16 0 698 0 0 char8regexeq eqsel eqjoinsel ));
DATA(insert OID = 698 ( "!~" PGUID 0 b t f 411 25 16 0 697 0 0 char8regexne neqsel neqjoinsel ));
DATA(insert OID = 706 ( "<===>" PGUID 0 b t f 603 603 701 706 0 0 0 box_distance intltsel intltjoinsel ));
DATA(insert OID = 707 ( "<===>" PGUID 0 b t f 602 602 701 707 0 0 0 path_distance intltsel intltjoinsel ));
DATA(insert OID = 708 ( "<===>" PGUID 0 b t f 603 603 701 708 0 0 0 line_distance intltsel intltjoinsel ));
DATA(insert OID = 709 ( "<===>" PGUID 0 b t f 601 601 701 709 0 0 0 lseg_distance intltsel intltjoinsel ));
DATA(insert OID = 830 ( "<" PGUID 0 b t f 810 810 16 834 833 0 0 oidint2lt intltsel intltjoinsel ));
DATA(insert OID = 831 ( "<=" PGUID 0 b t f 810 810 16 833 834 0 0 oidint2le intltsel intltjoinsel ));
DATA(insert OID = 832 ( "=" PGUID 0 b t f 810 810 16 832 835 0 0 oidint2eq intltsel intltjoinsel ));
@ -509,7 +522,32 @@ DATA(insert OID = 1303 ( ">" PGUID 0 b t f 1296 1296 16 1302 1304 0 0 ti
DATA(insert OID = 1304 ( "<=" PGUID 0 b t f 1296 1296 16 1305 1303 0 0 timestample intltsel intltjoinsel ));
DATA(insert OID = 1305 ( ">=" PGUID 0 b t f 1296 1296 16 1304 1302 0 0 timestampge intltsel intltjoinsel ));
/* additional geometric operators - tgl 97/04/18 */
DATA(insert OID = 1500 ( "=" PGUID 0 b t t 718 718 16 1500 1501 1502 1502 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1501 ( "<>" PGUID 0 b t f 718 718 16 1501 1500 0 0 circle_ne neqsel neqjoinsel ));
DATA(insert OID = 1502 ( "<" PGUID 0 b t f 718 718 16 1503 1505 0 0 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1503 ( ">" PGUID 0 b t f 718 718 16 1502 1504 0 0 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1504 ( "<=" PGUID 0 b t f 718 718 16 1505 1503 0 0 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1505 ( ">=" PGUID 0 b t f 718 718 16 1504 1502 0 0 circle_eq eqsel eqjoinsel ));
DATA(insert OID = 1506 ( "<<" PGUID 0 b t f 718 718 16 0 0 0 0 circle_left intltsel intltjoinsel ));
DATA(insert OID = 1507 ( "&<" PGUID 0 b t f 718 718 16 0 0 0 0 circle_overleft intltsel intltjoinsel ));
DATA(insert OID = 1508 ( "&>" PGUID 0 b t f 718 718 16 0 0 0 0 circle_overright intltsel intltjoinsel ));
DATA(insert OID = 1509 ( ">>" PGUID 0 b t f 718 718 16 0 0 0 0 circle_right intltsel intltjoinsel ));
DATA(insert OID = 1510 ( "@" PGUID 0 b t f 718 718 16 0 0 0 0 circle_contained intltsel intltjoinsel ));
DATA(insert OID = 1511 ( "~" PGUID 0 b t f 718 718 16 0 0 0 0 circle_contain intltsel intltjoinsel ));
DATA(insert OID = 1512 ( "~=" PGUID 0 b t f 718 718 16 1512 0 0 0 circle_same intltsel intltjoinsel ));
DATA(insert OID = 1513 ( "&&" PGUID 0 b t f 718 718 16 0 0 0 0 circle_overlap intltsel intltjoinsel ));
DATA(insert OID = 1514 ( "!^" PGUID 0 b t f 718 718 16 0 0 0 0 circle_above intltsel intltjoinsel ));
DATA(insert OID = 1515 ( "!|" PGUID 0 b t f 718 718 16 0 0 0 0 circle_below intltsel intltjoinsel ));
DATA(insert OID = 1516 ( "+" PGUID 0 b t f 718 600 718 1516 0 0 0 circle_add_pt - - ));
DATA(insert OID = 1517 ( "-" PGUID 0 b t f 718 600 718 0 0 0 0 circle_sub_pt - - ));
DATA(insert OID = 1518 ( "*" PGUID 0 b t f 718 600 718 1518 0 0 0 circle_mul_pt - - ));
DATA(insert OID = 1519 ( "/" PGUID 0 b t f 718 600 718 0 0 0 0 circle_div_pt - - ));
DATA(insert OID = 1520 ( "<===>" PGUID 0 b t f 718 718 701 1520 0 0 0 circle_distance intltsel intltjoinsel ));
DATA(insert OID = 1521 ( "#" PGUID 0 l t f 0 604 23 0 0 0 0 poly_npoints - - ));
/*
* function prototypes

View File

@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_proc.h,v 1.17 1997/04/15 17:41:03 scrappy Exp $
* $Id: pg_proc.h,v 1.18 1997/04/22 17:32:12 scrappy Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
@ -92,6 +92,7 @@ typedef FormData_pg_proc *Form_pg_proc;
/* keep the following ordered by OID so that later changes can be made easier*/
/* OIDS 1 - 99 */
DATA(insert OID = 1242 ( boolin PGUID 11 f t f 1 f 16 "0" 100 0 0 100 foo bar ));
DATA(insert OID = 1243 ( boolout PGUID 11 f t f 1 f 23 "0" 100 0 0 100 foo bar ));
DATA(insert OID = 1244 ( byteain PGUID 11 f t f 1 f 17 "0" 100 0 0 100 foo bar ));
@ -524,6 +525,7 @@ DATA(insert OID = 696 ( char8regexne PGUID 11 f t f 2 f 16 "411 25" 100 0
DATA(insert OID = 699 ( char2regexeq PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100 foo bar ));
/* OIDS 700 - 799 */
DATA(insert OID = 1288 ( char16regexeq PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100 foo bar ));
DATA(insert OID = 1289 ( char16regexne PGUID 11 f t f 2 f 16 "19 25" 100 0 0 100 foo bar ));
@ -534,13 +536,16 @@ DATA(insert OID = 715 ( oidsrand PGUID 11 f t f 1 f 16 "23" 100 0 0 10
DATA(insert OID = 716 ( oideqint4 PGUID 11 f t f 2 f 16 "26 23" 100 0 0 100 foo bar ));
DATA(insert OID = 717 ( int4eqoid PGUID 11 f t f 2 f 16 "23 26" 100 0 0 100 foo bar ));
DATA(insert OID = 720 ( byteaGetSize PGUID 11 f t f 1 f 23 "17" 100 0 0 100 foo bar ));
DATA(insert OID = 721 ( byteaGetByte PGUID 11 f t f 2 f 23 "17 23" 100 0 0 100 foo bar ));
DATA(insert OID = 722 ( byteaSetByte PGUID 11 f t f 3 f 17 "17 23 23" 100 0 0 100 foo bar ));
DATA(insert OID = 723 ( byteaGetBit PGUID 11 f t f 2 f 23 "17 23" 100 0 0 100 foo bar ));
DATA(insert OID = 724 ( byteaSetBit PGUID 11 f t f 3 f 17 "17 23 23" 100 0 0 100 foo bar ));
DATA(insert OID = 725 ( dist_pl PGUID 11 f t f 2 f 701 "600 654" 100 0 0 100 foo bar ));
DATA(insert OID = 726 ( dist_lb PGUID 11 f t f 2 f 701 "654 603" 100 0 0 100 foo bar ));
DATA(insert OID = 727 ( dist_sl PGUID 11 f t f 2 f 701 "601 654" 100 0 0 100 foo bar ));
DATA(insert OID = 730 ( pqtest PGUID 11 f t f 1 f 23 "25" 100 0 0 100 foo bar ));
DATA(insert OID = 740 ( text_lt PGUID 11 f t f 2 f 16 "25 25" 100 0 0 0 foo bar ));
@ -587,6 +592,7 @@ DATA(insert OID = 781 ( gistrestrpos PGUID 11 f t f 1 f 23 "0" 100 0 0 100
DATA(insert OID = 782 ( gistbuild PGUID 11 f t f 9 f 23 "0" 100 0 0 100 foo bar ));
/* OIDS 800 - 899 */
DATA(insert OID = 820 ( oidint2in PGUID 11 f t f 1 f 810 "0" 100 0 0 100 foo bar));
DATA(insert OID = 821 ( oidint2out PGUID 11 f t f 1 f 19 "0" 100 0 0 100 foo bar));
DATA(insert OID = 822 ( oidint2lt PGUID 11 f t f 2 f 16 "810 810" 100 0 0 100 foo bar));
@ -747,6 +753,7 @@ DATA(insert OID = 1091 ( date_ne PGUID 11 f t f 2 f 16 "1082 1082" 100
DATA(insert OID = 1092 ( date_cmp PGUID 11 f t f 2 f 23 "1082 1082" 100 0 0 100 foo bar ));
/* OIDS 1100 - 1199 */
DATA(insert OID = 1102 ( time_lt PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100 foo bar ));
DATA(insert OID = 1103 ( time_le PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100 foo bar ));
DATA(insert OID = 1104 ( time_gt PGUID 11 f t f 2 f 16 "1083 1083" 100 0 0 100 foo bar ));
@ -806,6 +813,7 @@ DATA(insert OID = 1194 ( timespan_reltime PGUID 11 f t f 1 f 703 "1186" 100
/* reserve OIDs 1195-1199 for additional date/time conversion routines! tgl 97/03/19 */
/* OIDS 1200 - 1299 */
DATA(insert OID = 1200 ( int42reltime PGUID 11 f t f 1 f 703 "21" 100 0 0 100 foo bar ));
DATA(insert OID = 1290 ( char2icregexeq PGUID 11 f t f 2 f 16 "409 25" 100 0 0 100 foo bar ));
@ -826,6 +834,7 @@ DATA(insert OID = 1298 ( timestamp_out PGUID 11 f t f 1 f 23 "0" 100 0 0 100
DATA(insert OID = 1299 ( now PGUID 11 f t f 0 f 1296 "0" 100 0 0 100 foo bar ));
/* OIDS 1300 - 1399 */
DATA(insert OID = 1306 ( timestampeq PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100 foo bar ));
DATA(insert OID = 1307 ( timestampne PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100 foo bar ));
DATA(insert OID = 1308 ( timestamplt PGUID 11 f t f 2 f 16 "1296 1296" 100 0 0 100 foo bar ));
@ -873,6 +882,7 @@ DATA(insert OID = 1392 ( isfinite PGUID 14 f t f 1 f 16 "702" 100 0 0 10
/* reserve OIDs 1370-1399 for additional date/time conversion routines! tgl 97/04/01 */
/* OIDS 1400 - 1499 */
DATA(insert OID = 1400 ( float PGUID 14 f t f 1 f 701 "701" 100 0 0 100 "select $1" - ));
DATA(insert OID = 1401 ( float PGUID 14 f t f 1 f 701 "700" 100 0 0 100 "select ftod($1)" - ));
DATA(insert OID = 1402 ( float4 PGUID 14 f t f 1 f 700 "700" 100 0 0 100 "select $1" - ));
@ -880,6 +890,109 @@ DATA(insert OID = 1403 ( float4 PGUID 14 f t f 1 f 700 "701" 100 0 0 10
DATA(insert OID = 1404 ( int PGUID 14 f t f 1 f 23 "23" 100 0 0 100 "select $1" - ));
DATA(insert OID = 1405 ( int2 PGUID 14 f t f 1 f 21 "21" 100 0 0 100 "select $1" - ));
DATA(insert OID = 1421 ( box PGUID 11 f t f 2 f 603 "600 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1422 ( box_add PGUID 11 f t f 2 f 603 "603 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1423 ( box_sub PGUID 11 f t f 2 f 603 "603 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1424 ( box_mul PGUID 11 f t f 2 f 603 "603 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1425 ( box_div PGUID 11 f t f 2 f 603 "603 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1430 ( path_isclosed PGUID 11 f t f 1 f 16 "602" 100 0 0 100 foo bar ));
DATA(insert OID = 1431 ( path_isopen PGUID 11 f t f 1 f 16 "602" 100 0 0 100 foo bar ));
DATA(insert OID = 1432 ( path_npoints PGUID 11 f t f 1 f 23 "602" 100 0 0 100 foo bar ));
DATA(insert OID = 1433 ( path_close PGUID 11 f t f 1 f 602 "602" 100 0 0 100 foo bar ));
DATA(insert OID = 1434 ( path_open PGUID 11 f t f 1 f 602 "602" 100 0 0 100 foo bar ));
DATA(insert OID = 1435 ( path_add PGUID 11 f t f 2 f 602 "602 602" 100 0 0 100 foo bar ));
DATA(insert OID = 1436 ( path_add_pt PGUID 11 f t f 2 f 602 "602 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1437 ( path_sub_pt PGUID 11 f t f 2 f 602 "602 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1438 ( path_mul_pt PGUID 11 f t f 2 f 602 "602 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1439 ( path_div_pt PGUID 11 f t f 2 f 602 "602 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1440 ( point PGUID 11 f t f 2 f 600 "701 701" 100 0 0 100 foo bar ));
DATA(insert OID = 1441 ( point_add PGUID 11 f t f 2 f 600 "600 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1442 ( point_sub PGUID 11 f t f 2 f 600 "600 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1443 ( point_mul PGUID 11 f t f 2 f 600 "600 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1444 ( point_div PGUID 11 f t f 2 f 600 "600 600" 100 0 0 100 foo bar ));
DATA(insert OID = 1445 ( poly_npoints PGUID 11 f t f 1 f 23 "604" 100 0 0 100 foo bar ));
DATA(insert OID = 1446 ( poly_box PGUID 11 f t f 1 f 603 "604" 100 0 0 100 foo bar ));
DATA(insert OID = 1447 ( poly_path PGUID 11 f t f 1 f 602 "604" 100 0 0 100 foo bar ));
DATA(insert OID = 1448 ( box_poly PGUID 11 f t f 1 f 604 "603" 100 0 0 100 foo bar ));
DATA(insert OID = 1449 ( path_poly PGUID 11 f t f 1 f 604 "602" 100 0 0 100 foo bar ));
DATA(insert OID = 1450 ( circle_in PGUID 11 f t f 1 f 718 "0" 100 0 1 0 foo bar ));
DATA(insert OID = 1451 ( circle_out PGUID 11 f t f 1 f 23 "0" 100 0 1 0 foo bar ));
DATA(insert OID = 1452 ( circle_same PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1453 ( circle_contain PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1454 ( circle_left PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1455 ( circle_overleft PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1456 ( circle_overright PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1457 ( circle_right PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1458 ( circle_contained PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1459 ( circle_overlap PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1460 ( circle_below PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1461 ( circle_above PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1462 ( circle_eq PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1463 ( circle_ne PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1464 ( circle_lt PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1465 ( circle_gt PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1466 ( circle_le PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1467 ( circle_ge PGUID 11 f t f 2 f 16 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1468 ( circle_area PGUID 11 f t f 1 f 701 "718" 100 0 1 0 foo bar ));
DATA(insert OID = 1469 ( circle_diameter PGUID 11 f t f 1 f 701 "718" 100 0 1 0 foo bar ));
DATA(insert OID = 1470 ( circle_radius PGUID 11 f t f 1 f 701 "718" 100 0 1 0 foo bar ));
DATA(insert OID = 1471 ( circle_distance PGUID 11 f t f 2 f 701 "718 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1472 ( circle_center PGUID 11 f t f 1 f 600 "718" 100 0 1 0 foo bar ));
DATA(insert OID = 1473 ( circle PGUID 11 f t f 2 f 718 "600 701" 100 0 1 0 foo bar ));
DATA(insert OID = 1474 ( poly_circle PGUID 11 f t f 1 f 718 "604" 100 0 1 0 foo bar ));
DATA(insert OID = 1475 ( circle_poly PGUID 11 f t f 2 f 604 "23 718" 100 0 1 0 foo bar ));
DATA(insert OID = 1530 ( point PGUID 14 f t f 2 f 600 "601 601" 100 0 0 100 "select lseg_interpt($1, $2)" - ));
DATA(insert OID = 1531 ( point PGUID 14 f t f 1 f 600 "718" 100 0 0 100 "select circle_center($1)" - ));
DATA(insert OID = 1532 ( isvertical PGUID 14 f t f 2 f 16 "600 600" 100 0 0 100 "select point_vert($1, $2)" - ));
DATA(insert OID = 1533 ( ishorizonal PGUID 14 f t f 2 f 16 "600 600" 100 0 0 100 "select point_horiz($1, $2)" - ));
DATA(insert OID = 1534 ( slope PGUID 14 f t f 2 f 701 "600 600" 100 0 0 100 "select point_slope($1, $2)" - ));
DATA(insert OID = 1540 ( lseg PGUID 14 f t f 2 f 601 "600 600" 100 0 0 100 "select lseg_construct($1, $2)" - ));
DATA(insert OID = 1541 ( lseg PGUID 14 f t f 1 f 601 "603" 100 0 0 100 "select box_diagonal($1)" - ));
DATA(insert OID = 1542 ( isparallel PGUID 14 f t f 2 f 16 "601 601" 100 0 0 100 "select lseg_parallel($1, $2)" - ));
DATA(insert OID = 1543 ( isperpendicular PGUID 14 f t f 2 f 16 "601 601" 100 0 0 100 "select lseg_perp($1, $2)" - ));
DATA(insert OID = 1544 ( isvertical PGUID 14 f t f 1 f 16 "601" 100 0 0 100 "select lseg_vertical($1)" - ));
DATA(insert OID = 1545 ( ishorizontal PGUID 14 f t f 1 f 16 "601" 100 0 0 100 "select lseg_horizontal($1)" - ));
/* XXX "length" for boxes is different than "length" for paths, so use "width" for boxes instead.
* should go back into code and change subroutine name from "box_length" to "box_width".
* pclose and popen might better be named close and open, but that crashes initdb.
* - tgl 97/04/20
*/
DATA(insert OID = 1550 ( path PGUID 14 f t f 1 f 602 "604" 100 0 0 100 "select poly_path($1)" - ));
DATA(insert OID = 1551 ( length PGUID 14 f t f 1 f 701 "602" 100 0 1 0 "select path_length($1)" - ));
DATA(insert OID = 1552 ( points PGUID 14 f t f 1 f 23 "602" 100 0 0 100 "select path_npoints($1)" - ));
DATA(insert OID = 1553 ( pclose PGUID 14 f t f 1 f 602 "602" 100 0 0 100 "select path_close($1)" - ));
DATA(insert OID = 1554 ( popen PGUID 14 f t f 1 f 602 "602" 100 0 0 100 "select path_open($1)" - ));
DATA(insert OID = 1555 ( isopen PGUID 14 f t f 1 f 16 "602" 100 0 0 100 "select path_isopen($1)" - ));
DATA(insert OID = 1555 ( isclosed PGUID 14 f t f 1 f 16 "602" 100 0 0 100 "select path_isclosed($1)" - ));
DATA(insert OID = 1560 ( box PGUID 14 f t f 2 f 603 "603 603" 100 0 0 100 "select box_intersect($1, $2)" - ));
DATA(insert OID = 1561 ( box PGUID 14 f t f 1 f 603 "604" 100 0 0 100 "select poly_box($1)" - ));
DATA(insert OID = 1562 ( width PGUID 14 f t f 1 f 701 "603" 100 0 0 100 "select box_length($1)" - ));
DATA(insert OID = 1563 ( height PGUID 14 f t f 1 f 701 "603" 100 0 0 100 "select box_height($1)" - ));
DATA(insert OID = 1564 ( center PGUID 14 f t f 1 f 600 "603" 100 0 0 100 "select box_center($1)" - ));
DATA(insert OID = 1565 ( area PGUID 14 f t f 1 f 701 "603" 100 0 0 100 "select box_area($1)" - ));
DATA(insert OID = 1570 ( polygon PGUID 14 f t f 1 f 604 "602" 100 0 0 100 "select path_poly($1)" - ));
DATA(insert OID = 1571 ( polygon PGUID 14 f t f 1 f 604 "603" 100 0 0 100 "select box_poly($1)" - ));
DATA(insert OID = 1572 ( polygon PGUID 14 f t f 2 f 604 "23 718" 100 0 0 100 "select circle_poly($1, $2)" - ));
DATA(insert OID = 1573 ( polygon PGUID 14 f t f 1 f 604 "718" 100 0 0 100 "select circle_poly(12, $1)" - ));
DATA(insert OID = 1574 ( points PGUID 14 f t f 1 f 23 "604" 100 0 0 100 "select poly_npoints($1)" - ));
DATA(insert OID = 1575 ( center PGUID 14 f t f 1 f 600 "604" 100 0 0 100 "select poly_center($1)" - ));
DATA(insert OID = 1580 ( circle PGUID 14 f t f 1 f 701 "604" 100 0 0 100 "select poly_circle($1)" - ));
DATA(insert OID = 1581 ( center PGUID 14 f t f 1 f 600 "718" 100 0 0 100 "select circle_center($1)" - ));
DATA(insert OID = 1582 ( radius PGUID 14 f t f 1 f 701 "718" 100 0 0 100 "select circle_radius($1)" - ));
DATA(insert OID = 1583 ( diameter PGUID 14 f t f 1 f 701 "718" 100 0 0 100 "select circle_diameter($1)" - ));
DATA(insert OID = 1584 ( area PGUID 14 f t f 1 f 701 "718" 100 0 0 100 "select circle_area($1)" - ));
/* Oracle Compatibility Related Functions - By Edmund Mergl <E.Mergl@bawue.de> */
DATA(insert OID = 870 ( lower PGUID 11 f t f 1 f 25 "25" 100 0 0 100 foo bar ));
DATA(insert OID = 871 ( upper PGUID 11 f t f 1 f 25 "25" 100 0 0 100 foo bar ));

View File

@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_type.h,v 1.10 1997/04/15 17:41:19 scrappy Exp $
* $Id: pg_type.h,v 1.11 1997/04/22 17:32:26 scrappy Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@ -220,7 +220,10 @@ DATA(insert OID = 601 ( lseg PGUID 32 48 f b t \054 0 600 lseg_in lseg_ou
DATA(insert OID = 602 ( path PGUID -1 -1 f b t \054 0 600 path_in path_out path_in path_out d _null_ ));
DATA(insert OID = 603 ( box PGUID 32 100 f b t \073 0 600 box_in box_out box_in box_out d _null_ ));
DATA(insert OID = 604 ( polygon PGUID -1 -1 f b t \054 0 -1 poly_in poly_out poly_in poly_out d _null_ ));
DATA(insert OID = 605 ( filename PGUID 256 -1 f b t \054 0 18 filename_in filename_out filename_in filename_out i _null_ ));
DATA(insert OID = 605 ( filename PGUID 256 -1 f b t \054 0 18 filename_in filename_out filename_in filename_out i _null_ ));
DATA(insert OID = 628 ( line PGUID 32 48 f b t \054 0 701 line_in line_out line_in line_out d _null_ ));
DATA(insert OID = 629 ( _line PGUID -1 -1 f b t \054 0 628 array_in array_out array_in array_out d _null_ ));
/* OIDS 700 - 799 */
@ -234,8 +237,9 @@ DATA(insert OID = 704 ( tinterval PGUID 12 47 f b t \054 0 0 tintervalin tin
DATA(insert OID = 705 ( unknown PGUID -1 -1 f b t \054 0 18 textin textout textin textout i _null_ ));
#define UNKNOWNOID 705
DATA(insert OID = 790 ( money PGUID 4 47 f b t \054 0 0 cash_in cash_out cash_in cash_out i _null_ ));
#define CASHOID 790
DATA(insert OID = 718 ( circle PGUID 24 47 f b t \054 0 0 circle_in circle_out circle_in circle_out d _null_ ));
DATA(insert OID = 719 ( _circle PGUID -1 -1 f b t \054 0 718 array_in array_out array_in array_out i _null_ ));
DATA(insert OID = 790 ( money PGUID 4 24 f b t \054 0 0 cash_in cash_out cash_in cash_out i _null_ ));
DATA(insert OID = 791 ( _money PGUID -1 -1 f b t \054 0 790 array_in array_out array_in array_out i _null_ ));
/* OIDS 800 - 899 */

View File

@ -1,17 +1,18 @@
/*-------------------------------------------------------------------------
*
* geo_decls.h--
* Declarations for various 2D constructs.
* geo_decls.h - Declarations for various 2D constructs.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: geo_decls.h,v 1.1 1997/03/14 23:33:27 scrappy Exp $
* $Id: geo_decls.h,v 1.2 1997/04/22 17:32:41 scrappy Exp $
*
* NOTE
* These routines do *not* use the float types from adt/.
*
* XXX These routines were not written by a numerical analyst.
* XXX I have made some attempt to flesh out the operators
* and data types. There are still some more to do. - tgl 97/04/19
*
*-------------------------------------------------------------------------
*/
@ -23,23 +24,32 @@
/*#ifndef FmgrIncluded -- seems like always included. (it's FMgrIncluded) AY */
/*--------------------------------------------------------------------
* Useful floating point utilities and constants.
* Useful floating point utilities and constants.
*-------------------------------------------------------------------*/
#define EPSILON 1.0E-06
#ifdef EPSILON
#define FPzero(A) (fabs(A) <= EPSILON)
#define FPeq(A,B) (fabs((A) - (B)) <= EPSILON)
#define FPlt(A,B) ((B) - (A) > EPSILON)
#define FPle(A,B) ((A) - (B) <= EPSILON)
#define FPgt(A,B) ((A) - (B) > EPSILON)
#define FPge(A,B) ((B) - (A) <= EPSILON)
#else
#define FPzero(A) (A == 0)
#define FPeq(A,B) (A == B)
#define FPlt(A,B) (A < B)
#define FPle(A,B) (A <= B)
#define FPgt(A,B) (A > B)
#define FPge(A,B) (A >= B)
#endif
#define HYPOT(A, B) sqrt((A) * (A) + (B) * (B))
/*--------------------------------------------------------------------
* Memory management.
* Memory management.
*-------------------------------------------------------------------*/
#define PALLOC(SIZE) palloc(SIZE)
@ -49,7 +59,7 @@
/*#endif !FmgrIncluded */
/*---------------------------------------------------------------------
* Point - (x,y)
* Point - (x,y)
*-------------------------------------------------------------------*/
typedef struct {
double x, y;
@ -57,7 +67,7 @@ typedef struct {
/*---------------------------------------------------------------------
* LSEG - A straight line, specified by endpoints.
* LSEG - A straight line, specified by endpoints.
*-------------------------------------------------------------------*/
typedef struct {
Point p[2];
@ -67,24 +77,24 @@ typedef struct {
/*---------------------------------------------------------------------
* PATH - Specified by vertex points.
* PATH - Specified by vertex points.
*-------------------------------------------------------------------*/
typedef struct {
int32 length; /* XXX varlena */
int32 size; /* XXX varlena */
int32 npts;
int32 closed; /* is this a closed polygon? */
int32 dummy; /* padding to make it double align */
Point p[1]; /* variable length array of POINTs */
Point p[0]; /* variable length array of POINTs */
} PATH;
/*---------------------------------------------------------------------
* LINE - Specified by its general equation (Ax+By+C=0).
* If there is a y-intercept, it is C, which
* incidentally gives a freebie point on the line
* (if B=0, then C is the x-intercept).
* Slope m is precalculated to save time; if
* the line is not vertical, m == A.
* LINE - Specified by its general equation (Ax+By+C=0).
* If there is a y-intercept, it is C, which
* incidentally gives a freebie point on the line
* (if B=0, then C is the x-intercept).
* Slope m is precalculated to save time; if
* the line is not vertical, m == A.
*-------------------------------------------------------------------*/
typedef struct {
double A, B, C;
@ -93,25 +103,32 @@ typedef struct {
/*---------------------------------------------------------------------
* BOX - Specified by two corner points, which are
* sorted to save calculation time later.
* BOX - Specified by two corner points, which are
* sorted to save calculation time later.
*-------------------------------------------------------------------*/
typedef struct {
double xh, yh, xl, yl; /* high and low coords */
Point high, low; /* corner POINTs */
} BOX;
/*---------------------------------------------------------------------
* POLYGON - Specified by an array of doubles defining the points,
* keeping the number of points and the bounding box for
* speed purposes.
* POLYGON - Specified by an array of doubles defining the points,
* keeping the number of points and the bounding box for
* speed purposes.
*-------------------------------------------------------------------*/
typedef struct {
int32 size; /* XXX varlena */
int32 npts;
BOX boundbox;
char pts[1];
Point p[0]; /* variable length array of POINTs */
} POLYGON;
/*---------------------------------------------------------------------
* CIRCLE - Specified by a center point and radius.
*-------------------------------------------------------------------*/
typedef struct {
Point center;
double radius;
} CIRCLE;
/*
* in geo_ops.h
@ -121,81 +138,115 @@ extern char *box_out(BOX *box);
extern BOX *box_construct(double x1, double x2, double y1, double y2);
extern BOX *box_fill(BOX *result, double x1, double x2, double y1, double y2);
extern BOX *box_copy(BOX *box);
extern long box_same(BOX *box1, BOX *box2);
extern long box_overlap(BOX *box1, BOX *box2);
extern long box_overleft(BOX *box1, BOX *box2);
extern long box_left(BOX *box1, BOX *box2);
extern long box_right(BOX *box1, BOX *box2);
extern long box_overright(BOX *box1, BOX *box2);
extern long box_contained(BOX *box1, BOX *box2);
extern long box_contain(BOX *box1, BOX *box2);
extern long box_below(BOX *box1, BOX *box2);
extern long box_above(BOX *box1, BOX *box2);
extern long box_lt(BOX *box1, BOX *box2);
extern long box_gt(BOX *box1, BOX *box2);
extern long box_eq(BOX *box1, BOX *box2);
extern long box_le(BOX *box1, BOX *box2);
extern long box_ge(BOX *box1, BOX *box2);
extern bool box_same(BOX *box1, BOX *box2);
extern bool box_overlap(BOX *box1, BOX *box2);
extern bool box_overleft(BOX *box1, BOX *box2);
extern bool box_left(BOX *box1, BOX *box2);
extern bool box_right(BOX *box1, BOX *box2);
extern bool box_overright(BOX *box1, BOX *box2);
extern bool box_contained(BOX *box1, BOX *box2);
extern bool box_contain(BOX *box1, BOX *box2);
extern bool box_below(BOX *box1, BOX *box2);
extern bool box_above(BOX *box1, BOX *box2);
extern bool box_lt(BOX *box1, BOX *box2);
extern bool box_gt(BOX *box1, BOX *box2);
extern bool box_eq(BOX *box1, BOX *box2);
extern bool box_le(BOX *box1, BOX *box2);
extern bool box_ge(BOX *box1, BOX *box2);
extern Point *box_center(BOX *box);
extern double *box_area(BOX *box);
extern double *box_length(BOX *box);
extern double *box_height(BOX *box);
extern double *box_distance(BOX *box1, BOX *box2);
extern Point *box_center(BOX *box);
extern BOX *box_intersect(BOX *box1, BOX *box2);
extern LSEG *box_diagonal(BOX *box);
/* private routines */
extern double box_ar(BOX *box);
extern double box_ln(BOX *box);
extern double box_ht(BOX *box);
extern double box_dt(BOX *box1, BOX *box2);
extern BOX *box_intersect(BOX *box1, BOX *box2);
extern LSEG *box_diagonal(BOX *box);
extern BOX *box(Point *p1, Point *p2);
extern BOX *box_add(BOX *box, Point *p);
extern BOX *box_sub(BOX *box, Point *p);
extern BOX *box_mul(BOX *box, Point *p);
extern BOX *box_div(BOX *box, Point *p);
extern LINE *line_construct_pm(Point *pt, double m);
extern LINE *line_construct_pp(Point *pt1, Point *pt2);
extern long line_intersect(LINE *l1, LINE *l2);
extern long line_parallel(LINE *l1, LINE *l2);
extern long line_perp(LINE *l1, LINE *l2);
extern long line_vertical(LINE *line);
extern long line_horizontal(LINE *line);
extern long line_eq(LINE *l1, LINE *l2);
extern bool line_intersect(LINE *l1, LINE *l2);
extern bool line_parallel(LINE *l1, LINE *l2);
extern bool line_perp(LINE *l1, LINE *l2);
extern bool line_vertical(LINE *line);
extern bool line_horizontal(LINE *line);
extern bool line_eq(LINE *l1, LINE *l2);
extern double *line_distance(LINE *l1, LINE *l2);
extern Point *line_interpt(LINE *l1, LINE *l2);
extern PATH *path_in(char *str);
extern char *path_out(PATH *path);
extern long path_n_lt(PATH *p1, PATH *p2);
extern long path_n_gt(PATH *p1, PATH *p2);
extern long path_n_eq(PATH *p1, PATH *p2);
extern long path_n_le(PATH *p1, PATH *p2);
extern long path_n_ge(PATH *p1, PATH *p2);
extern long path_inter(PATH *p1, PATH *p2);
extern bool path_n_lt(PATH *p1, PATH *p2);
extern bool path_n_gt(PATH *p1, PATH *p2);
extern bool path_n_eq(PATH *p1, PATH *p2);
extern bool path_n_le(PATH *p1, PATH *p2);
extern bool path_n_ge(PATH *p1, PATH *p2);
extern bool path_inter(PATH *p1, PATH *p2);
extern double *path_distance(PATH *p1, PATH *p2);
extern double *path_length(PATH *path);
/* private routines */
extern double path_ln(PATH *path);
extern bool path_isclosed(PATH *path);
extern bool path_isopen(PATH *path);
extern int4 path_npoints(PATH *path);
extern PATH *path_close(PATH *path);
extern PATH *path_open(PATH *path);
extern PATH *path_add(PATH *p1, PATH *p2);
extern PATH *path_add_pt(PATH *path, Point *point);
extern PATH *path_sub_pt(PATH *path, Point *point);
extern PATH *path_mul_pt(PATH *path, Point *point);
extern PATH *path_div_pt(PATH *path, Point *point);
extern POLYGON *path_poly(PATH *path);
extern Point *point_in(char *str);
extern char *point_out(Point *pt);
extern Point *point_construct(double x, double y);
extern Point *point_copy(Point *pt);
extern long point_left(Point *pt1, Point *pt2);
extern long point_right(Point *pt1, Point *pt2);
extern long point_above(Point *pt1, Point *pt2);
extern long point_below(Point *pt1, Point *pt2);
extern long point_vert(Point *pt1, Point *pt2);
extern long point_horiz(Point *pt1, Point *pt2);
extern long point_eq(Point *pt1, Point *pt2);
extern long pointdist(Point *p1, Point *p2);
extern bool point_left(Point *pt1, Point *pt2);
extern bool point_right(Point *pt1, Point *pt2);
extern bool point_above(Point *pt1, Point *pt2);
extern bool point_below(Point *pt1, Point *pt2);
extern bool point_vert(Point *pt1, Point *pt2);
extern bool point_horiz(Point *pt1, Point *pt2);
extern bool point_eq(Point *pt1, Point *pt2);
extern int32 pointdist(Point *p1, Point *p2);
extern double *point_distance(Point *pt1, Point *pt2);
extern double point_dt(Point *pt1, Point *pt2);
extern double *point_slope(Point *pt1, Point *pt2);
/* private routines */
extern double point_dt(Point *pt1, Point *pt2);
extern double point_sl(Point *pt1, Point *pt2);
extern Point *point(float8 *x, float8 *y);
extern Point *point_add(Point *p1, Point *p2);
extern Point *point_sub(Point *p1, Point *p2);
extern Point *point_mul(Point *p1, Point *p2);
extern Point *point_div(Point *p1, Point *p2);
extern LSEG *lseg_in(char *str);
extern char *lseg_out(LSEG *ls);
extern LSEG *lseg_construct(Point *pt1, Point *pt2);
extern void statlseg_construct(LSEG *lseg, Point *pt1, Point *pt2);
extern long lseg_intersect(LSEG *l1, LSEG *l2);
extern long lseg_parallel(LSEG *l1, LSEG *l2);
extern long lseg_perp(LSEG *l1, LSEG *l2);
extern long lseg_vertical(LSEG *lseg);
extern long lseg_horizontal(LSEG *lseg);
extern long lseg_eq(LSEG *l1, LSEG *l2);
extern bool lseg_intersect(LSEG *l1, LSEG *l2);
extern bool lseg_parallel(LSEG *l1, LSEG *l2);
extern bool lseg_perp(LSEG *l1, LSEG *l2);
extern bool lseg_vertical(LSEG *lseg);
extern bool lseg_horizontal(LSEG *lseg);
extern bool lseg_eq(LSEG *l1, LSEG *l2);
extern double *lseg_distance(LSEG *l1, LSEG *l2);
extern double lseg_dt(LSEG *l1, LSEG *l2);
extern Point *lseg_interpt(LSEG *l1, LSEG *l2);
extern double *dist_pl(Point *pt, LINE *line);
extern double *dist_ps(Point *pt, LSEG *lseg);
@ -211,29 +262,73 @@ extern Point *close_pb(Point *pt, BOX *box);
extern Point *close_sl(LSEG *lseg, LINE *line);
extern Point *close_sb(LSEG *lseg, BOX *box);
extern Point *close_lb(LINE *line, BOX *box);
extern long on_pl(Point *pt, LINE *line);
extern long on_ps(Point *pt, LSEG *lseg);
extern long on_pb(Point *pt, BOX *box);
extern long on_ppath(Point *pt, PATH *path);
extern long on_sl(LSEG *lseg, LINE *line);
extern long on_sb(LSEG *lseg, BOX *box);
extern long inter_sl(LSEG *lseg, LINE *line);
extern long inter_sb(LSEG *lseg, BOX *box);
extern long inter_lb(LINE *line, BOX *box);
extern bool on_pl(Point *pt, LINE *line);
extern bool on_ps(Point *pt, LSEG *lseg);
extern bool on_pb(Point *pt, BOX *box);
extern bool on_ppath(Point *pt, PATH *path);
extern bool on_sl(LSEG *lseg, LINE *line);
extern bool on_sb(LSEG *lseg, BOX *box);
extern bool inter_sl(LSEG *lseg, LINE *line);
extern bool inter_sb(LSEG *lseg, BOX *box);
extern bool inter_lb(LINE *line, BOX *box);
/* private routines */
extern LSEG *lseg_construct(Point *pt1, Point *pt2);
extern void statlseg_construct(LSEG *lseg, Point *pt1, Point *pt2);
extern double lseg_dt(LSEG *l1, LSEG *l2);
extern void make_bound_box(POLYGON *poly);
extern POLYGON *poly_in(char *s);
extern long poly_pt_count(char *s, char delim);
extern char *poly_out(POLYGON *poly);
extern double poly_max(double *coords, int ncoords);
extern double poly_min(double *coords, int ncoords);
extern long poly_left(POLYGON *polya, POLYGON *polyb);
extern long poly_overleft(POLYGON *polya, POLYGON *polyb);
extern long poly_right(POLYGON *polya, POLYGON *polyb);
extern long poly_overright(POLYGON *polya, POLYGON *polyb);
extern long poly_same(POLYGON *polya, POLYGON *polyb);
extern long poly_overlap(POLYGON *polya, POLYGON *polyb);
extern long poly_contain(POLYGON *polya, POLYGON *polyb);
extern long poly_contained(POLYGON *polya, POLYGON *polyb);
extern bool poly_left(POLYGON *polya, POLYGON *polyb);
extern bool poly_overleft(POLYGON *polya, POLYGON *polyb);
extern bool poly_right(POLYGON *polya, POLYGON *polyb);
extern bool poly_overright(POLYGON *polya, POLYGON *polyb);
extern bool poly_same(POLYGON *polya, POLYGON *polyb);
extern bool poly_overlap(POLYGON *polya, POLYGON *polyb);
extern bool poly_contain(POLYGON *polya, POLYGON *polyb);
extern bool poly_contained(POLYGON *polya, POLYGON *polyb);
extern int4 poly_npoints(POLYGON *poly);
extern BOX *poly_box(POLYGON *poly);
extern PATH *poly_path(POLYGON *poly);
extern POLYGON *box_poly(BOX *box);
extern CIRCLE *circle_in(char *str);
extern char *circle_out(CIRCLE *circle);
extern bool circle_same(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_overlap(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_overleft(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_left(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_right(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_overright(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_contained(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_contain(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_below(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_above(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_eq(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_ne(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_lt(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_gt(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_le(CIRCLE *circle1, CIRCLE *circle2);
extern bool circle_ge(CIRCLE *circle1, CIRCLE *circle2);
extern CIRCLE *circle_add_pt(CIRCLE *circle, Point *point);
extern CIRCLE *circle_sub_pt(CIRCLE *circle, Point *point);
extern CIRCLE *circle_mul_pt(CIRCLE *circle, Point *point);
extern CIRCLE *circle_div_pt(CIRCLE *circle, Point *point);
extern double *circle_area(CIRCLE *circle);
extern double *circle_diameter(CIRCLE *circle);
extern double *circle_radius(CIRCLE *circle);
extern double *circle_distance(CIRCLE *circle1, CIRCLE *circle2);
extern Point *circle_center(CIRCLE *circle);
extern CIRCLE *circle(Point *center, float8 *radius);
extern CIRCLE *poly_circle(POLYGON *poly);
extern POLYGON *circle_poly(int npts, CIRCLE *circle);
/* private routines */
extern double circle_ar(CIRCLE *circle);
extern double circle_dt(CIRCLE *circle1, CIRCLE *circle2);
/* geo_selfuncs.c */
extern float64 areasel(Oid opid, Oid relid, AttrNumber attno,
@ -247,6 +342,6 @@ extern float64 leftjoinsel(Oid opid, Oid relid, AttrNumber attno,
extern float64 contsel(Oid opid, Oid relid, AttrNumber attno,
char *value, int32 flag);
extern float64 contjoinsel(Oid opid, Oid relid, AttrNumber attno,
char *value, int32 flag);
char *value, int32 flag);
#endif /* GEO_DECLS_H */

View File

@ -6,8 +6,8 @@ QUERY: CREATE OPERATOR ## (
);
QUERY: CREATE OPERATOR <% (
leftarg = point,
rightarg = circle,
procedure = pt_in_circle,
rightarg = widget,
procedure = pt_in_widget,
commutator = >=%
);
QUERY: CREATE OPERATOR @#@ (

View File

@ -1,7 +1,7 @@
QUERY: CREATE TYPE circle (
QUERY: CREATE TYPE widget (
internallength = 24,
input = circle_in,
output = circle_out,
input = widget_in,
output = widget_out,
alignment = double
);
QUERY: CREATE TYPE city_budget (

View File

@ -3357,20 +3357,20 @@ QUERY: DROP FUNCTION hobbies(person);
QUERY: DROP FUNCTION hobby_construct(text,text);
QUERY: DROP FUNCTION equipment(hobbies_r);
QUERY: DROP FUNCTION user_relns();
QUERY: DROP FUNCTION circle_in(opaque);
QUERY: DROP FUNCTION circle_out(opaque);
QUERY: DROP FUNCTION pt_in_circle(point,circle);
QUERY: DROP FUNCTION widget_in(opaque);
QUERY: DROP FUNCTION widget_out(opaque);
QUERY: DROP FUNCTION pt_in_widget(point,widget);
QUERY: DROP FUNCTION overpaid(emp);
QUERY: DROP FUNCTION boxarea(box);
QUERY: DROP FUNCTION interpt_pp(path,path);
QUERY: DROP FUNCTION reverse_c16(char16);
QUERY: DROP OPERATOR ## (path, path);
QUERY: DROP OPERATOR <% (point, circle);
QUERY: DROP OPERATOR <% (point, widget);
QUERY: DROP OPERATOR @#@ (none, int4);
QUERY: DROP OPERATOR #@# (int4, none);
QUERY: DROP OPERATOR #%# (int4, none);
QUERY: DROP TYPE city_budget;
QUERY: DROP TYPE circle;
QUERY: DROP TYPE widget;
QUERY: DROP AGGREGATE newavg;
QUERY: DROP AGGREGATE newsum;
QUERY: DROP AGGREGATE newcnt;

View File

@ -3,12 +3,12 @@
--
--
CREATE FUNCTION circle_in(opaque)
RETURNS circle
CREATE FUNCTION widget_in(opaque)
RETURNS widget
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c';
CREATE FUNCTION circle_out(opaque)
CREATE FUNCTION widget_out(opaque)
RETURNS opaque
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c';
@ -42,7 +42,7 @@ CREATE FUNCTION user_relns()
relkind <> ''i'' '
LANGUAGE 'sql';
CREATE FUNCTION pt_in_circle(point, circle)
CREATE FUNCTION pt_in_widget(point, widget)
RETURNS int4
AS '_OBJWD_/regress_DLSUFFIX_'
LANGUAGE 'c';

View File

@ -1,5 +1,5 @@
/*
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.5 1997/03/14 23:34:16 scrappy Exp $
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.6 1997/04/22 17:33:00 scrappy Exp $
*/
#include <float.h> /* faked on sunos */
@ -103,22 +103,19 @@ poly2path(poly)
{
int i;
char *output = (char *)PALLOC(2*(P_MAXDIG + 1)*poly->npts + 64);
char *outptr = output;
double *xp, *yp;
char buf[2*(P_MAXDIG)+20];
sprintf(outptr, "(1, %*d", P_MAXDIG, poly->npts);
xp = (double *) poly->pts;
yp = (double *) (poly->pts + (poly->npts * sizeof(double *)));
sprintf(output, "(1, %*d", P_MAXDIG, poly->npts);
for (i=1; i<poly->npts; i++,xp++,yp++)
for (i=0; i<poly->npts; i++)
{
sprintf(outptr, ",%*g,%*g", P_MAXDIG, *xp, P_MAXDIG, *yp);
outptr += 2*(P_MAXDIG + 1);
sprintf(buf, ",%*g,%*g", P_MAXDIG, poly->p[i].x, P_MAXDIG, poly->p[i].y);
strcat(output, buf);
}
*outptr++ = RDELIM;
*outptr = '\0';
return(path_in(outptr));
sprintf(buf, "%c", RDELIM);
strcat(output, buf);
return(path_in(output));
}
/* return the point where two paths intersect. Assumes that they do. */
@ -176,24 +173,29 @@ char overpaid(tuple)
return(salary > 699);
}
/* New type "widget"
* This used to be "circle", but I added circle to builtins,
* so needed to make sure the names do not collide. - tgl 97/04/21
*/
typedef struct {
Point center;
double radius;
} CIRCLE;
} WIDGET;
extern CIRCLE *circle_in (char *str);
extern char *circle_out (CIRCLE *circle);
extern int pt_in_circle (Point *point, CIRCLE *circle);
extern WIDGET *widget_in (char *str);
extern char *widget_out (WIDGET *widget);
extern int pt_in_widget (Point *point, WIDGET *widget);
#define NARGS 3
CIRCLE *
circle_in(str)
WIDGET *
widget_in(str)
char *str;
{
char *p, *coord[NARGS], buf2[1000];
int i;
CIRCLE *result;
WIDGET *result;
if (str == NULL)
return(NULL);
@ -202,39 +204,39 @@ char *str;
coord[i++] = p + 1;
if (i < NARGS - 1)
return(NULL);
result = (CIRCLE *) palloc(sizeof(CIRCLE));
result = (WIDGET *) palloc(sizeof(WIDGET));
result->center.x = atof(coord[0]);
result->center.y = atof(coord[1]);
result->radius = atof(coord[2]);
sprintf(buf2, "circle_in: read (%f, %f, %f)\n", result->center.x,
sprintf(buf2, "widget_in: read (%f, %f, %f)\n", result->center.x,
result->center.y,result->radius);
return(result);
}
char *
circle_out(circle)
CIRCLE *circle;
widget_out(widget)
WIDGET *widget;
{
char *result;
if (circle == NULL)
if (widget == NULL)
return(NULL);
result = (char *) palloc(60);
(void) sprintf(result, "(%g,%g,%g)",
circle->center.x, circle->center.y, circle->radius);
widget->center.x, widget->center.y, widget->radius);
return(result);
}
int
pt_in_circle(point, circle)
pt_in_widget(point, widget)
Point *point;
CIRCLE *circle;
WIDGET *widget;
{
extern double point_dt();
return( point_dt(point, &circle->center) < circle->radius );
return( point_dt(point, &widget->center) < widget->radius );
}
#define ABS(X) ((X) > 0 ? (X) : -(X))
@ -247,8 +249,8 @@ BOX *box;
{
int width, height;
width = ABS(box->xh - box->xl);
height = ABS(box->yh - box->yl);
width = ABS(box->high.x - box->low.x);
height = ABS(box->high.y - box->low.y);
return (width * height);
}

View File

@ -10,8 +10,8 @@ CREATE OPERATOR ## (
CREATE OPERATOR <% (
leftarg = point,
rightarg = circle,
procedure = pt_in_circle,
rightarg = widget,
procedure = pt_in_widget,
commutator = >=%
);

View File

@ -3,10 +3,10 @@
--
--
CREATE TYPE circle (
CREATE TYPE widget (
internallength = 24,
input = circle_in,
output = circle_out,
input = widget_in,
output = widget_out,
alignment = double
);