PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_ptarray_signed_area ( )
static

Definition at line 318 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().

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

Here is the call graph for this function:

Here is the caller graph for this function: