summaryrefslogtreecommitdiff
path: root/parsecalldata.pde
diff options
context:
space:
mode:
authorgit@eclectronics.org <git@eclectronics.org@eclectronics.org>2012-02-06 22:31:12 +0000
committergit@eclectronics.org <git@eclectronics.org@eclectronics.org>2012-02-06 22:31:12 +0000
commit0112f6b9c24746c126e3f2a02997b3809d501579 (patch)
tree15e6a2f44b57fb80d6ebdc36d76dc94b39528e11 /parsecalldata.pde
parent5e660544d27b2eec9e133e44c9f10c0cf0a51664 (diff)
trying great circles: seems to be an error
Diffstat (limited to 'parsecalldata.pde')
-rw-r--r--parsecalldata.pde62
1 files changed, 49 insertions, 13 deletions
diff --git a/parsecalldata.pde b/parsecalldata.pde
index 0406194..4247041 100644
--- a/parsecalldata.pde
+++ b/parsecalldata.pde
@@ -1,39 +1,75 @@
//BT IRELAND MTM,Destination CID Name,VIA,Calls,MINS,ALOC,% User,ASR,NER 02
+boolean DEBUG=false;
class country {
String name;
float calls,mins;
- country(String n,String c,String m){
+ RShape outline;
+ country(String n,float c,float m,RShape shp){
name=n;
- calls=Float.valueOf(c.trim()).floatValue();
- mins=Float.valueOf(m.trim()).floatValue();
+ calls=c;
+ mins=m;
+ outline=shp;
}
- void addnetwork(String c,String m) {
- calls+=Float.valueOf(c.trim()).floatValue();
- mins+=Float.valueOf(m.trim()).floatValue();
+ void addnetwork(float c,float m) {
+ calls+=c;
+ mins+=m;
}
void printOut() {
println(name+" "+calls+" "+mins);
}
+ RPoint getpoint(int tries){
+ RPoint tl=outline.getTopLeft();
+ RPoint br=outline.getBottomRight();
+ RPoint np= new RPoint(0,0);
+ int searching =1;
+ while (searching>0&&searching<tries) {
+ np=new RPoint(random(tl.x,br.x),random(tl.y,br.y));
+ if(outline.contains(np)) searching=0;
+ if (DEBUG) println(name+"; try "+searching+": "+np.x+","+np.y+" bounds: "+tl.x+","+tl.y+" - "+br.x+","+br.y+": "+(searching>0));
+ if (searching==10||searching==100||searching==1000||searching==10000||searching==100000) {
+ println(name+"; try "+searching+": MISS at "+np.x+","+np.y+" bounds: "+tl.x+","+tl.y+" - "+br.x+","+br.y);
+ }
+ }
+ if (searching==0) return np;
+ else return new RPoint(0,0);
+ }
}
class calldata {
Vector<country> countries = new Vector<country>();
- calldata(String[][] data) {
+ HashMap<String, Integer> outlines = new HashMap<String, Integer>();
+ calldata(String[][] data,RShape shp) {
+
+ for (int i=0;i<shp.children.length;i++) {
+ outlines.put(shp.children[i].name.substring(0, 3),i);
+ }
+
println("parsing "+data.length+" entries");
//detect number of countries
int num=0;
- countries.add(new country(data[0][1],"0","0"));
+ if (outlines.containsKey(data[0][1].substring(0, 3))) {
+ countries.add(new country(data[0][1],0,0,shp.children[outlines.get(data[0][1].substring(0, 3))]));
+ }
+
for (int i=0; i < data.length; i++) {
- if (data[i][1].substring(0, 2).equals(countries.lastElement().name.substring(0, 2))) {
- countries.lastElement().addnetwork(data[i][3],data[i][4]);
+ if (data[i][1].substring(0,3).equals(countries.lastElement().name.substring(0, 3))) {
+ countries.lastElement().addnetwork(Float.valueOf(data[i][3].trim()).floatValue(),Float.valueOf(data[i][4].trim()).floatValue());
}
+
else {
- countries.lastElement().printOut();
- countries.add(new country(data[i][1],data[i][3],data[i][4]));
+ if (outlines.containsKey(data[i][1].substring(0, 3))) {
+ countries.add(new country(data[i][1],Float.valueOf(data[i][3].trim()).floatValue(),Float.valueOf(data[i][4].trim()).floatValue(),shp.children[outlines.get(data[i][1].substring(0, 3))]));
+ }
}
}
+ for (int i=0; i < countries.size(); i++) {
+ countries.get(i).printOut();
+ }
+
+ }
+ country getcountry(int w) {
+ return countries.get(w);
}
-
}