Index: src/backend/utils/adt/geo_ops.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/adt/geo_ops.c,v retrieving revision 1.84 diff -u -r1.84 geo_ops.c --- src/backend/utils/adt/geo_ops.c 12 May 2004 22:38:44 -0000 1.84 +++ src/backend/utils/adt/geo_ops.c 18 May 2004 18:59:40 -0000 @@ -1313,6 +1313,27 @@ *---------------------------------------------------------*/ Datum +path_area(PG_FUNCTION_ARGS) +{ + PATH *path = PG_GETARG_PATH_P(0); + double area = 0.0; + int i,j; + + if (!path->closed) + PG_RETURN_NULL(); + + for (i = 0; i < path->npts; i++) { + j = (i + 1) % path->npts; + area += path->p[i].x * path->p[j].y; + area -= path->p[i].y * path->p[j].x; + } + + area *= 0.5; + PG_RETURN_FLOAT8(area < 0.0 ? -area : area); +} + + +Datum path_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); Index: src/include/catalog/pg_proc.h =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/include/catalog/pg_proc.h,v retrieving revision 1.329 diff -u -r1.329 pg_proc.h --- src/include/catalog/pg_proc.h 14 May 2004 21:42:28 -0000 1.329 +++ src/include/catalog/pg_proc.h 18 May 2004 18:59:41 -0000 @@ -1259,6 +1259,8 @@ DESCR("box height"); DATA(insert OID = 978 ( box_distance PGNSP PGUID 12 f f t f i 2 701 "603 603" _null_ box_distance - _null_ )); DESCR("distance between boxes"); +DATA(insert OID = 979 ( area PGNSP PGUID 12 f f t f i 1 701 "602" _null_ path_area - _null_ )); +DESCR("area of a closed path"); DATA(insert OID = 980 ( box_intersect PGNSP PGUID 12 f f t f i 2 603 "603 603" _null_ box_intersect - _null_ )); DESCR("box intersection (another box)"); DATA(insert OID = 981 ( diagonal PGNSP PGUID 12 f f t f i 1 601 "603" _null_ box_diagonal - _null_ )); Index: src/include/utils/geo_decls.h =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/include/utils/geo_decls.h,v retrieving revision 1.43 diff -u -r1.43 geo_decls.h --- src/include/utils/geo_decls.h 29 Nov 2003 22:41:15 -0000 1.43 +++ src/include/utils/geo_decls.h 18 May 2004 18:59:41 -0000 @@ -305,6 +305,7 @@ extern Datum box_div(PG_FUNCTION_ARGS); /* public path routines */ +extern Datum path_area(PG_FUNCTION_ARGS); extern Datum path_in(PG_FUNCTION_ARGS); extern Datum path_out(PG_FUNCTION_ARGS); extern Datum path_recv(PG_FUNCTION_ARGS);