int ptarray_is_closed_z(const POINTARRAY *in) { if ( FLAGS_GET_Z(in->flags) ) return ptarray_is_closed_3d(in); else return ptarray_is_closed_2d(in); }
/* * Construct a triangle from a LWLINE being * the shell * Pointarray from intput geom are cloned. * Input line must have 4 points, and be closed. */ LWTRIANGLE * lwtriangle_from_lwline(const LWLINE *shell) { LWTRIANGLE *ret; POINTARRAY *pa; if ( shell->points->npoints != 4 ) lwerror("lwtriangle_from_lwline: shell must have exactly 4 points"); if ( (!FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_2d(shell->points)) || (FLAGS_GET_Z(shell->flags) && !ptarray_is_closed_3d(shell->points)) ) lwerror("lwtriangle_from_lwline: shell must be closed"); pa = ptarray_clone_deep(shell->points); ret = lwtriangle_construct(shell->srid, NULL, pa); if (lwtriangle_is_repeated_points(ret)) lwerror("lwtriangle_from_lwline: some points are repeated in triangle"); return ret; }
int lwpoly_is_closed(const LWPOLY *poly) { int i = 0; if ( poly->nrings == 0 ) return LW_TRUE; for ( i = 0; i < poly->nrings; i++ ) { if (FLAGS_GET_Z(poly->flags)) { if ( ! ptarray_is_closed_3d(poly->rings[i]) ) return LW_FALSE; } else { if ( ! ptarray_is_closed_2d(poly->rings[i]) ) return LW_FALSE; } } return LW_TRUE; }