PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ findFaceHoles()

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

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

952 {
953  int i, j, h;
954 
955  /* We sort by envelope area so that we know holes are only after their shells */
956  qsort(faces, nfaces, sizeof(Face*), compare_by_envarea);
957  for (i = 0; i < nfaces; ++i)
958  {
959  Face* f = faces[i];
960  int nholes = GEOSGetNumInteriorRings(f->geom);
961  LWDEBUGF(2, "Scanning face %d with env area %g and %d holes", i, f->envarea, nholes);
962  for (h = 0; h < nholes; ++h)
963  {
964  const GEOSGeometry* hole = GEOSGetInteriorRingN(f->geom, h);
965  LWDEBUGF(2,
966  "Looking for hole %d/%d of face %d among %d other faces",
967  h + 1,
968  nholes,
969  i,
970  nfaces - i - 1);
971  for (j = i + 1; j < nfaces; ++j)
972  {
973  const GEOSGeometry* f2er;
974  Face* f2 = faces[j];
975  if (f2->parent) continue; /* hole already assigned */
976  f2er = GEOSGetExteriorRing(f2->geom);
977  /* TODO: can be optimized as the ring would have the same vertices, possibly in
978  * different order. Maybe comparing number of points could already be useful. */
979  if (GEOSEquals(f2er, hole))
980  {
981  LWDEBUGF(2, "Hole %d/%d of face %d is face %d", h + 1, nholes, i, j);
982  f2->parent = f;
983  break;
984  }
985  }
986  }
987  }
988 }
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: