PostGIS  2.2.7dev-r@@SVN_REVISION@@
static struct STRTree make_strtree ( void **  geoms,
uint32_t  num_geoms,
char  is_lwgeom 
)
static

Make a GEOSSTRtree of either GEOSGeometry* or LWGEOM* pointers.

Definition at line 60 of file lwgeom_geos_cluster.c.

References STRTree::envelopes, GBOX2GEOS(), STRTree::geom_ids, lwalloc(), lwgeom_get_bbox(), STRTree::num_geoms, STRTREE_NODE_CAPACITY, and STRTree::tree.

Referenced by union_intersecting_pairs(), and union_pairs_within_distance().

61 {
62  struct STRTree tree;
63  tree.tree = GEOSSTRtree_create(STRTREE_NODE_CAPACITY);
64  if (tree.tree == NULL)
65  {
66  return tree;
67  }
68  tree.envelopes = lwalloc(num_geoms * sizeof(GEOSGeometry*));
69  tree.geom_ids = lwalloc(num_geoms * sizeof(uint32_t));
70  tree.num_geoms = num_geoms;
71 
72  size_t i;
73  for (i = 0; i < num_geoms; i++)
74  {
75  tree.geom_ids[i] = i;
76  if (!is_lwgeom)
77  {
78  tree.envelopes[i] = GEOSEnvelope(geoms[i]);
79  }
80  else
81  {
82  const GBOX* box = lwgeom_get_bbox(geoms[i]);
83  if (box)
84  {
85  tree.envelopes[i] = GBOX2GEOS(box);
86  }
87  else
88  {
89  /* Empty geometry */
90  tree.envelopes[i] = GEOSGeom_createEmptyPolygon();
91  }
92  }
93  GEOSSTRtree_insert(tree.tree, tree.envelopes[i], &(tree.geom_ids[i]));
94  }
95  return tree;
96 }
GEOSGeometry * GBOX2GEOS(const GBOX *box)
GEOSSTRtree * tree
static const int STRTREE_NODE_CAPACITY
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
Definition: lwgeom.c:640
void * lwalloc(size_t size)
Definition: lwutil.c:199
uint32_t num_geoms

Here is the call graph for this function:

Here is the caller graph for this function: