Created
November 21, 2010 21:00
-
-
Save ussjoin/709152 to your computer and use it in GitHub Desktop.
Ham Radio Visualization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.opengl.*; | |
HashMap<String, String> date = new HashMap<String, String>(); | |
HashMap<String, String> license = new HashMap<String, String>(); | |
HashMap<String, Integer> zip = new HashMap<String, Integer>(); | |
float[][] ziplookup = new float[100000][2]; | |
int[] zipbucket = new int[100000]; | |
void setup() | |
{ | |
noLoop(); | |
size(800, 600, OPENGL); | |
String[] parts; | |
String[] lines; | |
String l; | |
//To pull from files | |
//AD: FRN in [2], Date of Action in [10] | |
//AM: FRN in [2], License Class in [5] | |
//EN: FRN in [2], ZIP Code in [18] | |
//zipcode: ZIP in [0], lat in [3], lon in [4] (Remove quotes from everything) | |
// lines = loadStrings("AD.dat"); | |
// for (int i=0; i<lines.length; i++) | |
// { | |
// l = lines[i]; | |
// parts = split(l, '|'); | |
// date.put(parts[2], parts[10]); | |
// } | |
// System.out.println("Done with AD."); | |
// lines = loadStrings("AM.dat"); | |
// for (int i=0; i<lines.length; i++) | |
// { | |
// l = lines[i]; | |
// parts = split(l, '|'); | |
// license.put(parts[2], parts[5]); | |
// } | |
// System.out.println("Done with AM."); | |
lines = loadStrings("EN.dat"); | |
for (int i=0; i<lines.length; i++) | |
{ | |
l = lines[i]; | |
parts = split(l, '|'); | |
try | |
{ | |
zipbucket[Integer.parseInt(parts[18].substring(0,5))] += 1; | |
} | |
catch (NumberFormatException e) {} | |
catch (StringIndexOutOfBoundsException e) {} | |
} | |
System.out.println("Done with EN."); | |
lines = loadStrings("zipcode.csv"); | |
for (int i=1; i<lines.length; i++) | |
{ | |
l = lines[i]; | |
parts = split(l, ','); | |
if (parts.length >= 5) | |
{ | |
String z = parts[0]; | |
String lat = parts[3]; | |
String lon = parts[4]; | |
z = z.substring(1,z.length()-1); | |
lat = lat.substring(1,lat.length()-1); | |
lon = lon.substring(1,lon.length()-1); | |
float[] arr = new float[2]; | |
arr[0] = Float.parseFloat(lat); | |
arr[1] = Float.parseFloat(lon); | |
ziplookup[Integer.parseInt(z)] = arr; | |
} | |
} | |
} | |
void draw() | |
{ | |
background(0); | |
stroke(#ffffff); | |
fill(#ffffff); | |
for (int i=0; i<zipbucket.length; i++) | |
{ | |
int num = zipbucket[i]; | |
if (num > 0) | |
{ | |
float[] coord = ziplookup[i]; | |
float x = map(coord[1], -68, -125, width, 0); | |
float y = map(coord[0], 25, 50, height, 0); | |
//point(x, y); | |
//ellipse(x, y, num, num); | |
//ellipse(x, y, log(num), log(num)); | |
//ellipse(x, y, log(log(num)), log(log(num))); | |
stroke(lerpColor(#ffffff, #ff0000, num/20.0)); | |
ellipse(x, y, 1, 1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment