import voclient.*; import dalclient.*; /** */ public class skyportal1 { private static final double DEF_RA = 16.031; private static final double DEF_DEC = -0.891; public static void main(String args[]) throws Exception { double ra = DEF_RA, dec = DEF_DEC; int arg = 0; if (args.length == 0) { // Built-in no-args unit test. } else if (args.length >= 3) { ra = Double.parseDouble(args[arg++]); dec = Double.parseDouble(args[arg++]); } else { System.out.println ("Usage: skyportal1 ra dec"); System.exit(1); } querySkyPortal (ra, dec); // make the query } /** Simple test routine to query a SkyPortal and summarize results. */ static void querySkyPortal (double ra, double dec) throws Exception { String qry = " SELECT o.objId, o.ra,o.dec, o.type,t.objId,t.j_m,o.z " + " FROM SDSS:PhotoPrimary o, " + " TWOMASS:PhotoPrimary t WHERE XMATCH(o,t)<2.5 " + " AND Region('Circle J2000 " + ra + " " + dec + " .10') " + " AND( o.z- t.j_m)>1 " ; // Get a new connection to the service. VOCSkyPortal sp = new VOCSkyPortal (qry); // Execute the query and fetch results. sp.executeCSV(); QueryResponse qr = sp.execute(); if (qr.getRecordCount() <= 0) { System.out.println("no records found"); System.exit(1); } // Summarize query response. { int nrec = qr.getRecordCount(); QueryRecord r = qr.getRecord(0); int nattr = (r != null) ? r.getAttributeCount() : 0; System.out.println("# returns " + nrec + " records containing " + nattr + " attributes each"); System.out.println("# --- Summary output ---"); } // Summarize and print selected query results. for (int i=0; i < qr.getRecordCount(); i++) { QueryRecord r = qr.getRecord(i); String s_id, s_ra, s_dec, s_class; QRAttribute v; s_id = ((v = r.getAttribute("sdss_objid")) != null) ? v.stringValue() : ""; s_ra = ((v = r.getAttribute("sdss_ra")) != null) ? v.stringValue() : ""; s_dec = ((v = r.getAttribute("sdss_dec")) != null) ? v.stringValue() : ""; s_class = ((v = r.getAttribute("sdss_type")) != null) ? v.stringValue() : ""; System.out.println("id=" + s_id + "\tra=" + s_ra + "\tdec=" + s_dec + "\tclass=" + s_class); } } }