PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void calc_tile_size ( int  dimX,
int  dimY,
int *  tileX,
int *  tileY 
)
static

Definition at line 443 of file raster2pgsql.c.

References FLT_EQ, and r.

Referenced by convert_raster().

446  {
447  int i = 0;
448  int j = 0;
449  int min = 30;
450  int max = 100;
451 
452  int d = 0;
453  double r = 0;
454  /*int _d = 0;*/
455  double _r = -1;
456  int _i = 0;
457 
458  /* j = 0, X */
459  for (j = 0; j < 2; j++) {
460  _i = 0;
461  /*_d = 0;*/
462  _r = -1;
463 
464  if (j < 1 && dimX <= max) {
465  *tileX = dimX;
466  continue;
467  }
468  else if (dimY <= max) {
469  *tileY = dimY;
470  continue;
471  }
472 
473  for (i = max; i >= min; i--) {
474  if (j < 1) {
475  d = dimX / i;
476  r = (double) dimX / (double) i;
477 
478  }
479  else {
480  d = dimY / i;
481  r = (double) dimY / (double) i;
482  }
483  r = r - (double) d;
484 
485  if (
486  FLT_EQ(_r, -1) ||
487  (r < _r) ||
488  FLT_EQ(r, _r)
489  ) {
490  /*_d = d;*/
491  _r = r;
492  _i = i;
493  }
494  }
495 
496  if (j < 1)
497  *tileX = _i;
498  else
499  *tileY = _i;
500  }
501 }
char * r
Definition: cu_in_wkt.c:25
#define FLT_EQ(x, y)
Definition: rt_api.h:2159

Here is the caller graph for this function: