PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ test_ptarray_signed_area()

static void test_ptarray_signed_area ( )
static

Definition at line 317 of file cu_ptarray.c.

References area(), lwgeom_as_lwline(), lwgeom_from_text(), lwline_free(), LWLINE::points, and ptarray_signed_area().

Referenced by ptarray_suite_setup().

318 {
319  LWLINE *line;
320  double area;
321 
322  /* parallelogram */
323  line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 0,1 1, 2 1, 1 0, 0 0)"));
324  area = ptarray_signed_area(line->points);
325  CU_ASSERT_DOUBLE_EQUAL(area, 1.0, 0.0000001);
326  lwline_free(line);
327 
328  /* square */
329  line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 0,0 2, 2 2, 2 0, 0 0)"));
330  area = ptarray_signed_area(line->points);
331  CU_ASSERT_DOUBLE_EQUAL(area, 4.0, 0.0000001);
332  lwline_free(line);
333 
334  /* square backwares*/
335  line = lwgeom_as_lwline(lwgeom_from_text("LINESTRING(0 0,2 0, 2 2, 0 2, 0 0)"));
336  area = ptarray_signed_area(line->points);
337  //printf("%g\n",area);
338  CU_ASSERT_DOUBLE_EQUAL(area, -4.0, 0.0000001);
339  lwline_free(line);
340 
341 }
Datum area(PG_FUNCTION_ARGS)
void lwline_free(LWLINE *line)
Definition: lwline.c:76
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
Definition: ptarray.c:990
static LWGEOM * lwgeom_from_text(const char *str)
Definition: cu_ptarray.c:24
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:170
POINTARRAY * points
Definition: liblwgeom.h:424
Here is the call graph for this function:
Here is the caller graph for this function: