diff options
Diffstat (limited to 'src/backend/utils/adt/geo_ops.c')
-rw-r--r-- | src/backend/utils/adt/geo_ops.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 4236be5471f..0dd5f2a75c5 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.84 2004/05/12 22:38:44 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/geo_ops.c,v 1.85 2004/05/26 18:35:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1313,6 +1313,27 @@ line_interpt_internal(LINE *l1, LINE *l2) *---------------------------------------------------------*/ 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); |