/*
 * Created on 09-Oct-2007
 *
 * TODO 
 */
package uk.ac.roe.wfau;

import java.sql.ResultSet;
import java.sql.SQLException;

import uk.ac.starlink.ast.AstObject;
import uk.ac.starlink.ast.FitsChan;

/**
 * @author mar
 *
 */
public class ResultSetToFitsChan {

    public static  FitsChan getFitsChan(ResultSet rs) {
        FitsChan fc=new FitsChan();
        fc.setCard(1);
        try {
            fc.putFits("NAXIS   = "+rs.getString("numaxes"),true);
            } catch (Exception e){
                fc.putFits("NAXIS   = 2",true); 
            }
            try {
                fc.putFits("NAXIS1  = "+rs.getString("axis1length"),true);
                //System.out.println(rs.getString("axis1length"));
            } catch (SQLException se) {
            }
            try {
                fc.putFits("NAXIS2  = "+rs.getString("axis2length"),true);
            } catch (SQLException se) {
            }
            try {
                fc.putFits("CTYPE1  = '"+rs.getString("CTYPEX")+"'",true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("CTYPE2  = '"+rs.getString("CTYPEY")+"'",true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("CRPIX1  = "+rs.getString("CRPIXX"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("CRPIX2  = "+rs.getString("CRPIXY"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("CRVAL1  = "+rs.getString("CRVALX"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("CRVAL2  = "+rs.getString("CRVALY"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("CD1_1   = "+rs.getString("CD11"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("CD1_2   = "+rs.getString("CD12"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("CD2_2   = "+rs.getString("CD22"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("CD2_1   = "+rs.getString("CD21"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("PROJP1  = "+rs.getString("PROJP1"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("PROJP3  = "+rs.getString("PROJP3"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("PV2_1   = "+rs.getString("PV21"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("PV2_2   = "+rs.getString("PV22"),true);
            } catch (SQLException se) {
            } 
            try {
                fc.putFits("PV2_3   = "+rs.getString("PV23"),true);
            } catch (SQLException se) {
            } 
    
    
            
 
 
            //int noCards=fc.getNcard();
            //System.out.println("cards: "+noCards);
            
        return fc;
        
    }

}
