public void LoadFromXML(XmlDocument xml) { XmlNode voTable = Util.SelectSingleNode(xml, "VOTABLE"); if (voTable == null) { return; } int index = 0; try { XmlNode table = Util.SelectSingleNode(Util.SelectSingleNode(voTable, "RESOURCE"), "TABLE"); if (table != null) { foreach (XmlNode node in table.ChildNodes) { if (node.Name == "FIELD") { VoColumn col = new VoColumn(node, index++); Columns[col.Name] = col; Column.Add(col); } } } } catch { error = true; errorText = Util.SelectSingleNode(voTable, "DESCRIPTION").InnerText.ToString(); } try { XmlNode tableData = Util.SelectSingleNode(Util.SelectSingleNode(Util.SelectSingleNode(Util.SelectSingleNode(voTable, "RESOURCE"), "TABLE"), "DATA"), "TABLEDATA"); if (tableData != null) { foreach (XmlNode node in tableData.ChildNodes) { if (node.Name == "TR") { VoRow row = new VoRow(this); row.ColumnData = new object[Columns.Count]; index = 0; foreach (XmlNode child in node.ChildNodes) { if (child.Name == "TD") { row.ColumnData[index++] = Util.GetInnerText(child).Trim(); } } Rows.Add(row); } } } } catch { } }
public VoColumn GetDistanceColumn() { foreach (string key in Columns.Keys) { VoColumn col = Columns[key]; if (col.Ucd.ToLowerCase().IndexOf("pos.distance") > -1 || col.Ucd.ToLowerCase().IndexOf("pos_distance") > -1) { return(col); } } return(null); }
public VoColumn GetColumnByUcd(string ucd) { foreach (string key in Columns.Keys) { VoColumn col = Columns[key]; if (col.Ucd.Replace("_", ".").ToLocaleLowerCase().IndexOf(ucd.ToLocaleLowerCase()) > -1) { return(col); } } return(null); }
public VoColumn GetMagColumn() { foreach (string key in Columns.Keys) { VoColumn col = Columns[key]; if (col.Ucd.ToLowerCase().IndexOf("phot.mag") > -1 || col.Ucd.ToLowerCase().IndexOf("phot_mag") > -1) { return(col); } } return(null); }
public override string ToString() { StringBuilder sb = new StringBuilder(); bool first = true; // Copy header foreach (string key in Columns.Keys) { VoColumn col = Columns[key]; if (first) { first = false; } else { sb.Append("\t"); } sb.Append(col.Name); } sb.AppendLine(""); // copy rows foreach (VoRow row in Rows) { first = true; foreach (object col in row.ColumnData) { if (first) { first = false; } else { sb.Append("\t"); } sb.Append(col.ToString()); } sb.AppendLine(""); } return(sb.ToString()); }
public VoColumn GetDecColumn() { foreach (string key in Columns.Keys) { VoColumn col = Columns[key]; if (col.Ucd.ToLowerCase().IndexOf("pos.eq.dec") > -1 || col.Ucd.ToLowerCase().IndexOf("pos_eq_dec") > -1) { return(col); } } foreach (string key in Columns.Keys) { VoColumn col = Columns[key]; if (col.Name.ToLowerCase().IndexOf("dec") > -1) { return(col); } } return(null); }