From db82a3b7330ee61ecafdaf16592feba4bf536635 Mon Sep 17 00:00:00 2001
From: cmv <>
Date: Mon, 3 Dec 2001 20:34:06 +0000
Subject: [PATCH] nouvelle interface de gestion des systemes de coordonnees et
 des unites cmv 3/12/01

---
 XAstroPack/xastropack.cc | 378 ++++++++++++++++++++++++++++++++-------
 XAstroPack/xastropack.h  |  90 ++++++----
 2 files changed, 367 insertions(+), 101 deletions(-)

diff --git a/XAstroPack/xastropack.cc b/XAstroPack/xastropack.cc
index 38f76f3..4bd50ff 100644
--- a/XAstroPack/xastropack.cc
+++ b/XAstroPack/xastropack.cc
@@ -40,15 +40,26 @@
 //              temps sideral du lieu: tsid=ha+ra (ou lst)
 // GALACTIQUE: longitude en degres [0,360[  (glng)
 //             latitude en degres [-90,90]  (glat)
+//             (colatitude en degres [0,180]  (gcolat))
 // HORIZONTAL: azimuth en degres [0,360[   (az)
 //                 (angle round to the east from north+)
-//             altitude en degres [-90,90] (alt)
+//             altitude ou elevation en degres [-90,90] (alt)
+//             (distance zenitale en degres [0,180] (zendist))
 // ECLIPTIQUE: lontitude ecliptique en degres [0,360[ (eclng)
 //                 (angle round counter clockwise from the vernal equinoxe)
 //             latitude ecliptique en degres [-90,90] (eclat)
+//             (colatitude ecliptique en degres [0,180] (eccolat))
 // GEOGRAPHIE: longitude en degres ]-180,180]        (geolng)
 //                 (angle <0 vers l'ouest, >0 vers l'est)
 //             latitude en degres [-90,90] (north>0 sud<0) (geolat)
+//             (colatitude en degres [0,180] (north=0, sud=180) (geocolat))
+//
+// --- Remarque sur la colatitude:
+//   La latitude peut etre remplacee par la colatitude
+//      (ou altitude/elevation par la distance zenitale):
+//      latitude   : [-90,90] avec 0=equateur,  90=pole nord, -90=pole sud
+//      colatitude : [0,180]  avec 0=pole nord, 90=equateur,  180=pole sud
+//      colatitude = 90.-latitude , latitude = 90.-colatitude
   \endverbatim
 */
 
@@ -60,82 +71,315 @@
  de coordonnees.
  "typ" code le systeme de coordonnees astronomiques et les unites utilisees
 
