
/*
-- DEC/CMS REPLACEMENT HISTORY, Element RR_FIL.ADA
-- DEC/CMS REPLACEMENT HISTORY, Element RR_FIL.ADA
------------------------------------------------------------
-- Rr_Fil			File: Rr_FIL.ADA
--
-- Rev
--    971210   ARG, Added levels_t, modified Heights_t
--    950830   ADS, Added ConvConst_t for new export/import funktion.
--    950102	 ARG, New quantity attribute value
--    940228	 CFR, Converted RR_FIL.ADA to RR_FIL.H
--    940119	 ARG, Modified m to km in quantity attribute
--
------------------------------------------------------------
   --------------------------------------------
   --------------------------------------------
   -- Attribute part
   --------------------------------------------
   --------------------------------------------
*/
 
/*
   ------------------------------------------------------------
   -- Name attribute
   ------------------------------------------------------------
   Package Name is new FilAttr.OneAttr_g ( Prod.ProdName_t, Name_Attr );

   ------------------------------------------------------------
   -- Area Name attribute
   -- 
   -- Name      : The name of the area
   -- 
   ------------------------------------------------------------
*/

#define MaxAreaName_c 16

typedef struct {
	   char Name [MaxAreaName_c];
} Area_t;

typedef struct
  {
  float X;
  float Y;  
  } MeterPos_t;

typedef struct 
  {
  float Lat;
  float Long;  
  }LatLong_t; 

typedef enum {
	Polar_Stereographic,
	Gnomonic,
        Unknown
}Projection_Type_t;

typedef struct {
  Projection_Type_t ProjectionType; /* 0 = Polar_Stereographic, 1 = Gnomonic */
  union
    {
    LatLong_t Pos;		 /* Polar */
    LatLong_t TangentPoint;	 /* Gnomonic */
    }ProjData;
  }Projection_t;

typedef struct 
  {
	LatLong_t LatLong;
  }GeometryStruc_t;

typedef struct AreaStruc
  {
  Projection_t  Proj;
  GeometryStruc_t SouthWest;
  GeometryStruc_t NorthEast;
  }AreaDef_t;


/* ------------------------------------------------------------
   -- Time attribute
   -- YYMMDDHHMMSS
   ------------------------------------------------------------
*/

#define TimeStringLength_c 12

typedef struct  {
	   char timeString[ TimeStringLength_c];
   }   Time_t;

/*
   ------------------------------------------------------------
   -- Quantity attribute
   ------------------------------------------------------------
*/
   typedef enum {
	   q_None,
	   q_Refl,
	   q_Prec,
	   q_Velocity,
	   q_Turb,
	   q_Height,
  	   q_Log_Surface_Rain_Intensity,
  	   q_Log_Surface_Rain_Total
   } QuantityUnit_t;

typedef enum  {
	None,
	km,
	m_s,
	Dbz, 
	mm,
	mm_h
     } PhysUnit_t;

typedef struct {
	QuantityUnit_t What;
	PhysUnit_t Unit;
}Quantity_t;

/*
   ------------------------------------------------------------
   -- Internal Store normalization constants attribute
   ------------------------------------------------------------
*/

typedef struct  {
	float Ord  ;
	float Slope;
	INT32 Offset;
}IntStore_t;

/*   for
      IntStore_t use record
         Ord    at 0 range 0..31;
   	 Slope  at 4 range 0..31;
         Offset at 8 range 0..31;
      end record;

   for IntStore_t'size use 12 * byte;
*/

/*
   ------------------------------------------------------------
   -- RrTyp attribute
   ------------------------------------------------------------
*/
typedef enum {
	Rr_Normal = 1, 
	Rr_Doppler,
	Rr_Dual,
	Rr_X_Band,
	Rr_S_Band,
	Rr_X1_Band,
	Rr_X2_Band,
	Rr_Undefined
}RrTyp_t;

/*   for RrTyp_t use ( 
      Rr_Normal  => 1,
      Rr_Doppler => 2,
      Rr_Dual    => 3,
      Rr_X_Band  => 4,
      Rr_S_Band  => 5,
      Rr_X1_Band => 6,
      Rr_X2_Band => 7,
      Rr_Undefined => 8 );
*/

/*
   ------------------------------------------------------------
   -- Occultation_Correction_t attribute
   ------------------------------------------------------------
*/

typedef enum {
	 o_None,
	 Map_Of_Correction_Factors,
	 Interpolation
}Occultation_Values_t;

