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

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

845 {
846  int i, j, h;
847 
848  /* We sort by envelope area so that we know holes are only
849  * after their shells */
850  qsort(faces, nfaces, sizeof(Face*), compare_by_envarea);
851  for (i=0; i<nfaces; ++i) {
852  Face* f = faces[i];
853  int nholes = GEOSGetNumInteriorRings(f->geom);
854  LWDEBUGF(2, "Scanning face %d with env area %g and %d holes", i, f->envarea, nholes);
855  for (h=0; h<nholes; ++h) {
856  const GEOSGeometry *hole = GEOSGetInteriorRingN(f->geom, h);
857  LWDEBUGF(2, "Looking for hole %d/%d of face %d among %d other faces", h+1, nholes, i, nfaces-i-1);
858  for (j=i+1; j<nfaces; ++j) {
859  const GEOSGeometry *f2er;
860  Face* f2 = faces[j];
861  if ( f2->parent ) continue; /* hole already assigned */
862  f2er = GEOSGetExteriorRing(f2->geom);
863  /* TODO: can be optimized as the ring would have the
864  * same vertices, possibly in different order.
865  * maybe comparing number of points could already be
866  * useful.
867  */
868  if ( GEOSEquals(f2er, hole) ) {
869  LWDEBUGF(2, "Hole %d/%d of face %d is face %d", h+1, nholes, i, j);
870  f2->parent = f;
871  break;
872  }
873  }
874  }
875  }
876 }
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: