PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ findFaceHoles()

static void findFaceHoles ( Face **  faces,
int  nfaces 
)
static

Definition at line 1169 of file liblwgeom/lwgeom_geos.c.

References compare_by_envarea(), Face_t::envarea, Face_t::geom, LWDEBUGF, and Face_t::parent.

Referenced by LWGEOM_GEOS_buildArea().

1170 {
1171  int i, j, h;
1172 
1173  /* We sort by envelope area so that we know holes are only
1174  * after their shells */
1175  qsort(faces, nfaces, sizeof(Face*), compare_by_envarea);
1176  for (i=0; i<nfaces; ++i) {
1177  Face* f = faces[i];
1178  int nholes = GEOSGetNumInteriorRings(f->geom);
1179  LWDEBUGF(2, "Scanning face %d with env area %g and %d holes", i, f->envarea, nholes);
1180  for (h=0; h<nholes; ++h) {
1181  const GEOSGeometry *hole = GEOSGetInteriorRingN(f->geom, h);
1182  LWDEBUGF(2, "Looking for hole %d/%d of face %d among %d other faces", h+1, nholes, i, nfaces-i-1);
1183  for (j=i+1; j<nfaces; ++j) {
1184  const GEOSGeometry *f2er;
1185  Face* f2 = faces[j];
1186  if ( f2->parent ) continue; /* hole already assigned */
1187  f2er = GEOSGetExteriorRing(f2->geom);
1188  /* TODO: can be optimized as the ring would have the
1189  * same vertices, possibly in different order.
1190  * maybe comparing number of points could already be
1191  * useful.
1192  */
1193  if ( GEOSEquals(f2er, hole) ) {
1194  LWDEBUGF(2, "Hole %d/%d of face %d is face %d", h+1, nholes, i, j);
1195  f2->parent = f;
1196  break;
1197  }
1198  }
1199  }
1200  }
1201 }
static int compare_by_envarea(const void *g1, const void *g2)
const GEOSGeometry * geom
struct Face_t * parent
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
Here is the call graph for this function:
Here is the caller graph for this function: