Index: trunk/SophyaExt/FitsIOServer/exclude
===================================================================
--- trunk/SophyaExt/FitsIOServer/exclude	(revision 2174)
+++ trunk/SophyaExt/FitsIOServer/exclude	(revision 2197)
@@ -4,3 +4,2 @@
 fitsbntbllinereader.travail.cc
 fitsbntbllinereader.sv.cc
-fitsspherethetaphi.cc
Index: trunk/SophyaExt/FitsIOServer/fitsbntbllineRW.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsbntbllineRW.cc	(revision 2174)
+++ trunk/SophyaExt/FitsIOServer/fitsbntbllineRW.cc	(revision 2197)
@@ -16,5 +16,5 @@
 }
 
-FITS_BntblLineReader::FITS_BntblLineReader(char inputfile[],int hdunum) 
+FITS_BntblLineReader::FITS_BntblLineReader(const char inputfile[],int hdunum) 
                                                                  
 {
@@ -134,5 +134,5 @@
   for (k=0; k<ic;k++)
     {
-      types+='I';
+      types+='J';
     }
   for (k=0; k<lc;k++)
Index: trunk/SophyaExt/FitsIOServer/fitsbntbllineRW.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsbntbllineRW.h	(revision 2174)
+++ trunk/SophyaExt/FitsIOServer/fitsbntbllineRW.h	(revision 2197)
@@ -19,5 +19,5 @@
 public:
 FITS_BntblLineReader();
-FITS_BntblLineReader(char inputfile[],int hdunum=2);
+FITS_BntblLineReader(const char inputfile[],int hdunum=2);
 ~FITS_BntblLineReader();
 
Index: trunk/SophyaExt/FitsIOServer/fitsfile.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsfile.cc	(revision 2174)
+++ trunk/SophyaExt/FitsIOServer/fitsfile.cc	(revision 2197)
@@ -26,8 +26,8 @@
     if (dc >0) ddata_ = vector<double>(dc);
     if (fc >0) fdata_ = vector<float>(fc);
-    if (ic >0) idata_ = vector<int>(fc);
-    if (cc >0) cdata_ = vector<string>(fc);
+    if (ic >0) idata_ = vector<int>(ic);
     if (lc >0) ldata_ = vector<long>(lc);
     if (bc >0) bdata_ = vector<unsigned char>(bc);
+    if (cc >0) cdata_ = vector<string>(cc);
    }
 
@@ -66,5 +66,133 @@
    }
 
