PostGIS  2.5.0dev-r@@SVN_REVISION@@
static void findFaceHoles ( Face **  faces,
int  nfaces 
)
static

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

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