PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ findFaceHoles()

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

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

1199 {
1200  int i, j, h;
1201 
1202  /* We sort by envelope area so that we know holes are only
1203  * after their shells */
1204  qsort(faces, nfaces, sizeof(Face*), compare_by_envarea);
1205  for (i=0; i<nfaces; ++i) {
1206  Face* f = faces[i];
1207  int nholes = GEOSGetNumInteriorRings(f->geom);
1208  LWDEBUGF(2, "Scanning face %d with env area %g and %d holes", i, f->envarea, nholes);
1209  for (h=0; h<nholes; ++h) {
1210  const GEOSGeometry *hole = GEOSGetInteriorRingN(f->geom, h);
1211  LWDEBUGF(2, "Looking for hole %d/%d of face %d among %d other faces", h+1, nholes, i, nfaces-i-1);
1212  for (j=i+1; j<nfaces; ++j) {
1213  const GEOSGeometry *f2er;
1214  Face* f2 = faces[j];
1215  if ( f2->parent ) continue; /* hole already assigned */
1216  f2er = GEOSGetExteriorRing(f2->geom);
1217  /* TODO: can be optimized as the ring would have the
1218  * same vertices, possibly in different order.
1219  * maybe comparing number of points could already be
1220  * useful.
1221  */
1222  if ( GEOSEquals(f2er, hole) ) {
1223  LWDEBUGF(2, "Hole %d/%d of face %d is face %d", h+1, nholes, i, j);
1224  f2->parent = f;
1225  break;
1226  }
1227  }
1228  }
1229  }
1230 }
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: