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

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

1090 {
1091  int i, j, h;
1092 
1093  /* We sort by envelope area so that we know holes are only
1094  * after their shells */
1095  qsort(faces, nfaces, sizeof(Face*), compare_by_envarea);
1096  for (i=0; i<nfaces; ++i) {
1097  Face* f = faces[i];
1098  int nholes = GEOSGetNumInteriorRings(f->geom);
1099  LWDEBUGF(2, "Scanning face %d with env area %g and %d holes", i, f->envarea, nholes);
1100  for (h=0; h<nholes; ++h) {
1101  const GEOSGeometry *hole = GEOSGetInteriorRingN(f->geom, h);
1102  LWDEBUGF(2, "Looking for hole %d/%d of face %d among %d other faces", h+1, nholes, i, nfaces-i-1);
1103  for (j=i+1; j<nfaces; ++j) {
1104  const GEOSGeometry *f2er;
1105  Face* f2 = faces[j];
1106  if ( f2->parent ) continue; /* hole already assigned */
1107  f2er = GEOSGetExteriorRing(f2->geom);
1108  /* TODO: can be optimized as the ring would have the
1109  * same vertices, possibly in different order.
1110  * maybe comparing number of points could already be
1111  * useful.
1112  */
1113  if ( GEOSEquals(f2er, hole) ) {
1114  LWDEBUGF(2, "Hole %d/%d of face %d is face %d", h+1, nholes, i, j);
1115  f2->parent = f;
1116  break;
1117  }
1118  }
1119  }
1120  }
1121 }
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:55

Here is the call graph for this function:

Here is the caller graph for this function: