import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.text.DecimalFormat; /** * @author Maggie Leber K3XS */ public class QRZdata { URL u; String content; String call; String[] parse; String[] fields; static DecimalFormat df = new DecimalFormat("00.00"); static DecimalFormat df2 = new DecimalFormat("000"); float lat, lon; /** * Connect to the QRZ website and request the detail page * for this callsign */ public QRZdata(String call) throws IOException, MalformedURLException { this.call = call; u = new URL("http://www.qrz.com/detail/" + call); BufferedReader r = new BufferedReader( new InputStreamReader((InputStream) u.getContent())); content = ""; while (content != null) { if (content.indexOf("Coordinates:") != -1) // is this the location? { parse = content.split(""); // break out the fields delimited by ... for (int i = 0; i < parse.length; i++) { if (i == 3) // this is the line we want { fields = parse[i].split("( )+"); lat = Float.parseFloat(fields[0]); lon = 0 - Float.parseFloat(fields[1]); } }; } content = r.readLine(); } } /** * return this callsign as an XASTIR APRS object * */ public String getAPRSObject() { return ( ";" + call + " ".substring(0, 9 - call.length()) + "*272000z" + // use a timestamp close to your XASTIR runtime (int) Math.floor(lat) + df.format(((lat - Math.floor(lat)) * 60)) + "N/" + df2.format((int) Math.floor(lon)) + df.format(((lon - Math.floor(lon)) * 60)) + "Wy"); }; }