typedef struct {
	Occultation_Values_t Value;
} Occultation_Correction_t;


/*
   ------------------------------------------------------------
   -- Clutter Treatment attribute
   -- Refer to BUFR format description for a description of 
   -- possible settings.
   ----------------------------------------------------------
*/

typedef enum
{
	c_None,
	Map,
	Higher_Elevation,
	Clutter_Detection,
	Clutter_Suppression,
	Clutter_Suppression_Doppler,
	Multiparameter_Analysis
}Clutter_Values_t;

typedef struct 
{
	Clutter_Values_t Value;
}Clutter_Treatment_t;



/*
   ------------------------------------------------------------
   -- Height attribute (Used for height-related products)
   ------------------------------------------------------------
   Package Height is new FilAttr.OneAttr_g ( Prod.Height_t, Height_Attr );
*/

typedef INT16 Height_t;

/*
   ------------------------------------------------------------
   -- Pixel attribute
   -- RowCnt       The number of rows in the data
   -- ColCnt       The number of columns in the data
   -- StorePixels  The total number of pixels in data
   -- StoreBits    Bits per element of file.
   -- StoreMax     Max. stored value.
   -- Compressed   Pixel data compressed or not
   -- FileOffset   Offset in the file to where the data starts
   ------------------------------------------------------------
   type Pixel_t is record 
      RowCnt       : ByteCnt_t range 0..2**16-1;
      ColCnt       : ByteCnt_t range 0..2**16-1;
      StorePixels  : ByteCnt_t; 
      StoreBits    : positive  range 1..2**8-1;
      StoreMax     : integer   range 0..2**8-1;
      Compressed   : boolean;   -- Pixel data compressed or not
      FileOffset   : ByteNo_t;  -- Offset in the file
   end record;
*/

typedef struct {
	unsigned int RowCnt;			/* 16 bit */
	unsigned int ColCnt;			/* 16 bit */
	INT32 StorePixels;		/* 32 bit */
	unsigned char StoreBits;	/* 8 bit */
	unsigned char StoreMax;		/* 8 bit */
	unsigned Compressed : 1;	/* 1 bit */
	INT32 FileOffset;		/* 32 bit */
}Pixel_t;

/*
   ------------------------------------------------------------
   -- Levels Attributes
   ------------------------------------------------------------
   MaxLevels_c : constant Natural := 16;
*/
#define MaxLevels_c 16

typedef struct {
	Height_t  Levels[MaxLevels_c];
       }Levels_t;


/*
   ------------------------------------------------------------
   -- Prodtype Attributes
   ------------------------------------------------------------
*/
   typedef enum {
	   /* -- Special 'products' -------------------------------------- */
      Non,		/* -- Not a product */
      Foreign,		/* -- No structure, just a file name */
      GeoMap,		/* -- A geographical map (Road, Air...) */
      RrStatus,		/* -- Radar status */

	   /* -- Radar products ------------------------------------------ */

      RrPPI_Z,       /* -- Lowest antenna elevation, Z-volume */
      RrPPI_W,       /* -- Lowest antenna elevation, W-volume */
      RrPPI_T,       /* -- Lowest antenna elevation, T-volume */
      RrCAPPI_Z,     /* -- Constant altitude PPI, Z-volume */
      RrCAPPI_W,     /* -- Constant altitude PPI, W-volume */
      RrCAPPI_T,     /* -- Constant altitude PPI, T-volume */
      RrPsC_Z,       /* -- Pseudo CAPPI, Z-volume */
      RrPsC_W,       /* -- Pseudo CAPPI, W-volume */
      RrPsC_T,       /* -- Pseudo CAPPI, T-volume */
      RrETM_Z,       /* -- Echo Top Map, Z-volume */
      RrVMI_Z,       /* -- Vertical Maximum Intensity, Z-volume */
      RrVMI_W,       /* -- Vertical Maximum Intensity, W-volume */
      RrVMI_T,       /* -- Vertical Maximum Intensity, T-volume */
      RrHMI_Z,       /* -- Horizontal Maximum Intesity, Z-volume */
      RrHMI_W,       /* -- Horizontal Maximum Intesity, W-volume */
      RrHMI_T,       /* -- Horizontal Maximum Intesity, T-volume */
      RrHMAX_Z,      /* -- Height of Max, Z-volume */
      RrHMAX_W,      /* -- Height of Max, W-volume */
      RrHMAX_T,      /* -- Height of Max, T-volume */
      RrVSI_Z,       /* -- Vertical cut through E/W N/S, Z-volume */
      RrVSI_W,       /* -- Vertical cut through E/W N/S, W-volume */
      RrVSI_T,       /* -- Vertical cut through E/W N/S, T-volume */
      RrSRT_Z,      /* -- SRT from Z-volume */
      RrSRI_Z       /* -- SRI from Z-volume */
   }ProdName_t;
		      