- - Return : 0 = OK
-            1 = Unknown type of coordinates
-            2 = bad range for coord1
-            4 = bad range for coord2
-            6 = bad range for coord1 et coord2
-
- Les types de coordonnees sont definies dans le enum TypAstroCoord:
-  La premiere coordonnee est de type "longitude" (alpha,longitude)
-  La deuxieme coordonnee est de type "latidude" (delta,latitude)
- *** Definitions des unites des coordonnees et de leurs dynamiques
- - TypCoordH0 : heure=[0,24[
- - TypCoordH1 : heure=]-12,12]
- - TypCoordD0 : degre=[0,360[
- - TypCoordD1 : degre=]-180,180]
- - TypCoordD2 : degre=[-90,90]
- - TypCoordR0 : degre=[0,2Pi[
- - TypCoordR1 : degre=]-Pi,Pi]
- - TypCoordR2 : degre=[-Pi/2,Pi/2]
- *** Definitions des combinaisons unites des coordonnees
- - TypCoordHD  : coordonnees en (heure=[0,24[,degre=[-90,90])
- - TypCoordDD  : coordonnees en (degre=[0,360[,degre=[-90,90])
- - TypCoordRR  : coordonnees en (radian=[0,2Pi[,radian=[-Pi/2,Pi/2])
- - TypCoordH1D : coordonnees en (heure=]-12,12],degre=[-90,90])
- - TypCoordD1D : coordonnees en (degre=]-180,180],degre=[-90,90])
- - TypCoordR1R : coordonnees en (radian=]-Pi,Pi],radian=[-Pi/2,Pi/2])
- *** Definitions des types de systemes de coordonnees astronomiques.
- - TypCoordEq  : Coordonnees Equatoriales alpha,delta
- - TypCoordGal : Coordonnees Galactiques gLong, gLat
- - TypCoordHor : Coordonnees Horizontales azimuth,altitude
- - TypCoordEcl : Coordonnees Ecliptiques EclLong,EclLat
- *** Definitions des unites par defaut pour les divers systemes de coordonnees.
- - TypCoordEqStd  : heure=[0,24[, degre=[-90,90]
- - TypCoordGalStd : degre=[0,360[,degre=[-90,90]
- - TypCoordHorStd : degre=[0,360[,degre=[-90,90]
- - TypCoordEclStd : degre=[0,360[,degre=[-90,90]
+ - Return : 0 = Problem
+            TypAstroCoord du systeme de coordonnees retourne
+
+ - Les types de coordonnees (A,B) sont definies
+           dans le enum TypAstroCoord (unsigned long):
+   La premiere coordonnee "A" est de type "longitude"
+                          (alpha,longitude,azimuth)
+   La deuxieme coordonnee "B" est de type "latidude"
+                          (delta,latitude,altitude ou elevation)
+
+ *** Definitions des unites des coordonnees
+ - Coordonnee: 
+      TypCoordH en heure
+      TypCoordD en degre
+      TypCoordR en radian
+ - Coordonnee "A": 
+      TypCoord1H en heure
+      TypCoord1D en degre
+      TypCoord1R en radian
+      - Defaut (pas de bit leve): radians
+ - Coordonnee "B": 
+      TypCoord2H en heure
+      TypCoord2D en degre
+      TypCoord2R en radian
+      - Defaut (pas de bit leve): radians
+ *** Definitions des types d'intervalle utilises
+ - Coordonnee "A":
+      TypCoord1C type intervalle
+                 [0,24[ ou [0,360[ ou [0,2Pi[
+      TypCoord1L type intervalle centre
+                 ]-12,12] ou ]-180,180] ou ]-Pi,Pi]
+      - Defaut (pas de bit leve): TypCoord1C
+ - Coordonnee "B": 
+      TypCoord2C type intervalle (colatitude)
+                 [0,12] ou [0,180] ou [0,Pi]
+      TypCoord2L type intervalle centre (latitude)
+                 [-6,6] ou [-90,90] ou [-Pi/2,Pi/2]
+      - Defaut (pas de bit leve): TypCoord2L (latitude)
+ *** Les systemes de coordonnes astronomiques
+ TypCoordEq  coordonnees Equatoriales alpha,delta
+ TypCoordGal coordonnees Galactiques gLong, gLat
+ TypCoordHor coordonnees Horizontales azimuth,altitude
+ TypCoordEcl coordonnees Ecliptiques EclLong,EclLat
+      (Pas de defaut)
+ *** Les systemes de coordonnes astronomiques "standard"
+ TypCoordEqStd   alpha en heure=[0,24[ delta en degre=[-90,90]
+ TypCoordGalStd  long en degre=[0,360[ lat en degre=[-90,90] (latitude)
+ TypCoordHorStd  long en degre=[0,360[ lat en degre=[-90,90] (latitude)
+ TypCoordEclStd  long en degre=[0,360[ lat en degre=[-90,90] (latitude)
 \endverbatim
 */
-int  CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2)
+unsigned long CoordConvertToStd(unsigned long typ,double* coord1,double* coord2)
 {
-  int rc = 0;
+  unsigned long rc = TypCoordUndef;
 
-  // ---- Equatoriales alpha,delta
-  //    - standard = [0,24[ , [-90,90]
   if(typ&TypCoordEq) {
-    if(typ&TypCoordDD) {
-      coord1 = deghr(coord1);
-    } else if(typ&TypCoordRR) {
-      coord1 = radhr(coord1);
-      coord2 = raddeg(coord2);
-    }
-    if(coord1==24.) coord1 = 0.;
-    if(coord1<0.   || coord1>=24.) rc+= 2;
-    if(coord2<-90. || coord2>90. ) rc+= 4;
-
-  // ---- Galactiques gLong, gLat
-  // ---- Horizontales azimuth,altitude
-  // ---- Ecliptiques EclLong,EclLat
-  //    - standard = [0,360[ , [-90,90]
-  } else if( typ&TypCoordGal || typ&TypCoordHor || typ&TypCoordEcl) {
-    if(typ&TypCoordHD) {
-      coord1 = hrdeg(coord1);
-    } else if(typ&TypCoordRR) {
-      coord1 = raddeg(coord1);
-      coord2 = raddeg(coord2);
-    }
-    if(coord1==360.) coord1 = 0.;
-    if(coord1<0.   || coord1>=360.) rc+= 2;
-    if(coord2<-90. || coord2>90. )  rc+= 4;
-
-  } else {          // Coordonnees non-connues
-    rc= 1;
+    // ---- Equatoriales alpha,delta
+    if     (typ&TypCoord1D)    *coord1 = deghr(*coord1);
+    else if(typ&TypCoord1R)    *coord1 = radhr(*coord1);
+    else if(!(typ&TypCoord1H)) *coord1 = radhr(*coord1);
+
+    InRange(coord1,24.);
+
+    if     (typ&TypCoord2H)    *coord2 = hrdeg(*coord2);
+    else if(typ&TypCoord2R)    *coord2 = raddeg(*coord2);
+    else if(!(typ&TypCoord2D)) *coord2 = raddeg(*coord2);
+
+    if(typ&TypCoord2C) {
+      InRangeCoLat(coord2,TypUniteD);
+      ToCoLat(coord2,TypUniteD);
+    } else InRangeLat(coord2,TypUniteD);
+
+    rc=TypCoordEqStd;
+
+  } else if(typ&TypCoordGal || typ&TypCoordHor || typ&TypCoordEcl) {
+    // ---- Galactiques gLong, gLat
+    // ---- Horizontales azimuth,altitude ou elevation
+    // ---- Ecliptiques EclLong,EclLat
+    if     (typ&TypCoord1H)    *coord1 = hrdeg(*coord1);
+    else if(typ&TypCoord1R)    *coord1 = raddeg(*coord1);
+    else if(!(typ&TypCoord1D)) *coord1 = raddeg(*coord1);
+
+    InRange(coord1,360.);
+
+    if     (typ&TypCoord2H)    *coord2 = hrdeg(*coord2);
+    else if(typ&TypCoord2R)    *coord2 = raddeg(*coord2);
+    else if(!(typ&TypCoord2D)) *coord2 = raddeg(*coord2);
+
+    if(typ&TypCoord2C) {
+      InRangeCoLat(coord2,TypUniteD);
+      ToCoLat(coord2,TypUniteD);
+    } else InRangeLat(coord2,TypUniteD);
+
+    if     (typ&TypCoordGal) rc=TypCoordGalStd;
+    else if(typ&TypCoordHor) rc=TypCoordHorStd;
+    else if(typ&TypCoordEcl) rc=TypCoordEclStd;
+
+  } else {          // Systeme de coordonnees non-connu
+    rc=TypCoordUndef;
   }
 
   return rc;
 }
 
+/*! \ingroup XAstroPack
+\brief Retourne te type d'unite pour la coordonnee "coordnum"
+       pour un TypAstroCoord valant "typ"
+\verbatim
+   coordnum : numero de coordonnee: 1 ou 2
+   retourne: TypUniteH si la coordonnee est en heure
+             TypUniteD si la coordonnee est en degre
+             TypUniteR si la coordonnee est en radian
+             TypUniteR par defaut
+             TypCoordUndef si le numero de coordonnee est errone.
+\endverbatim
+*/
+unsigned long GetCoordUnit(int coordnum,unsigned long typ)
+{
+ if(coordnum==1) {
+   if     (typ&TypCoord1H) return TypUniteH;
+   else if(typ&TypCoord1D) return TypUniteD;
+   else if(typ&TypCoord1R) return TypUniteR;
+   else                    return TypUniteR;
+ }
+ if(coordnum==2) {
+   if     (typ&TypCoord2H) return TypUniteH;
+   else if(typ&TypCoord2D) return TypUniteD;
+   else if(typ&TypCoord2R) return TypUniteR;
+   else                    return TypUniteR;
+ }
+ return TypCoordUndef;
+}
+
+/*! \ingroup XAstroPack
+\brief Pour decoder et transcrire en TypAstroCoord une chaine
+       donnant la structure du systeme de coordonnees.
+\verbatim
+  ctype = "CAaBb"
+    C: type de coordonnees: E Equatoriales
+                            G Galactiques
+                            H Horizontales
+                            S Ecliptiques
+                            pas de defaut
+    A: unite de la coordonnee 1 (alpha,longitude etc...)
+                            H heure
+                            D degre
+                            R radian
+                            defaut radian
+    a: type d'intervalle pour la coordonnee 1
+                            C intervalle [0,24[ [0,360[ [0,2*Pi[
+                            L intervalle [-12,12[ [-180,180[ [-Pi,Pi[
+                            (defaut: C)
+    A: unite de la coordonnee 2 (delta,latitude etc...)
+                            H heure
+                            D degre
+                            R radian
+                            defaut radian
+    a: type d'intervalle pour la coordonnee 2
+                            C intervalle [0,12] [0,180] [0,Pi]
+                              (type colatitude)
+                            L intervalle [-6,6] [-90,90][ [-Pi/2,Pi/2]
+                            (defaut: L)
+
+    Exemple: GDCDL : galactiques long=[0,360[ lat=[-90,90]
+             GDxDx ou GDxD: idem
+             Gxxxx ou G : galactiques long=[0,2*Pi[ lat=[-Pi/2,Pi/2]
+    Exemple: EHCDL : equatoriales alpha=[0,24[ delta=[-90,90]
+             EHxDx ou EHxD : idem
+             Exxxx ou E : equatoriales alpha=[0,2*Pi[ delta=[-Pi/2,Pi/2]
+                            
+  - Retourne 0 si probleme dans la chaine
+\endverbatim
+*/
+unsigned long DecodeTypAstro(const char *ctype)
+{
+  if(ctype==NULL) return TypCoordUndef;
+  int len = strlen(ctype);
+  if(len<1) return TypCoordUndef;
+
+  unsigned long typ=0;
+  // Le type de systeme de coordonnees
+  int i = 0;
+  if     (ctype[i]=='e' || ctype[i]=='E') typ=TypCoordEq;
+  else if(ctype[i]=='g' || ctype[i]=='G') typ=TypCoordGal;
+  else if(ctype[i]=='h' || ctype[i]=='H') typ=TypCoordHor;
+  else if(ctype[i]=='s' || ctype[i]=='S') typ=TypCoordEcl;
+  else return TypCoordUndef;
+  // La coordonnee 1
+  i = 1;
+  if(i>=len)
+    {typ |= TypCoord1R|TypCoord1C|TypCoord2R|TypCoord2L; return typ;}
+  if     (ctype[i]=='h' || ctype[i]=='H') typ |= TypCoord1H;
+  else if(ctype[i]=='d' || ctype[i]=='D') typ |= TypCoord1D;
+  else if(ctype[i]=='r' || ctype[i]=='R') typ |= TypCoord1R;
+  else                                    typ |= TypCoord1R;
+  i = 2;
+  if(i>=len) {typ |= TypCoord1C|TypCoord2R|TypCoord2L; return typ;}
+  if     (ctype[i]=='c' || ctype[i]=='C') typ |= TypCoord1C;
+  else if(ctype[i]=='l' || ctype[i]=='L') typ |= TypCoord1L;
+  else                                    typ |= TypCoord1C;
+  // La coordonnee 2
+  i = 3;
+  if(i>=len) {typ |= TypCoord2R|TypCoord2L; return typ;}
+  if     (ctype[i]=='h' || ctype[i]=='H') typ |= TypCoord2H;
+  else if(ctype[i]=='d' || ctype[i]=='D') typ |= TypCoord2D;
+  else if(ctype[i]=='r' || ctype[i]=='R') typ |= TypCoord2R;
+  else                                    typ |= TypCoord2R;
+  i = 4;
+  if(i>=len) {typ |= TypCoord2L; return typ;}
+  if     (ctype[i]=='c' || ctype[i]=='C') typ |= TypCoord2C;
+  else if(ctype[i]=='l' || ctype[i]=='L') typ |= TypCoord2L;
+  else                                    typ |= TypCoord2L;
+  // Return
+  return typ;
+}
+
+/*! \ingroup XAstroPack
+\brief Idem DecodeTypAstro(char *) mais a l'envers
+*/
+string DecodeTypAstro(unsigned long typ)
+{
+ string s = "";
+
+ if     (typ&TypCoordEq)  s += "E";
+ else if(typ&TypCoordGal) s += "G";
+ else if(typ&TypCoordHor) s += "H";
+ else if(typ&TypCoordEcl) s += "S";
+ else                     s += "x";
+
+ if     (typ&TypCoord1H) s += "H";
+ else if(typ&TypCoord1D) s += "D";
+ else if(typ&TypCoord1R) s += "R";
+ else                    s += "x";
+
+ if     (typ&TypCoord1C) s += "C";
+ else if(typ&TypCoord1L) s += "L";
+ else                    s += "x";
+
+ if     (typ&TypCoord2H) s += "H";
+ else if(typ&TypCoord2D) s += "D";
+ else if(typ&TypCoord2R) s += "R";
+ else                    s += "x";
+
+ if     (typ&TypCoord2C) s += "C";
+ else if(typ&TypCoord2L) s += "L";
+ else                    s += "x";
+
+ return s;
+}
+
+/*! \ingroup XAstroPack
+\brief Pour convertir la latitude en colatitude et vice-versa (in place)
+\verbatim
+  val = valeur a convertir qui doit etre:
+      si type "latitude"   dans [-6,6] [-90,90] [-Pi/2,Pi/2]
+      si type "colatitude" dans [0,12] [0,180] [0,Pi]
+  typ = type d'unite: heure  TypUniteH
+                      degre  TypUniteD
+                      radian TypUniteR
+        (Defaut: radian TypUniteR)
+\endverbatim
+*/
+void ToCoLat(double *val,unsigned long typ)
+{
+ if     (typ&TypUniteH) *val = 6.    - *val;
+ else if(typ&TypUniteD) *val = 90.   - *val;
+ else if(typ&TypUniteR) *val = PI/2. - *val;
+ else *val = PI/2. - *val;
+}
+
+/*! \ingroup XAstroPack
+\brief Pour remettre la valeur de la COLATITUDE "val" dans la dynamique [0.,range]
+\verbatim
+  val = valeur a convertir qui doit etre mise dans [0,12] [0,180] [0,Pi]
+  typ = type d'unite: heure  TypUniteH
+                      degre  TypUniteD
+                      radian TypUniteR
+  ex en degre: 0 -> 0 ,  90 ->  90 ,  180 -> 180 ,  270 -> 90 ,  360 -> 0
+                        -90 ->  90 , -180 -> 180 , -270 -> 90 , -360 -> 0
+\endverbatim
+*/
+void InRangeCoLat(double *val,unsigned long typ)
+{
+ double range=PI;
+ if(typ==TypUniteH) range=12.; else if(typ==TypUniteD) range=180.;
+ InRange(val,2.*range,range);
+ if(*val<0.) *val*=-1.;
+}
+
+/*! \ingroup XAstroPack
+\brief Pour remettre la valeur de la LATITUDE "val" dans la dynamique [-range/2,range/2]
+\verbatim
+  val = valeur a convertir qui doit etre mise dans [-6,6] [-90,90] [-Pi/2,Pi/2]
+  typ = type d'unite: heure  TypUniteH
+                      degre  TypUniteD
+                      radian TypUniteR
+  ex en degre: 0 -> 0 ,  90 ->  90 ,  180 -> 0 ,  270 -> -90 ,  360 -> 0
+                        -90 -> -90 , -180 -> 0 , -270 ->  90 , -360 -> 0
+\endverbatim
+*/
+void InRangeLat(double *val,unsigned long typ)
+{
+ double range = PI;
+ if(typ==TypUniteH) range = 12.; else if(typ==TypUniteD) range = 180.;
+ InRange(val,2.*range,range);
+ if(*val>range/2.) *val = range - *val;
+   else if(*val<-range/2.) *val = -(range + *val);
+}
+
 /*! \ingroup XAstroPack
 \brief Compute MJD from date
 \verbatim
diff --git a/XAstroPack/xastropack.h b/XAstroPack/xastropack.h
index dc8b511..a48cecf 100644
--- a/XAstroPack/xastropack.h
+++ b/XAstroPack/xastropack.h
@@ -15,46 +15,68 @@ extern "C" {  /* extern "C" */
 #endif
 
 enum TypAstroCoord {
-  TypCoordUndef  =  (unsigned long)  (0),
-
-  TypCoordH0     =  (unsigned long)  (1 << 10), // heure=[0,24[
-  TypCoordH1     =  (unsigned long)  (1 << 11), // heure=]-12,12]
-  TypCoordD0     =  (unsigned long)  (1 << 12), // degre=[0,360[
-  TypCoordD1     =  (unsigned long)  (1 << 13), // degre=]-180,180]
-  TypCoordD2     =  (unsigned long)  (1 << 14), // degre=[-90,90]
-  TypCoordR0     =  (unsigned long)  (1 << 15), // degre=[0,2Pi[
-  TypCoordR1     =  (unsigned long)  (1 << 16), // degre=]-Pi,Pi]
-  TypCoordR2     =  (unsigned long)  (1 << 17), // degre=[-Pi/2,Pi/2]
-
-  // Pour indiquer que les coordonnees sont en (heure=[0,24[,degre=[-90,90])
-  TypCoordHD     =  (unsigned long)  (1 << 20),
-  // Pour indiquer que les coordonnees sont en (degre=[0,360[,degre=[-90,90])
-  TypCoordDD     =  (unsigned long)  (1 << 21),
-  // Pour indiquer que les coordonnees sont en (radian=[0,2Pi[,radian=[-Pi/2,Pi/2])
-  TypCoordRR     =  (unsigned long)  (1 << 22),
-  // Pour indiquer que les coordonnees sont en (heure=]-12,12],degre=[-90,90])
-  TypCoordH1D    =  (unsigned long)  (1 << 23),
-  // Pour indiquer que les coordonnees sont en (degre=]-180,180],degre=[-90,90])
-  TypCoordD1D    =  (unsigned long)  (1 << 24),
-  // Pour indiquer que les coordonnees sont en (radian=]-Pi,Pi],radian=[-Pi/2,Pi/2])
-  TypCoordR1R    =  (unsigned long)  (1 << 25),
+  //------ Coordonnees de type (A,B) avec:
+  //      A,B <==> alpha,delta
+  //      A,B <==> longitude,latitude
+  //      A,B <==> azimuth,altitude ou elevation
+
+  //------ Les unites des coordonnees
+  TypUniteH       =  (unsigned long)  (1 << 0), // coord en heure
+  TypUniteD       =  (unsigned long)  (1 << 1), // coord en degre
+  TypUniteR       =  (unsigned long)  (1 << 2), // coord en radian
+
+  //------ Les unites des coordonnees A et B
+  TypCoord1H      =  (unsigned long)  (1 << 3), // coord A en heure
+  TypCoord1D      =  (unsigned long)  (1 << 4), // coord A en degre
+  TypCoord1R      =  (unsigned long)  (1 << 5), // coord A en radian
+  TypCoord2H      =  (unsigned long)  (1 << 6), // coord B en heure
+  TypCoord2D      =  (unsigned long)  (1 << 7), // coord B en degre
+  TypCoord2R      =  (unsigned long)  (1 << 8), // coord B en radian
+
+  //------ Le type d'intervalle des coordonnees A et B
+  // Coord A intervalle... ex: [0,24[ ou [0,360[ ou [0,2Pi[
+  TypCoord1C      =  (unsigned long)  (1 << 10),
+  // Coord A intervalle centre... ex: ]-12,12] ou ]-180,180] ou ]-Pi,Pi]
+  TypCoord1L      =  (unsigned long)  (1 << 11),
+  // Coord B intervalle... ex:  [0,12] ou [0,180] ou [0,Pi] (colatitude)
+  TypCoord2C      =  (unsigned long)  (1 << 12),
+  // Coord B intervalle centre... ex: [-6,6] ou [-90,90] ou [-Pi/2,Pi/2] (latitude)
+  TypCoord2L      =  (unsigned long)  (1 << 13),
+
+  //------ Les systemes de coordonnees astronomiques
+  // Coordonnees Equatoriales alpha,delta
+  TypCoordEq     =  (unsigned long)  (1 << 15),
+  // Coordonnees Galactiques gLong, gLat
+  TypCoordGal    =  (unsigned long)  (1 << 16),
+  // Coordonnees Horizontales azimuth,altitude
+  TypCoordHor    =  (unsigned long)  (1 << 17),
+  // Coordonnees Ecliptiques EclLong,EclLat
+  TypCoordEcl    =  (unsigned long)  (1 << 18),
 
+  //------ Les systemes de coordonnees astronomiques "standard"
   // Coordonnees Equatoriales alpha,delta
-  TypCoordEq     =  (unsigned long)  (1 << 0),
-  TypCoordEqStd  =  (unsigned long) ((1 << 0) | (1 << 20)),
+  TypCoordEqStd     =  (unsigned long)  (TypCoordEq |TypCoord1C|TypCoord1H|TypCoord2L|TypCoord2D),
   // Coordonnees Galactiques gLong, gLat
-  TypCoordGal    =  (unsigned long)  (1 << 1),
-  TypCoordGalStd =  (unsigned long) ((1 << 1) | (1 << 21)),
+  TypCoordGalStd    =  (unsigned long)  (TypCoordGal|TypCoord1C|TypCoord1D|TypCoord2L|TypCoord2D),
   // Coordonnees Horizontales azimuth,altitude
-  TypCoordHor    =  (unsigned long)  (1 << 2),
-  TypCoordHorStd =  (unsigned long) ((1 << 2) | (1 << 21)),
+  TypCoordHorStd    =  (unsigned long)  (TypCoordHor|TypCoord1C|TypCoord1D|TypCoord2L|TypCoord2D),
   // Coordonnees Ecliptiques EclLong,EclLat
-  TypCoordEcl    =  (unsigned long)  (1 << 3),
-  TypCoordEclStd =  (unsigned long) ((1 << 3) | (1 << 21))
+  TypCoordEclStd    =  (unsigned long)  (TypCoordEcl|TypCoord1C|TypCoord1D|TypCoord2L|TypCoord2D),
+
+  //------ undef pour la forme
+  TypCoordUndef  =  (unsigned long)  (0)
 };
 
 // ------------------- Utilitaires -------------------
-int  CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2);
+unsigned long CoordConvertToStd(unsigned long typ,double* coord1,double* coord2);
+unsigned long GetCoordUnit(int coordnum,unsigned long typ);
+unsigned long DecodeTypAstro(const char *ctype);
+inline unsigned long DecodeTypAstro(const string stype)
+                {return DecodeTypAstro(stype.c_str());}
+string        DecodeTypAstro(unsigned long typ);
+void ToCoLat(double* val,unsigned long typ);
+void InRangeLat(double* val,unsigned long typ);
+void InRangeCoLat(double* val,unsigned long typ);
 
 /*!
 \brief Pour remettre la valeur "val" dans la dynamique [0.,range[.
@@ -63,8 +85,8 @@ int  CoordConvertToStd(TypAstroCoord typ,double& coord1,double& coord2);
        (si elle est depassee, on soustrait "range").
 \verbatim
   r>0 vmax>0
-  r=24. vmax=24.   -> mets dans [  0,+24[ borne sup exclue
-  r=24. vmax=12.   -> mets dans ]-12,+12] borne inf exclue
+  r=24. vmax=24.   -> mets "val" dans [  0,+24[ borne sup exclue
+  r=24. vmax=12.   -> mets "val" dans ]-12,+12] borne inf exclue
   (ATTENTION: ca ne marche pas pour la latitude [-90,90]
               car -90 ne peut etre inclus dans l'intervalle)
 \endverbatim
-- 
GitLab