-
+FitsFile::BufferLine::BufferLine(const vector<FitsFile::FitsDataType>& types)
+{
+
+
+  int dc=0;
+  int fc=0;
+  int shc=0;
+  int ic=0;
+  int lc=0;
+  int cc=0;
+  int bc=0;
+  id_  = vector< pair<FitsFile::FitsDataType, int> >(types.size());
+  for (int k= 0; k < types.size(); k++)
+    {
+      switch( types[k] )
+	{
+	case FitsFile::FitsDataType_double :
+	  {
+            id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_double, dc);
+	    dc++;
+	    break;
+	  }
+	case FitsFile::FitsDataType_float :
+	  {
+            id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_float, fc);
+	    fc++;
+	    break;
+	  }
+	case  FitsFile::FitsDataType_short :
+	  {
+            id_[k] = pair<FitsFile::FitsDataType, int>(FitsDataType_short, shc);
+	    shc++;
+	    break;
+	  }
+	case  FitsFile::FitsDataType_int :
+	  {
+            id_[k] = pair<FitsFile::FitsDataType, int>(FitsDataType_int, ic);
+	    ic++;
+	    break;
+	  }
+	case  FitsFile::FitsDataType_long :
+	  {
+            id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_long, lc);
+	    lc++;
+	    break;
+	  }
+	case  FitsFile::FitsDataType_byte :
+	  {
+            id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_byte, bc);
+	    bc++;
+	    break;
+	  }
+	case FitsDataType_char :
+	  {
+            id_[k] = pair<FitsFile::FitsDataType, int>(FitsFile::FitsDataType_char, cc);
+	    cc++;
+	    break;
+	  }
+	default:
+	  {
+	    throw PException(" FitsFile::getHeaderWithSophyaObject() : unsupported FITS data type");
+	  }
+	}
+    }
+
+  if (dc >0) ddata_ = vector<r_8>(dc);
+  if (fc >0) fdata_ = vector<r_4>(fc);
+  if (shc >0) shdata_ = vector<int_2>(shc);
+  if (ic >0) idata_ = vector<int_4>(ic);
+  if (lc >0) ldata_ = vector<int_8>(lc);
+  if (cc >0) cdata_ = vector<string>(cc);
+  if (bc >0) bdata_ = vector<unsigned char>(bc);
+}
+
+
+void FitsFile::BufferLine::Print() const
+{
+  cout << " impression de la ligne: " << endl;
+
+  cout << " doubles : " << endl;
+  for (int k=0; k< ddata_.size(); k++)
+    {
+      cout << ddata_[k] << " " ;
+    } 
+  cout << endl;
+
+  cout << " floats : " << endl;
+  for (int k=0; k< fdata_.size(); k++)
+    {
+      cout << fdata_[k] << " " ;
+    } 
+  cout << endl;
+
+  cout << " entiers courts: " << endl;
+  for (int k=0; k< shdata_.size(); k++)
+    {
+      cout << shdata_[k] << " " ;
+    } 
+  cout << endl;
+  cout << " entiers : " << endl;
+  for (int k=0; k< idata_.size(); k++)
+    {
+      cout << idata_[k] << " " ;
+    } 
+  cout << endl;
+
+  cout << " entiers longs : " << endl;
+  for (int k=0; k< ldata_.size(); k++)
+    {
+      cout << ldata_[k] << " " ;
+    } 
+  cout << endl;
+
+  cout << " chaines carac.  : " << endl;
+  for (int k=0; k< cdata_.size(); k++)
+    {
+      cout << cdata_[k] << " " ;
+    } 
+  cout << endl;
+
+  cout << " bytes : " << endl;
+  for (int k=0; k< bdata_.size(); k++)
+    {
+      cout << (char)bdata_[k] << " " ;
+    } 
+  cout << endl;
+
+
+}
 
 /*!
@@ -601,4 +729,6 @@
 	  // printerror( status,":FitsInFile::getHeader : erreur movabs");
 	}
+	
+
       if(hdutype == IMAGE_HDU) 
 	{
@@ -627,4 +757,9 @@
 	  KeywordsIntoDVList(fptr_, dvl_, hdunum_);
 	}
+
+    }
+  if (hdutype_ == FitsExtensionType_BINARY_TBL || hdutype_ == FitsExtensionType_ASCII_TBL)
+    {
+      bfl_ = BufferLine(types_);
     }
 }
@@ -736,4 +871,71 @@
     }
   return  taille_des_chaines_[index];
+}
+
+const FitsFile::BufferLine&   FitsInFile::GetBufferLine(long NoLine) 
+{
+  int status= 0;
+  int    anynul;
+  double dnull= dnull_;
+  float fnull= fnull_;
+  int inull= inull_;
+  char* cnull=  const_cast<char*>(cnull_.c_str());
+  int ncol;
+  long nels=1;
+  double dval;
+  float  fval;
+  int    ival;
+
+  // pas d'entier de longueur superieure a 32 bits, pour cfitsio
+  int    lval;
+
+  unsigned char usval; 
+  int rang = 0;
+  int ccount = 0;
+  for (ncol=0; ncol<nbcols_; ncol++)
+    {
+      rang =  bfl_.identificateur()[ncol].second;
+      //      cout << " fitsfile : relecture col " << ncol << " type " << bfl_.identificateur()[ncol].first << " rang " << rang << endl; 
+      switch (bfl_.identificateur()[ncol].first)
+	{ 
+	case FitsDataType_double :
+	  fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull, &dval,&anynul,&status);
+	  bfl_.r_8Array(rang) = (r_8)dval;
+	  break;
+	case FitsDataType_float :
+	  fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&fval,&anynul,&status);
+	  bfl_.r_4Array(rang)  = (r_4)fval;
+	  break;
+	case FitsDataType_short :
+	  fits_read_col(fptr_,TSHORT,ncol+1,NoLine+1,1,1,&inull,&ival, &anynul,&status);
+	  bfl_.int_2Array(rang) = (int_2)ival;
+	  break;
+	case FitsDataType_int :
+	  fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&ival, &anynul,&status);
+	  bfl_.int_4Array(rang) = (int_4)ival;
+	  break;
+	case FitsDataType_long :
+	  fits_read_col(fptr_,TLONG,ncol+1,NoLine+1,1,1,&inull,&lval, &anynul,&status);
+	  bfl_.int_8Array(rang) = (int_8)lval;
+	  break;
+	case FitsDataType_byte :
+	  fits_read_col(fptr_,TBYTE,ncol+1,NoLine+1,1,1,&inull, &usval, &anynul,&status);
+	  bfl_.u_charArray(rang) = usval;
+	  break;
+	case FitsDataType_char :
+	  char* chaine = new char[taille_des_chaines_[ccount++]];
+	  fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&chaine,&anynul,&status);
+	  bfl_.stringArray(rang) = string(chaine);
+	  break;
+	}
+      if (status)
+	{
+	  ResetStatus(status);
+	  break;
+	}
+    }
+  //  cout << " fitsfile : ligne relue " << endl;
+  //  bfl_.Print();
+  return bfl_;
 }
 
@@ -778,14 +980,20 @@
 	    break;
 	  }
-	case FitsDataType_float :	  
-	  fits_read_col(fptr_,TFLOAT,ncol+1,ligneALire,premierElement,1,&fnull,&fdata[fcount++],&anynul,&status);
-	  break;
+	case FitsDataType_float :
+	  {	  
+	    fits_read_col(fptr_,TFLOAT,ncol+1,ligneALire,premierElement,1,&fnull,&fdata[fcount++],&anynul,&status);
+	    break;
+	  }
 	case  FitsDataType_int :
-	  fits_read_col(fptr_,TINT,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++],
+	  {
+	    fits_read_col(fptr_,TINT,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++],
 			&anynul,&status);
-	  break;
+	    break;
+	  }
 	case  FitsDataType_long :
-	  fits_read_col(fptr_,TLONG,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++], &anynul,&status);
-          break;
+	  {
+	    fits_read_col(fptr_,TLONG,ncol+1,ligneALire,premierElement,1,&inull,&idata[icount++], &anynul,&status);
+	    break;
+	  }
 	case  FitsDataType_byte :
 	  {
@@ -793,9 +1001,15 @@
 	    fits_read_col(fptr_,TBYTE,ncol+1,ligneALire,premierElement,1,&inull,&uschar, &anynul,&status);
 	    idata[icount++] = (int)uschar;
-	  }
-	  break;
+	    break;
+	  }
 	case FitsDataType_char :
-	  fits_read_col(fptr_,TSTRING,ncol+1,ligneALire,premierElement,1,cnull,&cdata[ccount++],&anynul,&status);
-	  break;
+	  {
+	    fits_read_col(fptr_,TSTRING,ncol+1,ligneALire,premierElement,1,cnull,&cdata[ccount++],&anynul,&status);
+	    break;
+	  }
+	default:
+	  {
+	    throw PException(" FitsInFile::GetBinTabLine : unsupported FITS data type");
+	  }
 	}
       if (status)
@@ -829,23 +1043,39 @@
 	{ 
 	case FitsDataType_double :
-	  fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull,&ligne.ddata_[dcount++],&anynul,&status);
-	  break;
+	  {
+	    fits_read_col(fptr_,TDOUBLE,ncol+1,NoLine+1,1,1,&dnull,&ligne.ddata_[dcount++],&anynul,&status);
+	    break;
+	  }
 	case FitsDataType_float :
-	  fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&ligne.fdata_[fcount++],&anynul,&status);
-	  break;
+	  {
+	    fits_read_col(fptr_,TFLOAT,ncol+1,NoLine+1,1,1,&fnull,&ligne.fdata_[fcount++],&anynul,&status);
+	    break;
+	  }
 	case FitsDataType_int :
-	  fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&ligne.idata_[icount++], &anynul,&status);
-	  break;
+	  {
+	    fits_read_col(fptr_,TINT,ncol+1,NoLine+1,1,1,&inull,&ligne.idata_[icount++], &anynul,&status);
+	    break;
+	  }
 	case FitsDataType_long :
-	  fits_read_col(fptr_,TLONG,ncol+1,NoLine+1,1,1,&inull,&ligne.ldata_[icount++], &anynul,&status);
-	  break;
+	  {
+	    fits_read_col(fptr_,TLONG,ncol+1,NoLine+1,1,1,&inull,&ligne.ldata_[icount++], &anynul,&status);
+	    break;
+	  }
 	case FitsDataType_byte :
-	  fits_read_col(fptr_,TBYTE,ncol+1,NoLine+1,1,1,&inull,&ligne.bdata_[icount++], &anynul,&status);
-	  break;
+	  {
+	    fits_read_col(fptr_,TBYTE,ncol+1,NoLine+1,1,1,&inull,&ligne.bdata_[icount++], &anynul,&status);
+	    break;
+	  }
 	case FitsDataType_char :
-	  char* chaine = new char[taille_des_chaines_[ccount]];
-	  fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&chaine,&anynul,&status);
-	  ligne.cdata_[ccount++] = string(chaine);
-	  break;
+	  {
+	    char* chaine = new char[taille_des_chaines_[ccount]];
+	    fits_read_col(fptr_,TSTRING,ncol+1,NoLine+1,1,1,cnull,&chaine,&anynul,&status);
+	    ligne.cdata_[ccount++] = string(chaine);
+	    break;
+	  }
+	default:
+	  {
+	    throw PException(" FitsInFile::GetBinTabLine : unsupported FITS data type");
+	  }
 	}
       if (status)
@@ -856,4 +1086,6 @@
     }
 }
+
+
 
 /*! \fn void SOPHYA::FitsInFile::GetBinTabLine(int NoLine, float* fdata)
@@ -945,5 +1177,4 @@
       long repeat,width;
       fits_get_coltype(fptr_, NoCol+1,&DTYPE,&repeat,&width,&status);
-      cout << " en lecture fits trouve le type " << DTYPE << endl;
       if( DTYPE != TLONG &&  DTYPE != TINT) 
 	{
@@ -1137,41 +1368,4 @@
   int rept=0;
   if(hdutype == ASCII_TBL)
-    {
-      for(ii = 0; ii <  nbcols; ii++)
-	{
-	  int DTYPE;
-	  long width;
-	  long repete = 0;
-	  fits_get_coltype(fileptr,ii+1,&DTYPE,&repete,&width,&status);
-	  if( status ) printerror( status,"erreur lecture type de colonne");
-	  rept = repete;
-	  noms.push_back(string(ttype[ii]));
-	  switch (DTYPE)
-	    {
-	    case TDOUBLE :
-	      types.push_back(FitsDataType_double);
-	      break;
-	    case TFLOAT :
-	      types.push_back(FitsDataType_float);
-	      break;
-	    case TLONG :
-	      types.push_back(FitsDataType_long);
-	      break;
-	    case TSHORT :
-	      types.push_back(FitsDataType_int);
-	      break;
-	    case TSTRING :
-	      types.push_back(FitsDataType_char);
-	      taille_des_chaines.push_back(width);
-	      rept/=width;
-	      break;
-	    default :
-	      cout << " field " << ii+1 << " DTYPE= " << DTYPE << endl;
-	      throw IOExc("FitsFile::GetBinTabParameters, unsupported data type of field, for ASCII table");
-	    }
-	  repeat.push_back(rept);
-	}
-    }
-  else 
     {
       for(ii = 0; ii <  nbcols; ii++)
@@ -1199,5 +1393,45 @@
 	      break;
 	    case TSHORT :
+	      types.push_back(FitsDataType_short);
+	      break;
+	    case TSTRING :
+	      types.push_back(FitsDataType_char);
+	      taille_des_chaines.push_back(width);
+	      rept/=width;
+	      break;
+	    default :
+	      cout << " field " << ii+1 << " DTYPE= " << DTYPE << endl;
+	      throw IOExc("FitsFile::GetBinTabParameters, unsupported data type of field, for ASCII table");
+	    }
+	  repeat.push_back(rept);
+	}
+    }
+  else 
+    {
+      for(ii = 0; ii <  nbcols; ii++)
+	{
+	  int DTYPE;
+	  long width;
+	  long repete = 0;
+	  fits_get_coltype(fileptr,ii+1,&DTYPE,&repete,&width,&status);
+	  if( status ) printerror( status,"erreur lecture type de colonne");
+	  rept = repete;
+	  noms.push_back(string(ttype[ii]));
+	  switch (DTYPE)
+	    {
+	    case TDOUBLE :
+	      types.push_back(FitsDataType_double);
+	      break;
+	    case TFLOAT :
+	      types.push_back(FitsDataType_float);
+	      break;
+	    case TLONG :
+	      types.push_back(FitsDataType_long);
+	      break;
+	    case TINT :
 	      types.push_back(FitsDataType_int);
+	      break;
+	    case TSHORT :
+	      types.push_back(FitsDataType_short);
 	      break;
 	    case TSTRING :
@@ -1718,18 +1952,13 @@
     
 
-// la logique voudrait qu'on distingue TLONG et TINT. Mais si j'ecris 
-// et relis immediatement quelque chose en TLONG l'experience montre 
-// que ca foire. Donc, je fais tout en TINT, d'ailleurs cfitsio n'a pas
-// (apparemment) d'entiers de longueur superieure a 32 bits.
-// En fait, je n'y comprend rien. A suivre (GLM).
-  if (code == TINT || code == TLONG )
-    {
-      cout << " j'ecris des TINT" << endl;
+  
+  if (code == TINT || code == TLONG)
+    {
+      // cfitsio n'a que des entiers de longueur inferieure a 32 bits.
+      // ici, a l'ecriture TLONG impliquerait que le tableau de donnees
+      // soit un tableau int_8. Donc c'est toujours TINT qu;il faut mettre
+      // De plus, j'ai l'impression que TINT va devenir obsolete dans cfitsio
+      // (GLM)
       fits_write_col(fptr_,TINT,nocol+1,1,1,nentries, donnees ,&status);
-    }
-  else if (code == TSHORT) 
-    {
-      cout << " j'ecris des TSHORT " << endl;
-      fits_write_col(fptr_,TSHORT,nocol+1,1,1,nentries, donnees ,&status);
     }
   else
@@ -2211,4 +2440,5 @@
 	{
 	  cout << "FitsKeyword : complex keyword value not supported" << endl;;
+	  break;
 	}
       default :
Index: trunk/SophyaExt/FitsIOServer/fitsfile.h
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsfile.h	(revision 2174)
+++ trunk/SophyaExt/FitsIOServer/fitsfile.h	(revision 2197)
@@ -17,4 +17,5 @@
 
   struct BnTblLine;
+  class BufferLine;
   class FitsFile;
   class FitsInFile;
@@ -96,6 +97,54 @@
      FitsDataType_ASCII,
      FitsDataType_long,
-     FitsDataType_byte
+     FitsDataType_byte,
+     FitsDataType_short
    };
+
+
+class BufferLine
+
+  {
+    public :
+
+BufferLine() {;}
+BufferLine(const vector<FitsFile::FitsDataType>& types);
+inline const vector< pair<FitsFile::FitsDataType, int> >& identificateur() const {return id_;}
+ inline r_8&    r_8Array(int k) { return ddata_[k];}
+ inline const r_8&    r_8Array(int k) const { return ddata_[k];}
+ inline r_4& r_4Array(int k) { return fdata_[k];}
+ inline const r_4& r_4Array(int k) const { return fdata_[k];}
+
+
+ inline int_2& int_2Array(int k) { return shdata_[k];}
+ inline const int_2& int_2Array(int k) const { return shdata_[k];}
+ inline int_4& int_4Array(int k) { return idata_[k];}
+ inline const int_4& int_4Array(int k) const { return idata_[k];}
+
+
+ inline int_8& int_8Array(int k) { return ldata_[k];}
+ inline const int_8& int_8Array(int k) const { return ldata_[k];}
+ inline string& stringArray(int k) { return cdata_[k];}
+ inline const string& stringArray(int k) const { return cdata_[k];}
+ inline unsigned char& u_charArray(int k) { return bdata_[k];}
+ inline const unsigned char& u_charArray(int k) const { return bdata_[k];}
+
+
+ void Print() const;
+
+
+    private :
+      // la paire contient le type de la variable et le rang dans le tableau
+      // du type
+   vector< pair<FitsFile::FitsDataType, int> > id_;
+   vector<r_8>     ddata_;
+   vector<r_4>     fdata_;
+   vector<int_2>   shdata_; 
+   vector<int_4>   idata_; 
+   vector<int_8>   ldata_;
+   vector<string>  cdata_;
+   vector<unsigned char>   bdata_;
+  };
+
+
 
    FitsFile() { InitNull(); };
@@ -108,4 +157,9 @@
 
  protected:
+
+
+
+
+
 
 void         ResetStatus(int& status) ; 
@@ -130,4 +184,7 @@
    bool imageOnPrimary_;
 
+   BufferLine bfl_;
+
+
  };
 
@@ -214,4 +271,5 @@
  string ColNameFromFits(int nocol) const;
  int    ColStringLengthFromFits(int nocol) const;
+ const BufferLine& GetBufferLine(long NoLine); 
  void   GetBinTabLine(int NoLine, double* ddata, float* fdata, int* idata, char
 ** cdata) ;
@@ -367,6 +425,4 @@
 
 
-
-
 } // Fin du namespace
 
Index: trunk/SophyaExt/FitsIOServer/fitslocalmap.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitslocalmap.cc	(revision 2174)
+++ trunk/SophyaExt/FitsIOServer/fitslocalmap.cc	(revision 2197)
@@ -76,13 +76,37 @@
       ownobj_= true;      
     }
-  int nbcols, nbentries;
-  nbcols = is.NbColsFromFits();
-  if (nbcols != 1) 
-    {
-      throw IOExc("le fichier fits n'est pas une LocalMap");
-    }
+  int nbentries;
+
+  // lecture sur bin-table
+  //
+  //  if (!is.IsFitsTable())
+  // {
+  //     throw PException("ReadFromFits: the fits file seems not to be a bintable");
+  //  }
+  // int nbcols;
+  // nbcols = is.NbColsFromFits();
+  // if (nbcols != 1) 
+  //  {
+  //    throw IOExc("le fichier fits n'est pas une LocalMap");
+  //  }
+  // nbentries = is.NentriesFromFits(0);
+  //
+
+  // lecture sur image fits
+  //
+  if (!is.IsFitsImage())
+    {
+      throw PException("ReadFromFits: the fits file seems not to be an image");
+    }
+  int dimension = is.nbDimOfImage();
+  if (dimension != 2 )
+    {
+      cout << " WARNING::ReadFromFits: the fits image seems not to be a matrix" << endl;
+    }
+  nbentries =  is.nbOfImageData();
+  //
+
   DVList dvl=is.DVListFromFits();
-
-  nbentries = is.NentriesFromFits(0);
+  
   int_4 nSzX = dvl.GetI("NSZX");
   int_4 nSzY = dvl.GetI("NSZY");
@@ -93,7 +117,7 @@
     }
   dobj_->ReSize(nSzX, nSzY); 
-  //  int_4 localMappingDone = dvl.GetI("LCMP");
-  // if (localMappingDone)
-  //  {
+  int_4 localMappingDone = dvl.GetI("LCMP");
+  if (localMappingDone)
+    {
       int_4 x0 = dvl.GetI("X0");
       int_4 y0 = dvl.GetI("Y0");
@@ -105,6 +129,7 @@
       double angleY = dvl.GetD("ANGLEY");
       dobj_->SetSize(angleX, angleY);
-      //  }
+    }
   // On lit les DataBlocks;
+
   dobj_->DataBlock().ReSize(nPix);
   is.GetSingleColumn(dobj_->DataBlock().Data(),nPix);
@@ -122,17 +147,20 @@
       return;
     }
-
-  DVList dvl( dobj_->Info() );  
-  dvl["NSZX"] = dobj_->Size_x();
+  int nx, ny;
+
+  DVList dvl( dobj_->Info() );
+  nx = dobj_->Size_x();  
+  dvl["NSZX"] = nx;
   dvl.SetComment("NSZX", "number of pixels in x direction");
-  dvl["NSZY"] = dobj_->Size_y();
+  ny = dobj_->Size_y();
+  dvl["NSZY"] = ny;
   dvl.SetComment("NSZY", "number of pixels in y direction");
   dvl["NPIX"] = dobj_->NbPixels();
   dvl.SetComment("NPIX", "number of pixels in local map");
 
-  // if(dobj_->LocalMap_isDone())
-  // {
-  //   dvl["LCMP"] = (int_4) 1;
-  //   dvl.SetComment("LCMP", "local mapping 1= done, 0= not done");
+  if(dobj_->LocalMap_isDone())
+    {
+      dvl["LCMP"] = (int_4) 1;
+      dvl.SetComment("LCMP", "local mapping 1= done, 0= not done");
       int_4 x0 = 0;
       int_4 y0 = 0;
@@ -159,9 +187,9 @@
       dvl["ANGLEY"] = angleY;
       dvl.SetComment("ANGLEY", "sphere angle covered by map y-extension ");
-      // }
-  // else
-  //  {
-  //    dvl["LCMP"] = (int_4) 0;
-  //  }
+    }
+  else
+    {
+      dvl["LCMP"] = (int_4) 0;
+    }
   dvl["Content"]= "LocalMap";
   dvl.SetComment("Content", "name of SOPHYA object");
@@ -171,16 +199,42 @@
   string extname("SIMULATION");
 
-  string Type;
-  if (typeid(T) == typeid(r_8) ) Type+='D';
+  // sortie sur image fits
+  //
+  char type;
+  if ( typeid(T) == typeid(r_8) ) type='D';
   else 
-    if (typeid(T) == typeid(r_4) )  Type+='E';
+    if ( typeid(T) == typeid(r_4) )  type='E';
     else
-      {
-	cout <<  " type de la LocalMap = " <<  typeid(T).name() << endl;
-	throw IOExc("FITS_LocalMap:: unknown type");
-      }
-  vector<int> dummy;
-  os.makeHeaderBntblOnFits(Type, Noms, dobj_->NbPixels(), 1, &dvl, extname, dummy);
-  os.PutColToFits(0,  dobj_->NbPixels(), dobj_->DataBlock().Data()); 
+      if ( typeid(T) == typeid(int_4) )  type='J';
+      else
+	{
+	  cout <<  " type du tableau= " <<  typeid(T).name() << endl;
+	  throw IOExc("FITS_LocalMap:: unknown type");
+	}
+  int nbdim = 2;
+  int* naxisn = new int[nbdim];
+  naxisn[0] = dobj_->Matrix().Size(0);
+  naxisn[1] = dobj_->Matrix().Size(1);
+  os.makeHeaderImageOnFits(type, nbdim, naxisn, &dvl);
+  os.PutImageToFits(nx*ny, dobj_->Matrix().Data());
+
+  delete [] naxisn;
+  //
+
+  // sortie sur bin-table fits
+  //
+  //  string Type;
+  //  if (typeid(T) == typeid(r_8) ) Type+='D';
+  //  else 
+  //   if (typeid(T) == typeid(r_4) )  Type+='E';
+  //   else
+  //    {
+  //	cout <<  " type de la LocalMap = " <<  typeid(T).name() << endl;
+  //	throw IOExc("FITS_LocalMap:: unknown type");
+  //    }
+  //  vector<int> dummy;
+  //  os.makeHeaderBntblOnFits(Type, Noms, dobj_->NbPixels(), 1, &dvl, extname, dummy);
+  //  os.PutColToFits(0,  dobj_->NbPixels(), dobj_->DataBlock().Data()); 
+  //
 
 }
Index: trunk/SophyaExt/FitsIOServer/fitsspherethetaphi.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsspherethetaphi.cc	(revision 2174)
+++ trunk/SophyaExt/FitsIOServer/fitsspherethetaphi.cc	(revision 2197)
@@ -101,4 +101,13 @@
   
   // On ecrit les dataBlocks 
+
+  // the BINTABLE consits of 4 columns 
+  // first column  : pixels values (type : T ), length : number of pixels
+  // second column : number of pixels of each theta slice (type : integer) , 
+  //       length  : number of theta-slices  (parameter INDTHMAX above +1)
+  // third  column : cumulated number of pixels until the beginning of each 
+  //       theta slice (type : integer) , same length as the previous one
+  // fourth column : theta values of each slice (type : double_) same length
+  //                 as the previous one.
   vector<string> Noms(4);   
   Noms[0] = dvl.GetS("Content");
@@ -187,4 +196,13 @@
   // On lit les DataBlocks;
   //
+  // the BINTABLE consits of 4 columns 
+  // first column  : pixels values (type : T ), length : number of pixels
+  // second column : number of pixels of each theta slice (type : integer) , 
+  //       length  : number of theta-slices  (parameter INDTHMAX above +1)
+  // third  column : cumulated number of pixels until the beginning of each 
+  //       theta slice (type : integer) , same length as the previous one
+  // fourth column : theta values of each slice (type : double_) same length
+  //                 as the previous one.
+
   dobj_->pixels_.ReSize(nPix);
   is.GetBinTabFCol(dobj_->pixels_.Data(),nPix,0);
@@ -265,9 +283,9 @@
 #pragma define_template FITS_SphereThetaPhi<r_8>
 #pragma define_template FITS_SphereThetaPhi<r_4>
-//#pragma define_template FITS_SphereThetaPhi<int_4>
+#pragma define_template FITS_SphereThetaPhi<int_4>
 #endif
 #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
 template class FITS_SphereThetaPhi<r_8>;
 template class FITS_SphereThetaPhi<r_4>;
-//template class FITS_SphereThetaPhi<int_4>;
+template class FITS_SphereThetaPhi<int_4>;
 #endif
Index: trunk/SophyaExt/FitsIOServer/fitstarray.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitstarray.cc	(revision 2174)
+++ trunk/SophyaExt/FitsIOServer/fitstarray.cc	(revision 2197)
@@ -125,5 +125,5 @@
     if ( typeid(T) == typeid(r_4) )  type='E';
     else
-      if ( typeid(T) == typeid(int_4) )  type='I';
+      if ( typeid(T) == typeid(int_4) )  type='J';
       else
 	{
Index: trunk/SophyaExt/FitsIOServer/fitsxntuple.cc
===================================================================
--- trunk/SophyaExt/FitsIOServer/fitsxntuple.cc	(revision 2174)
+++ trunk/SophyaExt/FitsIOServer/fitsxntuple.cc	(revision 2197)
@@ -86,15 +86,44 @@
   for (k=0; k<nbcols;k++)
     {
+
       FitsFile::FitsDataType ss= is.ColTypeFromFits(k);
-      if (ss == FitsFile::FitsDataType_double) DfitsCol.push_back(k);
-      else if (ss == FitsFile::FitsDataType_float) FfitsCol.push_back(k);
-      else if (ss == FitsFile::FitsDataType_int) IfitsCol.push_back(k);
-      else if (ss == FitsFile::FitsDataType_long) IfitsCol.push_back(k);
-      else if (ss == FitsFile::FitsDataType_byte) IfitsCol.push_back(k);
-      else if (ss == FitsFile::FitsDataType_char) SfitsCol.push_back(k);
-      else {
-	cout << " FITS_XNTuple: colonne fits " << k << " type= " << (int) ss << endl;
-	throw  IOExc("type de champ inconnu");
-      }
+      switch (ss) 
+	{
+	case  FitsFile::FitsDataType_double :
+	  {
+	    DfitsCol.push_back(k);
+	    break;
+	  }
+	case FitsFile::FitsDataType_float :
+	  {
+	    FfitsCol.push_back(k);
+	    break;
+	  }
+	case FitsFile::FitsDataType_int :
+	  {
+	    IfitsCol.push_back(k);
+	    break;
+	  }
+	case FitsFile::FitsDataType_long :
+	  {
+	    IfitsCol.push_back(k);
+	    break;
+	  }
+	case FitsFile::FitsDataType_byte :
+	  {
+	    IfitsCol.push_back(k);
+	    break;
+	  }
+	case FitsFile::FitsDataType_char :
+	  {
+	    SfitsCol.push_back(k);
+	    break;
+	  }
+	default :
+	  {
+	    cout << " FITS_XNTuple: colonne fits " << k << " type= " << (int) ss << endl;
+	    throw  IOExc("type de champ inconnu");
+	  }
+	}
     }
   char ** ColName = new char*[nbcols];
@@ -143,5 +172,5 @@
 	  if (ND != dobj_->NDVar() || NF != dobj_->NFVar() ||  NI != dobj_->NIVar() || NS != dobj_->NSVar())
 	    {
-	      cout << " WARNING : FITS_XNTuple : XNTuple reconfigured " << endl;
+	      //	      cout << " WARNING : FITS_XNTuple : XNTuple reconfigured " << endl;
 	      (*dobj_)= XNTuple(ND, NF, NI, NS,ColName);
 	    }
@@ -155,7 +184,7 @@
   delete [] ColName;
 
-    double* dligne;
-    float* fligne;
-    int* iligne;
+    r_8* dligne;
+    r_4* fligne;
+    int_4* iligne;
     char** cligne;
 
@@ -188,6 +217,62 @@
   for (numLigne=firstln; numLigne < lastln; numLigne++)
     {
-      is.GetBinTabLine(numLigne, dligne, fligne, iligne, cligne );
-      dobj_->Fill((r_8*)dligne, (r_4*)fligne, (int_4*)iligne, cligne);    
+      const FitsFile::BufferLine& bfligne = is.GetBufferLine(numLigne);
+      int k;
+      int rang;
+      int dcount =0;
+      int fcount =0;
+      int icount =0;
+      int ccount = 0;
+      for (k=0; k<nbcols;k++)
+	{
+	  rang = bfligne.identificateur()[k].second;
+	  switch (bfligne.identificateur()[k].first)
+	    {
+	    case  FitsFile::FitsDataType_double :
+	      {
+		dligne[dcount++] =  bfligne.r_8Array(rang);
+		break;
+	      }
+	    case  FitsFile::FitsDataType_float :
+	      {
+		fligne[fcount++] =  bfligne.r_4Array(rang);
+		break;
+	      }
+	    case  FitsFile::FitsDataType_short :
+	      {
+		iligne[icount++] =  bfligne.int_2Array(rang);
+		break;
+	      }
+	    case  FitsFile::FitsDataType_int :
+	      {
+		iligne[icount++] =  bfligne.int_4Array(rang);
+		break;
+	      }
+	    case  FitsFile::FitsDataType_long :
+	      {
+		iligne[icount++] =  (int_4)bfligne.int_8Array(rang);
+		break;
+	      }
+	    case  FitsFile::FitsDataType_byte :
+	      {
+		iligne[icount++] =  (int_4)bfligne.u_charArray(rang);
+		break;
+	      }
+	    case FitsFile::FitsDataType_char :
+	      {
+		strncpy( cligne[ccount++], bfligne.stringArray(rang).c_str(),bfligne.stringArray(rang).length());
+		break;
+	      }
+
+	    default:
+	      {  
+		throw PException(" FITS_XNTuple::ReadFromFits : unsupported FITS data type");
+	      }
+	    }
+	
+	}
+      //      is.GetBinTabLine(numLigne, dligne, fligne, iligne, cligne );
+      //      dobj_->Fill((r_8*)dligne, (r_4*)fligne, (int_4*)iligne, cligne);    
+      dobj_->Fill(dligne, fligne, iligne, cligne);    
     }
     delete [] dligne;
@@ -234,5 +319,5 @@
   for (k=0; k<dobj_->NIVar();k++)
     {
-      types+='I';
+      types+='J';
     }
   for (k=0; k<dobj_->NSVar();k++)
@@ -277,4 +362,7 @@
 	 {
 	   for(int j = 0; j < nrows; j++) icolumn[j]= dobj_->GetIVal(j,compt);
+	   cout << " fitsx.. va ecrire la colonne " << endl;
+	   for(int j = 0; j < nrows; j++) cout << icolumn[j] << endl;;
+
 	   os.PutColToFits(compt, nrows, icolumn);
 	   compt++;