/*
   ------------------------------------------------------------
   -- AreaWall Attributes
   ------------------------------------------------------------
*/

   /*
   ------------------------------------------------------------
   -- Bitmap attribute
   -- Covers the data described by Pixel_t attribute.
   ------------------------------------------------------------
   */

   typedef struct {
	INT32 FileOffset;
	INT32 StorePixels;
	unsigned Compressed  : 1;
   }Bitmap_t;

/*   
   type Bitmap_t is record 
      FileOffset   : ByteNo_t;  -- Offset in the file
      StorePixels  : ByteCnt_t; 
      Compressed   : boolean;   -- Pixel data compressed or not
   end record;
 
   for BitMap_t use record 
      FileOffset   at  0 range 0..31;
      StorePixels  at  4 range 0..31;
      Compressed   at  8 range 0..0;
   end record;

   for BitMap_t'size use 9 * byte;  

   Package Bitmap is new FilAttr.OneAttr_g ( Bitmap_t, Bitmap_Attr );

   ------------------------------------------------------------
   -- SubArea attribute
   -- 
   -- The number of subareas was derived from PGF_DEF.MaxSubProds 
   ------------------------------------------------------------
   MaxNoSubAreas : constant Integer := AreaDef.MaxNoSubAreas;

   type
      Areas_t is array ( 1..MaxNoSubAreas ) of Area_t;

   pragma pack ( Areas_t );

   type
      SubAreas_t is record
         Count   : Integer;
         Areas   : Areas_t;
      end record;

   for 
      SubAreas_t use record
         Count   at 0 range 0..31;
      end record;

   Package SubAreas is new FilAttr.OneAttr_g ( SubAreas_t,
                                               SubAreas_Attr );

   ------------------------------------------------------------
   -- Resolution attribute
   ------------------------------------------------------------
   type
      Resolution_t is record
         Resolution : Prod.Resolution_t;
      end record;

   for 
      Resolution_t use record
         Resolution at 0 range 0..15;
      end record;
 
   for 
      Resolution_t'size use 16;

   Package Resolution is new FilAttr.OneAttr_g (Resolution_t,
                                                Resolution_Attr);
*/

/*
   ------------------------------------------------------------
   -- Resolution attribute
   ------------------------------------------------------------
*/
typedef  struct
     {
     unsigned int Resolution;
     }Resolution_t;


/* ------------------------------------------------------------
   -- Z_To_R_Constants_Attr attribute
   ------------------------------------------------------------
*/
typedef struct {
	float Factor;
	float Exponent;
	unsigned char Type; /* CFR,ARG,BBN new 940426 */
}Z_To_R_Constants_t;

 /* type
      Z_To_R_Constants_t is record
         Factor   : Float;
         Exponent : Float;
      end record;

   for 
      Z_To_R_Constants_t use record
         Factor   at 0 range 0..31;
         Exponent at 4 range 0..31;
      end record;
  
   for Z_To_R_Constants_t'size use 8 * byte;

   Package Z_To_R_Constants is new FilAttr.OneAttr_g (Z_To_R_Constants_t,
                                                      Z_To_R_Constants_Attr );
*/

/*
   ------------------------------------------------------------
   -- Period attribute
   -- The Period when SRT data was collected:
   --    - Period   : Duration in minutes.
   --    - LostTime : Duration in minutes.
   ------------------------------------------------------------
   type
      Period_t is record
         Period    : Natural;
         LostTime  : Natural;
      end record;

   for
      Period_t use record
         Period   at 0 range 0..31;
         LostTime at 4 range 0..31;
      end record;

   for
      Period_t'size use 8 * byte;
 */

/*
   ------------------------------------------------------------
   -- ConvConst attrib
   -- izr       Rain conversion type
   -- iexpzr    Rain conversion attrib
   -- ifaczr    Rain conversion factor
   ------------------------------------------------------------
*/
typedef struct {
  float izr;
  float iexpzr;
  float ifaczr;
} ConvConst_t;


