PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ make_strtree()

static struct STRTree make_strtree ( void **  geoms,
uint32_t  num_geoms,
char  is_lwgeom 
)
static

Make a GEOSSTRtree that stores a pointer to a variable containing the array index of the input geoms.

Definition at line 81 of file lwgeom_geos_cluster.c.

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

Referenced by union_dbscan_general(), union_dbscan_minpoints_1(), and union_intersecting_pairs().

82 {
83  struct STRTree tree;
84  tree.tree = GEOSSTRtree_create(STRTREE_NODE_CAPACITY);
85  if (tree.tree == NULL)
86  {
87  return tree;
88  }
89  tree.geom_ids = lwalloc(num_geoms * sizeof(uint32_t));
90  tree.num_geoms = num_geoms;
91 
92  if (is_lwgeom)
93  {
94  uint32_t i;
95  tree.envelopes = lwalloc(num_geoms * sizeof(GEOSGeometry*));
96  for (i = 0; i < num_geoms; i++)
97  {
98  tree.geom_ids[i] = i;
99  tree.envelopes[i] = geos_envelope_surrogate(geoms[i]);
100  GEOSSTRtree_insert(tree.tree, tree.envelopes[i], &(tree.geom_ids[i]));
101  }
102  }
103  else
104  {
105  uint32_t i;
106  tree.envelopes = NULL;
107  for (i = 0; i < num_geoms; i++)
108  {
109  tree.geom_ids[i] = i;
110  GEOSSTRtree_insert(tree.tree, geoms[i], &(tree.geom_ids[i]));
111  }
112  }
113 
114  return tree;
115 }
GEOSSTRtree * tree
unsigned int uint32_t
Definition: uthash.h:78
static const int STRTREE_NODE_CAPACITY
void * lwalloc(size_t size)
Definition: lwutil.c:229
uint32_t num_geoms
static GEOSGeometry * geos_envelope_surrogate(const LWGEOM *g)
Here is the call graph for this function:
Here is the caller graph for this function: