PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ calc_tile_size()

static void calc_tile_size ( int  dimX,
int  dimY,
int *  tileX,
int *  tileY 
)
static

Definition at line 450 of file raster2pgsql.c.

References FLT_EQ, and r.

Referenced by convert_raster().

453  {
454  int i = 0;
455  int j = 0;
456  int min = 30;
457  int max = 100;
458 
459  int d = 0;
460  double r = 0;
461  /*int _d = 0;*/
462  double _r = -1;
463  int _i = 0;
464 
465  /* j = 0, X */
466  for (j = 0; j < 2; j++) {
467  _i = 0;
468  /*_d = 0;*/
469  _r = -1;
470 
471  if (j < 1 && dimX <= max) {
472  *tileX = dimX;
473  continue;
474  }
475  else if (dimY <= max) {
476  *tileY = dimY;
477  continue;
478  }
479 
480  for (i = max; i >= min; i--) {
481  if (j < 1) {
482  d = dimX / i;
483  r = (double) dimX / (double) i;
484 
485  }
486  else {
487  d = dimY / i;
488  r = (double) dimY / (double) i;
489  }
490  r = r - (double) d;
491 
492  if (
493  FLT_EQ(_r, -1) ||
494  (r < _r) ||
495  FLT_EQ(r, _r)
496  ) {
497  /*_d = d;*/
498  _r = r;
499  _i = i;
500  }
501  }
502 
503  if (j < 1)
504  *tileX = _i;
505  else
506  *tileY = _i;
507  }
508 }
char * r
Definition: cu_in_wkt.c:24
#define FLT_EQ(x, y)
Definition: librtcore.h:2185
Here is the caller graph for this function: