lib/cache_sqlite.c
static void _bind_sqlite_params(mapcache_context *ctx, void *vstmt, mapcache_tile *tile)
{
  sqlite3_stmt *stmt = vstmt;
  int paramidx;
  /* tile->x */
  paramidx = sqlite3_bind_parameter_index(stmt, ":x");
  if (paramidx) sqlite3_bind_int(stmt, paramidx, tile->x);

  /* tile->y */
  paramidx = sqlite3_bind_parameter_index(stmt, ":y");
  if (paramidx) sqlite3_bind_int(stmt, paramidx, tile->y);

  /* tile->y */
  paramidx = sqlite3_bind_parameter_index(stmt, ":z");
  if (paramidx) sqlite3_bind_int(stmt, paramidx, tile->z);

  /* eventual dimensions */
  paramidx = sqlite3_bind_parameter_index(stmt, ":dim");
  if (paramidx) {
    if (tile->dimensions) {
      char *dim = mapcache_util_get_tile_dimkey(ctx, tile, NULL, NULL);
      sqlite3_bind_text(stmt, paramidx, dim, -1, SQLITE_STATIC);
    } else {
      sqlite3_bind_text(stmt, paramidx, "", -1, SQLITE_STATIC);
    }
  }

  /* grid */
  paramidx = sqlite3_bind_parameter_index(stmt, ":grid");
  if (paramidx) sqlite3_bind_text(stmt, paramidx, tile->grid_link->grid->name, -1, SQLITE_STATIC);

  /* tileset */
  paramidx = sqlite3_bind_parameter_index(stmt, ":tileset");
  if (paramidx) sqlite3_bind_text(stmt, paramidx, tile->tileset->name, -1, SQLITE_STATIC);

  /* tile blob data */
  paramidx = sqlite3_bind_parameter_index(stmt, ":data");
  if (paramidx) {
    int written = 0;
    if(((mapcache_cache_sqlite*)tile->tileset->cache)->detect_blank && tile->grid_link->grid->tile_sx == 256 &&
            tile->grid_link->grid->tile_sy == 256) {
      if(!tile->raw_image) {
        tile->raw_image = mapcache_imageio_decode(ctx, tile->encoded_data);
        GC_CHECK_ERROR(ctx);
      }
      if(mapcache_image_blank_color(tile->raw_image) != MAPCACHE_FALSE) {
        char *buf = apr_palloc(ctx->pool, 5* sizeof(char));
        buf[0] = '#';
        memcpy(buf+1,tile->raw_image->data,4);
        written = 1;
        sqlite3_bind_blob(stmt, paramidx, buf, 5, SQLITE_STATIC);
      }
    }
    if(!written) {
      if (!tile->encoded_data) {
        tile->encoded_data = tile->tileset->format->write(ctx, tile->raw_image, tile->tileset->format);
        GC_CHECK_ERROR(ctx);
      }
      if (tile->encoded_data && tile->encoded_data->size) {
        sqlite3_bind_blob(stmt, paramidx, tile->encoded_data->buf, tile->encoded_data->size, SQLITE_STATIC);
      } else {
        sqlite3_bind_text(stmt, paramidx, "", -1, SQLITE_STATIC);
      }
    }
  }
}
/**
 * \brief apply appropriate tile properties to the sqlite statement */
\brief apply appropriate tile properties to the sqlite statement
\ brief apply appropriate tile properties to the sqlite statement
static void _bind_sqlite_params(mapcache_context *ctx, void *vstmt, mapcache_tile *tile)
{
  sqlite3_stmt *stmt = vstmt;
  int paramidx;
  paramidx = sqlite3_bind_parameter_index(stmt, ":x");
  if (paramidx) sqlite3_bind_int(stmt, paramidx, tile->x);
  paramidx = sqlite3_bind_parameter_index(stmt, ":y");
  if (paramidx) sqlite3_bind_int(stmt, paramidx, tile->y);
  paramidx = sqlite3_bind_parameter_index(stmt, ":z");
  if (paramidx) sqlite3_bind_int(stmt, paramidx, tile->z);
  paramidx = sqlite3_bind_parameter_index(stmt, ":dim");
  if (paramidx) {
    if (tile->dimensions) {
      char *dim = mapcache_util_get_tile_dimkey(ctx, tile, NULL, NULL);
      sqlite3_bind_text(stmt, paramidx, dim, -1, SQLITE_STATIC);
    } else {
      sqlite3_bind_text(stmt, paramidx, "", -1, SQLITE_STATIC);
    }
  }
  paramidx = sqlite3_bind_parameter_index(stmt, ":grid");
  if (paramidx) sqlite3_bind_text(stmt, paramidx, tile->grid_link->grid->name, -1, SQLITE_STATIC);
  paramidx = sqlite3_bind_parameter_index(stmt, ":tileset");
  if (paramidx) sqlite3_bind_text(stmt, paramidx, tile->tileset->name, -1, SQLITE_STATIC);
  paramidx = sqlite3_bind_parameter_index(stmt, ":data");
  if (paramidx) {
    int written = 0;
    if(((mapcache_cache_sqlite*)tile->tileset->cache)->detect_blank && tile->grid_link->grid->tile_sx == 256 &&
            tile->grid_link->grid->tile_sy == 256) {
      if(!tile->raw_image) {
        tile->raw_image = mapcache_imageio_decode(ctx, tile->encoded_data);
        GC_CHECK_ERROR(ctx);
      }
      if(mapcache_image_blank_color(tile->raw_image) != MAPCACHE_FALSE) {
        char *buf = apr_palloc(ctx->pool, 5* sizeof(char));
        buf[0] = '#';
        memcpy(buf+1,tile->raw_image->data,4);
        written = 1;
        sqlite3_bind_blob(stmt, paramidx, buf, 5, SQLITE_STATIC);
      }
    }
    if(!written) {
      if (!tile->encoded_data) {
        tile->encoded_data = tile->tileset->format->write(ctx, tile->raw_image, tile->tileset->format);
        GC_CHECK_ERROR(ctx);
      }
      if (tile->encoded_data && tile->encoded_data->size) {
        sqlite3_bind_blob(stmt, paramidx, tile->encoded_data->buf, tile->encoded_data->size, SQLITE_STATIC);
      } else {
        sqlite3_bind_text(stmt, paramidx, "", -1, SQLITE_STATIC);
      }
    }
  }
}
static void _bind_sqlite_params ( mapcache_context * ctx , void * vstmt , mapcache_tile * tile ) { sqlite3_stmt * stmt = vstmt ; int paramidx ; paramidx = sqlite3_bind_parameter_index ( stmt , " " ) ; if ( paramidx ) sqlite3_bind_int ( stmt , paramidx , tile -> x ) ; paramidx = sqlite3_bind_parameter_index ( stmt , " " ) ; if ( paramidx ) sqlite3_bind_int ( stmt , paramidx , tile -> y ) ; paramidx = sqlite3_bind_parameter_index ( stmt , " " ) ; if ( paramidx ) sqlite3_bind_int ( stmt , paramidx , tile -> z ) ; paramidx = sqlite3_bind_parameter_index ( stmt , " " ) ; if ( paramidx ) { if ( tile -> dimensions ) { char * dim = mapcache_util_get_tile_dimkey ( ctx , tile , NULL , NULL ) ; sqlite3_bind_text ( stmt , paramidx , dim , -1 , SQLITE_STATIC ) ; } else { sqlite3_bind_text ( stmt , paramidx , " " , -1 , SQLITE_STATIC ) ; } } paramidx = sqlite3_bind_parameter_index ( stmt , " " ) ; if ( paramidx ) sqlite3_bind_text ( stmt , paramidx , tile -> grid_link -> grid -> name , -1 , SQLITE_STATIC ) ; paramidx = sqlite3_bind_parameter_index ( stmt , " " ) ; if ( paramidx ) sqlite3_bind_text ( stmt , paramidx , tile -> tileset -> name , -1 , SQLITE_STATIC ) ; paramidx = sqlite3_bind_parameter_index ( stmt , " " ) ; if ( paramidx ) { int written = 0 ; if ( ( ( mapcache_cache_sqlite * ) tile -> tileset -> cache ) -> detect_blank && tile -> grid_link -> grid -> tile_sx == 256 && tile -> grid_link -> grid -> tile_sy == 256 ) { if ( ! tile -> raw_image ) { tile -> raw_image = mapcache_imageio_decode ( ctx , tile -> encoded_data ) ; GC_CHECK_ERROR ( ctx ) ; } if ( mapcache_image_blank_color ( tile -> raw_image ) != MAPCACHE_FALSE ) { char * buf = apr_palloc ( ctx -> pool , 5 * sizeof ( char ) ) ; buf [ 0 ] = ' ' ; memcpy ( buf + 1 , tile -> raw_image -> data , 4 ) ; written = 1 ; sqlite3_bind_blob ( stmt , paramidx , buf , 5 , SQLITE_STATIC ) ; } } if ( ! written ) { if ( ! tile -> encoded_data ) { tile -> encoded_data = tile -> tileset -> format -> write ( ctx , tile -> raw_image , tile -> tileset -> format ) ; GC_CHECK_ERROR ( ctx ) ; } if ( tile -> encoded_data && tile -> encoded_data -> size ) { sqlite3_bind_blob ( stmt , paramidx , tile -> encoded_data -> buf , tile -> encoded_data -> size , SQLITE_STATIC ) ; } else { sqlite3_bind_text ( stmt , paramidx , " " , -1 , SQLITE_STATIC ) ; } } } }
\brief apply appropriate tile properties to the sqlite statement
\ brief apply appropriate tile properties to the sqlite statement
/* tile->x */ /* tile->y */ /* tile->y */ /* eventual dimensions */ /* grid */ /* tileset */ /* tile blob data */