PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ findFaceHoles()

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

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

981 {
982  int i, j, h;
983 
984  /* We sort by envelope area so that we know holes are only after their shells */
985  qsort(faces, nfaces, sizeof(Face*), compare_by_envarea);
986  for (i = 0; i < nfaces; ++i)
987  {
988  Face* f = faces[i];
989  int nholes = GEOSGetNumInteriorRings(f->geom);
990  LWDEBUGF(2, "Scanning face %d with env area %g and %d holes", i, f->envarea, nholes);
991  for (h = 0; h < nholes; ++h)
992  {
993  const GEOSGeometry* hole = GEOSGetInteriorRingN(f->geom, h);
994  LWDEBUGF(2,
995  "Looking for hole %d/%d of face %d among %d other faces",
996  h + 1,
997  nholes,
998  i,
999  nfaces - i - 1);
1000  for (j = i + 1; j < nfaces; ++j)
1001  {
1002  const GEOSGeometry* f2er;
1003  Face* f2 = faces[j];
1004  if (f2->parent) continue; /* hole already assigned */
1005  f2er = GEOSGetExteriorRing(f2->geom);
1006  /* TODO: can be optimized as the ring would have the same vertices, possibly in
1007  * different order. Maybe comparing number of points could already be useful. */
1008  if (GEOSEquals(f2er, hole))
1009  {
1010  LWDEBUGF(2, "Hole %d/%d of face %d is face %d", h + 1, nholes, i, j);
1011  f2->parent = f;
1012  break;
1013  }
1014  }
1015  }
1016  }
1017 }
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: