PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ calc_tile_size()

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

Definition at line 453 of file raster2pgsql.c.

References FLT_EQ, and r.

Referenced by convert_raster().

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