Example #1
0
 public VOTableWrapper(VOTABLE v)
 {
     vot              = v;
     ActiveTable      = 0;
     dataTypes        = VOTableUtil.getdataTypeTable();
     dataTypesReverse = VOTableUtil.getdataTypeTableReverse();
 }
Example #2
0
        public static VOTABLE Wrapper2VOTable(DataWrapper dw)
        {
            if (dw is VOTableWrapper)
            {
                return(((VOTableWrapper)dw).vot);
            }
            VOTABLE vot = new VOTABLE();

            vot.version          = VOTABLEVersion.Item11;
            vot.RESOURCE         = new RESOURCE[1];
            vot.RESOURCE[0]      = new RESOURCE();
            vot.RESOURCE[0].type = RESOURCEType.results;
            int ntbl = dw.TableCount;

            vot.RESOURCE[0].TABLE = new TABLE[ntbl];
            vot.INFO = new INFO[ntbl];
            Hashtable dataTypes = VOTableUtil.getdataTypeTable();

            for (int t = 0; t < ntbl; t++)
            {
                dw.ActiveTable                 = t;
                vot.INFO[t]                    = new INFO();
                vot.INFO[t].name               = "rowcount, table " + t;
                vot.INFO[t].value              = "" + dw.RowCount;
                vot.RESOURCE[0].TABLE[t]       = new TABLE();
                vot.RESOURCE[0].TABLE[t].Items = new object[dw.ColCount];
                for (int c = 0; c < dw.ColCount; c++)
                {
                    vot.RESOURCE[0].TABLE[t].Items[c] = new FIELD();
                    ((FIELD)vot.RESOURCE[0].TABLE[t].Items[c]).name = dw.ColName(c);
                    try
                    {
                        ((FIELD)vot.RESOURCE[0].TABLE[t].Items[c]).datatype = (dataType)dataTypes[dw.MSColType(c)];
                    }
                    catch
                    {
                        //if type does not exist, cast into char
                        ((FIELD)vot.RESOURCE[0].TABLE[t].Items[c]).datatype = dataType.@char;
                    }
                }
                TABLEDATA data = new TABLEDATA();
                data.TR = new TR[dw.RowCount];
                for (int r = 0; r < data.TR.Length; r++)
                {
                    data.TR[r]    = new TR();
                    data.TR[r].TD = new TD[dw.ColCount];
                    for (int c = 0; c < data.TR[r].TD.Length; c++)
                    {
                        data.TR[r].TD[c]         = new TD();
                        data.TR[r].TD[c].Text    = new string[1];
                        data.TR[r].TD[c].Text[0] = dw[r, c].ToString();
                    }
                }
                vot.RESOURCE[0].TABLE[t].DATA      = new DATA();
                vot.RESOURCE[0].TABLE[t].DATA.Item = data;
            }
            return(vot);
        }
Example #3
0
        public VOTABLE ConeSearch(DataSet ds)
        {
            try
            {
                //Hashtable ucds = FetchUCDS(ds, cjobs);
                VOTABLE vot = VOTableUtil.DataSet2VOTable(ds);
                vot.DESCRIPTION = new anyTEXT();
                vot.RESOURCE[0].TABLE[0].Items = new object[ds.Tables[0].Columns.Count + 3];
                Hashtable votypes = VOTableUtil.getdataTypeTable();
                PARAM     p       = new PARAM();
                p.name     = "inputRA";
                p.datatype = (dataType)votypes[typeof(System.Single)];
                p.value    = this.ra.ToString();
                p.unit     = "degrees";
                vot.RESOURCE[0].TABLE[0].Items[0] = p;
                p          = new PARAM();
                p.name     = "inputDEC";
                p.datatype = (dataType)votypes[typeof(System.Single)];
                p.unit     = "degrees";
                p.value    = this.dec.ToString();
                vot.RESOURCE[0].TABLE[0].Items[1] = p;
                p          = new PARAM();
                p.name     = "inputSR";
                p.datatype = (dataType)votypes[typeof(System.Single)];
                p.unit     = "degrees";
                p.value    = this.sr.ToString();
                vot.RESOURCE[0].TABLE[0].Items[2] = p;

                vot.DESCRIPTION.Any = new System.Xml.XmlNode[1];
                XmlDocument doc = new XmlDocument();
                vot.DESCRIPTION.Any[0]           = doc.CreateTextNode("DESCRIPTION");
                vot.DESCRIPTION.Any[0].InnerText = "ConeSearch results from the Sloan Digital Sky Survey";
                //vot.RESOURCE[0].Items[ind] = p;

                for (int x = 0; x < ds.Tables[0].Columns.Count; x++)
                {
                    DataColumn col = ds.Tables[0].Columns[x];
                    FIELD      f   = new FIELD();
                    f.datatype = (dataType)votypes[col.DataType];
                    f.ID       = fix(col.ColumnName);
                    //f.ucd = ucds[fix(col.ColumnName)] != null ? ucds[fix(col.ColumnName)].ToString() : "UNKNOWN";
                    vot.RESOURCE[0].TABLE[0].Items[x + 3] = f;
                }

                return(vot);
            }
            catch (Exception exp)
            {
                throw new Exception(exp.Message);
            }
        }
        public VOTABLE ConeSearch(System.Double ra, System.Double dec, System.Double sr)
        {
            CJobsTARGET = (HttpContext.Current.Request.RequestContext.RouteData.Values["anything1"] as string).ToUpper().Replace("CONE", "");

            VOTABLE v;

            if (!valid_input(ra, dec, sr))
            {
                throw new Exception(" Wrong input parameters ");
            }

            sr *= 60.0; // in arcminutes because dbo.fGetNearbyObjEq requires  arcminutes ;

            StringBuilder qry = new StringBuilder();

            qry.Append("select " + ConeSelect);
            qry.Append("  from PhotoPrimary p, dbo.fGetNearbyObjEq(" + ra + "," + dec + "," + sr + ") n");
            qry.Append("  where p.objId=n.objId");

            sr /= 60.0; // back to degrees as the ervices requieres;

            JobsSoapClient cjobs = new JobsSoapClient();
            //cjobs.Url = CJobsURL;

            DataSet   ds   = cjobs.ExecuteQuickJobDS(CJobsWSID, CJobsPasswd, qry.ToString(), CJobsTARGET, "FOR CONESEARCH", false);
            Hashtable ucds = FetchUCDS(ds, cjobs);
            VOTABLE   vot  = VOTableUtil.DataSet2VOTable(ds);

            vot.DESCRIPTION = new anyTEXT();
            // = "ConeSearch results from the Sloan Digital Sky Survey ";
            vot.RESOURCE[0].TABLE[0].Items = new object[ds.Tables[0].Columns.Count + 3];
            Hashtable votypes = VOTableUtil.getdataTypeTable();
            PARAM     p       = new PARAM();

            p.name     = "inputRA";
            p.datatype = (dataType)votypes[typeof(System.Single)];
            p.value    = ra.ToString();
            p.unit     = "degrees";
            vot.RESOURCE[0].TABLE[0].Items[0] = p;
            p          = new PARAM();
            p.name     = "inputDEC";
            p.datatype = (dataType)votypes[typeof(System.Single)];
            p.unit     = "degrees";
            p.value    = dec.ToString();
            vot.RESOURCE[0].TABLE[0].Items[1] = p;
            p          = new PARAM();
            p.name     = "inputSR";
            p.datatype = (dataType)votypes[typeof(System.Single)];
            p.unit     = "degrees";
            p.value    = sr.ToString();
            vot.RESOURCE[0].TABLE[0].Items[2] = p;

            vot.DESCRIPTION.Any = new System.Xml.XmlNode[1];
            XmlDocument doc = new XmlDocument();

            vot.DESCRIPTION.Any[0] = doc.CreateTextNode("DESCRIPTION");

            vot.DESCRIPTION.Any[0].InnerText = "ConeSearch results from the Sloan Digital Sky Survey " + CJobsTARGET;

            //vot.RESOURCE[0].Items[ind] = p;

            for (int x = 0; x < ds.Tables[0].Columns.Count; x++)
            {
                DataColumn col = ds.Tables[0].Columns[x];
                FIELD      f   = new FIELD();
                f.datatype = (dataType)votypes[col.DataType];
                f.ID       = fix(col.ColumnName);
                f.ucd      = ucds[fix(col.ColumnName)] != null ? ucds[fix(col.ColumnName)].ToString() : "UNKNOWN";
                vot.RESOURCE[0].TABLE[0].Items[x + 3] = f;
            }

            return(vot);
        }