PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ nd_box_ratio()

static double nd_box_ratio ( const ND_BOX cover,
const ND_BOX target,
int  ndims 
)
inlinestatic

Definition at line 201 of file gserialized_estimate_support.h.

202{
203 int d;
204 bool fully_covered = true;
205 double ivol = 1.0;
206 double refvol = 1.0;
207
208 for (d = 0; d < ndims; d++)
209 {
210 if (cover->max[d] <= target->min[d] || cover->min[d] >= target->max[d])
211 return 0.0; /* Disjoint */
212
213 if (cover->min[d] > target->min[d] || cover->max[d] < target->max[d])
214 fully_covered = false;
215 }
216
217 if (fully_covered)
218 return 1.0;
219
220 for (d = 0; d < ndims; d++)
221 {
222 double width = target->max[d] - target->min[d];
223 double imin = Max(cover->min[d], target->min[d]);
224 double imax = Min(cover->max[d], target->max[d]);
225 double iwidth = Max(0.0, imax - imin);
226
227 refvol *= width;
228 ivol *= iwidth;
229 }
230
231 if (refvol == 0.0)
232 return refvol;
233
234 return ivol / refvol;
235}

References ND_BOX_T::max, and ND_BOX_T::min.

Referenced by compute_gserialized_stats_mode(), estimate_join_selectivity(), estimate_selectivity(), and nd_box_ratio_cases().

Here is the caller graph for this function: