PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ findFaceHoles()

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

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

1045 {
1046  int i, j, h;
1047 
1048  /* We sort by envelope area so that we know holes are only after their shells */
1049  qsort(faces, nfaces, sizeof(Face*), compare_by_envarea);
1050  for (i = 0; i < nfaces; ++i)
1051  {
1052  Face* f = faces[i];
1053  int nholes = GEOSGetNumInteriorRings(f->geom);
1054  LWDEBUGF(2, "Scanning face %d with env area %g and %d holes", i, f->envarea, nholes);
1055  for (h = 0; h < nholes; ++h)
1056  {
1057  const GEOSGeometry* hole = GEOSGetInteriorRingN(f->geom, h);
1058  LWDEBUGF(2,
1059  "Looking for hole %d/%d of face %d among %d other faces",
1060  h + 1,
1061  nholes,
1062  i,
1063  nfaces - i - 1);
1064  for (j = i + 1; j < nfaces; ++j)
1065  {
1066  const GEOSGeometry* f2er;
1067  Face* f2 = faces[j];
1068  if (f2->parent) continue; /* hole already assigned */
1069  f2er = GEOSGetExteriorRing(f2->geom);
1070  /* TODO: can be optimized as the ring would have the same vertices, possibly in
1071  * different order. Maybe comparing number of points could already be useful. */
1072  if (GEOSEquals(f2er, hole))
1073  {
1074  LWDEBUGF(2, "Hole %d/%d of face %d is face %d", h + 1, nholes, i, j);
1075  f2->parent = f;
1076  break;
1077  }
1078  }
1079  }
1080  }
1081 }
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: